Example #1
0
function breadcrumbs()
{
    global $lang, $catz, $catmap, $template, $CurrentHandler, $config, $SYSTEM_FLAGS, $tpl, $systemAccessURL, $twig;
    $tpath = locatePluginTemplates(array('breadcrumbs'), 'breadcrumbs', pluginGetVariable('breadcrumbs', 'template_source'));
    $location = array();
    $location_last = '';
    # processing 404 page
    if ($SYSTEM_FLAGS['info']['title']['group'] == $lang['404.title']) {
        $link = str_replace(array('{home_url}', '{home_title}'), array($config['home_url'], $lang['bc:mainpage']), $lang['bc:page_404']);
        $location[] = array('url' => $config['home_url'], 'title' => $lang['bc:mainpage'], 'link' => $link);
        $location_last = $lang['404.title'];
    } else {
        if ($CurrentHandler) {
            $params = $CurrentHandler['params'];
            $pluginName = $CurrentHandler['pluginName'];
        }
        # generate main page with or without link
        $main_page = $systemAccessURL != '/' ? str_replace(array('{home_url}', '{home_title}'), array($config['home_url'], $lang['bc:mainpage']), $lang['bc:page_404']) : $lang['bc:mainpage'];
        $location[] = array('url' => $systemAccessURL != '/' ? $config['home_url'] : '', 'title' => $systemAccessURL != '/' ? $lang['bc:mainpage'] : $lang['bc:mainpage'], 'link' => $main_page);
        $location_last = $main_page;
        # if category
        if ($CurrentHandler['handlerName'] == 'by.category') {
            $location_last = GetCategories($catz[$params['category']]['id'], true);
            # show full path [if requested]
            if ($catz[$params['category']]['parent'] != 0 && !pluginGetVariable('breadcrumbs', 'block_full_path')) {
                $id = $catz[$params['category']]['parent'];
                do {
                    $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $catz[$params['category']]['alt'], 'catid' => $catz[$params['category']]['id'])), 'title' => $catz[$params['category']]['name'], 'link' => GetCategories($id, false));
                    $id = $catz[$catmap[$id]]['parent'];
                } while ($id != 0);
                $location = array_merge($location, array_reverse($location_tmp));
            }
        } elseif ($params['year']) {
            # if we have only year then $year = plain text, if we have month then $year = link
            $year = !$params['month'] ? $params['year'] : str_replace(array('{year_url}', '{year}'), array(generateLink('news', 'by.year', array('year' => $params['year'])), $params['year']), $lang['bc:by.year']);
            $month_p = LangDate("F", mktime(0, 0, 0, $params['month'], 7, 0));
            # if we have only year and month then $month = plain text, if we have day then $month = link
            $month = !$params['day'] ? $month_p : str_replace(array('{month_url}', '{month_p}'), array(generateLink('news', 'by.month', array('year' => $params['year'], 'month' => $params['month'])), $month_p), $lang['bc:by.month']);
            $day = $params['day'];
            $location_last = $year;
            if ($params['month']) {
                $location[] = array('url' => !$params['month'] ? '' : generateLink('news', 'by.year', array('year' => $params['year'])), 'title' => !$params['month'] ? $params['year'] : $params['year'], 'link' => $year);
                $location_last = $month;
            }
            if ($params['day']) {
                $location[] = array('url' => !$params['day'] ? '' : generateLink('news', 'by.month', array('year' => $params['year'], 'month' => $params['month'])), 'title' => !$params['day'] ? $month_p : $month_p, 'link' => $month);
                $location_last = $day;
            }
            # plugin, static, etc.
        } elseif ($pluginName != 'news') {
            if ($pluginName == "static") {
                $location_last = $SYSTEM_FLAGS['info']['title']['item'];
            } elseif ($pluginName == 'uprofile' && $CurrentHandler['handlerName'] == 'edit' || $pluginName == 'search') {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'];
            } elseif ($pluginName == 'uprofile' && $CurrentHandler['handlerName'] == 'show') {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'] . ' ' . $SYSTEM_FLAGS['info']['title']['item'];
            } elseif ($pluginName == 'core' && in_array($CurrentHandler['handlerName'], array('registration', 'lostpassword', 'login'))) {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'];
            } elseif ($params['plugin'] || $pluginName) {
                # if plugin provide put some info
                if ($SYSTEM_FLAGS['info']['breadcrumbs']) {
                    # plugin name becomes link
                    $count = count($SYSTEM_FLAGS['info']['breadcrumbs']) - 1;
                    # all items except last become links
                    for ($i = 0; $i < $count; $i++) {
                        $link = str_replace(array('{plugin_url}', '{plugin}'), array($SYSTEM_FLAGS['info']['breadcrumbs'][$i]['link'], $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text']), $lang['bc:plugin']);
                        $location[] = array('url' => $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['link'], 'title' => $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text'], 'link' => $link);
                    }
                    # last item becomes plain text
                    $location_last = $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text'];
                } else {
                    $link = str_replace(array('{plugin_url}', '{plugin}'), array(generatePluginLink($params['plugin'], '', array(), array(), false, true), $SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin'] ? $SYSTEM_FLAGS['info']['title']['group'] : $params['plugin']), $lang['bc:plugin']);
                    $location[] = array('url' => generatePluginLink($params['plugin'], '', array(), array(), false, true), 'title' => $SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin'] ? $SYSTEM_FLAGS['info']['title']['group'] : $params['plugin'], 'link' => $link);
                    if ($SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin']) {
                        $location_last = $SYSTEM_FLAGS['info']['title']['group'];
                    } else {
                        $location_last = $params['plugin'];
                    }
                }
            }
            # full news
        } elseif ($CurrentHandler['pluginName'] == 'news' && $CurrentHandler['handlerName'] == 'news') {
            $catids = $SYSTEM_FLAGS['news']['db.categories'];
            $location_last = $SYSTEM_FLAGS['info']['title']['item'];
            if (count($catids) != 1 || pluginGetVariable('breadcrumbs', 'block_full_path')) {
                if ($CurrentHandler['params']['category'] != 'none') {
                    foreach ($catids as $cid) {
                        foreach ($catz as $cc) {
                            if ($cc['id'] == $cid) {
                                $location[] = array('url' => generateLink('news', 'by.category', array('category' => $cc['alt'], 'catid' => $cc['id'])), 'title' => $cc['name'], 'link' => GetCategories($cc['id'], false));
                            }
                        }
                    }
                }
            } else {
                $id = $catz[$params['category']]['parent'];
                $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $catz[$params['category']]['alt'], 'catid' => $catz[$params['category']]['id'])), 'title' => $catz[$params['category']]['name'], 'link' => GetCategories($catz[$params['category']]['id'], false));
                while ($id != 0) {
                    foreach ($catz as $cc) {
                        if ($cc['id'] == $id) {
                            $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $cc['alt'], 'catid' => $cc['id'])), 'title' => $cc['name'], 'link' => GetCategories($cc['id'], false));
                            $id = $catz[$cc['alt']]['parent'];
                        }
                    }
                }
                $location = array_merge($location, array_reverse($location_tmp));
            }
        }
    }
    $tVars = array('location' => $location, 'location_last' => $location_last, 'separator' => $separator);
    $xt = $twig->loadTemplate($tpath['breadcrumbs'] . 'breadcrumbs.tpl');
    $template['vars']['breadcrumbs'] = $xt->render($tVars);
}
Example #2
0
function plugin_gsmg_screen()
{
    global $config, $mysql, $catz, $catmap, $SUPRESS_TEMPLATE_SHOW, $SYSTEM_FLAGS, $PFILTERS;
    $SUPRESS_TEMPLATE_SHOW = 1;
    $SUPRESS_MAINBLOCK_SHOW = 1;
    @header('Content-type: text/xml; charset=utf-8');
    $SYSTEM_FLAGS['http.headers'] = array('content-type' => 'application/xml; charset=charset=utf-8', 'cache-control' => 'private');
    if (extra_get_param('gsmg', 'cache')) {
        $cacheData = cacheRetrieveFile('gsmg.txt', extra_get_param('gsmg', 'cacheExpire'), 'gsmg');
        if ($cacheData != false) {
            // We got data from cache. Return it and stop
            print $cacheData;
            return;
        }
    }
    $output = '<?xml version="1.0" encoding="UTF-8"?>';
    $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
    // Настройки постранички
    if ($config['number'] < 1) {
        $config['number'] = 5;
    }
    // Надо ли выводить данные с головной страницы
    if (extra_get_param('gsmg', 'main')) {
        $output .= "<url>";
        $output .= "<loc>" . generateLink('news', 'main', array(), array(), false, true) . "</loc>";
        $output .= "<priority>" . floatval(extra_get_param('gsmg', 'main_pr')) . "</priority>";
        $lm = $mysql->record("select date(from_unixtime(max(postdate))) as pd from " . prefix . "_news");
        $output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
        $output .= "<changefreq>daily</changefreq>";
        $output .= "</url>";
        if (extra_get_param('gsmg', 'mainp')) {
            $cnt = $mysql->record("select count(*) as cnt from " . prefix . "_news");
            $pages = ceil($cnt['cnt'] / $config['number']);
            for ($i = 2; $i <= $pages; $i++) {
                $output .= "<url>";
                $output .= "<loc>" . generateLink('news', 'main', array('page' => $i), array(), false, true) . "</loc>";
                $output .= "<priority>" . floatval(extra_get_param('gsmg', 'mainp_pr')) . "</priority>";
                $output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
                $output .= "<changefreq>daily</changefreq>";
                $output .= "</url>";
            }
        }
    }
    // Надо ли выводить данные по категориям
    if (extra_get_param('gsmg', 'cat')) {
        foreach ($catmap as $id => $altname) {
            $output .= "<url>";
            $output .= "<loc>" . generateLink('news', 'by.category', array('category' => $altname, 'catid' => $id), array(), false, true) . "</loc>";
            $output .= "<priority>" . floatval(extra_get_param('gsmg', 'cat_pr')) . "</priority>";
            $output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
            $output .= "<changefreq>daily</changefreq>";
            $output .= "</url>";
            if (extra_get_param('gsmg', 'catp')) {
                $cn = $catz[$altname]['number'] > 0 ? $catz[$altname]['number'] : $config['number'];
                $pages = ceil($catz[$altname]['posts'] / $cn);
                for ($i = 2; $i <= $pages; $i++) {
                    $output .= "<url>";
                    $output .= "<loc>" . generateLink('news', 'by.category', array('category' => $altname, 'catid' => $id, 'page' => $i), array(), false, true) . "</loc>";
                    $output .= "<priority>" . floatval(extra_get_param('gsmg', 'catp_pr')) . "</priority>";
                    $output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
                    $output .= "<changefreq>daily</changefreq>";
                    $output .= "</url>";
                }
            }
        }
    }
    // Надо ли выводить данные по новостям
    if (extra_get_param('gsmg', 'news')) {
        $query = "select id, postdate, author, author_id, alt_name, editdate, catid from " . prefix . "_news where approve = 1 order by id desc";
        foreach ($mysql->select($query, 1) as $rec) {
            $link = newsGenerateLink($rec, false, 0, true);
            $output .= "<url>";
            $output .= "<loc>" . $link . "</loc>";
            $output .= "<priority>" . floatval(extra_get_param('gsmg', 'news_pr')) . "</priority>";
            $output .= "<lastmod>" . strftime("%Y-%m-%d", max($rec['editdate'], $rec['postdate'])) . "</lastmod>";
            $output .= "<changefreq>daily</changefreq>";
            $output .= "</url>";
        }
    }
    // Надо ли выводить данные по статическим страницам
    if (extra_get_param('gsmg', 'static')) {
        $query = "select id, alt_name from " . prefix . "_static where approve = 1";
        foreach ($mysql->select($query, 1) as $rec) {
            $link = generatePluginLink('static', '', array('altname' => $rec['alt_name'], 'id' => $rec['id']), array(), false, true);
            $output .= "<url>";
            $output .= "<loc>" . $link . "</loc>";
            $output .= "<priority>" . floatval(extra_get_param('gsmg', 'static_pr')) . "</priority>";
            $output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
            $output .= "<changefreq>weekly</changefreq>";
            $output .= "</url>";
        }
    }
    if (is_array($PFILTERS['gsmg'])) {
        foreach ($PFILTERS['gsmg'] as $k => $v) {
            $v->onShow($output);
        }
    }
    $output .= "</urlset>";
    print $output;
    cacheStoreFile('gsmg.txt', $output, 'gsmg');
}
Example #3
0
function _guestbook_records($order, $start, $perpage)
{
    global $mysql, $tpl, $userROW, $config, $parse;
    foreach ($mysql->select("SELECT * FROM " . prefix . "_guestbook WHERE status = 1 ORDER BY id {$order} LIMIT {$start}, {$perpage}") as $row) {
        if (pluginGetVariable('guestbook', 'usmilies')) {
            $row['message'] = $parse->smilies($row['message']);
        }
        if (pluginGetVariable('guestbook', 'ubbcodes')) {
            $row['message'] = $parse->bbcodes($row['message']);
        }
        $editlink = checkLinkAvailable('guestbook', 'edit') ? generatePluginLink('guestbook', 'edit', array('id' => $row['id']), array()) : generateLink('core', 'plugin', array('plugin' => 'guestbook', 'handler' => 'edit'), array('id' => $row['id']));
        $dellink = generateLink('core', 'plugin', array('plugin' => 'guestbook'), array('action' => 'delete', 'id' => $row['id']));
        $comnum++;
        // get fields
        $data = $mysql->select("select * from " . prefix . "_guestbook_fields");
        $fields = array();
        foreach ($data as $num => $value) {
            $fields[$value['id']] = $value['name'];
        }
        $comment_fields = array();
        foreach ($fields as $fid => $fname) {
            $comment_fields[$fid] = array('id' => $fid, 'name' => $fname, 'value' => $row[$fid]);
        }
        // set date format
        $date_format = pluginGetVariable('guestbook', 'date');
        if (empty($date_format)) {
            $date_format = 'j Q Y';
        }
        // get social data
        $social = unserialize($row['social']);
        $profiles = array();
        foreach ($social as $name => $id) {
            $img = $mysql->record("SELECT name, description FROM " . prefix . "_images WHERE id = {$id}");
            $profiles[$name] = array('photo' => $config['images_url'] . '/' . $img['name'], 'link' => $img['description']);
        }
        $comments[] = array('id' => $row['id'], 'date' => LangDate($date_format, $row['postdate']), 'message' => $row['message'], 'answer' => $row['answer'], 'author' => $row['author'], 'ip' => $row['ip'], 'comnum' => $comnum, 'edit' => $editlink, 'del' => $dellink, 'fields' => $comment_fields, 'social' => $profiles);
    }
    return $comments;
}