function smarty_cms_function_sitemap($params, &$smarty) { global $gCms; $contentops =& $gCms->GetContentOperations(); $allcontent = $contentops->GetAllContent(); // define variables $menu = ''; $last_level = 0; $first_level = 0; $count = 0; $in_hr = 0; $no_end = false; $add_elements = isset($params['add_elements']) ? $params['add_elements'] : 0; $add_element = explode(',', $add_elements); foreach ($allcontent as $onecontent) { // Handy little trick to figure out how deep in the tree we are // Remember, content comes to use in order of how it should be displayed in the tree already $depth = count(split('\\.', $onecontent->Hierarchy())); // If hierarchy starts with the start_element (if it's set), then continue on if (isset($params['start_element'])) { if (!(strpos($onecontent->Hierarchy(), $params['start_element']) !== FALSE && strpos($onecontent->Hierarchy(), $params['start_element']) == 0)) { if ($onecontent->Alias() == $params['start_element']) { $params['start_element'] = $onecontent->Hierarchy(); $depth = count(split('\\.', $onecontent->Hierarchy())); $first_level = $depth; continue; } else { continue; } } } // Now check to make sure we're not too many levels deep if number_of_levels is set if (isset($params['number_of_levels'])) { $number_of_levels = $params['number_of_levels'] - 1; $base_level = 1; // Is start_element set? If so, reset the base_level to it's level if (isset($params['start_element'])) { $base_level = count(split('\\.', $params['start_element'])) + 1; } // If this element's level is more than base_level + number_of_levels, then scratch it if ($base_level + $number_of_levels < $depth) { continue; } } // Not active or separator? Toss it. if (!$onecontent->Active() || !$onecontent->MenuText()) { continue; } // Not shown in menu? Toss it. if (!$onecontent->ShowInMenu()) { // If param showall, display also content not shown in menu. if (isset($params['showall']) && $params['showall'] == 1 || $add_elements && in_array($onecontent->Alias(), $add_element)) { } else { continue; } } if ($depth < $last_level) { for ($i = $depth; $i < $last_level; $i++) { $menu .= "</li>\n</ul>\n"; } if ($depth > 0) { $menu .= "</li>\n"; } } if ($depth == $last_level) { $menu .= "</li>\n"; } if ($depth > $last_level) { if (isset($params['class']) && $params['class'] != '' && $count == 0) { $menu .= '<ul class="' . $params['class'] . '">' . "\n"; } else { $menu .= "\n<ul>\n"; } } if (!(isset($params['relative']) && $params['relative'] == 1 && (isset($gCms->variables['content_id']) && $onecontent->Id() == $gCms->variables['content_id']))) { $menu .= '<li>'; if (isset($params['delimiter']) && $params['delimiter'] != '' && $depth > 1) { $ddepth = split('\\.', $onecontent->Hierarchy()); if ($ddepth[sizeof($ddepth) - 1] > 1 || isset($params['initial']) && $params['initial'] == '1') { $menu .= $params['delimiter']; } } // No link if section header. if ($onecontent->HasUsableLink()) { $menu .= '<a href="' . $onecontent->GetURL() . '"'; if (isset($gCms->variables['content_id']) && $onecontent->Id() == $gCms->variables['content_id']) { $menu .= ' class="currentpage"'; } if ($onecontent->GetPropertyValue('target') != '') { $menu .= ' target="' . $onecontent->GetPropertyValue('target') . '"'; } $menu .= '>' . my_htmlentities($onecontent->MenuText()) . '</a>'; } else { $menu .= my_htmlentities($onecontent->MenuText()); } } else { if (!$onecontent->HasChildren()) { $no_end = true; } else { $menu .= '<li>'; } } $last_level = $depth; $count++; } for ($i = $first_level; $i < $last_level; $i++) { if ($no_end != true) { $menu .= '</li>'; } $menu .= "\n</ul>"; } return $menu; }
/** * A method to perform HTML entity conversion on a string * * @see htmlentities * @param string The input string * @param string A flag indicating how quotes should be handled (see htmlentities) (ignored) * @param string The input character set (ignored) * @param boolean A flag indicating wether single quotes should be converted to entities. * @return string the converted string. */ function cms_htmlentities($string, $param = ENT_QUOTES, $charset = "UTF-8", $convert_single_quotes = false) { $result = ""; #$result = htmlentities($string, $param, $charset); $result = my_htmlentities($string, $convert_single_quotes); return $result; }
function &FillNode(&$content, &$node, &$nodelist, &$gCms, &$count, &$prevdepth, $origdepth, $deep = false, $params = array()) { $gCms = cmsms(); $config = $gCms->GetConfig(); $onenode = new stdClass(); $onenode->id = $content->Id(); $onenode->pagetitle = $content->Name(); $onenode->url = $content->GetURL(); $onenode->accesskey = $content->AccessKey(); $onenode->type = strtolower($content->Type()); $onenode->tabindex = $content->TabIndex(); $onenode->titleattribute = $content->TitleAttribute(); $onenode->modified = $content->GetModifiedDate(); $onenode->created = $content->GetCreationDate(); $onenode->hierarchy = $content->Hierarchy(); $onenode->depth = count(explode('.', $content->Hierarchy())) - ($origdepth - 1); $onenode->prevdepth = $prevdepth - ($origdepth - 1); if ($onenode->prevdepth == 0) { $onenode->prevdepth = 1; } $onenode->children_exist = false; if ($node->has_children()) { $children = $node->get_children(); if ($children) { for ($i = 0; $i < count($children); $i++) { $tmpc = $children[$i]->getContent(false, true, true); if ($tmpc->Active() && $tmpc->ShowInMenu()) { $onenode->children_exist = true; break; } } } } $onenode->haschildren = false; $prevdepth = $onenode->depth + ($origdepth - 1); $onenode->menutext = my_htmlentities($content->MenuText()); $onenode->raw_menutext = $content->MenuText(); $onenode->target = ''; $onenode->index = $count; $onenode->alias = $content->Alias(); $onenode->parent = false; $count++; if ($deep) { $onenode->extra1 = $content->GetPropertyValue('extra1'); $onenode->extra2 = $content->GetPropertyValue('extra2'); $onenode->extra3 = $content->GetPropertyValue('extra3'); $tmp = $content->GetPropertyValue('image'); if (!empty($tmp) && $tmp != -1) { $url = get_site_preference('content_imagefield_path') . '/' . $tmp; if (!startswith($url, '/')) { $url = '/' . $url; } $url = $config['image_uploads_url'] . $url; $onenode->image = $url; } $tmp = $content->GetPropertyValue('thumbnail'); if (!empty($tmp) && $tmp != -1) { $url = get_site_preference('content_thumbnailfield_path') . '/' . $tmp; if (!startswith($url, '/')) { $url = '/' . $url; } $url = $config['image_uploads_url'] . $url; $onenode->thumbnail = $url; } if ($content->HasProperty('target')) { $onenode->target = $content->GetPropertyValue('target'); } } if (isset($gCms->variables['content_id']) && $onenode->id == $gCms->variables['content_id']) { $onenode->current = true; } else { $onenode->current = false; //So, it's not current. Lets check to see if it's a direct parent if (isset($gCms->variables["friendly_position"])) { if (startswith($gCms->variables['friendly_position'] . '.', $content->Hierarchy() . '.')) { $onenode->parent = true; } } } $nodelist[] = $onenode; return $onenode; }
function &FillNode(&$content, &$node, &$nodelist, &$gCms, &$count, &$prevdepth, $origdepth, $deep = false) { $onenode = new stdClass(); $onenode->id = $content->Id(); $onenode->pagetitle = $content->Name(); $onenode->url = $content->GetURL(); $onenode->accesskey = $content->AccessKey(); $onenode->type = strtolower($content->Type()); $onenode->tabindex = $content->TabIndex(); $onenode->titleattribute = $content->TitleAttribute(); $onenode->modified = $content->GetModifiedDate(); $onenode->created = $content->GetCreationDate(); $onenode->hierarchy = $content->Hierarchy(); $onenode->depth = count(explode('.', $content->Hierarchy())) - ($origdepth - 1); $onenode->prevdepth = $prevdepth - ($origdepth - 1); if ($onenode->prevdepth == 0) { $onenode->prevdepth = 1; } $onenode->haschildren = false; if (isset($node)) { $onenode->haschildren = $node->HasChildren(true); } $prevdepth = $onenode->depth + ($origdepth - 1); $onenode->menutext = my_htmlentities($content->MenuText()); $onenode->raw_menutext = $content->MenuText(); $onenode->target = ''; $onenode->index = $count; $onenode->alias = $content->Alias(); $onenode->parent = false; $count++; if ($deep) { $onenode->extra1 = $content->GetPropertyValue('extra1'); $onenode->extra2 = $content->GetPropertyValue('extra2'); $onenode->extra3 = $content->GetPropertyValue('extra3'); $tmp = $content->GetPropertyValue('image'); if (!empty($tmp) && $tmp != -1) { $onenode->image = $tmp; } $tmp = $content->GetPropertyValue('thumbnail'); if (!empty($tmp) && $tmp != -1) { $onenode->thumbnail = $tmp; } if ($content->HasProperty('target')) { $onenode->target = $content->GetPropertyValue('target'); } } if (isset($gCms->variables['content_id']) && $onenode->id == $gCms->variables['content_id']) { $onenode->current = true; } else { $onenode->current = false; //So, it's not current. Lets check to see if it's a direct parent if (isset($gCms->variables["friendly_position"])) { if (strstr($gCms->variables["friendly_position"] . '.', $content->Hierarchy() . '.') == $gCms->variables["friendly_position"] . '.') { $onenode->parent = true; } } } $nodelist[] = $onenode; return $onenode; }