/** * Overload Sprig::__get() to return * * - email md5 hash for gravatar */ public function __get($name) { if ($name == 'gravatar') { $email = md5(strtolower(trim($this->email))); return $email; } else { return parent::__get($name); } }
/** * Overload Sprig::__get() to return comments array * * @param string variable name * @return mixed */ public function __get($key) { if ($key == 'comments') { return empty($this->comment) ? array() : unserialize($this->comment); } elseif ($key == 'diff') { return empty($this->_original['diff']) ? '' : unserialize($this->_original['diff']); } else { return parent::__get($key); } }
/** * Overload Sprig::__get() to get * full path */ public function __get($name) { if ($name == 'path') { return Kohana::config('blog.upload.folder').'/'.$this->filename; } else { return parent::__get($name); } }
public function __get($field) { if ($field === 'post_excerpt') { if (!parent::__get('post_excerpt')) { return Text::limit_words(parent::__get('post_content'), 50, ' ...'); } } if ($field === 'link') { return Route::get('public/blog')->uri(array('slug' => $this->slug)); } return parent::__get($field); }
/** * Overload Sprig::__get() to unserialize the data array */ public function __get($name) { if ($name == 'data') { if (empty($this->_original['data'])) { return array_fill(0, $this->_length, 0); } else { return explode(",", $this->_original['data']); } } else { return parent::__get($name); } }
/** * * @access public * @param $column - Which field to get. * @return mixed */ public function __get($column) { switch ($column) { case 'parent': return $this->parent(); case 'parents': return $this->parents(); case 'children': return $this->children(); case 'first_child': return $this->children(FALSE, 'ASC', 1); case 'last_child': return $this->children(FALSE, 'DESC', 1); case 'siblings': return $this->siblings(); case 'root': return $this->root(); case 'leaves': return $this->leaves(); case 'descendants': return $this->descendants(); default: return parent::__get($column); } }
/** * * @access public * @param $column - Which field to get. * @return mixed */ public function __get($name) { if (!$this->_init) { // The constructor must always be called first $this->__construct(); // This object is about to be loaded by mysql_fetch_object() or similar $this->state('loading'); } if (isset($this->_related[$name])) { // Shortcut to any related object return $this->_related[$name]; } switch ($name) { case 'parent': $this->parent($query); $limit = 1; break; case 'ancestors': $this->ancestors($query); $limit = FALSE; break; case 'children': $this->children($query); $limit = FALSE; break; case 'first_child': $this->children($query, FALSE, 'ASC'); $limit = 1; break; case 'last_child': $this->children($query, FALSE, 'DESC'); $limit = 1; break; case 'siblings': $this->siblings($query); $limit = FALSE; break; case 'root': $this->root($query); $limit = 1; break; case 'leaves': $this->leaves($query); $limit = FALSE; break; case 'descendants': $this->descendants($query); $limit = FALSE; break; default: return parent::__get($name); } return $this->_related[$name] = Sprig::factory($this->_model)->load($query, $limit); }