Example #1
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
function smarty_block_quote($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "quote";
    }
    if (class_exists("Quotes")) {
        $quote = new Quotes();
        $quote_controller = new Quote();
    } else {
        uses("quote");
        $quote = new Quotes();
        $quote_controller = new Quote();
    }
    if (!empty($params['productid'])) {
        $conditions[] = "q.product_id='" . intval($params['productid']) . "'";
    }
    if (!empty($params['marketid'])) {
        $conditions[] = "q.market_id=" . $params['marketid'];
    }
    if (!empty($params['areaid'])) {
        $conditions[] = "q.area_id='" . $params['areaid'] . "'";
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC ";
    }
    $quote->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $quote->setLimitOffset($offset, $limit);
    $sql = "SELECT id,title,content,max_price,min_price,created FROM {$quote->table_prefix}quotes q " . $quote->getCondition() . "{$orderby}" . $quote->getLimitOffset();
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $quote->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $url = $quote->getPermaLink($item['id'], 'market/quote.php');
        $item['url'] = $url;
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['pubdate'] = @date("m/d", $item['created']);
        $item['link'] = '<a title="' . $item['title'] . '" href="' . $url . '">' . $item['title'] . '</a>';
        $smarty->assign($params['name'], $item);
    } else {
        $repeat = false;
        reset($smarty->blockvars[$param_count]);
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $smarty->blockvars[$param_count] = array();
    }
}
Example #2
0
            }
            $info = $pdb->GetRow("SELECT * FROM " . $tb_prefix . "quotes WHERE id=" . $id);
            $pdb->Execute("UPDATE " . $tb_prefix . "quotes SET hits=hits+1 WHERE id=" . $id);
            $info['pubdate'] = df($info['created']);
            $info['clicked'] = $info['hits'];
            setvar("item", $info);
            $tpl_file = "detail.default";
            render($tpl_file, true);
            break;
        case "search":
            if (!empty($_GET['title'])) {
                $conditions[] = "title LIKE '%" . pb_addslashes($_GET['title']) . "%'";
            }
            break;
        default:
            break;
    }
}
if (isset($_GET['catid'])) {
    $type_id = intval($_GET['catid']);
    $conditions[] = "Quote.type_id='" . $type_id . "'";
    $viewhelper->setTitle("The industry " . $type_id);
}
$quote->setCondition($conditions);
$amount = $quote->findCount(null, $conditions);
$fields = "Quote.*,Quote.created AS pubdate,ROUND((Quote.min_price+Quote.max_price)/2,2) AS price";
$result = $quote->findAll($fields, $joins, $conditions, "Quote.id DESC", $pos, $limit);
setvar("items", $result);
uaAssign(array("QuoteSearchFrom" => date("Y-m-d", strtotime("last month")), "QuoteSearchTo" => date("Y-m-d")));
setvar("paging", array('total' => $amount));
render($tpl_file);