예제 #1
0
if ($usr['id'] != $item['item_userid'] && (!$usr['isadmin'] || $cfg['folio']['count_admin'])) {
    $item['item_count']++;
    $db->update($db_folio, array('item_count' => $item['item_count']), "item_id=" . (int) $item['item_id']);
}
$title_params = array('TITLE' => empty($item['item_metatitle']) ? $item['item_title'] : $item['item_metatitle'], 'CATEGORY' => $structure['folio'][$item['item_cat']]['title']);
$out['subtitle'] = cot_title($cfg['folio']['title_folio'], $title_params);
$out['desc'] = !empty($item['item_metadesc']) ? $item['item_metadesc'] : cot_cutstring(strip_tags(cot_parse($item['item_text'], $cfg['folio']['markup'], $item['item_parser'])), 160);
$out['meta_keywords'] = !empty($item['item_keywords']) ? $item['item_keywords'] : $structure['folio'][$item['item_cat']]['keywords'];
// Building the canonical URL
$pageurl_params = array('c' => $item['item_cat']);
empty($al) ? $pageurl_params['id'] = $id : ($pageurl_params['al'] = $al);
$out['canonical_uri'] = cot_url('folio', $pageurl_params);
$mskin = cot_tplfile(array('folio', $structure['folio'][$item['item_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('folio.main') as $pl) {
    include $pl;
}
/* ===== */
$t = new XTemplate($mskin);
$t->assign(cot_generate_usertags($item, 'PRD_OWNER_'));
$t->assign(cot_generate_foliotags($item, 'PRD_', $cfg['folio']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
/* === Hook === */
foreach (cot_getextplugins('folio.tags') as $pl) {
    include $pl;
}
/* ===== */
if ($usr['isadmin']) {
    $t->parse('MAIN.PRD_ADMIN');
}
$t->parse('MAIN');
$module_body = $t->text('MAIN');
예제 #2
0
function cot_getfoliolist($template = 'index', $count = 5, $sqlsearch = '', $order = "item_date DESC")
{
    global $db, $db_folio, $cfg, $db_users;
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('folio', 'any', 'RWA');
    $t = new XTemplate(cot_tplfile(array('folio', $template), 'module'));
    $sqlsearch = !empty($sqlsearch) ? " AND " . $sqlsearch : '';
    $sqllist = $db->query("SELECT * FROM {$db_folio} AS p LEFT JOIN {$db_users} AS u ON u.user_id=p.item_userid\n\tWHERE item_state=0 {$sqlsearch} ORDER BY {$order} LIMIT " . (int) $count);
    $sqllist_rowset = $sqllist->fetchAll();
    $sqllist_idset = array();
    foreach ($sqllist_rowset as $item) {
        $sqllist_idset[$item['item_id']] = $item['item_alias'];
    }
    foreach ($sqllist_rowset as $item) {
        $jj++;
        $t->assign(cot_generate_usertags($item, 'PRD_ROW_OWNER_'));
        $t->assign(cot_generate_foliotags($item, 'PRD_ROW_', $cfg['folio']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
        $t->assign(array("PRD_ROW_ODDEVEN" => cot_build_oddeven($jj)));
        $t->parse("FOLIO.PRD_ROWS");
    }
    $t->parse("FOLIO");
    return $t->text("FOLIO");
}
예제 #3
0
    if (!empty($c) && isset($structure['folio'][$c])) {
        $mtch = $structure['folio'][$c]['path'] . ".";
        $mtchlen = mb_strlen($mtch);
        $catsub = array();
        $catsub[] = $c;
        foreach ($structure['folio'] as $i => $x) {
            if (mb_substr($x['path'], 0, $mtchlen) == $mtch) {
                $catsub[] = $i;
            }
        }
        $sqllist = $db->query("SELECT p.*, u.* FROM {$db_folio} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.item_userid = u.user_id\n\t\t\tWHERE item_state=0 AND item_cat IN ('" . implode("','", $catsub) . "') \n\t\t\tORDER BY item_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    } else {
        $sqllist = $db->query("SELECT p.*, u.* FROM {$db_folio} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.item_userid = u.user_id\n\t\t\tWHERE item_state=0 \n\t\t\tORDER BY item_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    }
    $i = 0;
    $sqllist_rowset = $sqllist->fetchAll();
    $sqllist_idset = array();
    foreach ($sqllist_rowset as $item) {
        $sqllist_idset[$item['item_id']] = $item['item_alias'];
    }
    foreach ($sqllist_rowset as $row) {
        $row['item_pageurl'] = empty($row['item_alias']) ? cot_url('folio', 'c=' . $row['item_cat'] . '&id=' . $row['item_id'], '', true) : cot_url('folio', 'c=' . $row['item_cat'] . '&al=' . $row['item_alias'], '', true);
        $items[$i]['title'] = $row['item_title'];
        $items[$i]['link'] = COT_ABSOLUTE_URL . $row['item_pageurl'];
        $items[$i]['pubDate'] = cot_date('r', $row['item_date']);
        $items[$i]['description'] = cot_parse($row['item_text']);
        $items[$i]['fields'] = cot_generate_foliotags($row);
        $i++;
    }
    $sqllist->closeCursor();
}
/**
 * Search by tag in folio
 *
 * @param string $query User-entered query string
 * @global CotDB $db
 */
function cot_tag_search_folio($query)
{
    global $db, $t, $L, $lang, $cfg, $usr, $qs, $d, $db_tag_references, $db_folio, $o, $row, $sys;
    if (!cot_module_active('folio')) {
        return;
    }
    $query = cot_tag_parse_query($query, 'f.item_id');
    if (empty($query)) {
        return;
    }
    $totalitems = $db->query("SELECT DISTINCT COUNT(*)\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_folio} AS f\n\t\t\tON r.tag_item = f.item_id\n\t\tWHERE r.tag_area = 'folio' AND ({$query}) AND f.item_state = 0")->fetchColumn();
    switch ($o) {
        case 'title':
            $order = 'ORDER BY `item_title`';
            break;
        case 'date':
            $order = 'ORDER BY `item_date` DESC';
            break;
        case 'category':
            $order = 'ORDER BY `item_cat`';
            break;
        default:
            $order = '';
    }
    /* == Hook == */
    foreach (cot_getextplugins('tags.search.folio.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT DISTINCT f.* {$join_columns}\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_folio} AS f\n\t\t\tON r.tag_item = f.item_id {$join_tables}\n\t\tWHERE r.tag_area = 'folio' AND ({$query}) AND f.item_id IS NOT NULL AND f.item_state = 0 {$join_where}\n\t\t{$order}\n\t\tLIMIT {$d}, {$cfg['maxrowsperpage']}");
    $t->assign('TAGS_RESULT_TITLE', $L['tags_Found_in_folio']);
    $pcount = $sql->rowCount();
    /* == Hook : Part 1 == */
    $extp = cot_getextplugins('tags.search.folio.loop');
    /* ===== */
    if ($pcount > 0) {
        foreach ($sql->fetchAll() as $row) {
            $tags = cot_tag_list($row['item_id'], 'folio');
            $tag_list = '';
            $tag_i = 0;
            foreach ($tags as $tag) {
                $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag;
                $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
                $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
                if ($tag_i > 0) {
                    $tag_list .= ', ';
                }
                $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'folio', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t));
                $tag_i++;
            }
            $t->assign(cot_generate_foliotags($row, 'TAGS_RESULT_ROW_'));
            $t->assign(array('TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['item_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_structure_buildpath('folio', $row['item_cat']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list));
            /* == Hook : Part 2 == */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_ROW');
        }
        $sql->closeCursor();
        $qs_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($qs) : $qs;
        $tl = $lang != 'en' && $qs_u != $qs ? 1 : null;
        $pagenav = cot_pagenav('plug', array('e' => 'tags', 'a' => 'folio', 't' => $qs_u, 'tl' => $tl), $d, $totalitems, $cfg['maxrowsperpage']);
        $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main']));
        /* == Hook == */
        foreach (cot_getextplugins('tags.search.folio.tags') as $pl) {
            include $pl;
        }
        /* ===== */
    }
    if ($pcount == 0) {
        $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_NONE');
    }
    $t->parse('MAIN.TAGS_RESULT');
}
    }
    $sqllist = $db->query("SELECT SQL_CALC_FOUND_ROWS f.* {$search_join_columns}\n\t\tFROM {$db_folio} AS f {$search_join_condition}\n\t\tWHERE {$where}\n\t\tORDER BY item_" . $rs['foliosort'] . " " . $rs['foliosort2'] . "\n\t\tLIMIT {$d}, " . $cfg_maxitems . $search_union_query);
    $items = $sqllist->rowCount();
    $totalitems[] = $db->query('SELECT FOUND_ROWS()')->fetchColumn();
    $jj = 0;
    $sqllist_rowset = $sqllist->fetchAll();
    $sqllist_idset = array();
    foreach ($sqllist_rowset as $item) {
        $sqllist_idset[$item['item_id']] = $item['item_alias'];
    }
    /* === Hook - Part 1 === */
    $extp = cot_getextplugins('folio.search.loop');
    /* ===== */
    foreach ($sqllist_rowset as $row) {
        $url_cat = cot_url('folio', 'c=' . $row['item_cat']);
        $url_folio = empty($row['item_alias']) ? cot_url('folio', 'c=' . $row['item_cat'] . '&id=' . $row['item_id'] . '&highlight=' . $hl) : cot_url('folio', 'c=' . $row['item_cat'] . '&al=' . $row['item_alias'] . '&highlight=' . $hl);
        $t->assign(cot_generate_foliotags($row, 'PLUGIN_FOLIORES_'));
        $t->assign(array('PLUGIN_FOLIORES_CATEGORY' => cot_rc_link($url_cat, $structure['folio'][$row['item_cat']]['tpath']), 'PLUGIN_FOLIORES_CATEGORY_URL' => $url_cat, 'PLUGIN_FOLIORES_TITLE' => cot_rc_link($url_folio, htmlspecialchars($row['item_title'])), 'PLUGIN_FOLIORES_TEXT' => cot_clear_mark($row['item_text'], $words), 'PLUGIN_FOLIORES_TIME' => cot_date('datetime_medium', $row['item_date']), 'PLUGIN_FOLIORES_TIMESTAMP' => $row['item_date'], 'PLUGIN_FOLIORES_ODDEVEN' => cot_build_oddeven($jj), 'PLUGIN_FOLIORES_NUM' => $jj));
        /* === Hook - Part 2 === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $t->parse('MAIN.RESULTS.FOLIO.ITEM');
        $jj++;
    }
    if ($jj > 0) {
        $t->parse('MAIN.RESULTS.FOLIO');
    }
    unset($where_and, $where_or, $where);
}