示例#1
0
文件: page.php 项目: buyvolov/cms
function mso_page_nav($page_id = 0, $page_id_parent = 0, $echo = false)
{
    $r = mso_page_map($page_id, $page_id_parent);
    // построение карты страниц
    $r = mso_create_list($r);
    // создание ul-списка
    if ($echo) {
        echo $r;
    } else {
        return $r;
    }
}
示例#2
0
文件: index.php 项目: Kmartynov/cms
function category_widget_custom($options = array(), $num = 1)
{
    if (!isset($options['include'])) {
        $options['include'] = array();
    }
    if (!isset($options['exclude'])) {
        $options['exclude'] = array();
    }
    if (!isset($options['format'])) {
        $options['format'] = '[LINK][TITLE]<sup>[COUNT]</sup>[/LINK]<br>[DESCR]';
    }
    if (!isset($options['format_current'])) {
        $options['format_current'] = '<span>[TITLE]<sup>[COUNT]</sup></span><br>[DESCR]';
    }
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    if (!isset($options['hide_empty'])) {
        $options['hide_empty'] = 0;
    }
    if (!isset($options['order'])) {
        $options['order'] = 'category_name';
    }
    if (!isset($options['order_asc'])) {
        $options['order_asc'] = 'ASC';
    }
    if (!isset($options['include_child'])) {
        $options['include_child'] = 0;
    }
    if (!isset($options['nofollow'])) {
        $options['nofollow'] = false;
    }
    if (!isset($options['group_header_no_link'])) {
        $options['group_header_no_link'] = false;
    }
    $cache_key = 'category_widget' . serialize($options) . $num;
    $k = mso_get_cache($cache_key);
    if ($k) {
        $all = $k;
    } else {
        /*
        	$type = 'page', 
        	$parent_id = 0, 
        	$order = 'category_menu_order', 
        	$asc = 'asc', 
        	$child_order = 'category_menu_order', 
        	$child_asc = 'asc', 
        	$in = false, 
        	$ex = false, 
        	$in_child = false, 
        	$hide_empty = false, 
        	$only_page_publish = false, 
        	$date_now = true, 
        	$get_pages = true
        */
        $all = mso_cat_array('page', 0, $options['order'], $options['order_asc'], $options['order'], $options['order_asc'], $options['include'], $options['exclude'], $options['include_child'], $options['hide_empty'], true, true, false);
        mso_add_cache($cache_key, $all);
        // сразу в кэш добавим
    }
    // pr($all);
    $out = mso_create_list($all, array('childs' => 'childs', 'format' => $options['format'], 'format_current' => $options['format_current'], 'class_ul' => 'mso-widget-list', 'title' => 'category_name', 'link' => 'category_slug', 'current_id' => false, 'prefix' => 'category/', 'count' => 'pages_count', 'slug' => 'category_slug', 'id' => 'category_id', 'menu_order' => 'category_menu_order', 'id_parent' => 'category_id_parent', 'nofollow' => $options['nofollow'], 'group_header_no_link' => $options['group_header_no_link']));
    if ($out and $options['header']) {
        $out = $options['header'] . $out;
    }
    return $out;
}
示例#3
0
文件: admin.php 项目: rb2/MaxSite-CMS
	<td><textarea title="' . t('Название') . '" name="f_category_name[[ID]]">[TITLE_HTML]</textarea></td>
	
	<td><textarea title="' . t('Описание') . '" name="f_category_desc[[ID]]">[DESCR_HTML]</textarea></td>
	
	<td><input title="' . t('Короткая ссылка') . '" name="f_category_slug[[ID]]" value="[SLUG_HTML]" maxlength="500" type="text"><div style="text-align: right;"><a href="' . getinfo('siteurl') . 'category/[SLUG_HTML]" target="_blank" title="' . t('Смотреть рубрику на сайте') . '">»»»</a></div></td>
	
	<td><input title="' . t('Порядок') . '" name="f_category_menu_order[[ID]]" value="[MENU_ORDER]" maxlength="500" type="text"></td>
	
	<td><input type="submit" name="f_edit_submit[[ID]]" value="' . t('Изменить') . '">
	
	<br><input type="submit" name="f_delete_submit[[ID]]" value="' . t('Удалить') . '" onClick="if(confirm(\'' . t('Удалить рубрику?') . '\')) {return true;} else {return false;}" ></td>
	
	</tr></table>
	
	';
