コード例 #1
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function topic_list(MyTPL $tpl, $att_list = array())
    {
        global $setting;
        $result = "";
        if (!isset($att_list['order'])) {
            $att_list['order'] = "id desc";
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 10;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        if (!isset($att_list['condition'])) {
            $att_list['condition'] = "";
        }
        if (!isset($att_list['show_date'])) {
            $att_list['show_date'] = "";
        }
        if (!empty($att_list['show_date']) && date($att_list['show_date']) == $att_list['show_date']) {
            $att_list['show_date'] = "Y-m-d";
        }
        $sql = $db->buildSel($setting['db']['pre'] . "topic", "topic_id as id, topic_name as subject, topic_idx, topic_link, add_date", "", $att_list);
        $content = $tpl->Get_TPL(dirname(__FILE__) . "/tpl/block_news_" . $att_list['template'] . ".tpl", dirname(__FILE__) . "/tpl/block_news_classic.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "news_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $result = <<<mytpl
<?php
\$result = getData("{$sql}", "all", 86400);
for(\$n=0,\$m=count(\$result); \$n<\$m; \$n++) {
\t\$record = \$result[\$n];
\tHtmlTrans(&\$record);
\tif(empty(\$record['topic_link'])) {
\t\t\$record['link'] = getUrl("topic", \$record['topic_idx']);
\t} else {
\t\t\$record['link'] = \$record['topic_link'];
\t}
\t\$record['add_date'] = ("{$att_list['show_date']}"!="") ? date("{$att_list['show_date']}", strtotime(\$record['add_date'])) : "";
\t\$record['catalog'] = "";
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
for(; \$n<{$att_list['loop']}; \$n++) {
\t\$unit = str_replace("style=\\"\\"", "style=\\"".(\$n%2?"{$att_list['css1']}":"{$att_list['css2']}")."\\"", "{$unit_blank}");
\techo \$unit;
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $content);
        return $result;
    }
コード例 #2
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function news_mark(MyTPL $tpl, $att_list = array())
    {
        global $setting;
        $result = "";
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        if (!isset($att_list['web_id'])) {
            $att_list['web_id'] = "";
        }
        if (!isset($att_list['cat_id'])) {
            $att_list['cat_id'] = "";
        }
        if (!isset($att_list['css1'])) {
            $att_list['css1'] = "";
        }
        if (!isset($att_list['css2'])) {
            $att_list['css2'] = $att_list['css1'];
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 10;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['type'])) {
            $att_list['type'] = "jump";
        }
        if (!isset($att_list['time'])) {
            $att_list['time'] = 7;
        }
        $att_list['time'] *= 60 * 60 * 24;
        $the_order = array();
        $condition = array();
        if (!empty($att_list['web_id'])) {
            $condition[] = array("web_id", "n=", $att_list['web_id']);
        }
        if (!empty($att_list['cat_id'])) {
            $condition[] = array("cat_id", "nin", $att_list['cat_id']);
        }
        if ($att_list['type'] == "jump") {
            $condition[] = array("jump_time", "f>", "UNIX_TIMESTAMP()-" . $att_list['time']);
            $the_order[] = "jump desc";
        } else {
            $condition[] = array("rank_time", "f>", "UNIX_TIMESTAMP()-" . $att_list['time']);
            $the_order[] = "rank_total/rank_times desc";
        }
        $the_order[] = "news_id desc";
        $sql = $db->buildSel($setting['db']['pre'] . "news_mark", "*", $condition, array("order" => $the_order, "limit" => $att_list['limit']));
        $cur_content = $tpl->Get_TPL($tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_{$att_list['template']}.tpl", $tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_classic.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "news_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $result = <<<mytpl
<?php
global \$plugin_setting;
\$n = 0;
\$result = getData("{$sql}", "all", \$plugin_setting['offical']['ct_news']);
\$max_count = count(\$result);
for(\$num=0; \$num<\$max_count; \$num++) {
\t\$record = \$result[\$num];
\t\$record['subject_org'] = htmlspecialchars(\$record['subject']);
\tHtmlTrans(&\$record);
\t\$record['style'] = \$n++%2 ? "{$att_list['css1']}" : "{$att_list['css2']}";
\t\$cat_info = getParaInfo("news_cat", "cat_id", \$record['cat_id']);
\tif(empty(\$record['link'])) \$record['link'] = getUrl("read", array(\$record['news_id'], (\$cat_info?\$cat_info['cat_idx']:"")), 1, \$record['web_id']);
\t\$record['add_date'] = "";
\t\$record['catalog'] = "";
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
for(; \$n<{$att_list['loop']}; \$n++) {
\t\$unit = str_replace("style=\\"\\"", "style=\\"".(\$n%2?"{$att_list['css1']}":"{$att_list['css2']}")."\\"", "{$unit_blank}");
\techo \$unit;
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }
コード例 #3
0
ファイル: class.php プロジェクト: laiello/mystep-cms
 public static function parse_include(MyTPL $tpl, $att_list = array())
 {
     $result = "";
     if (isset($att_list['file'])) {
         if (file_exists($att_list['file'])) {
             $result = $tpl->GetFile($att_list['file']);
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function comment(MyTPL $tpl, $att_list = array())
    {
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        $content = $tpl->Get_TPL(dirname(__FILE__) . "/tpl/comment_{$att_list['template']}.tpl");
        if (isset($att_list['news_id'])) {
            $content = str_replace("<!--news_id-->", $att_list['news_id'], $content);
        } else {
            $content = str_replace("<!--news_id-->", "<?=\$GLOBALS['news_id']?>", $content);
        }
        if (isset($att_list['web_id'])) {
            $content = str_replace("<!--web_id-->", $att_list['web_id'], $content);
        } else {
            $content = str_replace("<!--web_id-->", "<?=\$setting['info']['web']['web_id']?>", $content);
        }
        $content = str_replace("<!--comment_page_size-->", "<?=\$comment_page_size?>", $content);
        $script .= <<<mystep
<?php
global \$req, \$plugin_setting;
\$req->setCookie("comment_check_".\$GLOBALS['news_id'], md5(date("Y-m-d")), 86400);
\$comment_page_size = \$plugin_setting['comment']['page_size'];
?>
mystep;
        return $script . $content;
    }
コード例 #5
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function parse_news(MyTPL $tpl, $att_list = array())
    {
        global $setting, $db;
        $result = "";
        if (!isset($att_list['template'])) {
            $att_list['template'] = "classic";
        }
        if (!isset($att_list['web_id'])) {
            $att_list['web_id'] = $setting['info']['web']['web_id'];
        }
        if (!isset($att_list['cat_id'])) {
            $att_list['cat_id'] = "";
        }
        if (!isset($att_list['css1'])) {
            $att_list['css1'] = "";
        }
        if (!isset($att_list['css2'])) {
            $att_list['css2'] = $att_list['css1'];
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 10;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['during'])) {
            $att_list['during'] = "year";
        }
        switch ($att_list['during']) {
            case "day":
                $att_list['order'] = "day_count desc";
                break;
            case "week":
                $att_list['order'] = "week_count desc";
                break;
            case "month":
                $att_list['order'] = "month_count desc";
                break;
            default:
                $att_list['order'] = "year_count desc";
                break;
        }
        $att_list['order'] .= ", news_id desc";
        $condition = array();
        if (!empty($att_list['web_id'])) {
            $condition[] = array("web_id", "nin", $att_list['web_id']);
        }
        if (!empty($att_list['cat_id'])) {
            $condition[] = array("cat_id", "nin", $att_list['cat_id']);
        }
        $sql = $db->buildSel($setting['db']['pre'] . "news_visit", "*", $condition, $att_list);
        $cur_content = $tpl->Get_TPL($tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_{$att_list['template']}.tpl", $tpl->tpl_info["path"] . "/" . $tpl->tpl_info["style"] . "/block_news_classic.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "news_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $result = <<<mytpl
<?php
global \$plugin_setting;
\$n = 0;
\$result = getData("{$sql}", "all", \$plugin_setting['offical']['ct_news']);
\$max_count = count(\$result);
for(\$num=0; \$num<\$max_count; \$num++) {
\t\$record = \$result[\$num];
\t\$record['subject_org'] = htmlspecialchars(\$record['subject']);
\tHtmlTrans(&\$record);
\t\$record['style'] = \$n++%2 ? "{$att_list['css1']}" : "{$att_list['css2']}";
\t\$cat_info = getParaInfo("news_cat", "cat_id", \$record['cat_id']);
\tif(empty(\$record['link'])) \$record['link'] = getUrl("read", array(\$record['news_id'], (\$cat_info?\$cat_info['cat_idx']:"")), 1, \$record['web_id']);
\t\$record['add_date'] = "";
\t\$record['catalog'] = "";
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
for(; \$n<{$att_list['loop']}; \$n++) {
\t\$unit = str_replace("style=\\"\\"", "style=\\"".(\$n%2?"{$att_list['css1']}":"{$att_list['css2']}")."\\"", "{$unit_blank}");
\techo \$unit;
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }
コード例 #6
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function tag_keyword(MyTPL $tpl, $att_list = array())
    {
        global $db, $setting;
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 10;
        }
        if (!isset($att_list['order'])) {
            $att_list['order'] = "chg_date";
        }
        $cur_content = $tpl->Get_TPL(dirname(__FILE__) . "/tpl/block_keyword.tpl");
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "keyword_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $sql = $db->buildSel($setting['db']['pre'] . "search_keyword", "keyword", array(array("amount", "n>", "0", "and"), array("chg_date", "f>", "UNIX_TIMESTAMP()-604800", "and"), array("length(keyword)", "n>", "4", "and"), array("length(keyword)", "n<", "30", "and")), array("order" => $att_list['order'], "limit" => $att_list['limit']));
        $result = <<<mytpl
<?php
\$result = getData("{$sql}", "all", 60*60*24);
for(\$num=0,\$m=count(\$result); \$num<\$m; \$num++) {
\t\$record = \$result[\$num];
\t\$record["encode"] = urlencode(\$record["keyword"]);
\t\$record["url"] = getUrl("search", \$record["keyword"]);
\tHtmlTrans(&\$record);
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
unset(\$result);
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }
コード例 #7
0
ファイル: class.php プロジェクト: laiello/mystep-cms
    public static function tag_list(MyTPL $tpl, $att_list = array())
    {
        global $setting, $db;
        $result = "";
        if (!isset($att_list['mid'])) {
            return "";
        }
        $mid = $att_list['mid'];
        if (!is_numeric($att_list['mid'])) {
            eval('$mid = "' . $mid . '";');
        }
        if (!isset($att_list['lng'])) {
            $att_list['lng'] = "cn";
        }
        if (!isset($att_list['order'])) {
            $att_list['order'] = "id desc";
        }
        if (!isset($att_list['limit'])) {
            $att_list['limit'] = 0;
        }
        if (!isset($att_list['loop'])) {
            $att_list['loop'] = 0;
        }
        if (!isset($att_list['condition'])) {
            $att_list['condition'] = "";
        }
        $sql = $db->buildSel($setting['db']['pre'] . "custom_form_" . $mid, "*", "", array("order" => $att_list['order'], "limit" => $att_list['limit'], "condition" => $att_list['condition']));
        $tpl_file = dirname(__FILE__) . "/setting/" . $mid . "_block_cf_list" . ($att_list['lng'] == "en" ? "_en" : "_cn") . ".tpl";
        $cur_content = $tpl->Get_TPL($tpl_file);
        preg_match("/" . preg_quote($tpl->delimiter_l) . "loop:start" . preg_quote($tpl->delimiter_r) . "(.*)" . preg_quote($tpl->delimiter_l) . "loop:end" . preg_quote($tpl->delimiter_r) . "/isU", $cur_content, $block_all);
        $block = $block_all[0];
        $unit = $block_all[1];
        $unit_blank = preg_replace("/" . preg_quote($tpl->delimiter_l) . ".*?" . preg_quote($tpl->delimiter_r) . "/is", "", $unit);
        $unit_blank = preg_replace("/<(td|li|p|dd|dt)([^>]*?)>.*?<\\/\\1>/is", "<\\1\\2>&nbsp;</\\1>", $unit_blank);
        $unit_blank = addslashes($unit_blank);
        $unit = preg_replace("/" . preg_quote($tpl->delimiter_l) . "cf_(\\w+)" . preg_quote($tpl->delimiter_r) . "/i", "{\$record['\\1']}", $unit);
        $result = <<<mytpl
<?php
\$db->Query("{$sql}");
while(\$record=\$db->getRS()) {
\tHtmlTrans(&\$record);
\tif("{$att_list['lng']}"=="cn" && \$record['name']=="") {
\t\t\$record['name'] = \$record['name_en'];
\t} elseif("{$att_list['lng']}"=="en") {
\t\t\$record['name_en'] = ucwords(strtolower(\$record['name_en']));
\t\tforeach(\$record as \$key => \$value) {
\t\t\t\$record[\$key] = itemTrans(\$value, \$key, 0, 1);
\t\t}
\t}
\techo <<<content
{$unit}
content;
\techo "\\n";
\tunset(\$record);
}
for(; \$n<{$att_list['loop']}-1; \$n++) {
\techo "{$unit_blank}";
\techo "\\n";
}
?>
mytpl;
        $result = str_replace($block, $result, $cur_content);
        return $result;
    }