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;
 }
 /**
  * @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);
     }
 }
 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]);
 }
 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]);
 }
 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
0
<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>
 /**
  * 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
0
 /**
  * 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
0
 public function actionIndex()
 {
     $publications = Publication::model()->findAll();
     $this->render('index', array('publications' => $publications));
 }