';// this div contains all the body tiers and is used in page swaps if(USER_IS_LOGGED_IN==1)require_once 'jensiis/insert.PHP.markers.inc.php'; if(WEBPAGE_ITEMDEF_ID!=0){// get a section header if one exists // get the item section header code if a section exists $sectionHeader=false; if(WEBPAGE_SAVED_VERSION=='1'){ $sectionHeader=ZDEF_PATH_TO_SUBDOMAIN.'saved/'.WEBPAGE_ITEM_TYPE.'/'.WEBPAGE_ITEM_TYPE.'.section.header.inc.php'; if(!file_exists($sectionHeader))$sectionHeader=false; } if(!$sectionHeader)$sectionHeader=ZDEF_PATH_TO_SUBDOMAIN.'published/'.WEBPAGE_ITEM_TYPE.'/'.WEBPAGE_ITEM_TYPE.'.section.header.inc.php'; if(file_exists($sectionHeader)){ //if(USER_IS_LOGGED_IN==1){$webpageHTML=file_get_contents($sectionHeader);$webpageHTML=insertPHPMarkers($webpageHTML);eval('?'.'>'.$webpageHTML.'<'.'?');}else{ DO NOT have any PHP in section headers until you figure out how to keep phpinsert numbers from starting at 1 again for the page body require $sectionHeader; } } if(USER_IS_LOGGED_IN==1){ $webpageHTML=file_get_contents($webpage);// $webpageHTML will be defined in zztest IF we are in the publisher doing a Rollback. HTML usually comes from the flat file in /published. $webpageHTML=insertPHPMarkers($webpageHTML); eval('?'.'>'.$webpageHTML.'<'.'?');// we can use eval because php snippets do not contain any user-provided code. All code that is not php snippet can be eval'd because HTML purifier escapes any php markers < ? ? > }else{ require $webpage; } if(WEBPAGE_ITEMDEF_ID!=0 && WEBPAGE_IS_ITEM_INDEX!=1){// get a section footer if one exists and if we aren't on the itemindex $sectionFooter=false; if(WEBPAGE_SAVED_VERSION=='1'){ $sectionFooter=ZDEF_PATH_TO_SUBDOMAIN.'saved/'.WEBPAGE_ITEM_TYPE.'/'.WEBPAGE_ITEM_TYPE.'.section.footer.inc.php'; if(!file_exists($sectionFooter))$sectionFooter=false; } if(!$sectionFooter)$sectionFooter=ZDEF_PATH_TO_SUBDOMAIN.'published/'.WEBPAGE_ITEM_TYPE.'/'.WEBPAGE_ITEM_TYPE.'.section.footer.inc.php'; if(file_exists($sectionFooter)){ //if(USER_IS_LOGGED_IN==1){$webpageHTML=file_get_contents($sectionFooter);$webpageHTML=insertPHPMarkers($webpageHTML);eval('?'.'>'.$webpageHTML.'<'.'?');}else{ DO NOT have any PHP in section headers until you figure out how to keep phpinsert numbers from starting at 1 again for the page body require $sectionFooter; } } $requestForSQLOnly=false;// we're just doing housekeeping here echo '
'; // close b_ if(!ZDEF_AJAX_PAGE_LOAD){ if(!WEBPAGE_IS_LANDING_PAGE && ZDEF_NOIMGS!==1){ // ZDEF_NOIMGS is a flag used when resizing browser to get coerced .img_ sizes so we don't need images and we don't need a footer because footers have no coerced images ){ $foot=ZDEF_PATH_TO_SUBDOMAIN.'gbl/foot.inc.php'; if(!file_exists($foot)){ $foot=ZDEF_PATH_TO_LIBRARY.'webpages/gbl/foot.inc.php'; } if(!file_exists($foot))errorMessage('Footer not Found: '.$foot); include $foot; if(ORG_PRIVACY_POPUP!=='')require ZDEF_PATH_TO_SUBDOMAIN.'published/'.ORG_PRIVACY_POPUP; } echo '
'; if(USER_IS_LOGGED_IN==1){ echo '
'; dbSel($db,ZDEF_DATA_DB_NAME,'ssv21a');// select the 'data' data base require ZDEF_PATH_TO_LIBRARY.'jensiis/jensiis.controls.inc.php'; require ZDEF_PATH_TO_LIBRARY.'jensiis/resource.panel.inc.php'; echo '
'; } }?> loadHTML($output); $xpath = new DomXPath($doc); require_once('WPC.widget.definitions.inc.php'); function uStartsWith($a){ foreach($a as $class){ if (strpos($class, 'u') === 0){ if(is_numeric(substr(str_replace('_','',$class),1)))return $class; } } return ''; } //=================== LOOK FOR OPENGRAPH and TITLE/DESCRIPTION information embedded in generated page (e.g. obituaries) //$expression = './/*[starts-with(name(@*),"data_")]'; //$expression = './/div[@id='..' or @class=']'; $expression = '//*[@data_ogurl or @data_ogtitle or @data_ogimg]'; $nodes = $xpath->query($expression); // this data overrides the constants set in zztest because it is defined first foreach($nodes as $node){ foreach( $node->attributes as $attr ){ if( $attr->nodeName !='class' && $attr->nodeName != 'id' ){ $dataName=$attr->nodeName; $value=$attr->nodeValue; if($dataName=='data_ogtitle'){define('WEBPAGE_OG_TITLE',$value);define('WEBPAGE_TITLE',$value);} if($dataName=='data_ogimg')define('WEBPAGE_OG_IMAGE',$value); if($dataName=='data_ogurl')define('WEBPAGE_OG_URL',$value); } } } //echo '

WEBPAGE_OG_TITLE '.WEBPAGE_OG_TITLE; //echo '
WEBPAGE_OG_IMAGE '.WEBPAGE_OG_IMAGE; //echo '
WEBPAGE_OG_URL '.WEBPAGE_OG_URL; $requiredWidgets=[];// these are all the widgets required, regardless if they have been loaded or not if(isset($cln_wdg)&&!empty($cln_wdg)){// $cln_wdg will only be set on an AJAX request // we allow the client to send cln_wdg parms, very useful in dealing with multi-step processes like stripe payment processing. Add to $requiredWidgets $requiredWidgets=explode(' ',$cln_wdg); } // ******************* THIS IS A START ON JUST GETTING ALL ELEMENTS, RATHER THAN WPC DEFINED CLASSES ********************** /*$nodes = $xpath->query('//*'); //all elements $a=[]; foreach($nodes as $node){ $classList=$node->attributes->getNamedItem('class')->nodeValue; $b=explode(' ',$classList); $a=array_merge($a,$b); } $a=array_unique($a); die; */ foreach($possibleWidgets as $widgetClass){ // we look for all the required classes whether we've loaded them or not. This way we can put out new styles based on attributes even though we've already sent general styles based on class e.g. .ss_ if(strpos($widgetClass,'*')!==false){ // if a classname contans * then take all classes containing the class $startsWith=(substr($widgetClass,0,1)=='*')?true:false; $classPattern=str_replace('*','',$widgetClass); if($startsWith){ $expression = './/*[contains(concat(normalize-space(@class), " "), "'.$classPattern.' ")]'; }else{ $expression = './/*[contains(concat(" ", normalize-space(@class)), " '.$classPattern.'")]'; } ////////////////////$classPattern=substr($widgetClass,0,strlen($widgetClass)-1); $nodes = $xpath->query($expression); $temp_dom = new DOMDocument(); foreach($nodes as $node){ $classList=$node->attributes->getNamedItem('class')->nodeValue; $id=$node->attributes->getNamedItem('id')->nodeValue; $tag=$node->nodeName; $parentNode=$node->parentNode->nodeName; $parentClass=$node->parentNode->attributes->getNamedItem('class')->nodeValue; $classNames=explode(' ',$classList); $attributes=[]; $ancestorClasses=[]; $ancestorNode=$node->parentNode; while($ancestorNode){ if($ancestorNode->attributes==null)break; $ancestorClasses[]=' '.$ancestorNode->attributes->getNamedItem('class')->nodeValue.' '; if($parentNode->nodeName=='body')break; $ancestorNode=$ancestorNode->parentNode; } foreach($classNames as $className){ if( ($startsWith && substr($className,-strlen($classPattern))==$classPattern) || (!$startsWith && substr($className,0,strlen($classPattern))==$classPattern) ){ $widgetName=$className; $color=getClass($node,'c9_',false); $background=getClass($node,'bg_',false); $framework=getClass($node,'u2',true); $inheritColor=getClass($node,'c9_',true); $inheritBackground=getClass($node,'bg_',true); if($className=='mn_'){ if($color)$widgetName.='.c9_'.$color; elseif($inheritColor)$widgetName.='attributes as $attr ){ if( $attr->nodeName !='class' && $attr->nodeName != 'id' ){ $attributes[$attr->nodeName]=$attr->nodeValue; } } if(substr($widgetName,0,4)=='mxw_' && in_array('i',$classNames)) $widgetName='.i.'.$widgetName; // the styling on a .i .mxw_??? is different than on a .mxw_ not .i $requiredWidgets[$widgetName]=array('classList'=>$classList,'id'=>$id,'tag'=>$tag,'parentNode'=>$parentNode,'parentClass'=>$parentClass,'framework'=>$framework,'ancestorClasses'=>$ancestorClasses,'color'=>$color,'inheritColor'=>$inheritColor,'bg'=>$background,'inheritBg'=>$inheritBackground,'attributes'=>$attributes); //$requiredWidgets[$widgetName]['ancestorClasses']=$ancestorClasses; } } } }else{ // looking for a specific class $expression = './/*[contains(concat(" ", normalize-space(@class), " "), " '.$widgetClass.' ")]'; $nodes = $xpath->query($expression); foreach($nodes as $node){ $className=' '.$node->attributes->getNamedItem('class')->nodeValue.' '; $id=$node->attributes->getNamedItem('id')->nodeValue; $tag=$node->nodeName; $parentNode=$node->parentNode->nodeName; $parentClass=$node->parentNode->attributes->getNamedItem('class')->nodeValue; $attributes=[]; foreach( $node->attributes as $attr ){ if( $attr->nodeName !='class' && $attr->nodeName != 'id' ){ $attributes[$attr->nodeName]=$attr->nodeValue; } } $maxWidth=false; if(strpos($className, ' i ') !== false && (strpos($className, ' w_xe')!=false || strpos($className, ' w_fe')!=false)){ $a=explode('w_xe',$className); if(count($a)>1)$maxWidth=explode(' ',$a[1])[0]; $a=explode('w_fe',$className); if(count($a)>1)$maxWidth=explode(' ',$a[1])[0]; } if(strpos($className, ' img_ ') !== false && (strpos($className, ' w_xe')!=false || strpos($className, ' w_fe')!=false)){ $a=explode('w_xe',$className); if(count($a)>1)$maxWidth=explode(' ',$a[1])[0]; $a=explode('w_fe',$className); if(count($a)>1)$maxWidth=explode(' ',$a[1])[0]; } if( $node->nodeName=='ul' && ( strpos($className, ' ind1 ') !== false || strpos($className, ' ind2 ') !== false || strpos($className, ' ind3 ') !== false || strpos($className, ' ind4 ') !== false) ){ $requiredWidgets['ind']=array('classList'=>$className,'id'=>$id,'tag'=>$tag); } if( $node->nodeName=='ul' && strpos($className, ' tbr_ ')!== false ){ /* table breakpoint */ $a=explode(' tbr_',$className); if($a[1]){ $a=explode(' ',$a[1]); $breakpoint=$a[0]; if(empty($breakpoint))$breakpoint='40';// default to 40 ems breakpoint if tbr_?? not specified } $requiredWidgets['tbr_'.$breakpoint]=array('classList'=>$className,'id'=>$id,'tag'=>$tag); } $requiredWidgets[$widgetClass]=array('classList'=>$className,'id'=>$id,'tag'=>$tag,'parentNode'=>$parentNode,'parentClass'=>$parentClass,'color'=>getClass($node,'c9_',false),'inheritColor'=>getClass($node,'c9_',true),'bg'=>getClass($node,'bg_',false),'inheritBg'=>getClass($node,'bg_',true),'attributes'=>$attributes,'maxWidth'=>$maxWidth); } } } function uClassNumber($node){ // returns the portion of pagewidth occupied by the node. e.g. u2 u2 =.25, u2 u3 =.1666, or .u2 .x_.fbs_60 = .6. //We were going to use this to determine what width image to send when there is no js, but realized it won't work because we could be 1up. //All we can really do is examine max-width on .i or .img_, and maybe figure out if the node is constrained by the max-width on f. Otherwise, we're hooped. $framework=1; while($node->nodeName!='body'){ try{$classList=$node->attributes->getNamedItem('class')->nodeValue;}catch (Exception $e){return round($framework,4);} $a=explode(' fbs_',' '.$classList.' '); if(isset($a[1])){ $class=explode(' ',$a[1])[0]; $framework=$framework*$class/100; $node=$node->parentNode;// flex basis is on the x_, so this 'skips' the f_ containing it }else{ $a=explode(' u',' '.$classList.' '); if(isset($a[1])){ $class=explode(' ',$a[1])[0]; $framework=$framework*100/$class; } } $node=$node->parentNode; } return round($framework,4); } function getClass($node,$className,$checkParents){ $c=0;// avoid endless loop if html is badly formed $colorClass=false; while($node->nodeName!='body' && $c!=100){ $c++; try{$classList=$node->attributes->getNamedItem('class')->nodeValue;}catch (Exception $e){return false;} $a=explode(' '.$className,' '.$classList.' '); if(isset($a[1])){ $colorClass=explode(' ',$a[1])[0]; break; } if(!$checkParents)break; $node=$node->parentNode; } return $colorClass; } // **** ADD widgets based on the existence of other widgets ***** /// foreach($requiredWidgets as $widgetClass => $value){ if(substr($widgetClass,0,5)==='icon_'){ if(!array_key_exists('icon_',$cln_wgl))$requiredWidgets['icon_']=''; } if(substr($widgetClass,0,2)==='g_'){ if(!array_key_exists('g_',$cln_wgl))$requiredWidgets['g_']=''; //if(!array_key_exists('ix_',$cln_wgl))$requiredWidgets['ix_']=''; NO! specifically place ix_ in classname if you want images expanded } if(array_key_exists('ssv_',$requiredWidgets) && !array_key_exists('frm_',$cln_wgl))$requiredWidgets['frm_']=[]; } $images=[]; $widgetTags=explode(' ','blockquote ul input label form img'); foreach($widgetTags as $widgetTag){ $expression = '//'.$widgetTag; $nodes = $xpath->query($expression); foreach($nodes as $node){ $className=' '.$node->attributes->getNamedItem('class')->nodeValue.' '; if( $node->nodeName=='img' && ZDEF_NOIMGS!==1 ){ // if we're not delivering 1x1.png transparent images //if($node->attributes->getNamedItem('srcset')->nodeValue) $ancestorClasses=[]; $ancestorNode=$node->parentNode; while($ancestorNode){ if($ancestorNode->attributes==null)break; $ancestorClasses[]=trim($ancestorNode->attributes->getNamedItem('class')->nodeValue); $ancestorClasses[]='.';// this is a signal that breaks classNames in the ancestorclasslist so we know if a class is on the same element, or is on a parent if($parentNode->nodeName=='body')break; $ancestorNode=$ancestorNode->parentNode; } $images[]=array( 'src' =>$node->attributes->getNamedItem('src')->nodeValue, 'class' =>$className, 'ancestorClasses'=>implode(' ',$ancestorClasses), 'alt' =>$node->attributes->getNamedItem('alt')->nodeValue, 'width' =>$node->attributes->getNamedItem('width')->nodeValue, 'height' =>$node->attributes->getNamedItem('height')->nodeValue, 'loading' =>$node->attributes->getNamedItem('loading')->nodeValue, 'sizes' =>$node->attributes->getNamedItem('sizes')->nodeValue, 'srcset' =>$node->attributes->getNamedItem('srcset')->nodeValue, ); //print_r($images); } // find any color code on the element, or on a containing element $colorClass='base'; $c=0;$styleRequired=true; while($node->nodeName!='body' && $c!=100){ if(!$requiredWidgets[$widgetTag])$requiredWidgets[$widgetTag]=array('classList'=>$className); $c++; $classList=$node->attributes->getNamedItem('class')->nodeValue; $id=$node->attributes->getNamedItem('id')->nodeValue; $a=explode(' mn_ ',' '.$classList.' '); if(isset($a[1])){$styleRequired=false;break;} // we don't need any ul color styling on mn_ because we pick it up on the color class, since mn_ colors are always on the mn_ element $x=$node->parentNode->attributes->getNamedItem('class')->nodeValue; $a=explode(' ms_ ',' '.$x.' '); if(isset($a[1])){$styleRequired=false;break;} // we don't need any ul color styling on ms_ because we pick it up on the color class, since ms_ colors are always on the mn_ element if(substr($id,0,8)!='cascade_'){ // don't need colors defined for the input#cascade_?? in the cascading menus $a=explode(' c9_',' '.$classList.' '); if(isset($a[1])){ $colorClass=explode(' ',$a[1])[0]; break; } if($widgetTag=='ul'){// this will pick up a colorclass but only if it is set on the ul, no pulling color classes from above the ul because it will inherit anyway break; } } $node=$node->parentNode; } if($styleRequired && !array_key_exists($widget.'.'.$colorClass,$requiredWidgets)){ if($widgetTag=='input' || $widgetTag=='label' || $colorClass != 'base'){ // we don't set base color class on elements that inherit $requiredWidgets[$widgetTag.'.'.$colorClass]=''; } } } } //die; $expression='//*[starts-with(name(@*),"data-")]'; $nodes = $xpath->query($expression); foreach($nodes as $node){ foreach ($node->attributes as $attr) { $name = $attr->nodeName; $value = $attr->nodeValue; define($name,$value); } } $theWidgets=[]; //$requiredWidgets = all widgets needed for this page foreach($requiredWidgets as $key => $value){ if(!in_array($key,$cln_wgl))$theWidgets[$key]=$value; } //print_r($requiredWidgets);echo 'cln_wgl';print_r($cln_wgl);print_r($theWidgets);die; //****************** enhance all code with srcset code ******************************** //echo '===>'.$output.'<==='.str_repeat(' x ',3000);flush();die; function imgSizes($breakpoints){ // sizes defs go from 0 to 40 to 60 to fWidth $lastWidthSpec=false; $lastColWidth=100; $sizes=''; $comma=''; $maxPixWidth=0; $breakCount=count($breakpoints); $i=0; foreach($breakpoints as $breakpoint => $breakSpec){ if($breakSpec['maxWidth'][2]=='f' && $breakSpec['maxWidth'][1]!='p' && $breakSpec['maxWidth'][3]=='single'){ // fixed width image WHERE THERE IS ONLY ONE FIXED WIDTH SPECIFIED $sizes=$breakSpec['maxWidth'][0]; if($breakSpec['maxWidth'][1]=='e')$sizes=round($sizes*STYLE_BASE_FONT_SIZE); $sizes=array($sizes); break; } $fWidthBreak=$breakSpec['maxWidth'][3]=='fWidth'; //if(!$breakSpec['maxWidth'] && !$breakSpec['colWidth']) continue; if($breakSpec['maxWidth'] &&!$fWidthBreak)$lastWidthSpec=array($breakSpec['maxWidth'][0],$breakSpec['maxWidth'][1],$breakSpec['maxWidth'][2]); // save the max width spec. It might not be specified at each breakpoint. Do not save the very last one, as that is the fWidth entry if($breakSpec['colWidth'])$lastColWidth=$breakSpec['colWidth']; // save the column width spec. It might not be specified at each breakpoint if($fWidthBreak){ if($maxPixWidth==0){ $newMax=$breakSpec['maxWidth'][0]*STYLE_BASE_FONT_SIZE; } }else{ $newMax=(max($breakSpec['maxWidth'][1]=='x'?$breakSpec['maxWidth'][0]/STYLE_BASE_FONT_SIZE:$breakSpec['maxWidth'][0],$breakSpec['maxWidth'][0]*$lastColWidth/100))*STYLE_BASE_FONT_SIZE; } if($newMax > $maxPixWidth) $maxPixWidth=$newMax; // this gets us the largest possible width at any breakpoint if(is_array($lastWidthSpec) || $fWidthBreak){ // There has been at least one width specified. The last breakpoint is always fWidth and there is always a width specified. if($fWidthBreak){// we've reached the maximum width on f_ (we won't get this on hero or parallax) if($maxPixWidth==0)$maxPixWidth=ZDEF_MAX_IMAGE_DOWNLOAD_WIDTH; // we're finished evaluating possible sizes. If we don't have any we're on a parallax or hero //echo '
MAX PIX WIDTH '.$maxPixWidth.' lastColumn '.$lastColWidth.' lastWidth ';print_r($lastWidthSpec);print_r($breakSpec['maxWidth']); if(!$lastWidthSpec){ // lastWidthSpec is not set for fWidthBreak, lastWidthSpec would be a width spec before (narrower than) the fWidth $sizes=parseSpec($breakSpec['maxWidth'][1].round($breakSpec['maxWidth'][0]*($lastColWidth/100))).$comma.$sizes; }elseif($lastWidthSpec[1]==$breakSpec['maxWidth'][1]){// last width is same unit as fWidth (ems), no need for a min() $sizes=parseSpec($breakSpec['maxWidth'][1].min($lastWidthSpec[0],round($breakSpec['maxWidth'][0]*($lastColWidth/100)))).$comma.$sizes; //echo '
==========>'.parseSpec($breakSpec[1].min($lastWidthSpec[0],round($breakSpec['maxWidth'][0]*($lastColWidth/100)))).'<==========='; if(parseSpec($breakSpec['maxWidth'][1].min($lastWidthSpec[0],round($breakSpec['maxWidth'][0]*($lastColWidth/100))))==0){ } }else{ if($lastWidthSpec[1]=='p'){ $sizes=parseSpec($breakSpec['maxWidth'][1].round($breakSpec['maxWidth'][0]*($lastColWidth/100) ) ).$comma.$sizes; }else{ $sizes='min('.parseSpec($lastWidthSpec[1].$lastWidthSpec[0]).','.parseSpec($breakSpec['maxWidth'][1].round($breakSpec['maxWidth'][0]*($lastColWidth/100)) ).')'.$comma.$sizes; } } }else{ if($lastWidthSpec[2]=='f' && ( $lastWidthSpec[1] !='p') ){ // if there is a FIXED width specified that's not a percentage, or WidthSpec == ColWidth we don't need min() $sizes=parseSpec($lastWidthSpec[1].$lastWidthSpec[0]).$comma.$sizes; }else{ if($lastWidthSpec[2]=='f' && $lastWidthSpec[1] =='p'){ // one fixed width column and one variable image width. The variable widths are specified for the image $sizes=$lastWidthSpec[0].'vw'.$comma.$sizes; }elseif(parseSpec($lastWidthSpec[0])!='vw'){ $sizes='min('.parseSpec($lastWidthSpec[1].$lastWidthSpec[0]).','.$lastColWidth.'vw)'.$comma.$sizes; } } } }else{// if you don't have a lastWidthSpec, you have a lastColWidth $sizes=$lastColWidth.'vw'.$comma.$sizes; } // add the min-width clause if($breakpoint !== array_key_first($breakpoints))$sizes='(min-width:'.$breakpoint.'em) '.$sizes; //echo '
here 2 '.$sizes;flush(); $comma=','; } if(!$sizes)$sizes='100vw'; //echo $sizes;flush();die; // !!!!!!!! you can use calc in sizes e.g. sizes="(min-width:36em) calc(.333 * 100vw - 12 em), sample for flexible images and fixed side column of 12 em return $sizes; } function buildParallaxSources($src,$plxWidth){ $plxWidth=$plxWidth/100; $breakWidths=[200,425,500,850,1120,1550,2000,2900,ZDEF_MAX_IMAGE_DOWNLOAD_WIDTH]; // mobile: 425, mobile: 2*425, ipad/desktop: 2*768 or 1* 1336, desktop: 1*1920, 2*1440=2900 // 9/19 tall phones, 9/16 most phones, 3:2 Windows laptops, 16:10 Dell XPS and Apple Macbook,16:9 laptops $aspectRatios=['9/19','9/16','5/8','2/3','3/4','1/1','3/2','16/10','16/9','2/1','5/2','3/1','7/2','4/1','5/1','7/1']; $sources=[]; //$ext=ZDEF_BROWSER_ACCEPTS_WEBP?'webp':getExtension($src); $ext=getExtension($src); //if(ZDEF_BROWSER_ACCEPTS_WEBP)$src.='.webp'; foreach($aspectRatios as $i => $ratioTerm){ // REMEMBER!!! the aspect ratio in a source clause is the aspect ratio of the VIEWPORT!!!, not the image $a=explode('/',$ratioTerm); //$a[1]=$a[1]/$plxWidth; //.5 width increases the second part of the aspect ratio by 2 $ratio=$a[1]/$a[0]; $set=[]; $set2=[]; foreach($breakWidths as $j => $width){ //$actualWidth=round($width*$plxWidth); // when a parallax image takes 50% of screen width, then the srcset is generated at half-width $set[]=round($width*$plxWidth).'x'.round($width*$ratio).'/'.$src.' '.$width.'w'; $set2[]=round($width*$plxWidth*2).'x'.round($width*$ratio*2).'/'.$src.' '.$width.'w'; } //print_r($set); // you need to break ''; $sources[]=''; $sources[]=''; } $sources=implode('',$sources); return $sources; } function buildHeroSources($breakpoints,$src,$fxRatio){ // you must use art direction for hero images because their aspect ratio cannot be known and we don't want the browser loading the wrong size // $fxRatio is used until the art direction kicks in, which can be at a viewport width of, say, 40 or 50 em $breakWidths=[200,375,425,850,1250,1550,1900,2200,2400,2900,ZDEF_MAX_IMAGE_DOWNLOAD_WIDTH]; // mobile: 425, mobile: 2*425, ipad/desktop: 2*768 or 1* 13336, desktop: 1*1920, 2*1440=2900 $sources=[]; //$ext=ZDEF_BROWSER_ACCEPTS_WEBP?'webp':getExtension($src); $ext=getExtension($src); //if(ZDEF_BROWSER_ACCEPTS_WEBP)$src.='.webp'; $lastColWidth=100; $lastFixedHeight=0; $firstHeightSpecAtWidth=100000; foreach($breakpoints as $i => $breakSpec){ // add a breakWidth wherever there are height or width changes on the image $w=round($i*STYLE_BASE_FONT_SIZE); if($w!=0 && !in_array($w,$breakWidths)){ $breakWidths[]=$w; } if($breakSpec['fixedHeight'] && ( $breakSpec['fixedHeight'][0]=='e' || $breakSpec['fixedHeight'][0]=='r' )){ // convert to pixels $breakpoints[$i]['fixedHeight']=['x',$breakSpec['fixedHeight'][1]*STYLE_BASE_FONT_SIZE]; if($firstHeightSpecAtWidth==100000)$firstHeightSpecAtWidth=$w;// this is pixel width where the fixed height kicks in. } // get a colWidth and fixedHeight on every breakpoint if($breakSpec['colWidth']){ $lastColWidth=$breakSpec['colWidth']; }else{ $breakpoints[$i]['colWidth']=$lastColWidth; } if($breakSpec['fixedHeight']){ // converted to pixels $lastFixedHeight=$breakpoints[$i]['fixedHeight']; //if($breakSpec['fixedHeight']!=='x')$lastFixedHeight=$breakSpec['fixedHeight']=['x',$lastFixedHeight*STYLE_BASE_FONT_SIZE]; }else{ $breakpoints[$i]['fixedHeight']=$lastFixedHeight; } } sort($breakWidths); foreach($breakWidths as $i => $width){ if($width<=$firstHeightSpecAtWidth){ // we haven't encountered a fixed height for hero yet, just put out the image using its $fxRatio // we're assuming the width of the image is 100%. After all, it's a hero. if($width==$firstHeightSpecAtWidth)$width=$width-1; //$sources[]=''; $sources[]=''; }else{ break; } } rsort($breakWidths); //print_r($breakWidths);flush();die; foreach($breakWidths as $i => $width){ if($i==0)$lastBreakWidth=$width; if($i==0 || $width < $firstHeightSpecAtWidth )continue; // we just created sources for the images narrower than $firstHeightSpecAtWidth $lastFixedHeight=round($i*100*$fxRatio[0],0); foreach($breakpoints as $j => $breakSpec){ if($j*STYLE_BASE_FONT_SIZE>$width)break; //print_r($breakSpec); if($breakSpec['colWidth']) $lastColWidth=$breakSpec['colWidth']/100; if($breakSpec['fixedHeight']){ // converted to pixels $lastFixedHeight=$breakSpec['fixedHeight'][1]; } } // you need to break ''; $sources[]=''; $lastBreakWidth=$width; } $sources=implode('',$sources); return $sources; } function buildCoercedSources($breakpoints,$src,$fxRatio){ // you must use art direction for coerced images because their aspect ratio cannot be known and we don't want the browser loading the wrong size // $fxRatio is used until the art direction kicks in, which can be at a viewport width of, say, 40 or 50 em $breakWidths=[160,320,400,480,560,640,720,800,960,1120,1280,1440]; // breakWidths in ems because that's how breaks are specified, breakWidths only go 2* of 50% width of the framework because coerced images are rarely > 50% of width of fWidth $sources=[]; //$ext=ZDEF_BROWSER_ACCEPTS_WEBP?'webp':getExtension($src); $ext=getExtension($src); //if(ZDEF_BROWSER_ACCEPTS_WEBP)$src.='.webp'; $lastColWidth=100; // percent $lastMaxWidth=0; $lastFixedHeight=0; $firstHeightSpecAtWidth=-1; foreach($breakpoints as $i => $breakSpec){ // add a breakWidth wherever there are height or width changes on the image $w=round($i*STYLE_BASE_FONT_SIZE); if($w!=0 && !in_array($w,$breakWidths)){ $breakWidths[]=$w; } if($breakSpec['fixedHeight'] && ( $breakSpec['fixedHeight'][0]=='e' || $breakSpec['fixedHeight'][0]=='r' )){ // convert to pixels $breakpoints[$i]['fixedHeight']=['x',$breakSpec['fixedHeight'][1]*STYLE_BASE_FONT_SIZE]; if($firstHeightSpecAtWidth === -1)$firstHeightSpecAtWidth=$w;// this is pixel width where the fixed height kicks in. } // get a colWidth and maxWidth and fixedHeight on every breakpoint if($breakSpec['colWidth']){ $lastColWidth=$breakSpec['colWidth']; }else{ $breakpoints[$i]['colWidth']=$lastColWidth; } if($breakSpec['maxWidth']){ if($breakSpec['maxWidth'][1]=='e'){ $lastMaxWidth=$breakSpec['maxWidth'][0]*STYLE_BASE_FONT_SIZE; }elseif($breakSpec['maxWidth'][1]=='x'){ $lastMaxWidth=$breakSpec['maxWidth'][0]; } } if($lastMaxWidth>0){ $breakpoints[$i]['maxWidth'][0]=$lastMaxWidth; $breakpoints[$i]['maxWidth'][1]='x'; // converted to pixels } if($breakSpec['fixedHeight']){ // converted to pixels $lastFixedHeight=$breakpoints[$i]['fixedHeight']; //if($breakSpec['fixedHeight']!=='x')$lastFixedHeight=$breakSpec['fixedHeight']=['x',$lastFixedHeight*STYLE_BASE_FONT_SIZE]; }else{ $breakpoints[$i]['fixedHeight']=$lastFixedHeight; } } sort($breakWidths); foreach($breakWidths as $i => $width){ if($firstHeightSpecAtWidth<$width)break; $imgWidth=$width; // look for any maxwidth at the breakwidth foreach($breakpoints as $i => $breakSpec){ if($width>$breakSpec['breakpointInPixels'] && $breakSpec['maxWidth'][0]){ if($width > $breakSpec['maxWidth'][0]){ $imgWidth=$breakSpec['maxWidth'][0]; } } } // we haven't encountered a fixed height for coerced image yet, just put out the image using its $fxRatio, $maxWidth if($width==$firstHeightSpecAtWidth)$width=$width-1; $sources[]=''; } // iterate through sources backwards and eliminate duplicates $lastSource=''; for($i=count($sources) - 1; $i >= 0; $i--){ $currentSource = explode('srcset=',$sources[$i])[1]; if($lastSource==$currentSource){ $sources[$i]=''; }else{ $lastSource=$currentSource; } } rsort($breakWidths); foreach($breakWidths as $i => $width){ //if($width > $maxWidth) continue; // don't specify images at width greater than fWidth in pixels because image sizes don't change if($i==0)$lastBreakWidth=$width; if($i==0 || $width < $firstHeightSpecAtWidth )continue; // we just created sources for the images narrower than $firstHeightSpecAtWidth $lastFixedHeight=round($i*100*$fxRatio[0],0);// this is a precaution. This should always be overridden below when lastFixedHeight is set to $breakSpec['fixedHeight'][1] foreach($breakpoints as $j => $breakSpec){ if($j*STYLE_BASE_FONT_SIZE>$width)break; if($breakSpec['colWidth']) $lastColWidth=$breakSpec['colWidth']/100; $srcWidth=round($lastBreakWidth*$lastColWidth); if($breakSpec['maxWidth'][0] && $breakSpec['maxWidth'][0]<$srcWidth)$srcWidth=$breakSpec['maxWidth'][0]; if($breakSpec['fixedHeight']){ // converted to pixels $lastFixedHeight=$breakSpec['fixedHeight'][1]; } } // you need to break ''; $lastBreakWidth=$width; } $sources=implode('',$sources); return $sources; } function getExtension($src){ $a=explode('?',$src); $src=explode('.',$a[0]); $ext=array_pop($src); return $ext; } function buildSrcset($breakpoints,$maxWidth,$src,$fxRatio){ // ================ DETERMINE SRCSET =================================== $srcset=[]; $counter=1; //if(ZDEF_BROWSER_ACCEPTS_WEBP)$src.='.webp'; for($i=2;$i<40;$i=$i+$counter){ // no sense specifying srcset sizes for more than 2X the maxWidth of the image (we only cater to 2X pixel density) if(($i-4)*100>$maxWidth*2)break; if($fxRatio[1]=='x'){ // this is used on hero images, where there is a fixed height in pixels specified as padding bottom on .img_ e.g. p_bx500 // the problem is if we use normal and changing fxRatio on an image with fixed height, then when the browser goes out for the next height, it can be too soon for the related media query // so, we let height control the display of the image. If the browser went for the next larger size, we'll just get the sides cut off, which is ok for hero images $srcset[]=($i*100).'x'.$fxRatio[0].'/'.$src.' '.($i*100).'w'; // display of this srcset is ruled by height }else{ // default unit is 'p' $srcset[]=($i*100).'x'.round($i*100*$fxRatio[0],0).'/'.$src.' '.($i*100).'w'; } if($i>8)$counter=2; if($i>12)$counter=4; } $srcset=implode(',',$srcset); return $srcset; } $output=explode(' $imageCode){ $a=explode('src="',$imageCode);// fix this so don't pick up src= in alt !!!!!!!!!!!!!!!!!!!!!!!!!!! if($a[1]){ $b=explode('"',$a[1]); $b[0]=$b[0].'?noimgs=1'; $a[1]=implode('"',$b); } $imageCode=implode('src="',$a); $output[$imgCount]=$imageCode; } $output=implode(' $imageCode){ if($imgCount==0)continue; if(!empty($images[$imgCount-1]['srcset'])){$output[$imgCount]=' outside of the .i .img_ construct, e.g. icons $tagend=strpos($imageCode,'>'); // the end position of the image tag //echo '===>'.substr($imageCode,$tagend).'<==='.str_repeat(' x ',3000);flush();die; $tag=substr($imageCode,0,$tagend); $x=str_replace('https://www.'.ZDEF_HUB_HANDLE.'/'.ORG_HANDLE.'/','',$tag); if(mb_strpos($tag,'http')===0 && mb_strpos($tag,'://')!==false && mb_strlen($x)==$mb_strlen($tag) ){$output[$imgCount]=''.$src.' ';print_r($classes);echo str_repeat(' x ',3000);flush();die; $break=0; $hadFClass=false;// have we encountered the .f_ class in the ancestorClasses? $hadIClass=false;// have we encountered the .i class in the ancestorClasses? $hadFX=false;// have we encountered an .fx_ class already in the ancestorClasses? $breakpoints=[]; $fxRatio=array(100,'p'); // square is the default. should never be used. $fWidth=STYLE_MAX_PAGE_WIDTH; // the maximum width of f_ in ems $widthSpec=[]; $lastColWidth=100; $lastMaxWidth=0; // $classes contains the ancestor classlist, which is built from the current element up the DOM tree foreach($classes as $class){ if($class=='.'){ $classOnSameElement=false; } if($class=='f_')$hadFClass=true; if($class=='i')$hadIClass=true; // build an array of width specifications, at no-width, or at differing widths, determined by aw_ classes // $breakpoints[$breakpoint]['colWidth'] is a specification for width as a percentage aw_30_rcwt2 = 50%, aw_25_w_fp23 // $breakpoints[$breakpoint]['maxWidth'] is an array with specification for width e.g. w_xe25 if(strpos($class,'aw_')===0 || (strpos($class,'_aw_')!==false)){ $a=explode('aw_',$class)[1]; if($a){ $a=explode('_',$a); $breakpoint=+$a[0]; if($breakpoint=='mnx')$breakpoint=WIDGETS_MENU_BREAK; } }else{ $breakpoint=0; } //examine all the df_r... classes to determine the column count at various widths $columnCount=0; if(strpos($class,'df_r')===0 || strpos($class,'_df_r')!==false){ // e.g. df_rcnt1p1 $a=explode('df_r',$class); if(count($a)>1){ if(strlen($a[1])<4)continue;// there is no column count set on the df_, just ignore it $columnCount = explode('p',substr($a[1],3))[0];// remove the padding definition, if any $measure=round(100/$columnCount,2); $breakpoints[$breakpoint]['colWidth']=round($measure*$lastColWidth/100); $lastColWidth=$breakpoints[$breakpoint]['colWidth']; } } if(strpos($class,'plx_')===0){ // e.g. plx_30, meaning the plx_ image is 30% wide $a=explode('plx_',$class); $measure=count($a)>1?+$a[1]:100; $breakpoints[0]['colWidth']=$measure; } // examine any influential width classes $a=explode('de_',$class);// check for descendants so we can eliminate any that don't affect image width $descendentClass=false; if(count($a)>1){ if(strpos($class,'xde_')===false && strpos($class,'dde_')===false && strpos($class,'ide_')===false && strpos($class,'imde_')===false && strpos($class,'_de_')===false && strpos($class,'de_') !==0)continue; $descendentClass=true; } if(strpos($class,'w_f')===0 || strpos($class,'_w_f')!==false || strpos($class,'w_x')===0 || strpos($class,'_w_x')!==false ){ $b=explode('aw_',$class); if(count($b)>1){ $b=explode('w_',$b[1]); // don't let explode ('w_') pick up the w_ in aw_ }else{ $b=explode('w_',$class); } if(count($b)>1){ $spec=$b[1]; $fixOrMax=substr($spec,0,1); $spec=substr($spec,1);// f or x if($spec[0]=='s')$spec=substr($spec,1); // get rid of the optional 's' that indicates 'simple' css $unit=substr($spec,0,1); $measure=+str_replace('d','.',substr($spec,1)); if($unit=='p'){ // percentage width $breakpoints[$breakpoint]['colWidth']=round($measure); //$breakpoints[$breakpoint]['colWidth']=round($measure*$lastColWidth/100); // lastColWidth is usually 100, but when not 100 it means we have a % within a % $lastColWidth=$breakpoints[$breakpoint]['colWidth']; }else{ if( !$hadFClass || $descendentClass ){ // if we havn't hit the f_ class, or this is a descendent class if(!$breakpoints[$breakpoint] || !is_array($breakpoints[$breakpoint]['maxWidth']) || $breakpoints[$breakpoint]['maxWidth'][0]>$measure){ $fixes=$fixOrMax=='f'?substr_count($ancestorClassList,'w_f')>1?'multiple':'single':''; // are there multiple fixed widths on this image? $breakpoints[$breakpoint]['maxWidth']=array($measure,$unit,$fixOrMax,$fixes); $lastMaxWidth=$breakpoints[$breakpoint]['maxWidth']; } } } //echo '
CLASS '.$class.' ';print_r($widthSpec[$breakpoint]); if(!$descendentClass && $hadFClass){ $fWidth=$measure; // if the width is not a descendent and we're on f_, then $fWidth becomes the width specified on f_ } } $classOnSameElement=true; // Do not continue. Might have a height spec higher in the ancestorList } if(strpos($class,'h_f')===0 || strpos($class,'_h_f')!==false){ // this is in ems, generally on tiers $b=explode('h_f',$class); $spec=$b[1]; $unit=substr($spec,0,1); $measure=+str_replace('d','.',substr($spec,1)); if(!$breakpoints[$breakpoint]['fixedHeight']){ $breakpoints[$breakpoint]['fixedHeight']=[$unit,$measure]; } } // ======= Determine the ratio of the image at each beakpoint ======== // Check for p_bp. If there is an fx_ at the same breakpoint (usually 0) the fx_ value will overwrite p_bp if(strpos($class,'p_bp')!==false){ // this is always on .img_ $a=explode('p_bp',$class); $fxRatio=array($a[1]/100,'p'); continue; } // Check for p_be. If there is an fx_ at the same breakpoint the fx_ value will overwrite p_be. p_be is often used to fix the height of an image. e.g. hero images if(strpos($class,'p_be')!==false && !$hadIClass){// there is p_bE on .img_. It will overrule p_bp on $a=explode('p_be',$class); $x=str_replace('d','.',$a[1]); $fxRatio=array(round($x*STYLE_BASE_FONT_SIZE,3),'x'); continue; } // Check for p_bx. If there is an fx_ at the same breakpoint the fx_ value will overwrite p_bx. p_bx is often used to fix the height of an image. e.g. hero images if(strpos($class,'p_bx')!==false && !$hadIClass){// there is p_bx on .img_. It will overrule p_bp on $a=explode('p_bx',$class); $fxRatio=array($a[1],'x'); continue; } // fx_ rules the image ratio if(strpos($class,'fx_')!==false && !$hadFX){ // fx is processed after p_bp but if present it will overwrite it, almost always at breakpoint 0 $a=explode('fx_',$class); $a=explode('_',$a[1]); $hadFX=true; // it is theoretically possible to have a nested .fx_ $fxRatio=array(round($a[1]/$a[0],4),''); continue; } // if(strpos($class,'t_')===0 || strpos($class,' t_')!==false){ // cant break on t_ or dont get t_ classes //break; //} } ksort($breakpoints); $parallax=strpos($ancestorClassList,'plx_') !==false; $hero=strpos($ancestorClassList,'hero_ ') !==false; $sizes=imgSizes($breakpoints); $srcset=''; $sources=''; $maxWidth=ZDEF_MAX_IMAGE_DOWNLOAD_WIDTH;// this is the same as the max width of monitor we are going to support if(!is_array($lastMaxWidth)){ $breakpoints[$fWidth]['maxWidth']=array($fWidth,'e','x','fWidth'); }else{ $breakpoints[$fWidth]['maxWidth'][3]='fWidth'; } foreach($breakpoints as $i => $value){ $breakpoints[$i]['breakpointInPixels']=$i*STYLE_BASE_FONT_SIZE; } //print_r($breakpoints);flush();die; $maxWidth=$fWidth*STYLE_BASE_FONT_SIZE; if($parallax){ $maxEms=0; $a=explode('_plx_',$ancestorClassList)[0]; $a=array_pop(explode(' ',$a)); if(substr($a,0,3)=='aw_'){ $maxEms=substr($a,3); $maxWidth=substr($a,3)*STYLE_BASE_FONT_SIZE; // this is the pixel width in ems when parallax kicks in } $plxWidth=100; $x=explode('plx_',$ancestorClassList)[1]; if($x && substr($x,0,1)!==' '){ $plxWidth=+explode(' ',$x)[0]; } if($maxEms)$sources=''; $sources.=buildParallaxSources($src,$plxWidth); $fxRatio=array(1,'p');// if the sources fail, we don't have a clue what the aspect ratio is, pick the middle of the road $maxWidth=1000; }elseif($hero){ $sources=buildHeroSources($breakpoints,$src,$fxRatio); $fxRatio=array(1,'p');// if the sources fail, we don't have a clue what the aspect ratio is, pick the middle of the road $maxWidth=1000; }elseif($coerced){ //$sources=buildCoercedSources($breakpoints,$src,$fxRatio); //$fxRatio=array(1,'p');// if the sources fail, we don't have a clue what the aspect ratio is, pick the middle of the road //$maxWidth=1000; }else{ // not parallax or hero $ext=getExtension($src); if(is_array($sizes)){ // if $sizes is array then fixed width image. No need for sizes $maxWidth=$sizes[0]; if(ZDEF_BROWSER_ACCEPTS_WEBP && ($ext=='jpg' || $ext=='jpeg' || $ext=='png') ){ //$src=$src.'.webp'; } }else{ $srcset.=buildSrcset($breakpoints,$maxWidth,$src,$fxRatio); // $sizes is numeric when a fixed width has been specified for an image, so we don't need a srcset } //$ext=ZDEF_BROWSER_ACCEPTS_WEBP?'webp':getExtension($src); $ext=getExtension($src); } $tag=explode('"',$tag); $newTag=''; for($i=0;$i':'').$sources.''.($parallax||$hero?'':'').substr($imageCode,$tagend+1); //echo '
OUTPUT ===> '.$imgCount.' '.$output[$imgCount-1].'
'."\n"; if(1==2 && array_search('test',$classes)){ echo ' OUTPUT [$imgCount-1] '.$output[$imgCount]; print_r($classes); echo $class; echo ' breakpoint '.$breakpoint; echo ' Column Count '.$columnCount; echo ' $breakpoints[$breakpoint] '.$breakpoints[$breakpoint]; echo '
================= Breakpoints:
'; print_r($breakpoints); echo '
================= fWidth '.$fWidth; echo '
================= sizes'.$sizes; echo $newTag.substr($imageCode,$tagend)."\n"; print_r($tag);echo '
'.$src.' ';echo str_repeat(' x ',3000);ob_flush();flush(); die; } } $output=implode('',$output); } // place relative paths in front of inpage anchors. They don't work because of our base tag. $output=explode('href="#',$output); foreach($output as $anchorCount => $anchorCode){ if($anchorCount==0)continue; $output[$anchorCount]=WEBPAGE_URL.'#'.$anchorCode; } $output=implode('href="',$output); if(ZDEF_COMPRESS===1){ $output = preg_replace("/[\n\r\t\v\f]/","",$output); } define(HTMLOUTPUT,$output); return; function parseSpec($spec){ $css='0'; if(substr($spec,0,1)=='e')$css=str_replace('d','.',substr($spec,1)).'em'; // d represents a decimal if(substr($spec,0,1)=='r')$css=str_replace('d','.',substr($spec,1)).'rem'; // d represents a decimal if(substr($spec,0,1)=='g')$css='calc(var(--gutter) * '.str_replace('d','.',substr($spec,1)).')'; // DEPRECATED if(substr($spec,0,1)=='v')$css='calc('.STYLE_VERTICAL_RHYTHM.' * '.str_replace('d','.',substr($spec,1)).'em)'; if(substr($spec,0,1)=='p')$css=str_replace('d','.',substr($spec,1)).'%'; if(substr($spec,0,1)=='x')$css=str_replace('d','.',substr($spec,1)).'px'; if(substr($spec,0,1)=='h')$css=str_replace('d','.',substr($spec,1)).'vh'; if(substr($spec,0,1)=='w')$css=str_replace('d','.',substr($spec,1)).'vw'; if(substr($spec,0,1)=='u')$css='unset'; if(substr($spec,0,1)=='a')$css='auto'; return $css; } /* $header = $xpath->query('.//*[@id = "h_"]')->item(0); if($header){ $dataBreak=$header->getAttribute('data-break'); define(WIDGETS_MENU_BREAK,$dataBreak); $pageWidth=$header->getAttribute('data-pwidth'); define(WPC_PAGE_PAGE_WIDTH_IN_EMS,$pageWidth); $fontSize=$header->getAttribute('data-pfsize'); define(WPC_FONT_ADJUST,$fontSize); } // defaults if any of the above is not set define(WIDGETS_MENU_BREAK,$dataBreak); define(WPC_PAGE_WIDTH_IN_EMS,$pageWidth); define(WPC_FONT_ADJUST,$fontSize);*/ /* $image_list = $xpath->query("//img[@src]"); for($i=0;$i<$image_list->length; $i++){ $src=$image_list->item($i)->getAttribute("src"); if(strpos($src,'fx=')!==false){ $a=explode('fx=',$src); $a=explode('&',$a[1])[0]; $requiredWidgets['fx_'.$a[0].'_'.$a[1]]=[]; } } foreach($widgetSources as $widgetSource){ $expression = './/*[contains(@src),'.$widgetSrc.')]'; $nodes = $xpath->query($expression); foreach($nodes as $node){ $src=' '.$node->attributes->getNamedItem('src')->nodeValue.' '; if( $node->nodeName=='ul' && strpos($className, ' tbr_')!== false ){ $a=explode(' tbr_',$className); if($a[1]){ $a=explode(' ',$a[1]); $breakpoint=$a[0]; if(empty($breakpoint))$breakpoint='40';// default to 40 ems breakpoint if tbr_?? not specified } $requiredWidgets['tbr_'.$breakpoint]=[]; } $requiredWidgets[$widgetClass]=[]; //tried(count($nodes)>0) but evaluate returns an element in nodes, although var_dump dumps nothing } }*/ //$nodes = $xpath->query($expression); //$cln_wgl = all widgets already loaded //$theWidgets = all widgets required that have not already been loaded /*print_r($requiredWidgets); echo '====================================================
'; die;*/ //$requiredWidgets=array_unique($requiredWidgets,SORT_STRING); you can never have a duplicate key in an associative array /* print the nodelist $temp_dom = new DOMDocument(); foreach($nodes as $n) $temp_dom->appendChild($temp_dom->importNode($n,true)); print_r($temp_dom->saveHTML()); */ // if($nodes->length > 0) # of nodes // $node->attributes->getNamedItem('class')->nodeValue get the class of the node // $node->nodeName //foreach ($xpath->evaluate($expression) as $div) { //$nodes = $xpath->query("//div[@class='inner text-inner']"); // get multiple classes //$nodes = $xpath->query('//ul[@class="table"]'); /* print the nodelist $temp_dom = new DOMDocument(); foreach($nodes as $n) $temp_dom->appendChild($temp_dom->importNode($n,true)); print_r($temp_dom->saveHTML()); */ /* $dom = new DOMDocument; $dom->loadHTML($output); // examine the document and look for specific classes so we know what styles to load!!! foreach($dom->getElementsByTagName('img') as $image) { if($image->getAttribute('data-src')){ $image->setAttribute('src',$image->getAttribute('data-src').'?w=f400'); } } $output=$dom->saveHTML(); */ //$nodes->item(0) //echo $doc->saveHTML(); // DOMDocument changes html. don't write the DOMDocument //print_r($theWidgets);die; ?>