本文整理汇总了PHP中common::GetLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP common::GetLabel方法的具体用法?PHP common::GetLabel怎么用?PHP common::GetLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common
的用法示例。
在下文中一共展示了common::GetLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Child
/**
* 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>';
}
示例2: SetVars
static function SetVars($title, $meta)
{
self::$title = $title;
self::$label = common::GetLabel($title);
self::$meta = array();
if (is_array($meta)) {
self::$meta = $meta;
}
}
示例3: RunScript
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);
}
示例4: SetVars
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;
}
示例5: Child
/**
* 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>';
}
示例6: findString
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;
}
示例7: CopyForm
/**
* 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>';
}
示例8: OutputMenu
//.........这里部分代码省略.........
}
$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--;
}
}
示例9: ShowDetails
//.........这里部分代码省略.........
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>';
}
示例10: SearchPage
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);
}
示例11: RenameForm
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>';
//.........这里部分代码省略.........
示例12: GenerateOutput
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();
}
示例13: AutoCompleteValues
/**
* 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;
}
示例14: OutputMenu
//.........这里部分代码省略.........
}
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;
}
示例15: GetAbrev
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 . "...";
}