本文整理汇总了PHP中Publication::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Publication::model方法的具体用法?PHP Publication::model怎么用?PHP Publication::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publication
的用法示例。
在下文中一共展示了Publication::model方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
if (($model = Publication::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('PublicationModule.publication', 'Page was not found!'));
}
return $model;
}
示例2: onGenerate
/**
* @param Event $event
*/
public static function onGenerate(Event $event)
{
$generator = $event->getGenerator();
$provider = new CActiveDataProvider(Publication::model()->published());
foreach (new CDataProviderIterator($provider) as $item) {
$generator->addItem(Yii::app()->createAbsoluteUrl('/news/news/view', ['alias' => $item->alias]), strtotime($item->update_time), SitemapHelper::FREQUENCY_WEEKLY, 0.5);
}
}
示例3: actionView
public function actionView($alias)
{
$model = Publication::model()->published()->with('user')->findByAlias($alias);
if (is_null($model)) {
throw new CHttpException(404);
}
$this->currentCategory = !empty($model->categories) ? $model->categories[0] : null;
$this->render('view', ['model' => $model]);
}
示例4: run
public function run()
{
if ($this->title === false) {
$this->title = Yii::t('PublicationModule.publication', 'News');
}
$criteria = new CDbCriteria();
if ($this->limit > 0) {
$criteria->limit = (int) $this->limit;
}
$models = Publication::model()->sortByDate('DESC')->published()->onMainPage()->findAll($criteria);
$this->render($this->view, ['models' => $models, 'title' => $this->title]);
}
示例5: loadData
public function loadData()
{
if (!($limit = (int) $this->module->rssCount)) {
throw new CHttpException(404);
}
$criteria = new CDbCriteria();
$criteria->order = 't.date DESC';
$criteria->limit = $limit;
$this->title = $this->yupe->siteName;
$this->description = $this->yupe->siteDescription;
$alias = Yii::app()->getRequest()->getQuery('alias');
if (!empty($categoryId)) {
$category = PublicationCategory::model()->published()->findByAlias($alias);
if (is_null($category)) {
throw new CHttpException(404);
}
$this->title = $category->title;
$this->description = $category->short_text;
$criteria->scopes(['category' => $category->id]);
}
$this->data = Publication::model()->cache($this->yupe->coreCacheTime)->published()->with('user')->findAll($criteria);
}
示例6: foreach
<td align="center"><?php
echo Yii::t('library', 'Due Date');
?>
</td>
<td align="center"><?php
echo Yii::t('library', 'Is returned');
?>
</td>
</tr>
<?php
if ($book != NULL) {
foreach ($book as $book_1) {
$bookdetails = Book::model()->findByAttributes(array('id' => $book_1->book_id));
$author = Author::model()->findByAttributes(array('auth_id' => $bookdetails->author));
$publication = Publication::model()->findByAttributes(array('publication_id' => $bookdetails->publisher));
?>
<tr>
<td align="center"><?php
echo $student->last_name . ' ' . $student->first_name;
?>
</td>
<td align="center"><?php
echo $bookdetails->isbn;
?>
</td>
<td align="center"><?php
echo $bookdetails->title;
?>
</td>
示例7: 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 = Publication::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例8: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$authordetails = Author::model()->findByAttributes(array('auth_id' => $model->author));
$publication = Publication::model()->findByAttributes(array('publication_id' => $model->publisher));
$pub_id = $model->publisher;
$model->author = $authordetails->author_name;
$model->publisher = $publication->name;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Book'])) {
//$model->attributes=$_POST['Book'];
$authordetails = Author::model()->findByAttributes(array('author_name' => $_POST['Book']['author']));
$publication = Publication::model()->findByAttributes(array('name' => $_POST['Book']['publisher']));
$model->attributes = $_POST['Book'];
if ($authordetails != NULL) {
$model->author = $authordetails->auth_id;
}
if ($publication == NULL) {
$publication1 = Publication::model()->findByAttributes(array('publication_id' => $pub_id));
$publication1->name = $_POST['Book']['publisher'];
$publication1->save();
$model->publisher = $publication1->publication_id;
} else {
$model->publisher = $publication->publication_id;
}
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model));
}
示例9: actionIndex
public function actionIndex()
{
$publications = Publication::model()->findAll();
$this->render('index', array('publications' => $publications));
}