diff --git a/deployed/icemegamenu/modules/mod_icemegamenu/assets/index.html b/deployed/icemegamenu/modules/mod_icemegamenu/assets/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/icemegamenu/modules/mod_icemegamenu/assets/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/icemegamenu/modules/mod_icemegamenu/helper.php b/deployed/icemegamenu/modules/mod_icemegamenu/helper.php new file mode 100644 index 00000000..1c7469e5 --- /dev/null +++ b/deployed/icemegamenu/modules/mod_icemegamenu/helper.php @@ -0,0 +1,427 @@ +_module = $module; + $this->moduleid = $module->id; + $this->loadMediaFiles($params, $module); + } + $this->_params = $params; + } + + public static function buildXML($params) + { + $menu = new IceMenuTree($params); + $app = JFactory::getApplication(); + $items = $app->getMenu(); + $start = $params->get('startLevel'); + $end = $params->get('endLevel'); + $sChild = $params->get('showAllChildren'); + + if($end<$start && $end!=0){ return ""; } + + if(!$sChild){ $end = $start;} + + // Get Menu Items + $rows = $items->getItems('menutype', $params->get('menutype')); + foreach($rows as $key=>$val) + { + if(!(($end!=0 && $rows[$key]->level>=$start && $rows[$key]->level<=$end) ||($end==0 && $rows[$key]->level>=$start))) + { + unset($rows[$key]); + } + } + $maxdepth = $params->get('maxdepth',10); + + // Build Menu Tree root down(orphan proof - child might have lower id than parent) + $user_temp = JFactory::getUser(); + $user = &$user_temp; + $ids = array(); + $ids[1] = true; + $last = null; + $unresolved = array(); + $vertical_direction = $params->get("vertical_direction", "left"); + + // pop the first item until the array is empty if there is any item + if(is_array($rows)) + { + while(count($rows) && !is_null($row = array_shift($rows))) + { + if(array_key_exists($row->parent_id, $ids)) + { + $row->ionly = $params->get('menu_images_link'); + $menu->addNode($params, $row); + // record loaded parents + $ids[$row->id] = true; + } + else + { + // no parent yet so push item to back of list + // SAM: But if the key isn't in the list and we dont _add_ this is infinite, so check the unresolved queue + if(!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth) + { + array_push($rows, $row); + // so let us do max $maxdepth passes + // TODO: Put a time check in this loop in case we get too close to the PHP timeout + if(!isset($unresolved[$row->id])) $unresolved[$row->id] = 1; + else $unresolved[$row->id]++; + } + } + } + } + return $menu->toXML($vertical_direction); + } + + function &getXML($type, &$params, $decorator) + { + static $xmls; + + if(!isset($xmls[$type])) + { + $cache_temp = JFactory::getCache('mod_icemegamenu'); + $cache = &$cache_temp; + $string = $cache->call(array('modIceMegamenuHelper', 'buildXML'), $params); + $xmls[$type] = $string; + } + // Get document + require_once(JPATH_BASE.DS."modules".DS."mod_icemegamenu".DS."libs".DS."simplexml.php"); + $xml = new JSimpleXML; + $xml->loadString($xmls[$type]); + $doc = &$xml->document; + $app = JFactory::getApplication(); + $menu = $app->getMenu(); + $active = ($menu->getActive()) ? $menu->getActive() : $menu->getDefault(); + $start = $params->get('startLevel'); + $end = $params->get('endLevel'); + $sChild = $params->get('showAllChildren'); + $path = array(); + + // Get subtree + if($doc && is_callable($decorator)) + { + $doc->map($decorator, array('end'=>$end, 'children'=>$sChild)); + } + return $doc; + } + + function render(&$params, $callback) + { + switch($params->get('menu_style', 'list')) + { + case 'list_flat' : + break; + + case 'horiz_flat' : + break; + + case 'vert_indent' : + break; + + default : + // Include the new menu class + $xml = modIceMegamenuHelper::getXML($params->get('menutype'), $params, $callback); + if($xml) + { + $class = $params->get('class_sfx'); + $xml->addAttribute('class', 'icemegamenu'.$class); + + if($tagId = $params->get('tag_id')) + { + $xml->addAttribute('id', $tagId); + } + $result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace'))); + $result = str_replace(array('>','<','"'), array('>','<','"'), $result); + $result = str_replace(array('