/** * 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 ' <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; }
/** * Form for adding external link * */ public function ExternalForm($cmd, $submit, $args) { global $langmessage; //these aren't all required for each usage of ExternalForm() $args += array('url' => 'http://', 'label' => '', 'title_attr' => '', 'insert_how' => '', 'insert_where' => '', 'key' => ''); echo '<form action="' . $this->GetUrl('Admin/Menu/Ajax') . '" method="post">'; echo '<input type="hidden" name="insert_how" value="' . htmlspecialchars($args['insert_how']) . '" />'; echo '<input type="hidden" name="insert_where" value="' . htmlspecialchars($args['insert_where']) . '" />'; echo '<input type="hidden" name="key" value="' . htmlspecialchars($args['key']) . '" />'; echo '<table class="bordered full_width">'; echo '<tr>'; echo '<th> </th>'; echo '<th> </th>'; echo '</tr>'; echo '<tr><td>'; echo $langmessage['Target URL']; echo '</td><td>'; echo '<input type="text" name="url" value="' . $args['url'] . '" class="gpinput"/>'; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['label']; echo '</td><td>'; echo '<input type="text" name="label" value="' . \gp\tool::LabelSpecialChars($args['label']) . '" class="gpinput"/>'; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['title attribute']; echo '</td><td>'; echo '<input type="text" name="title_attr" value="' . $args['title_attr'] . '" class="gpinput"/>'; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['New_Window']; echo '</td><td>'; if (isset($args['new_win'])) { echo '<input type="checkbox" name="new_win" value="new_win" checked="checked" />'; } else { echo '<input type="checkbox" name="new_win" value="new_win" />'; } echo '</td></tr>'; echo '</table>'; echo '<p>'; echo '<input type="hidden" name="cmd" value="' . htmlspecialchars($cmd) . '" />'; echo '<input type="submit" name="" value="' . $submit . '" class="gpsubmit" data-cmd="gppost"/> '; echo '<input type="submit" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" /> '; echo '</p>'; echo '</form>'; }
/** * 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> </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>'; }
/** * 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>'; }
public function InheritingLayout($searchLevel, &$menu, &$result) { global $gp_titles; $children = true; do { $menu_key = key($menu); $info = current($menu); if (!isset($info['level'])) { break; } $level = $info['level']; if ($level < $searchLevel) { return; } if ($level > $searchLevel) { if ($children) { self::InheritingLayout($level, $menu, $result); } else { unset($menu[$menu_key]); } continue; } unset($menu[$menu_key]); if (!empty($gp_titles[$menu_key]['gpLayout'])) { $children = false; continue; } $children = true; //exclude external links if ($menu_key[0] == '_') { continue; } $label = \gp\tool::GetLabelIndex($menu_key, false); $result[] = \gp\tool::LabelSpecialChars($label); } while (count($menu) > 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>'; } }
/** * Fix the html for page labels * */ public static function LabelHtml($string) { //prepend with space for preg_split(), space will be trimmed at the end $string = ' ' . $string; //change non html entity uses of & to & (not exact but should be sufficient) $pieces = preg_split('#(&(?:\\#[0-9]{2,4}|[a-zA-Z0-9]{2,8});)#', $string, 0, PREG_SPLIT_DELIM_CAPTURE); $string = ''; for ($i = 0; $i < count($pieces); $i++) { if ($i % 2) { $string .= $pieces[$i]; } else { $string .= str_replace('&', '&', $pieces[$i]); } } //change non html tag < and > into < and > $pieces = preg_split('#(<(?:/?)[a-zA-Z0-9][^<>]*>)#', $string, 0, PREG_SPLIT_DELIM_CAPTURE); $string = ''; for ($i = 0; $i < count($pieces); $i++) { if ($i % 2) { $string .= $pieces[$i]; } else { $string .= \gp\tool::LabelSpecialChars($pieces[$i]); } } //only allow tags that are legal to be inside <a> except for <script>.Per http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_a.content $string = strip_tags($string, '<abbr><acronym><b><big><bdo><br><button><cite><code><del><dfn><em><kbd><i><img><input><ins><label><map><object><q><samp><select><small><span><sub><sup><strong><textarea><tt><var>'); return trim($string); }