Esempio n. 1
0
 function xml()
 {
     global $gp_menu;
     header('Content-Type: text/xml; charset=UTF-8');
     echo '<?xml version="1.0" encoding="UTF-8"?>';
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     foreach ($gp_menu as $key => $info) {
         $title = \gp\tool::IndexToTitle($key);
         if (isset($info['level'])) {
             echo "\n";
             echo '<url>';
             echo '<loc>';
             echo isset($info['url']) ? $info['url'] : 'http://' . $_SERVER['SERVER_NAME'] . \gp\tool::GetUrl($title);
             echo '</loc>';
             echo '</url>';
         }
     }
     echo '</urlset>';
     die;
 }
Esempio n. 2
0
 /**
  * Include the content of a page or gadget as specified in $data
  * @param array $data
  * @param string The included content
  */
 static function IncludeContent($data)
 {
     global $langmessage, $gp_index;
     if (isset($data['index'])) {
         $requested = \gp\tool::IndexToTitle($data['index']);
     } else {
         $requested = $data['content'];
     }
     if (empty($requested)) {
         return '<p>' . $langmessage['File Include'] . '</p>';
     }
     if (self::$title == $requested) {
         if (\gp\tool::LoggedIn()) {
             msg('Infinite loop detected: ' . htmlspecialchars($requested));
         }
         return;
     }
     if (isset($data['include_type'])) {
         $type = $data['include_type'];
     } else {
         $type = \gp\tool::SpecialOrAdmin($requested);
     }
     switch ($type) {
         case 'gadget':
             return self::IncludeGadget($requested);
         case 'special':
             return self::IncludeSpecial($requested);
         default:
             return self::IncludePage($requested);
     }
 }
Esempio n. 3
0
 /**
  * Start the link attributes array
  *
  */
 protected function MenuAttributesA()
 {
     global $gp_titles;
     $attributes = array('href' => '', 'attr' => '', 'value' => '', 'title' => '', 'class' => array());
     //external
     if (isset($this->curr_info['url'])) {
         if (empty($this->curr_info['title_attr'])) {
             $this->curr_info['title_attr'] = strip_tags($this->curr_info['label']);
         }
         $attributes['href'] = $this->curr_info['url'];
         $attributes['value'] = $this->curr_info['label'];
         $attributes['title'] = $this->curr_info['title_attr'];
         if (isset($this->curr_info['new_win'])) {
             $attributes['target'] = '_blank';
         }
         //internal link
     } else {
         $title = \gp\tool::IndexToTitle($this->curr_key);
         $attributes['href'] = \gp\tool::GetUrl($title);
         $attributes['value'] = \gp\tool::GetLabel($title);
         $attributes['title'] = \gp\tool::GetBrowserTitle($title);
         //get valid rel attr
         if (!empty($gp_titles[$this->curr_key]['rel'])) {
             $rel = explode(',', $gp_titles[$this->curr_key]['rel']);
             $attributes['rel'] = array_intersect(array('alternate', 'author', 'bookmark', 'help', 'icon', 'license', 'next', 'nofollow', 'noreferrer', 'prefetch', 'prev', 'search', 'stylesheet', 'tag'), $rel);
         }
     }
     return $attributes;
 }
Esempio n. 4
0
 /**
  * Save the posted page as the homepage
  *
  */
 public function HomepageSave()
 {
     global $langmessage, $config, $gp_index, $gp_titles;
     $homepage = $_POST['homepage'];
     $homepage_key = false;
     if (isset($gp_index[$homepage])) {
         $homepage_key = $gp_index[$homepage];
     } else {
         foreach ($gp_titles as $index => $title) {
             if ($title['label'] === $homepage) {
                 $homepage_key = $index;
                 break;
             }
         }
         if (!$homepage_key) {
             msg($langmessage['OOPS']);
             return;
         }
     }
     $config['homepath_key'] = $homepage_key;
     $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']);
     if (!\gp\admin\Tools::SaveConfig(true)) {
         return;
     }
     //update the display
     ob_start();
     $this->HomepageDisplay();
     $content = ob_get_clean();
     $this->page->ajaxReplace[] = array('inner', '.homepage_setting', $content);
 }
