function __get($k) { if ($k == 'logName') { return $this->name; } return parent::__get($k); }
function __get($k) { if ($k == 'editKey') { return substr($this->auth, 20, 10); } else { if ($k == 'stale') { $cutoff = time() - 365 * (24 * 60 * 60); $stamp = strtotime($this->updated); return $stamp < $cutoff; } else { if ($k == 'descriptionHtml') { return hashlinks(linkify(htmlify($this->description))); } else { if ($k == 'descriptionSummary') { return htmlify(substr_replace($this->description, ' ...', 140), false); } else { if ($k == 'rssDate') { // TODO: Is there a better way to handle the timezone? Mysql times are // GMT and have to be parsed as such. $oldtz = date_default_timezone_get(); date_default_timezone_set('GMT'); return date('D, d M Y H:i:s T', strtotime($this->updated)); date_default_timezone_set($oldtz); } } } } } return parent::__get($k); }
/** * Magic method to return the meta data like the post original fields * * @param string $key * @return string */ public function __get($key) { if (!isset($this->{$key})) { if (isset($this->term->{$key})) { return $this->term->{$key}; } } return parent::__get($key); }
function __get($k) { if ($k == 'friendly_created') { $ts = strtotime($this->created); return strftime('%b %e, %Y - %H:%M%P', $ts); } else { if ($k == 'from') { return $this->user->id ? $this->user->name : $this->name; } else { if ($k == 'from_link') { return $this->user->id ? url_to($this->user, 'show') : ""; } } } return parent::__get($k); }
/** * Getter * * @param string $name * * @throws \Exception * @return mixed */ public function __get($name) { // Run through the BaseModel/CModel stuff first try { return parent::__get($name); } catch (\Exception $e) { // Is $name a field handle? if ($this->getFieldByHandle($name)) { return $this->getFieldValue($name); } // Fine, throw the exception throw $e; } }
/** * Allows to access EAV attributes like normal model attrs. * e.g $model->eav_some_attribute_name * * @todo Optimize, cache. * @param $name * @return null */ public function __get($name) { if (substr($name, 0, 4) === 'eav_') { if ($this->getIsNewRecord()) { return null; } $attribute = substr($name, 4); $eavData = $this->getEavAttributes(); if (isset($eavData[$attribute])) { $value = $eavData[$attribute]; } else { return null; } $attributeModel = StoreAttribute::model()->findByAttributes(array('name' => $attribute)); return $attributeModel->renderValue($value); } return parent::__get($name); }
/** * Getter * * @param string $name * @throws \Exception * @return mixed */ function __get($name) { // Run through the BaseModel/CModel stuff first try { return parent::__get($name); } catch (\Exception $e) { // Is $name a field handle? $field = craft()->fields->getFieldByHandle($name); if ($field) { return $this->_getPreppedContentForField($field); } // Fine, throw the exception throw $e; } }