function getOne() { $m = new Magazine($this->magazine_id); $this->data['magazine']['id'] = $m->id; $this->data['magazine']['years'] = $m->getPeriodMap(); $this->data['magazine']['title'] = $m->data['title']; $this->data['magazine']['rightholder'] = $m->data['rightsholder'] ? $m->data['rightsholder'] : ''; $this->data['magazine']['annotation'] = $m->data['annotation']; }
function write() { global $current_user; if (!$current_user->authorized) { throw new Exception('Access Denied'); } $id = isset(Request::$post['id']) ? (int) Request::$post['id'] : false; if (!$id) { $this->_new(); return; } $magazine = new Magazine($id); $magazine->load(); Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']]; $fields = array('title' => 'title', 'isbn' => 'ISBN', 'lang_code' => 'id_lang', 'annotation' => 'annotation'); $to_update = array(); if (isset($_FILES['cover']) && $_FILES['cover']['tmp_name']) { $folder = Config::need('static_path') . '/upload/mcovers/' . ceil($magazine->id / 5000); @mkdir($folder); chmod($folder, 755); $filename = $folder . '/' . $magazine->id . '.jpg'; $upload = new UploadAvatar($_FILES['cover']['tmp_name'], 100, 100, "simple", $filename); if ($upload->out) { $to_update['is_cover'] = 1; } else { throw new Exception('cant copy file to ' . $filename, 100); } } foreach ($fields as $field => $magazinefield) { if (!isset(Request::$post[$field])) { throw new Exception('field missed #' . $field); } if ($magazine->data[$magazinefield] !== Request::$post[$field]) { $to_update[$magazinefield] = Request::$post[$field]; } } $q = array(); foreach ($to_update as $field => &$value) { if (in_array($field, array('ISBN', 'year'))) { $value = is_numeric($value) ? $value : 0; } $q[] = '`' . $field . '`=' . Database::escape($value) . ''; } if (count($q)) { $query = 'UPDATE `magazines` SET ' . implode(',', $q) . ' WHERE `id`=' . $magazine->id; Database::query($query); MagazineLog::addLog($to_update, $magazine->data, $magazine->id); MagazineLog::saveLog($magazine->id, BookLog::TargetType_magazine, $current_user->id, BiberLog::BiberLogType_magazineEdit); $search = Search::getInstance(); /* @var $search Search */ $search->setMagazineToFullUpdate($magazine->id); } ob_end_clean(); header('Location:' . Config::need('www_path') . '/m/' . $magazine->id); exit; }
public static function listMagazine() { $magazines = Magazine::all(array('id', 'name')); $magazineRow = array(); $magazineRow[0] = "Revista"; foreach ($magazines as $magazine) { $magazineRow[$magazine->id] = $magazine->name; } return $magazineRow; }
public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Magazine::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
function getContributionMagazines($mids) { // вся периодика $query = 'SELECT `id`,`title`,`first_year`,`last_year` FROM `magazines` WHERE `id` IN (' . implode(',', $mids) . ')'; $magazines = Database::sql2array($query); foreach ($magazines as &$m) { $m['path'] = Magazine::_getUrl($m['id']); } return $magazines; }
/** * 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 $id the ID of the model to be loaded * @return Magazine the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Magazine::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $month = mb_strtolower(Magazine::getMonthName($data['publication_month']), 'UTF-8'); $year = $data['publication_year']; $imgUrl = ImageHelper::imageUrl('magazine_title', $data['filename']); if (isset($data['magazine']) && !empty($data['magazine']) && file_exists(Yii::app()->params['uploadDir'] . $data['magazine'])) { $magazine = $data['magazine']; } else { $magazine = false; } echo "<img alt='" . $data['title'] . "' title='" . $data['title'] . "' src='" . $imgUrl . "'>"; ?> <p>журнал «Atmosphera»<br><?php echo "{$month}, {$year} г."; ?> </p> <a class="button" target="helperFrame" href="<?php if ($magazine) { echo Yii::app()->createAbsoluteUrl('blogs/default/downloadFile', array('filename' => $magazine)); } else { echo '#'; } ?> ">скачать</a> <iframe style="display: none;" name="helperFrame"></iframe>
<?php $this->widget('bootstrap.widgets.TbBreadcrumb', array('links' => array(Yii::t('main', 'Magazines') => Yii::app()->createUrl('magazine'), $model->isNewRecord ? Yii::t('main', 'Create') : Yii::t('main', 'Save')))); $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'magazine-form', 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL, 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'focus' => array($model, 'filename'))); //prepeare arrays for date $arrYear = array(); $arrMonth = array(); for ($i = 2010; $i < 2030; $i++) { $arrYear[$i] = $i; } for ($i = 1; $i <= 12; $i++) { $arrMonth[$i] = Magazine::getMonthName($i); } ?> <?php echo $form->errorSummary(array($model, $portfolio), null, null, array('class' => 'alert-error')); ?> <div class="control-group"> <?php echo TbHtml::activeLabelEx($model, 'title', array('class' => 'control-label')); ?> <div class="controls"> <?php echo TbHtml::activeTextField($model, 'title', array()); ?> </div> </div> <?php
public function magazineName($id_magazine) { $magazine = Magazine::find($id_magazine); return $magazine->name; }
$this->widget('bootstrap.widgets.TbBreadcrumb', array('links' => array(Yii::t('main', 'Magazines') => Yii::app()->createUrl('magazine'), Yii::t('main', 'Index')))); echo CHtml::link('<span class="pl-10 pr-10">' . Yii::t('main', 'Create') . '</span>', Yii::app()->controller->createUrl("create"), array('id' => 'btnAdd', 'class' => 'btn fl-r mt-10 mb-10')); ?> <div class="fl-l" style="margin-top: 10px;"> <div id="div-loading" class=""></div> </div> <div class="clearfix"></div> <?php $this->widget('bootstrap.widgets.TbAlert', array('block' => true, 'fade' => true, 'closeText' => '×', 'alerts' => array('success' => array('block' => true, 'fade' => true), 'error' => array('block' => true, 'fade' => true), 'warning' => array('block' => true, 'fade' => true)))); ?> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'magazine-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => "{items}\n{pager}", 'type' => 'striped', 'htmlOptions' => array('class' => 'table-list'), 'rowCssClassExpression' => '($row % 2 ? "even" : "odd")." bColor pt-5 pb-5 pl-10 pr-10 mb-5"', 'columns' => array(array('name' => 'title', 'type' => 'raw', 'value' => '$data->title'), array('name' => 'publication_year', 'type' => 'raw', 'value' => '$data->publication_year', 'filter' => CHtml::listData(Magazine::model()->findAll(array('order' => 'publication_year ASC')), 'publication_year', 'publication_year')), array('name' => 'publication_month', 'type' => 'raw', 'value' => 'Magazine::getMonthName($data->publication_month)', 'filter' => CHtml::listData(Magazine::model()->findAll(array('order' => 'publication_month ASC')), 'publication_month', function ($obj) { return Magazine::getMonthName($obj->publication_month); })), array('htmlOptions' => array('nowrap' => 'nowrap', 'style' => 'width: 75px'), 'class' => 'common.widgets.PButtonColumn', 'deleteButtonImageUrl' => false, 'deleteButtonIcon' => false, 'template' => '{update}{delete}{onoff}', 'buttons' => array('onoff' => array('labelExpression' => '$data->is_shown == 1 ? Yii::t("main","Off"):Yii::t("main","On")', 'url' => 'Yii::app()->controller->createUrl("activate", array("id" => $data->magazine_id, "on" => (!$data->is_shown) ? 1:0))', 'cssClassExpression' => '$data->is_shown == 1 ? "button on fl-l mr-5" : "button off fl-l mr-5"', 'options' => array('rel' => 'nofollow', 'ajax' => array('type' => 'get', 'url' => 'js:$(this).attr("href")', 'beforeSend' => 'js:function() { $("#div-loading").addClass("grid-loading"); return true; }', 'success' => 'js:function(data) { $.fn.yiiGridView.update("magazine-grid"); $("#div-loading").removeClass("grid-loading"); }')), 'htmlTemplate' => '<span><b></b></span>'), 'delete' => array('label' => Yii::t("main", "Delete"), 'url' => 'Yii::app()->controller->createUrl("delete", array("id" => $data->magazine_id))', 'icon' => 'trash', 'options' => array('class' => 'button delete fl-l mr-5', 'rel' => 'nofollow', 'ajax' => array('type' => 'post', 'url' => 'js:$(this).attr("href")', 'beforeSend' => 'js:function() { $("#div-loading").addClass("grid-loading"); if (!(isDel = confirm("' . Yii::t('main', 'Are you sure to delete this item') . '?"))) $("#div-loading").removeClass("grid-loading"); return isDel; }', 'success' => 'js:function(data) { $.fn.yiiGridView.update("magazine-grid"); $("#div-loading").removeClass("grid-loading"); }')), 'htmlTemplate' => '<span><b></b></span>'), 'update' => array('label' => Yii::t("main", "Update"), 'url' => 'Yii::app()->controller->createUrl("update", array("id" => $data->magazine_id))', 'options' => array('class' => 'button edit fl-l mr-5', 'rel' => 'nofollow'), 'htmlTemplate' => '<span><b></b></span>'))))));
public function getManager($section = null) { if (Auth::user()->level == 1) { if ($section == 'clients') { $clients = Client::findParentClients(); $executive = new Client(); $this->layout->content = View::make('pages.clients', array('clients' => $clients, 'users' => $executive->executiveList())); } elseif ($section == 'contacts') { $contacts = Contact::all(); $contact = new Contact(); $this->layout->content = View::make('pages.contacts', array('contacto' => $contact, 'contacts' => $contacts, 'clients' => $contact->clientList())); } elseif ($section == 'users') { $users = User::all(); $this->layout->content = View::make('pages.users', array('users' => $users)); } else { $status = Status::findStatus($_GET); $clientsList = Client::findClientsList(); $executive = new Client(); $magazine = Magazine::listMagazine(); $edition = range(0, 200); $edition[0] = 'Edición'; $stat = new Status(); $this->layout->content = View::make('pages.statusManager', array('estatus' => $stat, 'status' => $status, 'magazine' => $magazine, 'edition' => $edition, 'clients' => $clientsList, 'executive' => $executive->executiveList())); } } else { return Redirect::to('home')->with('message', 'Debes iniciar sesión para continuar.'); } }
/** * 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 = Magazine::model()->with(array('portfolio' => array('with' => 'photos')))->findByPk($id); $model->deleteMagazine(); // 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')); } }
function getOne() { $m = new Magazine($this->magazine_id); $m->load(); $this->data['magazine']['id'] = $m->id; $langId = $m->data['id_lang']; $langCode = Config::need('default_language'); foreach (Config::$langs as $code => $id_lang) { if ($id_lang == $langId) { $langCode = $code; } } $this->data['magazine']['lang_code'] = $langCode; $this->data['magazine']['lang_title'] = Config::$langRus[$langCode]; $this->data['magazine']['lang_id'] = $langId; $this->data['magazine']['path'] = $m->getUrl(); $this->data['magazine']['isbn'] = $m->data['ISBN']; $this->data['magazine']['cover'] = $m->getCover(); $this->data['magazine']['years'] = $m->getPeriodMap(); $this->data['magazine']['title'] = $m->data['title']; $this->data['magazine']['rightholder'] = $m->data['rightsholder'] ? $m->data['rightsholder'] : ''; $this->data['magazine']['annotation'] = $m->data['annotation']; }