当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsModel::yamlToArray方法代码示例

本文整理汇总了PHP中cmsModel::yamlToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsModel::yamlToArray方法的具体用法?PHP cmsModel::yamlToArray怎么用?PHP cmsModel::yamlToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsModel的用法示例。


在下文中一共展示了cmsModel::yamlToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getControllerInfo

 public function getControllerInfo($controller_name)
 {
     return $this->getItemByField('controllers', 'name', $controller_name, function ($item) {
         $item['options'] = cmsModel::yamlToArray($item['options']);
         return $item;
     });
 }
开发者ID:rookees,项目名称:icms2,代码行数:7,代码来源:model.php

示例2: getPresetByName

 public function getPresetByName($name)
 {
     return $this->getItemByField('images_presets', 'name', $name, function ($item, $model) {
         $item['wm_image'] = cmsModel::yamlToArray($item['wm_image']);
         return $item;
     });
 }
开发者ID:asphix,项目名称:icms2,代码行数:7,代码来源:model.php

示例3: store

 public function store($value, $is_submitted, $old_value = null)
 {
     $config = cmsConfig::getInstance();
     $files_model = cmsCore::getModel('files');
     if ($value) {
         $file = cmsModel::yamlToArray($old_value);
         $path = $config->upload_path . $file['path'];
         @unlink($path);
         $files_model->deleteFile($file['id']);
         $old_value = null;
     }
     $uploader = new cmsUploader();
     if (!$uploader->isUploaded($this->name)) {
         return $old_value;
     }
     $allowed_extensions = $this->getOption('extensions');
     $max_size_mb = $this->getOption('max_size_mb');
     if (!trim($allowed_extensions)) {
         $allowed_extensions = false;
     }
     if (!$max_size_mb) {
         $max_size_mb = 0;
     }
     $result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
     if (!$result['success']) {
         if (!empty($result['path'])) {
             $uploader->remove($result['path']);
         }
         cmsUser::addSessionMessage($result['error'], 'error');
         return null;
     }
     $file = $files_model->registerFile($result['url'], $result['name']);
     return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
 }
开发者ID:asphix,项目名称:icms2,代码行数:34,代码来源:file.php

示例4: run

 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $content_model = cmsCore::getModel('content');
     $ctype = $content_model->getContentType($id);
     $ctype = cmsEventsManager::hook("ctype_before_delete", $ctype);
     $content_model->deleteContentType($id);
     cmsEventsManager::hook("ctype_after_delete", $ctype);
     cmsCore::getModel('widgets')->deletePagesByName('content', "{$ctype['name']}.*");
     $binded_widgets = $content_model->get('widgets_bind', function ($item, $model) {
         $item['options'] = cmsModel::yamlToArray($item['options']);
         return $item;
     });
     if ($binded_widgets) {
         foreach ($binded_widgets as $widget) {
             if (isset($widget['options']['ctype_id']) && $ctype['id'] == $widget['options']['ctype_id']) {
                 $content_model->delete('widgets_bind', $widget['id']);
             }
         }
     }
     cmsCore::getController('activity')->deleteType('content', "add.{$ctype['name']}");
     $this->redirectToAction('ctypes');
 }
开发者ID:asphix,项目名称:icms2,代码行数:25,代码来源:ctypes_delete.php

示例5: feed

 private function feed()
 {
     return $this->getItem('rss_feeds', function ($item, $model) {
         $item['mapping'] = cmsModel::yamlToArray($item['mapping']);
         $item['image'] = cmsModel::yamlToArray($item['image']);
         return $item;
     });
 }
开发者ID:pin-git,项目名称:icms2,代码行数:8,代码来源:model.php

