예제 #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_getdata($params, $content, Smarty_Internal_Template $sTemplate, &$repeat)
{
    $conditions = $orderbys = array();
    $mysql_limit = $mysql_orderby = $image_col = $_seperate = '';
    $target = "_blank";
    extract($params);
    if (!isset($params['assign'])) {
        $assign = 'row';
    }
    if (!empty($params['name'])) {
        $assign = trim($params['name']);
    }
    $C = new PbController();
    $M = new PbModel();
    $M->condition = '';
    //Initial any last conditions
    $_table = $params['module'];
    switch ($params['module']) {
        case "offer":
        case "trade":
            $_table = "trade";
            break;
        case "fair":
        case "expo":
            $_table = "expo";
            break;
        case "announce":
            $_table = "announcement";
            break;
        case "ads":
            $_table = "adses";
            break;
        case "adword":
            $_table = "spread";
            break;
        case "price":
            $_table = "productprice";
            break;
        case "adses":
            break;
        default:
            break;
    }
    if (method_exists($sTemplate, 'get_template_vars')) {
        $_bindex = $sTemplate->getTemplateVars('_bindex');
    } else {
        $_bindex = $sTemplate->getVariable('_bindex')->value;
    }
    if (!$_bindex) {
        $_bindex = array();
    }
    if (isset($params['name'])) {
        if (!isset($_bindex[$params['name']])) {
            $_bindex[$params['name']] = 1;
        } else {
            $_bindex[$params['name']]++;
        }
    }
    $sTemplate->assign('_bindex', $_bindex);
    if (!isset($sTemplate->block_data)) {
        $sTemplate->block_data = array();
    }
    $iTags = count($sTemplate->_tag_stack);
    /**
     * set condition
     */
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    if (isset($_GET['pos'])) {
        $_pos = intval($_GET['pos']);
        $offset = ceil($_pos / $limit) * $row;
    }
    if (!empty($params['flag'])) {
        $conditions[] = "flag='" . $params['flag'] . "'";
    }
    if ($_table == "industry" or $_table == "area") {
        if (isset($params['parentid'])) {
            if (!empty($params['parentid'])) {
                $conditions['parentid'] = "parent_id='" . intval($params['parentid']) . "' OR id=" . intval($params['parentid']);
            } else {
                $conditions['parentid'] = "parent_id=0";
            }
        } else {
            $conditions['parentid'] = "parent_id=0";
        }
    }
    if (!empty($params['level'])) {
        if ($_table == "newstype") {
            $conditions[] = "level_id='" . $params['level'] . "'";
        } else {
            $conditions[] = "level='" . $params['level'] . "'";
        }
    }
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    if ($module == "friendlink") {
                        $image_col = "logo";
                    } else {
                        $image_col = "picture";
                    }
                    $conditions[] = "{$image_col}!=''";
                    break;
                case 'hot':
                    $orderbys[] = "hits DESC";
                    break;
                case 'commend':
                    $conditions[] = "if_commend='1'";
                    break;
                default:
                    break;
            }
        }
    }
    if (isset($params['exclude'])) {
        $conditions[] = $M->getExcludeIds($params['exclude']);
    }
    if (isset($params['include'])) {
        $conditions[] = $M->getIncludeIds($params['include']);
    }
    if (isset($params['orderby'])) {
        $orderbys[] = trim($params['orderby']);
    }
    if (!empty($row) && $row != 'all' && $row != -1) {
        $M->setLimitOffset($offset, $limit);
        $mysql_limit = $M->getLimitOffset();
    }
    if (!empty($params['limit'])) {
        $mysql_limit = " " . trim($params['limit']);
    }
    if (!empty($_GET['producttypeid'])) {
        $conditions[] = "type_id=" . intval($_GET['producttypeid']);
    }
    if (!empty($params['companyid'])) {
        $conditions[] = "company_id=" . intval($params['companyid']);
    }
    if (!empty($params['industryid'])) {
        $conditions[] = "industry_id=" . intval($params['industryid']);
    }
    if (!empty($params['typeid'])) {
        if ($_table == 'adses') {
            $conditions[] = "adzone_id=" . intval($params['typeid']);
        } else {
            $conditions[] = "type_id=" . intval($params['typeid']);
        }
    }
    if (empty($sTemplate->block_data[$iTags])) {
        # ************************************************************************
        # Main content
        $M->setCondition($conditions);
        $M->setOrderby($orderbys);
        $sql = sprintf("SELECT * FROM %s%s %s %s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition(), $M->getOrderby(), $mysql_limit);
        $sTemplate->block_data[$iTags] = $M->GetArray($sql);
        //如果没有数据,那就不用再执行了(repeat)
        if (!$sTemplate->block_data[$iTags]) {
            return $repeat = false;
        }
        if (isset($stat)) {
            $_total_count = $M->dbstuff->GetOne(sprintf("SELECT count(*) FROM %s%s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition()));
            $sTemplate->assign('total_count', $_total_count);
            $sTemplate->assign("paging", array('total' => $_total_count));
        }
        # End main content
        # ************************************************************************
    }
    if (!$sTemplate->block_data[$iTags]) {
        $repeat = false;
        return '';
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    $counts = count($sTemplate->block_data[$iTags]);
    if (list($key, $item) = each($sTemplate->block_data[$iTags])) {
        $_title = $_title_full = $_content = $_content_full = '';
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        if (!empty($item['url'])) {
            $url = $item['url'];
        } else {
            $url = smarty_function_the_url(array("do" => $module, "id" => $item['id'], "action" => 'detail'));
        }
        if ($module == "company") {
            $url = smarty_function_the_url(array("id" => $item['id'], "do" => "company", "userid" => $item['cache_spacename']));
        } elseif ($module == "tag") {
            $url = smarty_function_the_url(array("do" => "product", "action" => 'lists', "q" => $item['name']));
        }
        $item['url'] = $url;
        if (isset($item['title'])) {
            $_title = $item['name'] = $item['title'];
        } elseif (isset($item['name'])) {
            $_title = $item['title'] = $item['name'];
        } elseif (isset($item['subject'])) {
            $_title = $item['title'] = $item['subject'];
        } elseif (isset($item['word'])) {
            $_title = $item['title'] = $item['word'];
        }
        $_title_full = $_title;
        $item['title'] = $_title = strip_tags(pb_lang_split($_title));
        $_title_full = strip_tags(pb_lang_split($_title_full));
        if (!empty($titlelen)) {
            $_title = mb_substr($_title, 0, $titlelen);
        }
        if (isset($item['description'])) {
            $_content = $item['description'];
        } elseif (isset($item['content'])) {
            $_content = $item['content'];
        }
        if (isset($item['clicked'])) {
            $item['hits'] = $item['clicked'];
        }
        $_content_full = $_content;
        if (!empty($_content) && isset($infolen)) {
            $_content = mb_substr($_content, 0, $infolen);
        }
        if (isset($item['created'])) {
            $item['pubdate'] = df($item['created'], "m-d");
        } elseif (isset($item['submit_time'])) {
            $item['pubdate'] = df($item['submit_time']);
        }
        if (!empty($params['sep'])) {
            $_seperate = $params['sep'];
        }
        $item['content'] = $_content = strip_tags(pb_lang_split($_content));
        //		if($seperate) $_title = ($key==$counts-1)?$_title:$_title.$seperate;
        $item['link'] = '<a title="' . $_title_full . '" href="' . $url . '" target="' . $target . '">' . $_title . '</a>' . $_seperate;
        $media_url = '';
        if (!empty($item['picture'])) {
            $media_url = $item['picture'];
            if (!empty($media_url)) {
                $item['thumb'] = $item['src'] = pb_get_attachmenturl($media_url, '', 'small');
            }
        }
        if (!empty($item['source_url'])) {
            $media_url = $item['source_url'];
            if (!empty($media_url)) {
                $item['thumb'] = $item['src'] = $media_url;
            }
        }
        if (isset($item['highlight'])) {
            $item['style'] = parse_highlight($item['highlight']);
        }
        $sTemplate->assign($assign, $item);
        $repeat = true;
    } else {
        $repeat = false;
        reset($sTemplate->block_data[$iTags]);
        if (isset($params['name'])) {
            unset($_bindex[$params['name']]);
            $sTemplate->assign('_bindex', $_bindex);
        }
    }
    if (!is_null($content)) {
        print $content;
    }
    if (!$repeat) {
        $sTemplate->block_data[$iTags] = array();
    }
}
				<td><?php 
        if ($this->_tpl_vars['item']['gradename']) {
            echo $this->_tpl_vars['item']['gradeimg'];
        }
        ?>
</td>
				<td>
					<?php 
        echo $this->_tpl_vars['item']['im'];
        ?>

					<?php 
        if ($this->_tpl_vars['item']['companyname'] != "") {
            ?>
					<a href="<?php 
            echo smarty_function_the_url(array('module' => 'space', 'userid' => $this->_tpl_vars['item']['userid']), $this);
            ?>
"><span class="im_pms"><?php 
            echo $this->_tpl_vars['_station_message'];
            ?>
</span></a>
					<?php 
        } elseif ($this->_tpl_vars['item']['username']) {
            ?>
					<a href="virtual-office/pms.php?do=send&to=<?php 
            echo $this->_tpl_vars['item']['username'];
            ?>
"><span class="im_pms"><?php 
            echo $this->_tpl_vars['_send_message'];
            ?>
</span></a>
<th class="tt" rowspan="2"><?php 
echo $this->_tpl_vars['_similar_search'];
?>
</th>
<?php 
$_from = $this->_tpl_vars['similar_search'];
if (!is_array($_from) && !is_object($_from)) {
    settype($_from, 'array');
}
$this->_foreach['similar'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['similar']['total'] > 0) {
    foreach ($_from as $this->_tpl_vars['item']) {
        $this->_foreach['similar']['iteration']++;
        ?>
<th><a href="<?php 
        echo smarty_function_the_url(array('module' => 'list', 'extra' => "q," . $this->_tpl_vars['item']['title'] . "|total_count|pos|typeid"), $this);
        ?>
"><?php 
        echo $this->_tpl_vars['item']['title'];
        ?>
</a>
</th><td></td>
<?php 
        if (!($this->_foreach['similar']['iteration'] % 5)) {
            ?>
<th></th>
</tr><tr>
<?php 
        }
    }
}
예제 #4
0
 function url($params)
 {
     if (!function_exists("smarty_function_the_url")) {
         require SLUGIN_PATH . "function.the_url.php";
     }
     return smarty_function_the_url($params);
 }
예제 #5
0
 function disSubNames($id, $sep = "&raquo;", $link = false, $do = null)
 {
     $ids = $this->disSubOptions($id);
     $tmp_controller = new PbController();
     if (is_null($sep)) {
         $sep = "&raquo;";
     }
     $r = array();
     $_PB_CACHE['industry'] = cache_read("industry");
     $datas = $tmp_controller->array_multi2single($_PB_CACHE['industry']);
     $tmp_ids = $ids;
     foreach ($ids as $key => $val) {
         if ($link) {
             $tmp = ltrim($key, "id");
             switch ($tmp) {
                 case 1:
                     $the_id = implode(",", $ids);
                     break;
                 case 2:
                     unset($tmp_ids["id1"]);
                     $the_id = implode(",", $tmp_ids);
                     break;
                 default:
                     $the_id = $val;
                     break;
             }
             if (!function_exists("smarty_function_the_url")) {
                 require SLUGIN_PATH . "function.the_url.php";
             }
             $r[] = "<a href='" . smarty_function_the_url(array("module" => $do, "action" => "lists", "do" => "search", "industryid" => $the_id)) . "' rel='special_link'>" . $datas[$val] . "</a>";
         } else {
             $r[] = $datas[$val];
         }
     }
     unset($_PB_CACHE);
     return implode($sep, $r);
 }
예제 #6
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_newstype($params, $content, &$smarty, &$repeat)
{
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "newstype";
    }
    $conditions = array();
    $orderby = array();
    if (isset($params['id'])) {
        $conditions[] = "id = " . $params['id'];
    }
    if (class_exists("Newstype")) {
        $newstype = new Newstypes();
        $newstype_controller = new Newstype();
    } else {
        uses("newstype");
        $newstype = new Newstypes();
        $newstype_controller = new Newstype();
    }
    if (isset($params['exclude'])) {
        $conditions[] = "id NOT IN (" . $params['exclude'] . ")";
    }
    if (isset($params['include'])) {
        $conditions[] = "id IN(" . $params['include'] . ")";
    }
    if (isset($params['level'])) {
        $conditions[] = "level_id='" . $params['level'] . "'";
    }
    if (isset($params['parentid'])) {
        $conditions[] = "parent_id='" . $params['parentid'] . "'";
    }
    if (isset($params['orderby'])) {
        $orderby[] = trim($params['orderby']);
    } else {
        $orderby[] = "id DESC ";
    }
    $newstype->setOrderby($orderby);
    $newstype->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $newstype->setLimitOffset($offset, $limit);
    if (isset($params['exclude'])) {
        $conditions[] = $newstype->getExcludeIds($params['exclude']);
    }
    if (isset($params['include'])) {
        $conditions[] = $newstype->getIncludeIds($params['include']);
    }
    $sql = "SELECT * FROM {$newstype->table_prefix}newstypes " . $newstype->getCondition() . $newstype->getOrderby() . $newstype->getLimitOffset();
    $res = $newstype->GetArray($sql);
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $res;
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $url = smarty_function_the_url(array("module" => "search", "typeid" => $item['id'], "do" => "news"));
        $item['url'] = $url;
        $item['rownum'] = $key;
        $item['title'] = $item['name'];
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['link'] = '<a title="' . strip_tags($item['name']) . '" 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();
    }
}
예제 #7
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: 2193 $
 */
function smarty_block_area($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "area";
    }
    if (class_exists("Areas")) {
        $area = new Areas();
        $area_controller = new Area();
    } else {
        uses("area");
        $area = new Areas();
        $area_controller = new Area();
    }
    $conditions[] = "available=1";
    if (isset($params['typeid'])) {
        $conditions[] = "areatype_id=" . $params['typeid'];
    }
    if (isset($params['depth'])) {
        //depth
        if ($params['depth'] == -1) {
            if (!empty($_GET['level'])) {
                if (isset($_GET['areaid'])) {
                    $next_level = $area->dbstuff->GetOne("SELECT level FROM " . $area->table_prefix . "areas WHERE id=" . intval($_GET['areaid']));
                    $next_level += 1;
                    $conditions['level'] = "level=" . $next_level;
                    $conditions['parentid'] = "parent_id=" . intval($_GET['areaid']) . " OR id=" . intval($_GET['areaid']);
                } elseif (!isset($_GET['industryid'])) {
                    $conditions['level'] = "level=" . intval($_GET['level']);
                } else {
                    $conditions['level'] = "level=1";
                }
            } else {
                $conditions['level'] = "level=1";
            }
        }
    }
    if (!empty($params['typeid'])) {
        $conditions[] = "areatype_id=" . $params['typeid'];
    }
    if (!empty($params['id'])) {
        $conditions[] = "id=" . $params['id'];
    }
    if (!empty($params['topid'])) {
        $conditions[] = "top_parentid='" . $params['topid'] . "'";
    }
    if (!empty($params['level'])) {
        $conditions['level'] = "level=" . $params['level'];
    }
    if (!empty($params['parentid'])) {
        $conditions['parentid'] = "parent_id='" . $params['parentid'] . "' OR id=" . $params['parentid'];
    }
    if (!empty($params['exclude'])) {
        $conditions[] = "id NOT IN (" . $params['exclude'] . ")";
    }
    if (!empty($params['include'])) {
        $conditions[] = "id IN (" . $params['include'] . ")";
    }
    $area->setCondition($conditions);
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY display_order ASC,id DESC";
    }
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    if (!empty($limit)) {
        $area->setLimitOffset($offset, $limit);
    } else {
        $area->limit_offset = 0;
    }
    $sql = "SELECT id,name,level,name as title,alias_name,highlight,url,parent_id FROM {$area->table_prefix}areas a " . $area->getCondition() . "{$orderby}" . $area->getLimitOffset() . ";";
    $area->dbstuff->setFetchMode(ADODB_FETCH_ASSOC);
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $area->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        if (!empty($item['url'])) {
            $url = $item['url'];
        } else {
            $url = smarty_function_the_url(array("module" => "special", "type" => "area", "id" => $item['id'], "do" => $smarty->_tpl_vars['do']));
        }
        $item['url'] = $url;
        $item['style'] = parse_highlight($item['highlight']);
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['link'] = '<a title="' . $item['name'] . '" href="' . $url . '">' . $item['title'] . '</a>';
        if (isset($_GET['areaid'])) {
            $id = intval($_GET['areaid']);
            if ($id > 0 && $id == $item['id']) {
                $item['child'] = $area->GetArray("SELECT *,name AS title FROM {$area->table_prefix}areas WHERE parent_id=" . $id . " AND available=1 ORDER BY display_order ASC;");
            }
        }
        $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();
    }
}
예제 #8
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_tag($params, $content, &$smarty, &$repeat)
{
    global $cookiepre, $tb_prefix;
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "tag";
    }
    if (!class_exists("Tags")) {
        uses("tag");
        $tag = new Tags();
        $tag_controller = new Tag();
    } else {
        $tag = new Tags();
        $tag_controller = new Tag();
    }
    $conditions[] = "closed=0";
    if (isset($params['typeid'])) {
        $conditions[] = "type='" . intval($params['typeid']) . "'";
    }
    if (isset($params['flag'])) {
        $conditions[] = "flag='" . $params['flag'] . "'";
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC";
    }
    $tag->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $tag->setLimitOffset($offset, $limit);
    $sql = "SELECT id,name,name AS title FROM {$tag->table_prefix}tags " . $tag->getCondition() . "{$orderby}" . $tag->getLimitOffset();
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $tag->dbstuff->CacheGetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $item['title'] = preg_replace('#https?://[\\w\\.\\?&/=]+#is', '', strip_tags($item['title']));
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr($item['title'], 0, $params['titlelen']);
        }
        $do = !empty($params['do']) ? trim($params['do']) : "product";
        $url = smarty_function_the_url(array("module" => "tag", "q" => urlencode($item['title']), "do" => $do));
        $item['url'] = $url;
        $item['link'] = '<a title="' . $item['name'] . '" 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();
    }
}
예제 #9
0
 function getCacheArray($cachename = '', $script = '')
 {
     global $pdb, $tb_prefix;
     $conditions = $curdata = '';
     $data = array();
     if (empty($cachename) && !empty($this->cache_name)) {
         $cachename = $this->cache_name;
     }
     switch ($cachename) {
         case 'nav':
             $navs = $pdb->GetArray("SELECT id,name,description,url,target,display_order,highlight FROM {$tb_prefix}navs  WHERE status=1 ORDER BY display_order ASC");
             $navmns = array();
             if (!empty($navs)) {
                 foreach ($navs as $nav => $nav_val) {
                     $navmns[$nav_val['id']]['link'] = '<a href="' . $nav_val['url'] . '" title="' . $nav_val['name'] . '"' . parse_highlight($nav_val['highlight']) . '"><span>' . $nav_val['name'] . '</span></a>';
                     $navmns[$nav_val['id']]['id'] = $nav_val['id'];
                     $navmns[$nav_val['id']]['name'] = $nav_val['name'];
                     $navmns[$nav_val['id']]['url'] = $nav_val['url'];
                     $navmns[$nav_val['id']]['level'] = $nav_val['display_order'];
                 }
                 $data['navs'] = $navmns;
             }
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         case 'trusttype':
             $pdb->setFetchMode(ADODB_FETCH_ASSOC);
             $conditions = "";
             $sql = "SELECT * FROM {$tb_prefix}trusttypes ORDER BY display_order ASC,id DESC";
             $result = $pdb->GetArray($sql);
             foreach ($result as $key => $val) {
                 $result[$key]['avatar'] = $val['image'];
                 unset($result[$key]['description'], $result[$key]['display_order'], $result[$key]['status'], $result[$key]['image']);
                 $data[$val['id']] = $result[$key];
             }
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         case 'country':
             $pdb->setFetchMode(ADODB_FETCH_ASSOC);
             $conditions = "";
             $sql = "SELECT * FROM {$tb_prefix}countries ORDER BY display_order ASC,id ASC";
             $result = $pdb->GetArray($sql);
             foreach ($result as $key => $val) {
                 $result[$key]['image'] = $val['picture'];
                 unset($result[$key]['display_order']);
                 $data[$val['id']] = $result[$key];
             }
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         case 'setting':
             $tmp_mail = array();
             $table = 'setting';
             $conditions = "";
             $sql = "SELECT * FROM {$tb_prefix}settings WHERE type_id IN (0,1)";
             $setting = $pdb->GetArray($sql);
             foreach ($setting as $key => $val) {
                 $data[$val['variable']] = $val['valued'];
             }
             //set sendmail
             $tmp_mail['send_mail'] = $data['send_mail'];
             $tmp_mail['auth_protocol'] = $data['auth_protocol'];
             $tmp_mail['smtp_server'] = $data['smtp_server'];
             $tmp_mail['smtp_port'] = $data['smtp_port'];
             $tmp_mail['smtp_auth'] = $data['smtp_auth'];
             $tmp_mail['mail_from'] = $data['mail_from'];
             $tmp_mail['mail_fromwho'] = $data['mail_fromwho'];
             $tmp_mail['auth_username'] = $data['auth_username'];
             $tmp_mail['auth_password'] = $data['auth_password'];
             $tmp_mail['mail_delimiter'] = $data['mail_delimiter'];
             $tmp_mail['sendmail_silent'] = $data['sendmail_silent'];
             $data['mail'] = serialize($tmp_mail);
             unset($tmp_mail, $data['send_mail'], $data['smtp_server'], $data['smtp_port'], $data['smtp_auth'], $data['mail_from'], $data['mail_fromwho'], $data['auth_username'], $data['auth_password'], $data['mail_delimiter'], $data['sendmail_silent']);
             $data['capt_auth'] = bindec($data['capt_logging'] . $data['capt_register'] . $data['capt_post_free'] . $data['capt_add_market'] . $data['capt_login_admin'] . $data['capt_apply_friendlink'] . $data['capt_service']);
             unset($data['capt_logging'], $data['capt_register'], $data['capt_post_free'], $data['capt_add_market'], $data['capt_login_admin'], $data['capt_apply_friendlink'], $data['capt_service']);
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         case 'area':
             $sql = "select name,id from {$tb_prefix}areas a where a.parent_id=0 ORDER by display_order asc";
             $top_areas = $sec_areas = $third_areas = $areas = $total_areas = array();
             $area1 = $pdb->GetArray($sql);
             $op = "<!--// Created " . date("M j, Y, G:i") . " -->\n";
             $op .= "var data_area = { \n";
             foreach ($area1 as $key => $val) {
                 $top_areas[$val['id']] = $total_areas[1][$val['id']] = $val['name'];
                 $sql = "select id,name,parent_id ,top_parentid from {$tb_prefix}areas a where level=2 AND parent_id=" . $val['id'] . " ORDER by display_order asc";
                 $sec_areas = $pdb->GetArray($sql);
                 foreach ($sec_areas as $key2 => $val2) {
                     $third_areas = $pdb->GetArray("select id,name,parent_id,top_parentid from {$tb_prefix}areas a where level=3 AND parent_id=" . $val2['id'] . " ORDER by display_order asc");
                     $areas[$val['id']]['sub'][$val2['id']] = $val2['name'];
                     $total_areas[2][$val2['id']] = $val2['name'];
                     foreach ($third_areas as $key3 => $val3) {
                         $areas[$val2['id']]['sub'][$val3['id']] = $total_areas[3][$val3['id']] = $val3['name'];
                     }
                 }
             }
             $top_areas = $this->convert2utf8($top_areas);
             $areas = $this->convert2utf8($areas);
             $op .= "'0':" . json_encode($top_areas);
             $tmp_op = array();
             foreach ($top_areas as $js_key => $js_val) {
                 if (isset($areas[$js_key])) {
                     foreach ($areas[$js_key] as $js_key1 => $js_val1) {
                         $tmp_op[] = "'0,{$js_key}':" . json_encode($areas[$js_key]['sub']);
                         foreach ($areas[$js_key]['sub'] as $js_key2 => $js_val2) {
                             if (!empty($areas[$js_key2]['sub'])) {
                                 $tmp_op[] = "'0,{$js_key},{$js_key2}':" . json_encode($areas[$js_key2]['sub']);
                             }
                         }
                     }
                 }
             }
             if (!empty($tmp_op)) {
                 $op .= ",\n";
                 $tmp_op = implode(",\n", $tmp_op);
                 $op .= $tmp_op . "\n}";
             } else {
                 $op .= "\n}";
             }
             $fp = file_put_contents($this->cache_path . "area.js", $op);
             ksort($total_areas);
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($total_areas) . ";\n\n";
             break;
         case 'industry':
             if (!function_exists("smarty_function_the_url")) {
                 require PHPB2B_ROOT . "app/slug/function.the_url.php";
             }
             $sql = "SELECT name,id,name AS title FROM {$tb_prefix}industries i WHERE i.parent_id=0 and available=1 ORDER BY display_order ASC";
             $top_levels = $sec_levels = $third_levels = $datas = $total_datas = array();
             $level1 = $pdb->GetArray($sql);
             $op = "<!--// Created " . date("M j, Y, G:i") . " -->\n";
             $op .= "var data_industry = { \n";
             foreach ($level1 as $key => $val) {
                 $top_levels[$val['id']] = $total_datas[1][$val['id']] = $val['name'];
                 $sql = "SELECT id,name,parent_id,top_parentid,name AS title FROM {$tb_prefix}industries t WHERE available=1 AND level=2 AND parent_id=" . $val['id'] . " ORDER BY display_order ASC";
                 $sec_levels = $pdb->GetArray($sql);
                 foreach ($sec_levels as $key2 => $val2) {
                     $third_levels = $pdb->GetArray("SELECT id,name,parent_id,top_parentid,name AS title FROM {$tb_prefix}industries t WHERE available=1 AND level=3 AND parent_id=" . $val2['id'] . " ORDER BY display_order ASC");
                     $datas[$val['id']]['sub'][$val2['id']] = $val2['name'];
                     $total_datas[2][$val2['id']] = $val2['name'];
                     foreach ($third_levels as $key3 => $val3) {
                         $datas[$val2['id']]['sub'][$val3['id']] = $total_datas[3][$val3['id']] = $val3['name'];
                     }
                 }
             }
             $top_levels = $this->convert2utf8($top_levels);
             $datas = $this->convert2utf8($datas);
             $op .= "'0':" . json_encode($top_levels);
             $tmp_op = array();
             foreach ($top_levels as $js_key => $js_val) {
                 if (isset($datas[$js_key])) {
                     foreach ($datas[$js_key] as $js_key1 => $js_val1) {
                         $tmp_op[] = "'0,{$js_key}':" . json_encode($datas[$js_key]['sub']);
                         foreach ($datas[$js_key]['sub'] as $js_key2 => $js_val2) {
                             if (!empty($datas[$js_key2]['sub'])) {
                                 $tmp_op[] = "'0,{$js_key},{$js_key2}':" . json_encode($datas[$js_key2]['sub']);
                             }
                         }
                     }
                 }
             }
             if (!empty($tmp_op)) {
                 $op .= ",\n";
                 $tmp_op = implode(",\n", $tmp_op);
                 $op .= $tmp_op . "\n}";
             } else {
                 $op .= "\n}";
             }
             $fp = file_put_contents($this->cache_path . "industry.js", $op);
             unset($op);
             ksort($total_datas);
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($total_datas) . ";\n\n";
             unset($top_levels, $sec_levels, $third_levels, $datas, $total_datas, $op);
             //db cache.
             $data = array();
             $op = "<?php\n";
             $op .= "return ";
             $tmp_level_top = $pdb->GetArray("SELECT id,name FROM " . $tb_prefix . "industries WHERE parent_id=0 and available=1 ORDER BY display_order ASC");
             if (!empty($tmp_level_top)) {
                 foreach ($tmp_level_top as $tmp_val) {
                     $level_top[$tmp_val['id']] = $tmp_val['name'];
                 }
             }
             foreach ($level_top as $key1 => $val1) {
                 $data[$key1]['id'] = $key1;
                 $data[$key1]['name'] = $val1;
                 $data[$key1]['parent_id'] = 0;
                 $data[$key1]['level'] = 1;
                 $url = $pdb->GetOne("SELECT url FROM " . $tb_prefix . "industries WHERE id={$key1} ORDER BY display_order ASC");
                 if ($url) {
                     $data[$key1]['url'] = $url;
                 } else {
                     $data[$key1]['url'] = smarty_function_the_url(array("module" => "special", "type" => "industry", "id" => $key1));
                 }
                 $tmp_result1 = $pdb->GetArray("SELECT * FROM " . $tb_prefix . "industries WHERE level=2 AND parent_id=" . $key1 . " AND available=1 ORDER BY display_order ASC");
                 if (!empty($tmp_result1)) {
                     foreach ($tmp_result1 as $key2 => $val2) {
                         $data[$key1]['sub'][$key2]['id'] = $val2['id'];
                         $data[$key1]['sub'][$key2]['name'] = $val2['name'];
                         $data[$key1]['sub'][$key2]['available'] = $val2['available'];
                         $data[$key1]['sub'][$key2]['parent_id'] = $val2['parent_id'];
                         $data[$key1]['sub'][$key2]['level'] = $val2['level'];
                         $url = $pdb->GetRow("SELECT * FROM " . $tb_prefix . "industries WHERE id={$val2['id']}");
                         if (!empty($url['url'])) {
                             $data[$key1]['sub'][$key2]['url'] = $url['url'];
                         } else {
                             $data[$key1]['sub'][$key2]['url'] = smarty_function_the_url(array("module" => "special", "type" => "industry", "id" => $val2['id']));
                         }
                         $tmp_result2 = $pdb->GetArray("SELECT * FROM " . $tb_prefix . "industries WHERE level=3 AND parent_id=" . $val2['id'] . " AND available=1 ORDER BY display_order ASC");
                         if (!empty($tmp_result2)) {
                             foreach ($tmp_result2 as $key3 => $val3) {
                                 $data[$key1]['sub'][$key2]['sub'][$key3]['id'] = $val3['id'];
                                 $data[$key1]['sub'][$key2]['sub'][$key3]['name'] = $val3['name'];
                                 $data[$key1]['sub'][$key2]['sub'][$key3]['available'] = $val3['available'];
                                 $data[$key1]['sub'][$key2]['sub'][$key3]['parent_id'] = $val3['parent_id'];
                                 $data[$key1]['sub'][$key2]['sub'][$key3]['level'] = $val3['level'];
                                 $url = $pdb->GetRow("SELECT * FROM " . $tb_prefix . "industries WHERE id={$val3['id']}");
                                 if (!empty($url['url'])) {
                                     $data[$key1]['sub'][$key2]['sub'][$key3]['url'] = $url['url'];
                                 } else {
                                     $data[$key1]['sub'][$key2]['sub'][$key3]['url'] = smarty_function_the_url(array("module" => "special", "type" => "industry", "id" => $val3['id']));
                                 }
                             }
                         }
                     }
                 }
             }
             $op .= $this->evalArray($data);
             unset($data);
             $op .= "\n";
             $op .= "?>";
             $fp = file_put_contents($this->cache_path . "industry.php", $op);
             break;
         case 'userpage':
             $sql = "SELECT id,name,title,url,digest FROM {$tb_prefix}userpages ORDER BY display_order ASC,id ASC";
             $result = $pdb->GetArray($sql);
             if (!empty($result)) {
                 $i = 0;
                 foreach ($result as $key => $val) {
                     $data[$i]['id'] = $val['id'];
                     $data[$i]['title'] = $val['title'];
                     $data[$i]['name'] = $val['name'];
                     $data[$i]['digest'] = $val['digest'];
                     if (!empty($val['url'])) {
                         $data[$i]['url'] = $val['url'];
                     } else {
                         $data[$i]['url'] = "";
                     }
                     $i++;
                 }
             }
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         case 'form':
             $form_result = $pdb->GetArray("SELECT * FROM {$tb_prefix}forms ORDER BY id ASC");
             if (!empty($form_result)) {
                 foreach ($form_result as $val) {
                     $item_result = $pdb->GetArray("SELECT * FROM {$tb_prefix}formitems WHERE id IN (" . $val['items'] . ") ORDER BY id ASC");
                     if (!empty($item_result)) {
                         foreach ($item_result as $val1) {
                             $data[$val['id']][$val1['id']]['id'] = $val1['identifier'];
                             $data[$val['id']][$val1['id']]['label'] = $val1['title'];
                         }
                     }
                 }
                 $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             }
             break;
         case 'membergroup':
             $sql = "SELECT * FROM {$tb_prefix}membergroups mg ORDER BY mg.id DESC";
             $membergroup_result = $pdb->GetArray($sql);
             if (!empty($membergroup_result)) {
                 foreach ($membergroup_result as $key => $val) {
                     $data[$val['id']]['name'] = $val['name'];
                     $data[$val['id']]['max_offer'] = $val['max_offer'];
                     $data[$val['id']]['type_id'] = $val['membertype_id'];
                     $data[$val['id']]['max_product'] = $val['max_product'];
                     $data[$val['id']]['max_job'] = $val['max_job'];
                     $data[$val['id']]['max_companynews'] = $val['max_companynews'];
                     $data[$val['id']]['max_market'] = $val['max_companynews'];
                     $data[$val['id']]['max_album'] = $val['max_companynews'];
                     $data[$val['id']]['max_producttype'] = $val['max_producttype'];
                     $data[$val['id']]['max_attach_size'] = $val['max_attach_size'];
                     $data[$val['id']]['max_size_perday'] = $val['max_size_perday'];
                     $data[$val['id']]['max_favorite'] = $val['max_favorite'];
                     $data[$val['id']]['type'] = $val['type'];
                     $data[$val['id']]['avatar'] = $val['picture'];
                     $data[$val['id']]['allow_space'] = $val['allow_space'];
                     $tmp_allow = sprintf("%02b", $val['allow_offer']);
                     $data[$val['id']]['offer_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['offer_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_market']);
                     $data[$val['id']]['market_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['market_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_company']);
                     $data[$val['id']]['company_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['company_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_product']);
                     $data[$val['id']]['product_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['product_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_job']);
                     $data[$val['id']]['job_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['job_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_companynews']);
                     $data[$val['id']]['companynews_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['companynews_check'] = intval($tmp_allow[1]);
                     $tmp_allow = sprintf("%02b", $val['allow_album']);
                     $data[$val['id']]['album_allow'] = intval($tmp_allow[0]);
                     $data[$val['id']]['album_check'] = intval($tmp_allow[1]);
                     $data[$val['id']]['auth_level'] = intval($val['exempt']);
                 }
             }
             $curdata = "\$_PB_CACHE['{$cachename}'] = " . $this->evalArray($data) . ";\n\n";
             break;
         default:
             break;
     }
     return $curdata;
 }
예제 #10
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_topic($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "topic";
    }
    if (class_exists("Topics")) {
        $topic = new Topics();
        $topic_controller = new Topic();
    } else {
        uses("topic");
        $topic = new Topics();
        $topic_controller = new Topic();
    }
    if (isset($params['id'])) {
        $conditions[] = "id=" . $params['id'];
    }
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    $conditions[] = "picture!=''";
                    break;
                case 'news':
                    $url_fix = "news/list.php?";
                default:
                    break;
            }
        }
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC";
    }
    $topic->setCondition($conditions);
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $topic->setLimitOffset($offset, $limit);
    $sql = "SELECT * FROM {$topic->table_prefix}topics " . $topic->getCondition() . "{$orderby}" . $topic->getLimitOffset() . "";
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $topic->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        //Todo:news/topic/topic-name.html
        //$item['url'] = $url_fix."topicid=".$item['id'];
        if (!empty($item['alias_name'])) {
            $name = trim($item['alias_name']);
        } else {
            $name = trim($item['title']);
        }
        $item['url'] = smarty_function_the_url(array("module" => "special", "type" => "topic", "name" => urlencode($name)));
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr(strip_tags($item['title']), 0, $params['titlelen']);
        }
        $item['thumb'] = $item['src'] = pb_get_attachmenturl($item['picture'], '', 'small');
        $item['link'] = '<a title="' . $item['title'] . '" href="' . $item['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();
    }
}
    $_block_content = ob_get_contents();
    ob_end_clean();
    $_block_repeat = false;
    echo smarty_block_news($this->_tag_stack[count($this->_tag_stack) - 1][1], $_block_content, $this, $_block_repeat);
}
array_pop($this->_tag_stack);
?>
						</ul>
					</div>
				</div>
			</div>
			<div class="fr hotzt">
				<div class="hotztbox">
                   <div class="title">
					<span class="more"><a href="<?php 
