public static function form() { $className = __CLASS__; $slideWidth = 'js:function(event,ui)' . <<<JS { \t\$('#{$className}_width').val(ui.value); \t{$className}_makesize(ui.value, false, ui.handle); } JS; $changeWidth = 'js:function(event,ui)' . <<<JS { \t{$className}_makesize(ui.value, false, ui.handle); } JS; $slideHeight = 'js:function(event,ui)' . <<<JS { \t\$('#{$className}_height').val(ui.value); \t{$className}_makesize(ui.value, true, ui.handle); } JS; $changeHeight = 'js:function(event,ui)' . <<<JS { \t{$className}_makesize(ui.value, true, ui.handle); } JS; $cfg = ContentUnit::loadConfig(); return array('elements' => array(Form::tab(Yii::t('UnitRandomimage.main', 'Images')), 'images' => array('type' => 'FileManager', 'width' => 900, 'height' => 350, 'multiple' => true, 'options' => array('onlyMimes' => array('image/jpeg', 'image/gif', 'image/png')), 'element' => array(array('name' => 'caption', 'type' => 'text', 'size' => 40, 'label' => Yii::t('UnitRandomimage.main', 'Caption'), 'i18n' => true))), Form::tab(Yii::t('UnitRandomimage.main', 'Size & link')), Yii::app()->controller->renderPartial($cfg['UnitImage'] . '.image.assets.imagesize', compact('className'), true), 'width' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 2000, 'step' => 1, 'slide' => $slideWidth, 'change' => $changeWidth)), 'height' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 2000, 'step' => 1, 'slide' => $slideHeight, 'change' => $changeHeight)), 'url' => array('type' => 'text', 'size' => 40), 'target' => array('type' => 'dropdownlist', 'items' => array('' => Yii::t('UnitRandomimage.main', 'Current window'), '_blank' => Yii::t('UnitRandomimage.main', 'New window'))))); }
protected function proccessRequest() { if (Yii::app()->request->getPost('logout') !== null) { Yii::app()->user->logout(); Yii::app()->controller->refresh(); return true; } if (Yii::app()->request->getPost('LoginForm') !== null) { $model = new LoginForm(); $model->attributes = Yii::app()->request->getPost('LoginForm'); if ($model->validate() && $model->login()) { Yii::app()->controller->refresh(); return true; } } if (Yii::app()->request->getPost('RememberForm') !== null) { $model = new RememberForm(); $model->attributes = Yii::app()->request->getPost('RememberForm'); if ($model->validate()) { $user = User::model()->find('`login` = :username OR `email` = :username', array('username' => $model->username)); if ($user) { $user->saveAttributes(array('authcode' => User::hash($user->id . $user->email . time() . rand()))); $cfg = ContentUnit::loadConfig(); $viewFileDir = $cfg['UnitLogin'] . '.login.templates.mail.'; $tpldata['model'] = $user; $tpldata['settings'] = Yii::app()->settings->model->getAttributes(); $tpldata['page'] = $this->params['content']->getUnitPageArray(); // send 'to_user_confirm' mail Yii::app()->messenger->send('email', $user->email, Yii::t('UnitLogin.main', 'Password reset'), Yii::app()->controller->renderPartial($viewFileDir . 'password_reset', $tpldata, true)); return true; } } } return false; }
public static function form() { $className = __CLASS__; $slideWidth = 'js:function(event,ui)' . <<<JS { \t\$('#{$className}_width').val(ui.value); \t{$className}_makesize(ui.value, false, ui.handle); } JS; $changeWidth = 'js:function(event,ui)' . <<<JS { \t{$className}_makesize(ui.value, false, ui.handle); } JS; $slideHeight = 'js:function(event,ui)' . <<<JS { \t\$('#{$className}_height').val(ui.value); \t{$className}_makesize(ui.value, true, ui.handle); } JS; $changeHeight = 'js:function(event,ui)' . <<<JS { \t{$className}_makesize(ui.value, true, ui.handle); } JS; $cfg = ContentUnit::loadConfig(); return array('elements' => array(Form::tab(Yii::t('UnitVideo.main', 'Video')), 'video' => array('type' => 'Link', 'size' => 40, 'showPageSelectButton' => false), 'show_link' => array('type' => 'checkbox'), Yii::app()->controller->renderPartial($cfg['UnitVideo'] . '.video.assets.containersize', array('attribute' => 'video', 'width' => 'width', 'height' => 'height', 'selector' => 'object, embed, iframe', 'sizes' => array('425x344' => '425 × 344', '480x385' => '480 × 385', '640x505' => '640 × 505', '960x745' => '960 × 745'), 'className' => $className), true), 'width' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 1000, 'step' => 1, 'slide' => $slideWidth, 'change' => $changeWidth)), 'height' => array('type' => 'Slider', 'event' => 'none', 'options' => array('min' => 1, 'max' => 1000, 'step' => 1, 'slide' => $slideHeight, 'change' => $changeHeight)), Form::tab(Yii::t('UnitVideo.main', 'HTML')), 'html' => array('hint' => Yii::t('UnitVideo.main', 'If the link to your video is not recognized, use the version with the html-code.'), 'type' => 'textarea', 'rows' => 6, 'cols' => 60))); }
public function init() { parent::init(); $id = __CLASS__ . $this->params['content']->id; $this->params['profileVar'] = $this->urlParam('view'); $blank = true; if (Yii::app()->request->getParam($this->params['profileVar']) !== null) { $profile = User::model()->findByPk(intval(Yii::app()->request->getParam($this->params['profileVar']))); if ($profile) { $this->params['details'] = Yii::app()->controller->widget('zii.widgets.CDetailView', array('data' => $profile, 'attributes' => $this->makeFields($this->params['content']->displayed_fields, $profile)), true); $this->params['profile'] = $profile->getAttributes(); if (Yii::app()->user->hasRole($profile->send_message) && $profile->id != $this->params['user']->id && $profile->email) { $vm = new VirtualModel($this->params['content']->feedback_form, 'FieldSet'); $config = $vm->formMap; $config['id'] = sprintf('%x', crc32(serialize(array_keys($this->params['content']->feedback_form)))); $config['buttons'] = array('send' => array('type' => 'submit', 'label' => Yii::t('UnitProfiles.main', 'Send'))); $config['activeForm'] = Form::ajaxify($config['id']); $config['activeForm']['clientOptions']['validationUrl'] = '/?r=view/widget&pageWidgetId=' . $this->params['pageWidget']->id . '&' . $this->params['profileVar'] . '=' . $profile->id; $config['activeForm']['clientOptions']['afterValidate'] = "js:function(f,d,h){if (!h) {return true;}}"; $form = new Form($config, $vm); if (Yii::app()->request->getParam('ajax-validate') !== null) { echo CActiveForm::validate($vm); Yii::app()->end(); } if ($form->submitted('send')) { $vm = $form->model; if ($form->validate()) { $cfg = ContentUnit::loadConfig(); $viewFileDir = $cfg['UnitProfiles'] . '.profiles.templates.mail.'; $labels = $vm->attributeLabels(); foreach ($vm->getAttributes() as $attr => $value) { $tpldata['fields'][$labels[$attr]] = $value; } $tpldata['profile'] = $profile->getAttributes(); $tpldata['settings'] = Yii::app()->settings->model->getAttributes(); $tpldata['page'] = $this->params['content']->getWidgetPageArray(); $registerModel = ModelRegister::model()->find('widget_id > 0'); $registerWidget = new WidgetRegister(); if ($registerUnit) { $tpldata['profileEditUrl'] = $registerModel->getWidgetUrl(); $tpldata['profileEditUrlParams'] = $registerWidget->urlParam('do') . '=edit'; } Yii::app()->messenger->send('email', $profile->email, '[' . $_SERVER['HTTP_HOST'] . '] ' . Yii::t('UnitProfiles.main', 'Feedback form'), Yii::app()->controller->renderPartial($viewFileDir . 'feedback', $tpldata, true)); Yii::app()->user->setFlash('UnitProfilesSend-permanent', Yii::t('UnitProfiles.main', 'Your message was successfully sent')); Yii::app()->controller->refresh(); } } $this->params['feedbackForm'] = $form->render(); } } else { $this->params['error'] = Yii::t('UnitProfiles.main', 'Profile not found'); } $blank = false; } if ($blank) { $this->prepareTable(); } }
public function installAll($withUnits = true) { if (!$this->allowAccess()) { return false; } foreach (Yii::app()->params['coreModels'] as $className) { $this->installTable($className); $this->installDefaultAccess($className); } if ($withUnits) { ContentUnit::install(array_keys(ContentUnit::getAvailableUnits())); } }
public function init() { if (!is_file(Yii::getPathOfAlias('config.general') . '.php')) { // ToDo: Сделать вызов инсталлятора Yii::app()->end(); } ini_set('mbstring.internal_encoding', 'UTF-8'); ini_set('mbstring.func_overload', 2); if (Yii::app()->settings->getValue('timezone')) { $timezone = Yii::app()->settings->getValue('timezone'); if (Yii::app()->user->data && Yii::app()->user->data->timezone) { $timezone = Yii::app()->user->data->timezone; } date_default_timezone_set($timezone); $tz = date("Z"); $tz = sprintf('%s%02d:%02d', $tz < 0 ? '-' : '+', abs($tz / 3600), abs($tz % 3600) / 60); Yii::app()->db->createCommand('set @@session.time_zone = "' . $tz . '";')->execute(); } $language = 'en'; $langs = array_keys(I18nActiveRecord::getLangs()); if (Yii::app()->request->preferredLanguage && in_array(Yii::app()->request->preferredLanguage, $langs)) { $language = Yii::app()->request->preferredLanguage; } if (Yii::app()->settings->getValue('language')) { $language = Yii::app()->settings->getValue('language'); } if (isset($_REQUEST['language']) && in_array($_REQUEST['language'], $langs)) { $language = $_REQUEST['language']; } if (!in_array($language, $langs)) { $language = $langs[0]; } Yii::app()->language = $language; // $e = Yii::app()->user->checkAccess('read', array('object' => array('Page', 1))); // echo intval($e); // Yii::app()->end(); if (!Yii::app()->request->isAjaxRequest) { Yii::app()->getClientScript()->registerCssFile(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.css')) . '/icons/' . Yii::app()->params['icons'] . '.css'); } ContentUnit::loadUnits(); Yii::app()->getClientScript()->packages = (require Yii::getPathOfAlias('application.config') . '/packages.php'); }
public function actionFeed($type = 'rss') { header('Content-Type: application/rss+xml'); if (Yii::app()->request->getQuery('model') !== null) { $modelClass = 'Model' . ucfirst(Yii::app()->request->getQuery('model')); ContentUnit::loadUnits(); if (!FeedHelper::isFeedPresent($modelClass, Yii::app()->request->getQuery('id') === null)) { throw new CHttpException(404, Yii::t('cms', 'The requested page does not exist.')); } // Фид определенного раздела if (Yii::app()->request->getQuery('id') !== null && ($content = call_user_func(array($modelClass, 'model'))->findByPk(intval(Yii::app()->request->getQuery('id'))))) { FeedHelper::renderFeed($type, $content); // Фид всех записей этого типа } else { FeedHelper::renderFeed($type, $modelClass); } // Общий фид } else { FeedHelper::renderFeed($type); } }
public function form() { $timezoneList = timezone_identifiers_list(); sort($timezoneList); $timezoneList = array_combine($timezoneList, $timezoneList); // Общие настроки $ret = array('elements' => array(Form::tab(Yii::t('cms', 'General settings')), 'sitename' => array('type' => 'text', 'size' => 60), 'adminEmail' => array('type' => 'text', 'size' => 60), 'language' => array('type' => 'LanguageSelect', 'empty' => null), 'timezone' => array('type' => 'dropdownlist', 'items' => $timezoneList), 'autoSave' => array('type' => 'checkbox'), 'slugTransliterate' => array('type' => 'checkbox'), 'slugLowercase' => array('type' => 'checkbox'), 'pageOnError403' => array('type' => 'PageSelect'), 'pageOnError404' => array('type' => 'PageSelect'), Form::tab(Yii::t('cms', 'Appearance')), 'theme' => array('type' => 'ThemeSelect', 'empty' => null), 'defaultsPerPage' => array('type' => 'Slider', 'options' => array('min' => 1, 'max' => 50)), 'showWidgetAppearance' => array('type' => 'checkbox'), 'ajaxPager' => array('type' => 'checkbox'), 'ajaxPagerScroll' => array('type' => 'checkbox'), Form::tab(Yii::t('cms', 'Users')), 'defaultsShowEmail' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'defaultsSendMessage' => array('type' => 'dropdownlist', 'items' => Role::builtInRoles()), 'userExtraFields' => array('type' => 'FieldSet'), Form::tab(Yii::t('cms', 'Performance')), 'cacheTime' => array('type' => 'Slider', 'options' => array('min' => 0, 'max' => 3600, 'step' => 60), 'hint' => Yii::t('cms', 'in seconds, 0 = off, 3600 - one hour')))); // Настройки для юнитов $units = ContentUnit::getInstalledUnits(); $ret['elements'][] = Form::tab(Yii::t('cms', 'Units settings')); foreach ($units as $unitClass) { if (method_exists($unitClass, 'settings')) { $elems = call_user_func(array($unitClass, 'settings'), $unitClass); if (is_array($elems) && !empty($elems)) { $ret['elements'][] = Form::section(call_user_func(array($unitClass, 'name'))); foreach ($elems as $k => $elem) { $ret['elements'][$unitClass . '.' . $k] = $elem; } } } } return self::localizedForm($ret); }
public static function getHtmlByUrl($url, $width = 0, $height = 0, $title = '') { /* * TODO: * - vkontakte.ru * - video.yandex.ru * - bbc ? * - cnn ? * - */ $vs = array('youtube.com' => array('pattern' => "|youtube\\.com([^0-9\\?\\#\\=]*)(\\?v[=/])?(#p/u/)?([0-9]*/)?([a-zA-Z0-9\\-]*)|msi", 'match' => 5, 'width' => 480, 'height' => 270, 'view' => 'youtube'), 'youtu.be' => array('pattern' => "|youtu\\.be\\/([a-zA-Z0-9\\-]*)|msi", 'match' => 1, 'width' => 480, 'height' => 270, 'view' => 'youtube'), 'vimeo.com' => array('pattern' => "|vimeo\\.com(/video)?/([0-9]*)|msi", 'match' => 2, 'width' => 480, 'height' => 270, 'view' => 'vimeo'), 'rutube.ru' => array('pattern' => "|rutube\\.ru.*v=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 360, 'view' => 'rutube'), 'godtube.com' => array('pattern' => "|godtube\\.com.*v[=/]([a-zA-Z0-9]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'godtube'), 'tangle.com' => array('pattern' => "|tangle\\.com.*viewkey=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'tangle'), 'video.google.com' => array('pattern' => "|google\\.com.*docid=([\\-0-9]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'google'), 'myspace.com' => array('pattern' => "|myspace\\.com.*videoid=([0-9]*)|msi", 'match' => 1, 'width' => 425, 'height' => 360, 'view' => 'myspace'), 'dailymotion.com' => array('pattern' => "|dailymotion\\.com/video/([^?]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'dailymotion'), 'truegod.tv' => array('pattern' => "|truegod\\.tv.*viewkey=([0-9a-f]*)|msi", 'match' => 1, 'width' => 480, 'height' => 385, 'view' => 'truegod'), 'smotri.com' => array('pattern' => "|smotri\\.com.*id=([0-9a-z]*)|msi", 'match' => 1, 'width' => 640, 'height' => 360, 'view' => 'smotri'), '1tv.ru' => array('pattern' => "|1tv\\.ru[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 460, 'height' => 353, 'view' => '1tv'), 'video.bigmir.net' => array('pattern' => "|bigmir\\.net[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 608, 'height' => 342, 'view' => 'bigmir'), 'video.online.ua' => array('pattern' => "|online\\.ua[^0-9]*([0-9]*)|msi", 'match' => 1, 'width' => 640, 'height' => 400, 'view' => 'online_ua'), 'vision.rambler.ru' => array('pattern' => "|rambler\\.ru/users/(.*)|msi", 'match' => 1, 'width' => 480, 'height' => 291, 'view' => 'rambler'), 'video.utro.ua' => array('pattern' => "|utro\\.ua.*id=([0-9a-z]*)|msi", 'match' => 1, 'width' => 640, 'height' => 360, 'view' => 'utro'), 'nbc.com' => array('pattern' => "|nbc\\.com/[^/]*/video/[^/]*/([0-9]*)|msi", 'match' => 1, 'width' => 512, 'height' => 347, 'view' => 'nbc'), $_SERVER['HTTP_HOST'] => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer'), '.flv' => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer'), '.mp4' => array('pattern' => "|(.*)|msi", 'match' => 1, 'width' => 492, 'height' => 300, 'view' => 'jwplayer')); foreach ($vs as $site => $arr) { if (strpos($url, $site) !== false) { preg_match($arr['pattern'], $url, $matches); $id = $matches[$arr['match']]; $w = $width ? $width : $arr['width']; $h = $height ? $height : $arr['height']; $cfg = ContentUnit::loadConfig(); return Yii::app()->controller->renderPartial($cfg['UnitVideo'] . '.video.codes.' . $arr['view'], array('id' => $id, 'width' => $w, 'height' => $h, 'title' => $title), true); } } return false; }
/** * Страница инсталляции/деинсталляции блоков */ public function actionInstall() { $allUnits = ContentUnit::getAvailableUnits(); $errors = array(); if (isset($_POST['Units'])) { $units = array_keys($_POST['Units']); ContentUnit::install($units); $uninstall = array_diff(array_keys($allUnits), $units); foreach ($uninstall as $i => $className) { $sql = 'SELECT count(*) FROM `' . Widget::tableName() . '` WHERE `class` = :class'; $command = Yii::app()->db->createCommand($sql); $command->bindValue(':class', $className, PDO::PARAM_STR); $exists = $command->queryScalar(); if ($exists) { unset($uninstall[$i]); $errors[] = Yii::t('cms', 'Can\\`t unistall "{name}"', array('{name}' => $allUnits[$className]['name'])); } } ContentUnit::uninstall($uninstall); $allUnits = ContentUnit::getAvailableUnits(); } $this->render('install', array('units' => $allUnits, 'errors' => $errors)); }
public static function getInstalledWidgets() { $units = ContentUnit::getInstalledUnits(true); $return = array(); $unitConfig = ContentUnit::loadConfig(); foreach ($units as $unitClassName => $name) { $unit = array('className' => $unitClassName, 'name' => $name, 'icon' => call_user_func(array($unitClassName, 'icon')), 'widgets' => array()); $dir = strtolower(substr($unitClassName, 4)); $widgets = call_user_func(array($unitClassName, 'widgets')); foreach ($widgets as $className => $alias) { if (is_int($className)) { $className = $alias; $alias = $unitConfig[$unitClassName] . '.' . $dir . '.' . $className; } $unit['widgets'][] = array('className' => $className, 'name' => call_user_func(array($className, 'name')), 'icon' => call_user_func(array($className, 'icon'))); } $return[] = $unit; } return $return; }
height: Math.ceil(\$(window).height()*0.5), width: 400 }); return false; } JS ) : null))); $buttons = array('filemanager' => array('icon' => 'files', 'title' => Yii::t('cms', 'File manager'), 'click' => 'js:function()' . <<<JS { var url = '/?r=files/manager&language={$language}'; window.open( url, 'filemanager','width=950, height=550, location=0, status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes'); return false; } JS )); $units = ContentUnit::getInstalledUnits(true); $modelToolbars = ''; foreach ($units as $unitClassName => $unitName) { $widgets = call_user_func(array($unitClassName, 'widgets')); $models = array(); foreach ($widgets as $widgetClassName) { $models[] = call_user_func(array($widgetClassName, 'modelClassName')); } $models = array_diff(call_user_func(array($unitClassName, 'models')), $models); foreach ($models as $modelClassName) { $buttons[$modelClassName] = array('icon' => 'data', 'title' => call_user_func(array($modelClassName, 'modelName')), 'click' => 'js:function()' . <<<JS { cmsLoadDialog('/?r=records/list&className={$modelClassName}&language={$language}'); return false; } JS
protected function proccessRequest($model = null) { if (Yii::app()->request->getPost('User') !== null) { if (!$model) { $model = new User('register'); $model->makeForm('register', $this->params['content']->fields, $this->params['content']->fields_req); } $tpldata = array(); $model->attributes = Yii::app()->request->getPost('User'); if ($model->password == '') { $model->password = $model->password_repeat = $tpldata['generatedPassword'] = User::generatePassword(); $model->askfill = true; } if ($model->validate()) { $model->save(false); $cfg = ContentUnit::loadConfig(); $viewFileDir = $cfg['UnitRegister'] . '.register.templates.mail.'; $tpldata['model'] = $model->getAttributes(); $tpldata['settings'] = Yii::app()->settings->model->getAttributes(); $tpldata['page'] = $this->params['content']->getWidgetPageArray(); if ($this->params['content']->notify_admin) { // send 'to_admin_notify' mail Yii::app()->messenger->send('email', Yii::app()->settings->getValue('adminEmail'), '[' . $_SERVER['HTTP_HOST'] . '] ' . Yii::t('UnitRegister.main', 'New user registration'), Yii::app()->controller->renderPartial($viewFileDir . 'to_admin_notify', $tpldata, true)); } if ($this->params['content']->is_emailauth_req) { $model->saveAttributes(array('authcode' => User::hash($model->id . $model->login . time() . rand()))); $tpldata['model'] = $model; // send 'to_user_confirm' mail Yii::app()->messenger->send('email', $model->email, Yii::t('UnitRegister.main', 'Registration confirm'), Yii::app()->controller->renderPartial($viewFileDir . 'to_user_confirm', $tpldata, true)); return true; } else { $model->saveAttributes(array('active' => true)); if ($this->params['content']->notify_user || $tpldata['generatedPassword']) { // send 'to_user_notify' mail Yii::app()->messenger->send('email', $model->email, Yii::t('UnitRegister.main', 'Registration completed'), Yii::app()->controller->renderPartial($viewFileDir . 'to_user_notify', $tpldata, true)); } $loginForm = new LoginForm(); $loginForm->username = $model->email; $loginForm->password = !empty($_POST['User']['password']) ? $_POST['User']['password'] : $tpldata['generatedPassword']; if ($loginForm->login()) { return true; } } } } return false; }
public static function getInstalledModels($flatten = false) { $units = ContentUnit::getInstalledUnits(true); $return = array(); $unitConfig = ContentUnit::loadConfig(); foreach ($units as $unitClassName => $name) { $unit = array('className' => $unitClassName, 'name' => $name, 'icon' => call_user_func(array($unitClassName, 'icon')), 'models' => array()); $dir = strtolower(substr($unitClassName, 4)); $models = call_user_func(array($unitClassName, 'models')); foreach ($models as $className => $alias) { if (is_int($className)) { $className = $alias; $alias = $unitConfig[$unitClassName] . '.' . $dir . '.' . $className; } $unit['models'][] = array('className' => $className, 'name' => call_user_func(array($className, 'modelName')), 'icon' => call_user_func(array($className, 'icon'))); } $return[] = $unit; } if ($flatten) { $units = $return; $models = array(); foreach ($units as $unit) { foreach ($unit['models'] as $model) { $models[$model['className']] = $model['name']; } } $return = $models; } return $return; }
echo AdminFunctions::GetAdminActionUrl('panel', 'updatepage'); ?> " method="post" enctype="multipart/form-data"> <?php if ($item != null) { ?> <input type="hidden" name="id" value="<?php echo $item->id; ?> "> <?php } else { ?> <?php $item = new ContentUnit(); ?> <?php } ?> <label class="top-field-label">Метка:</label> <div class="field-container-long"><input type="text" name="label" class="input-main float-left" value="<?php echo $item->label; ?> "></div> <div class="hr"></div> <label class="top-field-label">Выбор состояния:</label>
protected function showTemplateSelectForType($templateType, $htmlOptions = '') { if (is_subclass_of($this->className, 'ContentWidget')) { $className = call_user_func(array($this->className, 'unitClassName')); } else { $className = $this->className; } $data = array_keys(ContentUnit::getTemplates($className, $templateType)); $data = array_combine($data, $data); if ($this->hideDefault) { unset($data['default']); } $value = $this->hasModel() ? $this->model->{$this->attribute} : $this->value; $array_value = @unserialize($value); if ($array_value !== false && isset($array_value[$templateType])) { $value = $array_value[$templateType]; } if (is_array($data)) { $data = array_merge(array('' => Yii::t('cms', $this->empty)), $data); if (!$htmlOptions) { $htmlOptions = $this->htmlOptions; } echo CHtml::dropDownList($htmlOptions['name'], $value, $data, $htmlOptions); } }
public function settingsRules() { return array_merge(parent::settingsRules(__CLASS__), array(array('show_border', 'boolean'))); }
oneAtTime: false, appendType: 'append' }) .css({ 'position': 'fixed', 'marginTop': '10px', 'left': Math.ceil(\$('body').width()/2-125)+'px', 'width': '300px', 'z-index': '100000' }); JS , CClientScript::POS_READY); $js = ''; $flashes = Yii::app()->user->getFlashes(false); $unitConfig = ContentUnit::loadConfig(); if (Yii::app()->user->hasState('askfill') && isset($unitConfig['register'])) { $registerModel = ModelRegister::model()->find('widget_id > 0'); if ($registerModel) { $shortMessage = '<a href=\'' . $registerModel->getWidgetUrl() . '\'>' . Yii::t('cms', 'Please fill all required fields in your personal profile. And if necessary, change your password.') . '</a>'; $message = '<h3>' . Yii::t('cms', 'Attention') . '</h3><p>' . $shortMessage . '</p>'; if (Yii::app()->user->getState('askfill') == 'first') { $fancyPath = $am->publish(Yii::getPathOfAlias('application.vendors.fancybox')); $cs->registerScriptFile($fancyPath . '/jquery.fancybox-1.3.1.pack.js'); $cs->registerCssFile($fancyPath . '/jquery.fancybox-1.3.1.css'); $js .= '$.fancybox("' . $message . '");'; Yii::app()->user->setState('askfill', 'second'); } else { $flashes['askfill-permanent'] = $shortMessage; } }
public function actionUpdatePage() { /* @var $item ContentUnit */ //get parameters from request $id = Yii::app()->request->getParam('id', null); $label = Yii::app()->request->getParam('label', ''); $status = Yii::app()->request->getParam('status', Constants::STATUS_HIDDEN); $tree_id = Yii::app()->request->getParam('tree_id', ''); //get multi-language arrays $titles = Yii::app()->request->getParam('title', array()); $texts = Yii::app()->request->getParam('text', array()); //try find by id $item = ContentUnit::model()->findByPk($id); //if not found - that means we need create if ($item == null) { $item = new ContentUnit(); } //changed category or not $changed = false; if (!$item->getIsNewRecord() && $item->tree_id != $tree_id) { $changed = true; } //set main params $item->label = $label; $item->status = $status; $item->type = Constants::TYPE_TEXT_BLOCK; $item->tree_id = $tree_id; //upload thumbnail $old_f_name = $item->thumb; $new_f_name = DwHelper::uploadPicAndGetPath($_FILES, 'thumbnail', $old_f_name); if ($new_f_name != "") { $item->thumb = $new_f_name; } //if this is creation if ($item->getIsNewRecord()) { //set new priority considering category if ($tree_id != '') { $item->priority = DwHelper::getNextPriorityComplex("ContentUnit", $tree_id, "tree_id"); } else { $item->priority = DwHelper::getNextPriority("ContentUnit"); } //set dates $item->date_created = time(); $item->date_changed = time(); //save $item->save(); } else { //if changed category - get next priority in category if ($changed) { $item->priority = DwHelper::getNextPriorityComplex("ContentUnit", $tree_id, "tree_id"); } //set date of changing $item->date_changed = time(); //update $item->update(); } //get language objects foreach (Constants::GetLngArray() as $lng) { //get lng object $itemLng = $item->getLngObject($lng); //set data $itemLng->title = $titles[$lng]; $itemLng->text = $texts[$lng]; //update or create if not exist if ($itemLng->getIsNewRecord()) { $itemLng->save(); } else { $itemLng->update(); } } //prefix for category in url $prefixRedirect = ""; //if have category - set url prefix if ($tree_id != '') { $prefixRedirect = "/cat/" . $tree_id; } //back to list $this->redirect($this->createUrl('/admin/panel/pageslist' . $prefixRedirect)); }