本文整理汇总了PHP中Content::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::model方法的具体用法?PHP Content::model怎么用?PHP Content::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Provides functionality to view a given profile
* @param int $id The ID belonging to the user
* @param string $displayName The user's display name. This isn't super necessary, it just is better for SEO
*/
public function actionIndex($id = NULL, $displayName = NULL)
{
// If an ID isn't provided, throw an error
if ($id === NULL) {
throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
}
// For SEO, if the display name isn't in the url, reroute it
if ($id !== NULL && $displayName === NULL) {
$model = Users::model()->findByPk($id);
if ($model === NULL || $model->status == 0) {
throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
} else {
$this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\\da-z]/i', '', $model->displayName));
}
}
$model = Users::model()->findByPk($id);
// Don't allow null signings or invalidated users to pollute our site
if ($model->status == 0) {
throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
}
$this->pageTitle = $model->displayName . ' | ' . Cii::getConfig('name', Yii::app()->name);
$postsCriteria = Content::model()->getBaseCriteria()->addCondition('type_id=2')->addCondition('password=""')->addCondition('author_id=:id');
$postsCriteria->params = array(':id' => $id);
$contentCount = Content::model()->count($postsCriteria);
$this->render('index', array('model' => $model, 'contentCount' => $contentCount));
}
示例2: actionContent
/**
* On given Content Class and id redirect the user to it.
*/
public function actionContent()
{
$content = Content::model()->findByAttributes(array('object_model' => Yii::app()->request->getParam('model'), 'object_id' => Yii::app()->request->getParam('id')));
if ($content != null) {
$url = $this->createUrl('WallEntry', array('id' => $content->getFirstWallEntryId()));
$this->redirect($url);
return;
}
$id = (int) Yii::app()->request->getParam('id', "");
$model = Yii::app()->request->getParam('model');
// Check given model
if (!class_exists($model)) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Unknown content class!'));
}
// Load Model and check type
$foo = new $model();
if (!$foo instanceof HActiveRecordContent && !$foo instanceof HActiveRecordContentAddon) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Invalid content class!'));
}
$model = call_user_func(array($model, 'model'));
$object = $model->findByPk($id);
if ($object == null) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Could not find requested content!'));
}
$url = $this->createUrl('WallEntry', array('id' => $object->content->getFirstWallEntryId()));
$this->redirect($url);
}
示例3: prepareMenu
public function prepareMenu()
{
switch ($this->lang) {
case 19:
$this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
$this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
$this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
break;
case 20:
$this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(10)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(11)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(12)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(13)));
$this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
$this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(5)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(6)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(7)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(8)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(9)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'About boutiques'));
break;
case 21:
$this->menu = array(0 => array('class' => 'card', 'model' => Content::model()->findByPk(14)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(15)), 2 => array('class' => 'gift', 'model' => Content::model()->findByPk(16)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(17)));
$this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => '', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
$this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(9)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(10)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(11)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(12)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(10)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'Boutiques'));
break;
default:
$this->menu = array(0 => array('class' => 'card l1', 'model' => Content::model()->findByPk(1)), 1 => array('class' => 'product l1', 'model' => Content::model()->findByPk(2)), 2 => array('class' => 'gift l1', 'model' => Content::model()->findByPk(3)), 3 => array('class' => 'week l1', 'model' => Content::model()->findByPk(4)));
$this->innerMenu = array(0 => array('class' => 'bottle_product', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol_product', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz_product', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories_product', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine_product', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique_product', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
$this->catalogMenu = array(0 => array('class' => 'bottle', 'model' => CatalogCategories::model()->findByPk(1)), 1 => array('class' => 'alcohol', 'model' => CatalogCategories::model()->findByPk(2)), 2 => array('class' => 'fizz', 'model' => CatalogCategories::model()->findByPk(3)), 3 => array('class' => 'accessories', 'model' => CatalogCategories::model()->findByPk(4)), 4 => array('class' => 'read_wine', 'model' => NewsCategories::model()->findByPk(15)), 5 => array('class' => 'boutique', 'model' => null, 'url' => '/boutiques', 'name' => 'О бутиках'));
break;
}
}
示例4: run
public function run()
{
parent::run();
$data['cnn'] = Content::model()->findAll(array("condition" => "category_id = 31 and state = 1", "order" => "id desc", "limit" => 6));
$data['count'] = Content::model()->count(array("condition" => "category_id = 31 and state = 1", "order" => "id desc"));
$this->render('study_by_cnn', $data);
}
示例5: onIntegrityCheck
/**
* On run of integrity check command, validate all wall data
*
* @param type $event
*/
public static function onIntegrityCheck($event)
{
$integrityChecker = $event->sender;
$integrityChecker->showTestHeadline("Validating Wall Module (" . WallEntry::model()->count() . " entries)");
foreach (WallEntry::model()->with('content')->findAll() as $w) {
if ($w->content === null) {
$integrityChecker->showFix("Deleting wall entry id " . $w->id . " without assigned wall entry!");
if (!$integrityChecker->simulate) {
$w->delete();
}
continue;
}
}
//TODO: Maybe not the best place for that
$integrityChecker->showTestHeadline("Validating Content Objects (" . Content::model()->count() . " entries)");
foreach (Content::model()->findAll() as $content) {
if ($content->user == null) {
$integrityChecker->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid user!");
if (!$integrityChecker->simulate) {
$content->delete();
}
continue;
}
if ($content->getUnderlyingObject() == null) {
$integrityChecker->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid content object!");
if (!$integrityChecker->simulate) {
$content->delete();
}
continue;
}
}
}
示例6: run
public function run()
{
parent::run();
$data = array();
$id_listen_cat = Category::model()->findAll("taxonomy_id = " . $this->_id_bai_hoc . " and state = 1");
$id_listen_cat_array = array();
foreach ($id_listen_cat as $k) {
$id_listen_cat_array[] = $k->id;
}
$id_news_cat = Category::model()->findAll("taxonomy_id = " . $this->_id__tintuc . " and state = 1");
$id_news_cat_array = array();
foreach ($id_news_cat as $k) {
$id_news_cat_array[] = $k->id;
}
$comment = Comment::model()->findAll(array("condition" => "state = 1", "limit" => 5, "order" => "id desc"));
$options = array();
$i = 0;
foreach ($comment as $k) {
$options[$i]['content'] = Content::model()->findByPk($k->content_id);
$options[$i]['category'] = Category::model()->findByPk($options[$i]['content']->category_id);
$options[$i]['parent'] = '';
if ($options[$i]['category']->parent != 0) {
$options[$i]['parent'] = Category::model()->findByPk($options[$i]['category']->parent);
}
$options[$i]['taxonomy'] = Taxonomy::model()->findByPk($options[$i]['category']->taxonomy_id);
$i++;
}
$data['comments'] = $comment;
$data['options'] = $options;
$data['news'] = Content::model()->findAll(array("condition" => "state = 1 and category_id in (" . implode(",", $id_news_cat_array) . ")", "limit" => 10, "order" => "id desc"));
$data['listen'] = Content::model()->findAll(array("condition" => "state = 1 and category_id in (" . implode(",", $id_listen_cat_array) . ")", "limit" => 10, "order" => "id desc"));
$this->render('news_lession_comment', $data);
}
示例7: run
public function run()
{
parent::run();
$data['new_music'] = Content::model()->findAll(array("condition" => "category_id = 33 and state = 1", "limit" => 20, "order" => "id desc"));
$data['hot_music'] = Content::model()->findAll(array("condition" => "category_id = 33 and state = 1", "limit" => 20, "order" => "view desc"));
$this->render('study_by_music', $data);
}
示例8: actionView
public function actionView()
{
$pid = Yii::app()->request->getParam('pid');
$cid = Yii::app()->request->getParam('cid');
$id = Yii::app()->request->getParam('id');
$category = Category::model()->findByPk($pid);
if ($category->taxonomy_id == $this->root_id) {
$data = array();
$data['item'] = Content::model()->findbyPk($id);
if ($data['item']->category_id == $cid) {
$data['cat'] = Category::model()->findbyPk($data['item']->category_id);
$data['root_cat'] = Taxonomy::model()->findbyPk($data['cat']->taxonomy_id);
$this->title = $data['item']->title;
Content::model()->updateByPk($id, array('view' => $data['item']->view + 1));
$data['comment_model'] = Comment::model()->findAll(array('condition' => 'content_id = :cid and state = 1', 'params' => array(':cid' => $id)));
if ($data['item']->category_id != $cid) {
throw new CHttpException(404, 'PAGE NOT FOUND.');
}
$this->render('view', $data);
} else {
throw new CHttpException(404, 'PAGE NOT FOUND.');
}
} else {
throw new CHttpException(404, 'PAGE NOT FOUND.');
}
}
示例9: actionIndex
/**
* Handles all incoming requests for the entire site that are not previous defined in CUrlManager
* Requests come in, are verified, and then pulled from the database dynamically
* Shows all blog posts for a particular category_id
* @param $id - The content ID that we want to pull from the database
* @return $this->render() - Render of page that we want to display
**/
public function actionIndex($id = NULL)
{
// Run a pre check of our data
$this->beforeCiiAction($id);
// Retrieve the data
$category = Categories::model()->findByPk($id);
$this->breadcrumbs = Categories::model()->getParentCategories($id);
// Parse Metadata
$meta = Categories::model()->parseMeta($category->metadata);
$this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
$layout = isset($meta['layout']) ? $meta['layout']['value'] : 'default';
// Set the layout
$this->setLayout($layout);
$data = array();
$pages = array();
$itemCount = 0;
$pageSize = Cii::getConfig('categoryPaginationSize', 10);
$criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
$criteria->limit = $pageSize;
$criteria->order = 'created DESC';
$itemCount = Content::model()->count($criteria);
$pages = new CPagination($itemCount);
$pages->pageSize = $pageSize;
$criteria->offset = $criteria->limit * $pages->getCurrentPage();
$data = Content::model()->findAll($criteria);
$pages->applyLimit($criteria);
$this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
}
示例10: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Content::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例11: run
public function run()
{
parent::run();
$data['trailer'] = Content::model()->findAll(array("condition" => "category_id = 30 and state = 1", "order" => "id desc", "limit" => 5));
$data['count_tl'] = Content::model()->count(array("condition" => "category_id = 30 and state = 1", "order" => "id desc"));
$data['voa'] = Content::model()->findAll(array("condition" => "category_id = 27 and state = 1", "order" => "id desc", "limit" => 5));
$data['count_voa'] = Content::model()->count(array("condition" => "category_id = 27 and state = 1", "order" => "id desc"));
$this->render('study_by_film', $data);
}
示例12: testRelatedContentRecord
public function testRelatedContentRecord()
{
// Create Post
$post = new Post();
$post->message = "Test";
$post->content->container = Yii::app()->user->getModel();
$this->assertTrue(isset($post->content) && $post->content instanceof Content);
$this->assertTrue($post->validate());
$this->assertTrue($post->save());
$this->assertEquals(1, Content::model()->countByAttributes(array('object_model' => 'Post', 'object_id' => $post->getPrimaryKey())));
}
示例13: page
function page()
{
$this->layout = 'layout/page';
if (!($id = $this->get('id'))) {
throw new HttpException(404);
}
if (!($content = Content::model()->findByPk($id))) {
throw new HttpException(404);
}
$this->render('page', array('content' => $content));
}
示例14: run
public function run()
{
parent::run();
$data['count_gt'] = Content::model()->count(array("condition" => "category_id = 28 and state = 1", "order" => "id desc"));
$data['giaotiep'] = Content::model()->findAll(array("condition" => "category_id = 28 and state = 1", "order" => "id desc", "limit" => 6));
$data['count_nt'] = Content::model()->count(array("condition" => "category_id = 29 and state = 1", "order" => "id desc"));
$data['noitieng'] = Content::model()->findAll(array("condition" => "category_id = 29 and state = 1", "order" => "id desc", "limit" => 6));
$data['count_ytb'] = Content::model()->count(array("condition" => "category_id = 25 and state = 1", "order" => "id desc"));
$data['youtube'] = Content::model()->findAll(array("condition" => "category_id = 25 and state = 1", "order" => "id desc", "limit" => 6));
$this->render('study_by_clip', $data);
}
示例15: disable
/**
* On global module disable, delete all created content
*/
public function disable()
{
if (parent::disable()) {
foreach (Content::model()->findAll(array('condition' => 'object_model=:cat OR object_model=:libraryitem', 'params' => array(':cat' => 'LibraryCategory', ':libraryitem' => 'LibraryItem'))) as $content) {
$content->delete();
}
return true;
}
throw new CHttpException(404);
return false;
}