• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mso_add_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mso_add_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP mso_add_cache函数的具体用法?PHP mso_add_cache怎么用?PHP mso_add_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mso_add_cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: parents_out_way_to

function parents_out_way_to($page_id = 0)
{
    $cache_key = 'parents_out_way_to' . $page_id;
    $k = mso_get_cache($cache_key);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    $r = '';
    $CI =& get_instance();
    $CI->db->select('page_id, page_id_parent, page_title, page_slug');
    $CI->db->where('page_id', $page_id);
    $CI->db->order_by('page_menu_order');
    $query = $CI->db->get('page');
    $result = $query->result_array();
    if ($result) {
        foreach ($result as $key => $page2) {
            extract($page2);
            $r = $page_title;
            if ($page_id_parent > 0) {
                $parents = parents_out_way_parents($page_id_parent);
                if ($parents) {
                    $r = $parents . ' <span class="arr">→</span> ' . $page_title;
                }
            }
        }
    }
    mso_add_cache($cache_key, $r);
    // в кэш
    return $r;
}
开发者ID:nicothin,项目名称:nicothin_ru,代码行数:31,代码来源:functions.php


示例2: perelinks_custom

function perelinks_custom($content = '')
{
    // получаем список всех титлов - возможно из кэша
    // после этого выполняем замену всех этих вхождений в тексте на ссылки
    global $page;
    // текущая страница - это массив
    $options = mso_get_option('perelinks', 'plugins', array());
    // получаем опции
    $options['linkcount'] = isset($options['linkcount']) ? (int) $options['linkcount'] : 0;
    $options['wordcount'] = isset($options['wordcount']) ? (int) $options['wordcount'] : 0;
    $options['allowlate'] = isset($options['allowlate']) ? (int) $options['allowlate'] : 1;
    $options['stopwords'] = isset($options['stopwords']) ? $options['stopwords'] : 'будет нужно';
    if (isset($options['stopwords'])) {
        $stopwords = explode(' ', $options['stopwords']);
    }
    $cache_key = 'perelinks_custom';
    if ($k = mso_get_cache($cache_key)) {
        $all_title = $k;
    } else {
        $CI =& get_instance();
        $CI->db->select('page_title, page_slug');
        if ($options['allowlate'] > 0) {
            $CI->db->where('page_date_publish <', date('Y-m-d H:i:s'));
            // $CI->db->where('page_date_publish <', 'NOW()', false);
        } else {
            $CI->db->where('page_date_publish <', $page['page_date_publish']);
        }
        $CI->db->where('page_status', 'publish');
        $CI->db->from('page');
        $query = $CI->db->get();
        $all_title = array();
        if ($query->num_rows() > 0) {
            foreach ($query->result_array() as $row) {
                $title = mb_strtolower($row['page_title'], 'UTF-8');
                $title = str_replace(array('\\', '|', '/', '?', '%', '*', '`', ',', '.', '$', '!', '\'', '"', '«', '»', '—'), '', $title);
                $a_words = explode(' ', $title);
                $a_words = array_unique($a_words);
                $title = array();
                foreach ($a_words as $word) {
                    if (mb_strlen($word, 'UTF-8') > 3 and !in_array($word, $stopwords)) {
                        $title[] = $word;
                    }
                }
                foreach ($title as $word) {
                    $all_title[$word][] = $row['page_slug'];
                }
            }
        }
        mso_add_cache($cache_key, $all_title);
    }
    $curr_page_slug = $page['page_slug'];
    // текущая страница - для ссылки
    $my_site = getinfo('siteurl') . 'page/';
    // ищем вхождения
    $linkcounter = 0;
    foreach ($all_title as $key => $word) {
        $r = '| (' . preg_quote($key) . ') |siu';
        if (preg_match($r, $content)) {
            if (!in_array($curr_page_slug, $word)) {
                if ($options['wordcount'] > 0) {
                    $r = '| (' . preg_quote($key) . ') (.*$)|siu';
                }
                //Если только первое найденное слово-дубликат делать ссылкой
                $content = preg_replace($r, ' <a href="' . $my_site . $word[0] . '" class="perelink">\\1</a> \\2', $content);
                $linkcounter++;
            }
        }
        if ($linkcounter > 0 and $linkcounter == $options['linkcount']) {
            break;
        }
    }
    return $content;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:73,代码来源:index.php


示例3: mso_get_cat_from_id

                $cat_info = mso_get_cat_from_id($cat_id);
                // все данные рубрики
                // название рубрики и ссылка
                echo '<div class="mso-header-home-cat">' . '<a href="' . getinfo('site_url') . 'category/' . $cat_info['category_slug'] . '">' . htmlspecialchars($cat_info['category_name']) . '</a>' . '</div>';
                // выводить описание рубрики
                if (mso_get_option('default_description_home_cat', 'templates', '0') and $cat_info['category_desc']) {
                    echo '<div class="mso-description-cat">' . $cat_info['category_desc'] . '</div>';
                }
                if ($f = mso_page_foreach('home-cat-block-out-pages-do')) {
                    require $f;
                }
                mso_set_val('container_class', 'mso-type-home mso-type-home-cat-block mso-type-home-cat-block-list');
                if (mso_get_option('default_description_home', 'templates', '0')) {
                    mso_set_val('list_line_format', '[title] - [date] [meta_description]');
                }
                if ($fn = mso_find_ts_file('type/_def_out/list/list.php')) {
                    require $fn;
                }
            }
            // endif $pages
        }
        // end foreach $home_cat_block
    }
    mso_add_cache($key_home_cache, ob_get_flush(), 900);
}
// if $k
if ($f = mso_page_foreach('home-cat-block-posle')) {
    require $f;
}
echo NR . '</div><!-- class="mso-type-home-cat-block" -->' . NR;
# end file
开发者ID:Kmartynov,项目名称:cms,代码行数:31,代码来源:home-cat-block-list.php


