/** * Display a list of all the titles using the current layout * */ 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 = common::IndexToTitle($index); if (empty($title)) { continue; //may be external link } echo "\n<li>"; $label = common::GetLabel($title); $label = common::LabelSpecialChars($label); echo common::Link($title, $label); echo '</li>'; } } echo '</ul>'; echo '<div class="clear"></div>'; } }
/** * Fix the html for page labels * */ 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 .= common::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); }
/** * Language selection popup * */ public function TitleSettings($args = array()) { global $gp_titles, $langmessage, $langmessage, $gp_index; $args += array('to_lang' => '', 'to_slug' => ''); $page_index = $_REQUEST['index']; if (!isset($gp_titles[$page_index])) { echo $langmessage['OOPS'] . ' (Invalid Title - 3)'; return; } $list = $this->GetList($page_index); echo '<div>'; echo '<form method="post" action="' . common::GetUrl('Admin_MultiLang') . '">'; echo '<input type="hidden" name="cmd" value="TitleSettingsSave" />'; echo '<input type="hidden" name="index" value="' . $page_index . '" />'; echo '<h3>Page Settings</h3>'; echo '<table class="bordered"><tr><th>Language</th><th>Title</th><th>Options</th></tr>'; //not set yet if (!$list) { $in_menu = $this->InMenu($page_index); echo '<tr><td>'; if ($in_menu) { echo $this->language; } else { $this->Select('from_lang', '#lang_data'); } echo '</td><td>'; $title = common::IndexToTitle($page_index); echo common::Link_Page($title); echo '</td><td>'; echo '</td></tr>'; } //current settings foreach ($this->avail_langs as $lang => $language) { if (!isset($list[$lang])) { continue; } $index = $list[$lang]; echo '<tr><td>'; echo $language . ' (' . $lang . ')'; echo '</td><td>'; $title = common::IndexToTitle($index); echo common::Link_Page($title); echo '</td><td>'; echo common::Link('Admin_MultiLang', 'Remove', 'cmd=RemoveTitle&index=' . $page_index . '&rmindex=' . $index, 'name="gpabox" class="gpconfirm" title="Remove this entry?"'); echo '</td></tr>'; } //option to add another title echo '<tr><td>'; $this->Select('to_lang', '#lang_data', $args['to_lang']); echo '</td><td>'; $this->Select('to_slug', '#lang_titles', $args['to_slug']); echo '</td><td>'; echo '<input type="submit" value="' . $langmessage['save'] . '" class="gpabox gpbutton" /> '; echo '</td></tr>'; echo '</table>'; echo '</form>'; $this->SmLinks(); //add languages as json $data = array(); foreach ($this->langs as $code => $label) { $data[] = array($label, $code); } echo "\n"; echo '<span id="lang_data" data-json=\'' . htmlspecialchars(json_encode($data), ENT_QUOTES & ~ENT_COMPAT) . '\'></span>'; //add titles as json $data = array(); foreach ($gp_index as $slug => $index) { $label = common::GetLabelIndex($index); $data[] = array($slug, common::LabelSpecialChars($label)); } echo "\n"; echo '<span id="lang_titles" data-json=\'' . htmlspecialchars(json_encode($data), ENT_QUOTES & ~ENT_COMPAT, 'UTF-8', false) . '\'></span>'; echo '</div>'; }
/** * Display a form for copying a page * */ function CopyForm() { global $langmessage, $gp_index, $page; $from_title = $_REQUEST['title']; if (!isset($gp_index[$from_title])) { message($langmessage['OOPS_TITLE']); return false; } $from_label = common::GetLabel($from_title); $from_label = common::LabelSpecialChars($from_label); echo '<div class="inline_box">'; echo '<form method="post" action="' . common::GetUrl('Admin_Menu') . '">'; 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="copyit"/> '; echo '<input type="submit" name="" value="' . $langmessage['continue'] . '" class="gppost gpsubmit"/>'; echo '<input type="button" class="admin_box_close gpcancel" name="" value="' . $langmessage['cancel'] . '" />'; echo '</p>'; echo '</form>'; echo '</div>'; }
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) { page_layout::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 = common::GetLabelIndex($menu_key, false); $result[] = common::LabelSpecialChars($label); } while (count($menu) > 0); }
/** * Show details about the selected layout * */ function ShowDetails($layout, $layout_info, $handlers_count) { global $langmessage, $config; echo '<h3>' . $langmessage['details'] . '</h3>'; //layout options echo '<table class="bordered full_width">'; echo '<tr><th colspan="2">'; echo $langmessage['layout']; echo '</th></tr>'; echo '<tr><td style="width:40%">'; echo $langmessage['label']; echo '</td><td>'; echo '<a name="layout_id" title="' . $layout_info['color'] . '" rel="' . $layout_info['color'] . '">'; echo '<input type="hidden" name="layout" value="' . htmlspecialchars($layout) . '" /> '; echo '<input type="hidden" name="layout_label" value="' . $layout_info['label'] . '" /> '; echo '<span class="layout_color_id" style="background-color:' . $layout_info['color'] . ';"></span>'; echo ' '; echo $layout_info['label']; echo '</a>'; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['theme']; echo '</td><td>'; echo $layout_info['theme_name']; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['usage']; echo '</td><td>'; if ($config['gpLayout'] == $layout) { echo $langmessage['default']; } elseif (!isset($_GET['show'])) { echo common::Link('Admin_Theme_Content/' . rawurlencode($layout), str_replace(' ', ' ', $langmessage['make_default']), 'cmd=makedefault', ' name="gpabox" title="' . htmlspecialchars($langmessage['make_default']) . '" '); } else { echo common::Link('Admin_Theme_Content', str_replace(' ', ' ', $langmessage['default']), 'cmd=makedefault&layout_id=' . rawurlencode($layout), ' name="creq" title="' . htmlspecialchars($langmessage['make_default']) . '" '); } echo ' '; $titles_count = $this->TitlesCount($layout); echo sprintf($langmessage['%s Pages'], $titles_count); echo '</td></tr>'; $theme_colors = $this->GetThemeColors($layout_info['dir']); echo '<tr><td>'; echo $langmessage['style']; echo '</td><td>'; if (!isset($_GET['show'])) { echo '<form action="' . common::GetUrl('Admin_Theme_Content/' . rawurlencode($layout)) . '" method="post">'; } else { echo '<form action="' . common::GetUrl('Admin_Theme_Content') . '" method="post">'; echo '<input type="hidden" name="layout" value="' . $layout . '" />'; } echo '<select name="color" class="gpselect">'; foreach ($theme_colors as $color) { if ($color == $layout_info['theme_color']) { echo '<option value="' . htmlspecialchars($color) . '" selected="selected">'; } else { echo '<option value="' . htmlspecialchars($color) . '">'; } echo $color; echo '</option>'; } echo '</select>'; echo ' <input type="hidden" name="cmd" value="change_layout_color" />'; echo ' <input type="submit" name="" value="' . htmlspecialchars($langmessage['save']) . '" class="gpbutton" />'; echo '</form>'; echo '</td></tr>'; echo '<tr><td>'; echo $langmessage['content_arrangement']; echo '</td><td>'; if ($handlers_count > 0) { if (!isset($_GET['show'])) { echo common::Link('Admin_Theme_Content/' . rawurlencode($layout), $langmessage['restore_defaults'], 'cmd=restore', ' name="creq" '); } else { echo common::Link('Admin_Theme_Content', $langmessage['restore_defaults'], 'cmd=restore&layout=' . rawurlencode($layout), ' name="creq" '); } } else { echo $langmessage['default']; } echo '</td></tr>'; echo '</table>'; // gadgets echo '<br/>'; echo '<table class="bordered full_width">'; $gadget_info = gpOutput::WhichGadgets($this->curr_layout); echo '<tr><th style="width:40%">'; echo $langmessage['gadgets']; echo '</th><th> </th></tr>'; if (!isset($config['gadgets']) || count($config['gadgets']) == 0) { echo '<tr><td colspan="2">'; echo $langmessage['Empty']; echo '</td></tr>'; } else { foreach ($config['gadgets'] as $gadget => $temp) { echo '<tr><td>'; echo str_replace('_', ' ', $gadget); echo '</td><td>'; if (isset($gadget_info[$gadget])) { if (!isset($_GET['show'])) { echo common::Link('Admin_Theme_Content/' . rawurlencode($layout), $langmessage['remove'], 'cmd=rmgadget&gadget=' . urlencode($gadget), ' name="creq" '); } else { echo common::Link('Admin_Theme_Content', $langmessage['remove'], 'cmd=rmgadget&gadget=' . urlencode($gadget) . '&layout=' . rawurlencode($layout), ' name="creq" '); } } else { echo $langmessage['disabled']; } echo '</td></tr>'; } } echo '</table>'; //CSS options echo '<br/>'; if (!isset($_GET['show'])) { echo '<form action="' . common::GetUrl('Admin_Theme_Content/' . rawurlencode($layout)) . '" method="post">'; } else { echo '<form action="' . common::GetUrl('Admin_Theme_Content') . '" method="post">'; echo '<input type="hidden" name="layout" value="' . $layout . '" />'; } echo '<input type="hidden" name="cmd" value="css_preferences" />'; echo '<table class="bordered full_width">'; echo '<tr><th style="width:40%">CSS</th><th> </th></tr>'; echo '<tr><td>'; echo 'Name Based Menu Classes'; echo '</td><td>'; $checked = ''; if (!isset($layout_info['menu_css_ordered'])) { $checked = 'checked="checked"'; } echo '<input type="checkbox" name="menu_css_ordered" value="on" ' . $checked . ' />'; echo '</td></tr>'; echo '<tr><td>'; echo 'Ordered Menu Classes'; echo '</td><td>'; $checked = ''; if (!isset($layout_info['menu_css_indexed'])) { $checked = 'checked="checked"'; } echo '<input type="checkbox" name="menu_css_indexed" value="on" ' . $checked . ' />'; echo '</td></tr>'; echo '<tr><td>'; echo ' '; echo '</td><td>'; echo ' <input type="submit" name="" value="' . htmlspecialchars($langmessage['save']) . '" class="gpbutton" />'; echo '</td></tr>'; echo '</table>'; echo '</form>'; //affected titles $titles_count = $this->TitlesCount($layout); echo '<br/>'; echo '<table class="bordered full_width">'; echo '<tr><th colspan="2">'; echo $langmessage['titles_using_layout']; echo ': ' . $titles_count; echo '</th></tr>'; echo '<tr><td colspan="2">'; if ($titles_count > 0) { echo '<ul class="titles_using">'; foreach ($this->LayoutArray as $index => $layout_comparison) { if ($layout == $layout_comparison) { $title = common::IndexToTitle($index); if (empty($title)) { continue; //may be external link } echo "\n<li>"; $label = common::GetLabel($title); $label = common::LabelSpecialChars($label); echo common::Link($title, $label); echo '</li>'; } } echo '</ul>'; echo '<div class="clear"></div>'; } echo '</td></tr>'; echo '</table>'; }
static function RenameForm($index, $action) { global $langmessage, $page, $gp_index, $gp_titles; $label = common::GetLabelIndex($index); $title = common::IndexToTitle($index); $title_info = $gp_titles[$index]; if (empty($_REQUEST['new_title'])) { $new_title = common::LabelSpecialChars($label); } else { $new_title = htmlspecialchars($_REQUEST['new_title']); } $new_title = str_replace('_', ' ', $new_title); //show more options? $hidden_rows = false; ob_start(); echo '<div class="inline_box">'; echo '<form action="' . $action . '" method="post" id="gp_rename_form">'; echo '<input type="hidden" name="old_title" value="' . htmlspecialchars(str_replace('_', ' ', $title)) . '" />'; echo '<h2>' . $langmessage['rename/details'] . '</h2>'; echo '<input type="hidden" name="title" value="' . htmlspecialchars($title) . '" />'; echo '<table class="bordered full_width" id="gp_rename_table">'; echo '<thead>'; echo '<tr>'; echo '<th colspan="2">'; echo $langmessage['options']; echo '</th>'; echo '</tr>'; echo '</thead>'; //label echo '<tbody>'; echo '<tr><td class="formlabel">' . $langmessage['label'] . '</td>'; echo '<td><input type="text" class="title_label gpinput" name="new_label" maxlength="100" size="50" value="' . $new_title . '" />'; echo '</td></tr>'; //slug $attr = ''; $class = 'new_title'; $editable = true; if ($title == admin_tools::LabelToSlug($label)) { $attr = 'disabled="disabled" '; $class .= ' sync_label'; } echo '<tr><td class="formlabel">' . $langmessage['Slug/URL'] . '</td>'; echo '<td><input type="text" class="' . $class . ' gpinput" name="new_title" maxlength="100" size="50" value="' . htmlspecialchars($title) . '" ' . $attr . '/>'; if ($editable) { echo ' <div class="label_synchronize">'; if (empty($attr)) { echo '<a href="#">' . $langmessage['sync_with_label'] . '</a>'; echo '<a href="#" class="slug_edit nodisplay">' . $langmessage['edit'] . '</a>'; } else { echo '<a href="#" class="nodisplay">' . $langmessage['sync_with_label'] . '</a>'; echo '<a href="#" class="slug_edit">' . $langmessage['edit'] . '</a>'; } echo '</div>'; } echo '</td>'; echo '</tr>'; //browser title defaults to label $attr = ''; $class = 'browser_title'; if (isset($title_info['browser_title'])) { echo '<tr>'; $browser_title = $title_info['browser_title']; } else { echo '<tr class="nodisplay">'; $hidden_rows = true; $browser_title = $label; $attr = 'disabled="disabled" '; $class .= ' sync_label'; } echo '<td class="formlabel">'; echo $langmessage['browser_title']; echo '</td>'; echo '<td>'; echo '<input type="text" class="' . $class . ' gpinput" size="50" name="browser_title" value="' . $browser_title . '" ' . $attr . '/>'; echo ' <div class="label_synchronize">'; if (empty($attr)) { echo '<a href="#">' . $langmessage['sync_with_label'] . '</a>'; echo '<a href="#" class="slug_edit nodisplay">' . $langmessage['edit'] . '</a>'; } else { echo '<a href="#" class="nodisplay">' . $langmessage['sync_with_label'] . '</a>'; echo '<a href="#" class="slug_edit">' . $langmessage['edit'] . '</a>'; } echo '</div>'; echo '</td>'; echo '</tr>'; //meta keywords $keywords = ''; if (isset($title_info['keywords'])) { echo '<tr>'; $keywords = $title_info['keywords']; } else { echo '<tr class="nodisplay">'; $hidden_rows = true; } echo '<td class="formlabel">'; echo $langmessage['keywords']; echo '</td>'; echo '<td>'; echo '<input type="text" class="gpinput" size="50" name="keywords" value="' . $keywords . '" />'; echo '</td>'; echo '</tr>'; //meta description $description = ''; if (isset($title_info['description'])) { echo '<tr>'; $description = $title_info['description']; } else { echo '<tr class="nodisplay">'; $hidden_rows = true; } echo '<td class="formlabel">'; echo $langmessage['description']; echo '</td>'; echo '<td>'; //echo '<input type="text" class="gpinput" size="50" name="description" value="'.$description.'" />'; echo '<textarea class="gptextarea show_character_count" rows="2" cols="50" name="description">' . $description . '</textarea>'; $count_label = sprintf($langmessage['_characters'], '<span>' . strlen($description) . '</span>'); echo '<div class="character_count">' . $count_label . '</div>'; echo '</td>'; echo '</tr>'; //robots $rel = ''; if (isset($title_info['rel'])) { echo '<tr>'; $rel = $title_info['rel']; } else { echo '<tr class="nodisplay">'; $hidden_rows = true; } echo '<td class="formlabel">'; echo $langmessage['robots']; echo '</td>'; echo '<td>'; echo '<label>'; $checked = strpos($rel, 'nofollow') !== false ? 'checked="checked"' : ''; echo '<input type="checkbox" name="nofollow" value="nofollow" ' . $checked . '/> '; echo ' Nofollow '; echo '</label>'; echo '<label>'; $checked = strpos($rel, 'noindex') !== false ? 'checked="checked"' : ''; echo '<input type="checkbox" name="noindex" value="noindex" ' . $checked . '/> '; echo ' Noindex'; echo '</label>'; echo '</td>'; echo '</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 ($hidden_rows) { echo ' <a data-cmd="showmore" >+ ' . $langmessage['more_options'] . '</a>'; } echo '</p>'; echo '<p>'; echo '<input type="hidden" name="cmd" value="renameit"/> '; 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; }
function TitleSelect($default_index, $exclude = array()) { global $gp_index, $gp_titles, $langmessage; $exclude = (array) $exclude; echo '<div>'; $data = array(); foreach ($gp_index as $url => $index) { if (in_array($index, $exclude)) { continue; } $label = common::GetLabelIndex($index); $data[] = array(common::LabelSpecialChars($label), $url); } //$data = array_slice($data,107,1); echo '<span class="data" style="display:none">'; $data = json_encode($data); echo htmlspecialchars($data, ENT_NOQUOTES); echo '</span>'; $default_url = ''; if ($default_index) { $default_url = common::IndexToTitle($default_index); } echo '<span class="gpinput combobox">'; echo '<input type="text" name="title" value="' . htmlspecialchars($default_url) . '" class="combobox"/>'; echo '</span>'; echo '</div>'; }