function updatecontentobj(&$contentobj, $preview = false, $params = null) { if ($params == null) { $params = $_POST; } $userid = get_userid(); $adminaccess = check_ownership($userid, $contentobj->Id()) || check_permission($userid, 'Modify Any Page'); #Fill contentobj with parameters $contentobj->FillParams($params); if ($preview) { $error = $contentobj->ValidateData(); } if (isset($params["ownerid"])) { $contentobj->SetOwner($params["ownerid"]); } $contentobj->SetLastModifiedBy($userid); // #Fill Additional Editors (kind of kludgy) // if (isset($params["additional_editors"])) // { // $addtarray = array(); // foreach ($params["additional_editors"] as $addt_user_id) // { // $addtarray[] = $addt_user_id; // } // $contentobj->SetAdditionalEditors($addtarray); // } // else if ($adminaccess) // { // $contentobj->SetAdditionalEditors(array()); // } }
$xajax->configure('requestURI', $config['admin_url'] . '/editcontent.php?' . CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY] . '&content_id=' . $content_id); $xajax->register(XAJAX_FUNCTION, 'ajaxpreview'); $headtext = $xajax->getJavascript('../lib/xajax') . "\n"; if (isset($_POST["cancel"])) { redirect("listcontent.php" . $urlext); } if ($apply) { $CMS_EXCLUDE_FROM_RECENT = 1; } #Get a list of content types and pick a default if necessary $gCms = cmsms(); $contentops = $gCms->GetContentOperations(); $existingtypes = $contentops->ListContentTypes(false, true); #Get current userid and make sure they have permission to add something $userid = get_userid(); $access = check_ownership($userid, $content_id) || check_permission($userid, 'Modify Any Page') || check_permission($userid, 'Manage All Content'); $adminaccess = $access; if (!$access) { $access = check_authorship($userid, $content_id); } if ($access) { // get the content object. $contentobj = ""; $content_type = 'content'; // default content type. if (!is_object($contentobj) && $content_id != -1) { // load the content object from the database. $contentobj = $contentops->LoadContentFromId($content_id); $content_type = $contentobj->Type(); } if (isset($_POST['content_type'])) {
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); } } }
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; }
/** * 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); } }
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); } } }