示例4: last_comments_widget_custom

function last_comments_widget_custom($options = array(), $num = 1)
{
    if (!isset($options['count'])) {
        $options['count'] = 5;
    }
    if (!isset($options['words'])) {
        $options['words'] = 20;
    }
    if (!isset($options['maxchars'])) {
        $options['maxchars'] = 20;
    }
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    $options['count'] = (int) $options['count'];
    if ($options['count'] < 1) {
        $options['count'] = 5;
    }
    $options['words'] = (int) $options['words'];
    if ($options['words'] < 1) {
        $options['words'] = 20;
    }
    $options['maxchars'] = (int) $options['maxchars'];
    if ($options['maxchars'] < 1) {
        $options['maxchars'] = 20;
    }
    $cache_key = 'last_comments_widget_' . $num . mso_md5(serialize($options));
    $k = mso_get_cache($cache_key, true);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    require_once getinfo('common_dir') . 'comments.php';
    // функции комментариев
    $comments = mso_get_comments(false, array('limit' => $options['count'], 'order' => 'desc'));
    $out = '';
    if ($comments) {
        // сгруппируем все комментарии по записям
        $arr_com_page = array();
        $arr_com_page_title = array();
        foreach ($comments as $comment) {
            $arr_com_page[$comment['page_id']][$comment['comments_id']] = $comment;
            $arr_com_page_title[$comment['page_id']] = $comment['page_title'];
        }
        // выводим по странично
        foreach ($arr_com_page as $key => $comments) {
            $out .= '<h5>' . $arr_com_page_title[$key] . '</h5>';
            $comments = array_reverse($comments);
            // чтобы комментарии были в привычном порядке сверху вниз
            $out .= '<ul class="mso-widget-list">';
            foreach ($comments as $comment) {
                extract($comment);
                if ($comment['comments_users_id']) {
                    $css_style_add = 'last_comment_users ' . ' mso-last-comment-users-' . $comment['comments_users_id'];
                } elseif ($comment['comments_comusers_id']) {
                    $css_style_add = 'last_comment_comusers ' . ' mso-last-comment-comusers-' . $comment['comments_comusers_id'];
                } else {
                    $css_style_add = 'last_comment_anonim';
                }
                $out .= '<li class="' . $css_style_add . '"><a href="' . getinfo('siteurl') . 'page/' . mso_slug($page_slug) . '#comment-' . $comments_id . '"><b>';
                if ($comments_users_id) {
                    $out .= $users_nik;
                } elseif ($comments_comusers_id) {
                    if ($comusers_nik) {
                        $out .= $comusers_nik;
                    } else {
                        $out .= t('Комментатор') . ' ' . $comusers_id;
                    }
                } elseif ($comments_author_name) {
                    $out .= $comments_author_name;
                } else {
                    $out .= ' ' . t('Аноним');
                }
                $comments_content_1 = strip_tags($comments_content);
                // удалим тэги
                $comments_content = mso_str_word($comments_content_1, $options['words']);
                // ограничение на количество слов
                // если старый и новый текст после обрезки разные, значит добавим в конце ...
                if ($comments_content_1 != $comments_content) {
                    $comments_content .= '...';
                }
                // каждое слово нужно проверить на длину и если оно больше maxchars, то добавить пробел в wordwrap
                $words = explode(' ', $comments_content);
                foreach ($words as $key => $word) {
                    $words[$key] = mso_wordwrap($word, $options['maxchars'], ' ');
                }
                $comments_content = implode(' ', $words);
                $out .= ' »</b>  ' . strip_tags($comments_content) . '</a>';
                $out .= '</li>' . NR;
            }
            $out .= '</ul>';
        }
        if ($options['header']) {
            $out = $options['header'] . $out;
        }
    }
    mso_add_cache($cache_key, $out, false, true);
    // сразу в кэш добавим
    return trim($out);
}
开发者ID:Kmartynov,项目名称:cms,代码行数:100,代码来源:index.php


