function xml_sitemap_custom($args = array()) { /* Настройки по-умолчанию */ $options = mso_get_option('plugin_xml_sitemap', 'plugins', array()); if (!isset($options['page_hide'])) { $options['page_hide'] = ''; } $options['page_hide'] = mso_explode($options['page_hide']); if (!isset($options['page_cats_hide'])) { $options['page_cats_hide'] = ''; } $options['page_cats_hide'] = mso_explode($options['page_cats_hide']); if (!isset($options['categories_show'])) { $options['categories_show'] = ''; } $options['categories_show'] = mso_explode($options['categories_show']); if (!isset($options['tags_show'])) { $options['tags_show'] = true; } if (!isset($options['comusers_show'])) { $options['comusers_show'] = true; } if (!isset($options['users_show'])) { $options['users_show'] = true; } if (!isset($options['freq_priority'])) { $options['freq_priority'] = 'home | daily | 1 ' . NR . 'notblog | monthly | 0.7 ' . NR . 'blog | weekly | 0.5 ' . NR . 'category | weekly | 0.3 ' . NR . 'tag | weekly | 0.3 ' . NR . 'comuser | weekly | 0.3 ' . NR . 'user | weekly | 0.3 '; } $fp = explode(NR, trim($options['freq_priority'])); $options['freq_priority'] = array(); foreach ($fp as $ln) { $params = array_map('trim', explode('|', trim($ln))); $options['freq_priority'][$params[0]] = array('changefreq' => $params[1], 'priority' => $params[2]); } // создание sitemap.xml // $t = "\t"; // табулятор для отступа $t = ''; // отступ для красоты $CI =& get_instance(); $CI->load->helper('file'); // хелпер для работы с файлами // временная зона сайта в формат +03:00 из 3.00 $time_zone = getinfo('time_zone'); // 3.00 -11.00; $znak = (int) $time_zone >= 0 ? '+' : '-'; $time_zone = abs($time_zone); if ($time_zone == 0) { $time_zone = '0.0'; } $time_zone = trim(str_replace('.', ' ', $time_zone)); $time_z = explode(' ', $time_zone); if (!isset($time_z[0])) { $time_z[0] = '0'; } if (!isset($time_z[1])) { $time_z[1] = '0'; } if ($time_z[0] < 10) { $time_z[0] = '0' . $time_z[0]; } if ($time_z[1] < 10) { $time_z[1] = '0' . $time_z[1]; } $time_zone = $znak . $time_z[0] . ':' . $time_z[1]; $url = getinfo('siteurl'); $out = '<' . '?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>' . $url . '</loc> <lastmod>' . date('Y-m-d') . 'T' . date('H:i:s') . $time_zone . '</lastmod> <changefreq>' . $options['freq_priority']['home']['changefreq'] . '</changefreq> <priority>' . $options['freq_priority']['home']['priority'] . '</priority> </url> '; // временная зона для запросов с page_date_publish $tz = getinfo('time_zone'); if ($tz < 10 and $tz > 0) { $tz = '0' . $tz; } elseif ($tz > -10 and $tz < 0) { $tz = '0' . $time_zone; $tz = str_replace('0-', '-0', $time_zone); } else { $tz = '00.00'; } $tz = str_replace('.', ':', $tz); // страницы не blog $CI->db->select('page.page_id, page_slug, page_date_publish'); if (count($options['page_cats_hide']) > 0) { $CI->db->join('cat2obj', 'cat2obj.page_id = page.page_id', 'left'); $CI->db->where_not_in('category_id', $options['page_cats_hide']); } if (count($options['page_hide']) > 0) { $CI->db->where_not_in('page.page_id', $options['page_hide']); } $CI->db->where('page_type_name !=', 'blog'); $CI->db->where('page_status', 'publish'); $CI->db->where('page_date_publish < ', 'DATE_ADD(NOW(), INTERVAL "' . $tz . '" HOUR_MINUTE)', false); //$CI->db->where('page_date_publish <', mso_date_convert('Y-m-d H:i:s', date('Y-m-d H:i:s'))); $CI->db->join('page_type', 'page_type.page_type_id = page.page_type_id', 'left'); $CI->db->order_by('page_date_publish', 'desc'); $CI->db->group_by('page.page_id'); $query = $CI->db->get('page'); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $date = str_replace(' ', 'T', $row['page_date_publish']) . $time_zone; $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'page/' . $row['page_slug'] . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['notblog']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['notblog']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } // страницы $CI->db->select('page.page_id, page_slug, page_date_publish'); if (count($options['page_cats_hide']) > 0) { $CI->db->join('cat2obj', 'cat2obj.page_id = page.page_id', 'left'); $CI->db->where_not_in('category_id', $options['page_cats_hide']); } if (count($options['page_hide']) > 0) { $CI->db->where_not_in('page.page_id', $options['page_hide']); } $CI->db->where('page_type_name', 'blog'); $CI->db->where('page_status', 'publish'); $CI->db->where('page_date_publish < ', 'DATE_ADD(NOW(), INTERVAL "' . $tz . '" HOUR_MINUTE)', false); $CI->db->join('page_type', 'page_type.page_type_id = page.page_type_id', 'left'); $CI->db->group_by('page.page_id'); $CI->db->order_by('page_date_publish', 'desc'); $query = $CI->db->get('page'); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $date = str_replace(' ', 'T', $row['page_date_publish']) . $time_zone; $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'page/' . $row['page_slug'] . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['blog']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['blog']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } // рубрики if (count($options['categories_show']) > 0) { $CI->db->or_where_in('category_id', $options['categories_show']); } $CI->db->where('category_type', 'page'); $query = $CI->db->get('category'); if ($query->num_rows() > 0) { $date = date('Y-m-d') . 'T' . date('H:i:s') . $time_zone; foreach ($query->result_array() as $row) { // $date = str_replace(' ', 'T', date('Y-m-d')) . $time_zone; $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'category/' . $row['category_slug'] . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['category']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['category']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } // все метки if ($options['tags_show']) { require_once getinfo('common_dir') . 'meta.php'; $alltags = mso_get_all_tags_page(); foreach ($alltags as $tag => $count) { $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'tag/' . htmlentities(urlencode($tag)) . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['tag']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['tag']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } // и все комюзеры if ($options['comusers_show']) { $CI->db->select('comusers_id'); $query = $CI->db->get('comusers'); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'users/' . $row['comusers_id'] . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['comuser']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['comuser']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } } // и все юзеры if ($options['users_show']) { $CI->db->select('users_id'); $query = $CI->db->get('users'); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $out .= $t . '<url>' . NR; $out .= $t . $t . '<loc>' . $url . 'author/' . $row['users_id'] . '</loc>' . NR; $out .= $t . $t . '<lastmod>' . $date . '</lastmod>' . NR; $out .= $t . $t . '<changefreq>' . $options['freq_priority']['user']['changefreq'] . '</changefreq>' . NR; $out .= $t . $t . '<priority>' . $options['freq_priority']['user']['priority'] . '</priority>' . NR; $out .= $t . '</url>' . NR; } } } $out .= mso_hook('xml_sitemap'); # хук, если нужно добавить свои данные $out .= NR . '</urlset>' . NR; $fn = getinfo('FCPATH') . 'sitemap.xml'; write_file($fn, $out); return $args; // для обеспечения цепочки хуков }
function mso_remote_f_gettags($post) { require_once getinfo('common_dir') . 'meta.php'; $out = ''; if ($post['remote_format_out'] == 'xml') { $out .= '<' . '?xml version="1.0" encoding="UTF-8"?' . '>'; } if ($post['remote_format_out'] == 'xml') { $out .= NR . '<tags>'; } $all_tags = mso_get_all_tags_page(); if ($all_tags) { foreach ($all_tags as $tag_name => $tag_count) { if ($post['remote_format_out'] == 'xml') { $out .= NR . '<tag count="' . $tag_count . '">' . $tag_name . '</tag>'; } else { $out .= NR . 'tag=' . $tag_count . ' ' . $tag_name; } } } if ($post['remote_format_out'] == 'xml') { $out .= '</tags>'; } return trim($out); }
function tagclouds3d_widget_custom($options = array(), $num = 1) { // кэш $cache_key = 'tagclouds3d_widget_custom' . serialize($options) . $num; $k = mso_get_cache($cache_key); if ($k) { return $k; } // да есть в кэше // формат вывода %SIZE% %URL% %TAG% %COUNT% // параметры $min_size $max_size $block_start $block_end // сортировка if (!isset($options['header'])) { $options['header'] = ''; } if (!isset($options['block_start'])) { $options['block_start'] = '<div class="tagclouds3d">'; } if (!isset($options['block_end'])) { $options['block_end'] = '</div>'; } if (!isset($options['min_size'])) { $min_size = 90; } else { $min_size = (int) $options['min_size']; } if (!isset($options['max_size'])) { $max_size = 230; } else { $max_size = (int) $options['max_size']; } if (!isset($options['max_num'])) { $max_num = 50; } else { $max_num = (int) $options['max_num']; } if (!isset($options['min_count'])) { $min_count = 0; } else { $min_count = (int) $options['min_count']; } if (!isset($options['width'])) { $width = 150; } else { $width = (int) $options['width']; } if (!isset($options['height'])) { $height = 150; } else { $height = (int) $options['height']; } if (!isset($options['speed'])) { $speed = 220; } else { $speed = (int) $options['speed']; } /* === */ if (!isset($options['bgcolor'])) { $bgcolor = 'FFFFFF'; } else { $bgcolor = $options['bgcolor']; } if (!isset($options['text_color'])) { $text_color = '000000'; } else { $text_color = $options['text_color']; } if (!isset($options['text_color2'])) { $text_color2 = 'CCCCCC'; } else { $text_color2 = $options['text_color2']; } if (!isset($options['hover_color'])) { $hover_color = '999999'; } else { $hover_color = $options['hover_color']; } /* === */ if (!isset($options['sort'])) { $sort = 0; } else { $sort = (int) $options['sort']; } require_once getinfo('common_dir') . 'meta.php'; // функции мета $tagcloud = mso_get_all_tags_page(); asort($tagcloud); $min = reset($tagcloud); $max = end($tagcloud); if ($max == $min) { $max++; } // сортировка перед выводом if ($sort == 0) { arsort($tagcloud); } elseif ($sort == 1) { asort($tagcloud); } elseif ($sort == 2) { ksort($tagcloud); } elseif ($sort == 3) { krsort($tagcloud); } else { arsort($tagcloud); } // по умолчанию $url = getinfo('siteurl') . 'tag/'; $out = ''; $links = ''; $links_noscript = ''; $i = 0; $format = '<a href=\'%URL%\' style=\'font-size:%SIZE%px;\'>%TAG%<\\/a>'; $no_script = '<a href="%URL%" style="font-size:%SIZE%px;">%TAG%</a>'; /* ============ */ foreach ($tagcloud as $tag => $count) { if ($min_count) { if ($count < $min_count) { continue; } } $font_size = round(($count - $min) / ($max - $min) * ($max_size - $min_size) + $min_size); $tag_url = urlencode($tag); $f = str_replace(array('%SIZE%', '%URL%', '%TAG%', '%COUNT%'), array($font_size, $url . $tag_url, $tag, $count), $format); $af = str_replace(array('%SIZE%', '%URL%', '%TAG%'), array($font_size, $url . $tag_url, $tag), $no_script); $links .= $f . ' '; $links_noscript .= $af . ' '; $i++; if ($max_num != 0 and $i == $max_num) { break; } } $out .= '<script src="' . getinfo('plugins_url') . 'tagclouds3d/swfobject.js"></script> <div id="tag3dcontent">'; $out .= $links_noscript; $out .= '<script> //<![CDATA[ var rnumber = Math.floor(Math.random()*9999999); var widget_so = new SWFObject("' . getinfo('plugins_url') . 'tagclouds3d/tagcloud.swf?r="+rnumber, "tagcloudflash", "' . $width . '", "' . $height . '", "9", "#' . $bgcolor . '"); widget_so.addParam("wmode", "transparent") widget_so.addParam("allowScriptAccess", "always"); widget_so.addVariable("tcolor", "0x' . $text_color . '"); widget_so.addVariable("tcolor2", "0x' . $text_color2 . '"); widget_so.addVariable("hicolor", "0x' . $hover_color . '"); widget_so.addVariable("tspeed", "' . $speed . '"); widget_so.addVariable("distr", "true"); widget_so.addVariable("mode", "tags"); widget_so.addVariable("tagcloud", "<span>'; $out .= $links . '<\\/span>"); widget_so.write("tag3dcontent"); //]]> </script> </div>'; if ($out) { $out = $options['header'] . $options['block_start'] . $out . $options['block_end']; } mso_add_cache($cache_key, $out); // сразу в кэш добавим return $out; }
$categories = array(); // параметры ($type = 'page', $order = 'category_name', $asc = 'ASC', $type_page = 'blog', $cache = true) $all_categories = mso_cat_array_single(); // получаем все рубрики в один массив foreach ($all_categories as $cat) { // сверяем названия рубрик с исходной фразой $category_name = mb_strtolower($cat['category_name'], 'UTF8'); // если нужно искать по части вхождения: плагин -> плагины, плагинюшки, плагинячки if (strpos($category_name, $searh_to_text) !== false) { $categories[$cat['category_slug']] = $cat['category_name']; } } // метки require_once getinfo('common_dir') . 'meta.php'; $tags = array(); $all_tags = mso_get_all_tags_page(); // получаем все метки foreach ($all_tags as $key => $val) { // сверяем метки с исходной фразой $tag_name = mb_strtolower($key, 'UTF8'); if (strpos($tag_name, $searh_to_text) !== false) { $tags[] = $key; } } } if (!$pages and !$categories and !$tags and mso_get_option('page_404_http_not_found', 'templates', 1)) { header('HTTP/1.0 404 Not Found'); } # начальная часть шаблона if ($fn = mso_find_ts_file('main/main-start.php')) { require $fn;
function tagclouds_widget_custom($options = array(), $num = 1) { // кэш $cache_key = 'tagclouds_widget_custom' . serialize($options) . $num; $k = mso_get_cache($cache_key); if ($k) { return $k; } // да есть в кэше // формат вывода %SIZE% %URL% %TAG% %COUNT% // параметры $min_size $max_size $block_start $block_end // сортировка if (!isset($options['header'])) { $options['header'] = ''; } if (!isset($options['block_start'])) { $options['block_start'] = '<div class="tagclouds">'; } if (!isset($options['block_end'])) { $options['block_end'] = '</div>'; } if (!isset($options['min_size'])) { $min_size = 90; } else { $min_size = (int) $options['min_size']; } if (!isset($options['max_size'])) { $max_size = 230; } else { $max_size = (int) $options['max_size']; } if (!isset($options['max_num'])) { $max_num = 50; } else { $max_num = (int) $options['max_num']; } if (!isset($options['min_count'])) { $min_count = 0; } else { $min_count = (int) $options['min_count']; } if (!isset($options['format'])) { $options['format'] = '<span style="font-size: %SIZE%%"><a href="%URL%">%TAG%</a><sub style="font-size: 7pt;">%COUNT%</sub></span>'; } if (!isset($options['sort'])) { $sort = 0; } else { $sort = (int) $options['sort']; } require_once getinfo('common_dir') . 'meta.php'; // функции мета $tagcloud = mso_get_all_tags_page(); asort($tagcloud); $min = reset($tagcloud); $max = end($tagcloud); if ($max == $min) { $max++; } // сортировка перед выводом if ($sort == 0) { arsort($tagcloud); } elseif ($sort == 1) { asort($tagcloud); } elseif ($sort == 2) { ksort($tagcloud); } elseif ($sort == 3) { krsort($tagcloud); } else { arsort($tagcloud); } // по умолчанию $url = getinfo('siteurl') . 'tag/'; $out = ''; $i = 0; foreach ($tagcloud as $tag => $count) { if ($min_count) { if ($count < $min_count) { continue; } } $font_size = round(($count - $min) / ($max - $min) * ($max_size - $min_size) + $min_size); $af = str_replace(array('%SIZE%', '%URL%', '%TAG%', '%COUNT%'), array($font_size, $url . urlencode($tag), $tag, $count), $options['format']); // альтернативный синтаксис с [] $af = str_replace(array('[SIZE]', '[URL]', '[TAG]', '[COUNT]'), array($font_size, $url . urlencode($tag), $tag, $count), $af); $out .= $af . ' '; $i++; if ($max_num != 0 and $i == $max_num) { break; } } if ($out) { $out = $options['header'] . $options['block_start'] . $out . $options['block_end']; } mso_add_cache($cache_key, $out); // сразу в кэш добавим return $out; }