/** * 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 $id the ID of the model to be loaded * * @throws CHttpException * @return model * @internal param the $integer ID of the model to be loaded */ public function loadModel($id) { $model = Banners::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Delete page by Pk */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { $model = Banners::model()->findAllByPk($_REQUEST['id']); if (!empty($model)) { foreach ($model as $page) { $page->delete(); } } if (!Yii::app()->request->isAjaxRequest) { $this->redirect('index'); } } }
public function actionRemoveImage() { $response = array("status" => "fail"); if (isset($_REQUEST['id']) && isset($_REQUEST['field']) && isset($_REQUEST['model'])) { $id = $_REQUEST['id']; $field = $_REQUEST['field']; $modelName = $_REQUEST['model']; switch ($modelName) { case 'news': $model = News::model()->findByPk($id); break; case 'articles': $model = Articles::model()->findByPk($id); break; case 'articles_categories': $model = ArticlesCategories::model()->findByPk($id); break; case 'clinics': $model = Clinics::model()->findByPk($id); break; case 'experts': $model = Experts::model()->findByPk($id); break; case 'book_pages': $model = BookPages::model()->findByPk($id); break; case 'comments': $model = Comments::model()->findByPk($id); break; case 'banners': $model = Banners::model()->findByPk($id); break; default: $model = false; break; } if (is_object($model) && isset($model->{$field})) { $imagePath = Yii::app()->basePath . "/.." . $model->{$field}; if (is_file($imagePath)) { unlink($imagePath); $model->{$field} = ''; if ($model->save()) { $response = array("status" => "success"); } } } } echo json_encode($response); }
protected function renderContent() { $module = strtolower(Yii::app()->controller->module->id); $controller = strtolower(Yii::app()->controller->id); $action = strtolower(Yii::app()->controller->action->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); //import model Yii::import('application.modules.banner.models.Banners'); Yii::import('application.modules.banner.models.BannerCategory'); $criteria = new CDbCriteria(); $criteria->condition = 'publish = :publish AND (expired_date >= curdate() OR published_date >= curdate())'; $criteria->params = array(':publish' => 1); $criteria->order = 'published_date DESC'; if ($this->category != null) { $criteria->compare('cat_id', $this->category); } $model = Banners::model()->findAll($criteria); $this->render('front_banner_recent', array('model' => $model, 'category' => $category)); }
public function run() { $this->htmlOptions['style'] = 'width: ' . $this->width . 'px; height: ' . $this->height . 'px;'; $banner = Banners::model()->findByPK($this->banner_id); $images = $banner->images; $this->htmlOptions['id'] = "slider_banner_" . $banner->id; if ($images) { foreach ($images as $image) { $this->images[] = array('src' => $image->getUrl($this->width . "x" . $this->height, 'cropFromCenter'), 'caption' => $image->title, 'url' => $image->link); } } $this->render('index'); if (!count($this->config)) { $config = array('effect' => 'random', 'slices' => 25, 'animSpeed' => 500, 'pauseTime' => 6000, 'startSlide' => 0, 'directionNav' => true, 'directionNavHide' => true, 'controlNav' => true, 'keyboardNav' => true, 'pauseOnHover' => true, 'manualAdvance' => false, 'captionOpacity' => 0.5); } else { $config = $this->config; } $config = CJavaScript::encode($config); Yii::app()->getClientScript()->registerScript(__CLASS__, "\n\t\t\t\$('#" . $this->htmlOptions['id'] . "').nivoSlider({$config});\n\t\t"); }
protected function renderContent() { $module = strtolower(Yii::app()->controller->module->id); $controller = strtolower(Yii::app()->controller->id); $action = strtolower(Yii::app()->controller->action->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); $currentModule = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id); $currentModuleAction = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); //import model Yii::import('application.modules.banner.models.Banners'); Yii::import('application.modules.banner.models.BannerCategory'); $criteria = new CDbCriteria(); $criteria->condition = 'publish = :publish AND ((expired_date >= curdate() OR published_date >= curdate()) OR ((expired_date = :date OR expired_date = :datestr) OR published_date >= curdate()))'; $criteria->params = array(':publish' => 1, ':date' => '0000-00-00', ':datestr' => '1970-01-01'); $criteria->order = 'expired_date ASC'; if ($this->category != null) { $criteria->compare('cat_id', $this->category); } $model = Banners::model()->find($criteria); $this->render('banner_main', array('module' => $module, 'controller' => $controller, 'action' => $action, 'currentAction' => $currentAction, 'currentModule' => $currentModule, 'currentModuleAction' => $currentModuleAction, 'model' => $model, 'category' => $category)); }
/** * 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 = Banners::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Phrase::trans(193, 0)); } return $model; }
public function actionToggleActivity() { if (isset($_REQUEST['pk'])) { $model = Banners::model()->findByPk($_REQUEST['pk']); if (is_object($model)) { $model->is_active = $model->is_active ? 0 : 1; if ($model->save()) { return true; } } } return false; }
class="active"<?php } ?> ><a href="/site/lang/21">FR</a></li> </ul> </div> </div> <?php echo $content; ?> </div> </div> <?php if ($_SERVER['REQUEST_URI'] == "/" || $_SERVER['REQUEST_URI'] == "/?io=1" || Yii::app()->controller->id == 'frontCatalog' && Yii::app()->controller->action->id == 'category') { $model = Banners::model()->findAllByAttributes(array("is_active" => 1)); $href = "#"; ?> <script> $(function() { var images = [ <?php foreach ($model as $js) { switch ($this->lang) { case 19: $text = $js->text_ru; $href = $js->url; break; case 20: $text = $js->text_en; $href = $js->url;
public static function getBanners() { $model = Banners::model()->active()->findAll(); return CHtml::listData($model, 'id', 'name'); }
/** * Before save model * @return bool */ protected function beforeSave() { if (parent::beforeSave()) { if (!$this->isNewRecord) { $old_model = Banners::model()->findByPk($this->id); $old_image = $old_model->image; } else { $old_image = ''; } if ($image = CUploadedFile::getInstance($this, 'image')) { $name = md5(time() . $image) . '.' . $image->getExtensionName(); $this->image = $name; $image->saveAs($this->folder . '/' . $name); if ($old_image) { @unlink($this->folder . '/' . $old_image); } } else { $this->image = $old_image; } return true; } else { return false; } }
</div> </div> </div> </li> <?php } } ?> </ul> </div> <div class="ex-sub-reviews" style="min-height:120px;"> <?php $banners = Banners::model()->exposition()->findAll(); if ($banners) { foreach ($banners as $banner) { $src = $banner->getOrigFilePath() . $banner->image; $target = $banner->url; if (!$target) { $target = '#'; } ?> <a href="<?php echo $target; ?> "> <div class="ex-sub-review" style="background-image:url('<?php echo $src; ?>
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { $banner_path = "public/banner"; $this->media = CUploadedFile::getInstance($this, 'media'); if ($this->media instanceof CUploadedFile) { $fileName = $this->banner_id . '_' . time() . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->media->extensionName); if ($this->media->saveAs($banner_path . '/' . $fileName)) { if (BannerSetting::getInfo(1, 'media_resize') == 1) { self::resizeBanner($banner_path . '/' . $fileName, $this->category_relation->media_size); } Banners::model()->updateByPk($this->banner_id, array('media' => $fileName)); } } } }
public function actionDelete($id) { $model = Banners::model()->findByPk($id)->delete(); if (!Yii::app()->request->isAjaxRequest) { $this->redirect('/admin/banners/'); } }
</nav> <ul class="link"> <li class="twitter"><a href="https://twitter.com/#!/65doctor" target="_bank"><?php echo Yii::t('translation', 'layout.site.Follow_us_on_Twitter'); ?> </a></li> <li><a href="https://www.facebook.com/pages/65doctor/267042123402667" target="_bank"><?php echo Yii::t('translation', 'layout.site.Find_us_on_Facebook'); ?> </a></li> </ul> </div> </header><!-- //header --> <?php $specialty = Specialty::model()->findAll(array('order' => 'first_char ASC')); $banner = Banners::model()->findAll(array('order' => 'RAND()', 'limit' => '1')); $body_part = BodyPart::model()->findAll(array('condition' => 'parent_id IS NULL')); Yii::app()->clientScript->registerScript('search', "\n \$('#search_submit').click(function(){\n if( \$('#specialty').val()=='' && \$('#doctor_clinic').val() == ''){\n alert('" . Yii::t('translation', 'layout.site.Please_choose_Specialty_OR_type_Doctor_name_to_search_for_doctor') . "');\n return false;\n }\n });\n "); ?> <div class="banner"> <div class="wrapper"> <div class="search-form"> <p class="title"><strong><?php echo Yii::t('translation', 'layout.site.It_s_FREE'); ?> </strong></p> <?php echo CHtml::form(Yii::app()->createAbsoluteUrl('/search/index/'), 'get', array('id' => 'search-form', 'class' => 'jNice')); ?> <input type="hidden" name="find-doctor" value="1" /> <fieldset>
/** * @method run */ public function run() { if ($bannerarea = Bannerarea::model()->find('name=:name', array('name' => $this->areaname))) { $banners = array(); $typeRotation = false; $criteria = new CDbCriteria(); $criteria->condition = 'bannerarea=:bannerarea AND notactive<>1'; $criteria->params = array('bannerarea' => $bannerarea->id); switch ($bannerarea->mode) { case Bannerarea::SHOW_ALL: $criteria->order = 'sort_order'; break; case Bannerarea::RANDOM_ALL: $criteria->order = new CDbExpression('RAND()'); break; } $dataProvider = new CActiveDataProvider('Banners', array('criteria' => $criteria)); switch ($bannerarea->mode) { case Bannerarea::ONE_AT_ROTATION: // Поочередная ротация $typeRotation = true; $dataProvider->pagination->pageSize = 1; // Увеличиваем номер очередного баннера на 1 if (isset($bannerarea->queue)) { $bannerarea->queue = $bannerarea->queue + 1; } else { $bannerarea->queue = 0; } // Если номер больше, чем общее количество - обнуляем if ($bannerarea->queue > $dataProvider->totalItemCount - 1) { $bannerarea->queue = 0; } // Устанавливаем текущую страницу $dataProvider->pagination->currentPage = $bannerarea->queue; // Сохраняем номер очередной просмотренной страницы $bannerarea->save(); break; case Bannerarea::RANDOM_ROTATION: $typeRotation = true; $dataProvider->pagination->pageSize = 1; // Генерируем случайным образом номер баннера для показа $bannerarea->queue = mt_rand(0, $dataProvider->totalItemCount - 1); // Устанавливаем текущую страницу $dataProvider->pagination->currentPage = $bannerarea->queue; // Сохраняем номер очередной просмотренной страницы $bannerarea->save(); break; case Bannerarea::SLIDER: $this->viewName = 'slider'; $banners = Banners::model()->findAll($criteria); break; default: $dataProvider->pagination = false; break; } $this->render($this->viewName, array('dataProvider' => $dataProvider, 'itemViewName' => $this->itemViewName, 'banners' => $banners, 'typeRotation' => $typeRotation)); return parent::run(); } else { echo 'Рекламное место ' . $this->areaname . 'не найдено!'; } }
<?php $banners = Banners::model()->findAll(array('condition' => 'side=1 and status=1', 'order' => 'pos, id')); if ($banners) { ?> <div class="carusel" id="stSlider"> <?php foreach ($banners as $k => $v) { ?> <a href="<?php echo $v->link; ?> " class="<?php if ($k == 0) { ?> active<?php } ?> "><img src="<?php echo $this->getImageUrl($v, 'b'); ?> " width="100%" /></a> <?php } ?> <img src="/static/img/empty2x5.gif" width="100%" /> <div class="carusel_pages"> <?php foreach ($banners as $k => $v) { ?> <span class="dot <?php if ($k == 0) { ?> active<?php }
// } // } // else{ // if ($this->banner_type == TOP || $this->banner_type == BOTTOM) { // $ImageProcessing->file = $this->large_image; // $ImageProcessing->thumbs = self::$aSizeBannerTop; //resize Of banner // $ImageProcessing->create_thumbs(); // } // else{ // $ImageProcessing->file = $this->large_image; // $ImageProcessing->thumbs = self::$aSizeBannerMiddle; //resize Of banner // $ImageProcessing->create_thumbs(); // }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = Banners::model()->with(array('portfolio' => array('with' => 'photos')))->findByPk($id); $model->deleteBanners(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } }