public static final function create_input_dropdown($id, $name, $items, $selectedindex, $selectedvalue, $addttext = '', $required = false) { $id = cms_htmlentities($id); $name = cms_htmlentities($name); $selectedindex = cms_htmlentities($selectedindex); $selectedvalue = cms_htmlentities($selectedvalue); $text = '<select class="cms_dropdown" name="' . $id . $name . '" id="' . $name . '"'; if (!empty($addttext)) { $text .= ' ' . $addttext; } if ($required) { $text .= ' required="required"'; } $text .= '>'; $count = 0; if (is_array($items) && count($items) > 0) { foreach ($items as $key => $value) { $text .= '<option value="' . $value . '"'; if ($selectedindex == $count || $selectedvalue == $value) { $text .= ' ' . 'selected="selected"'; } $text .= '>'; $text .= $key; $text .= '</option>'; $count++; } } $text .= '</select>' . "\n"; return $text; }
function EditAsArray($adding = false, $tab = 0, $showadmin = false) { global $gCms; $config = $gCms->config; $contentops =& $gCms->GetContentOperations(); $templateops =& $gCms->GetTemplateOperations(); $ret = array(); switch ($tab) { case 0: array_push($ret, array(lang('title') . ':', '<input type="text" name="title" value="' . $this->mName . '">')); array_push($ret, array(lang('menutext') . ':', '<input type="text" name="menutext" value="' . $this->mMenuText . '">')); array_push($ret, array(lang('parent') . ':', $contentops->CreateHierarchyDropdown($this->mId, $this->mParentId))); array_push($ret, array(lang('template') . ':', $templateops->TemplateDropdown('template_id', $this->mTemplateId))); array_push($ret, array($this->Lang('multiplealbumtemplate') . ':', $this->TemplateDropdown('album_template', $this->GetPropertyValue('album_template')))); array_push($ret, array($this->Lang('Albums') . ':', $this->AlbumsSelect('albums', $this->GetPropertyValue('albums')))); break; case 1: array_push($ret, array(lang('pagealias') . ':', '<input type="text" name="alias" value="' . $this->mAlias . '">')); array_push($ret, array(lang('active') . ':', '<input type="checkbox" name="active"' . ($this->mActive ? ' checked="true"' : '') . '>')); array_push($ret, array(lang('showinmenu') . ':', '<input type="checkbox" name="showinmenu"' . ($this->mShowInMenu ? ' checked="true"' : '') . '>')); array_push($ret, array(lang('metadata') . ':', create_textarea(false, $this->Metadata(), 'metadata', 'pagesmalltextarea', 'metadata', '', '', '80', '6'))); array_push($ret, array(lang('titleattribute') . ':', '<input type="text" name="titleattribute" maxlength="255" value="' . cms_htmlentities($this->mTitleAttribute) . '" />')); array_push($ret, array(lang('tabindex') . ':', '<input type="text" name="tabindex" maxlength="10" value="' . cms_htmlentities($this->mTabIndex) . '" />')); array_push($ret, array(lang('accesskey') . ':', '<input type="text" name="accesskey" maxlength="5" value="' . cms_htmlentities($this->mAccessKey) . '" />')); if (!$adding && $showadmin) { global $gCms; $userops =& $gCms->GetUserOperations(); $ret[] = array(lang('owner') . ':', $userops->GenerateDropdown($this->Owner())); } } return $ret; }
function smarty_cms_function_title($params, &$smarty) { global $gCms; $pageinfo =& $gCms->variables['pageinfo']; $config =& $gCms->GetConfig(); $result = ''; if (isset($pageinfo) && $pageinfo->content_id == -1) { #We've a custom error message... set a current timestamp $result = "404 Error"; } else { $result = cms_htmlentities($pageinfo->content_title); if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) { if (version_compare(phpversion(), "5.3.0", "<")) { $result = ereg_replace("\\{\\/?php\\}", "", $result); } else { $result = preg_replace("/\\{\\/?php\\}/", "", $result); } } } if (isset($params['assign'])) { $smarty =& $gCms->GetSmarty(); $smarty->assign($params['assign'], $result); return; } return $result; }
function smarty_cms_function_startExpandCollapse($params, &$smarty) { static $firstExpandCollapse = true; //only gets set one time per page global $gCms; $config =& $gCms->GetConfig(); if (!empty($params['id']) && !empty($params['title'])) { $id = $params['id']; $title = $params['title']; } else { echo 'Error: The expand/collapse plugin requires that both parameters (id,title) are used.'; return; } if ($firstExpandCollapse) { echo '<script type="text/javascript" language="javascript" src="' . $config['root_url'] . '/lib/helparea.js"></script>'; $firstExpandCollapse = false; } $url = cms_htmlentities($_SERVER['REQUEST_URI']); $url = str_replace('&', '***', $url); $url = str_replace('&', '&', $url); $url = str_replace('***', '&', $url); //$url = str_replace('&', '&', $_SERVER['REQUEST_URI']); echo '<a href="' . $url . '#' . $id . '" onclick="expandcontent(\'' . $id . '\')" style="cursor:hand; cursor:pointer">' . $title . '</a><br /> <div id="' . $id . '" class="expand">'; }
/** * Module API wrapper function * * @since 1.0 * @return string */ public static function WYSIWYGTextarea($name = 'textarea', $columns = '80', $rows = '15', $encoding = '', $content = '', $stylesheet = '', $addtext = '') { $mod = cms_utils::get_module('MicroTiny'); // Check if we are in object instance if (!is_object($mod)) { return false; } // TODO: some error message? // Force WYSIWYG on $mod->wysiwygactive = true; // Stikki: calling this before TODO cause whole thing failing, check this Silmarillion. if ($stylesheet != '') { $_SESSION["microtiny_live_templateid"] = substr($stylesheet, strpos($stylesheet, "=") + 1); } else { $tplops = cmsms()->GetTemplateOperations(); $templateid = $tplops->LoadDefaultTemplate(); $mod->templateid = $templateid->id; } self::add_textarea($name); $output = '<textarea id="' . $name . '" name="' . $name . '" cols="' . $columns . '" rows="' . ($rows + 5) . '" ' . $addtext . '>' . cms_htmlentities($content, ENT_NOQUOTES, get_encoding($encoding)) . '</textarea>'; global $CMS_ADMIN_PAGE; if ($CMS_ADMIN_PAGE && $mod->CheckPermission('MicroTiny View HTML Source')) { $output .= '<span style="display:block; margin-top:10px;"><input type="checkbox" id="toggle_' . $name . '" onclick="toggleMicroTiny(\'' . $name . '\');"/><label for="toggle_' . $name . '">' . $mod->Lang('view_html') . '</label></span>'; } return $output; }
function smarty_function_anchor($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); #Added by Russ for class, tabindex and title for anchor 2006/07/19 $class = ""; $title = ""; $tabindex = ""; $accesskey = ""; if (isset($params['class'])) { $class = ' class="' . $params['class'] . '"'; } if (isset($params['title'])) { $title = ' title="' . $params['title'] . '"'; } if (isset($params['tabindex'])) { $tabindex = ' tabindex="' . $params['tabindex'] . '"'; } if (isset($params['accesskey'])) { $accesskey = ' accesskey="' . $params['accesskey'] . '"'; } #End of first part added by Russ 2006/07/19 $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $str = $_SERVER['REQUEST_URI']; $pos = strpos($str, '?'); if ($pos !== FALSE) { $str = substr($str, 0, $pos); } $pageURL .= $_SERVER["SERVER_NAME"] . $str; } if (isset($pageURL)) { $url = cms_htmlentities($_SERVER['REQUEST_URI']) . '#' . $params['anchor']; $url = str_replace('&', '***', $url); $url = str_replace('&', '&', $url); $url = str_replace('***', '&', $url); if (isset($params['onlyhref']) && ($params['onlyhref'] == '1' || $params['onlyhref'] == 'true')) { #Note if you set 'onlyheref' that is what you get - no class or title or tabindex or text $tmp = $url; } else { #Line replaced by Russ # echo '<a href="'.$url.'">'.$params['text'].'</a>'; #Line replaced with - by Russ to reflect class and title for anchor 2006/07/19 $tmp = '<a href="' . $url . '"' . $class . $title . $tabindex . $accesskey . '>' . $params['text'] . '</a>'; } #End of second part added by Russ 2006/07/19 } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $tmp); return; } echo $tmp; }
function smarty_cms_function_current_date($params, &$smarty) { if (empty($params['format'])) { $format = "%b %e, %Y"; } else { $format = $params['format']; } $string = strftime($format, time()); if ($params['ucwords']) { $string = ucwords($string); } return cms_htmlentities($string); }
function smarty_cms_function_current_date($params, &$smarty) { $format = '%b %c, %Y'; if (isset($params['format']) && !empty($params['format'])) { $format = trim($params['format']); } $string = strftime($format, time()); if (isset($params['ucwords']) && $params['ucwords'] != '') { $string = ucwords($string); } $out = cms_htmlentities($string); if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $out); return; } return $out; }
function smarty_cms_function_get_template_vars($params, &$smarty) { global $gCms; $tpl_vars = $gCms->smarty->get_template_vars(); $str = '<pre>'; foreach ($tpl_vars as $key => $value) { if (is_object($value)) { $str .= "{$key} = Object<br/>"; } else { if (is_array($value)) { $str .= "{$key} = Array (" . count($value) . ")<br/>"; } else { $str .= "{$key} = " . cms_htmlentities(trim($value)) . "<br/>"; } } } return $str . '</pre>'; }
function smarty_cms_function_modified_date($params, &$smarty) { $gCms = cmsms(); $content_obj = $gCms->variables['content_obj']; if (empty($params['format'])) { $format = "%x %X"; } else { $format = $params['format']; } if (is_object($content_obj) && $content_obj->GetModifiedDate() && $content_obj->GetModifiedDate() > -1) { $time = $content_obj->GetModifiedDate(); $str = cms_htmlentities(strftime($format, $time)); if (isset($params['assign'])) { $smarty->assign($params['assign'], $str); return; } return $str; } }
function smarty_function_created_date($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); $content_obj = $gCms->variables['content_obj']; if (empty($params['format'])) { $format = "%x %X"; } else { $format = $params['format']; } if (is_object($content_obj) && $content_obj->GetCreationDate() > -1) { $time = $content_obj->GetCreationDate(); $str = cms_htmlentities(strftime($format, $time)); if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $str); return; } return $str; } }
function smarty_cms_function_get_template_vars($params, &$smarty) { $tpl_vars = $smarty->get_template_vars(); $str = '<pre>'; foreach ($tpl_vars as $key => $value) { if (is_object($value)) { $str .= "{$key} = Object<br/>"; } else { if (is_array($value)) { $str .= "{$key} = Array (" . count($value) . ")<br/>"; } else { $str .= "{$key} = " . cms_htmlentities(trim($value)) . "<br/>"; } } } $str . '</pre>'; if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $str); return; } return $str; }
function smarty_function_title($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); $contentobj = $gCms->variables['content_obj']; $config = $gCms->GetConfig(); $result = ''; if (!is_object($contentobj)) { #We've a custom error message... set a current timestamp $result = "404 Error"; } else { $result = cms_htmlentities($contentobj->Name()); if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) { $result = preg_replace("/\\{\\/?php\\}/", "", $result); } } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $result); return; } return $result; }
function smarty_function_last_modified_by($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); $content_obj = $gCms->variables['content_obj']; $id = ""; if (isset($content_obj) && $content_obj->LastModifiedBy() > -1) { $id = $content_obj->LastModifiedBy(); } else { return ""; } if (empty($params['format'])) { $format = "id"; } else { $format = $params['format']; $userops =& $gCms->GetUserOperations(); $thisuser =& $userops->LoadUserByID($id); } $output = ''; if ($format === "id") { $output = $id; } else { if ($format === "username") { $output = cms_htmlentities($thisuser->username); } else { if ($format === "fullname") { $output = cms_htmlentities($thisuser->firstname . " " . $thisuser->lastname); } } } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $output); return; } return $output; }
function smarty_cms_function_last_modified_by($params, &$smarty) { global $gCms; $pageinfo = $gCms->variables['pageinfo']; $id = ""; if (isset($pageinfo) && $pageinfo->content_last_modified_by_id > -1) { $id = $pageinfo->content_last_modified_by_id; } else { return ""; } if (empty($params['format'])) { $format = "id"; } else { $format = $params['format']; $userops =& $gCms->GetUserOperations(); $thisuser =& $userops->LoadUserByID($id); } $output = ''; if ($format === "id") { $output = $id; } else { if ($format === "username") { $output = cms_htmlentities($thisuser->username); } else { if ($format === "fullname") { $output = cms_htmlentities($thisuser->firstname . " " . $thisuser->lastname); } } } if (isset($params['assign'])) { $smarty = $gCms->GetSmarty(); $smarty->assign($params['assign'], $output); return; } return $output; }
} } else { if (isset($_POST['clearcache'])) { global $gCms; $gCms->clear_cached_files(); // $contentops =& $gCms->GetContentOperations(); // $contentops->ClearCache(); $message .= lang('cachecleared'); } else { if (isset($_POST["editsiteprefs"])) { if ($access) { switch ($active_tab) { case 'general': // tab 1 if (isset($_POST['sitename'])) { $sitename = cms_htmlentities($_POST['sitename']); } set_site_preference('sitename', $sitename); if (isset($_POST['frontendlang'])) { $frontendlang = $_POST['frontendlang']; } set_site_preference('frontendlang', $frontendlang); if (isset($_POST['frontendwysiwyg'])) { $frontendwysiwyg = $_POST['frontendwysiwyg']; } set_site_preference('frontendwysiwyg', $frontendwysiwyg); if (isset($_POST['metadata'])) { $metadata = $_POST['metadata']; } set_site_preference('metadata', $metadata); if (isset($_POST["logintheme"])) {
function display_hierarchy(&$root, &$userid, $modifyall, &$users, &$menupos, &$openedArray, &$pagelist, &$image_true, &$image_set_false, &$image_set_true, &$upImg, &$downImg, &$viewImg, &$editImg, &$copyImg, &$deleteImg, &$expandImg, &$contractImg, &$mypages, &$page, $columnstodisplay, $author_allpages) { global $thisurl; global $urlext; global $currow; global $config; global $page; global $indent; if (empty($currow)) { $currow = 'row1'; } $children = $root->getChildren(false, true); $one = $root->getContent(); $thelist = ''; if (!(isset($one) && $one != NULL)) { audit($root->get_tag('id'), 'Core', 'failed to get content for valid content id ' . $root->get_tag('id')); return; } if (!array_key_exists($one->Owner(), $users)) { $userops = cmsms()->GetUserOperations(); $users[$one->Owner()] = $userops->LoadUserById($one->Owner()); } $display = 'none'; if (check_modify_all($userid) || check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) { $display = 'edit'; } else { if (check_children($root, $mypages, $userid)) { $display = 'view'; } else { if (check_permission($userid, 'Manage All Content')) { $display = 'structure'; } } } $columns = array(); if ($display != 'none') { $thelist .= "<tr id=\"tr_" . $one->Id() . "\" class=\"{$currow}\">\n"; /* expand/collapse column */ $columns['expand'] = ' '; if ($columnstodisplay['expand']) { $txt = ''; if ($root->hasChildren()) { if (!in_array($one->Id(), $openedArray)) { $txt .= "<a class=\"expand\" href=\"{$thisurl}&content_id=" . $one->Id() . "&col=0&page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'false'); return false;\">"; $txt .= $expandImg; $txt .= "</a>"; } else { $txt .= "<a class=\"contract\" href=\"{$thisurl}&content_id=" . $one->Id() . "&col=1&page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'true'); return false;\">"; $txt .= $contractImg; $txt .= "</a>"; } } if (!empty($txt)) { $columns['expand'] = $txt; } } /* hierarchy column */ if ($columnstodisplay['hier']) { $columns['hier'] = $one->Hierarchy(); } /* page column */ if ($columnstodisplay['page']) { $columns['page'] = ' '; $txt = ''; if ($one->MenuText() != CMS_CONTENT_HIDDEN_NAME) { if ($indent) { for ($i = 0; $i < $root->getLevel(); $i++) { $txt .= "- "; } } $str = $one->MenuText(); if (get_site_preference('listcontent_showtitle', 0)) { $str = $one->Name(); } if ($display == 'edit') { $txt .= '<a class="tooltip" href="editcontent.php' . $urlext . '&content_id=' . $one->Id() . '&page=' . $page . '" title="' . cms_htmlentities($one->Name() . ' (' . $one->Alias() . ')', '', '', true) . '" onmouseover="document.getElementById(\'' . $one->Id() . '_info\').style.display = \'inline-block\';" onmouseout="document.getElementById(\'' . $one->Id() . '_info\').style.display = \'none\';"> ' . cms_htmlentities($str, '', '', true) . '<span id="' . $one->Id() . '_info"><strong>' . lang('content_id') . ':</strong> ' . $one->Id() . '<br /> <strong>' . lang('title') . ':</strong> ' . cms_htmlentities($one->Name()) . '<br /> <strong>' . lang('pagealias') . ':</strong> ' . $one->Alias() . '</span></a>'; } else { $txt .= cms_htmlentities($str, '', '', true); } } if (!empty($txt)) { $columns['page'] = $txt; } } /* alias column */ if ($columnstodisplay['alias']) { $columns['alias'] = ' '; $txt = ''; if ($one->HasUsableLink() && $one->Alias() != '') { $txt = $one->Alias(); } if (!empty($txt)) { $columns['alias'] = $txt; } } /* url column */ if ($columnstodisplay['url']) { $columns['url'] = ' '; $txt = ''; if ($one->HasUsableLink() && $one->URL() != '') { $url = $one->URL(); if (strlen($url) > 30) { $url = '...' . substr($url, strlen($url) - 27); } $txt = $url; } if (!empty($txt)) { if (!prettyurls_ok()) { $txt = '<span style="color: red;" title="' . lang('prettyurls_noeffect') . '">' . $txt . '<span>'; } } if (!empty($txt)) { $columns['url'] = $txt; } } /* template column */ if ($columnstodisplay['template']) { $columns['template'] = ' '; $txt = ''; if ($one->Type() != 'pagelink' && $one->Type() != 'link' && $one->Type() != 'sectionheader' && $one->Type() != 'separator') { $template = TemplateOperations::get_instance()->LoadTemplateById($one->TemplateId()); if ($template && check_permission($userid, 'Modify Template')) { $txt .= "<a title=\"" . lang('edittemplate') . "\" href=\"edittemplate.php" . $urlext . "&template_id=" . $one->TemplateId() . "&from=content\">" . cms_htmlentities($template->name, '', '', true) . "</a>"; } else { if ($template) { $txt .= $template->name; } } } if (!empty($txt)) { $columns['template'] = $txt; } } /* friendly name column */ if ($columnstodisplay['friendlyname']) { $columns['friendlyname'] = $one->FriendlyName(); } /* owner column */ if ($columnstodisplay['owner']) { $columns['owner'] = ' '; if ($one->Owner() > -1) { $columns['owner'] = $users[$one->Owner()]->username; } } /* active column */ if ($columnstodisplay['active']) { $columns['active'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content') && $one->Type() != 'errorpage') { if ($one->Active()) { $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&setinactive=" . $one->Id() . "\" onclick=\"xajax_content_setinactive(" . $one->Id() . ");return false;\">" . $image_set_false . "</a>"; } else { $txt = "<a href=\"{$thisurl}&setactive=" . $one->Id() . "\" onclick=\"xajax_content_setactive(" . $one->Id() . ");return false;\">" . $image_set_true . "</a>"; } } if (!empty($txt)) { $columns['active'] = $txt; } } /* default content */ if ($columnstodisplay['default']) { $columns['default'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content')) { if ($one->IsDefaultPossible()) { $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&makedefault=" . $one->Id() . "\" onclick=\"if(confirm('" . cms_html_entity_decode_utf8(lang("confirmdefault", $one->Name()), true) . "')) xajax_content_setdefault(" . $one->Id() . ");return false;\">" . $image_set_true . "</a>"; } } if (!empty($txt)) { $columns['default'] = $txt; } } /* move column */ if ($columnstodisplay['move']) { // code for move up is simple $columns['move'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content') || $author_allpages) { $sameLevel = $root->getSiblingCount(); if ($sameLevel > 1) { if ($one->ItemOrder() - 1 <= 0) { $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&direction=down&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $downImg; $txt .= "</a> "; } else { if ($one->ItemOrder() - 1 == $sameLevel - 1) { $txt .= " <a class=\"move_up\" onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&direction=up&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $upImg; $txt .= "</a>"; } else { $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&direction=down&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $downImg; $txt .= "</a> <a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&direction=up&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $upImg; $txt .= "</a>"; } } } // $txt .= '<input clsss="hidden" type="text" name="order-'. $one->Id().'" value="'.$one->ItemOrder().'" class="order" />'; } if (!empty($txt)) { $columns['move'] = $txt; } // end of move code } /* view column */ if ($columnstodisplay['view']) { $columns['view'] = ' '; $txt = ''; $url = $one->GetURL(); if ($url != '' && $url != '#' && $one->IsViewable() && $one->Active()) { $txt .= "<a href=\"" . $url . "\" rel=\"external\" target=\"_blank\">"; $txt .= $viewImg . "</a>"; } if (!empty($txt)) { $columns['view'] = $txt; } } /* copy column */ if ($columnstodisplay['copy']) { $columns['copy'] = ' '; $txt = ''; if ($one->IsCopyable() && (check_permission($userid, 'Add Pages') && (check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) || check_permission($userid, 'Manage All Content'))) { $txt .= '<a href="copycontent.php' . $urlext . '&content_id=' . $one->Id() . '">'; $txt .= $copyImg . "</a>"; } if (!empty($txt)) { $columns['copy'] = $txt; } } /* edit column */ if ($columnstodisplay['edit']) { $columns['edit'] = ' '; $txt = ''; if (check_modify_all($userid) || check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages) || check_permission($userid, 'Manage All Content')) { // edit link $txt .= "<a href=\"editcontent.php" . $urlext . "&content_id=" . $one->Id() . "\">"; $txt .= $editImg; $txt .= "</a>"; } if (!empty($txt)) { $columns['edit'] = $txt; } } /* delete column */ if ($columnstodisplay['delete']) { $columns['delete'] = ' '; $txt = ''; if ($one->DefaultContent() != true) { if ($root->getChildrenCount() == 0 && (check_permission($userid, 'Remove Pages') && (check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) || check_permission($userid, 'Manage All Content'))) { //$txt .= "<a href=\"{$thisurl}&deletecontent=".$one->Id()."\" onclick=\"confirm('".cms_html_entity_decode_utf8(lang('deleteconfirm', $one->mName), true)."');\">"; $txt .= "<a href=\"{$thisurl}&deletecontent=" . $one->Id() . "\" onclick=\"if (confirm('" . cms_html_entity_decode_utf8(lang('deleteconfirm', $one->Name()), true) . "')) xajax_content_delete(" . $one->Id() . "); return false;\">"; $txt .= $deleteImg; $txt .= "</a>"; } } if (!empty($txt)) { $columns['delete'] = $txt; } } if ($columnstodisplay['multiselect']) { /* multiselect */ $columns['multiselect'] = ' '; $txt = ''; $remove = check_permission($userid, 'Remove Pages') ? 1 : 0; $structure = check_permission($userid, 'Manage All Content') ? 1 : 0; $editperms = check_permission($userid, 'Modify Any Page') || quick_check_authorship($one->Id(), $mypages) || check_ownership($userid, $one->Id()) ? 1 : 0; if (($structure == 1 || $remove == 1 && $editperms == 1) && $one->Type() != 'errorpage') { $txt .= '<label class="invisible" for="multicontent-' . $one->Id() . '">' . lang('toggle') . '</label><input type="checkbox" id="multicontent-' . $one->Id() . '" name="multicontent-' . $one->Id() . '" title="' . lang('toggle') . '"/>'; } if (!empty($txt)) { $columns['multiselect'] = $txt; } } /* done */ foreach ($columns as $name => $value) { if (!$columnstodisplay[$name]) { continue; } switch ($name) { case 'edit': case 'default': case 'view': case 'copy': case 'delete': case 'active': $thelist .= '<td class="pagepos">' . $value . "</td>\n"; break; case 'move': $thelist .= '<td class="move">' . $value . "</td>\n"; break; case 'multiselect': $thelist .= '<td class="checkbox">' . $value . "</td>\n"; break; default: $thelist .= '<td>' . $value . "</td>\n"; break; } } $thelist .= "</tr>\n"; $currow == "row1" ? $currow = "row2" : ($currow = "row1"); } $pagelist[] = $thelist; $indent = get_preference($userid, 'indent', true); if (in_array($one->Id(), $openedArray) && is_array($children) && count($children)) { // count through all the children and see if we can display the move column. $author_allpages = check_permission($userid, 'Reorder Content') && check_peer_authorship($userid, $children[0]->getId()); foreach ($children as $child) { display_hierarchy($child, $userid, $modifyall, $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $copyImg, $deleteImg, $expandImg, $contractImg, $mypages, $page, $columnstodisplay, $author_allpages); } } }
/** * @since 1.11 * @author calguy1000 * @internal * @ignore */ public static function smarty_internal_fetch_contentblock($params, $template) { $smarty = $template->smarty; $gCms = cmsms(); $contentobj = $gCms->variables['content_obj']; $page_id = cmsms()->get_variable('page_id'); if (is_object($contentobj)) { if (!$contentobj->IsPermitted()) { throw new CmsError403Exception(); } $id = ''; $modulename = ''; $action = ''; $inline = false; if (isset($_REQUEST['module'])) { $modulename = $_REQUEST['module']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $modulename = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : ''; $action = isset($ary[2]) ? $ary[2] : ''; $inline = isset($ary[3]) && $ary[3] == 1 ? true : false; } if (isset($_REQUEST[$id . 'action'])) { $action = $_REQUEST[$id . 'action']; } else { if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } } //Only consider doing module processing if //a. There is no block parameter //b. then // 1. $id is cntnt01 or _preview_ // 2. or inline is false if (!isset($params['block']) && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) { // todo, would be neat here if we could get a list of only frontend modules. $installedmodules = ModuleOperations::get_instance()->GetInstalledModules(); if (count($installedmodules)) { // case insensitive module match. foreach ($installedmodules as $key) { if (strtolower($modulename) == strtolower($key)) { $modulename = $key; } } if (!isset($modulename) || empty($modulename)) { // no module specified. @trigger_error('Attempt to call a module action, without specifying a valid module name'); return self::content_return('', $params, $smarty); } $modobj = ModuleOperations::get_instance()->get_module_instance($modulename); if (!$modobj) { // module not found... couldn't even autoload it. @trigger_error('Attempt to access module ' . $modulename . ' which could not be found (is it properly installed and configured?'); return self::content_return('', $params, $smarty); } if ($modobj->IsPluginModule()) { @ob_start(); unset($params['block']); unset($params['label']); unset($params['wysiwyg']); unset($params['oneline']); unset($params['default']); unset($params['size']); unset($params['tab']); $params = array_merge($params, GetModuleParameters($id)); $returnid = ''; if (isset($params['returnid'])) { $returnid = $params['returnid']; } else { $returnid = $contentobj->Id(); } $oldcache = $smarty->caching; $smarty->caching = false; $result = $modobj->DoActionBase($action, $id, $params, $returnid); $smarty->caching = $oldcache; if ($result !== FALSE) { echo $result; } $modresult = @ob_get_contents(); @ob_end_clean(); return self::content_return($modresult, $params, $smarty); } else { @trigger_error('Attempt to access module ' . $key . ' which could not be found (is it properly installed and configured?'); return self::content_return("<!-- Not a tag module -->\n", $params, $smarty); } } } else { $block = isset($params['block']) ? $params['block'] : 'content_en'; $result = ''; $oldvalue = $smarty->caching; $smarty->caching = false; if ($id == '_preview_' || $page_id == '__CMS_PREVIEW_PAGE__') { // note: content precompile/postcompile events will not be triggererd in preview. $val = $contentobj->Show($block); $result = $smarty->fetch('string:' . $val); } else { $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $block), '|' . $block, $contentobj->Id() . $block); } $smarty->caching = $oldvalue; return self::content_return($result, $params, $smarty); } } return _smarty_cms_function_content_return('', $params, $smarty); }
/** * @access private */ function cms_module_CreateFieldsetStart(&$modinstance, $id, $name, $legend_text = '', $addtext = '', $addtext_legend = '') { $id = cms_htmlentities($id); $name = cms_htmlentities($name); $legend_text = cms_htmlentities($legend_text); $text = '<fieldset class="cms_fieldset" ' . $addtext . '>' . "\n"; $text .= '<legend class="cms_legend" ' . $addtext_legend . '>' . "\n"; $text .= $legend_text; $text .= '</legend>'; return $text; }
} } } $result->MoveNext(); } $col->CalculateWeights(); if ($this->GetPreference('alpharesults', 'false') == 'true') { $col->Sort(); } // now we're gonna do some post processing on the results // and replace the search terms with <span class="searchhilite">term</span> $results = $col->_ary; $newresults = array(); foreach ($results as $result) { $title = cms_htmlentities($result->title); $txt = cms_htmlentities($result->urltxt); foreach ($words as $word) { $word = preg_quote($word); $title = preg_replace('/\\b(' . $word . ')\\b/i', '<span class="searchhilite">$1</span>', $title); $txt = preg_replace('/\\b(' . $word . ')\\b/i', '<span class="searchhilite">$1</span>', $txt); } $result->title = $title; $result->urltxt = $txt; $newresults[] = $result; } $col->_ary = $newresults; @$this->SendEvent('SearchCompleted', array(&$params['searchinput'], &$col->_ary)); $smarty->assign('searchwords', $words); $smarty->assign('results', $col->_ary); $smarty->assign('itemcount', count($col->_ary)); $searchendtime = microtime();
if (isset($_POST["wysiwyg"])) { $wysiwyg = $_POST["wysiwyg"]; } $syntaxhighlighter = ''; if (isset($_POST["syntaxhighlighter"])) { $syntaxhighlighter = $_POST["syntaxhighlighter"]; } $gcb_wysiwyg = 0; if (isset($_POST['gcb_wysiwyg'])) { $gcb_wysiwyg = 1; } $date_format_string = '%x %X'; if (isset($_POST['date_format_string'])) { $date_format_string = $_POST['date_format_string']; } $date_format_string = cms_htmlentities(strip_tags($date_format_string)); $listtemplates_pagelimit = '20'; if (isset($_POST['listtemplates_pagelimit'])) { $listtemplates_pagelimit = $_POST['listtemplates_pagelimit']; } $liststylesheets_pagelimit = '20'; if (isset($_POST['liststylesheets_pagelimit'])) { $liststylesheets_pagelimit = $_POST['liststylesheets_pagelimit']; } $listgcbs_pagelimit = '20'; if (isset($_POST['listgcbs_pagelimit'])) { $listgcbs_pagelimit = $_POST['listgcbs_pagelimit']; } $default_parent = ''; if (isset($_POST['parent_id'])) { $default_parent = $_POST['parent_id'];
function &FillNode(&$content, &$node, &$nodelist, &$count, &$prevdepth, $origdepth, $deep = false, $params = array()) { $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->haschildren = false; if ($content->DefaultContent()) { $onenode->default = 1; } $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 (is_object($node) && $node->has_children()) { $children = $node->get_children(); if ($children) { for ($i = 0; $i < count($children); $i++) { $tmpc = $children[$i]->getContent(false, true, true); if (is_object($tmpc) && $tmpc->Active() && $tmpc->ShowInMenu()) { $onenode->children_exist = true; break; } } } } $prevdepth = $onenode->depth + ($origdepth - 1); $onenode->menutext = cms_htmlentities($content->MenuText()); $onenode->raw_menutext = $content->MenuText(); $onenode->target = ''; $onenode->index = $count; $onenode->alias = $content->Alias(); $onenode->parent = false; $count++; $gCms = cmsms(); if ($deep) { $config = cmsms()->GetConfig(); $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; }
#along with this program; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #$Id: listtags.php 6473 2010-07-04 03:21:29Z wishy $ $CMS_ADMIN_PAGE = 1; $CMS_LOAD_ALL_PLUGINS = 1; require_once "../include.php"; $urlext = '?' . CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY]; check_login(); $plugin = ""; if (isset($_GET["plugin"])) { $plugin = cms_htmlentities($_GET["plugin"]); } $action = ""; if (isset($_GET["action"])) { $action = cms_htmlentities($_GET["action"]); } $userid = get_userid(); $access = check_permission($userid, "View Tag Help"); //if( !$access ) return; if (!$access) { die('Permission Denied'); return; } #$smarty = new Smarty_CMS($gCms->config); debug_buffer('before header'); include_once "header.php"; debug_buffer('after header'); if ($action == "showpluginhelp") { if (function_exists('smarty_cms_help_function_' . $plugin)) { echo '<div class="pagecontainer">';
/** * A method to display a single input element for an object basic, or extended property. * * @abstract * @param string The property name * @param boolean Wether or not we are in add or edit mode. * @return array consisting of two elements. A label, and the input element. */ protected function display_single_element($one, $adding) { $gCms = cmsms(); $config = $gCms->GetConfig(); switch ($one) { case 'cachable': return array('<label for="in_cachable">' . lang('cachable') . ':</label>', '<input type="hidden" name="cachable" value="0"/><input id="in_cachable" class="pagecheckbox" type="checkbox" value="1" name="cachable"' . ($this->mCachable ? ' checked="checked"' : '') . ' />', lang('help_page_cachable')); break; case 'title': return array('<label for="in_title">*' . lang('title') . '</label>:', '<input type="text" id="in_title" name="title" value="' . cms_htmlentities($this->mName) . '" />'); break; case 'menutext': return array('<label for="in_menutext">*' . lang('menutext') . '</label>:', '<input type="text" name="menutext" id="in_menutext" value="' . cms_htmlentities($this->mMenuText) . '" />'); break; case 'parent': $contentops = $gCms->GetContentOperations(); $tmp = $contentops->CreateHierarchyDropdown($this->mId, $this->mParentId, 'parent_id', 0, 1, 0, 1, get_site_preference('listcontent_showtitle', true)); if (empty($tmp) && !check_permission(get_userid(), 'Manage All Content')) { return array('', '<input type="hidden" name="parent_id" value="' . $this->mParentId . '" />'); } if (!empty($tmp)) { return array('<label for="parent_id">' . lang('parent') . '</label>:', $tmp); } break; case 'active': if (!$this->DefaultContent()) { return array('<label for="id_active">' . lang('active') . '</label>:', '<input type="hidden" name="active" value="0"/><input class="pagecheckbox" type="checkbox" name="active" id="id_active" value="1"' . ($this->mActive ? ' checked="checked"' : '') . ' />'); } break; case 'showinmenu': return array('<label for="showinmenu">' . lang('showinmenu') . '</label>:', '<input type="hidden" name="showinmenu" value="0"/><input class="pagecheckbox" type="checkbox" value="1" name="showinmenu" id="showinmenu"' . ($this->mShowInMenu ? ' checked="checked"' : '') . ' />'); break; case 'target': $text = '<option value="---">' . lang('none') . '</option>'; $text .= '<option value="_blank"' . ($this->GetPropertyValue('target') == '_blank' ? ' selected="selected"' : '') . '>_blank</option>'; $text .= '<option value="_parent"' . ($this->GetPropertyValue('target') == '_parent' ? ' selected="selected"' : '') . '>_parent</option>'; $text .= '<option value="_self"' . ($this->GetPropertyValue('target') == '_self' ? ' selected="selected"' : '') . '>_self</option>'; $text .= '<option value="_top"' . ($this->GetPropertyValue('target') == '_top' ? ' selected="selected"' : '') . '>_top</option>'; return array('<label for="target">' . lang('target') . '</label>:', '<select name="target" id="target">' . $text . '</select>', lang('info_target')); break; case 'alias': return array('<label for="alias">' . lang('pagealias') . '</label>:', '<input type="text" name="alias" id="alias" value="' . $this->mAlias . '" />', lang('help_page_alias')); break; case 'secure': $opt = ''; if ($this->mSecure) { $opt = ' checked="checked"'; } $str = '<input type="hidden" name="secure" value="0"/>'; $str .= '<input type="checkbox" name="secure" id="secure" value="1"' . $opt . '/>'; return array('<label for="secure">' . lang('secure_page') . '</label>:', $str); break; case 'page_url': if (!$this->DefaultContent()) { $str = '<input type="text" name="page_url" id="page_url" value="' . $this->mURL . '" size="50" maxlength="255"/>'; $prompt = '<label for="page_url">' . lang('page_url') . '</label>:'; if (get_site_preference('content_mandatory_urls', 0)) { $prompt = '*' . $prompt; } return array($prompt, $str, lang('help_page_url')); } break; case 'image': $dir = cms_join_path($config['image_uploads_path'], get_site_preference('content_imagefield_path')); $data = $this->GetPropertyValue('image'); $dropdown = create_file_dropdown('image', $dir, $data, 'jpg,jpeg,png,gif', '', true, '', 'thumb_', 1, 1); if (!$dropdown) { return; } return array('<label for="image">' . lang('image') . '</label>:', $dropdown); break; case 'thumbnail': $dir = cms_join_path($config['image_uploads_path'], get_site_preference('content_thumbnailfield_path')); $data = $this->GetPropertyValue('thumbnail'); $dropdown = create_file_dropdown('thumbnail', $dir, $data, 'jpg,jpeg,png,gif', '', true, '', 'thumb_', 0, 1); if (!$dropdown) { return FALSE; } return array('<label for="thumbnail">' . lang('thumbnail') . '</label>:', $dropdown); break; case 'titleattribute': return array('<label for="titleattribute">' . lang('titleattribute') . '</label>:', '<input type="text" name="titleattribute" id="titleattribute" maxlength="255" size="80" value="' . cms_htmlentities($this->mTitleAttribute) . '" />'); break; case 'accesskey': return array('<label for="accesskey">' . lang('accesskey') . '</label>:', '<input type="text" name="accesskey" id="accesskey" maxlength="5" value="' . cms_htmlentities($this->mAccessKey) . '" />'); break; case 'tabindex': return array('<label for="tabindex">' . lang('tabindex') . '</label>:', '<input type="text" name="tabindex" id="tabindex" maxlength="5" value="' . cms_htmlentities($this->mTabIndex) . '" />'); break; case 'extra1': return array('<label for="extra1">' . lang('extra1') . '</label>:', '<input type="text" name="extra1" id="extra1" maxlength="255" size="80" value="' . cms_htmlentities($this->GetPropertyValue('extra1')) . '" />'); break; case 'extra2': return array('<label for="extra2">' . lang('extra2') . '</label>:', '<input type="text" name="extra2" id="extra2" maxlength="255" size="80" value="' . cms_htmlentities($this->GetPropertyValue('extra2')) . '" />'); break; case 'extra3': return array('<label for="extra3">' . lang('extra3') . '</label>:', '<input type="text" name="extra3" id="extra3" maxlength="255" size="80" value="' . cms_htmlentities($this->GetPropertyValue('extra3')) . '" />'); break; case 'owner': $showadmin = check_ownership(get_userid(), $this->Id()); $userops = $gCms->GetUserOperations(); if (!$adding && ($showadmin || check_permission(get_userid(), 'Manage All Content'))) { return array('<label for="owner">' . lang('owner') . '</label>:', $userops->GenerateDropdown($this->Owner())); } break; case 'additionaleditors': // do owner/additional-editor stuff if ($adding || check_ownership(get_userid(), $this->Id()) || check_permission(get_userid(), 'Manage All Content')) { return $this->ShowAdditionalEditors(); } break; default: stack_trace(); die('unknown property ' . $one); } }
$smarty->assign('date_format_string', get_preference($userid, 'date_format_string', '%x %X')); try { $id = 'm1_'; $module = ''; $action = 'defaultadmin'; $suppressOutput = false; if (isset($_REQUEST['module'])) { $module = $_REQUEST['module']; } if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $module = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : 'm1_'; $action = isset($ary[2]) ? $ary[2] : ''; } if (!$module) { trigger_error('Module action specified, but could not determine the module.'); redirect("index.php" . $urlext); } $modinst = ModuleOperations::get_instance()->get_module_instance($module); if (!$modinst) { trigger_error('Module ' . $module . ' not found in memory. This could indicate that the module is in need of upgrade or that there are other problems'); redirect("index.php" . $urlext); } if (get_preference($userid, 'use_wysiwyg') == '1' && $modinst->IsWYSIWYG()) { $htmlarea_flag = "true";
if (isset($_POST['liststylesheets_pagelimit'])) { $liststylesheets_pagelimit = $_POST['liststylesheets_pagelimit']; } $listgcbs_pagelimit = '20'; if (isset($_POST['listgcbs_pagelimit'])) { $listgcbs_pagelimit = $_POST['listgcbs_pagelimit']; } $hide_help_links = isset($_POST['hide_help_links']) ? 1 : 0; $ignoredmodules = array(); if (isset($_POST['ignoredmodules'])) { $ignoredmodules = $_POST['ignoredmodules']; if (in_array('**none**', $ignoredmodules)) { $ignoredmodules = array(); } } $homepage = cms_htmlentities(trim($_POST['homepage'])); # Set prefs set_preference($userid, 'gcb_wysiwyg', $gcb_wysiwyg); set_preference($userid, 'wysiwyg', $wysiwyg); set_preference($userid, 'syntaxhighlighter', $syntaxhighlighter); set_preference($userid, 'default_cms_language', $default_cms_language); set_preference($userid, 'admintheme', $admintheme); set_preference($userid, 'bookmarks', $bookmarks); set_preference($userid, 'hide_help_links', $hide_help_links); set_preference($userid, 'indent', $indent); set_preference($userid, 'enablenotifications', $enablenotifications); set_preference($userid, 'paging', $paging); set_preference($userid, 'date_format_string', $date_format_string); set_preference($userid, 'default_parent', $default_parent); set_preference($userid, 'listtemplates_pagelimit', $listtemplates_pagelimit); set_preference($userid, 'liststylesheets_pagelimit', $liststylesheets_pagelimit);
function display_single_element($one, $adding) { switch ($one) { case 'page': $gCms = cmsms(); $contentops =& $gCms->GetContentOperations(); $tmp = $contentops->CreateHierarchyDropdown($this->mId, $this->GetPropertyValue('page'), 'page', 1, 0, 0, 0); if (!empty($tmp)) { return array(lang('destination_page') . ':', $tmp); } break; case 'params': $val = cms_htmlentities($this->GetPropertyValue('params')); return array(lang('additional_params') . ':', '<input type="text" name="params" value="' . $val . '" />'); break; default: return parent::display_single_element($one, $adding); } }
function smarty_function_breadcrumbs($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); $manager = $gCms->GetHierarchyManager(); $thispage = $gCms->variables['content_id']; $trail = ""; #Check if user has specified a delimiter, otherwise use default if (isset($params['delimiter'])) { $delimiter = $params['delimiter']; } else { $delimiter = ">>"; } #Check if user has requested an initial delimiter if (isset($params['initial'])) { if ($params['initial'] == "1") { $trail .= $delimiter . " "; } } $root = '##ROOT_NODE##'; #Check if user has requested the list to start with a specific page if (isset($params['root'])) { $root = $params['root']; } $root_url = ''; #Check if user has requested to overrided the root URL if (isset($params['root_url'])) { $root_url = $params['root_url']; } $endNode = $manager->sureGetNodeById($thispage); # build path if (isset($endNode)) { $content = $endNode->getContent(); $path = array($endNode); $currentNode = $endNode->getParentNode(); while (isset($currentNode) && $currentNode->getLevel() >= 0) { $content = $currentNode->getContent(); if (isset($content)) { //Add current node to the path and then check to see if //current node is the set root //as long as it's not hidden if ($content->ShowInMenu() && $content->Active()) { $path[] = $currentNode; } if (strtolower($content->Alias()) != strtolower($root)) { //Get the parent node and loop $currentNode = $currentNode->getParentNode(); } else { //No need to get the parent node -- we're the set root already break; } } else { //There are more serious problems here, dump out while we can break; } } if ($root != '##ROOT_NODE##') { // check if the last added is root. if not, add it $currentNode = $manager->sureGetNodeByAlias($root); if (isset($currentNode)) { $top_alias = '##garbage##'; if (count($path)) { $top_alias = $path[count($path) - 1]->get_tag('alias'); } if (strtolower($top_alias) != strtolower($root)) { $content = $currentNode->getContent(); if (is_object($content) && $content->Active() && $content->ShowInMenu()) { $path[] = $currentNode; } } } } $classid = isset($params['classid']) ? ' class="' . $params['classid'] . '"' : ''; $currentclassid = isset($params['currentclassid']) ? ' class="' . $params['currentclassid'] . '"' : ''; // now create the trail (by iterating through the path we built, backwards) for ($i = count($path) - 1; $i >= 0; $i--) { $node = $path[$i]; if (isset($node)) { $onecontent = $node->getContent(); if ($onecontent->Id() != $thispage && $onecontent->Type() != 'seperator') { if ($onecontent->getURL() != "" && $onecontent->Type() != 'sectionheader') { if ($onecontent->DefaultContent() && false == empty($root_url)) { $trail .= '<a href="' . $root_url . '"'; } else { $trail .= '<a href="' . $onecontent->getURL() . '"'; } $trail .= $classid; $trail .= '>'; $trail .= cms_htmlentities($onecontent->MenuText() != '' ? $onecontent->MenuText() : $onecontent->Name()); $trail .= '</a> '; } else { $trail .= "<span {$classid}>"; $trail .= cms_htmlentities($onecontent->MenuText() != '' ? $onecontent->MenuText() : $onecontent->Name()); $trail .= '</span>'; $trail .= ' '; } $trail .= $delimiter . ' '; } else { if (isset($params['currentclassid'])) { $trail .= "<span {$currentclassid}>"; } else { $trail .= '<span class="lastitem">'; } $trail .= cms_htmlentities($onecontent->MenuText() != '' ? $onecontent->MenuText() : $onecontent->Name()); if (isset($params['currentclassid'])) { $trail .= '</span>'; } else { $trail .= '</span>'; } } } } } if (isset($params['starttext']) && $params['starttext'] != '') { $trail = $params['starttext'] . ': ' . $trail; } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $trail); return; } return $trail; }
function dump_array($params, &$data, $level = 1, $ignore = array(), $accessor) { $maxlevel = 3; if (isset($params['maxlevel'])) { $maxlevel = (int) $params['maxlevel']; $maxlevel = max(1, $maxlevel); $maxlevel = min(10, $maxlevel); } if ($level > $maxlevel) { return; } $str = ''; foreach ($data as $key => $value) { $acc = build_accessor($accessor, 'array', $key); $type = gettype($value); if (is_object($value)) { $str .= str_repeat(' ', $level) . '- <u>' . $key . ' = Object</u> <em>{$' . $acc . '}</em><br/>'; if (isset($params['recurse'])) { $str .= dump_object($params, $value, $level + 1, $ignore, $acc); } } else { if (is_array($value)) { $str .= str_repeat(' ', $level) . "- <u>{$key} = Array (" . count($value) . ')</u> <em>{$' . $acc . '}</em><br/>'; if (isset($params['recurse'])) { $str .= dump_array($params, $value, $level + 1, $ignore, $acc); } } else { if ($type == 'NULL') { $str .= str_repeat(' ', $level) . '- ' . $name . ': NULL <em>{$' . $acc . '\\}</em><br/>'; } else { $str .= str_repeat(' ', $level) . "- {$key} = " . cms_htmlentities($value) . ' {$' . $acc . '}<br/>'; } } } } return $str; }
function display_hierarchy(&$root, &$userid, $modifyall, &$templates, &$users, &$menupos, &$openedArray, &$pagelist, &$image_true, &$image_set_false, &$image_set_true, &$upImg, &$downImg, &$viewImg, &$editImg, &$copyImg, &$deleteImg, &$expandImg, &$contractImg, &$mypages, &$page, $columnstodisplay) { global $thisurl; global $urlext; global $currow; global $config; global $page; global $indent; if (empty($currow)) { $currow = 'row1'; } $children =& $root->getChildren(false, true); $one =& $root->getContent(); $thelist = ''; if (!(isset($one) && $one != NULL)) { return; } if (!array_key_exists($one->TemplateId(), $templates)) { global $gCms; $templateops =& $gCms->GetTemplateOperations(); $templates[$one->TemplateId()] = $templateops->LoadTemplateById($one->TemplateId()); } if (!array_key_exists($one->Owner(), $users)) { global $gCms; $userops =& $gCms->GetUserOperations(); $users[$one->Owner()] =& $userops->LoadUserById($one->Owner()); } $display = 'none'; if (check_modify_all($userid) || check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) { $display = 'edit'; } else { if (check_children($root, $mypages, $userid)) { $display = 'view'; } else { if (check_permission($userid, 'Manage All Content')) { $display = 'structure'; } } } $columns = array(); if ($display != 'none') { $thelist .= "<tr id=\"tr_" . $one->Id() . "\" class=\"{$currow}\" onmouseover=\"this.className='" . $currow . 'hover' . "';\" onmouseout=\"this.className='" . $currow . "';\">\n"; /* expand/collapse column */ $columns['expand'] = ' '; if ($columnstodisplay['expand']) { $txt = ''; if ($root->hasChildren()) { if (!in_array($one->Id(), $openedArray)) { $txt .= "<a href=\"{$thisurl}&content_id=" . $one->Id() . "&col=0&page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'false'); return false;\">"; $txt .= $expandImg; $txt .= "</a>"; } else { $txt .= "<a href=\"{$thisurl}&content_id=" . $one->Id() . "&col=1&page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'true'); return false;\">"; $txt .= $contractImg; $txt .= "</a>"; } } if (!empty($txt)) { $columns['expand'] = $txt; } } /* hierarchy column */ if ($columnstodisplay['hier']) { $columns['hier'] = $one->Hierarchy(); } /* page column */ if ($columnstodisplay['page']) { $columns['page'] = ' '; $txt = ''; if ($one->mMenuText != CMS_CONTENT_HIDDEN_NAME) { if ($indent) { for ($i = 0; $i < $root->getLevel(); $i++) { $txt .= "- "; } } if ($display == 'edit') { $txt .= '<a href="editcontent.php' . $urlext . '&content_id=' . $one->mId . '&page=' . $page . '" title="' . cms_htmlentities($one->mName . ' (' . $one->mAlias . ')', '', '', true) . '">' . cms_htmlentities($one->mMenuText, '', '', true) . '</a>'; } else { $txt .= cms_htmlentities($one->mMenuText, '', '', true); } } if (!empty($txt)) { $columns['page'] = $txt; } } /* template column */ if ($columnstodisplay['template']) { $columns['template'] = ' '; $txt = ''; if ($one->Type() != 'pagelink' && $one->Type() != 'link' && $one->Type() != 'sectionheader' && $one->Type() != 'separator') { if (isset($templates[$one->TemplateId()]->name) && $templates[$one->TemplateId()]->name && check_permission($userid, 'Modify Templates')) { $txt .= "<a href=\"edittemplate.php" . $urlext . "&template_id=" . $one->TemplateId() . "&from=content\">" . cms_htmlentities($templates[$one->TemplateId()]->name, '', '', true) . "</a>"; } else { $txt .= $templates[$one->TemplateId()]->name; } } if (!empty($txt)) { $columns['template'] = $txt; } } /* friendly name column */ if ($columnstodisplay['friendlyname']) { $columns['friendlyname'] = $one->FriendlyName(); } /* owner column */ if ($columnstodisplay['owner']) { $columns['owner'] = ' '; if ($one->Owner() > -1) { $columns['owner'] = $users[$one->Owner()]->username; } } /* active column */ if ($columnstodisplay['active']) { $columns['active'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content') && $one->Type() != 'errorpage') { if ($one->Active()) { $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&setinactive=" . $one->Id() . "\" onclick=\"xajax_content_setinactive(" . $one->Id() . ");return false;\">" . $image_set_false . "</a>"; } else { $txt = "<a href=\"{$thisurl}&setactive=" . $one->Id() . "\" onclick=\"xajax_content_setactive(" . $one->Id() . ");return false;\">" . $image_set_true . "</a>"; } } if (!empty($txt)) { $columns['active'] = $txt; } } /* default content */ if ($columnstodisplay['default']) { $columns['default'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content')) { if ($one->IsDefaultPossible()) { $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&makedefault=" . $one->Id() . "\" onclick=\"if(confirm('" . cms_html_entity_decode_utf8(lang("confirmdefault", $one->mName), true) . "')) xajax_content_setdefault(" . $one->Id() . ");return false;\">" . $image_set_true . "</a>"; } } if (!empty($txt)) { $columns['default'] = $txt; } } /* move column */ if ($columnstodisplay['move']) { // code for move up is simple $columns['move'] = ' '; $txt = ''; if (check_permission($userid, 'Manage All Content')) { $sameLevel = $root->getSiblingCount(); if ($sameLevel > 1) { if ($one->ItemOrder() - 1 <= 0) { $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&direction=down&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $downImg; $txt .= "</a> "; } else { if ($one->ItemOrder() - 1 == $sameLevel - 1) { $txt .= " <a class=\"move_up\" onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&direction=up&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $upImg; $txt .= "</a>"; } else { $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&direction=down&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $downImg; $txt .= "</a> <a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&direction=up&content_id=" . $one->Id() . "&parent_id=" . $one->ParentId() . "&page=" . $page . "\">"; $txt .= $upImg; $txt .= "</a>"; } } } // $txt .= '<input clsss="hidden" type="text" name="order-'. $one->Id().'" value="'.$one->ItemOrder().'" class="order" />'; } if (!empty($txt)) { $columns['move'] = $txt; } // end of move code } /* view column */ if ($columnstodisplay['view']) { $columns['view'] = ' '; $txt = ''; $url = $one->GetURL(); if ($url != '' && $url != '#' && $one->IsViewable() && $one->Active()) { $txt .= "<a href=\"" . $url . "\" rel=\"external\" target=\"_blank\">"; $txt .= $viewImg . "</a>"; } if (!empty($txt)) { $columns['view'] = $txt; } } /* copy column */ if ($columnstodisplay['copy']) { $columns['copy'] = ' '; $txt = ''; if ($one->IsCopyable() && (check_permission($userid, 'Add Pages') && (check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) || check_permission($userid, 'Manage All Content'))) { $txt .= '<a href="copycontent.php' . $urlext . '&content_id=' . $one->Id() . '">'; $txt .= $copyImg . "</a>"; } if (!empty($txt)) { $columns['copy'] = $txt; } } /* edit column */ if ($columnstodisplay['edit']) { $columns['edit'] = ' '; $txt = ''; if (check_modify_all($userid) || check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages) || check_permission($userid, 'Manage All Content')) { // edit link $txt .= "<a href=\"editcontent.php" . $urlext . "&content_id=" . $one->Id() . "\">"; $txt .= $editImg; $txt .= "</a>"; } if (!empty($txt)) { $columns['edit'] = $txt; } } /* delete column */ if ($columnstodisplay['delete']) { $columns['delete'] = ' '; $txt = ''; if ($one->DefaultContent() != true) { if ($root->getChildrenCount() == 0 && (check_permission($userid, 'Remove Pages') && (check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) || check_permission($userid, 'Manage All Content'))) { $txt .= "<a href=\"{$thisurl}&deletecontent=" . $one->Id() . "\" onclick=\"if (confirm('" . cms_html_entity_decode_utf8(lang('deleteconfirm', $one->mName), true) . "')) xajax_content_delete(" . $one->Id() . "); return false;\">"; $txt .= $deleteImg; $txt .= "</a>"; } } if (!empty($txt)) { $columns['delete'] = $txt; } } if ($columnstodisplay['multiselect']) { /* multiselect */ $columns['multiselect'] = ' '; $txt = ''; $remove = check_permission($userid, 'Remove Pages') ? 1 : 0; $structure = check_permission($userid, 'Manage All Content') ? 1 : 0; $editperms = check_permission($userid, 'Modify Any Page') || quick_check_authorship($one->Id(), $mypages) || check_ownership($userid, $one->Id()) ? 1 : 0; if (($structure == 1 || $remove == 1 && $editperms == 1) && $one->Type() != 'errorpage') { $txt .= '<input type="checkbox" name="multicontent-' . $one->Id() . '" />'; } if (!empty($txt)) { $columns['multiselect'] = $txt; } } /* done */ foreach ($columns as $name => $value) { if (!$columnstodisplay[$name]) { continue; } switch ($name) { case 'edit': case 'default': case 'view': case 'copy': case 'delete': case 'active': $thelist .= '<td class="pagepos">' . $value . "</td>\n"; break; case 'move': $thelist .= '<td class="move">' . $value . "</td>\n"; break; case 'multiselect': $thelist .= '<td class="checkbox">' . $value . "</td>\n"; break; default: $thelist .= '<td>' . $value . "</td>\n"; break; } } $thelist .= "</tr>\n"; $currow == "row1" ? $currow = "row2" : ($currow = "row1"); } $pagelist[] =& $thelist; $indent = get_preference($userid, 'indent', true); if (in_array($one->Id(), $openedArray)) { foreach ($children as $child) { display_hierarchy($child, $userid, $modifyall, $templates, $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $copyImg, $deleteImg, $expandImg, $contractImg, $mypages, $page, $columnstodisplay); } } }