/** * Very rough integration test of the updater * Passes if no errors are thrown * Also defines $page for subsequent tests * */ function UpdateOutputTest() { global $page; ob_start(); $page = new \gp\admin\Update(); \gp\tool\Output::HeadContent(); includeFile('install/template.php'); ob_get_clean(); }
public function EditGalleries() { global $langmessage; $this->page->head_js[] = '/include/js/special_galleries.js'; $this->page->css_admin[] = '/include/css/edit_gallery.css'; echo '<h2>'; echo \gp\tool::Link('Special_Galleries', \gp\tool\Output::ReturnText('galleries')); echo ' » ' . $langmessage['administration']; echo '</h2>'; echo '<p>'; echo $langmessage['DRAG-N-DROP-DESC2']; echo '</p>'; $this->EditableArea(); }
/** * Handle HTTP responses made with $_REQUEST['req'] = json (when <a ... data-cmd="gpajax">) * Sends JSON object to client * */ static function Response() { global $page; if (!is_array($page->ajaxReplace)) { die; } //admin toolbar self::AdminToolbar(); //gadgets may be using gpajax/json request/responses \gp\tool\Output::TemplateSettings(); \gp\tool\Output::PrepGadgetContent(); echo self::Callback(); echo '(['; //output content if (!empty($_REQUEST['gpx_content'])) { switch ($_REQUEST['gpx_content']) { case 'gpabox': self::JsonDo('admin_box_data', '', $page->contentBuffer); break; } } elseif (in_array('#gpx_content', $page->ajaxReplace)) { $replace_id = '#gpx_content'; if (isset($_GET['gpreqarea'])) { $replace_id = '#' . $_GET['gpreqarea']; } ob_start(); $page->GetGpxContent(true); $content = ob_get_clean(); self::JsonDo('replace', $replace_id, $content); } //other areas foreach ($page->ajaxReplace as $arguments) { if (is_array($arguments)) { $arguments += array(0 => '', 1 => '', 2 => ''); self::JsonDo($arguments[0], $arguments[1], $arguments[2]); } } //always send messages self::Messages(); echo ']);'; die; }
function __construct($args) { global $langmessage, $config; parent::__construct($args); /* An xml site map will not show any of the pages from dynamic add-ons ... which is precisely what the regular sitemap shows */ if (isset($_GET['xml'])) { $this->xml(); return; } $this->MultiSiteData(); echo '<div class="sitemap_xml">'; echo \gp\tool::Link('Special_Site_Map', 'XML', 'xml'); echo '</div>'; echo '<h2>'; echo \gp\tool\Output::ReturnText('site_map'); echo '</h2>'; \gp\tool\Output::GetFullMenu(); }
/** * Update the gp_index, gp_titles and menus so that special pages can be renamed * */ function Upgrade_234() { global $gp_index, $gp_titles, $gp_menu, $config, $dataDir; $special_indexes = array(); $new_index = array(); $new_titles = array(); foreach ($gp_index as $title => $index) { $info = $gp_titles[$index]; $type = \gp\tool::SpecialOrAdmin($title); if ($type === 'special') { $special_indexes[$index] = strtolower($title); $index = strtolower($title); $info['type'] = 'special'; //some older versions didn't maintain this value well } $new_index[$title] = $index; $new_titles[$index] = $info; } $gp_titles = $new_titles; $gp_index = $new_index; //update gp_menu $gp_menu = $this->FixMenu($gp_menu, $special_indexes); //save pages if (!\gp\admin\Tools::SavePagesPHP()) { return; } $config['gpversion'] = '2.3.4'; \gp\admin\Tools::SaveConfig(); //update alt menus if (isset($config['menus']) && is_array($config['menus'])) { foreach ($config['menus'] as $key => $value) { $menu_file = $dataDir . '/data/_menus/' . $key . '.php'; if (\gp\tool\Files::Exists($menu_file)) { $menu = \gp\tool\Output::GetMenuArray($key); $menu = $this->FixMenu($menu, $special_indexes); \gp\tool\Files::SaveData($menu_file, 'menu', $menu); } } } }
<?php define('is_running', true); //define('gpdebug',true); require_once '../common.php'; \gp\tool::EntryPoint(2, 'update.php'); /* check permissions */ if (!\gp\tool::LoggedIn()) { die('You must be logged in to access this area.'); } if (!isset($gpAdmin['granted']) || $gpAdmin['granted'] !== 'all') { die('Sorry, you do not have sufficient privileges to access this area.'); } \gp\tool::GetLangFile(); $page = new \gp\admin\Update(); \gp\tool\Output::HeadContent(); includeFile('install/template.php');
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; }
/** * * */ public function ExtraRow($title, $types) { global $langmessage; $file = $this->ExtraExists($title); $file_draft = dirname($file) . '/draft.php'; $sections = \gp\tool\Output::ExtraContent($title); $section = $sections[0]; echo '<tr><td style="white-space:nowrap">'; echo str_replace('_', ' ', $title); echo '</td><td>'; $type = $section['type']; if (isset($types[$type]) && isset($types[$type]['label'])) { $type = $types[$type]['label']; } echo $type; echo '</td><td>"<span class="admin_note">'; $content = strip_tags($section['content']); echo substr($content, 0, 50); echo '</span>..."</td><td style="white-space:nowrap">'; //preview echo \gp\tool::Link('Admin/Extra', $langmessage['preview'], 'cmd=PreviewText&file=' . rawurlencode($title)); echo ' '; //publish if (file_exists($file_draft)) { echo \gp\tool::Link('Admin/Extra', $langmessage['Publish Draft'], 'cmd=PublishDraft&file=' . rawurlencode($title), array('data-cmd' => 'creq')); } else { echo '<span class="text-muted">' . $langmessage['Publish Draft'] . '</span>'; } echo ' '; //edit if ($section['type'] == 'text') { echo \gp\tool::Link('Admin/Extra', $langmessage['edit'], 'cmd=EditExtra&file=' . rawurlencode($title)); } else { echo '<span class="text-muted">' . $langmessage['edit'] . '</span>'; } echo ' '; $title = sprintf($langmessage['generic_delete_confirm'], htmlspecialchars($title)); echo \gp\tool::Link('Admin/Extra', $langmessage['delete'], 'cmd=DeleteArea&file=' . rawurlencode($title), array('data-cmd' => 'postlink', 'title' => $title, 'class' => 'gpconfirm')); echo '</td></tr>'; }
/** * Get an array of titles that is not represented in any of the menus * */ public function GetNoMenus() { global $gp_index; //first get all titles in a menu $menus = $this->GetAvailMenus('menu'); $all_keys = array(); foreach ($menus as $menu_id => $label) { $menu_array = \gp\tool\Output::GetMenuArray($menu_id); $keys = array_keys($menu_array); $all_keys = array_merge($all_keys, $keys); } $all_keys = array_unique($all_keys); //then check $gp_index agains $all_keys $avail = array(); foreach ($gp_index as $title => $index) { if (in_array($index, $all_keys)) { continue; } $avail[] = $title; } return $avail; }
public static function ExecInfo($scriptinfo) { ob_start(); \gp\tool\Output::ExecInfo($scriptinfo); return ob_get_clean(); }
public function ShowForm() { global $langmessage, $config; $attr = ''; if ($this->sent) { $attr = ' readonly="readonly" '; } $_GET += array('name' => '', 'email' => '', 'subject' => '', 'message' => ''); $_POST += array('name' => $_GET['name'], 'email' => $_GET['email'], 'subject' => $_GET['subject'], 'message' => $_GET['message']); $require_email =& $config['require_email']; echo '<form class="contactform" action="' . \gp\tool::GetUrl($this->page->title) . '" method="post">'; //nonce fields echo '<div style="display:none !important">'; echo '<input type="hidden" name="contact_nonce" value="' . htmlspecialchars(\gp\tool::new_nonce('contact_post', true)) . '" />'; echo '<input type="text" name="contact_void" value="" />'; echo '</div>'; echo '<label for="contact_name"><span class="title">'; echo \gp\tool\Output::ReturnText('your_name'); echo '</span><input id="contact_name" class="input text" type="text" name="name" value="' . htmlspecialchars($_POST['name']) . '" ' . $attr . ' />'; echo '</label>'; echo '<label for="contact_email"><span class="title">'; echo \gp\tool\Output::ReturnText('your_email'); if (strpos($require_email, 'email') !== false) { echo '*'; } echo '</span><input id="contact_email" class="input text" type="text" name="email" value="' . htmlspecialchars($_POST['email']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_subject"><span class="title">'; echo \gp\tool\Output::ReturnText('subject'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</span><input id="contact_subject" class="input text" type="text" name="subject" value="' . htmlspecialchars($_POST['subject']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_message">'; echo \gp\tool\Output::ReturnText('message'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</label>'; echo '<textarea id="contact_message" name="message" ' . $attr . ' rows="10" cols="10">'; echo htmlspecialchars($_POST['message']); echo '</textarea>'; \gp\tool\Plugins::Action('contact_form_pre_captcha'); if (!$this->sent && \gp\tool\Recaptcha::isActive()) { echo '<div class="captchaForm">'; echo \gp\tool\Output::ReturnText('captcha'); \gp\tool\Recaptcha::Form(); echo '</div>'; } if ($this->sent) { echo \gp\tool\Output::ReturnText('message_sent', '%s', 'message_sent'); } else { echo '<input type="hidden" name="cmd" value="gp_send_message" />'; $key = 'send_message'; $text = \gp\tool\Output::SelectText($key); if (\gp\tool\Output::ShowEditLink('Admin_Theme_Content')) { $query = 'cmd=EditText&key=' . urlencode($key); echo \gp\tool\Output::EditAreaLink($edit_index, 'Admin_Theme_Content', $langmessage['edit'], $query, ' title="' . $key . '" data-cmd="gpabox" '); echo '<input type="submit" class="submit editable_area" id="ExtraEditArea' . $edit_index . '" name="aaa" value="' . $text . '" />'; } else { echo '<input type="submit" class="submit" name="aaa" value="' . $text . '" />'; } } echo '</form>'; }
function GetAdminLink() { trigger_error('deprecated functions'); \gp\tool\Output::GetAdminLink(); }
/** * Find the requested admin script and execute it if the user has permissions to view it * */ private function RunAdminScript() { global $dataDir, $langmessage; if (strtolower($this->requested) == 'admin') { $this->AdminPanel(); return; } //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234 $request_string = str_replace('_', '/', $this->requested); $parts = explode('/', $request_string); do { $request_string = implode('/', $parts); $scriptinfo = $this->GetScriptInfo($request_string); if (is_array($scriptinfo)) { if (\gp\admin\Tools::HasPermission($request_string)) { $this->OrganizeFrequentScripts($request_string); \gp\tool\Output::ExecInfo($scriptinfo, array('page' => $this)); return; } message($langmessage['not_permitted']); $this->AdminPanel(); return; } //these are here because they should be available to everyone switch ($request_string) { case 'Admin/Finder': if (\gp\admin\Tools::HasPermission('Admin_Uploaded')) { includeFile('thirdparty/finder/connector.php'); return; } break; } array_pop($parts); } while (count($parts)); $this->Redirect(); }
/** * Execute the php code associated with a $hook * @param string $hook * @param array $hook_info * @param array $args * */ public static function ExecHook($hook, $info, $args = array()) { global $dataDir, $gp_current_hook; if (gp_safe_mode) { if (isset($args[0])) { return $args[0]; } return; } if (!is_array($args)) { $args = array($args); } $gp_current_hook[] = $hook; //value if (!empty($info['value'])) { $args[0] = $info['value']; } $args = \gp\tool\Output::ExecInfo($info, $args); array_pop($gp_current_hook); if (isset($args[0])) { return $args[0]; } return false; }
require_once 'common.php'; \gp\tool::EntryPoint(0); /* * Flow Control */ if (!empty($GLOBALS['config']['updating_message'])) { die($GLOBALS['config']['updating_message']); } $title = \gp\tool::WhichPage(); $type = \gp\tool::SpecialOrAdmin($title); switch ($type) { case 'special': $page = new \gp\special\Page($title, $type); break; case 'admin': if (\gp\tool::LoggedIn()) { $page = new \gp\admin\Page($title, $type); } else { $page = new \gp\admin\Login($title, $type); } break; default: if (\gp\tool::LoggedIn()) { $page = new \gp\Page\Edit($title, $type); } else { $page = new \gp\Page($title, $type); } break; } \gp\tool\Output::RunOut();
public function ShowForm() { echo \gp\tool\Output::GetExtra('Contact'); parent::ShowForm(); }
public function Get404() { global $langmessage, $page; \gp\tool\Output::AddHeader('Not Found', true, 404); $page->head .= '<meta name="robots" content="noindex,nofollow" />'; //this isn't getting to the template because $page isn't available yet //message for admins if (\gp\tool::LoggedIn()) { if ($this->requested && \gp\tool::SpecialOrAdmin($this->requested) === false) { $with_spaces = htmlspecialchars($this->requested); $link = \gp\tool::GetUrl('Admin/Menu/Ajax', 'cmd=AddHidden&redir=redir&title=' . rawurlencode($this->requested)) . '" title="' . $langmessage['create_new_file'] . '" data-cmd="gpabox'; $message = sprintf($langmessage['DOESNT_EXIST'], $with_spaces, $link); msg($message); } } //Contents of 404 page $wrap = \gp\tool\Output::ShowEditLink('Admin/Missing'); if ($wrap) { echo \gp\tool\Output::EditAreaLink($edit_index, 'Admin/Missing', $langmessage['edit'], 'cmd=edit404', ' title="' . $langmessage['404_Page'] . '" '); echo '<div class="editable_area" id="ExtraEditArea' . $edit_index . '">'; // class="edit_area" added by javascript } echo self::Get404Output(); if ($wrap) { echo '</div>'; } }
/** * Get a list of theme subfolders that have style.css files * */ public function GetThemeColors($dir) { $subdirs = \gp\tool\Files::readDir($dir, 1); $colors = array(); asort($subdirs); foreach ($subdirs as $subdir) { if (\gp\tool\Output::StyleType($dir . '/' . $subdir) !== false) { $colors[$subdir] = $subdir; } } return $colors; }
public function ShowResults() { global $langmessage; if (!count($this->results)) { echo '<p>'; echo \gp\tool\Output::GetAddonText($langmessage['search_no_results']); echo '</p>'; return; } $this->RemoveDups(); usort($this->results, array($this, 'sort')); $total = count($this->results); $len = 20; $total_pages = ceil($total / $len); $current_page = self::ReqPage('pg', $total_pages); $start = $current_page * $len; $end = min($start + $len, $total); $this->results = array_slice($this->results, $start, $len, true); echo '<p class="search_nav search_nav_top">'; echo sprintf($langmessage['SHOWING'], $start + 1, $end, $total); echo '</p>'; echo '<div class="result_list">'; foreach ($this->results as $result) { echo '<div><h4>'; echo isset($result['link']) ? $result['link'] : \gp\tool::Link($result['slug'], $result['label'], $result['query']); echo '</h4>'; echo $result['content']; if ($this->show_stats) { echo ' <span class="match_stats">'; echo $result['matches'] . ' match(es) out of ' . $result['words'] . ' words '; echo ' </span>'; } echo '</div>'; } echo '</div>'; $attr = ''; if ($this->gpabox) { $attr = 'data-cmd="gpabox"'; } $query = 'q=' . rawurlencode($_REQUEST['q']); self::PaginationLinks($current_page, $total_pages, 'special_gpsearch', $query, 'pg', $attr); }
color:#aaa; } .progress li{ padding: 5px 20px 5px 0; } .formtable td, .formtable th{ padding: 5px 20px 5px 0; text-align:left; vertical-align:top; } </style> <?php \gp\tool\Output::getHead(); ?> </head> <body> <div class="wrapper"> <h1>Typesetter Updater</h1> <?php $page->GetContent(); ?> </div>
/** * Include the content of a gadget * @param string $requested The name of the gadget to include * */ static function IncludeGadget($requested) { global $config; if (!isset($config['gadgets'][$requested])) { return '{{Gadget Not Found: ' . htmlspecialchars($requested) . '}}'; } ob_start(); \gp\tool\Output::GetGadget($requested); return ob_get_clean(); }
/** * Include a script, unless it has caused a fatal error. * Using this function allows handling fatal errors that are thrown by the included php scripts * * @param string $file The full path of the php file to include * @param string $include_variation Which variation or adaptation of php's include() function to use (include,include_once,include_if, include_once_if, require ...) * @param array List of global variables to set */ function IncludeScript($file, $include_variation = 'include_once', $globals = array()) { $exists = file_exists($file); //check to see if it exists $include_variation = str_replace('_if', '', $include_variation, $has_if); if ($has_if && !$exists) { return; } //check for fatal errors if (\gp\tool\Output::FatalNotice('include', $file)) { return false; } //set global variables foreach ($globals as $global) { global ${$global}; } switch ($include_variation) { case 'include': $return = (include $file); break; case 'include_once': $return = (include_once $file); break; case 'require': $return = (require $file); break; case 'require_once': $return = (require_once $file); break; } \gp\tool\Output::PopCatchable(); return $return; }
/** * Perform admin only changes to the content buffer * This will happen before \gp\tool\Output::BufferOut() * */ public static function AdminBuffer($buffer) { global $wbErrorBuffer, $gp_admin_html; //add $gp_admin_html to the document if (strpos($buffer, '<!-- get_head_placeholder ' . gp_random . ' -->') !== false) { $buffer = \gp\tool\Output::AddToBody($buffer, '<div id="gp_admin_html">' . $gp_admin_html . \gp\tool\Output::$editlinks . '</div><div id="gp_admin_fixed"></div>'); } // Add a generic admin nonce field to each post form // Admin nonces are also added with javascript if needed $count = preg_match_all('#<form[^<>]*method=[\'"]post[\'"][^<>]*>#i', $buffer, $matches); if ($count) { $nonce = \gp\tool::new_nonce('post', true); $matches[0] = array_unique($matches[0]); foreach ($matches[0] as $match) { //make sure it's a local action if (preg_match('#action=[\'"]([^\'"]+)[\'"]#i', $match, $sub_matches)) { $action = $sub_matches[1]; if (substr($action, 0, 2) === '//') { continue; } elseif (strpos($action, '://')) { continue; } } $replacement = '<span class="nodisplay"><input type="hidden" name="verified" value="' . $nonce . '"/></span>'; $pos = strpos($buffer, $match) + strlen($match); $buffer = substr_replace($buffer, $replacement, $pos, 0); } } return $buffer; }
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(); }
/** * Set global variables ( $gp_index, $gp_titles, $gp_menu and $gpLayouts ) from _site/pages.php * */ public static function GetPagesPHP() { global $gp_index, $gp_titles, $gp_menu, $gpLayouts, $config; $gp_index = array(); $pages = \gp\tool\Files::Get('_site/pages'); //update for < 2.0a3 if (array_key_exists('gpmenu', $pages) && array_key_exists('gptitles', $pages) && !array_key_exists('gp_titles', $pages) && !array_key_exists('gp_menu', $pages)) { foreach ($pages['gptitles'] as $title => $info) { $index = self::NewFileIndex(); $gp_index[$title] = $index; $gp_titles[$index] = $info; } foreach ($pages['gpmenu'] as $title => $level) { $index = $gp_index[$title]; $gp_menu[$index] = array('level' => $level); } return; } $gpLayouts = $pages['gpLayouts']; $gp_index = $pages['gp_index']; $gp_titles = $pages['gp_titles']; $gp_menu = $pages['gp_menu']; if (!is_array($gp_menu)) { self::stop(); } //update for 3.5, if (!isset($gp_titles['special_gpsearch'])) { $gp_titles['special_gpsearch'] = array(); $gp_titles['special_gpsearch']['label'] = 'Search'; $gp_titles['special_gpsearch']['type'] = 'special'; $gp_index['Search'] = 'special_gpsearch'; //may overwrite special_search settings } //fix the gpmenu if (version_compare(\gp\tool\Files::$last_version, '3.0b1', '<')) { $gp_menu = \gp\tool\Output::FixMenu($gp_menu); // fix gp_titles for 3.0+ // just make sure any ampersands in the label are escaped foreach ($gp_titles as $key => $value) { if (isset($gp_titles[$key]['label'])) { $gp_titles[$key]['label'] = self::GetLabelIndex($key, true); } } } //title related configuration settings if (empty($config['homepath_key'])) { $config['homepath_key'] = key($gp_menu); } $config['homepath'] = self::IndexToTitle($config['homepath_key']); }
/** * Insert new content into a layout * */ public function AddContent() { global $langmessage; //for ajax responses $this->page->ajaxReplace = array(); if (!isset($_REQUEST['where'])) { message($langmessage['OOPS']); return false; } //prep destination if (!$this->GetValues($_REQUEST['where'], $to_container, $to_gpOutCmd)) { return false; } $handlers = $this->GetAllHandlers(); $this->PrepContainerHandlers($handlers, $to_container, $to_gpOutCmd); //figure out what we're inserting $addtype =& $_REQUEST['addtype']; switch ($_REQUEST['addtype']) { case 'new_extra': $extra_name = $this->NewExtraArea(); if ($extra_name === false) { message($langmessage['OOPS'] . '(2)'); return false; } $insert = 'Extra:' . $extra_name; break; case 'custom_menu': $insert = $this->NewCustomMenu(); break; case 'preset_menu': $insert = $this->NewPresetMenu(); break; default: $insert = $_REQUEST['insert']; break; } if (!$insert) { message($langmessage['OOPS'] . ' (Nothing to insert)'); return false; } //new info $new_gpOutInfo = \gp\tool\Output::GetgpOutInfo($insert); if (!$new_gpOutInfo) { message($langmessage['OOPS'] . ' (Nothing to insert)'); return false; } $new_gpOutCmd = rtrim($new_gpOutInfo['key'] . ':' . $new_gpOutInfo['arg'], ':'); if (!$this->AddToContainer($handlers[$to_container], $to_gpOutCmd, $new_gpOutCmd, false)) { return false; } $this->SaveHandlersNew($handlers); return true; }