echo smarty_function_the_url(array('module' => 'search', 'do' => 'news', 'type' => 'topic'), $this);
?>
"><span class="raquo">&raquo;</span><?php 
echo $this->_tpl_vars['_more'];
?>
</a></span><h2><?php 
echo $this->_tpl_vars['_topic_news'];
?>
</h2>
                    </div>
                     <ul>
					<?php 
$this->_tag_stack[] = array('topic', array('type' => 'news', 'row' => 3, 'name' => 'item'));
$_block_repeat = true;
smarty_block_topic($this->_tag_stack[count($this->_tag_stack) - 1][1], null, $this, $_block_repeat);
while ($_block_repeat) {
예제 #12
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: 2115 $
 */
function smarty_block_company($params, $content, &$smarty, &$repeat)
{
    global $_PB_CACHE;
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "company";
    }
    require CACHE_PATH . "cache_area.php";
    require CACHE_PATH . "cache_membergroup.php";
    if (class_exists("Companies")) {
        $company = new Companies();
        $company_controller = new Company();
    } else {
        uses("company");
        $company = new Companies();
        $company_controller = new Company();
    }
    if (class_exists("Spaces")) {
        $space_controller = new Space();
    } else {
        uses("space");
        $space_controller = new Space();
    }
    $conditions[] = "c.status=1";
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    $conditions[] = "c.picture!=''";
                    break;
                case 'commend':
                    $conditions[] = "c.if_commend>0";
                    break;
                case 'hot':
                    break;
                default:
                    break;
            }
        }
    }
    if (isset($params['typeid'])) {
        $conditions[] = "c.type_id=" . $params['typeid'];
    }
    if (isset($params['id'])) {
        $conditions[] = "c.id=" . $params['id'];
    }
    if (isset($params['industryid'])) {
        if (strpos($params['industryid'], ",")) {
            $conditions['industry'] = "c.industry_id IN (" . $params['industryid'] . ")";
        } else {
            $industry_id = intval($params['industryid']);
            if ($industry_id) {
                $conditions['industry'] = "c.industry_id=" . $industry_id;
            }
        }
    }
    if (isset($params['areaid'])) {
        if (strpos($params['areaid'], ",")) {
            $conditions['area'] = "c.area_id IN (" . $params['areaid'] . ")";
        } else {
            $area_id = intval($params['areaid']);
            if ($area_id) {
                $conditions['area'] = "c.area_id=" . $area_id;
            }
        }
    }
    if (!empty($_GET['industryid'])) {
        $conditions['industry'] = "c.industry_id=" . intval($_GET['industryid']);
    }
    if (!empty($_GET['areaid'])) {
        $conditions['area'] = "c.area_id=" . intval($_GET['areaid']);
    }
    if (isset($params['groupid'])) {
        $conditions[] = "c.cache_membergroupid=" . $params['groupid'];
    }
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $orderby = null;
    if (isset($params['orderby'])) {
        if ($params['orderby'] == "rand" || $params['orderby'] == "rand()") {
            $sql = "SELECT max(id) AS max_id,min(id) AS min_id FROM " . $company->table_prefix . "companies";
            $result = $company->GetRow($sql);
            for ($i = 0; $i <= $limit; $i++) {
                $ids[] = mt_rand($result['min_id'], $result['max_id']);
            }
            $conditions[] = "id IN (" . implode(",", $ids) . ")";
        } else {
            $orderby = " ORDER BY " . trim($params['orderby']) . " ";
        }
    } else {
        $orderby = " ORDER BY id DESC ";
    }
    $company->setCondition($conditions);
    $company->setLimitOffset($offset, $limit);
    $mysql_limit = $company->getLimitOffset();
    if (isset($params['limit'])) {
        $mysql_limit = " " . trim($params['limit']);
    }
    $sql = "SELECT c.id as companyid,c.name as companyname,c.name as title,cache_spacename as userid,c.* FROM {$company->table_prefix}companies c " . $company->getCondition() . "{$orderby}" . $mysql_limit . "";
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $company->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        if (!empty($item['userid']) && $item['member_id'] > 0) {
            $url = $space_controller->rewrite($item['userid']);
        } else {
            $url = smarty_function_the_url(array("id" => $item['id'], "module" => "company"));
        }
        $item['url'] = $url;
        if (isset($params['titlelen'])) {
            $item['companyname'] = mb_substr($item['name'], 0, $params['titlelen']);
        }
        if (!empty($item['cache_membergroupid'])) {
            $item['avatar'] = $item['groupavatar'] = "images/group/" . $_PB_CACHE['membergroup'][$item['cache_membergroupid']]['avatar'];
        }
        if (!empty($item['picture'])) {
            $item['logo'] = pb_get_attachmenturl($item['picture'], '', 'small');
        }
        $item['areaid'] = $item['area_id'];
        $areas = $company_controller->array_multi2single($_PB_CACHE['area']);
        if (!empty($areas[$item['area_id']])) {
            $item['areaname'] = $areas[$item['area_id']];
        }
        if (!empty($_PB_CACHE['membergroup'][$item['cache_membergroupid']]['name'])) {
            $item['groupname'] = $_PB_CACHE['membergroup'][$item['cache_membergroupid']]['name'];
        }
        $item['link'] = '<a title="' . $item['name'] . '" href="' . $url . '">' . $item['companyname'] . '</a>';
        $item['thumb'] = $item['src'] = $item['logo'];
        $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();
    }
}
				<h2><?php 
