function mso_remote_f_getcategorylist($post) { $out = ''; require_once getinfo('common_dir') . 'category.php'; // функции рубрик $pages = mso_cat_array('page', 0); $out = mso_cat_ul('%ID% %NAME%', true, array(), array()); $out = str_replace('</li>', '', $out); $out = str_replace('</ul>', '', $out); $out = str_replace('<ul>', '', $out); $out = str_replace('<ul class="child">', '', $out); $out = str_replace('<ul class="category">', '', $out); $out = str_replace("\t", '', $out); $out = str_replace("\n\n", "\n", $out); $out = str_replace("\n\n", "\n", $out); $out = str_replace(" ", " ", $out); $out = str_replace('<li class="', '', $out); $out = str_replace('">', ' ', $out); $out = str_replace('count', '', $out); $out = str_replace('level', '', $out); return trim($out); }
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; }
function mso_cat($li_format = '%NAME%', $checked_id = array(), $type = 'page', $parent_id = 0, $order = 'category_menu_order', $asc = 'asc', $child_order = 'category_menu_order', $child_asc = 'asc') { // возможно, что этот список уже сформирован, поэтому посмотрим в кэше $cache_key = mso_md5('mso_cat' . $li_format . $type . $parent_id . $order . $asc . $child_order . $child_asc . implode(' ', $checked_id)); $k = mso_get_cache($cache_key); if ($k) { return $k; } // да есть в кэше // массив всех рубрик с учетом воложенности в виде массива $r = mso_cat_array($type, $parent_id, $order, $asc, $child_order, $child_asc); $list = "\n"; foreach ($r as $key => $row) { $add = $li_format; $add = str_replace('%NAME%', $row['category_name'], $add); $add = str_replace('%ID%', $row['category_id'], $add); $add = str_replace('%DESC%', $row['category_desc'], $add); // если нужно отмечать какие-то id if ($checked_id) { // %CHECKED% if (in_array($row['category_id'], $checked_id)) { $add = str_replace('%CHECKED%', ' checked="checked" ', $add); } else { $add = str_replace('%CHECKED%', '', $add); } } else { $add = str_replace('%CHECKED%', '', $add); } $list .= '<ul class="category">' . "\n" . '<li>' . $add; if (isset($row['childs'])) { $ch = _get_child2($row['childs'], $li_format, $checked_id); // возвращает индексы чилдевского массива $list .= "\n" . '<ul class="child">' . "\n" . '' . $ch . '' . "\n" . '</ul>'; } $list .= "\n" . '</li>' . "\n" . '</ul>' . "\n"; } mso_add_cache($cache_key, $list); // сразу в кэш добавим return $list; }
} else { echo '<div class="error">' . t('Ошибка удаления') . ' ' . $result['description'] . '</div>'; } } ?> <h1><?php echo t('Рубрики'); ?> </h1> <p class="info"><?php echo t('Настройка рубрик'); ?> </p> <?php $all = mso_cat_array('page', 0, 'category_menu_order', 'asc', 'category_menu_order', 'asc', false, false, false, false, false, false, false); $format = ' <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> <td class="alt"><strong title="' . t('Номер рубрики. Записей в этой рубрике: [COUNT]') . '">[ID]</strong><sub><a href="' . getinfo('site_admin_url') . 'page/category/[ID]">[COUNT]</a></sub></td>
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; }