$out = mso_create_list($all, array('childs' => 'childs', 'format' => $format, 'format_current' => $format, 'class_ul' => '', 'class_ul_style' => 'list-style-type: none; margin: 0;', 'class_child_style' => 'list-style-type: none;', 'class_li_style' => 'margin: 5px 0;', 'title' => 'category_name', 'link' => 'category_slug', 'current_id' => false, 'prefix' => 'category/', 'count' => 'pages_count', 'id' => 'category_id', 'slug' => 'category_slug', 'menu_order' => 'category_menu_order', 'id_parent' => 'category_id_parent'));
// добавляем форму, а также текущую сессию
echo '<form method="post" class="fform">' . mso_form_session('f_session_id') . '<table class="page cats">
			<colgroup style="width: 30px">
			<colgroup style="width: 50px">
			<colgroup style="width: 200px">
			<colgroup>
			<colgroup style="width: 150px">
			<colgroup style="width: 50px">
			<colgroup style="width: 80px">
			<tr>
			<th>ID</th>
			<th>' . t('Род.') . '</th>
			<th>' . t('Название') . '</th>
			<th>' . t('Описание') . '</th>
			<th>' . t('Ссылка') . '</th>
示例#4
0
文件: index.php 项目: Kmartynov/cms
function page_parent_widget_custom($options = array(), $num = 1)
{
    // кэш не нужен, потому что mso_page_map сама всё кэширует
    $out = '';
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    if (!isset($options['page_id'])) {
        $options['page_id'] = 0;
    }
    if (!$options['page_id']) {
        return '';
    }
    $r = mso_page_map($options['page_id']);
    // построение карты страниц
    // создание ul-списка со своими опциями
    $out = mso_create_list($r, array('format_current' => '[LINK][TITLE][/LINK]', 'class_ul' => 'mso-widget-list mso-page-parent', 'class_child' => 'mso-widget-list mso-page-parent-child', 'current_id' => false));
    if ($out and $options['header']) {
        $out = $options['header'] . $out;
    }
    return $out;
}
示例#5
0
文件: common.php 项目: rettebinu/cms
function mso_create_list($a = array(), $options = array(), $child = false)
{
    if (!$a) {
        return '';
    }
    if (!isset($options['class_ul'])) {
        $options['class_ul'] = '';
    }
    // класс UL
    if (!isset($options['class_ul_style'])) {
        $options['class_ul_style'] = '';
    }
    // свой стиль для UL
    if (!isset($options['class_child'])) {
        $options['class_child'] = 'child';
    }
    // класс для ребенка
    if (!isset($options['class_child_style'])) {
        $options['class_child_style'] = '';
    }
    // свой стиль для ребенка
    if (!isset($options['class_current'])) {
        $options['class_current'] = 'current-page';
    }
    // класс li текущей страницы
    if (!isset($options['class_current_style'])) {
        $options['class_current_style'] = '';
    }
    // стиль li текущей страницы
    if (!isset($options['class_li'])) {
        $options['class_li'] = '';
    }
    // класс LI
    if (!isset($options['class_li_style'])) {
        $options['class_li_style'] = '';
    }
    // стиль LI
    if (!isset($options['format'])) {
        $options['format'] = '[LINK][TITLE][/LINK]';
    }
    // формат ссылки
    if (!isset($options['format_current'])) {
        $options['format_current'] = '<span>[TITLE]</span>';
    }
    // формат для текущей
    if (!isset($options['title'])) {
        $options['title'] = 'page_title';
    }
    // имя ключа для титула
    if (!isset($options['link'])) {
        $options['link'] = 'page_slug';
    }
    // имя ключа для слага
    if (!isset($options['descr'])) {
        $options['descr'] = 'category_desc';
    }
    // имя ключа для описания
    if (!isset($options['id'])) {
        $options['id'] = 'page_id';
    }
    // имя ключа для id
    if (!isset($options['slug'])) {
        $options['slug'] = 'page_slug';
    }
    // имя ключа для slug
    if (!isset($options['menu_order'])) {
        $options['menu_order'] = 'page_menu_order';
    }
    // имя ключа для menu_order
    if (!isset($options['id_parent'])) {
        $options['id_parent'] = 'page_id_parent';
    }
    // имя ключа для id_parent
    if (!isset($options['count'])) {
        $options['count'] = 'count';
    }
    // имя ключа для количества элементов
    if (!isset($options['prefix'])) {
        $options['prefix'] = 'page/';
    }
    // префикс для ссылки
    if (!isset($options['current_id'])) {
        $options['current_id'] = true;
    }
    // текущая страница отмечается по page_id - иначе по текущему url
    if (!isset($options['childs'])) {
        $options['childs'] = 'childs';
    }
    // поле для массива детей
    // если true, то главная рабрика выводится без ссылки в <span>
    if (!isset($options['group_header_no_link'])) {
        $options['group_header_no_link'] = false;
    }
    # функция, которая сработает на [FUNCTION]
    # эта функция получает в качестве параметра текущий массив $elem
    if (!isset($options['function'])) {
        $options['function'] = false;
    }
    if (!isset($options['nofollow']) or !$options['nofollow']) {
        $options['nofollow'] = '';
    } else {
        $options['nofollow'] = ' rel="nofollow"';
    }
    $class_child = $class_child_style = $class_ul = $class_ul_style = '';
    $class_current = $class_current_style = $class_li = $class_li_style = '';
    // [LEVEL] - заменяется на level-текущий уровень вложенности
    if ($options['class_child']) {
        $class_child = ' class="' . $options['class_child'] . ' [LEVEL]"';
    }
    static $level = 0;
    $class_child = str_replace('[LEVEL]', 'level' . $level, $class_child);
    if ($options['class_child_style']) {
        $class_child_style = ' style="' . $options['class_child_style'] . '"';
    }
    if ($options['class_ul']) {
        $class_ul = ' class="' . $options['class_ul'] . '"';
    }
    if ($options['class_ul_style']) {
        $class_ul_style = ' style="' . $options['class_ul_style'] . '"';
    }
    if ($options['class_current']) {
        $class_current = ' class="' . $options['class_current'] . '"';
    }
    if ($options['class_current_style']) {
        $class_current_style = ' style="' . $options['class_current_style'] . '"';
    }
    if ($options['class_li']) {
        $class_li = ' class="' . $options['class_li'] . ' group"';
    } else {
        $class_li = ' class="group"';
    }
    if ($options['class_li_style']) {
        $class_li_style = ' style="' . $options['class_li_style'] . '"';
    }
    if ($child) {
        $out = NR . '	<ul' . $class_child . $class_child_style . '>';
    } else {
        $out = NR . '<ul' . $class_ul . $class_ul_style . '>';
    }
    $current_url = getinfo('siteurl') . mso_current_url();
    // текущий урл
    // из текущего адресу нужно убрать пагинацию
    $current_url = str_replace('/next/' . mso_current_paged(), '', $current_url);
    foreach ($a as $elem) {
        $title = $elem[$options['title']];
        $elem_slug = mso_strip($elem[$options['link']]);
        // slug элемента
        $url = getinfo('siteurl') . $options['prefix'] . $elem_slug;
        // если это page, то нужно проверить вхождение этой записи в элемент рубрики
        // если есть, то ставим css-класс curent-page-cat
        $curent_page_cat_class = is_page_cat($elem_slug, false, false) ? ' class="curent-page-cat"' : '';
        $link = '<a' . $options['nofollow'] . ' href="' . $url . '" title="' . htmlspecialchars($title) . '"' . $curent_page_cat_class . '>';
        if (isset($elem[$options['descr']])) {
            $descr = $elem[$options['descr']];
        } else {
            $descr = '';
        }
        if (isset($elem[$options['count']])) {
            $count = $elem[$options['count']];
        } else {
            $count = '';
        }
        if (isset($elem[$options['id']])) {
            $id = $elem[$options['id']];
        } else {
            $id = '';
        }
        if (isset($elem[$options['slug']])) {
            $slug = $elem[$options['slug']];
        } else {
            $slug = '';
        }
        if (isset($elem[$options['menu_order']])) {
            $menu_order = $elem[$options['menu_order']];
        } else {
            $menu_order = '';
        }
        if (isset($elem[$options['id_parent']])) {
            $id_parent = $elem[$options['id_parent']];
        } else {
            $id_parent = '';
        }
        $cur = false;
        if ($options['current_id']) {
            if (isset($elem['current'])) {
                $e = $options['format_current'];
                $cur = true;
            } else {
                $e = $options['format'];
            }
        } else {
            if ($url == $current_url) {
                $e = $options['format_current'];
                $cur = true;
            } else {
                $e = $options['format'];
            }
        }
        $e = str_replace('[LINK]', $link, $e);
        $e = str_replace('[/LINK]', '</a>', $e);
        $e = str_replace('[TITLE]', $title, $e);
        $e = str_replace('[TITLE_HTML]', htmlspecialchars($title), $e);
        $e = str_replace('[DESCR]', $descr, $e);
        $e = str_replace('[DESCR_HTML]', htmlspecialchars($descr), $e);
        $e = str_replace('[ID]', $id, $e);
        $e = str_replace('[SLUG]', $slug, $e);
        $e = str_replace('[SLUG_HTML]', htmlspecialchars($slug), $e);
        $e = str_replace('[MENU_ORDER]', $menu_order, $e);
        $e = str_replace('[ID_PARENT]', $id_parent, $e);
        $e = str_replace('[COUNT]', $count, $e);
        $e = str_replace('[URL]', $url, $e);
        if ($options['function'] and function_exists($options['function'])) {
            $function = $options['function']($elem);
            $e = str_replace('[FUNCTION]', $function, $e);
        } else {
            $e = str_replace('[FUNCTION]', '', $e);
        }
        if (isset($elem[$options['childs']])) {
            if ($cur) {
                $out .= NR . '<li' . $class_current . $class_current_style . '>' . $e;
            } else {
                if ($options['group_header_no_link']) {
                    $out .= NR . '<li' . $class_li . $class_li_style . '><span class="group_header">' . $title . '</span>';
                } else {
                    $out .= NR . '<li' . $class_li . $class_li_style . '>' . $e;
                }
            }
            ++$level;
            $out .= mso_create_list($elem[$options['childs']], $options, true);
            --$level;
            $out .= NR . '</li>';
        } else {
            if ($child) {
                $out .= NR . '	';
            } else {
                $out .= NR;
            }
            // если нет детей, то уберем класс group
            $class_li_1 = str_replace('group', '', $class_li);
            if ($cur) {
                $out .= '<li' . $class_current . $class_current_style . '>' . $e . '</li>';
            } else {
                $out .= '<li' . $class_li_1 . $class_li_style . '>' . $e . '</li>';
            }
        }
    }
    if ($child) {
        $out .= NR . '	</ul>' . NR;
    } else {
        $out .= NR . '</ul>' . NR;
    }
    $out = str_replace('<li class="">', '<li>', $out);
    return $out;
}
示例#6
0
文件: index.php 项目: rb2/MaxSite-CMS
function sitemap_cat($arg = '')
{
    $cache_key = 'sitemap_cat';
    $k = mso_get_cache($cache_key);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    $out = '';
    $out .= '<div class="page_content sitemap">' . NR . mso_hook('sitemap_do');
    $out .= '<div class="sitemap-link"><a href="' . getinfo('siteurl') . 'sitemap">' . tf('Группировка по датам') . '</a>' . NR . '</div>';
    $all = mso_cat_array('page', 0, 'category_menu_order', 'asc', 'category_name', 'asc', array(), array(), 0, 0, true);
    $out .= mso_create_list($all, array('function' => '_sitemap_cat_elem', 'childs' => 'childs', 'format' => '<h3>[TITLE_HTML]</h3><p><em>[DESCR_HTML]</em></p>[FUNCTION]', 'format_current' => '', 'class_ul' => '', 'title' => 'category_name', 'link' => 'category_slug', 'current_id' => false, 'prefix' => 'category/', 'count' => 'pages_count', 'slug' => 'category_slug', 'id' => 'category_id', 'menu_order' => 'category_menu_order', 'id_parent' => 'category_id_parent'));
    $out .= NR . mso_hook('sitemap_posle') . '</div>' . NR;
    mso_add_cache($cache_key, $out);
    // сразу в кэш добавим
    return $out;
}