function SelectContent_Areas($param, $count_gadgets) { global $dataDir, $langmessage, $config; $slug = 'Admin_Theme_Content/' . rawurlencode($this->curr_layout); $addQuery = 'cmd=addcontent&where=' . rawurlencode($param); echo '<div id="area_lists">'; //extra content echo '<div id="layout_extra_content">'; echo '<table class="bordered">'; echo '<tr><th colspan="2"> </th></tr>'; $extrasFolder = $dataDir . '/data/_extra'; $files = gpFiles::ReadDir($extrasFolder); asort($files); foreach ($files as $file) { $extraName = $file; echo '<tr><td>'; echo str_replace('_', ' ', $extraName); echo '</td><td class="add">'; echo common::Link($slug, $langmessage['add'], $addQuery . '&insert=Extra:' . $extraName, array('data-cmd' => 'creq')); echo '</td></tr>'; } //new extra area echo '<tr><td>'; echo '<form action="' . common::GetUrl($slug) . '" method="post">'; echo '<input type="hidden" name="cmd" value="addcontent" />'; echo '<input type="hidden" name="addtype" value="new_extra" />'; echo '<input type="hidden" name="where" value="' . htmlspecialchars($param) . '" />'; echo '<input type="text" name="extra_area" value="" size="15" class="gpinput"/>'; includeFile('tool/SectionContent.php'); $types = section_content::GetTypes(); echo '<select name="type" class="gpselect">'; foreach ($types as $type => $info) { echo '<option value="' . $type . '">' . $info['label'] . '</option>'; } echo '</select> '; echo ' <input type="submit" name="" value="' . $langmessage['Add New Area'] . '" class="gpbutton"/>'; echo '</form>'; echo '</td><td colspan="2" class="add">'; echo '<form action="' . common::GetUrl($slug) . '" method="post">'; echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />'; echo '</form>'; echo '</td></tr>'; echo '</table>'; echo '</div>'; //gadgets if ($count_gadgets > 0) { echo '<div id="layout_gadgets" class="nodisplay">'; echo '<table class="bordered">'; echo '<tr><th colspan="2"> </th></tr>'; foreach ($config['gadgets'] as $gadget => $info) { echo '<tr>'; echo '<td>'; echo str_replace('_', ' ', $gadget); echo '</td>'; echo '<td class="add">'; echo common::Link($slug, $langmessage['add'], $addQuery . '&insert=' . $gadget, array('data-cmd' => 'creq')); echo '</td>'; echo '</tr>'; } echo '<tr><td colspan="2" class="add">'; echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />'; echo '</td></tr>'; echo '</table>'; echo '</div>'; } //menus echo '<div id="layout_menus" class="nodisplay">'; echo '<form action="' . common::GetUrl($slug) . '" method="post">'; echo '<input type="hidden" name="cmd" value="addcontent" />'; echo '<input type="hidden" name="addtype" value="preset_menu" />'; echo '<input type="hidden" name="where" value="' . htmlspecialchars($param) . '" />'; echo '<table class="bordered">'; $this->PresetMenuForm(); echo '<tr><td colspan="2" class="add">'; echo '<input type="submit" name="" value="' . $langmessage['Add New Menu'] . '" class="gpsubmit" />'; echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />'; echo '</td></tr>'; echo '</table>'; echo '</form>'; echo '</div>'; echo '<div id="layout_custom" class="nodisplay">'; //custom area echo '<form action="' . common::GetUrl($slug) . '" method="post">'; echo '<input type="hidden" name="cmd" value="addcontent" />'; echo '<input type="hidden" name="addtype" value="custom_menu" />'; echo '<input type="hidden" name="where" value="' . htmlspecialchars($param) . '" />'; $this->CustomMenuForm(); echo '<tr><td colspan="2" class="add">'; echo '<input type="submit" name="" value="' . $langmessage['Add New Menu'] . '" class="gpsubmit" />'; echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />'; echo '</td></tr>'; echo '</table>'; echo '</form>'; echo '</div>'; echo '</div>'; }
function ShowExtras() { global $langmessage; $types = section_content::GetTypes(); echo '<h2>' . $langmessage['theme_content'] . '</h2>'; echo '<table class="bordered full_width">'; echo '<tr><th>'; echo $langmessage['file_name']; echo '</th><th>'; echo $langmessage['Content Type']; echo '</th><th> </th><th>'; echo $langmessage['options']; echo '</th></tr>'; $i = 0; foreach ($this->areas as $file) { $extraName = $file; $data = gpOutput::ExtraContent($file); if ($i % 2 == 0) { echo '<tr class="even">'; } else { echo '<tr>'; } echo '<td style="white-space:nowrap">'; echo str_replace('_', ' ', $extraName); echo '</td><td>'; $type = $data['type']; if (isset($types[$type]) && isset($types[$type]['label'])) { $type = $types[$type]['label']; } echo $type; echo '</td><td>"<span class="admin_note">'; $content = strip_tags($data['content']); echo substr($content, 0, 50); echo '</span>..."</td><td style="white-space:nowrap">'; if ($data['type'] == 'text') { echo common::Link('Admin_Extra', $langmessage['edit'], 'cmd=edit&file=' . $file); echo ' '; } echo common::Link('Admin_Extra', $langmessage['preview'], 'cmd=view&file=' . $file); echo ' '; $title = sprintf($langmessage['generic_delete_confirm'], htmlspecialchars($file)); echo common::Link('Admin_Extra', $langmessage['delete'], 'cmd=delete&file=' . $file, array('data-cmd' => 'postlink', 'title' => $title, 'class' => 'gpconfirm')); echo '</td></tr>'; $i++; } echo '</table>'; echo '<p>'; echo '<form action="' . common::GetUrl('Admin_Extra') . '" method="post">'; echo '<input type="hidden" name="cmd" value="new_section" />'; echo '<input type="text" name="file" value="" size="15" class="gpinput"/> '; echo '<select name="type" class="gpselect">'; foreach ($types as $type => $info) { echo '<option value="' . $type . '">' . $info['label'] . '</option>'; } echo '</select> '; echo '<input type="submit" name="" value="' . $langmessage['Add New Area'] . '" class="gppost gpsubmit"/>'; echo '</form>'; echo '</p>'; }
function GetSection(&$section_num) { global $langmessage, $GP_NESTED_EDIT; if (!isset($this->file_sections[$section_num])) { trigger_error('invalid section number'); return; } $curr_section_num = $section_num; $section_num++; $content = ''; $section_data = $this->file_sections[$curr_section_num]; $section_data += array('attributes' => array(), 'type' => 'text'); $section_data['attributes'] += array('class' => ''); $orig_attrs = json_encode($section_data['attributes']); $section_data['attributes']['data-gp-section'] = $curr_section_num; $section_types = section_content::GetTypes(); if (gpOutput::ShowEditLink() && admin_tools::CanEdit($this->gp_index)) { if (isset($section_types[$section_data['type']])) { $title_attr = $section_types[$section_data['type']]['label']; } else { $title_attr = sprintf($langmessage['Section %s'], $curr_section_num + 1); } $attrs = array('title' => $title_attr, 'data-cmd' => 'inline_edit_generic', 'data-arg' => $section_data['type'] . '_inline_edit'); $link = gpOutput::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $curr_section_num . '&revision=' . $this->fileModTime, $attrs); //section control links if ($section_data['type'] != 'wrapper_section') { ob_start(); echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">'; echo $link; echo common::Link($this->title, $langmessage['Manage Sections'] . '...', 'cmd=ManageSections', array('class' => 'manage_sections', 'data-cmd' => 'inline_edit_generic', 'data-arg' => 'manage_sections')); echo '</span>'; gpOutput::$editlinks .= ob_get_clean(); } $section_data['attributes']['id'] = 'ExtraEditArea' . $edit_index; $section_data['attributes']['class'] .= ' editable_area'; // class="edit_area" added by javascript //$section_data['attributes']['data-gp-editarea'] = $edit_index; } if (!isset($section_data['nodeName'])) { $content .= "\n" . '<div' . section_content::SectionAttributes($section_data['attributes'], $section_data['type']) . ' data-gp-attrs=\'' . htmlspecialchars($orig_attrs, ENT_QUOTES & ~ENT_COMPAT) . '\'>'; } else { $content .= "\n" . '<' . $section_data['nodeName'] . section_content::SectionAttributes($section_data['attributes'], $section_data['type']) . ' data-gp-attrs=\'' . htmlspecialchars($orig_attrs, ENT_QUOTES & ~ENT_COMPAT) . '\'>'; } if ($section_data['type'] == 'wrapper_section') { for ($cc = 0; $cc < $section_data['contains_sections']; $cc++) { $content .= $this->GetSection($section_num); } } else { $GP_NESTED_EDIT = true; $content .= section_content::RenderSection($section_data, $curr_section_num, $this->title, $this->file_stats); $GP_NESTED_EDIT = false; } if (!isset($section_data['nodeName'])) { $content .= '<div class="gpclear"></div>'; $content .= '</div>'; } else { $content .= '</' . $section_data['nodeName'] . '>'; } return $content; }
function __construct() { global $langmessage, $page, $config; $this->section_types = section_content::GetTypes(); $page->ajaxReplace = array(); $page->css_admin[] = '/include/css/admin_menu_new.css'; $page->head_js[] = '/include/thirdparty/js/nestedSortable.js'; $page->head_js[] = '/include/thirdparty/js/jquery_cookie.js'; $page->head_js[] = '/include/js/admin_menu_new.js'; $this->max_level_index = max(3, gp_max_menu_level - 1); $page->head_script .= 'var max_level_index = ' . $this->max_level_index . ';'; $this->avail_menus['gpmenu'] = $langmessage['Main Menu'] . ' / ' . $langmessage['site_map']; $this->avail_menus['all'] = $langmessage['All Pages']; $this->avail_menus['hidden'] = $langmessage['Not In Main Menu']; $this->avail_menus['nomenus'] = $langmessage['Not In Any Menus']; $this->avail_menus['search'] = $langmessage['search pages']; if (isset($config['menus'])) { foreach ($config['menus'] as $id => $menu_label) { $this->avail_menus[$id] = $menu_label; } } //early commands $cmd = common::GetCommand(); switch ($cmd) { case 'altmenu_create': $this->AltMenu_Create(); break; case 'rm_menu': $this->AltMenu_Remove(); break; case 'alt_menu_rename': $this->AltMenu_Rename(); break; } //read cookie settings if (isset($_COOKIE['gp_menu_prefs'])) { parse_str($_COOKIE['gp_menu_prefs'], $this->cookie_settings); } $this->SetMenuID(); $this->SetMenuArray(); $this->SetCollapseSettings(); $this->SetQueryInfo(); $cmd_after = gpPlugin::Filter('MenuCommand', array($cmd)); if ($cmd !== $cmd_after) { $cmd = $cmd_after; if ($cmd === 'return') { return; } } switch ($cmd) { case 'rename_menu_prompt': $this->RenameMenuPrompt(); return; //menu creation //menu creation case 'newmenu': $this->NewMenu(); return; case 'homepage_select': $this->HomepageSelect(); return; case 'homepage_save': $this->HomepageSave(); return; //rename //rename case 'renameform': $this->RenameForm(); //will die() return; case 'renameit': $this->RenameFile(); break; case 'hide': $this->Hide(); break; case 'drag': $this->SaveDrag(); break; case 'trash_page': case 'trash': $this->MoveToTrash($cmd); break; case 'add_hidden': $this->AddHidden(); return; case 'new_hidden': $this->NewHiddenFile(); break; case 'new_redir': $this->NewHiddenFile_Redir(); return; case 'copyit': $this->CopyPage(); break; case 'copypage': $this->CopyForm(); return; // Page Insertion // Page Insertion case 'insert_before': case 'insert_after': case 'insert_child': $this->InsertDialog($cmd); return; case 'restore': $this->RestoreFromTrash(); break; case 'insert_from_hidden': $this->InsertFromHidden(); break; case 'new_file': $this->NewFile(); break; //layout //layout case 'layout': case 'uselayout': case 'restorelayout': includeFile('tool/Page_Layout.php'); $page_layout = new page_layout($cmd, 'Admin_Menu', $this->query_string); if ($page_layout->result()) { return; } break; //external links //external links case 'new_external': $this->NewExternal(); break; case 'edit_external': $this->EditExternal(); return; case 'save_external': $this->SaveExternal(); break; } $this->ShowForm($cmd); }
public function GetSection(&$section_num) { global $langmessage; if (!isset($this->file_sections[$section_num])) { trigger_error('invalid section number'); return; } $curr_section_num = $section_num; $section_num++; $content = ''; $section_data = $this->file_sections[$curr_section_num]; //make sure section_data is an array $type = gettype($section_data); if ($type !== 'array') { trigger_error('$section_data is ' . $type . '. Array expected'); return; } $section_data += array('attributes' => array(), 'type' => 'text'); $section_data['attributes'] += array('class' => ''); $orig_attrs = $section_data['attributes']; $section_data['attributes']['data-gp-section'] = $curr_section_num; $section_types = section_content::GetTypes(); if (gpOutput::ShowEditLink() && admin_tools::CanEdit($this->gp_index)) { if (isset($section_types[$section_data['type']])) { $title_attr = $section_types[$section_data['type']]['label']; } else { $title_attr = sprintf($langmessage['Section %s'], $curr_section_num + 1); } $attrs = array('title' => $title_attr, 'data-cmd' => 'inline_edit_generic', 'data-arg' => $section_data['type'] . '_inline_edit'); $link = gpOutput::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $curr_section_num . '&revision=' . $this->fileModTime, $attrs); //section control links if ($section_data['type'] != 'wrapper_section') { ob_start(); echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">'; echo $link; echo common::Link($this->title, $langmessage['Manage Sections'], 'cmd=ManageSections', array('class' => 'manage_sections', 'data-cmd' => 'inline_edit_generic', 'data-arg' => 'manage_sections')); echo '<hr/>'; echo common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', 'data-cmd="gpajax"'); echo common::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox')); echo '</span>'; gpOutput::$editlinks .= ob_get_clean(); } $section_data['attributes']['id'] = 'ExtraEditArea' . $edit_index; $section_data['attributes']['class'] .= ' editable_area'; // class="edit_area" added by javascript } $content .= $this->SectionNode($section_data, $orig_attrs); if ($section_data['type'] == 'wrapper_section') { for ($cc = 0; $cc < $section_data['contains_sections']; $cc++) { $content .= $this->GetSection($section_num); } } else { gpOutput::$nested_edit = true; $content .= section_content::RenderSection($section_data, $curr_section_num, $this->title, $this->file_stats); gpOutput::$nested_edit = false; } if (!isset($section_data['nodeName'])) { $content .= '<div class="gpclear"></div>'; $content .= '</div>'; } else { $content .= section_content::EndTag($section_data['nodeName']); } return $content; }
/** * View all files in the trash * */ function Trash() { global $dataDir, $langmessage; $this->section_types = section_content::GetTypes(); echo '<h2>' . $langmessage['trash'] . '</h2>'; if (count($this->trash_files) == 0) { echo '<ul><li>' . $langmessage['TRASH_IS_EMPTY'] . '</li></ul>'; return false; } echo '<form action="' . common::GetUrl('Admin_Trash') . '" method="post">'; echo '<table class="bordered striped">'; ob_start(); echo '<tr><th colspan="3">'; echo '<input type="checkbox" name="" class="check_all"/>'; echo '</th><th>'; echo '<button type="submit" name="cmd" value="RestoreDeleted" class="gppost gpsubmit">' . $langmessage['restore'] . '</button> '; echo '<button type="submit" name="cmd" value="DeleteFromTrash" class="gppost gpsubmit">' . $langmessage['delete'] . '</button>'; echo '</th></tr>'; $heading = ob_get_clean(); echo $heading; // non-orphaned $orphaned = array(); foreach ($this->trash_files as $trash_index => $info) { if (isset($info['orphaned'])) { $orphaned[$trash_index] = $info; } else { $this->TrashRow($trash_index, $info); } } // orphaned files if ($orphaned) { echo '<tr><td colspan="3">'; echo '<input type="checkbox" style="visibility:hidden"> '; echo count($orphaned) . ' Orphaned Files Found'; echo '</td><td>'; echo '<a class="nowrap" data-cmd="ViewOrphaned">' . $langmessage['View'] . '</a> '; $q = array(); $q['titles'] = array_keys($orphaned); $q = 'cmd=DeleteFromTrash&' . http_build_query($q); echo common::Link('Admin_Trash', $langmessage['delete'], $q, array('data-cmd' => 'postlink')); echo '</td></tr>'; foreach ($orphaned as $trash_index => $info) { $this->TrashRow($trash_index, $info); } } echo $heading; echo '</table>'; echo '</form>'; }