Esempio n. 5
0
 /**
  * Display form in popup for renaming page given by $index
  *
  */
 public static function RenameForm()
 {
     global $langmessage, $page, $gp_index, $gp_titles, $config;
     $index = $_REQUEST['index'];
     if (!isset($gp_titles[$index])) {
         msg($langmessage['OOPS'] . ' (Invalid Request)');
         return;
     }
     $action = \gp\tool::GetUrl($page->requested);
     $label = \gp\tool::GetLabelIndex($index);
     $title = \gp\tool::IndexToTitle($index);
     $title_info = $gp_titles[$index];
     $title_info += array('browser_title' => '', 'keywords' => '', 'description' => '', 'rel' => '');
     if (empty($_REQUEST['new_title'])) {
         $new_title = \gp\tool::LabelSpecialChars($label);
     } else {
         $new_title = htmlspecialchars($_REQUEST['new_title']);
     }
     $new_title = str_replace('_', ' ', $new_title);
     ob_start();
     echo '<div class="inline_box">';
     echo '<form action="' . $action . '" method="post" id="gp_rename_form">';
     echo '<input type="hidden" name="title" id="old_title" value="' . htmlspecialchars($title) . '" />';
     echo '<input type="hidden" id="gp_space_char" value="' . htmlspecialchars($config['space_char']) . '" />';
     echo '<h2>' . $langmessage['rename/details'] . '</h2>';
     echo '<table class="bordered full_width" id="gp_rename_table">';
     echo '<thead>';
     echo '<tr><th colspan="2">';
     echo $langmessage['options'];
     echo '</th></tr>';
     echo '</thead>';
     echo '<tbody>';
     //label
     self::FormLabel('label');
     echo '<input type="text" class="title_label gpinput" name="new_label" maxlength="100" size="50" value="' . $new_title . '" />';
     echo '</td></tr>';
     //slug (title)
     $attr = '';
     $class = 'new_title';
     if ($title == \gp\admin\Tools::LabelToSlug($label)) {
         $attr = 'disabled="disabled" ';
         $class .= ' sync_label';
     }
     self::FormLabel('Slug/URL');
     echo '<input type="text" class="' . $class . ' gpinput" name="new_title" maxlength="100" size="50" value="' . htmlspecialchars($title) . '" ' . $attr . '/>';
     self::ToggleSync($attr);
     echo '</td></tr>';
     //browser title defaults to label
     $attr = '';
     $class = 'browser_title';
     $browser_title = $title_info['browser_title'];
     self::FormLabel('browser_title', $title_info['browser_title']);
     if (empty($title_info['browser_title'])) {
         $browser_title = htmlspecialchars($label);
         $attr = 'disabled="disabled" ';
         $class .= ' sync_label';
     }
     echo '<input type="text" class="' . $class . ' gpinput" size="50" name="browser_title" value="' . $browser_title . '" ' . $attr . '/>';
     self::ToggleSync($attr);
     echo '</td></tr>';
     //meta keywords
     self::FormLabel('keywords', $title_info['keywords']);
     echo '<input type="text" class="gpinput" size="50" name="keywords" value="' . $title_info['keywords'] . '" />';
     echo '</td></tr>';
     //meta description
     self::FormLabel('description', $title_info['description']);
     $count_label = sprintf($langmessage['_characters'], '<span>' . strlen($title_info['description']) . '</span>');
     echo '<span class="show_character_count gptextarea">';
     echo '<textarea rows="2" cols="50" name="description">' . $title_info['description'] . '</textarea>';
     echo '<span class="character_count">' . $count_label . '</span>';
     echo '</span>';
     echo '</td></tr>';
     //robots
     self::FormLabel('robots', $title_info['rel']);
     echo '<label>';
     $checked = strpos($title_info['rel'], 'nofollow') !== false ? 'checked="checked"' : '';
     echo '<input type="checkbox" name="nofollow" value="nofollow" ' . $checked . '/> ';
     echo '  Nofollow ';
     echo '</label>';
     echo '<label>';
     $checked = strpos($title_info['rel'], 'noindex') !== false ? 'checked="checked"' : '';
     echo '<input type="checkbox" name="noindex" value="noindex" ' . $checked . '/> ';
     echo ' Noindex';
     echo '</label>';
     echo '</td></tr>';
     echo '</tbody>';
     echo '</table>';
     //redirection
     echo '<p id="gp_rename_redirect" class="nodisplay">';
     echo '<label>';
     echo '<input type="checkbox" name="add_redirect" value="add" /> ';
     echo sprintf($langmessage['Auto Redirect'], '"' . $title . '"');
     echo '</label>';
     echo '</p>';
     echo '<p>';
     if (self::$hidden_rows) {
         echo ' &nbsp; <a data-cmd="showmore" >+ ' . $langmessage['more_options'] . '</a>';
     }
     echo '</p>';
     echo '<p>';
     echo '<input type="hidden" name="cmd" value="RenameFile"/> ';
     echo '<input type="submit" name="" value="' . $langmessage['save_changes'] . '...' . '" class="gpsubmit" data-cmd="gppost"/>';
     echo '<input type="button" class="admin_box_close gpcancel" name="" value="' . $langmessage['cancel'] . '" />';
     echo '</p>';
     echo '</form>';
     echo '</div>';
     $content = ob_get_clean();
     $page->ajaxReplace = array();
     $array = array();
     $array[0] = 'admin_box_data';
     $array[1] = '';
     $array[2] = $content;
     $page->ajaxReplace[] = $array;
     //call renameprep function after admin_box
     $array = array();
     $array[0] = 'renameprep';
     $array[1] = '';
     $array[2] = '';
     $page->ajaxReplace[] = $array;
 }
Esempio n. 6
0
 /**
  * Add an addon's special links to the configuration
  *
  */
 public function AddToConfig_Special($Special_Links)
 {
     global $gp_index, $gp_titles, $gp_menu, $langmessage;
     $lower_links = array_change_key_case($Special_Links, CASE_LOWER);
     //purge links no longer defined ... similar to PurgeExisting()
     foreach ($gp_index as $linkName => $index) {
         $linkInfo = $gp_titles[$index];
         if (!isset($linkInfo['addon'])) {
             continue;
         }
         if ($linkInfo['addon'] !== $this->config_key) {
             continue;
         }
         if (isset($lower_links[$index])) {
             continue;
         }
         unset($gp_index[$linkName]);
         unset($gp_titles[$index]);
         if (isset($gp_menu[$index])) {
             unset($gp_menu[$index]);
         }
     }
     //prepare a list with all titles converted to lower case
     $lower_titles = array_keys($gp_index);
     $lower_titles = array_combine($lower_titles, $lower_titles);
     $lower_titles = array_change_key_case($lower_titles, CASE_LOWER);
     //add new links ... similar to AddToConfig()
     foreach ($Special_Links as $new_title => $linkInfo) {
         $index = strtolower($new_title);
         $title = \gp\tool::IndexToTitle($index);
         //if the title already exists, see if we need to update it
         if ($title) {
             $add_link = $this->CanAddLink($gp_titles[$index]);
             if (!$add_link) {
                 $this->message(sprintf($langmessage['addon_key_defined'], ' <em>Special_Link: ' . $new_title . '</em>'));
                 continue;
             }
             //this will overwrite things like label which are at times editable by users
             //$AddTo[$new_title] = $linkInfo + $AddTo[$new_title];
             // if it doesn't exist, just add it
         } else {
             // we don't need the Special_ prefix, but we don't want duplicates
             $temp = $new_title = substr($new_title, 8);
             $temp_lower = $new_lower = strtolower($new_title);
             $i = 1;
             while (isset($lower_titles[$new_lower])) {
                 $new_lower = $temp_lower . '_' . $i;
                 $new_title = $temp . '_' . $i;
                 $i++;
             }
             $gp_index[$new_title] = $index;
             $gp_titles[$index] = $linkInfo;
         }
         $this->UpdateLinkInfo($gp_titles[$index], $linkInfo);
     }
 }
Esempio n. 7
0
 /**
  * Show a menu entry if it's an internal page
  *
  */
 public function ShowLevel_Title($menu_key, $menu_value, $layout_info)
 {
     $title = \gp\tool::IndexToTitle($menu_key);
     $data = $this->GetReplaceData($title, $layout_info, $menu_key, $menu_value);
     $label = \gp\tool::GetLabel($title);
     \gp\admin\Menu\Tools::MenuLink($data);
     echo \gp\tool::LabelSpecialChars($label);
     echo '</a>';
 }
Esempio n. 8
0
 /**
  * Make sure the homepage has a value
  *
  */
 public static function ResetHomepage()
 {
     global $config, $gp_menu, $gp_titles;
     if (!isset($gp_titles[$config['homepath_key']])) {
         $config['homepath_key'] = key($gp_menu);
         $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']);
     }
 }
