예제 #1
0
 // set frontend edit link
 if ($content['article_frontend_edit']) {
     $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
 }
 // include content part code section
 if ($crow["acontent_type"] != 30) {
     include PHPWCMS_ROOT . "/include/inc_front/content/cnt" . $crow["acontent_type"] . ".article.inc.php";
 } elseif ($crow["acontent_type"] == 30 && is_file($phpwcms['modules'][$crow["acontent_module"]]['path'] . 'inc/cnt.article.php')) {
     if ($content['article_frontend_edit']) {
         $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name'], $crow['acontent_aid']);
     }
     // now try to include module content part code
     include $phpwcms['modules'][$crow["acontent_module"]]['path'] . 'inc/cnt.article.php';
 }
 // check if top link should be shown
 $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
 // Space after
 if ($crow["acontent_after"]) {
     if (!empty($template_default["article"]["div_spacer"])) {
         $CNT_TMP .= '<div style="margin-bottom:' . $crow["acontent_after"] . 'px;" class="' . $template_default['classes']['spaceholder-cp-after'] . '"></div>';
     } else {
         $CNT_TMP .= '<br class="' . $template_default['classes']['spaceholder-cp-after'] . '" />' . spacer(1, $crow["acontent_after"]);
     }
 }
 // Maybe content part ID should b used inside templates or for something different
 $CNT_TMP = str_replace(array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP);
 // trigger content part functions
 $CNT_TMP = trigger_cp($CNT_TMP, $crow);
 //check if PHP replacent tags are allowed for content
 if (empty($phpwcms["allow_cntPHP_rt"])) {
     $CNT_TMP = remove_unsecure_rptags($CNT_TMP);
예제 #2
0
function showSelectedContent($param = '', $cpsql = null, $listmode = false)
{
    global $template_default;
    global $db;
    global $content;
    global $block;
    global $phpwcms;
    global $aktion;
    $topcount = 999999;
    $template = '';
    $param = is_array($param) && isset($param[1]) ? $param[1] : $param;
    $type = null;
    $mode = null;
    $related_type = 'OR';
    $where = '';
    $not = array();
    if ($cpsql === null) {
        if ($cp = explode(',', $param)) {
            $mode = strtoupper(trim($cp[0]));
            $type = substr($mode, 0, 2);
            if ($type === 'AS') {
                $mode = explode('|', $cp[0]);
                if (isset($mode[1])) {
                    $mode[1] = trim($mode[1]);
                    if (is_numeric($mode[1])) {
                        $topcount = intval($mode[1]);
                    } elseif (empty($mode[2]) && strlen($mode[1]) > 4 && ($mode[1] == 'default' || is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/articlesummary/list/' . $mode[1]))) {
                        $template = $mode[1];
                    }
                }
                if (isset($mode[2])) {
                    $mode[2] = trim($mode[2]);
                    if (is_numeric($mode[2])) {
                        $topcount = intval($mode[2]);
                    } elseif (strlen($mode[2]) > 4 && ($mode[2] == 'default' || is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/articlesummary/list/' . $mode[2]))) {
                        $template = $mode[2];
                    }
                }
                $mode = strtoupper(trim($mode[0]));
                if (isset($cp[1])) {
                    // now check if
                    $cp[1] = trim($cp[1]);
                    if (!is_numeric($cp[1])) {
                        $cp[1] = explode('|', $cp[1], 2);
                        // Check for OR or AND
                        if (isset($cp[1][1])) {
                            $related_type = strtoupper(trim($cp[1][1]));
                            if ($related_type !== 'AND' && $related_type !== 'OR') {
                                $related_type = 'OR';
                            }
                        }
                        $cp[1] = trim($cp[1][0]);
                        switch ($cp[1]) {
                            case 'random':
                                $where = 'RANDOM';
                                break;
                            case 'related':
                                if (isset($cp[2])) {
                                    unset($cp[0], $cp[1]);
                                    $related = array();
                                    foreach ($cp as $value) {
                                        $related[] = "article_keyword LIKE " . _dbEscape(strtoupper(trim($value)), true, '%', '%');
                                    }
                                    if (count($related)) {
                                        $where = '(' . implode(' ' . $related_type . ' ', $related) . ')';
                                    }
                                }
                                break;
                            case 'new':
                            default:
                                $where = 'NEW';
                                break;
                        }
                        $not[] = $aktion[1];
                        $cp = array();
                    }
                }
            }
            if (count($cp)) {
                unset($cp[0]);
                foreach ($cp as $key => $value) {
                    $value = intval($value);
                    if (!$value) {
                        unset($cp[$key]);
                    } else {
                        $cp[$key] = $value;
                    }
                }
                if (!count($cp)) {
                    return '';
                }
            }
        } else {
            // oh no ID given, end function
            return '';
        }
    } elseif (is_string($cpsql)) {
        // Otherwise custom SQL
        // and fallback to CPC mode
        $type = 'CP';
        $mode = 'CPC';
        $cp = array(0);
    }
    $CNT_TMP = '';
    // Article Mode
    if ($type === 'AS') {
        if (substr($mode, -1) == 'P') {
            $mode = substr($mode, 0, -1);
            $priorize = 'article_priorize DESC, ';
        } else {
            $priorize = '';
        }
        switch ($mode) {
            case 'ASL':
                $sort = $priorize . 'article_begin ASC';
                break;
                // sorted by livedate ascending
            // sorted by livedate ascending
            case 'ASLD':
                $sort = $priorize . 'article_begin DESC';
                break;
                // sorted by livedate descending
            // sorted by livedate descending
            case 'ASK':
                $sort = $priorize . 'article_end ASC';
                break;
                // sorted by killdate ascending
            // sorted by killdate ascending
            case 'ASKD':
                $sort = $priorize . 'article_end DESC';
                break;
                // sorted by killdate descending
            // sorted by killdate descending
            case 'ASC':
                $sort = $priorize . 'article_tstamp ASC';
                break;
                // sorted by change date ascending
            // sorted by change date ascending
            case 'ASCD':
                $sort = $priorize . 'article_tspamp DESC';
                break;
                // sorted by change date descending
            // sorted by change date descending
            case 'AST':
                $sort = $priorize . 'article_keyword ASC';
                break;
                // sorted by keyword ascending
            // sorted by keyword ascending
            case 'ASTD':
                $sort = $priorize . 'article_keyword DESC';
                break;
                // sorted by keyword descending
            // sorted by keyword descending
            case 'ASR':
                $sort = 'RAND()';
                break;
                // random sort
            // random sort
            default:
                $sort = '';
        }
        $CNT_TMP = list_articles_summary(get_article_data($cp, $topcount, $sort, $where, $not), $topcount, $template);
        // Content Part mode CP, CPA, CPAD, CPS, CPAS, CPASD
    } elseif ($type === 'CP') {
        $sort = $mode == 'CPAD' || $mode == 'CPASD' ? ' DESC' : '';
        //means ASCENDING
        foreach ($cp as $value) {
            if ($mode == 'CP') {
                // content part listing
                $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent ";
                $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON ";
                $sql .= DB_PREPEND . "phpwcms_article.article_id=" . DB_PREPEND . "phpwcms_articlecontent.acontent_aid ";
                $sql .= "WHERE acontent_id=" . $value . " AND acontent_visible=1 ";
                $sql .= "AND acontent_block NOT IN ('CPSET', 'SYSTEM') ";
                if (!FEUSER_LOGIN_STATUS) {
                    $sql .= 'AND acontent_granted=0 ';
                }
                $sql .= "AND acontent_trash=0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 ";
                if (!PREVIEW_MODE) {
                    $sql .= ' AND ' . DB_PREPEND . "phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() ";
                }
                $sql .= "LIMIT 1";
            } elseif ($mode == 'CPS') {
                $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent ";
                $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON ";
                $sql .= DB_PREPEND . "phpwcms_article.article_id=" . DB_PREPEND . "phpwcms_articlecontent.acontent_aid ";
                $sql .= "WHERE acontent_id=" . $value . " AND acontent_visible=1 ";
                $sql .= "AND acontent_block='SYSTEM' ";
                if (!FEUSER_LOGIN_STATUS) {
                    $sql .= 'AND acontent_granted=0 ';
                }
                $sql .= "AND acontent_trash=0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 ";
                if (!PREVIEW_MODE) {
                    $sql .= ' AND ' . DB_PREPEND . "phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() ";
                }
                $sql .= "LIMIT 1";
            } elseif ($mode == 'CPC') {
                $sql = $cpsql;
            } else {
                // content parts based on article ID
                $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent ";
                $sql .= "WHERE acontent_aid=" . $value . " AND acontent_visible=1 AND acontent_trash=0 ";
                if ($mode == 'CPAS' || $mode == 'CPASD') {
                    $sql .= "AND acontent_block='SYSTEM' ";
                } else {
                    $sql .= "AND acontent_block NOT IN ('CPSET', 'SYSTEM') ";
                }
                if (!FEUSER_LOGIN_STATUS) {
                    $sql .= 'AND acontent_granted=0 ';
                }
                $sql .= "ORDER BY acontent_sorting" . $sort . ", acontent_id";
            }
            if (!empty($sql) && ($cresult = mysql_query($sql, $db))) {
                while ($crow = mysql_fetch_assoc($cresult)) {
                    if ($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]])) {
                        continue;
                    }
                    if ($crow["acontent_type"] == 24) {
                        // first retrieve alias ID information and settings
                        $crow = getContentPartAlias($crow);
                        if ($crow === false) {
                            continue;
                        }
                    }
                    // Set listmode setting, allows fallback listmode content part template
                    // for content parts which supports it (ToDo extend it)
                    $crow['acontent_template_listmode'] = $listmode;
                    $space = getContentPartSpacer($crow["acontent_before"], $crow["acontent_after"]);
                    // Space before
                    $CNT_TMP .= $space['before'];
                    // set frontend edit link
                    $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']);
                    // include content part code section
                    if ($crow["acontent_type"] != 30) {
                        include PHPWCMS_ROOT . '/include/inc_front/content/cnt' . $crow["acontent_type"] . '.article.inc.php';
                    } elseif ($crow["acontent_type"] == 30 && file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'] . 'inc/cnt.article.php')) {
                        $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name'], $crow['acontent_aid']);
                        // now try to include module content part code
                        include $phpwcms['modules'][$crow["acontent_module"]]['path'] . 'inc/cnt.article.php';
                    }
                    //check if top link should be shown
                    $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]);
                    //Maybe content part ID should b used inside templates or for something different
                    $CNT_TMP = str_replace(array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP);
                    // trigger content part functions
                    $CNT_TMP = trigger_cp($CNT_TMP, $crow);
                    // Space after
                    $CNT_TMP .= $space['after'];
                }
                mysql_free_result($cresult);
            }
        }
    }
    if (empty($phpwcms["allow_cntPHP_rt"]) || empty($phpwcms['enable_inline_php'])) {
        $CNT_TMP = remove_unsecure_rptags($CNT_TMP);
    }
    return trim($CNT_TMP);
}