echo $this->_tpl_vars['_area_category'];
?>
</h2>
			</div>
			<div class="corner_content_s6">
			   <ul>
				 <?php 
$this->_tag_stack[] = array('area', array('level' => 1, 'name' => 'item'));
$_block_repeat = true;
smarty_block_area($this->_tag_stack[count($this->_tag_stack) - 1][1], null, $this, $_block_repeat);
while ($_block_repeat) {
    ob_start();
    ?>
				  <li><a href="<?php 
    echo smarty_function_the_url(array('module' => 'search', 'do' => 'market', 'areaid' => $this->_tpl_vars['item']['id'], 'level' => 1), $this);
    ?>
"><?php 
    echo $this->_tpl_vars['item']['title'];
    ?>
</a></li>
				 <?php 
    $_block_content = ob_get_contents();
    ob_end_clean();
    $_block_repeat = false;
    echo smarty_block_area($this->_tag_stack[count($this->_tag_stack) - 1][1], $_block_content, $this, $_block_repeat);
}
array_pop($this->_tag_stack);
?>
			   </ul>
			</div>
예제 #14
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: 2116 $
 */
function smarty_block_offer($params, $content, &$smarty, &$repeat)
{
    global $_PB_CACHE;
    $conditions[] = "t.status='1'";
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "offer";
    }
    if (!class_exists("Trades")) {
        uses("trade");
        $trade = new Trades();
        $trade_controller = new Trade();
    } else {
        $trade = new Trades();
        $trade_controller = new Trade();
    }
    if ($_PB_CACHE['setting']['offer_expire_method']) {
        switch ($_PB_CACHE['setting']['offer_expire_method']) {
            case "2":
                $conditions[] = "t.expire_time>" . $trade->timestamp;
                break;
            case "3":
                $conditions[] = "t.expire_time>" . $trade->timestamp;
                break;
            default:
                break;
        }
    }
    if (isset($params['type'])) {
        $type = explode(",", $params['type']);
        $type = array_unique($type);
        foreach ($type as $val) {
            switch ($val) {
                case 'image':
                    $conditions[] = "t.picture!=''";
                    break;
                case 'urgent':
                    $conditions[] = "t.if_urgent='1'";
                    break;
                case 'company':
                    $conditions[] = "t.company_id>0";
                    break;
                case 'commend':
                    $conditions[] = "t.if_commend>0";
                    break;
                default:
                    break;
            }
        }
    }
    if (isset($params['industryid'])) {
        if (isset($params['depth'])) {
            $depth = intval($params['depth']);
            if ($depth) {
                if (class_exists("Industries")) {
                    $industry = new Industries();
                    $industry_controller = new Industry();
                } else {
                    uses("industry");
                    $industry = new Industries();
                    $industry_controller = new Industry();
                }
                $ids_s = $industry->getConditionIds($params['industryid']);
                if (is_array($ids_s)) {
                    $ids_s = array_filter($ids_s);
                    $conditions['industry'] = "t.industry_id IN (" . implode(",", $ids_s) . ")";
                } else {
                    $conditions['industry'] = "t.industry_id='" . $ids_s . "'";
                }
            }
        } else {
            $conditions[] = "t.industry_id = '" . $params['industryid'] . "'";
        }
    }
    if (isset($params['areaid'])) {
        if (isset($params['depth'])) {
            $depth = intval($params['depth']);
            if ($depth) {
                global $industry;
                $ids_s = $industry->getConditionIds($params['areaid']);
                if (is_array($ids_s)) {
                    $ids_s = array_filter($ids_s);
                    $conditions['area'] = "t.area_id IN (" . implode(",", $ids_s) . ")";
                } else {
                    $conditions['area'] = "t.area_id='" . $ids_s . "'";
                }
            }
        } else {
            $conditions['area'] = "t.area_id = '" . $params['areaid'] . "'";
        }
    }
    if (!empty($_GET['industryid'])) {
        $conditions['industry'] = "t.industry_id=" . intval($_GET['industryid']);
    }
    if (!empty($_GET['areaid'])) {
        $conditions['area'] = "t.area_id=" . intval($_GET['areaid']);
    }
    if (isset($params['exclude'])) {
        $conditions[] = $trade->getExcludeIds($params['exclude']);
    }
    if (isset($params['include'])) {
        $conditions[] = $trade->getIncludeIds($params['include']);
    }
    if (isset($params['country_id'])) {
        $conditions[] = "t.country_id='" . $params['country_id'] . "'";
    }
    if (isset($params['expday'])) {
        $conditions[] = "t.expire_time<'" . ($params['expday'] * 86400 + $trade->timestamp) . "'";
    }
    if (isset($params['subday'])) {
        $conditions[] = "t.submit_time>'" . ($trade->timestamp - $params['expireday'] * 86400) . "'";
    }
    if (isset($params['typeid'])) {
        if (!empty($params['typeid'])) {
            if (strpos($params['typeid'], ",") > 0) {
                $tmp_ids = explode(",", $params['typeid']);
                $conditions[] = "t.type_id in ('" . implode("','", $tmp_ids) . "')";
            } else {
                $conditions[] = "t.type_id='" . $params['typeid'] . "'";
            }
        }
    }
    if (isset($params['urgent'])) {
        $conditions[] = "t.if_urgent='1'";
    }
    if (!empty($params['memberid'])) {
        $conditions[] = "t.member_id='" . $params['memberid'] . "'";
    }
    if (!empty($params['companyid'])) {
        $conditions[] = "t.company_id='" . $params['companyid'] . "'";
    }
    if (isset($params['cash'])) {
        $conditions[] = "t.require_point>0";
    }
    $trade->setCondition($conditions);
    $orderby = null;
    $orderby = isset($params['orderby']) ? " ORDER BY " . trim($params['orderby']) . " " : " ORDER BY modified DESC";
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    if (isset($_GET['pos'])) {
        $offset = intval($_GET['pos']);
    }
    $trade->setLimitOffset($offset, $limit);
    $mysql_limit = $trade->getLimitOffset();
    if (isset($params['limit'])) {
        $mysql_limit = " " . trim($params['limit']);
    }
    if (!$params['recursive']) {
        $sql = "SELECT *,title as name,title as fulltitle,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . "{$orderby}" . $mysql_limit;
    } else {
        $sql = "SELECT *,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . " ORDER BY t.display_order ASC,t.id DESC" . $mysql_limit;
    }
    $offer_typenames = $trade_controller->getTradeTypes();
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $trade->GetArray($sql);
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        $item['rownum'] = $key;
        $item['iteration'] = ++$key;
        $url = smarty_function_the_url(array("id" => $item['id'], "typeid" => $item['type_id'], "module" => "offer"));
        $item['url'] = $url;
        $item['title'] = strip_tags($item['title']);
        $item['content'] = strip_tags($item['content']);
        if (isset($params['titlelen'])) {
            $item['title'] = mb_substr($item['title'], 0, $params['titlelen']);
        }
        if (isset($params['infolen'])) {
            $item['content'] = mb_substr($item['content'], 0, $params['infolen']);
        }
        if (isset($params['titlestart'])) {
            $item['title'] = $params['titlestart'] . $item['title'];
        }
        $item['pubdate'] = df($item['submit_time']);
        $item['typeid'] = $item['type_id'];
        $item['typename'] = $offer_typenames[$item['type_id']];
        $item['src'] = $item['thumb'] = URL . "attachment/" . $item['picture'] . ".small.jpg";
        $item['link'] = '<a title="' . $item['fulltitle'] . '" href="' . $url . '">' . $item['title'] . '</a>';
        $item['style'] = parse_highlight($item['highlight']);
        $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();
    }
}
unset($_from);
?>
		 </ul>
	   </div>
	  </div>
	  <div class="main_right_w230">
	   <div class="title_bar_s4">
	   <span class="title_top_s4"><span></span></span>
	   <h3><?php 
