Пример #1
0
function tag_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $sm->article_list_params = Articles_list::get_search_params_from_url($sm);
    $sm->article_list_params['search_options'] = array();
    if (VIVVO_MODULES_TAGS == 1 && ($um->isset_param('show_tags') || ($um->get_param('search_tag_id') || $um->get_param('search_tag')) && !$um->get_param('search_do_advanced'))) {
        //Tag view page
        if ($um->isset_param('show_tags')) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
            $content_template = new template($sm, $template);
            $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/tags_page.tpl');
            $template->assign_template('PAGE_CONTENT', $content_template);
            $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_TAGS')));
        } else {
            require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
            if ($um->get_param('search_tag_id')) {
                $sm->article_list_params['search_options']['search_tag_id'] = $um->get_param('search_tag_id');
                $tag_list =& new Tags_list($sm);
                $tag =& $tag_list->get_tag_by_id($um->get_param('search_tag_id'));
            } else {
                $sm->article_list_params['search_options']['search_tag'] = $um->get_param('search_tag');
                $tag_list =& new Tags_list($sm);
                $tag =& $tag_list->get_tag_by_name($um->get_param('search_tag'));
            }
            if ($tag) {
                if (VIVVO_MODULES_FEED == 1) {
                    $header->add_rss(switch_format('rss', CURRENT_URL), $tag->name);
                }
                $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_TAG') . ': ' . $tag->name));
                if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . $um->get_param('force_template'))) {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . $um->get_param('force_template'));
                } else {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . VIVVO_TAG_LAYOUT);
                }
            } else {
                go_404();
            }
        }
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
        $template->assign('content_params', $sm->article_list_params);
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    } else {
        go_404();
    }
}
Пример #2
0
function default_header($sm = null)
{
    $sm != null or $sm = vivvo_lite_site::get_instance();
    define('VIVVO_JS_COMPRESOR', VIVVO_STATIC_URL . 'compress.php?js,');
    $header = $sm->get_header_manager();
    $header->add_script(VIVVO_URL . 'js/framework/prototype.js');
    $header->add_script(VIVVO_URL . 'js/control_tabs.js');
    $header->add_script(VIVVO_URL . 'js/functions.js');
    if (VIVVO_MODULES_FEED == 1) {
        $header->add_rss(switch_format('rss', VIVVO_ABSOLUTE_URL), VIVVO_WEBSITE_TITLE);
    }
    $sm->set_theme();
    if (file_exists(VIVVO_FS_THEME_ROOT . str_replace(VIVVO_URL, '', VIVVO_THEME) . '/css/compress.php')) {
        define('VIVVO_CSS_COMPRESOR', VIVVO_THEME . 'css/compress.php?css,');
    }
}
Пример #3
0
function article_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    if ($um->get_param('search_id')) {
        //Article page
        $id = $um->get_param('search_id');
        require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
        $al = Articles_list::factory();
        $sm->article = $al->get_article_by_id($id);
        if ($sm->article !== false) {
            $sm->set_categories();
            $category = $sm->categories->list[$sm->article->get_category_id()];
            if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $um->get_param('force_template'))) {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $um->get_param('force_template'));
            } else {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $category->get_article_template());
            }
            // 1. is user and is admin
            // 2. is user and can read article category
            // 3. guest and can read article category
            if ($sm->user && ($sm->user->is_admin() || $sm->user->can('READ', 'Categories', $category->id)) || !$sm->user && $sm->guest_group && $sm->guest_group->can('READ', 'Categories', $category->id)) {
                if (!defined('VIVVO_ADMIN_MODE')) {
                    if (($sm->article->status == 0 || strtotime($sm->article->created) > VIVVO_START_TIME) && !($sm->user && $sm->user->can('ACCESS_ADMIN'))) {
                        go_404();
                    }
                    $sm->article->on_display();
                }
                $template->assign('CURRENT_CATEGORY', $category);
                if (isset($sm->article->author_obj)) {
                    $template->assign('CURRENT_AUTHOR', $sm->article->author_obj);
                }
                // revision view:
                // 1. both 'news' and 'rev' parameters must be passed trough GET
                // 2. 'news' parameter must be equal to 'search_id' parameter from url_manager
                // 3. user must have EDITOR privilege for this category, or be an author of article (with WRITE privilege)
                if (!empty($_GET['news']) and $_GET['news'] == $sm->article->get_id() and !empty($_GET['rev']) and $sm->user and ($sm->user->is('EDITOR', 'Categories', $category->get_id()) or count($sm->user->get_privilege_object_ids('WRITE', 'Categories')) and $sm->user->get_id() == $sm->article->get_user_id())) {
                    class_exists('ArticlesRevisions') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/ArticlesRevisions.class.php');
                    $revision = ArticlesRevisions_list::factory()->get_revision_by_article_id_ver($sm->article->get_id(), $_GET['rev'] << 0);
                    if ($revision) {
                        $sm->article->set_title($revision->get_title());
                        $sm->article->set_abstract($revision->get_abstract());
                        $sm->article->set_body($revision->get_body());
                    }
                }
                // end revision view
                // add this article to printed list
                $sm->printed_articles[] = $sm->article->get_id();
                $template->assign('article', $sm->article);
                if (!defined('VIVVO_ADMIN_MODE')) {
                    if (VIVVO_MODULES_FEED == 1) {
                        $header->add_rss(switch_format('rss', CURRENT_URL), $sm->article->get_title());
                        if (VIVVO_FRIENDY_URL) {
                            $header->add_rss(switch_format('rss', VIVVO_URL . $category->get_href()), $category->category_name);
                        } else {
                            $header->add_rss(switch_format('rss', $category->get_href()), $category->category_name);
                        }
                    }
                    $sm->page_title = $sm->article->get_title();
                    if ($um->isset_param('print')) {
                        $sm->set_theme($category->get_css(), true);
                    } else {
                        $sm->set_theme($category->get_css());
                    }
                }
                $sm->_template->assign('PAGE_TITLE', strval($sm->article->title));
                $um->set_param('search_cid', $category->id);
            } else {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
                $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_RESTRICTED_ACCESS')));
                $content_template = new template($sm, $template);
                $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/restricted.tpl');
                $template->assign_template('PAGE_CONTENT', $content_template);
            }
        } else {
            go_404();
        }
    } else {
        go_404();
    }
}
Пример #4
0
function category_content_handler(&$sm)
{
    $template =& $sm->get_template();
    $header =& $sm->get_header_manager();
    $categories =& $sm->get_categories();
    $um =& $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    //Article list page
    $cur_page = (int) $um->get_param('pg');
    if (empty($cur_page)) {
        $cur_page = 1;
    }
    $sm->article_list_params['search_options'] = array();
    //Category page
    $category =& $categories->get_category($um->get_param('search_cid'));
    if ($category->redirect) {
        header('Location:' . $category->redirect);
        exit;
    }
    if ($category) {
        $sm->article_list_params['search_options']['search_cid'] = $um->get_param('search_cid');
        if (VIVVO_MODULES_FEED == 1) {
            $header->add_rss(switch_format('rss', CURRENT_URL), $category->category_name);
        }
        define('VIVVO_CURENT_CATEGORY', $um->get_param('search_cid'));
        $template->assign('CURRENT_CATEGORY', $category);
        if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $um->get_param('force_template'))) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $um->get_param('force_template'));
        } else {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $category->get_template());
        }
        $sm->article_list_params['search_limit'] = $category->article_num;
        $template->assign('PAGE_TITLE', strval($category->get_category_name()));
        $sm->set_theme($category->get_css());
    } else {
        go_404();
    }
    if (empty($sm->article_list_params['search_limit'])) {
        $sm->article_list_params['search_limit'] = 10;
    }
    $sm->article_list_params['pg'] = $cur_page;
    $sm->article_list_params['offset'] = ($cur_page - 1) * $sm->article_list_params['search_limit'];
    if ($um->isset_param('search_sort_by')) {
        $sm->article_list_params['search_sort_by'] = $um->get_param('search_sort_by');
    }
    if ($um->isset_param('search_order')) {
        $sm->article_list_params['search_order'] = $um->get_param('search_order');
    }
    if (empty($sm->article_list_params['search_sort_by'])) {
        $sm->article_list_params['search_sort_by'] = 'order_num';
        $sm->article_list_params['search_order'] = 'descending';
    } else {
        if (empty($sm->article_list_params['search_order'])) {
            $sm->article_list_params['search_order'] = 'ascending';
        }
    }
    if (!defined('VIVVO_ADMIN_MODE')) {
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
    }
    $template->assign('content_params', $sm->article_list_params);
    if (isset($sm->article_list_params['search_options'])) {
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    }
}
Пример #5
0
function author_content_handler(&$sm)
{
    $template =& $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header =& $sm->get_header_manager();
    $um =& $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $sm->article_list_params = Articles_list::get_search_params_from_url($sm);
    $sm->article_list_params['search_options'] = array();
    if (VIVVO_MODULES_FEATURED_AUTHOR_PAGE == 1 && ($um->isset_param('show_authors') || $um->get_param('search_user_id') && !$um->get_param('search_do_advanced'))) {
        if ($um->isset_param('show_authors')) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
            $content_template = new template($sm, $template);
            $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/authors_page.tpl');
            $template->assign_template('PAGE_CONTENT', $content_template);
            $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_AUTHORS')));
        } else {
            $user_manager =& $sm->get_user_manager();
            $user_list =& $user_manager->get_user_list($sm);
            $user_list_a =& $user_list->get_user_by_id($um->get_param('search_user_id'));
            if ($user_list_a) {
                $sm->article_list_params['search_options']['search_user_id'] = $user_list_a->get_id();
                if ($um->get_param('search_by_year')) {
                    $sm->article_list_params['search_options']['search_by_year'] = $um->get_param('search_by_year');
                }
                if ($um->get_param('search_by_month')) {
                    $sm->article_list_params['search_options']['search_by_month'] = $um->get_param('search_by_month');
                }
                if ($um->get_param('search_by_year')) {
                    $sm->article_list_params['search_limit'] = 200;
                }
                $template->assign('CURRENT_AUTHOR', $user_list_a);
                $template->assign('PAGE_TITLE', strval($user_list_a->get_name()));
                if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/' . $um->get_param('force_template'))) {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/' . $um->get_param('force_template'));
                } else {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/default.tpl');
                }
                if (VIVVO_MODULES_FEED == 1) {
                    $header->add_rss(switch_format('rss', CURRENT_URL), $user_list_a->get_name());
                }
            } else {
                go_404();
            }
        }
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
        $template->assign('content_params', $sm->article_list_params);
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    } else {
        go_404();
    }
}