Example #1
0
 function SetVars()
 {
     global $gp_index, $gp_titles, $gp_menu;
     if (!isset($gp_index[$this->title])) {
         $this->Error_404($this->title);
         return false;
     }
     $this->gp_index = $gp_index[$this->title];
     $this->TitleInfo =& $gp_titles[$this->gp_index];
     //so changes made by rename are seen
     $this->label = \gp\tool::GetLabel($this->title);
     $this->file = \gp\tool\Files::PageFile($this->title);
     if (!$this->CheckVisibility()) {
         return false;
     }
     \gp\tool\Plugins::Action('PageSetVars');
     return true;
 }
Example #2
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;
 }
Example #3
0
 static function SetVars($title, $meta)
 {
     self::$title = $title;
     self::$label = \gp\tool::GetLabel($title);
     self::$meta = array();
     if (is_array($meta)) {
         self::$meta = $meta;
     }
 }
Example #4
0
 /**
  * Display row
  *
  */
 public function SearchDisplayRow($title)
 {
     global $langmessage, $gpLayouts, $gp_index, $gp_menu, $gp_titles;
     $menu_key = $gp_index[$title];
     $layout = \gp\admin\Menu\Tools::CurrentLayout($menu_key);
     $layout_info = $gpLayouts[$layout];
     $label = \gp\tool::GetLabel($title);
     $data = $this->GetReplaceData($title, $layout_info, $menu_key);
     echo '<tr><td>';
     echo \gp\tool::Link($title, \gp\tool::LabelSpecialChars($label));
     //area only display on mouseover
     echo '<div><div>';
     echo $this->Link('Admin/Menu/Ajax', $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($menu_key), array('title' => $langmessage['rename/details'], 'data-cmd' => 'gpajax'));
     $label = $langmessage['Visibility'] . ': ' . $langmessage['Private'];
     $q = 'cmd=ToggleVisibility&index=' . urlencode($menu_key);
     if (!isset($gp_titles[$menu_key]['vis'])) {
         $label = $langmessage['Visibility'] . ': ' . $langmessage['Public'];
         $q .= '&visibility=private';
     }
     echo $this->Link('Admin/Menu/Ajax', $label, $q, 'data-cmd="gpajax"');
     if ($data['special'] === false) {
         echo \gp\tool::Link($title, $langmessage['Revision History'], 'cmd=ViewHistory', 'class="view_edit_link not_multiple" data-cmd="gpabox"');
         echo $this->Link('Admin/Menu/Ajax', $langmessage['Copy'], 'cmd=CopyForm&index=' . urlencode($menu_key), array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox'));
     }
     echo '<span>';
     echo $langmessage['layout'] . ': ';
     echo $this->Link('Admin/Menu', $layout_info['label'], 'cmd=layout&index=' . urlencode($menu_key), array('title' => $langmessage['layout'], 'data-cmd' => 'gpabox'));
     echo '</span>';
     if ($data['special'] === false) {
         echo $this->Link('Admin/Menu/Ajax', $langmessage['delete'], 'cmd=MoveToTrash&index=' . urlencode($menu_key), array('title' => $langmessage['delete_page'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm'));
     }
     echo $data['opts'];
     //stats
     if (gpdebug) {
         echo '<span>Data Index: ' . $menu_key . '</span>';
     }
     echo '</div>&nbsp;</div>';
     //types
     echo '</td><td>';
     $this->TitleTypes($menu_key);
     //children
     echo '</td><td>';
     if (isset($this->inherit_info[$menu_key]) && isset($this->inherit_info[$menu_key]['children'])) {
         echo $this->inherit_info[$menu_key]['children'];
     } elseif (isset($gp_menu[$menu_key])) {
         echo '0';
     } else {
         echo $langmessage['Not In Main Menu'];
     }
     //size, modified
     echo '</td><td>';
     echo $data['size'];
     echo '</td><td>';
     echo $data['mtime'];
     echo '</td></tr>';
 }
Example #5
0
 /**
  * Display a form for copying a page
  *
  */
 public function CopyForm()
 {
     global $langmessage, $gp_index;
     $index = $_REQUEST['index'];
     $from_title = \gp\tool::IndexToTitle($index);
     if (!$from_title) {
         msg($langmessage['OOPS_TITLE']);
         return false;
     }
     $from_label = \gp\tool::GetLabel($from_title);
     $from_label = \gp\tool::LabelSpecialChars($from_label);
     echo '<div class="inline_box">';
     echo '<form method="post" action="' . \gp\tool::GetUrl('Admin/Menu/Ajax') . '">';
     if (isset($_REQUEST['redir'])) {
         echo '<input type="hidden" name="redir" value="redir"/> ';
     }
     echo '<input type="hidden" name="from_title" value="' . htmlspecialchars($from_title) . '"/> ';
     echo '<table class="bordered full_width" id="gp_rename_table">';
     echo '<thead><tr><th colspan="2">';
     echo $langmessage['Copy'];
     echo '</th></tr></thead>';
     echo '<tr class="line_row"><td>';
     echo $langmessage['from'];
     echo '</td><td>';
     echo $from_label;
     echo '</td></tr>';
     echo '<tr><td>';
     echo $langmessage['to'];
     echo '</td><td>';
     echo '<input type="text" name="title" maxlength="100" size="50" value="' . $from_label . '" class="gpinput" />';
     echo '</td></tr>';
     echo '</table>';
     echo '<p>';
     echo '<input type="hidden" name="cmd" value="CopyPage"/> ';
     echo '<input type="submit" name="" value="' . $langmessage['continue'] . '" class="gpsubmit" data-cmd="gppost"/>';
     echo '<input type="button" class="admin_box_close gpcancel" name="" value="' . $langmessage['cancel'] . '" />';
     echo '</p>';
     echo '</form>';
     echo '</div>';
 }
Example #6
0
 /**
  * Include Editing
  *
  */
 public static function IncludeDialog($section)
 {
     global $page, $langmessage, $config, $gp_index;
     $page->ajaxReplace = array();
     $include_type =& $section['include_type'];
     $gadget_content = '';
     $file_content = '';
     switch ($include_type) {
         case 'gadget':
             $gadget_content =& $section['content'];
             break;
         default:
             $file_content =& $section['content'];
             break;
     }
     ob_start();
     echo '<form id="gp_include_form">';
     echo '<div class="gp_scrolllist"><div>';
     echo '<input type="text" value="" class="gpsearch" placeholder="' . $langmessage['Search'] . '" autocomplete="off" />';
     //gadget include autocomplete
     if (isset($config['gadgets'])) {
         foreach ($config['gadgets'] as $uniq => $info) {
             echo '<label>';
             $checked = '';
             if ($uniq == $gadget_content) {
                 $checked = 'checked';
             }
             echo '<input type="radio" name="include" value="gadget:' . htmlspecialchars($uniq) . '" ' . $checked . ' data-cmd="IncludePreview" /> ';
             echo '<span>';
             echo $uniq;
             echo '</span>';
             echo '</label>';
         }
     }
     $array = array();
     foreach ($gp_index as $slug => $id) {
         if ($page->gp_index == $id) {
             continue;
         }
         $label = \gp\tool::GetLabel($slug);
         $label = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $label);
         $array[] = array($label, $slug);
         $checked = '';
         if ($slug == $file_content) {
             $checked = 'checked';
         }
         echo '<label>';
         echo '<input type="radio" name="include" value="file:' . htmlspecialchars($slug) . '" ' . $checked . '  data-cmd="IncludePreview" /> ';
         echo '<span>';
         echo $label;
         echo '<span class="slug">';
         echo '/' . $slug;
         echo '</span>';
         echo '</span>';
         echo '</label>';
     }
     echo '</div></div>';
     echo '</form>';
     $content = ob_get_clean();
     $page->ajaxReplace[] = array('gp_include_dialog', '', $content);
     return false;
 }
Example #7
0
 public function GenerateOutput()
 {
     global $langmessage;
     \gp\tool::ShowingGallery();
     echo '<h2>';
     echo \gp\tool\Output::ReturnText('galleries');
     echo '</h2>';
     $wrap = \gp\admin\Tools::CanEdit($this->page->gp_index);
     if ($wrap) {
         echo \gp\tool\Output::EditAreaLink($edit_index, 'Admin/Galleries', $langmessage['edit']);
         echo '<div class="editable_area cf" id="ExtraEditArea' . $edit_index . '">';
         // class="edit_area" added by javascript
     }
     $image_text = \gp\tool\Output::ReturnText('image');
     $images_text = \gp\tool\Output::ReturnText('images');
     $list = '';
     $shown = 0;
     foreach ($this->galleries as $title => $info) {
         //page is hidden
         if (!$this->GalleryVisible($title, $info)) {
             continue;
         }
         $count = '';
         if (is_array($info)) {
             $icon = $info['icon'];
             if ($info['count'] == 1) {
                 $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('image');
             } elseif ($info['count'] > 1) {
                 $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('images');
             }
         } else {
             $icon = $info;
         }
         if (empty($icon)) {
             continue;
         }
         $icon = rawurldecode($icon);
         //prevent double encoding
         if (strpos($icon, '/thumbnails/') === false) {
             $thumbPath = \gp\tool::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg');
         } else {
             $thumbPath = \gp\tool::GetDir('/data/_uploaded' . $icon);
         }
         $label = \gp\tool::GetLabel($title);
         $title_attr = ' title="' . \gp\tool::GetBrowserTitle($title) . '"';
         $label_img = ' <img src="' . $thumbPath . '" alt=""/>';
         $list .= '<li>' . \gp\tool::Link($title, $label_img, '', $title_attr) . '<div>' . \gp\tool::Link($title, $label, '', $title_attr) . '<p>' . $count . '</p>' . '</div>' . '</li>';
     }
     if (!empty($list)) {
         echo '<ul class="gp_gallery gp_galleries">';
         echo $list;
         echo '</ul>';
     }
     if ($wrap) {
         echo '</div>';
     }
     $this->PostSave();
 }
Example #8
0
 /**
  * Create a scrollable title list
  *
  * @param array $list
  * @param string $name
  * @pearm string $type
  * @param bool $index_as_value
  */
 public static function ScrollList($list, $name = 'from_title', $type = 'radio', $index_as_value = false)
 {
     global $langmessage;
     $list_out = array();
     foreach ($list as $title => $index) {
         ob_start();
         echo '<label>';
         if ($index_as_value) {
             echo '<input type="' . $type . '" name="' . $name . '" value="' . htmlspecialchars($index) . '" />';
         } else {
             echo '<input type="' . $type . '" name="' . $name . '" value="' . htmlspecialchars($title) . '" />';
         }
         echo '<span>';
         $label = \gp\tool::GetLabel($title);
         echo \gp\tool::LabelSpecialChars($label);
         echo '<span class="slug">';
         echo '/' . $title;
         echo '</span>';
         echo '</span>';
         echo '</label>';
         $list_out[$title] = ob_get_clean();
     }
     uksort($list_out, 'strnatcasecmp');
     echo '<div class="gp_scrolllist"><div>';
     echo '<input type="text" name="search" value="" class="gpsearch" placeholder="' . $langmessage['Search'] . '" autocomplete="off" />';
     echo implode('', $list_out);
     echo '</div></div>';
 }
Example #9
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>';
     }
 }
Example #10
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);
 }