echo $this->_tpl_vars['_dict_digest'];
?>
</h3>
	   </div>
	   <div class="dictionary">
		<form name="dict_search_frm" id="dictSearchFrm" action="<?php 
echo smarty_function_the_url(array('module' => 'search'), $this);
?>
" method="get">
		<input type="hidden" name="do" value="dict" />
		<input type="hidden" name="action" value="search" />
		 <p><?php 
echo $this->_tpl_vars['_dict_digest_content'];
?>
</p>
		 <p><input name="q" id="queryStr" type="text" class="input_w160"/>&nbsp;<input type="submit" value="<?php 
echo $this->_tpl_vars['_search'];
?>
" class="btn_submit_w45"/></p>
		</form>
	   </div>
	   <div class="blank6"></div>
예제 #16
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_userpage($params, $content, &$smarty, &$repeat)
{
    global $rewrite_able;
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "page";
    }
    if (!class_exists("Userpages")) {
        uses("userpage");
        $userpage = new Userpages();
        $userpage_controller = new Userpage();
    } else {
        $userpage = new Userpages();
        $userpage_controller = new Userpage();
    }
    if (isset($params['seperate'])) {
        $seperate = $params['seperate'];
    }
    if (isset($params['sep'])) {
        $seperate = $params['sep'];
    }
    require CACHE_PATH . "cache_userpage.php";
    $result = $_PB_CACHE['userpage'];
    if (isset($params['exclude'])) {
        if (strpos($params['exclude'], ",") > 0) {
            $tmp_str = explode(",", $params['exclude']);
            if (!empty($tmp_str)) {
                foreach ($tmp_str as $id_val) {
                    unset($result[$id_val]);
                }
            }
        } else {
            unset($params['exclude']);
        }
    }
    if (empty($smarty->blockvars[$param_count])) {
        $smarty->blockvars[$param_count] = $result;
        if (!$smarty->blockvars[$param_count]) {
            return $repeat = false;
        }
    }
    if (!function_exists("smarty_function_the_url")) {
        require "function.the_url.php";
    }
    $counts = count($smarty->blockvars[$param_count]);
    if (list($key, $item) = each($smarty->blockvars[$param_count])) {
        $repeat = true;
        if (empty($item['url'])) {
            $item['url'] = smarty_function_the_url(array("module" => "page", "title" => $item['title'], "id" => $item['id']));
        }
        $url = $item['url'];
        $item['tip'] = $item['title'];
        if ($seperate) {
            $sep = $key == $counts - 1 ? '' : $seperate;
        }
        $item['link'] = '<a title="' . $item['title'] . '" href="' . $url . '">' . $item['title'] . '</a>' . $sep;
        $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();
    }
}
예제 #17
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: 2181 $
 */
