本文整理汇总了PHP中Catalog::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Catalog::model方法的具体用法?PHP Catalog::model怎么用?PHP Catalog::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$model = new Soft();
if (isset($_POST['Soft'])) {
$model->attributes = $_POST['Soft'];
//封面、图标、 文件
$model->cover_image = isset($_POST['cover_image']) ? $_POST['cover_image'] : '';
$model->soft_icon = isset($_POST['soft_icon']) ? $_POST['soft_icon'] : '';
$model->soft_file = isset($_POST['soft_file']) ? $_POST['soft_file'] : '';
//摘要
$model->introduce = trim($_POST['Soft']['introduce']) ? $_POST['Soft']['introduce'] : Helper::truncate_utf8_string(preg_replace('/\\s+/', ' ', $_POST['Soft']['content']), 200);
//标签 (前5个标签有效)
$tags = trim($_POST['Soft']['tags']);
$unique_tags = array_unique(explode(',', str_replace(array(' ', ','), array('', ','), $tags)));
$explodeTags = array_slice($unique_tags, 0, 5);
$model->tags = implode(',', $explodeTags);
$model->create_time = time();
$model->update_time = $model->create_time;
if ($model->save()) {
$this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
}
}
//判断有无栏目
$article_cat = Catalog::model()->find('type=:type', array(':type' => $this->controller->_type));
if (!$article_cat) {
$this->controller->message('error', Yii::t('admin', 'No Catalog'), $this->controller->createUrl('index'));
}
$this->controller->render('create', array('model' => $model));
}
示例2: actionView
/**
* 浏览详细内容
*/
public function actionView($id)
{
$post = Image::model()->findByPk(intval($id));
if (false == $post || $post->status == 'N') {
throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
}
//更新浏览次数
$post->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $id));
//seo信息
$this->_seoTitle = empty($post->seo_title) ? $post->title . ' - ' . $this->_setting['site_name'] : $post->seo_title;
$this->_seoKeywords = empty($post->seo_keywords) ? $post->tags : $post->seo_keywords;
$this->_seoDescription = empty($post->seo_description) ? $this->_seoDescription : $post->seo_description;
$catalogArr = Catalog::model()->findByPk($post->catalog_id);
//加载css,js
Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/view.css");
Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/discuz/zoom.css");
Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/discuz/common.js");
Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/discuz/zoom.js");
Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
//最近的图集
$last_images = Image::model()->findAll(array('condition' => 'catalog_id = ' . $post->catalog_id, 'order' => 'id DESC', 'limit' => 10));
//nav
$navs = array();
$navs[] = array('url' => $this->createUrl('image/view', array('id' => $id)), 'name' => $post->title);
$tplVar = array('post' => $post, 'navs' => $navs, 'last_images' => $last_images);
$this->render('view', $tplVar);
}
示例3: actionHome
/**
* 主界面
*/
public function actionHome()
{
//查询课程
$lessons = Lesson::model()->findAll(array('select' => array('catalog_id', 'arrivals', 'price')));
//学员活跃度
$studentAllCount = Student::model()->count();
$criteria = new CDbCriteria();
$criteria->distinct = true;
$criteria->addCondition('is_pays=:is_pay');
$criteria->params[':is_pay'] = 1;
$studentActiveCount = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay", array(':is_pay' => 1));
$studentPercentage = round($studentActiveCount / $studentAllCount * 100) . '%';
//获取课程分类数组
$catalogs = Catalog::model()->findAllByAttributes(array('parent_id' => 6));
$allCountLesson = Lesson::model()->count();
foreach ($catalogs as $catalog) {
//初始化
$lessonMoney[$catalog[id]] = 0;
$allLesson[$catalog[id]] = 0;
$catalogName[$catalog[catalog_name]] = $catalog[id];
//各分类中已报名课程和发布课程总量
$allLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id", array(":catalog_id" => $catalog[id]));
$applyLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id AND actual_students<>:actual_students", array(":catalog_id" => $catalog[id], ":actual_students" => 0));
}
//成交总金额
foreach ($lessons as $lesson) {
$lessonMoney[$lesson[catalog_id]] = (int) $lesson[arrivals] * (int) $lesson[price];
}
$this->render('home', array('catalogName' => json_encode($catalogName), 'lessonMoney' => json_encode($lessonMoney), 'allLesson' => json_encode($allLesson), 'applyLesson' => json_encode($applyLesson), 'studentPercentage' => $studentPercentage));
}
示例4: run
public function run()
{
$model = $this->controller->loadModel();
if (isset($_POST['Soft'])) {
$model->attributes = $_POST['Soft'];
//封面、图标、 文件
$model->cover_image = isset($_POST['cover_image']) ? $_POST['cover_image'] : '';
$model->soft_icon = isset($_POST['soft_icon']) ? $_POST['soft_icon'] : '';
$model->soft_file = isset($_POST['soft_file']) ? $_POST['soft_file'] : '';
//摘要
$model->introduce = trim($_POST['Soft']['introduce']) ? $_POST['Soft']['introduce'] : Helper::truncate_utf8_string(preg_replace('/\\s+/', ' ', $_POST['Soft']['content']), 200);
//标签 (前5个标签有效)
$tags = trim($_POST['Soft']['tags']);
$unique_tags = array_unique(explode(',', str_replace(array(' ', ','), array('', ','), $tags)));
$explodeTags = array_slice($unique_tags, 0, 5);
$model->tags = implode(',', $explodeTags);
$model->update_time = time();
if ($model->save()) {
$this->controller->message('success', Yii::t('admin', 'Update Success'), $this->controller->createUrl('index'));
}
}
$parents = Catalog::getParantsCatalog($model->catalog_id);
$catalog = Catalog::model()->findByPk($model->catalog_id);
$belong = $catalog ? implode('>', $parents) . '>' . $catalog->catalog_name : '';
$this->controller->render('update', array('model' => $model, 'parents' => $belong));
}
示例5: actionIndex
public function actionIndex()
{
/* 永不超时 */
ini_set('max_execution_time', 0);
//生成的crond
$this->_conf = XXcache::get('_config');
if (empty($this->_conf['is_cron'])) {
exit;
}
$crond_json_file = SITE_BACKEND_PATH . 'protected/data/crond/crond.json';
$arr = json_decode(file_get_contents($crond_json_file), TRUE);
//为1则为完全删除
$old = empty($arr['old']) ? 0 : 1;
unset($arr['key'], $arr['old']);
$arr = array_keys($arr);
// XUtils::ppr($arr,1);
foreach ($arr as $v) {
switch ($v) {
case 'header':
$min = 1000;
$max = 1999;
break;
case 'left':
$min = 2000;
$max = 2999;
break;
case 'main':
$min = 3000;
$max = 3999;
break;
case 'shop':
$min = 4000;
$max = 4999;
break;
case 'fun':
$min = 5000;
$max = 5999;
break;
case 'tools':
$min = 6000;
$max = 6999;
break;
case 'games':
$min = 7000;
$max = 7999;
break;
}
if (!empty($max) && !empty($min)) {
$catalog_arr = Catalog::model()->findAll(array('select' => 'id,tb_id', 'condition' => "t.tb_id>:min AND t.tb_id<:max", 'params' => array(':min' => $min, ':max' => $max)));
}
if (!empty($catalog_arr)) {
foreach ($catalog_arr as $info) {
$re[$info->tb_id . ',' . $info->id] = $this->doTb($info->tb_id, $info->id, $old);
}
}
//XUtils::ppr($re,1);
}
exit('执行完毕');
}
示例6: init
public function init()
{
parent::init();
//栏目
$this->_catalog = Catalog::model()->findAll('status=:status', array('status' => 'Y'));
//专题
$this->_special = Special::model()->findAll('status=:status', array('status' => 'Y'));
}
示例7: getCatalogImage
protected function getCatalogImage($id)
{
$catalog = Catalog::model()->findByPk(intval($id));
if (!empty($catalog)) {
return $catalog->image;
} else {
return null;
}
}
示例8: actionSingle
public function actionSingle($id)
{
$model = Catalog::model()->findByPk($id);
if (!$model) {
$this->render('/errors/404');
}
$rubric = Rubrics::model()->findByPk($model->rubric_id);
$data = array('data' => $model, 'rubric' => $rubric);
$this->render('/catalog/single', $data);
}
示例9: loadModel
/**
* 判断数据是否存在
*
*/
public function loadModel()
{
if ($this->model === null) {
if (isset($_GET['id'])) {
$this->model = Catalog::model()->findbyPk($_GET['id']);
}
if ($this->model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->model;
}
示例10: run
public function run()
{
$catalog_id = trim(Yii::app()->request->getParam('catalog_id'));
$order = trim(Yii::app()->request->getParam('order'));
if (!$order) {
$order = 'id';
}
switch ($order) {
case 'id':
$order_by = 't.id DESC';
break;
case 'view_count':
$order_by = 'view_count DESC';
break;
default:
$order = 'id';
$order_by = 't.id DESC';
break;
}
//SEO
$navs = array();
$search_cats = '所有';
if ($catalog_id) {
$condition = ' AND catalog_id = ' . $catalog_id;
$catalog = Catalog::model()->findByPk($catalog_id);
if ($catalog) {
$this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name'];
$this->controller->_seoKeywords = $catalog->seo_keywords;
$this->controller->_seoDescription = $catalog->seo_description;
$navs[] = array('url' => $this->controller->createUrl('image/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
//已搜索的分类
$cat_parents = Catalog::getParantsCatalog($catalog_id);
$search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name;
}
}
if (!$navs) {
$condition = '';
$catalog = array();
$seo = ModelType::getSEO('image');
$this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name'];
$this->controller->_seoKeywords = $seo['seo_keywords'];
$this->controller->_seoDescription = $seo['seo_description'];
$navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle);
}
//获取所有符合条件的图集
$pages = array();
$datalist = Image::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
//该栏目下最新的图集
$last_images = Image::model()->getList(array('condition' => $condition, 'limit' => 10));
$this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'datalist' => $datalist, 'pagebar' => $pages, 'last_images' => $last_images, 'order' => $order, 'search_cats' => $search_cats));
}
示例11: actionIndex
/**
* 首页
*/
public function actionIndex()
{
$catalog_id = trim($this->_request->getParam('catalog_id'));
$order = trim($this->_request->getParam('order'));
$keyword = trim($this->_request->getParam('keyword'));
if (!$order) {
$order = 'id';
}
switch ($order) {
case 'id':
$order_by = 't.id DESC';
break;
case 'view_count':
$order_by = 'view_count DESC';
break;
default:
$order = 'id';
$order_by = 't.id DESC';
break;
}
//获取子孙分类(包括本身)
$data = Catalog::model()->getChildren($catalog_id);
$catalog = $data['catalog'];
$db_in_ids = $data['db_in_ids'];
//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('post/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
} else {
$seo = ModelType::getSEO('post');
$this->_seoTitle = $seo['seo_title'] . ' - ' . $this->_setting['site_name'];
$this->_seoKeywords = $seo['seo_keywords'];
$this->_seoDescription = $seo['seo_description'];
$navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle);
}
//获取所有符合条件的文章
$condition = '';
$catalog && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')');
$datalist = Post::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
//该栏目下最新的文章
$last_posts = Post::model()->getList(array('condition' => $condition, '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, 'catalog' => $catalog, 'posts' => $datalist, 'pagebar' => $pages, 'tags' => $tags, 'last_posts' => $last_posts, 'order' => $order));
}
示例12: actionCreateInner
public function actionCreateInner()
{
parent::_acl();
//内页主类
$innerCatalog = Catalog::model()->findAll("`status_is`='Y' AND `parent_id`='2'");
// ppr($innerCatalog,1);
$page_arr = null;
if (!empty($innerCatalog)) {
foreach ($innerCatalog as $pageInfo) {
$page_arr[$pageInfo->id] = array('name' => $pageInfo->catalog_name, 'path' => $pageInfo->path, 'error' => 0);
try {
if (FALSE === strpos($pageInfo->path, 'http:')) {
if (empty($pageInfo->path)) {
$page_arr[$pageInfo->id]['error'] = '目录名未填写';
continue;
}
preg_match_all("/\\w+/", $pageInfo->path, $re);
if (empty($re[0][0])) {
$page_arr[$pageInfo->id]['error'] = '目录名只能是字母数字下划线';
continue;
}
$dir = SITE_PATH . substr($this->_conf['path_inside_page'], 1) . '/' . $re[0][0] . '/';
if (!is_dir($dir)) {
mkdir($dir);
if (!is_writable($dir)) {
$page_arr[$pageInfo->id]['error'] = '目录写入失败';
continue;
}
}
// ppr($pageInfo);ppr($this->_getDataPid($pageInfo->id));
$links = $this->_getDataPid($pageInfo->id);
// ppr($links);
//统一内页模板
$code = $this->render($this->_conf['theme'] . '/inner', array('info' => $pageInfo, 'links' => $links, 'innerCatalog' => $innerCatalog), 1);
$filename_html = $dir . 'index.html';
$filename_htm = $dir . 'index.htm';
file_put_contents($filename_html, $code, LOCK_EX);
file_put_contents($filename_htm, $code, LOCK_EX);
} else {
$page_arr[$pageInfo->id]['error'] = '已设置' . '<a href=' . $pageInfo->path . ' target="blank">外链</a>';
}
} catch (Exception $exc) {
continue;
}
}
return $page_arr;
}
}
示例13: init
public function init()
{
parent::init();
if (isset($_POST['sessionId'])) {
$session = Yii::app()->getSession();
$session->close();
$session->sessionID = $_POST['sessionId'];
$session->open();
}
$this->_admini = parent::_sessionGet('_admini');
if (empty($this->_admini['userId'])) {
$this->redirect(array('public/login'));
}
//栏目
$this->_catalog = Catalog::model()->findAll();
}
示例14: actionIndex
public function actionIndex()
{
$client = new Client();
$catalogs = Catalog::model()->findAll(array('condition' => "status='ACTIVE'", 'order' => 'category'));
$pictures = [];
$files = [];
$medio = 'default';
if (isset($_GET["medio"])) {
$medio = $_GET["medio"];
}
foreach ($catalogs as $i => $catalog) {
$pictures[$catalog->id] = $catalog->vehicle->pictures[0]->description;
$files[$catalog->id] = $catalog->file;
}
$this->render('index', array("catalogs" => $catalogs, 'client' => $client, 'pictures' => $pictures, 'files' => $files, 'medio' => $medio));
}
示例15: renderNav
public function renderNav($roots)
{
echo CHtml::openTag('ul', array('class' => $this->rootUlCss, 'id' => $this->id)) . "\n";
foreach ($roots as $root) {
$a = Catalog::model()->findByPk($root);
echo CHtml::openTag('li');
echo CHtml::openTag('a', array('href' => Yii::app()->createUrl("/post/post/index", array("catalog" => $a->url))));
echo CHtml::openTag('span');
echo CHtml::encode($a->name);
echo CHtml::closeTag('span');
echo CHtml::closeTag('a');
echo CHtml::closeTag('span');
$level = 0;
$catalogs = Catalog::model()->findByPk($a->id)->children()->findAll();
foreach ($catalogs as $n => $catalog) {
// echo CHtml::openTag('ul',array('class'=>$this->childULCss)) . "\n";
if ($catalog->level == $level) {
echo CHtml::closeTag('li') . "\n";
} else {
if ($catalog->level > $level) {
echo CHtml::openTag('ul', array('class' => $this->childULCss)) . "\n";
} else {
echo CHtml::closeTag('li') . "\n";
for ($i = $level - $catalog->level; $i; $i--) {
echo CHtml::closeTag('ul') . "\n";
echo CHtml::closeTag('li') . "\n";
}
}
}
echo CHtml::openTag('li');
echo CHtml::openTag('a', array('href' => Yii::app()->createUrl("/post/post/index", array("catalog" => $catalog->url))));
echo CHtml::openTag('span');
echo CHtml::encode($catalog->name);
echo CHtml::closeTag('span');
echo CHtml::closeTag('a');
$level = $catalog->level;
}
for ($i = $level; $i; $i--) {
echo CHtml::closeTag('li') . "\n";
echo CHtml::closeTag('ul') . "\n";
}
// echo CHtml::closeTag('li') . "\n";
}
}