示例#1
0
 protected function _load_values(array $values)
 {
     if (!empty($values['data'])) {
         $values['data'] = Kohana::unserialize($values['data']);
     }
     parent::_load_values($values);
 }
示例#2
0
 public function code()
 {
     if ($this->_code === FALSE) {
         try {
             $this->_code = Kohana::unserialize($this->code);
         } catch (Exception $e) {
             $this->_code = new Model_Widget_HTML();
         }
         $this->_code->id = $this->id;
     }
     return $this->_code;
 }
示例#3
0
 /**
  * 
  * @param string $keyword
  * @param boolean $only_title
  * @param string $modules
  * @param integer $limit
  * @param integer $offset
  * @return array
  */
 public function find_by_keyword($keyword, $only_title = FALSE, $modules = NULL, $limit = 50, $offset = 0)
 {
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start('Search', __FUNCTION__);
     }
     $query = DB::select('id', 'module', 'title', 'annotation', 'params')->from('search_index');
     $result = $this->_get_query($query, $keyword, $only_title, $modules, $limit, $offset)->execute()->as_array();
     $ids = array();
     foreach ($result as $row) {
         $row['params'] = Kohana::unserialize($row['params']);
         $ids[$row['module']][$row['id']] = $row;
     }
     if (isset($benchmark)) {
         Profiler::stop($benchmark);
     }
     return $ids;
 }
示例#4
0
文件: meta.php 项目: ZerGabriel/cms-1
 /**
  * 
  * @param string $key
  * @param mixed $default
  * @param integer $user_id
  * @return mixed
  */
 public static function get($key, $default = NULL, $user_id = NULL)
 {
     if ($user_id === NULL) {
         $user_id = Auth::get_id();
     }
     self::_load($user_id);
     $value = Arr::path(self::$_cache, $user_id . '.' . $key);
     if ($value !== NULL) {
         return @Kohana::unserialize($value);
     } else {
         if ($user_id === 0) {
             return $default;
         }
         self::_load(0);
         $value = Arr::path(self::$_cache, 0 . '.' . $key);
         if ($value !== NULL) {
             return @Kohana::unserialize($value);
         } else {
             return $default;
         }
     }
 }
示例#5
0
 /**
  * 
  * @param array $data
  * @return Model_Widget_Decorator
  */
 public static function load_from_array(array $data)
 {
     if (empty($data) or !self::exists_by_type($data['type'])) {
         return NULL;
     }
     $widget = Kohana::unserialize($data['code']);
     unset($data['code'], $data['type']);
     foreach ($data as $key => $value) {
         $widget->{$key} = $value;
     }
     self::$_cache[$widget->id] = $widget;
     return $widget;
 }
示例#6
0
文件: type.php 项目: ZerGabriel/cms-1
 public function data()
 {
     return Kohana::unserialize($this->data);
 }
示例#7
0
文件: orm.php 项目: ZerGabriel/cms-1
 /**
  * Prepares the database connection and reloads the object.
  *
  * @param string $data String for unserialization
  * @return  void
  */
 public function unserialize($data)
 {
     // Initialize model
     $this->_initialize();
     foreach (Kohana::unserialize($data) as $name => $var) {
         $this->{$name} = $var;
     }
     if ($this->_reload_on_wakeup === TRUE) {
         // Reload the object
         $this->reload();
     }
 }
示例#8
0
 /**
  * Загрузка параметров плагина из БД
  *
  * @return \Plugin_Decorator
  */
 protected function _load_settings()
 {
     $settings = DB::select('settings')->from(Plugin::TABLE_NAME)->where('id', '=', $this->id())->cache_key(Plugin::CACHE_KEY . '::plugin::' . $this->id())->cached(Date::DAY)->limit(1)->execute()->get('settings');
     $this->_settings = !empty($settings) ? Kohana::unserialize($settings) : array();
     return $this;
 }
示例#9
0
 /**
  * Загрузка разедла из массива данных
  * 
  * @param array $data
  * @return Datasource_Section
  */
 public static function load_from_array(array $data)
 {
     $section = Kohana::unserialize($data['code']);
     $section->_id = $data['id'];
     $section->name = $data['name'];
     $section->description = Arr::get($data, 'description');
     $section->_docs = (int) Arr::get($data, 'docs');
     $section->_is_indexable = (bool) Arr::get($data, 'indexed');
     $section->_created_by_id = (int) Arr::get($data, 'created_by_id');
     $section->_folder_id = (int) Arr::get($data, 'folder_id');
     return $section;
 }
示例#10
0
 /**
  * Преобразование массива в объект поля
  * 
  * @see DataSource_Hybrid_Field_Factory::get_fields()
  * 
  * @param array $array
  * @return null|\DataSource_Hybrid_Field
  * @throws Kohana_Exception
  */
 public static function get_field_from_array(array $array = NULL)
 {
     if (empty($array) or !isset($array['type'])) {
         return NULL;
     }
     $class_name = 'DataSource_Hybrid_Field_' . $array['type'];
     if (!class_exists($class_name)) {
         return NULL;
     }
     if (isset($array['props'])) {
         $props = Kohana::unserialize($array['props']);
         unset($array['props']);
         if (is_array($props)) {
             $array = Arr::merge($array, $props);
         }
     }
     $result = DataSource_Hybrid_Field::factory($array['type'], $array);
     $result->set_id(Arr::get($array, 'id'));
     $result->set_ds(Arr::get($array, 'ds_id'));
     return $result;
 }