File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/includes/sections/list.php
<?php
/**
* This file contains the iwp_styleguide class.
*
* @author Jordie <jordie+code@interspire.com>
*
* @package IWP
* @subpackage IWP_API
*/
/**
* This class extends upon the base iwp_base class.
* This file deals specifically with the style guide for themes
*
* @package IWP
* @subpackage IWP_API
*
* @see iwp_base
*/
class iwp_section_list {
public function ProcessBlock($styleGuideObj, $domElement, $attributes){
$replaceFrom = $replaceTo = array();
$html = $subCode = '';
$domElement->setAttribute('class', '{$cssclasses} '.$domElement->getAttribute('class'));
$classes = trim((string)$domElement->getAttribute('class'));
if(!empty($classes)) {
$classes = $classes . ' ';
}
$domElement->setAttribute('class', $classes . '{$blockNumberClass}');
iwp_domhelper::AppendAttributeByClass($domElement, 'tplflag-addblocknumberclass', 'style', '{$blockNumberClass}');
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-smallsearch-pageurl', '{$urls.search}');
// Common replaceables
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-listitem-url', '{$row1.Url}');
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-list-title', '{$blockTitle}');
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-list-content', '{$blockContent}');
$fields = array(
'title', 'target', 'content', 'summary', 'views',
'publishdatewithlabel', 'publishdate', 'publishdate-monthshort' , 'publishdate-yearlong','publishdate-yearshort',
'publishdate-monthlong', 'publishdate-daynum', 'publishdate-year', 'publishdate-monthnumber', 'publishdate-monthnumberwithzero',
'categories', 'contenttypename', 'authors',
);
$allDetails = array();
$affectedElements = 0;
foreach($fields as $thisField) {
$fieldName = ucfirst(iwp_strtolower(str_replace("-", "", $thisField)));
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-listitem-'.iwp_strtolower($thisField), '{$row1.prepend' . $fieldName . '}{$row1.' . $fieldName . '}{$row1.append' . $fieldName . '}');
$affectedElements = iwp_domhelper::WrapElementsByClass($domElement, 'tplvar-listitem-'. $thisField, '{$row1.before' . $fieldName . '}{if strlen($row1.' . $fieldName . ') > 0}', '{/if}{$row1.after' . $fieldName . '}');
if($affectedElements > 0 && iwp_strtolower($fieldName) != "title") {
$allDetails[] = 'strlen($row1.' . $fieldName . ') > 0';
}
}
iwp_domhelper::WrapInnerElementsByClass($domElement, 'tplflag-listitem-contentdetails', '{$row1.beforeDetails}', '{$row1.afterDetails}');
iwp_domhelper::WrapElementsByClass($domElement, 'tplflag-listitem-contentdetails', '{if ' . implode(' || ', $allDetails) .'}', '{/if}');
iwp_domhelper::WrapElementsByClass($domElement, 'tplcond-listitem-iffirst', '{if $listLoop.first}', '{/if}');
iwp_domhelper::WrapElementsByClass($domElement, 'tplcond-listitem-ifnotfirst', '{if !$listLoop.first}', '{/if}');
iwp_domhelper::WrapElementsByClass($domElement, 'tplcond-listitem-iflast', '{if $listLoop.last}', '{/if}');
iwp_domhelper::WrapElementsByClass($domElement, 'tplcond-listitem-ifnotlast', '{if !$listLoop.last}', '{/if}');
for($i=1;$i<10;$i++) {
$codeNum = $i;
$searchNum = $i-1;
if($searchNum < 1){
$searchNum = '';
$nextLevel = 2;
}else{
$searchNum = $searchNum+1;
$nextLevel = 2+($i-1);
}
$parentNum = $i-1;
if($parentNum < 2){
$parentNum ='';
}
// ------ CHECK FOR ELEMENTS WITH NO CHILDREN ------ //
$repeatElement = iwp_domhelper::GetElementByClass($domElement, 'tplrepeat-listitem' . $searchNum . '-ifnochildren');
if(is_object($repeatElement)){ // should be a DOMElement
// we're only here if there is actually something that is repeated
iwp_domhelper::WrapElement($repeatElement, '{if is_empty($row'.$codeNum.'.children)}', '{/if}');
}
// ------ CHECK FOR ELEMENTS WITH CHILDREN ------ //
$repeatWithChildrenElement = iwp_domhelper::GetElementByClass($domElement, 'tplrepeat-listitem' . $searchNum . '-ifchildren');
if($repeatWithChildrenElement instanceof DOMElement){ // should be a
iwp_domhelper::WrapElement($repeatWithChildrenElement, '{if !is_empty($row'.$codeNum.'.children)}', '{/if}');
// this element should have children
$repeatSubParentElement = iwp_domhelper::GetElementByClass($domElement, 'tplrepeat-parent' . $nextLevel);
if(is_object($repeatSubParentElement)){ // should be a DOMElement
// we're only here if there is actually something that is repeated
iwp_domhelper::WrapInnerElement($repeatSubParentElement, '{foreach from=$row'.$codeNum.'.children item=row'.$nextLevel.' id=subListLoop'.$nextLevel.'}', '{/foreach}');
// Common Replaceables for sub row
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-listitem'.$nextLevel.'-title', '{$row'.$nextLevel.'.Title}');
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-listitem'.$nextLevel.'-url', '{$row'.$nextLevel.'.Url}');
iwp_domhelper::modifyTagByClassName($domElement, 'tplvar-listitem'.$nextLevel.'-target', '{$row'.$nextLevel.'.Target}');
}
}else{
break;
}
}
// ------ CHECK FOR PARENT OF REPEATED ELEMENT TO INSERT LOOP ------ //
$parentRepeatElement = iwp_domhelper::GetElementByClass($domElement, 'tplrepeat-parent');
if(is_object($parentRepeatElement)){ // should be a DOMElement
// we're only here if there is actually something that is repeated
$foreachStart = iwp_domhelper::NewDOMText('{foreach from=$OutputList item=row1 id=listLoop}');
$foreachEnd = iwp_domhelper::NewDOMText('{/foreach}');
// inserts the foreach loop before the repeated element
$parentRepeatElement->insertBefore($foreachStart, $parentRepeatElement->firstChild);
// inserts the closing foreach after the repeated element
$parentRepeatElement->insertBefore($foreachEnd, $parentRepeatElement->lastChild->nextSibling);
}
return iwp_domhelper::outerHTML($domElement);
}
}