/** * Get The Image * */ public function Child($title) { global $dirPrefix; $content = $this->TitleContent($title); $img_pos = strpos($content, '<img'); if ($img_pos === false) { return; } $src_pos = strpos($content, 'src=', $img_pos); if ($src_pos === false) { return; } $src = substr($content, $src_pos + 4); $quote = $src[0]; if ($quote != '"' && $quote != "'") { return; } $src_pos = strpos($src, $quote, 1); $src = substr($src, 1, $src_pos - 1); // check for resized image, get original source if img is resized if (strpos($src, 'image.php') !== false && strpos($src, 'img=') !== false) { $src = $dirPrefix . '/data/_uploaded/' . urldecode(substr($src, strpos($src, 'img=') + 4)); } $thumb_path = common::ThumbnailPath($src); echo '<li>'; echo '<img src="' . $thumb_path . '"/>'; $label = common::GetLabel($title); echo common::Link($title, $label); echo '</li>'; }
static function SetVars($title, $meta) { self::$title = $title; self::$label = common::GetLabel($title); self::$meta = array(); if (is_array($meta)) { self::$meta = $meta; } }
function RunScript() { global $gp_index, $langmessage, $page; $scriptinfo = special_display::GetScriptInfo($this->requested); if ($scriptinfo === false) { switch ($this->requested) { case 'Special_ExtraJS': $this->ExtraJS(); //dies } $this->Error_404($this->title); return; } $this->gp_index = $gp_index[$this->requested]; $this->label = common::GetLabel($this->requested); $this->TitleInfo = $scriptinfo; $menu_permissions = false; if (common::LoggedIn()) { $menu_permissions = admin_tools::HasPermission('Admin_Menu'); if ($menu_permissions) { $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', ' name="gpajax" '); $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), ' title="' . $langmessage['current_layout'] . '" name="gpabox"'); } if (admin_tools::HasPermission('Admin_User')) { $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), ' title="' . $langmessage['permissions'] . '" name="gpabox" '); } } //allow addons to affect page actions and how a page is displayed $cmd = common::GetCommand(); $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd)); if ($cmd !== $cmd_after) { $cmd = $cmd_after; if ($cmd === 'return') { return; } } if ($menu_permissions) { switch ($cmd) { // rename & details case 'renameform': $this->RenameForm(); return; case 'renameit': if ($this->RenameFile()) { return; } break; } } $this->contentBuffer = special_display::ExecInfo($scriptinfo); }
function SetVars() { global $gp_index, $gp_titles, $gp_menu; if (!isset($gp_index[$this->title])) { $this->Error_404($this->title); 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 = common::GetLabel($this->title); $this->file = gpFiles::PageFile($this->title); if (!$this->CheckVisibility()) { return false; } gpPlugin::Action('PageSetVars'); return true; }
/** * Get The Image * */ function Child($title) { global $dirPrefix; $file = gpFiles::PageFile($title); $file_sections = $file_stats = array(); ob_start(); require $file; ob_get_clean(); if (!is_array($file_sections)) { return; } //get the image $content = section_content::Render($file_sections, $title, $file_stats); $img_pos = strpos($content, '<img'); if ($img_pos === false) { return; } $src_pos = strpos($content, 'src=', $img_pos); if ($src_pos === false) { return; } $src = substr($content, $src_pos + 4); $quote = $src[0]; if ($quote != '"' && $quote != "'") { return; } $src_pos = strpos($src, $quote, 1); $src = substr($src, 1, $src_pos - 1); // check for resized image, get original source if img is resized if (strpos($src, 'image.php') !== false && strpos($src, 'img=') !== false) { $src = $dirPrefix . '/data/_uploaded/' . urldecode(substr($src, strpos($src, 'img=') + 4)); } $thumb_path = common::ThumbnailPath($src); $img_pos2 = strpos($content, '>', $img_pos); $img = substr($content, $img_pos, $img_pos2 - $img_pos + 1); echo '<li>'; echo '<img src="' . $thumb_path . '"/>'; //echo $img; $label = common::GetLabel($title); echo common::Link($title, $label); echo '</li>'; }
function findString(&$content, &$pattern, &$title, $link = '', $link_query = '') { $content = str_replace('>', '> ', $content); $content = strip_tags($content); $match_count = preg_match_all($pattern, $content, $matches, PREG_OFFSET_CAPTURE); if ($match_count < 1) { return; } $rating = $match_count / strlen($content); $result = '<div>'; $result .= '<b>'; $label = common::GetLabel($title); if (empty($link)) { $result .= common::Link($title, $label, $link_query); } else { $result .= common::Link($link, $label, $link_query); } $result .= '</b>'; $result .= '<p>'; $content = str_replace(array("\n", "\r", "\t"), array(' ', ' ', ' '), $content); //reduce a little bit $start = $matches[0][0][1]; //find a space at the beginning to start from $i = 0; do { $i++; $start_offset = $i * 10; $start = max(0, $start - $start_offset); $trimmed = substr($content, $start, 300); $space = strpos($trimmed, ' '); if ($space < $start_offset) { $content = substr($trimmed, $space); break; } } while ($start - $start_offset > 0); //find a space at the end if (strlen($content) > 250) { $space2 = strpos($content, ' ', $space + 220); if ($space2 > 0) { $content = substr($content, 0, $space2); } } $result .= preg_replace($pattern, '<b>\\1</b>', $content); $result .= '</p>'; $result .= '</div>'; while (isset($this->files[(string) $rating])) { $rating++; } $this->files[(string) $rating] = $result; }
/** * 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>'; }
/** * 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'; } if (!count($menu)) { //$attributes_ul['class']['empty_menu'] = 'empty_menu'; //self::FormatMenuElement('div',$attributes_ul).'</div>'; //an empty <ul> is not valid xhtml 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) { $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--; } }
/** * 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>'; }
function SearchPage($title, $index) { global $gp_menu, $gp_titles; //search hidden? if (!$this->search_hidden && !isset($gp_menu[$index])) { return; } //private pages if (!common::LoggedIn()) { if (isset($gp_titles[$index]['vis'])) { 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); }
function RenameForm($title, $action) { global $langmessage, $page, $gp_index, $gp_titles; $id = $gp_index[$title]; $label = common::GetLabel($title); $title_info = $gp_titles[$id]; 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" rows="2" cols="50" name="description">' . $description . '</textarea>'; 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 href="" name="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="menupost gpsubmit"/>'; 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 GenerateOutput() { global $langmessage, $page; common::ShowingGallery(); echo '<h2>'; echo gpOutput::ReturnText('galleries'); echo '</h2>'; includeFile('admin/admin_tools.php'); $wrap = admin_tools::CanEdit($page->gp_index); if ($wrap) { echo gpOutput::EditAreaLink($edit_index, 'Special_Galleries', $langmessage['edit'], 'cmd=edit'); echo '<div class="editable_area cf" id="ExtraEditArea' . $edit_index . '">'; // class="edit_area" added by javascript } $image_text = gpOutput::ReturnText('image'); $images_text = gpOutput::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'] . ' ' . gpOutput::ReturnText('image'); } elseif ($info['count'] > 1) { $count = $info['count'] . ' ' . gpOutput::ReturnText('images'); } } else { $icon = $info; } if (empty($icon)) { continue; } if (strpos($icon, '/thumbnails/') === false) { $thumbPath = common::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg'); } else { $thumbPath = common::GetDir('/data/_uploaded' . $icon); } $label = common::GetLabel($title); $title_attr = ' title="' . common::GetBrowserTitle($title) . '"'; $label_img = ' <img src="' . $thumbPath . '" alt=""/>'; $list .= '<li>' . common::Link($title, $label_img, '', $title_attr) . '<div>' . common::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(); }
/** * Return javascript code to be used with autocomplete (jquery ui) * */ static function AutoCompleteValues($GetUrl = true, $options = array()) { global $gp_index; $options += array('admin_vals' => true, 'var_name' => 'gptitles'); //internal link array $array = array(); foreach ($gp_index as $slug => $id) { $label = common::GetLabel($slug); $label = str_replace(array('<', '>', '"', ''', '&'), array('<', '>', '"', "'", '&'), $label); if ($GetUrl) { $slug = common::GetUrl($slug, '', false); $slug = rawurldecode($slug); } $array[] = array($label, $slug); } if ($options['admin_vals'] && class_exists('admin_tools')) { $scripts = admin_tools::AdminScripts(); foreach ($scripts as $url => $info) { if ($GetUrl) { $url = common::GetUrl($url, '', false); $url = rawurldecode($url); } $array[] = array($info['label'], $url); } } $code = json_encode($array); if ($options['var_name']) { $code = 'var ' . $options['var_name'] . ' = ' . $code . ';'; } return $code; }
/** * Output a navigation menu * @static */ function OutputMenu($menu, $start_level, $source_menu = false) { global $page, $GP_MENU_LINKS, $GP_MENU_CLASS, $gp_menu, $gp_titles; if ($source_menu === false) { $source_menu =& $gp_menu; } $search = array('{$href_text}', '{$attr}', '{$label}', '{$title}'); $replace = array(); if (count($menu) == 0) { echo '<div class="emtpy_menu"></div>'; //an empty <ul> is not valid xhtml gpOutput::ResetMenuGlobals(); return; } //$GP_MENU_LINKS = '<a href="{$href_text}" {$attr}><span class="sub-t">{$label}</span></a>'; //<a href="/rocky/index.php/Misson_&_Principles" title="Misson & Principles" >Misson & Principles</a> $link_format = '<a href="{$href_text}" title="{$title}"{$attr}>{$label}</a>'; if (!empty($GP_MENU_LINKS)) { $link_format = $GP_MENU_LINKS; } $result = array(); $prev_level = $start_level; $page_title_full = common::GetUrl($page->title); $source_keys = array_keys($source_menu); $source_values = array_values($source_menu); $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]; } $class = 'menu_top'; if (!empty($GP_MENU_CLASS)) { $class = $GP_MENU_CLASS; } $result[] = '<ul class="' . $class . '">'; foreach ($source_keys as $source_index => $menu_key) { $attr = $class = $attr_li = $class_li = ''; $menu_info = $source_values[$source_index]; $this_level = $menu_info['level']; //the next entry $next_info = false; if (isset($source_values[$source_index + 1])) { $next_info = $source_values[$source_index + 1]; } //create link if in $menu if (isset($menu[$menu_key])) { //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]++; } $class_li = 'li_' . $li_count[$this_level]; } if ($page->menu_css_indexed) { $class_li .= ' li_title_' . $menu_key; } //selected classes if ($this_level < $next_info['level']) { $class .= ' haschildren'; } if (isset($menu_info['url']) && ($menu_info['url'] == $page->title || $menu_info['url'] == $page_title_full)) { $class .= ' selected'; $class_li .= ' selected_li'; } elseif ($menu_key == $page->gp_index) { $class .= ' selected'; $class_li .= ' selected_li'; } elseif (in_array($menu_key, $parents)) { $class .= ' childselected'; $class_li .= ' childselected_li'; } if (!empty($class)) { $attr = ' class="' . trim($class) . '"'; } if (!empty($class_li)) { $attr_li = ' class="' . trim($class_li) . '"'; } //current is a child of the previous if ($this_level > $prev_level) { if (!$open) { $result[] = '<li' . $attr_li . '>'; //only needed if the menu starts below the start_level } while ($this_level > $prev_level) { $result[] = '<ul>'; $result[] = '<li>'; $prev_level++; } array_pop($result); //remove the last <li> //current is higher than the previous } elseif ($this_level < $prev_level) { while ($this_level < $prev_level) { $result[] = '</li>'; $result[] = '</ul>'; $prev_level--; } if ($open) { $result[] = '</li>'; } } elseif ($open) { $result[] = '</li>'; } $replace = array(); //external if (isset($menu_info['url'])) { if (empty($menu_info['title_attr'])) { $menu_info['title_attr'] = strip_tags($menu_info['label']); } if (isset($menu_info['new_win'])) { $attr .= ' target="_blank"'; } $replace[] = $menu_info['url']; $replace[] = $attr; $replace[] = $menu_info['label']; $replace[] = $menu_info['title_attr']; //internal link } else { if (!empty($gp_titles[$menu_key]['rel'])) { $attr .= ' rel="' . $gp_titles[$menu_key]['rel'] . '"'; } $title = common::IndexToTitle($menu_key); $replace[] = common::GetUrl($title); $replace[] = $attr; $replace[] = common::GetLabel($title); $replace[] = common::GetBrowserTitle($title); } $result[] = '<li' . $attr_li . '>' . str_replace($search, $replace, $link_format); $prev_level = $this_level; $open = true; } } while ($start_level <= $prev_level) { $result[] = '</li>'; $result[] = '</ul>'; $prev_level--; } //$test = implode("\n",$result); //$test = htmlspecialchars($test); //echo nl2br($test); //echo '<hr/>'; echo implode('', $result); //don't separate by spaces so css inline can be more functional gpOutput::ResetMenuGlobals(); return; }
function GetAbrev($content, $title, $abrv = 100) { $label = common::GetLabel($title); $content = strip_tags($content); $var = 1; //$content = str_replace($label,"",$content,$var) ; $haystack = $content; $needle = $label; $replace = ""; $pos = strpos($haystack, $needle); if ($pos !== false) { $newstring = substr_replace($haystack, $replace, $pos, strlen($needle)); } if (isset($newstring)) { $content = $newstring; } if (mb_strlen($content) < $abrv) { return $content; } $pos = mb_strpos($content, ' ', $abrv - 5); if ($pos > 0 && $abrv + 20 > $pos) { $abrv = $pos; } $content = mb_substr($content, 0, $abrv); return $content . "..."; }
/** * 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>'; } }
/** * Get the browser title for a page * @param string $title * */ static function GetBrowserTitle($title) { global $gp_titles, $gp_index; if (!isset($gp_index[$title])) { return false; } $index = $gp_index[$title]; $title_info = $gp_titles[$index]; if (isset($title_info['browser_title'])) { return $title_info['browser_title']; } $label = common::GetLabel($title); return strip_tags($label); }