Exemplo n.º 1
0
function smarty_cms_function_edit($params, &$smarty)
{
    global $gCms;
    if (!check_permission(get_userid(false), 'Modify Any Page') && !quick_check_authorship($gCms->variables['content_id'], author_pages(get_userid(false)))) {
        return;
    }
    $urlext = '?' . CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY];
    $text = isset($params['text']) ? $params['text'] : 'Edit This Page';
    if (isset($params["showbutton"])) {
        return '<a href="' . $gCms->config['root_url'] . '/' . $gCms->config['admin_dir'] . '/editcontent.php' . $urlext . '&amp;content_id=' . $gCms->variables['content_id'] . '"><img src="' . $gCms->config['root_url'] . '/images/cms/editbutton.png" alt="' . $text . '"/></a>';
    } else {
        return '<a href="' . $gCms->config['root_url'] . '/' . $gCms->config['admin_dir'] . '/editcontent.php' . $urlext . '&amp;content_id=' . $gCms->variables['content_id'] . '">' . $text . '</a>';
    }
    /*
    global $gCms;
    	
    $userid = get_userid(false);
    if(!$userid) return;
    
    $access = check_permission($userid, 'Modify Any Page');
    if (!$access) return;
    
    $text = 'Edit This Page';
    
    if (!empty($params['text']))
    {
    	$text = $params['text'];
    }
    
    //will this work if using htaccess? (Yes! -Wishy)
    if (isset($params["showbutton"]))
    {
    	return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].'/editcontent.php?content_id='.$gCms->variables['content_id'].'"><img src="'.$gCms->config['root_url'].'/images/cms/editbutton.png" alt="'.$text.'"/></a>';
    }
    else
    {
    	return '<a href="'.$gCms->config['root_url'].'/'.$gCms->config['admin_dir'].'/editcontent.php?content_id='.$gCms->variables['content_id'].'">'.$text.'</a>';
    }
    */
}
Exemplo n.º 2
0
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'] = '&nbsp;';
        if ($columnstodisplay['expand']) {
            $txt = '';
            if ($root->hasChildren()) {
                if (!in_array($one->Id(), $openedArray)) {
                    $txt .= "<a class=\"expand\" href=\"{$thisurl}&amp;content_id=" . $one->Id() . "&amp;col=0&amp;page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'false'); return false;\">";
                    $txt .= $expandImg;
                    $txt .= "</a>";
                } else {
                    $txt .= "<a class=\"contract\" href=\"{$thisurl}&amp;content_id=" . $one->Id() . "&amp;col=1&amp;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'] = '&nbsp;';
            $txt = '';
            if ($one->MenuText() != CMS_CONTENT_HIDDEN_NAME) {
                if ($indent) {
                    for ($i = 0; $i < $root->getLevel(); $i++) {
                        $txt .= "-&nbsp;&nbsp;&nbsp;";
                    }
                }
                $str = $one->MenuText();
                if (get_site_preference('listcontent_showtitle', 0)) {
                    $str = $one->Name();
                }
                if ($display == 'edit') {
                    $txt .= '<a class="tooltip" href="editcontent.php' . $urlext . '&amp;content_id=' . $one->Id() . '&amp;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'] = '&nbsp;';
            $txt = '';
            if ($one->HasUsableLink() && $one->Alias() != '') {
                $txt = $one->Alias();
            }
            if (!empty($txt)) {
                $columns['alias'] = $txt;
            }
        }
        /* url column */
        if ($columnstodisplay['url']) {
            $columns['url'] = '&nbsp;';
            $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'] = '&nbsp;';
            $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 . "&amp;template_id=" . $one->TemplateId() . "&amp;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'] = '&nbsp;';
            if ($one->Owner() > -1) {
                $columns['owner'] = $users[$one->Owner()]->username;
            }
        }
        /* active column */
        if ($columnstodisplay['active']) {
            $columns['active'] = '&nbsp;';
            $txt = '';
            if (check_permission($userid, 'Manage All Content') && $one->Type() != 'errorpage') {
                if ($one->Active()) {
                    $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&amp;setinactive=" . $one->Id() . "\" onclick=\"xajax_content_setinactive(" . $one->Id() . ");return false;\">" . $image_set_false . "</a>";
                } else {
                    $txt = "<a href=\"{$thisurl}&amp;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'] = '&nbsp;';
            $txt = '';
            if (check_permission($userid, 'Manage All Content')) {
                if ($one->IsDefaultPossible()) {
                    $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&amp;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'] = '&nbsp;';
            $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}&amp;direction=down&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                        $txt .= $downImg;
                        $txt .= "</a>&nbsp;&nbsp;";
                    } else {
                        if ($one->ItemOrder() - 1 == $sameLevel - 1) {
                            $txt .= "&nbsp;&nbsp;<a class=\"move_up\" onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&amp;direction=up&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                            $txt .= $upImg;
                            $txt .= "</a>";
                        } else {
                            $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&amp;direction=down&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                            $txt .= $downImg;
                            $txt .= "</a>&nbsp;<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&amp;direction=up&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;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'] = '&nbsp;';
            $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'] = '&nbsp;';
            $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 . '&amp;content_id=' . $one->Id() . '">';
                $txt .= $copyImg . "</a>";
            }
            if (!empty($txt)) {
                $columns['copy'] = $txt;
            }
        }
        /* edit column */
        if ($columnstodisplay['edit']) {
            $columns['edit'] = '&nbsp;';
            $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 . "&amp;content_id=" . $one->Id() . "\">";
                $txt .= $editImg;
                $txt .= "</a>";
            }
            if (!empty($txt)) {
                $columns['edit'] = $txt;
            }
        }
        /* delete column */
        if ($columnstodisplay['delete']) {
            $columns['delete'] = '&nbsp;';
            $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}&amp;deletecontent=".$one->Id()."\" onclick=\"confirm('".cms_html_entity_decode_utf8(lang('deleteconfirm', $one->mName), true)."');\">";
                    $txt .= "<a href=\"{$thisurl}&amp;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'] = '&nbsp;';
            $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);
        }
    }
}
Exemplo n.º 3
0
 echo "<th>" . lang('name') . "</th>\n";
 echo "<th>" . lang('tagtousegcb') . "</th>\n";
 echo "<th>" . lang('description') . "</th>\n";
 echo "<th class=\"pageicon\">&nbsp;</th>\n";
 echo "<th class=\"pageicon\">&nbsp;</th>\n";
 echo "</tr>\n";
 echo "</thead>";
 echo "<tbody>";
 $currow = "row1";
 // construct true/false button images
 $image_true = $themeObject->DisplayImage('icons/system/true.gif', lang('true'), '', '', 'systemicon');
 $image_false = $themeObject->DisplayImage('icons/system/false.gif', lang('false'), '', '', 'systemicon');
 $counter = 0;
 foreach ($htmlbloblist as $onehtmlblob) {
     if ($counter < $page * $limit && $counter >= $page * $limit - $limit) {
         if ($modifyall || quick_check_authorship($onehtmlblob->id, $myblobs)) {
             echo "<tr class=\"{$currow}\">\n";
             echo "<td><a href=\"edithtmlblob.php" . $urlext . "&amp;htmlblob_id=" . $onehtmlblob->id . "\">" . $onehtmlblob->name . "</a></td>\n";
             echo "<td>{global_content name='" . $onehtmlblob->name . "'}</td>\n";
             echo '<td>' . listgcb_summarize($onehtmlblob->description, 20) . '</td>';
             echo "<td><a href=\"edithtmlblob.php" . $urlext . "&amp;htmlblob_id=" . $onehtmlblob->id . "\">";
             echo $themeObject->DisplayImage('icons/system/edit.gif', lang('edit'), '', '', 'systemicon');
             echo "</a></td>\n";
             echo "<td>";
             if ($modifyall || check_permission($userid, 'Remove Global Content Blocks')) {
                 echo "<a href=\"deletehtmlblob.php" . $urlext . "&amp;htmlblob_id=" . $onehtmlblob->id . "\" onclick=\"return confirm('" . lang('deleteconfirm', $onehtmlblob->name) . "');\">";
                 echo $themeObject->DisplayImage('icons/system/delete.gif', lang('delete'), '', '', 'systemicon') . "</a>";
             }
             echo "</td>\n";
             echo "</tr>\n";
             $currow == "row1" ? $currow = "row2" : ($currow = "row1");
Exemplo n.º 4
0
function get_delete_list($sel_nodes, &$parent, &$final_result, $depth = 0)
{
    // get the list of items we should delete
    $userid = get_userid();
    if (!check_permission($userid, 'Remove Pages')) {
        return FALSE;
    }
    global $mypages;
    $status = TRUE;
    foreach ($sel_nodes as $node) {
        if (check_ownership($userid, $node->getTag()) || quick_check_authorship($node->getTag(), $mypages)) {
            $content =& $node->GetContent(false);
            $children =& $node->getChildren(false, true);
            $child_status = array();
            if (isset($children) && count($children)) {
                // we have children.. but we may not have access to
                // any or all of them.
                $tmp = array();
                $child_status = get_delete_list($children, $node, $tmp, $depth + 1);
                if ($child_status === FALSE || count($tmp) == 0) {
                    // there are children, but for one reason or another
                    // we can't delete em. which means we can't delete this
                    // parent either, or any of its parents.
                    $status = FALSE;
                } else {
                    $final_result[] = $content;
                }
                if (count($tmp)) {
                    // there are children se can delete.
                    for ($i = 0; $i < count($tmp); $i++) {
                        $one =& $tmp[$i];
                        $final_result[] =& $one;
                    }
                }
            } else {
                // no children
                $final_result[] = $content;
            }
        } else {
            $status = FALSE;
        }
    }
    return $status;
}
 /**
  * Checks to see if the given user has permission to modify the given global content block. Both user and
  * block are identified by id.
  *
  * @param integer $id The global content block id to check
  * @param integer $user_id The user id to check
  * @return boolean Returns true if the user is the permitted.  False if they are not.
  */
 function CheckAuthorship($id, $user_id)
 {
     $myblobs = $this->AuthorBlobs($user_id);
     return quick_check_authorship($id, $myblobs);
 }
Exemplo n.º 6
0
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'] = '&nbsp;';
        if ($columnstodisplay['expand']) {
            $txt = '';
            if ($root->hasChildren()) {
                if (!in_array($one->Id(), $openedArray)) {
                    $txt .= "<a href=\"{$thisurl}&amp;content_id=" . $one->Id() . "&amp;col=0&amp;page=" . $page . "\" onclick=\"xajax_content_toggleexpand(" . $one->Id() . ", 'false'); return false;\">";
                    $txt .= $expandImg;
                    $txt .= "</a>";
                } else {
                    $txt .= "<a href=\"{$thisurl}&amp;content_id=" . $one->Id() . "&amp;col=1&amp;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'] = '&nbsp;';
            $txt = '';
            if ($one->mMenuText != CMS_CONTENT_HIDDEN_NAME) {
                if ($indent) {
                    for ($i = 0; $i < $root->getLevel(); $i++) {
                        $txt .= "-&nbsp;&nbsp;&nbsp;";
                    }
                }
                if ($display == 'edit') {
                    $txt .= '<a href="editcontent.php' . $urlext . '&amp;content_id=' . $one->mId . '&amp;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'] = '&nbsp;';
            $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 . "&amp;template_id=" . $one->TemplateId() . "&amp;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'] = '&nbsp;';
            if ($one->Owner() > -1) {
                $columns['owner'] = $users[$one->Owner()]->username;
            }
        }
        /* active column */
        if ($columnstodisplay['active']) {
            $columns['active'] = '&nbsp;';
            $txt = '';
            if (check_permission($userid, 'Manage All Content') && $one->Type() != 'errorpage') {
                if ($one->Active()) {
                    $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&amp;setinactive=" . $one->Id() . "\" onclick=\"xajax_content_setinactive(" . $one->Id() . ");return false;\">" . $image_set_false . "</a>";
                } else {
                    $txt = "<a href=\"{$thisurl}&amp;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'] = '&nbsp;';
            $txt = '';
            if (check_permission($userid, 'Manage All Content')) {
                if ($one->IsDefaultPossible()) {
                    $txt = $one->DefaultContent() ? $image_true : "<a href=\"{$thisurl}&amp;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'] = '&nbsp;';
            $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}&amp;direction=down&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                        $txt .= $downImg;
                        $txt .= "</a>&nbsp;&nbsp;";
                    } else {
                        if ($one->ItemOrder() - 1 == $sameLevel - 1) {
                            $txt .= "&nbsp;&nbsp;<a class=\"move_up\" onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&amp;direction=up&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                            $txt .= $upImg;
                            $txt .= "</a>";
                        } else {
                            $txt .= "<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'down'); return false;\" href=\"{$thisurl}&amp;direction=down&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;page=" . $page . "\">";
                            $txt .= $downImg;
                            $txt .= "</a>&nbsp;<a onclick=\"xajax_content_move(" . $one->Id() . ", " . $one->ParentId() . ", 'up'); return false;\" href=\"{$thisurl}&amp;direction=up&amp;content_id=" . $one->Id() . "&amp;parent_id=" . $one->ParentId() . "&amp;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'] = '&nbsp;';
            $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'] = '&nbsp;';
            $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 . '&amp;content_id=' . $one->Id() . '">';
                $txt .= $copyImg . "</a>";
            }
            if (!empty($txt)) {
                $columns['copy'] = $txt;
            }
        }
        /* edit column */
        if ($columnstodisplay['edit']) {
            $columns['edit'] = '&nbsp;';
            $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 . "&amp;content_id=" . $one->Id() . "\">";
                $txt .= $editImg;
                $txt .= "</a>";
            }
            if (!empty($txt)) {
                $columns['edit'] = $txt;
            }
        }
        /* delete column */
        if ($columnstodisplay['delete']) {
            $columns['delete'] = '&nbsp;';
            $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}&amp;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'] = '&nbsp;';
            $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);
        }
    }
}