function getProductById($product_id) { $sql = "SELECT p.* FROM {$this->table_prefix}products p WHERE p.id=" . $product_id; $result = $this->dbstuff->GetRow($sql); if (empty($result) || !$result) { return false; } $result['pubdate'] = @date("Y-m-d", $result['created']); if (!empty($result['picture'])) { $result['imgsmall'] = "../" . pb_get_attachmenturl($result['picture']) . ".small.jpg"; $result['imgmiddle'] = "../" . pb_get_attachmenturl($result['picture']) . ".middle.jpg"; $result['image'] = "../" . pb_get_attachmenturl($result['picture']); $result['image_url'] = rawurlencode($result['picture']); } else { $result['image'] = pb_get_attachmenturl('', '', 'middle'); } if (!empty($result['tag_ids'])) { uses("tag"); $tag = new Tags(); $tag_res = $tag->getTagsByIds($result['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="product/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> '; } $result['tag'] = $tags; unset($tags, $tag_res, $tag); } } $this->info = $result; return $result; }
function getInfoById($pid) { $sql = "select tf.*,t.id,t.industry_id1,t.industry_id2,t.id,t.title,t.content,t.company_id,t.member_id,t.picture,t.area_id1,t.area_id2,t.status,t.type_id,t.submit_time AS pubdate,expire_time AS expdate,require_membertype,require_point,t.tag_ids,t.formattribute_ids,t.if_urgent from {$this->table_prefix}trades t left join {$this->table_prefix}tradefields tf on tf.trade_id=t.id WHERE t.id=" . $pid; $result = $this->dbstuff->GetRow($sql); $result['tel'] = $result['prim_telnumber']; if (!empty($result['picture'])) { $result['image'] = pb_get_attachmenturl($result['picture'], ''); $result['image_url'] = rawurlencode($result['picture']); } if (!empty($result['tag_ids'])) { uses("tag"); $tag = new Tags(); $tag_res = $tag->getTagsByIds($result['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="offer/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> '; } $result['tag'] = $tags; unset($tags, $tag_res, $tag); } } return $result; }
flash(); } } } if (isset($_GET['do'])) { $do = trim($_GET['do']); if (!empty($_GET['id'])) { $id = intval($_GET['id']); } if ($do == "edit") { if (!empty($id)) { $res = $product->getInfo($id); if (!empty($res['picture'])) { $res['image'] = pb_get_attachmenturl($res['picture'], '../', 'small'); } $tag->getTagsByIds($res['tag_ids'], true); $res['tag'] = $tag->tag; setvar("item", $res); unset($res); } $tpl_file = "product.edit"; template($tpl_file); exit; } if ($do == 'search') { if (!empty($_GET['data']['username'])) { $member_id = $pdb->GetOne("SELECT id from {$tb_prefix}members where username="******"Product.member_id='" . $member_id . "'"; } if (!empty($_GET['data']['companyname'])) { $conditions[] = "c.name like '%" . $_GET['data']['companyname'] . "%'";
function detail() { global $viewhelper; using("tag", "meta"); $tag = new Tags(); $meta = new Metas(); $conditions = array(); $viewhelper->setTitle(L("info", "tpl")); $viewhelper->setPosition(L("info", "tpl"), "index.php?do=news"); if (isset($_GET['title'])) { $title = trim($_GET['title']); $res = $this->news->findByTitle($title); $id = $res['id']; } if (isset($_GET['id'])) { $id = intval($_GET['id']); } if (!empty($id)) { $_PB_CACHE['newstype'] = cache_read("type", "newstype"); $this->news->clicked($id); $info = $this->news->read("*", $id); if (empty($info) or !$info) { flash("data_not_exists", '', 0); } if (!empty($info['tag_ids'])) { $the_tags = $tag->getTagsByIds($info['tag_ids'], true); $tmp = null; $info['tag'] = $tag->tag; foreach ($the_tags as $key => $val) { $tmp .= "<a href='" . $this->url(array("module" => "search", "do" => "news", "q" => urlencode($val))) . "'>" . $val . "</a> "; } $info['tag_link'] = $tmp; } if (!empty($info['picture'])) { $info['image'] = pb_get_attachmenturl($info['picture'], '', 'small'); } $info['pubdate'] = df($info['created']); $info['typename'] = $_PB_CACHE['newstype'][$info['type_id']]; $viewhelper->setTitle($info['typename']); $viewhelper->setPosition($info['typename'], $this->url(array("module" => "search", "do" => "news", "typeid" => $info['type_id']))); //seo info $meta_info = $meta->getSEOById($id, 'news', false); empty($meta_info['title']) ? $viewhelper->setTitle($info['title']) : $viewhelper->setTitle($meta_info['title']); empty($meta_info['description']) ? $viewhelper->setMetaDescription($info['content']) : $viewhelper->setMetaDescription($meta_info['description']); if (isset($meta_info['keyword'])) { $viewhelper->setMetaKeyword($meta_info['keyword']); } $viewhelper->setPosition($info['title']); if (!empty($info['require_membertype'])) { $require_ids = explode(",", $info['require_membertype']); if (!empty($pb_userinfo['pb_userid'])) { $membertype_id = $this->news->dbstuff->GetOne("SELECT membertype_id FROM {$tb_prefix}members WHERE id='" . $pb_user['pb_userid'] . "'"); if (!in_array($membertype_id, $require_ids)) { $info['content'] = L("news_membertype_not_allowed", "tpl"); } } else { $info['content'] = L("news_membertype_not_allowed", "tpl"); } } if ($info['type'] == 1) { $info['source'] = L("company_news", "tpl"); $info['content'] = "<a href='" . $info['content'] . "'>" . $info['content'] . "</a>"; } if (!empty($info['picture'])) { $info['image_url'] = pb_get_attachmenturl($info['picture']); } $neighbour_info = $this->news->getNeighbour($id, "id,title"); if (!empty($neighbour_info['prev'])) { $title = pb_lang_split($neighbour_info['prev']['title']); $info['prev_link'] = "<a href='" . $this->url(array("module" => "news", "id" => $neighbour_info['prev']['id'])) . "'>" . $title . "</a>"; $info['prev_title'] = $title; } else { $info['prev_link'] = L("nothing", "tpl"); } if (!empty($neighbour_info['next'])) { $title = pb_lang_split($neighbour_info['next']['title']); $info['next_link'] = "<a href='" . $this->url(array("module" => "news", "id" => $neighbour_info['next']['id'])) . "'>" . $title . "</a>"; $info['next_title'] = $title; } else { $info['next_link'] = L("nothing", "tpl"); } setvar("item", pb_lang_split_recursive($info)); } else { flash(); } setvar("Newstypes", $_PB_CACHE['newstype']); render("detail.default"); }
include CACHE_PATH . "cache_industry.php"; setvar("CacheAreas", $_PB_CACHE['area']); setvar("CacheIndustries", $_PB_CACHE['industry']); $result = $membertype->findAll("id,name", null, $conditions, " id desc"); $user_types = array(); foreach ($result as $key => $val) { $user_types[$val['id']] = $val['name']; } setvar("Membertypes", $user_types); setvar("NewstypeOptions", $newstype->getTypeOptions()); if (!empty($id)) { $item_info = $news->read("*", $id); if ($item_info['picture']) { $item_info['image'] = pb_get_attachmenturl($item_info['picture'], "../", 'small'); } $tag->getTagsByIds($item_info['tag_ids'], true); $item_info['tag'] = $tag->tag; } if ($action == "convert") { if (!empty($_GET['companynewsid'])) { $item_info['title'] = $pdb->GetOne("SELECT title FROM {$tb_prefix}companynewses WHERE id=" . intval($_GET['companynewsid'])); } } if (!empty($item_info)) { setvar("item", $item_info); } $tpl_file = "news.edit"; template($tpl_file); exit; } }
$trade_info['expire_date'] = df($trade_info['expire_time']); //industry ids, 1 to n. if (!empty($trade_info['picture'])) { $trade_info['image'] = pb_get_attachmenturl($trade_info['picture'], "../"); } if (!empty($trade_info['country_id'])) { $trade_info['country'] = $countries[$trade_info['country_id']]['picture']; } if (isset($trade_info['OfferPrimImaccount'])) { $tmp_personalinfo['MemberQQ'] = $trade_info['OfferPrimImaccount']; } if (isset($trade_info['OfferPrimTelnumber'])) { $tmp_personalinfo['MemberTel'] = $trade_info['OfferPrimTelnumber']; } if (!empty($trade_info['tag_ids'])) { $tag->getTagsByIds($trade_info['tag_ids'], true); $trade_info['tag'] = $tag->tag; } } else { if (!empty($companyinfo)) { $trade_info['industry_id'] = $companyinfo['industry_id']; $trade_info['area_id'] = $companyinfo['area_id']; } else { $trade_info['area_id'] = $memberinfo['area_id']; } } if (!empty($trade_info['country_id'])) { $trade_info['country'] = $countries[$trade_info['country_id']]['picture']; } else { $trade_info['country'] = "blank.gif"; }
function getInfoById($pid, $conditions = null) { $sql = "select tf.*,t.*,t.submit_time AS pubdate,expire_time AS expdate from {$this->table_prefix}trades t left join {$this->table_prefix}tradefields tf on tf.trade_id=t.id WHERE t.id=" . $pid . $conditions; $result = $this->dbstuff->GetRow($sql); $result['tel'] = $result['prim_telnumber']; $result['title'] = pb_lang_split($result['title']); $result['content'] = pb_lang_split($result['content']); if (!empty($result['picture'])) { $result['image'] = pb_get_attachmenturl($result['picture'], ''); $result['image_url'] = rawurlencode($result['picture']); } if (!empty($result['tag_ids'])) { if (!class_exists("Tags")) { uses("tag"); $tag = new Tags(); } else { $tag = new Tags(); } $tag_res = $tag->getTagsByIds($result['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="index.php?do=offer&action=lists&q=' . urlencode($val) . '" target="_blank">' . urldecode($val) . '</a> '; } $result['tag'] = $tags; unset($tags, $tag_res, $tag); } } return $result; }
$res = $product->findByName($title); $id = $res['id']; } if (isset($_GET['id'])) { $id = intval($_GET['id']); } $info = $product->getProductById($id); if (empty($info) || !$info) { flash("data_not_exists", '', 0); } if (isset($info['formattribute_ids'])) { $form_vars = $form->getAttributes(explode(",", $info['formattribute_ids']), 2); setvar("ObjectParams", $form_vars); } if (!empty($info['tag_ids'])) { $tag_res = $tag->getTagsByIds($info['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="product/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> '; } $info['tag'] = $tags; unset($tags, $tag_res, $tag); } } if ($info['state'] != 1) { flash("unvalid_product", '', 0); } if ($info['status'] != 1) { $tmp_key = intval($info['status']); flash("wait_apply", '', 0);
foreach ($user_brands as $user_brand) { $tmp_arr[$user_brand['id']] = $user_brand['name']; } setvar("UserBrands", $tmp_arr); } setvar("Forms", $attrs = $form->getAttributes(0, 2)); if (!empty($id)) { $productinfo = $product->read("*", $id, null, $conditions); if (empty($productinfo)) { flash("action_failed"); } else { if (!empty($productinfo['picture'])) { $productinfo['image'] = pb_get_attachmenturl($productinfo['picture'], '../'); } if (!empty($productinfo['tag_ids'])) { $tag->getTagsByIds($productinfo['tag_ids'], true); $productinfo['tag'] = $tag->tag; } $r1 = $industry->disSubOptions($productinfo['industry_id'], "industry_"); $r2 = $area->disSubOptions($productinfo['area_id'], "area_"); $productinfo = am($productinfo, $r1, $r2); setvar("Forms", $form->getAttributes(explode(",", $productinfo['formattribute_ids']), 2)); } } else { $productinfo['industry_id'] = $companyinfo['industry_id']; $productinfo['area_id'] = $companyinfo['area_id']; } if (!empty($productinfo['country_id'])) { $productinfo['country'] = $countries[$productinfo['country_id']]['picture']; } else { $productinfo['country'] = "blank.gif";
function detail() { global $viewhelper; $this->loadModel("industry"); using("company", "member", "form", "tag", "area", "meta"); $company = new Companies(); $area = new Areas(); $meta = new Metas(); $tag = new Tags(); $member = new Members(); $form = new Forms(); $tmp_status = explode(",", L('product_status', 'tpl')); $viewhelper->setPosition(L("product_center", 'tpl'), 'index.php?do=product'); $viewhelper->setTitle(L("product_center", 'tpl')); if (isset($_GET['title'])) { $title = trim($_GET['title']); $res = $this->product->findByName($title); $id = $res['id']; } if (isset($_GET['id'])) { $id = intval($_GET['id']); } $info = $this->product->getProductById($id); if (empty($info) || !$info) { flash("data_not_exists", '', 0); } $form_vars = array(); if (isset($info['formattribute_ids'])) { $form_vars = $form->getAttributes(explode(",", $info['formattribute_ids']), 2); } setvar("ObjectParams", $form_vars); $info['tag'] = ''; //Initialize tag value if (!empty($info['tag_ids'])) { $tag_res = $tag->getTagsByIds($info['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="' . $this->url(array("module" => "tag", "do" => "product", "q" => $val)) . '" target="_blank">' . $val . '</a> '; } $info['tag'] = $tags; unset($tags, $tag_res, $tag); } } if ($info['state'] != 1) { flash("unvalid_product", '', 0); } if ($info['status'] != 1) { $tmp_key = intval($info['status']); flash("wait_apply", '', 0); } if (!empty($info['member_id'])) { $member_info = $member->getInfoById($info['member_id']); $info['space_name'] = $member_info['space_name']; setvar("MEMBER", $member_info); } if (!empty($info['company_id'])) { $company_info = $company->getInfoById($info['company_id']); if (!empty($company_info)) { $info['companyname'] = $company_info['name']; $info['link_people'] = $company_info['link_man']; $info['address'] = $company_info['address']; $info['zipcode'] = $company_info['zipcode']; $info['site_url'] = $company_info['site_url']; $info['tel'] = pb_hidestr($company_info['tel']); $info['fax'] = pb_hidestr($company_info['fax']); $company_info = pb_lang_split_recursive($company_info); setvar("COMPANY", $company_info); } } $meta_info = $meta->getSEOById($id, 'product', false); empty($meta_info['title']) ? $viewhelper->setTitle($info['name'], $info['picture']) : $viewhelper->setTitle($meta_info['title']); empty($meta_info['description']) ? $viewhelper->setMetaDescription($info['content']) : $viewhelper->setMetaDescription($meta_info['description']); if (isset($meta_info['keyword'])) { $viewhelper->setMetaKeyword($meta_info['keyword']); } $viewhelper->setPosition($info['name']); $info['industry_names'] = $this->industry->disSubNames($info['industry_id'], null, true, "product"); $info['area_names'] = $area->disSubNames($info['area_id'], null, true, "product"); $info['title'] = strip_tags($info['name']); //delete the pre num.2011.9.1 $info['tel'] = preg_replace('/\\((.+?)\\)/i', '', $info['tel']); $info['fax'] = preg_replace('/\\((.+?)\\)/i', '', $info['fax']); $info = pb_lang_split_recursive($info); setvar("item", $info); $this->product->clicked($id); render("product/detail"); }