public function actionViewDocument() { if (isset($_GET['doc_id'])) { $doc_id = StringHelper::filterString($_GET['doc_id']); $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id))); $spCriteria = new CDbCriteria(); $spCriteria->select = "*"; $spCriteria->condition = "doc_id = :doc_id"; $spCriteria->params = array(':doc_id' => $doc_id); $subject_doc = SubjectDoc::model()->find($spCriteria); $spjCriteria = new CDbCriteria(); $spjCriteria->select = "*"; $spjCriteria->condition = "subject_id = :subject_id"; $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id); $subject = Subject::model()->find($spjCriteria); $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()")); foreach ($detail_doc as $detail) { $title = $detail->doc_name . " | Bluebee - UET"; $this->pageTitle = $title; if ($detail->doc_type == 3) { $image = Yii::app()->getBaseUrl(true) . $detail->doc_url; } else { $image = $detail->doc_url; } $des = $detail->doc_description; Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width')); Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height')); Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type')); Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description')); } $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject)); } }
public function saveDoc($doc_name, $doc_description, $doc_url, $doc_author, $subject_id, $doc_scribd_id, $doc_type, $doc_path, $doc_author_name) { $doc_data = Subject::model()->findByAttributes(array('subject_id' => $subject_id)); $doc_model = new Doc(); $doc_model->doc_name = $doc_name; $doc_model->doc_description = $doc_description; $doc_model->doc_url = $doc_url; $doc_model->subject_type = $doc_data->subject_type; $doc_model->doc_path = $doc_path; $doc_model->subject_faculty = $doc_data->subject_faculty; $doc_model->subject_dept = $doc_data->subject_dept; $doc_model->subject_general_faculty_id = $doc_data->subject_general_faculty_id; $doc_model->doc_scribd_id = $doc_scribd_id; $doc_model->doc_type = $doc_type; $doc_model->doc_status = 1; $doc_model->doc_author_name = $doc_author_name; $doc_model->doc_author = $doc_author; $doc_model->save(FALSE); $doc_subject = new SubjectDoc(); $doc_subject->doc_id = $doc_model->doc_id; $doc_subject->doc_type = $doc_model->doc_type; $doc_subject->subject_id = $subject_id; $doc_subject->active = 1; $doc_subject->save(FALSE); }
protected function afterSave() { parent::afterSave(); if ($this->getIsNewRecord() && $this->scenario == "fromAdmin") { $sub_doc = new SubjectDoc(); $sub_doc->subject_id = $this->subject_doc; $sub_doc->doc_id = $this->doc_id; $sub_doc->save(FALSE); } }