示例5: mso_pages_data

/**
*  возвращает массив структуры всех pages
*  включается title description keywords date dir url, а также массива $DATA в variables.php
*  date — время создания файла text.php (или явно заданное в $DATA['date'])
*  
*  @param $include — включить только указанные страницы
*  @param $exclude — исключить указанные страницы
*  @param $dir — основной каталог, если не указано то это PAGES_DIR
*  @param $url — основной http-путь, если не указано то это BASE_URL
*  
*  @return array
*  
*  [home] => Array (
*  		   // обязательные
*          [page] => home
*          [title] => Blog
*          [description] => Best page
*          [keywords] => 
*          [date] => 2014-10-22 12:56
*  		   [dir] => путь к странице
*  		   [url] => http-адрес страницы
*          
*          // все что задано в $DATA
*          [menu_name] => home
*          [menu_class] => icon star
*          [menu_order] => 23
*          [cat] => news, blog
*          [tag] => first, second
*   )
*/
function mso_pages_data($include = array(), $exclude = array(), $dir = false, $url = false, $cache_time = 3600)
{
    static $cache = array();
    // кеш хранится как массив с ключам = входящим параметрам
    $cache_key = md5(serialize($include) . serialize($exclude) . serialize($dir) . serialize($url));
    // уже получали данные, отдаем результат
    if (isset($cache[$cache_key])) {
        return $cache[$cache_key];
    } else {
        // возможно есть данные в файловом кеше
        if ($out = mso_get_cache('pages_data' . $cache_key, $cache_time)) {
            $cache[$cache_key] = $out;
            // статичный кеш
            return $out;
        }
    }
    $out = array();
    // путь на сервере
    if ($dir === false) {
        $dir = PAGES_DIR;
    }
    // url-путь
    if ($url === false) {
        $url = BASE_URL;
    }
    $pages = mso_get_dirs($dir, $exclude, 'variables.php');
    if ($pages) {
        if ($include) {
            $pages = array_intersect($include, $pages);
        }
        // для вложенных страниц добавляем префикс равный отличию от PAGES_DIR
        // pages/about => about
        // pages/blog/about => blog/about
        $prefix = str_replace(PAGES_DIR, '', $dir);
        foreach ($pages as $page) {
            if (!file_exists($dir . $page . '/text.php')) {
                continue;
            }
            // если нет text.php выходим
            $page_k = $prefix . $page;
            if ($page == HOME_PAGE) {
                $out[$page_k] = array('page' => '/');
            } else {
                $out[$page_k] = array('page' => $page_k);
            }
            // обнуляем данные
            $TITLE = '';
            $META = array();
            $DATA = array();
            // считываем данные
            require $dir . $page . '/variables.php';
            $out[$page_k]['title'] = $TITLE;
            $out[$page_k]['description'] = isset($META['description']) ? $META['description'] : '';
            $out[$page_k]['keywords'] = isset($META['keywords']) ? $META['keywords'] : '';
            // дата создания text.php
            $out[$page_k]['date'] = date('Y-m-d H:i', filemtime($dir . $page . '/text.php'));
            // путь на сервере
            $out[$page_k]['dir'] = $dir . $page;
            // url
            $out[$page_k]['url'] = $url . $page;
            if (isset($DATA)) {
                $out[$page_k] = array_merge($out[$page_k], $DATA);
            }
        }
    }
    $cache[$cache_key] = $out;
    // статичный кеш
    mso_add_cache('pages_data' . $cache_key, $out);
    // файловый
    return $out;
//.........这里部分代码省略.........
开发者ID:sheck87,项目名称:landing,代码行数:101,代码来源:engine.php


示例6: links_widget_custom

function links_widget_custom($options = array(), $num = 1)
{
    // кэш
    $cache_key = 'links_widget_custom' . serialize($options) . $num;
    $k = mso_get_cache($cache_key);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    $out = '';
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    if (!isset($options['screenshot'])) {
        $options['screenshot'] = 0;
    }
    if (isset($options['links'])) {
        $links = explode("\n", $options['links']);
        // разбиваем по строкам
        foreach ($links as $row) {
            $ar_link = explode('|', $row);
            // разбиваем по |
            // всего должно быть 5 элементов
            if (isset($ar_link[0]) and trim($ar_link[0])) {
                $href = trim($ar_link[0]);
                // адрес
                if ($href and isset($ar_link[1]) and trim($ar_link[1])) {
                    $title = trim($ar_link[1]);
                    // название
                    if (isset($ar_link[2]) and trim($ar_link[2])) {
                        $descr = '<div>' . trim($ar_link[2]) . '</div>';
                    } else {
                        $descr = '';
                    }
                    if (isset($ar_link[3]) and trim($ar_link[3])) {
                        //$noindex1 = '<noindex>';
                        //$noindex2 = '</noindex>';
                        $noindex1 = '';
                        $noindex2 = '';
                        $nofollow = ' rel="nofollow"';
                    } else {
                        $noindex1 = $noindex2 = $nofollow = '';
                    }
                    if (isset($ar_link[4]) and trim($ar_link[4])) {
                        $blank = ' target="_blank"';
                    } else {
                        $blank = '';
                    }
                    if (!$options['screenshot']) {
                        // обычный вывод списком
                        $out .= NR . '<li>' . $noindex1 . '<a href="' . $href . '" title="' . htmlspecialchars($title) . '"' . $nofollow . $blank . '>' . $title . '</a>' . $descr . $noindex2 . '</li>';
                    } else {
                        // скриншоты
                        $href_w = str_replace('http://', '', $href);
                        if ($options['screenshot'] == 1) {
                            $width = '120';
                            $height = '83';
                            $s = 'm';
                        } elseif ($options['screenshot'] == 2) {
                            $width = '202';
                            $height = '139';
                            $s = 's';
                        } elseif ($options['screenshot'] == 3) {
                            $width = '305';
                            $height = '210';
                            $s = 'n';
                        } else {
                            $width = '400';
                            $height = '275';
                            $s = 'b';
                        }
                        $out .= NR . '<p>' . $noindex1 . '<a href="' . $href . '" title="' . htmlspecialchars($title) . '"' . $nofollow . $blank . '>' . '<img src="http://webmorda.kz/site2img/?s=' . $s . '&u=' . $href_w . '" alt="' . htmlspecialchars($title) . '" title="' . $title . '" width="' . $width . '" height="' . $height . '"></a>' . $descr . '' . $noindex2 . '</p>';
                        /*
                        http://www.webmorda.kz/api.html
                        http://webmorda.kz/site2img/?u={1}&s={2}&q={3}&r={4}
                        */
                    }
                }
            }
        }
    }
    if ($out) {
        if (!$options['screenshot']) {
            // обычным списком
            $out = $options['header'] . NR . '<ul class="is_link links">' . $out . NR . '</ul>' . NR;
        } else {
            // скриншоты
            $out = $options['header'] . NR . '<div class="links">' . $out . '</div><div class="break"></div>' . NR;
        }
    }
    mso_add_cache($cache_key, $out);
    // сразу в кэш добавим
    return $out;
}
开发者ID:rb2,项目名称:MaxSite-CMS,代码行数:94,代码来源:index.php


示例7: authors_widget_custom

function authors_widget_custom($options = array(), $num = 1)
{
    // кэш
    $cache_key = 'authors_widget_custom' . serialize($options) . $num;
    $k = mso_get_cache($cache_key);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    $out = '';
    if (!isset($options['header'])) {
        $options['header'] = t('Авторы');
    }
    // получаем всех авторов
    $CI =& get_instance();
    $CI->db->select('users_nik, users_id');
    $CI->db->order_by('users_nik');
    $query = $CI->db->get('users');
    if ($query->num_rows() > 0) {
        $users = $query->result_array();
        $out = '';
        foreach ($users as $user) {
            $out .= NR . '<li><a href="' . getinfo('siteurl') . 'author/' . $user['users_id'] . '">' . $user['users_nik'] . '</a></li>';
        }
        if ($out) {
            $out = $options['header'] . '<ul class="mso-widget-list">' . $out . '</ul>' . NR;
        }
    }
    mso_add_cache($cache_key, $out);
    // сразу в кэш добавим
    return $out;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:32,代码来源:index.php


示例8: catclouds_widget_custom

function catclouds_widget_custom($options = array(), $num = 1)
{
    // кэш
    $cache_key = 'catclouds_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
    // сортировка
    $out = '';
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    if (!isset($options['block_start'])) {
        $options['block_start'] = '<div class="catclouds">';
    }
    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['cat_id'])) {
        $cat_id = 0;
    } else {
        $cat_id = (int) $options['cat_id'];
    }
    if (!isset($options['format'])) {
        $options['format'] = '<span style="font-size: %SIZE%%"><a href="%URL%">%CAT%</a><sub style="font-size: 7pt;">%COUNT%</sub></span>';
    }
    if (!isset($options['sort'])) {
        $sort = 0;
    } else {
        $sort = (int) $options['sort'];
    }
    $url = getinfo('siteurl') . 'category/';
    require_once getinfo('common_dir') . 'category.php';
    // функции мета
    $all_cat = mso_cat_array_single('page', 'category_name', 'ASC', 'blog');
    $catcloud = array();
    foreach ($all_cat as $key => $val) {
        if ($cat_id) {
            // выводим саму рубрику и всех её детей
            if ($val['category_id'] == $cat_id or $val['category_id_parent'] == $cat_id) {
                if (count($val['pages']) > 0) {
                    // кол-во страниц в этой рубрике > 0
                    $catcloud[$val['category_name']] = array('count' => count($val['pages']), 'slug' => $val['category_slug']);
                }
            }
        } else {
            if (count($val['pages']) > 0) {
                // кол-во страниц в этой рубрике > 0
                $catcloud[$val['category_name']] = array('count' => count($val['pages']), 'slug' => $val['category_slug']);
            }
        }
    }
    asort($catcloud);
    $min = reset($catcloud);
    $min = $min['count'];
    $max = end($catcloud);
    $max = $max['count'];
    if ($max == $min) {
        $max++;
    }
    // сортировка перед выводом
    if ($sort == 0) {
        arsort($catcloud);
    } elseif ($sort == 1) {
        asort($catcloud);
    } elseif ($sort == 2) {
        ksort($catcloud);
    } elseif ($sort == 3) {
        krsort($catcloud);
    } else {
        arsort($catcloud);
    }
    // по умолчанию
    foreach ($catcloud as $cat => $ar) {
        $count = $ar['count'];
        $slug = $ar['slug'];
        $font_size = round(($count - $min) / ($max - $min) * ($max_size - $min_size) + $min_size);
        $af = str_replace(array('%SIZE%', '%URL%', '%CAT%', '%COUNT%'), array($font_size, $url . $slug, $cat, $count), $options['format']);
        $out .= $af . ' ';
    }
    if ($out) {
        $out = $options['header'] . $options['block_start'] . $out . $options['block_end'];
    }
    mso_add_cache($cache_key, $out);
    // сразу в кэш добавим
    return $out;
//.........这里部分代码省略.........
开发者ID:rb2,项目名称:MaxSite-CMS,代码行数:101,代码来源:index.php


示例9: mso_cat_ul

function mso_cat_ul($li_format = '%NAME%', $show_empty = true, $checked_id = array(), $selected_id = array(), $ul_class = 'category', $type_page = 'blog', $type = 'page', $order = 'category_menu_order', $asc = 'asc', $custom_array = false, $include = array(), $exclude = array())
{
    // спасибо за помощь http://tedbeer.net/wp/
    // $include = array('3');
    // $exclude = array('3');
    // возможно, что этот список уже сформирован, поэтому посмотрим в кэше
    $cache_key = mso_md5('mso_cat_ul' . $li_format . $show_empty . implode(' ', $checked_id) . implode(' ', $selected_id) . $ul_class . $type_page . $type . $order . $asc . implode(' ', $include) . implode(' ', $exclude));
    $k = mso_get_cache($cache_key);
    if ($k) {
        // находим текущий url (код повтояет внизу)
        $current_url = getinfo('siteurl') . mso_current_url();
        // текущий урл
        $out = str_replace('<a href="' . $current_url . '">', '<a href="' . $current_url . '" class="current_url">', $k);
        $pattern = '|<li class="(.*?)">(.*?)(<a href="' . $current_url . '")|ui';
        $out = preg_replace($pattern, '<li class="$1 current_url">$2$3', $out);
        return $out;
    }
    # получим все рубрики в виде одномерного массива
    if ($custom_array) {
        $all = $custom_array;
    } else {
        $all = mso_cat_array_single('page', $order, $asc, $type_page);
    }
    $top = array();
    foreach ($all as $item) {
        $parentId = $item['category_id_parent'];
        $id = $item['category_id'];
        if ($parentId && isset($all[$parentId])) {
            if (!isset($all[$parentId]['children'])) {
                $all[$parentId]['children'] = array($id);
            } else {
                $all[$parentId]['children'][] = $id;
            }
        } else {
            $top[] = $id;
        }
    }
    // непосредственно формирование списка
    $out = _mso_cat_ul_glue($top, $all, $li_format, $checked_id, $selected_id, $show_empty, $include, $exclude);
    # $out = str_replace("\n{*}</li>", "</li>", $out);
    if ($ul_class) {
        $out = '<ul class="' . $ul_class . '">' . "\n" . $out . "\n" . '</ul>';
    } else {
        $out = '<ul>' . "\n" . $out . "\n" . '</ul>';
    }
    mso_add_cache($cache_key, $out);
    // сразу в кэш добавим
    // отметим текущую рубрику. Поскольку у нас к кэше должен быть весь список и не делать кэш для каждого url
    // то мы просто перед отдачей заменяем текущий url на url с li.current_url
    $current_url = getinfo('siteurl') . mso_current_url();
    // текущий урл
    $out = str_replace('<a href="' . $current_url . '">', '<a href="' . $current_url . '" class="current_url">', $out);
    $pattern = '|<li class="(.*?)">(.*?)(<a href="' . $current_url . '")|ui';
    $out = preg_replace($pattern, '<li class="$1 current_url">$2$3', $out);
    return $out;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:56,代码来源:category.php


示例10: sitemap_cat

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;
}
开发者ID:rb2,项目名称:MaxSite-CMS,代码行数:18,代码来源:index.php


示例11: twitter_go

function twitter_go($url = false, $count = 5, $format = '<p><strong>%DATE%</strong><br>%TITLE% <a href="%LINK%">&gt;&gt;&gt;</a></p>', $format_date = 'd/m/Y H:i:s', $max_word_description = false, $show_nick = true)
{
    if (!$url) {
        return false;
    }
    # проверим кеш, может уже есть в нем все данные
    $cache_key = 'rss/' . 'twitter_go' . $url . $count . $format . $format_date . (int) $max_word_description;
    $k = mso_get_cache($cache_key, true);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    if (!defined('MAGPIE_CACHE_AGE')) {
        define('MAGPIE_CACHE_AGE', 600);
    }
    // время кэширования MAGPIE
    require_once getinfo('common_dir') . 'magpierss/rss_fetch.inc';
    $rss = fetch_rss($url);
    $rss = array_slice($rss->items, 0, $count);
    $out = '';
    foreach ($rss as $item) {
        $out .= $format;
        if ($show_nick) {
            $item['title'] = preg_replace('|(\\S+): (.*)|si', '<strong>\\1:</strong> \\2', $item['title']);
        } else {
            $item['title'] = preg_replace('|(\\S+): (.*)|si', '\\2', $item['title']);
        }
        // подсветим ссылки
        $item['title'] = preg_replace('|(http:\\/\\/)(\\S+)|si', '<a rel="nofollow" href="http://\\2" target="_blank">\\2</a>', $item['title']);
        $out = str_replace('%TITLE%', $item['title'], $out);
        // [title] = [description] = [summary]
        if ($max_word_description) {
            $item['description'] = mso_str_word($item['description'], $max_word_description) . '...';
        }
        $item['description'] = preg_replace('|(\\S+): (.*)|si', '<strong>\\1:</strong> \\2', $item['description']);
        $item['description'] = preg_replace('|(http:\\/\\/)(\\S+)|si', '<a rel="nofollow" href="http://\\2" target="_blank">\\2</a>', $item['description']);
        $out = str_replace('%DESCRIPTION%', $item['description'], $out);
        // [title] = [description] = [summary]
        $out = str_replace('%DATE%', date($format_date, (int) $item['date_timestamp']), $out);
        // [pubdate]
        $out = str_replace('%LINK%', $item['link'], $out);
        // [link] = [guid]
    }
    mso_add_cache($cache_key, $out, 600, true);
    return $out;
}
开发者ID:rb2,项目名称:MaxSite-CMS,代码行数:46,代码来源:index.php


示例12: last_pages_widget_custom

function last_pages_widget_custom($arg = array(), $num = 1)
{
    if (!isset($arg['count'])) {
        $arg['count'] = 7;
    }
    if (!isset($arg['page_type'])) {
        $arg['page_type'] = 'blog';
    }
    if (!isset($arg['sort'])) {
        $arg['sort'] = 'page_date_publish';
    }
    if (!isset($arg['sort_order'])) {
        $arg['sort_order'] = 'desc';
    }
    if (!isset($arg['date_format'])) {
        $arg['date_format'] = 'd/m/Y';
    }
    if (!isset($arg['format'])) {
        $arg['format'] = '<h4>[TITLE]</h4><p>[DATE] [COMMENTS]</p>[IMG]<p>[TEXT]</p>';
    }
    if (!isset($arg['comments_format'])) {
        $arg['comments_format'] = ' | ' . t('Комментариев: ') . '[COUNT]';
    }
    if (!isset($arg['include_cat'])) {
        $arg['include_cat'] = '';
    }
    if (!isset($arg['img_prev_def'])) {
        $arg['img_prev_def'] = '';
    }
    if (!isset($arg['img_prev_attr'])) {
        $arg['img_prev_attr'] = 'class="b-left w100"';
    }
    if (!isset($arg['max_words'])) {
        $arg['max_words'] = 20;
    }
    if (!isset($arg['text_do'])) {
        $arg['text_do'] = '';
    }
    if (!isset($arg['text_posle'])) {
        $arg['text_posle'] = '';
    }
    if (!isset($arg['header'])) {
        $arg['header'] = mso_get_val('widget_header_start', '<div class="mso-widget-header"><span>') . t('Последние записи') . mso_get_val('widget_header_end', '</span></div>');
    }
    if (!isset($arg['block_start'])) {
        $arg['block_start'] = '';
    }
    if (!isset($arg['block_end'])) {
        $arg['block_end'] = '';
    }
    if ($arg['sort_order'] != 'random') {
        $cache_key = 'last_pages_widget' . serialize($arg) . $num;
        if ($k = mso_get_cache($cache_key)) {
            return $k;
        }
        // да есть в кэше
    }
    $par = array('limit' => $arg['count'], 'cut' => '', 'cat_order' => 'category_name', 'cat_order_asc' => 'asc', 'pagination' => false, 'cat_id' => $arg['include_cat'], 'order' => $arg['sort'], 'order_asc' => $arg['sort_order'], 'type' => $arg['page_type'], 'custom_type' => 'home');
    $pages = mso_get_pages($par, $temp);
    $out = '';
    if ($pages) {
        foreach ($pages as $page) {
            // [TITLE] [DATE] [TEXT] [IMG] [COMMENTS] [URL]
            $title = mso_page_title($page['page_slug'], $page['page_title'], '', '', true, false, 'page');
            $url = getinfo('site_url') . 'page/' . $page['page_slug'];
            $date = mso_page_date($page['page_date_publish'], $arg['date_format'], '', '', false);
            $img = isset($page['page_meta']['image_for_page'][0]) ? $page['page_meta']['image_for_page'][0] : '';
            if (!$img and $arg['img_prev_def']) {
                $img = $arg['img_prev_def'];
            }
            if ($img) {
                $img = '<a href="' . $url . '"><img src="' . $img . '" alt="' . $page['page_title'] . '" ' . $arg['img_prev_attr'] . '></a>';
            }
            if ($page['page_count_comments']) {
                $comments = str_replace('[COUNT]', $page['page_count_comments'], $arg['comments_format']);
            } else {
                $comments = '';
            }
            $text = mso_str_word(strip_tags($page['page_content']), $arg['max_words']) . ' ...';
            $out_page = $arg['format'];
            $out_page = str_replace('[TITLE]', $title, $out_page);
            $out_page = str_replace('[DATE]', $date, $out_page);
            $out_page = str_replace('[COMMENTS]', $comments, $out_page);
            $out_page = str_replace('[URL]', $url, $out_page);
            $out_page = str_replace('[TEXT]', $text, $out_page);
            $out_page = str_replace('[IMG]', $img, $out_page);
            $out .= $out_page;
        }
        $out = $arg['header'] . $arg['block_start'] . $arg['text_do'] . $out . $arg['text_posle'] . $arg['block_end'];
    }
    if ($arg['sort_order'] != 'random') {
        mso_add_cache($cache_key, $out);
    }
    // в кэш
    return $out;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:96,代码来源:index.php


示例13: mso_get_yaml

/**
 * Получение yaml-конфигурации из файла и сохранение её в глобальные переменные 
 */
function mso_get_yaml($fn)
{
    global $VAR, $TITLE, $META, $META_LINK;
    $key = 'yaml-' . $fn;
    $conf = mso_get_cache($key, 0, false, filemtime($fn));
    if (!$conf) {
        $data = file_get_contents($fn);
        // проверяем вхождение /* === конфигурация === */
        if (preg_match('!\\/\\* \\=\\=\\=(.*?)\\=\\=\\= \\*\\/!is', $data, $conf)) {
            $yaml = trim($conf[1]);
            // разрешено использовать php-шаблонизатор
            ob_start();
            eval(mso_tmpl_prepare($yaml));
            $yaml = ob_get_clean();
            require_once ENGINE_DIR . 'yaml/Spyc.php';
            $conf = spyc_load($yaml);
            mso_add_cache($key, $conf);
        }
    }
    if ($conf) {
        if (isset($conf['TITLE'])) {
            $TITLE = $conf['TITLE'];
        }
        if (isset($conf['VAR']) and is_array($conf['VAR'])) {
            $VAR = array_merge($VAR, $conf['VAR']);
        }
        if (isset($conf['META']) and is_array($conf['META'])) {
            $META = array_merge($META, $conf['META']);
        }
        if (isset($conf['META_LINK']) and is_array($conf['META_LINK'])) {
            $META_LINK = array_merge($META_LINK, $conf['META_LINK']);
        }
    }
}
开发者ID:vladiheg,项目名称:landing,代码行数:37,代码来源:engine.php


示例14: last_pages_unit_widget_custom

function last_pages_unit_widget_custom($arg = array(), $num = 1)
{
    if (!isset($arg['header'])) {
        $arg['header'] = mso_get_val('widget_header_start', '<div class="mso-widget-header"><span>') . t('Последние записи') . mso_get_val('widget_header_end', '</span></div>');
    }
    if (!isset($arg['cache_time'])) {
        $arg['cache_time'] = 0;
    }
    if (!isset($arg['prefs'])) {
        $arg['prefs'] = '';
    }
    $out = '';
    $cache_key = 'last_pages_unit_widget-' . serialize($arg) . '-' . $num;
    if ($arg['cache_time'] > 0 and $out = mso_get_cache($cache_key)) {
        return $out;
        # да есть в кэше
    }
    $units = mso_section_to_array('[unit]' . $arg['prefs'] . '[/unit]', '!\\[unit\\](.*?)\\[\\/unit\\]!is');
    ob_start();
    if ($units and isset($units[0]) and $units[0]) {
        $UNIT = $units[0];
        require dirname(realpath(__FILE__)) . '/last-pages.php';
    }
    $out = $arg['header'] . ob_get_clean();
    if ($arg['cache_time'] > 0) {
        mso_add_cache($cache_key, $out, $arg['cache_time'] * 60);
    }
    return $out;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:29,代码来源:index.php


示例15: rss_get_go

function rss_get_go($arg)
{
    // здесь нет проверок на корректность $arg, потому что мы её уже выполнили в rss_get_widget_custom
    if (!$arg['url']) {
        return false;
    }
    # проверим кеш, может уже есть в нем все данные
    $cache_key = 'rss/' . 'rss_get_' . md5(serialize($arg));
    $k = mso_get_cache($cache_key, true);
    if ($k) {
        return $k;
        // да есть в кэше
    } else {
        require_once getinfo('plugins_dir') . 'rss_get/lastrss.php';
        $rss_pars = new lastRSS();
        $rss_pars->convert_cp = $arg['charset'];
        $rss_pars->itemtags = mso_explode($arg['fields'], false);
        $rss = $rss_pars->Get($arg['url']);
    }
    if (!$rss) {
        return '';
    }
    if (isset($rss[$arg['fields_items']])) {
        $rss = $rss[$arg['fields_items']];
        $rss = array_slice($rss, 0, $arg['count']);
        // колво записей
    } else {
        return '';
        // нет items
    }
    // меняем ключи с values и заполняем нулями - это шаблон для полей
    $fields = array_fill_keys(mso_explode($arg['fields'], false), false);
    $out = '';
    foreach ($rss as $item) {
        // заполним массив шаблона полей значениями из итема
        $fields_out = $fields;
        foreach ($fields as $field => $tmp) {
            if (isset($item[$field])) {
                $fields_out[$field] = $item[$field];
                continue;
            }
        }
        $out1 = $arg['format'];
        foreach ($fields_out as $field => $value) {
            // обратное преобразование в html
            $value = str_replace('&lt;', '<', $value);
            $value = str_replace('&gt;', '>', $value);
            $value = str_replace('&amp;', '&', $value);
            $value = str_replace('<![CDATA[', '', $value);
            $value = str_replace(']]>', '', $value);
            // если стоит максимальное колво слов, то обрежем лишнее
            if ($arg['max_word_description'] and $field != 'link') {
                $value = mso_str_word($value, $arg['max_word_description']);
            }
            // если поле содержит date, то пробуем его преобразовать в нужный нам формат даты
            if (strpos($field, 'dc:date') !== false or strpos($field, 'date') !== false or $field == 'published' or $field == 'updated') {
                if (($d = strtotime($value)) !== -1) {
                    // успешное преобразование
                    $value = date($arg['format_date'], $d);
                }
            }
            if ($field == 'link') {
                $link_host = parse_url($value);
                $link_host = $link_host['host'];
                $out1 = str_replace('[link-host]', $link_host, $out1);
            }
            $out1 = str_replace('[' . $field . ']', $value, $out1);
        }
        $out .= $out1;
    }
    if ($out and $arg['time_cache']) {
        mso_add_cache($cache_key, $out, $arg['time_cache'] * 60, true);
    }
    return $out;
}
开发者ID:Kmartynov,项目名称:cms,代码行数:75,代码来源:index.php


示例16: page_views_widget_custom

function page_views_widget_custom($options = array(), $num = 1)
{
    // кэш
    $cache_key = 'page_views_widget_custom' . serialize($options) . $num;
    $k = mso_get_cache($cache_key);
    if ($k) {
        return $k;
    }
    // да есть в кэше
    $out = '';
    if (!isset($options['header'])) {
        $options['header'] = '';
    }
    if (!isset($options['limit'])) {
        $options['limit'] = 10;
 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mso_add_option函数代码示例发布时间:2022-05-15
下一篇:
PHP msgpack_unserialize函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap