content public $head = ''; public $head_js = array(); public $head_script = ''; public $jQueryCode = false; public $admin_js = false; public $head_force_inline = false; public $meta_description = ''; public $meta_keywords = array(); //css arrays public $css_user = array(); public $css_admin = array(); /* @deprecated 3.5 */ public $theme_is_addon = false; public function __construct($title, $type){ global $config, $languages; $this->requested = $title; $this->title = $title; $this->lang = $config['language']; if( isset($languages[$this->lang]) ){ $this->language = $languages[$this->lang]; } $this->head .= ''."\n"; } /** * Get page content or do redirect for non-existant titles * see special_missing.php and /Admin/Settings/Missing */ public function Error_404(){ ob_start(); $args = array('page'=>$this); $missing = new \gp\special\Missing($args); $missing->RunScript(); $this->contentBuffer = ob_get_clean(); } public function SetVars(){ global $gp_index, $gp_titles, $gp_menu; if( !isset($gp_index[$this->title]) ){ $this->Error_404(); 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; } /** * Check the page's visibility * */ public function CheckVisibility(){ global $gp_titles; if( isset($gp_titles[$this->gp_index]['vis']) ){ $this->visibility = $gp_titles[$this->gp_index]['vis']; } if( !\gp\tool::LoggedIn() && $this->visibility ){ $this->Error_404(); return false; } return true; } public 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); } /** * Retreive the data file for the current title and update the data if necessary * */ public function GetFile(){ $this->file_sections = \gp\tool\Files::Get($this->file,'file_sections'); $this->meta_data = \gp\tool\Files::$last_meta; $this->fileModTime = \gp\tool\Files::$last_modified; $this->file_stats = \gp\tool\Files::$last_stats; if( count($this->file_sections) == 0 ){ $this->file_sections[0] = array( 'type' => 'text', 'content' => '
Oops, this page no longer has any content.
', ); } } /** * 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 * */ public function SetTheme($layout=false){ global $dataDir; if( $layout === false ){ $layout = self::OrConfig($this->gp_index,'gpLayout'); } $layout_info = \gp\tool::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 = \gp\tool::GetDir($this->theme_rel); } /** * Return the most relevant configuration value for a configuration option ($var) * Check configuration for a page ($id) first, then parent pages (determined by main menu), then the site $config * * @return mixed * */ public static function OrConfig($id,$var){ global $config, $gp_titles; if( $id ){ if( !empty($gp_titles[$id][$var]) ){ return $gp_titles[$id][$var]; } if( self::ParentConfig($id,$var,$value) ){ return $value; } } if( isset($config[$var]) ){ return $config[$var]; } return false; } /** * Traverse the main menu upwards looking for a configuration setting for $var * Start at the title represented by $checkId * Set $value to the configuration setting if a parent page has the configuration setting * * @return bool */ public static function ParentConfig($checkId,$var,&$value){ global $gp_titles,$gp_menu; $parents = \gp\tool::Parents($checkId,$gp_menu); foreach($parents as $parent_index){ if( !empty($gp_titles[$parent_index][$var]) ){ $value = $gp_titles[$parent_index][$var]; return true; } } return false; } /* * Get functions * * Missing: * $#sitemap#$ * different menu output * */ public function GetSiteLabel(){ global $config; echo $config['title']; } public function GetSiteLabelLink(){ global $config; echo \gp\tool::Link('',$config['title']); } public function GetPageLabel(){ echo $this->label; } public function GetContent(){ $this->GetGpxContent(); echo '