function smarty_function_the_url($params)
{
    $do = null;
    extract($params);
    global $subdomain_support, $topleveldomain_support, $rewrite_able, $rewrite_compatible;
    $return = "##";
    if (!empty($module)) {
        switch ($module) {
            case "producttype":
                if ($rewrite_able) {
                    $return = URL . "space/" . $userid . "/product/list-" . $typeid . "-" . intval($page) . ".html";
                } else {
                    $return = URL . "space/?userid=" . $userid . "&do=product&typeid=" . $typeid . "&page=" . $page;
                }
                break;
            case "space":
                if (!class_exists('Space')) {
                    uses("space");
                }
                $space_controller = new Space();
                $return = $space_controller->rewrite($userid, $id, $do);
                break;
            case "offer":
                if (!class_exists('Trade')) {
                    uses("trade");
                }
                $trade_controller = new Trade();
                if ($rewrite_able) {
                    $return = "offer/" . $trade_controller->getModulenameById($typeid) . "/detail/" . $id . ".html";
                } else {
                    $return = "offer/detail.php?id=" . $id;
                }
                break;
            case "list":
                $extra_param = array();
                if (!empty($extra)) {
                    if (strpos($extra, "|") > 0) {
                        $tmp = explode("|", $extra);
                        foreach ($tmp as $k => $v) {
                            $tmp_p = explode(",", $v);
                            $extra_param[$tmp_p[0]] = $tmp_p[1];
                        }
                    } else {
                        $tmp = explode(",", $extra);
                        $extra_param[$tmp[0]] = $tmp[1];
                    }
                }
                $param = http_build_query($extra_param + $_GET);
                $return = $GLOBALS['php_self'] . "?" . $param;
                break;
            case "special":
                if ($rewrite_able) {
                    if ($type == "topic") {
                        //name first alias_name
                        $return = "topic/" . $name . "/";
                    } else {
                        $return = "topic/" . $type . "/" . $id . "/?do=" . $do;
                    }
                } else {
                    if ($type == "topic") {
                        //name first alias_name
                        $return = "special/?type=" . $type . "&name=" . $name;
                    } else {
                        $return = "special/?type=" . $type . "&do=" . $do . "&id=" . $id;
                    }
                }
                break;
            case "page":
                if ($rewrite_able) {
                    $return = "page/" . urlencode($title) . "/";
                } else {
                    $return = "page.php?title=" . urlencode($title);
                }
                break;
            case "search":
                if ($rewrite_able) {
                    if (!isset($pos)) {
                        $pos = 0;
                    }
                    if (!isset($params['pos']) && !isset($params['typeid'])) {
                        $return = empty($do) ? "search/" : "search/" . $do . "/";
                    } else {
                        $return = $do . "-list-" . $pos . "-" . intval($typeid) . "-" . intval($areaid) . "-" . intval($industryid) . ".html";
                    }
                } else {
                    $return = "search/?do=" . $do . "&pos=" . $pos;
                    if (!empty($q)) {
                        $return .= "&q=" . $q;
                    }
                    if (!empty($typeid)) {
                        $return .= "&typeid=" . intval($typeid);
                    }
                    if (!empty($areaid)) {
                        $return .= "&areaid=" . $areaid;
                    }
                    if (!empty($industryid)) {
                        $return .= "&industryid=" . $industryid;
                    }
                    if (!empty($type)) {
                        $return .= "&type=" . $type;
                    }
                }
                break;
            case "wap":
                if ($do) {
                    if ($rewrite_able) {
                        $return = "wap-" . $do . "/";
                    } else {
                        $return = "?do=" . $do;
                    }
                } else {
                    $return = URL . "wap/";
                }
                break;
            case "tag":
                if ($rewrite_able) {
                    $return = "tag/" . $do . "-" . $q . "/";
                } else {
                    $return = smarty_function_the_url(array("do" => $do, "q" => $q, "module" => "search"));
                }
                break;
            default:
                if (!empty($id)) {
                    if ($rewrite_able) {
                        $return = URL . $module . "/detail/" . $id . ".html";
                    } else {
                        $return = URL . $module . "/detail.php?id=" . $id;
                    }
                }
                break;
        }
    }
    return $return;
}