示例6: getControllerInfo

 public function getControllerInfo($controller_name)
 {
     return $this->getItemByField('controllers', 'name', $controller_name, function ($item) {
         $item['options'] = cmsModel::yamlToArray($item['options']);
         $item['title'] = string_lang($item['name'] . '_CONTROLLER', $item['title']);
         return $item;
     });
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:8,代码来源:model.php

示例7: getFeedByCtypeName

 public function getFeedByCtypeName($ctype_name)
 {
     return $this->filterEqual('ctype_name', $ctype_name)->getItem('rss_feeds', function ($item, $model) {
         $item['mapping'] = cmsModel::yamlToArray($item['mapping']);
         $item['image'] = cmsModel::yamlToArray($item['image']);
         return $item;
     });
 }
开发者ID:asphix,项目名称:icms2,代码行数:8,代码来源:model.php

示例8: loadControllers

 private static function loadControllers()
 {
     if (!isset(self::$controllers)) {
         $model = new cmsModel();
         self::$controllers = $model->useCache('controllers')->get('controllers', function ($item, $model) {
             $item['options'] = cmsModel::yamlToArray($item['options']);
             return $item;
         }, 'name');
     }
 }
开发者ID:pin-git,项目名称:icms2,代码行数:10,代码来源:controller.php

示例9: __construct

 public function __construct()
 {
     $config = cmsConfig::getInstance();
     $this->groups = array(GUEST_GROUP_ID);
     $this->ip = self::getIp();
     self::loadOnlineUsersIds();
     if (self::isSessionSet('user:id')) {
         // уже авторизован
         $this->id = self::sessionGet('user:id');
     } elseif (self::getCookie('auth')) {
         // пробуем авторизовать по кукису
         $this->id = self::autoLogin(self::getCookie('auth'));
     }
     self::deleteOldSessions($this->id);
     //
     // если авторизован, заполняем объект данными из базы
     //
     if ($this->id) {
         $model = cmsCore::getModel('users');
         $user = $model->getUser($this->id);
         if (!$user) {
             self::logout();
             return;
         }
         // если дата последнего визита еще не сохранена в сессии,
         // значит авторизация была только что
         // сохраним дату в сессии и обновим в базе
         if (!self::isSessionSet('user:date_log')) {
             self::sessionSet('user:date_log', $user['date_log']);
             $model->update('{users}', $this->id, array('date_log' => null), true);
         }
         // заполняем объект данными из базы
         foreach ($user as $field => $value) {
             $this->{$field} = $value;
         }
         // конвертим список аватаров в массив
         // к пути каждого аватара добавляем путь корня
         $this->avatar = cmsModel::yamlToArray($this->avatar);
         if ($this->avatar) {
             foreach ($this->avatar as $size => $path) {
                 $this->avatar[$size] = $config->upload_host . '/' . $path;
             }
         }
         // кешируем список друзей в сессию
         $this->recacheFriends();
         // создаем online-сессию
         self::createSession($this->id);
         // восстанавливаем те поля, которые не должны
         // изменяться в течении сессии
         $this->date_log = self::sessionGet('user:date_log');
         $this->perms = self::getPermissions($user['groups'], $user['id']);
         $this->is_logged = true;
         cmsEventsManager::hook('user_loaded', $user);
     }
 }
开发者ID:pin-git,项目名称:icms2,代码行数:55,代码来源:user.php

示例10: getPhoto

 public function getPhoto($id)
 {
     $this->select('u.nickname', 'user_nickname');
     $this->select('u.avatar', 'user_avatar');
     $this->join('{users}', 'u', 'u.id = i.user_id');
     return $this->getItemById('photos', $id, function ($item, $model) {
         $item['user'] = array('id' => $item['user_id'], 'nickname' => $item['user_nickname'], 'avatar' => $item['user_avatar']);
         $item['image'] = cmsModel::yamlToArray($item['image']);
         return $item;
     });
 }
开发者ID:asphix,项目名称:icms2,代码行数:11,代码来源:model.php

示例11: loadOptions

 /**
  * Загружает опции контроллера
  * @param string $controller_name
  * @return array
  */
 static function loadOptions($controller_name)
 {
     if (isset(self::$options_cache[$controller_name])) {
         return self::$options_cache[$controller_name];
     }
     $model = new cmsModel();
     $model->filterEqual('name', $controller_name);
     $options = $model->getFieldFiltered('controllers', 'options');
     if ($options) {
         $options = cmsModel::yamlToArray($options);
         self::$options_cache[$controller_name] = $options;
     }
     return $options;
 }
开发者ID:schednyj,项目名称:icms2,代码行数:19,代码来源:controller.php

示例12: getInput

 public function getInput($value)
 {
     $users_model = cmsCore::getModel('users');
     $items = $this->getProperty('show_all') ? array(0 => LANG_ALL) : array();
     $is_show_guests = (bool) $this->getProperty('show_guests');
     $groups = $users_model->getGroups($is_show_guests);
     foreach ($groups as $group) {
         $items[$group['id']] = $group['title'];
     }
     $this->data['groups'] = $items;
     if (!is_array($value)) {
         $value = cmsModel::yamlToArray($value);
     }
     return parent::getInput($value ? $value : array(0));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:15,代码来源:listgroups.php

示例13: deleteGroup

 public function deleteGroup($group)
 {
     $this->deleteGroupMemberships($group['id']);
     $this->deleteGroupInvites($group['id']);
     cmsCache::getInstance()->clean('groups.list');
     if ($group['logo']) {
         if (!is_array($group['logo'])) {
             $group['logo'] = cmsModel::yamlToArray($group['logo']);
         }
         $config = cmsConfig::getInstance();
         foreach ($group['logo'] as $image_url) {
             $image_path = $config->upload_path . $image_url;
             @unlink($image_path);
         }
     }
     return $this->delete('groups', $group['id']);
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:17,代码来源:model.php

示例14: run

 public function run()
 {
     $sources['photos'] = LANG_PHOTOS;
     // по каким полям поиск
     $match_fields['photos'] = array('title', 'content');
     // какие поля получать
     $select_fields['photos'] = array('id', 'content', 'image', 'slug', 'date_pub', 'title', 'rating', 'comments', 'user_id', 'sizes', 'hits_count');
     // из каких таблиц выборка
     $table_names['photos'] = 'photos';
     // получаем тут высоту строк, чтобы в шаблоне потом забрать
     $this->getRowHeight();
     return array('name' => $this->name, 'sources' => $sources, 'table_names' => $table_names, 'match_fields' => $match_fields, 'select_fields' => $select_fields, 'filters' => array('photos' => array()), 'item_callback' => function ($item, $model, $sources_name, $match_fields, $select_fields) {
         $item['image'] = cmsModel::yamlToArray($item['image']);
         $item['sizes'] = cmsModel::yamlToArray($item['sizes']);
         $item['title'] = strip_tags($item['title']);
         return $item;
     });
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:18,代码来源:fulltext_search.php

示例15: run

 public function run($id)
 {
     $menu_model = cmsCore::getModel('menu');
     $form = $this->getForm('menu', array('edit'));
     $menu = $menu_model->getMenu($id);
     if ($menu['is_fixed']) {
         $form->removeField('basic', 'name');
     }
     if ($this->request->has('submit')) {
         $new_menu = $form->parse($this->request, true);
         $errors = $form->validate($this, $new_menu);
         if (!$errors) {
             $menu_model->updateMenu($id, $new_menu);
             cmsUser::setCookiePublic('menu_tree_path', "{$id}.0");
             // обновление виджетов меню, в которых используется это меню
             if ($menu['name'] !== $new_menu['name']) {
                 $widgets_model = cmsCore::getModel('widgets');
                 $w_binds = $widgets_model->join('widgets', 'w', 'w.id = i.widget_id')->filterEqual('w.name', 'menu')->get('widgets_bind', function ($item, $model) {
                     $item['options'] = cmsModel::yamlToArray($item['options']);
                     return $item;
                 });
                 foreach ($w_binds as $w_bind) {
                     if (isset($w_bind['options']['menu']) && $w_bind['options']['menu'] === $menu['name']) {
                         $new = array('options' => $w_bind['options']);
                         $new['options']['menu'] = $new_menu['name'];
                         $widgets_model->updateWidgetBinding($w_bind['id'], $new);
                     }
                 }
             }
             $this->redirectToAction('menu');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
         $menu = $new_menu;
     }
     return $this->cms_template->render('menu_form', array('do' => 'edit', 'item' => $menu, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:38,代码来源:menu_edit.php


注:本文中的cmsModel::yamlToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。