コード例 #1
0
ファイル: Page_Layout.php プロジェクト: rizub4u/gpEasy-CMS
 /**
  * Assign a layout to the $title. Child pages without a layout assigned will inherit this setting
  * @param string $title
  */
 function SetLayout()
 {
     global $gp_index, $gp_titles, $langmessage, $gpLayouts;
     $index = $_POST['index'];
     $title = common::IndexToTitle($index);
     if (!$title) {
         message($langmessage['OOPS']);
         return;
     }
     $this->title = $title;
     $layout = $_POST['layout'];
     if (!isset($gpLayouts[$layout])) {
         message($langmessage['OOPS']);
         return;
     }
     if (!common::verify_nonce('use_' . $layout)) {
         message($langmessage['OOPS']);
         return;
     }
     //unset, then reset if needed
     unset($gp_titles[$index]['gpLayout']);
     $currentLayout = display::OrConfig($index, 'gpLayout');
     if ($currentLayout != $layout) {
         $gp_titles[$index]['gpLayout'] = $layout;
     }
     if (!admin_tools::SavePagesPHP()) {
         message($langmessage['OOPS'] . '(3)');
         return false;
     }
     message($langmessage['SAVED']);
 }
コード例 #2
0
ファイル: display.php プロジェクト: jozefkrz/gpEasy-CMS
 /**
  * Set the page's theme name and path information according to the specified $layout
  * If $layout is not found, use the installation's default theme
  *
  */
 function SetTheme($layout = false)
 {
     global $dataDir;
     if ($layout === false) {
         $layout = display::OrConfig($this->gp_index, 'gpLayout');
     }
     $layout_info = common::LayoutInfo($layout);
     if (!$layout_info) {
         $default_theme = explode('/', gp_default_theme);
         $this->gpLayout = false;
         $this->theme_name = $default_theme[0];
         $this->theme_color = $default_theme[1];
         $this->theme_rel = '/themes/' . $this->theme_name . '/' . $this->theme_color;
         $this->theme_dir = $dataDir . '/themes/' . $this->theme_name;
     } else {
         $this->gpLayout = $layout;
         $this->theme_name = $layout_info['theme_name'];
         $this->theme_color = $layout_info['theme_color'];
         $this->theme_rel = $layout_info['path'];
         $this->theme_dir = $layout_info['dir'];
         if (isset($layout_info['addon_id'])) {
             $this->theme_addon_id = $layout_info['addon_id'];
         }
         $this->theme_is_addon = $layout_info['is_addon'];
         //if installed in /themes or /data/_themes
         //css preferences
         if (isset($layout_info['menu_css_ordered']) && !$layout_info['menu_css_ordered']) {
             $this->menu_css_ordered = false;
         }
         if (isset($layout_info['menu_css_indexed']) && !$layout_info['menu_css_indexed']) {
             $this->menu_css_indexed = false;
         }
     }
     $this->theme_path = common::GetDir($this->theme_rel);
 }
コード例 #3
0
ファイル: common.php プロジェクト: rizub4u/gpEasy-CMS
 /**
  * Set the page's theme name and path information according to the specified $layout
  * If $layout is not found, use the installation's default theme
  *
  */
 function SetTheme($layout = false)
 {
     global $dataDir;
     if ($layout === false) {
         $layout = display::OrConfig($this->gp_index, 'gpLayout');
     }
     $layout_info = common::LayoutInfo($layout);
     if (!$layout_info) {
         $this->gpLayout = false;
         $this->theme_name = 'Light_Texture';
         $this->theme_color = 'Blue';
         $this->theme_is_addon = $this->theme_addon_id = false;
         $this->theme_dir = $dataDir . '/themes/' . $this->theme_name;
     } else {
         $this->gpLayout = $layout;
         $this->theme_name = $layout_info['theme_name'];
         $this->theme_color = $layout_info['theme_color'];
         $this->theme_is_addon = $layout_info['is_addon'];
         $this->theme_dir = $layout_info['dir'];
         if (isset($layout_info['css']) && $layout_info['css']) {
             $this->layout_css = true;
         }
         if (isset($layout_info['addon_id'])) {
             $this->theme_addon_id = $layout_info['addon_id'];
         }
         //css preferences
         if (isset($layout_info['menu_css_ordered']) && !$layout_info['menu_css_ordered']) {
             $this->menu_css_ordered = false;
         }
         if (isset($layout_info['menu_css_indexed']) && !$layout_info['menu_css_indexed']) {
             $this->menu_css_indexed = false;
         }
     }
     $this->SetThemePath();
 }
