本文整理汇总了PHP中Catalog::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Catalog::get方法的具体用法?PHP Catalog::get怎么用?PHP Catalog::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog::get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 初始化
* @see CController::init()
*/
public function init()
{
parent::init();
//前端控制器在此获得分类,从顶级分类(0)开始分层往下取,得到所有层次的分类
// ppr(XXcache::system('_catalog')); //这里是遍历出来未按照从属排序
// ppr($this->_catalog); //这里重新按从属排序
$this->_catalog = Catalog::get(0, XXcache::system('_catalog'));
//系统配置
$this->_conf = XXcache::system('_config');
$this->_seoTitle = $this->_conf['seo_title'];
$this->_seoKeywords = $this->_conf['seo_keywords'];
$this->_seoDescription = $this->_conf['seo_description'];
if ($this->_conf['site_status'] == 'close') {
self::_closed();
}
$this->_thisUrl = higu();
if ($this->_conf['cache_page_status'] == 'open') {
$value = Yii::app()->cache->get($this->_thisUrl);
if ($value === false) {
echo 'nocache';
} else {
echo 'cache';
echo $value;
}
}
}
示例2: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$catalogDropdown = DropdownField::create('CatalogID', 'Catalog to display', Catalog::get()->map('ID', 'Title'))->setEmptyString('Select...');
$fields->addFieldToTab('Root.Main', $catalogDropdown);
return $fields;
}
示例3: handler
public function handler()
{
$params = $this->getURLParams();
$catalog = null;
$product = null;
// Only deal with AJAX requests
if (!$this->request->isAjax()) {
return $this->httpError(401, 'Bad request');
}
switch ($params['Action']) {
case 'Catalog':
$catalog = Catalog::get()->byId($params['ID']);
break;
case 'Product':
$product = Product::get()->byID($params['ID']);
break;
default:
return $this->httpError(401, 'Bad request');
}
// Make sure we have some data.
if (!$catalog && !$product) {
return $this->httpError(404, 'Sorry, we couldn\'t find anything.');
}
// If there's a catalog, fetch its JSON, otherwise fetch the product's JSON.
$JSON = $catalog ? $catalog->getCatalogJSON() : $product->getProductJSON();
$response = $this->getResponse()->addHeader('Content-type', 'application/json; charset=utf-8');
$response->setBody($JSON);
return $response;
}
示例4: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
self::updateProductCache();
// Update the catalog cache
if ($catalog = Catalog::get()->byID($this->CatalogID)) {
$catalog->updateCatalogCache();
}
}
示例5: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!Catalog::get()->first()) {
$catalog = new Catalog();
$catalog->Title = "Product Catalog";
$catalog->URLSegment = "catalog";
$catalog->Sort = 4;
$catalog->write();
$catalog->publish('Stage', 'Live');
$catalog->flushCache();
DB::alteration_message('Product Catalog created', 'created');
}
}
示例6: actionIndex
/**
* 首页
*/
public function actionIndex()
{
$catalog_id = trim($this->_request->getParam('catalog_id'));
$keyword = trim($this->_request->getParam('keyword'));
$catalog = Catalog::model()->findByPk($catalog_id);
//调取子孙分类和当前分类
$catalog_ids = Catalog::get($catalog ? $catalog_id : 0, $this->_catalog);
$children_ids = Helper::array_key_values($catalog_ids, 'id');
$catalog_id ? $all_ids = array_merge($children_ids, (array) $catalog_id) : ($all_ids = $children_ids);
$db_in_ids = implode(',', $all_ids);
if (!$db_in_ids || $catalog_id && $catalog->type != $this->_type_ids['video']) {
throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
}
//SEO
$navs = array();
if ($catalog) {
$this->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->_setting['site_name'];
$this->_seoKeywords = $catalog->seo_keywords;
$this->_seoDescription = $catalog->seo_description;
$navs[] = array('url' => $this->createUrl('video/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
} else {
$this->_seoTitle = Yii::t('common', 'VideoListTitle') . ' - ' . $this->_setting['site_name'];
$this->_seoKeywords = Yii::t('common', 'VideoListKeywords');
$this->_seoDescription = Yii::t('common', 'VideoListDescription', array('{site_name}' => $this->_setting['site_name']));
$navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle);
}
//查询条件
$post = new Video();
$criteria = new CDbCriteria();
$condition = "t.status = 'Y'";
$keyword && ($condition .= ' AND title LIKE \'%' . $keyword . '%\'');
$db_in_ids && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')');
$criteria->condition = $condition;
$criteria->order = 'video_score DESC, view_count DESC, t.id DESC';
$criteria->with = array('catalog');
$criteria->select = "title, id, t.cover_image, t.video_score, t.update_time,t.introduce, t.view_count";
//分页
$count = $post->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = 20;
$criteria->limit = $pages->pageSize;
$criteria->offset = $pages->currentPage * $pages->pageSize;
$datalist = $post->findAll($criteria);
//最近的视频
$last_videos = Video::model()->findAll(array('condition' => 'catalog_id IN (' . $db_in_ids . ')', 'order' => 'id DESC', 'limit' => 10));
//加载css,js
Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/list.css");
Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
$this->render('index', array('navs' => $navs, 'videos' => $datalist, 'pagebar' => $pages, 'last_videos' => $last_videos));
}
示例7: parentTrue
/**
* 检测上级分类是否合法
*
* @param $item
* @param $parentId
*/
protected function parentTrue($item = 0, $parentId = 0)
{
$subCategory = Catalog::get($item, $this->_catalog);
if (empty($subCategory)) {
$getCategory[] = $item;
} else {
foreach ((array) $subCategory as $row) {
$getCategory[] = $row['id'];
}
//将本身ID加入检测对象
array_push($getCategory, $item);
}
if (in_array($parentId, $getCategory)) {
XUtils::message('error', '所选择的上级分类不能是当前分类或者当前分类的下级分类');
}
}
示例8: init
/**
* 初始化
* @see CController::init()
*/
public function init()
{
parent::init();
//检测系统是否已经安装
if (!is_file(WWWPATH . DS . 'data' . DS . 'install.lock')) {
$this->redirect(array('/install'));
}
//系统配置
$this->_conf = XXcache::system('_config');
$this->_catalog = Catalog::get(0, XXcache::system('_catalog'));
$this->_seoTitle = $this->_conf['seo_title'];
$this->_seoKeywords = $this->_conf['seo_keywords'];
$this->_seoDescription = $this->_conf['seo_description'];
if ($this->_conf['site_status'] == 'close') {
self::_closed();
}
}
示例9: edit
public function edit()
{
$oCatalog = new Catalog();
$prop = new Catalog_Property();
if ($this->show->itemID) {
$row = $oCatalog->getById($this->show->itemID);
$this->show->categoryID = $row['CategoryID'];
$this->show->propertyID = $row['PropertyID'];
} else {
$this->show->brandID = $this->post['BrandID'];
$this->show->categoryID = $this->post['CategoryID'];
}
$this->show->propertyList = $prop->getList($this->show->categoryID);
setcookie("brandID", $this->show->brandID, null, '/');
$this->show->status = $oCatalog->getStatusList();
if (!empty($this->post['Save'])) {
if ($this->show->itemID) {
$oCatalogID = $oCatalog->update($this->post, $this->show->itemID);
} else {
$oCatalogID = $oCatalog->insert($this->post);
}
if ($oCatalogID) {
redirect(BASE_PATH . 'admin/catalog/');
}
}
if ($this->show->itemID) {
$this->show->item = $oCatalog->getByID($this->show->itemID);
$this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => $this->show->item['Title']);
} else {
$this->show->item = $oCatalog->get();
$this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => 'Создание');
$oCategory = new Catalog_Category();
$this->show->categoryList = $oCategory->getList($this->show->brandID);
$oBrand = new Catalog_Brand();
$this->show->brandList = $oBrand->getList();
}
if (!empty($this->post['Save'])) {
$this->show->item->merge($this->post);
}
}
示例10: array
echo $form->textField($model, 'goods_name', array('size' => 60, 'maxlength' => 128, 'class' => 'validate[required]'));
?>
</td>
</tr>
<tr>
<td class="tb_title"><?php
echo Yii::t('admin', 'Belong Category');
?>
:</td>
</tr>
<tr >
<td ><select name="Goods[catalog_id]" id="Goods_catalog_id" onchange="changeCatalog(this)">
<?php
foreach ((array) Catalog::get(0, $this->_catalog) as $catalog) {
?>
<option value="<?php
echo $catalog['id'];
?>
" <?php
Helper::selected($catalog['id'], $model->catalog_id);
?>
><?php
echo $catalog['str_repeat'];
echo $catalog['catalog_name'];
?>
</option>
<?php
}
?>
示例11: parentTrue
/**
* 检测上级分类是否合法
*
* @param $item
* @param $parentId
*/
protected function parentTrue($item = 0, $parentId = 0)
{
$subCategory = Catalog::get($item, $this->_catalog);
if (empty($subCategory)) {
$getCategory[] = $item;
} else {
foreach ((array) $subCategory as $row) {
$getCategory[] = $row['id'];
}
//将本身ID加入检测对象
array_push($getCategory, $item);
}
if (in_array($parentId, $getCategory)) {
$this->message('error', Yii::t('admin', 'Selected Category is Current Category or Children Category'));
}
}