Esempio n. 9
0
 /**
  * Display current layout, list of available layouts and list of titles affected by the layout setting for $title
  *
  */
 public function SelectLayout($url, $query_string)
 {
     global $gp_titles, $gpLayouts, $langmessage, $config, $gp_index;
     $index = $_REQUEST['index'];
     $title = \gp\tool::IndexToTitle($index);
     if (!$title) {
         echo $langmessage['OOPS'];
         return;
     }
     $this->title = $title;
     $Inherit_Info = \gp\admin\Menu\Tools::Inheritance_Info();
     $curr_layout = \gp\admin\Menu\Tools::CurrentLayout($index);
     $curr_info = $gpLayouts[$curr_layout];
     echo '<div class="inline_box">';
     echo '<h3>';
     echo $langmessage['current_layout'] . ': &nbsp; ';
     echo '<span class="layout_color_id" style="background-color:' . $curr_info['color'] . ';" title="' . $curr_info['color'] . '"></span> &nbsp; ';
     echo str_replace('_', ' ', $curr_info['label']);
     echo '</h3>';
     if (!empty($gp_titles[$index]['gpLayout'])) {
         echo '<p>';
         if (isset($Inherit_Info[$index]['parent_layout'])) {
             $parent_layout = $Inherit_Info[$index]['parent_layout'];
         } else {
             $parent_layout = $config['gpLayout'];
         }
         $parent_info = $gpLayouts[$parent_layout];
         echo $langmessage['restore'] . ': ';
         $span = '<span class="layout_color_id" style="background-color:' . $parent_info['color'] . ';" title="' . $parent_info['color'] . '"></span> ';
         echo \gp\tool::Link($url, $span . $parent_info['label'], $query_string . 'cmd=restorelayout&index=' . urlencode($index), array('data-cmd' => 'postlink', 'title' => $langmessage['restore']), 'restore');
         echo '</p>';
     }
     echo '<table class="bordered full_width">';
     echo '<tr><th>';
     echo $langmessage['available_layouts'];
     echo '</th><th>';
     echo $langmessage['theme'];
     echo '</th></tr>';
     if (count($gpLayouts) < 2) {
         echo '<tr><td colspan="2">';
         echo $langmessage['Empty'];
         echo '</td></tr>';
         echo '</table>';
         echo \gp\tool::Link('Admin_Theme_Content', $langmessage['new_layout']);
         echo '</div>';
         return;
     }
     foreach ($gpLayouts as $layout => $info) {
         if ($layout == $curr_layout) {
             continue;
         }
         echo '<tr><td>';
         echo '<span class="layout_color_id" style="background-color:' . $info['color'] . ';" title="' . $info['color'] . '">';
         echo '</span> ';
         if ($layout != $curr_layout) {
             echo \gp\tool::Link($url, $info['label'], $query_string . 'cmd=uselayout&index=' . urlencode($index) . '&layout=' . urlencode($layout), array('data-cmd' => 'postlink'), 'use_' . $layout);
         }
         echo '</td><td>';
         echo $info['theme'];
         echo '</td></tr>';
     }
     echo '</table>';
     //show affected pages
     $affected = self::GetAffectedFiles($index);
     echo '<br/>';
     echo '<table class="bordered full_width">';
     echo '<tr><th>' . $langmessage['affected_files'] . '</th></tr></table>';
     echo '<p class="sm">' . $langmessage['about_layout_change'] . '</p>';
     echo '<p class="admin_note" style="width:35em">';
     $label = \gp\tool::GetLabelIndex($index, false);
     echo \gp\tool::LabelSpecialChars($label);
     $i = 0;
     foreach ($affected as $affected_label) {
         $i++;
         echo ', ' . $affected_label;
     }
     echo '</p>';
     echo '<p>';
     echo ' <input type="submit" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" /> ';
     echo '</p>';
     echo '<p class="admin_note">';
     echo '<b>' . $langmessage['see_also'] . '</b> ';
     echo \gp\tool::Link('Admin_Theme_Content', $langmessage['layouts']);
     echo '</p>';
     echo '</div>';
 }
Esempio n. 10
0
 /**
  * Display a list of all the titles using the current layout
  *
  */
 public function ShowTitles()
 {
     global $langmessage;
     //affected titles
     $titles_count = $this->TitlesCount($this->curr_layout);
     echo '<h2>' . $langmessage['titles_using_layout'];
     echo ': ' . $titles_count;
     echo '</h2>';
     if ($titles_count > 0) {
         echo '<ul class="titles_using">';
         foreach ($this->LayoutArray as $index => $layout_comparison) {
             if ($this->curr_layout == $layout_comparison) {
                 $title = \gp\tool::IndexToTitle($index);
                 if (empty($title)) {
                     continue;
                     //may be external link
                 }
                 echo "\n<li>";
                 $label = \gp\tool::GetLabel($title);
                 $label = \gp\tool::LabelSpecialChars($label);
                 echo \gp\tool::Link($title, $label);
                 echo '</li>';
             }
         }
         echo '</ul>';
         echo '<div class="clear"></div>';
     }
 }