コード例 #4
0
 /**
  * Get a list of existing titles similar to the requested page
  * @return array
  *
  */
 function SimilarTitleArray($title)
 {
     global $gp_index, $gp_titles;
     $similar = array();
     $percent_similar = array();
     $lower = str_replace(' ', '_', strtolower($title));
     $admin = common::LoggedIn();
     foreach ($gp_index as $title => $index) {
         //skip private pages
         if (!$admin) {
             $visibility = display::OrConfig($index, 'vis');
             if ($visibility) {
                 continue;
             }
         }
         similar_text($lower, strtolower($title), $percent);
         $similar[$title] = $percent;
     }
     arsort($similar);
     return $similar;
 }
コード例 #5
0
ファイル: editing_page.php プロジェクト: barbrick/gpEasy-CMS
 /**
  * Toggle the visibility of the current page
  *
  */
 function ToggleVisibility()
 {
     global $gp_titles;
     $_REQUEST += array('visibility' => '');
     \gp\tool\Visibility::Toggle($this->gp_index, $_REQUEST['visibility']);
     $this->visibility = display::OrConfig($this->gp_index, 'vis');
 }
コード例 #6
0
ファイル: gpOutput.php プロジェクト: barbrick/gpEasy-CMS
 /**
  * Output a navigation menu
  * @static
  */
 static function OutputMenu($menu, $start_level, $source_menu = false)
 {
     global $page, $gp_menu, $gp_titles, $GP_MENU_LINKS, $GP_MENU_CLASS, $GP_MENU_CLASSES;
     //source menu
     if ($source_menu === false) {
         $source_menu =& $gp_menu;
     }
     self::PrepMenuOutput();
     $clean_attributes = array('attr' => '', 'class' => array(), 'id' => '');
     $clean_attributes_a = array('href' => '', 'attr' => '', 'value' => '', 'title' => '', 'class' => array());
     // opening ul
     $attributes_ul = $clean_attributes;
     $attributes_ul['class']['menu_top'] = $GP_MENU_CLASSES['menu_top'];
     if (self::$edit_area_id) {
         $attributes_ul['id'] = self::$edit_area_id;
         $attributes_ul['class']['editable_area'] = 'editable_area';
     }
     // Without any output the menu wouldn't be editable
     // An empty <ul> is not valid
     if (!count($menu)) {
         $attributes_ul['class']['empty_menu'] = 'empty_menu';
         self::FormatMenuElement('div', $attributes_ul);
         echo '</div>';
         return;
     }
     $prev_level = $start_level;
     $page_title_full = common::GetUrl($page->title);
     $open = false;
     $li_count = array();
     //get parent page
     $parent_page = false;
     $parents = common::Parents($page->gp_index, $source_menu);
     if (count($parents)) {
         $parent_page = $parents[0];
     }
     //output
     self::FormatMenuElement('ul', $attributes_ul);
     $menu = array_keys($menu);
     foreach ($menu as $menu_index => $menu_key) {
         if (display::OrConfig($menu_key, 'vis')) {
             continue;
         }
         $menu_info = $source_menu[$menu_key];
         $this_level = $menu_info['level'];
         //the next entry
         $next_info = false;
         $next_index = $menu_index + 1;
         if (array_key_exists($next_index, $menu)) {
             $next_index = $menu[$next_index];
             $next_info = $source_menu[$next_index];
         }
         $attributes_a = $clean_attributes_a;
         $attributes_li = $attributes_ul = $clean_attributes;
         //ordered or "indexed" classes
         if ($page->menu_css_ordered) {
             for ($i = $prev_level; $i > $this_level; $i--) {
                 unset($li_count[$i]);
             }
             if (!isset($li_count[$this_level])) {
                 $li_count[$this_level] = 0;
             } else {
                 $li_count[$this_level]++;
             }
             if (!empty($GP_MENU_CLASSES['li_'])) {
                 $attributes_li['class']['li_'] = $GP_MENU_CLASSES['li_'] . $li_count[$this_level];
             }
         }
         if ($page->menu_css_indexed && !empty($GP_MENU_CLASSES['li_title_'])) {
             $attributes_li['class']['li_title_'] = $GP_MENU_CLASSES['li_title_'] . $menu_key;
         }
         //selected classes
         if ($this_level < $next_info['level']) {
             $attributes_a['class']['haschildren'] = $GP_MENU_CLASSES['haschildren'];
             $attributes_li['class']['haschildren_li'] = $GP_MENU_CLASSES['haschildren_li'];
         }
         if (isset($menu_info['url']) && ($menu_info['url'] == $page->title || $menu_info['url'] == $page_title_full)) {
             $attributes_a['class']['selected'] = $GP_MENU_CLASSES['selected'];
             $attributes_li['class']['selected_li'] = $GP_MENU_CLASSES['selected_li'];
         } elseif ($menu_key == $page->gp_index) {
             $attributes_a['class']['selected'] = $GP_MENU_CLASSES['selected'];
             $attributes_li['class']['selected_li'] = $GP_MENU_CLASSES['selected_li'];
         } elseif (in_array($menu_key, $parents)) {
             $attributes_a['class']['childselected'] = $GP_MENU_CLASSES['childselected'];
             $attributes_li['class']['childselected_li'] = $GP_MENU_CLASSES['childselected_li'];
         }
         //current is a child of the previous
         if ($this_level > $prev_level) {
             if ($menu_index === 0) {
                 //only needed if the menu starts below the start_level
                 self::FormatMenuElement('li', $attributes_li);
             }
             if (!empty($GP_MENU_CLASSES['child_ul'])) {
                 $attributes_ul['class'][] = $GP_MENU_CLASSES['child_ul'];
             }
             if ($this_level > $prev_level) {
                 $open_loops = $this_level - $prev_level;
                 for ($i = 0; $i < $open_loops; $i++) {
                     self::FormatMenuElement('ul', $attributes_ul);
                     if ($i < $open_loops - 1) {
                         echo '<li>';
                     }
                     $prev_level++;
                     $attributes_ul = $clean_attributes;
                 }
             }
             //current is higher than the previous
         } elseif ($this_level < $prev_level) {
             while ($this_level < $prev_level) {
                 echo '</li></ul>';
                 $prev_level--;
             }
             if ($open) {
                 echo '</li>';
             }
         } elseif ($open) {
             echo '</li>';
         }
         //external
         if (isset($menu_info['url'])) {
             if (empty($menu_info['title_attr'])) {
                 $menu_info['title_attr'] = strip_tags($menu_info['label']);
             }
             $attributes_a['href'] = $menu_info['url'];
             $attributes_a['value'] = $menu_info['label'];
             $attributes_a['title'] = $menu_info['title_attr'];
             if (isset($menu_info['new_win'])) {
                 $attributes_a['target'] = '_blank';
             }
             //internal link
         } else {
             $title = common::IndexToTitle($menu_key);
             $attributes_a['href'] = common::GetUrl($title);
             $attributes_a['value'] = common::GetLabel($title);
             $attributes_a['title'] = common::GetBrowserTitle($title);
             //get valid rel attr
             if (!empty($gp_titles[$menu_key]['rel'])) {
                 $rel = explode(',', $gp_titles[$menu_key]['rel']);
                 $attributes_a['rel'] = array_intersect(array('alternate', 'author', 'bookmark', 'help', 'icon', 'license', 'next', 'nofollow', 'noreferrer', 'prefetch', 'prev', 'search', 'stylesheet', 'tag'), $rel);
             }
         }
         self::FormatMenuElement('li', $attributes_li);
         self::FormatMenuElement('a', $attributes_a);
         $prev_level = $this_level;
         $open = true;
     }
     while ($start_level <= $prev_level) {
         echo '</li></ul>';
         $prev_level--;
     }
 }
コード例 #7
0
 function SearchPage($title, $index)
 {
     global $gp_menu;
     //search hidden?
     if (!$this->search_hidden && !isset($gp_menu[$index])) {
         return;
     }
     //private pages
     if (!common::LoggedIn()) {
         $visibility = display::OrConfig($index, 'vis');
         if ($visibility) {
             return;
         }
     }
     $full_path = gpFiles::PageFile($title);
     $file_sections = gpFiles::Get($full_path, 'file_sections');
     if (!$file_sections) {
         return;
     }
     $content = section_content::Render($file_sections, $title, gpFiles::$last_stats);
     $label = common::GetLabel($title);
     $this->FindString($content, $label, $title);
 }