示例#1
0
 public function __construct($args)
 {
     global $langmessage, $config;
     parent::__construct($args);
     $this->section_types = \gp\tool\Output\Sections::GetTypes();
     $this->page->ajaxReplace = array();
     $this->page->css_admin[] = '/include/css/admin_menu_new.css';
     $this->page->head_js[] = '/include/thirdparty/js/nestedSortable.js';
     $this->page->head_js[] = '/include/thirdparty/js/jquery_cookie.js';
     $this->page->head_js[] = '/include/js/admin_menu_new.js';
     $this->max_level_index = max(3, gp_max_menu_level - 1);
     $this->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;
         }
     }
     //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 = \gp\tool::GetCommand();
     $this->cmd = \gp\tool\Plugins::Filter('MenuCommand', array($cmd));
 }
示例#2
0
 function RunScript()
 {
     if (!$this->SetVars()) {
         return;
     }
     //allow addons to effect page actions and how a page is displayed
     $cmd = \gp\tool::GetCommand();
     $cmd_after = \gp\tool\Plugins::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     $this->GetFile();
     $this->contentBuffer = \gp\tool\Output\Sections::Render($this->file_sections, $this->title, $this->file_stats);
 }
示例#3
0
 /**
  * View the contents of a trash file
  *
  */
 public function ViewTrashFile($trash_index)
 {
     global $dataDir, $langmessage, $trash_file;
     $title_info = self::GetInfo($trash_index);
     //delete / restore links
     echo '<div class="pull-right">';
     echo \gp\tool::Link('Admin/Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'cnreq', 'class' => 'gpsubmit'));
     echo ' &nbsp; ';
     echo \gp\tool::Link('Admin/Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'cnreq', 'class' => 'gpsubmit'));
     echo '</div>';
     echo '<h2 class="hmargin">';
     echo \gp\tool::Link('Admin/Trash', $langmessage['trash']);
     echo ' &#187; ';
     echo htmlspecialchars($title_info['title']);
     echo '</h2>';
     echo '<hr>';
     //get file sections
     $file_sections = \gp\tool\Files::Get($title_info['page_file'], 'file_sections');
     if ($file_sections) {
         echo \gp\tool\Output\Sections::Render($file_sections, $title_info['title']);
     } else {
         echo '<p>This page no longer has any content</p>';
     }
 }
示例#4
0
 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 = \gp\tool\Output\Sections::GetTypes();
     if (\gp\tool\Output::ShowEditLink() && \gp\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 = \gp\tool\Output::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $curr_section_num, $attrs);
         $section_data['attributes']['data-gp-area-id'] = $edit_index;
         //section control links
         if ($section_data['type'] != 'wrapper_section') {
             ob_start();
             echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
             echo $link;
             echo \gp\tool::Link($this->title, $langmessage['Manage Sections'], 'cmd=ManageSections', array('class' => 'manage_sections', 'data-cmd' => 'inline_edit_generic', 'data-arg' => 'manage_sections'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link($this->title, $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($this->gp_index), 'data-cmd="gpajax"');
             echo \gp\tool::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link('Admin/Menu', $langmessage['file_manager']);
             echo '</span>';
             \gp\tool\Output::$editlinks .= ob_get_clean();
         }
         $section_data['attributes']['id'] = 'ExtraEditArea' . $edit_index;
     }
     $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 {
         \gp\tool\Output::$nested_edit = true;
         $content .= \gp\tool\Output\Sections::RenderSection($section_data, $curr_section_num, $this->title, $this->file_stats);
         \gp\tool\Output::$nested_edit = false;
     }
     if (!isset($section_data['nodeName'])) {
         $content .= '<div class="gpclear"></div>';
         $content .= '</div>';
     } else {
         $content .= \gp\tool\Output\Sections::EndTag($section_data['nodeName']);
     }
     return $content;
 }
示例#5
0
 /**
  * Save an include section
  *
  */
 public static function SectionFromPost_Include(&$existing_section, $section_num, $title, $file_stats)
 {
     global $page, $langmessage, $gp_index, $config;
     unset($existing_section['index']);
     //gadget include
     if (strpos($_POST['include'], 'gadget:') === 0) {
         $gadget = substr($_POST['include'], 7);
         if (!isset($config['gadgets'][$gadget])) {
             msg($langmessage['OOPS_TITLE']);
             return false;
         }
         $existing_section['include_type'] = 'gadget';
         $existing_section['content'] = $gadget;
         //file include
     } elseif (strpos($_POST['include'], 'file:') === 0) {
         $include_title = substr($_POST['include'], 5);
         if (!isset($gp_index[$include_title])) {
             msg($langmessage['OOPS_TITLE']);
             return false;
         }
         $existing_section['include_type'] = \gp\tool::SpecialOrAdmin($include_title);
         $existing_section['index'] = $gp_index[$include_title];
         $existing_section['content'] = $include_title;
     }
     //send replacement content
     $content = \gp\tool\Output\Sections::RenderSection($existing_section, $section_num, $title, $file_stats);
     $page->ajaxReplace[] = array('gp_include_content', '', $content);
     return true;
 }
示例#6
0
 /**
  * Preview
  *
  */
 public function PreviewText()
 {
     global $langmessage;
     echo '<h2>';
     echo \gp\tool::Link('Admin/Extra', $langmessage['theme_content']);
     echo ' &#187; ' . str_replace('_', ' ', $this->title) . '</h2>';
     echo '</h2>';
     echo '<hr/>';
     echo \gp\tool\Output\Sections::RenderSection($this->file_sections[0], 0, '', $this->file_stats);
     echo '<hr/>';
 }
示例#7
0
 public static function GetExtra($name = 'Side_Menu', $info = array())
 {
     global $dataDir, $langmessage;
     $name = str_replace(' ', '_', $name);
     $file_stats = array();
     $is_draft = false;
     $extra_content = self::ExtraContent($name, $file_stats, $is_draft);
     $wrap = self::ShowEditLink('Admin_Extra');
     if (!$wrap) {
         echo '<div>';
         echo \gp\tool\Output\Sections::RenderSection($extra_content[0], 0, '', $file_stats);
         echo '</div>';
         return;
     }
     ob_start();
     $edit_link = self::EditAreaLink($edit_index, 'Admin/Extra', $langmessage['edit'], 'cmd=edit&file=' . $name, array('title' => $name, 'data-cmd' => 'inline_edit_generic'));
     echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
     echo $edit_link;
     echo \gp\tool::Link('Admin/Extra', $langmessage['theme_content'], '', ' class="nodisplay"');
     echo '</span>';
     self::$editlinks .= ob_get_clean();
     $attrs = array();
     $attrs['data-gp_label'] = str_replace('_', ' ', $name);
     $attrs['class'] = 'editable_area';
     $attrs['id'] = 'ExtraEditArea' . $edit_index;
     if ($is_draft) {
         $attrs['data-draft'] = 1;
     } else {
         $attrs['data-draft'] = 0;
     }
     echo '<div' . \gp\tool\Output\Sections::SectionAttributes($attrs, $extra_content[0]['type']) . '>';
     echo \gp\tool\Output\Sections::RenderSection($extra_content[0], 0, '', $file_stats);
     echo '</div>';
 }
示例#8
0
 public function SearchPage($title, $index)
 {
     global $gp_menu, $gp_titles;
     //search hidden?
     if (!$this->search_hidden && !isset($gp_menu[$index])) {
         return;
     }
     //private pages
     if (!\gp\tool::LoggedIn()) {
         if (isset($gp_titles[$index]['vis'])) {
             return;
         }
     }
     $full_path = \gp\tool\Files::PageFile($title);
     $file_sections = \gp\tool\Files::Get($full_path, 'file_sections');
     if (!$file_sections) {
         return;
     }
     $content = \gp\tool\Output\Sections::Render($file_sections, $title, \gp\tool\Files::$last_stats);
     $label = \gp\tool::GetLabel($title);
     $this->FindString($content, $label, $title);
 }
示例#9
0
 public function SelectContent_Areas($param, $count_gadgets)
 {
     global $dataDir, $langmessage, $config;
     $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">&nbsp;</th></tr>';
     $extrasFolder = $dataDir . '/data/_extra';
     $files = \gp\tool\Files::ReadDir($extrasFolder);
     asort($files);
     foreach ($files as $file) {
         $extraName = $file;
         echo '<tr><td>';
         echo str_replace('_', ' ', $extraName);
         echo '</td><td class="add">';
         echo \gp\tool::Link($this->layout_slug, $langmessage['add'], $addQuery . '&insert=Extra:' . $extraName, array('data-cmd' => 'creq'));
         echo '</td></tr>';
     }
     //new extra area
     echo '<tr><td>';
     echo '<form action="' . \gp\tool::GetUrl($this->layout_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"/>';
     $types = \gp\tool\Output\Sections::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="' . \gp\tool::GetUrl($this->layout_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">&nbsp;</th></tr>';
         foreach ($config['gadgets'] as $gadget => $info) {
             echo '<tr>';
             echo '<td>';
             echo str_replace('_', ' ', $gadget);
             echo '</td>';
             echo '<td class="add">';
             echo \gp\tool::Link($this->layout_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="' . \gp\tool::GetUrl($this->layout_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="' . \gp\tool::GetUrl($this->layout_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>';
 }