__get() public method

Magic getter method, allows $model->property access to data.
public __get ( string $property ) : null | string
$property string
return null | string
Example #1
0
 public function __get($name)
 {
     $r = parent::__get($name);
     if (isset($r)) {
         return $this->markdown($r);
     }
     try {
         if ($trans = $this->translations()->filter('language')->find_one()) {
             $r = $trans->{$name};
             if (isset($r)) {
                 return $this->markdown($r);
             }
         }
     } catch (Exception $e) {
     }
     try {
         $r = $this->metas()->where('key', $name);
         if ($r->count() > 0) {
             $r = $r->find_one();
             return $r->field == 'text' || $r->field == 'textarea' ? $this->markdown($r->value) : $r->value;
         }
     } catch (Exception $e) {
     }
     return null;
 }
Example #2
0
 /**
  * Return custom options or table row data
  * @param mixed
  * @return mixed
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'billing_fields_raw':
         case 'shipping_fields_raw':
             if (!is_array($this->arrCache[$strKey])) {
                 $strField = str_replace('_raw', '', $strKey);
                 $arrFields = array();
                 foreach ($this->{$strField} as $field) {
                     if ($field['enabled']) {
                         $arrFields[] = $field['value'];
                     }
                 }
                 $this->arrCache[$strKey] = $arrFields;
             }
             return $this->arrCache[$strKey];
         case 'billing_countries':
         case 'shipping_countries':
             $arrCountries = deserialize(parent::__get($strKey));
             if (!is_array($arrCountries) || empty($arrCountries)) {
                 $this->import('Isotope');
                 $arrCountries = array_keys($this->Isotope->getCountries());
             }
             return $arrCountries;
             break;
         default:
             return deserialize(parent::__get($strKey));
     }
 }
Example #3
0
 /**
  * Magic method to get protected properties
  *
  * @param  string $property
  *
  * @return mixed
  */
 public function __get($property)
 {
     if ($property == 'picUrl' && !isset($this->picUrl)) {
         return '/images/default-avatar.png';
     }
     return parent::__get($property);
 }
Example #4
0
 public function __get($name)
 {
     switch ($name) {
         case 'rules':
             return $this->rules();
         default:
             return parent::__get($name);
     }
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * Dynamic getter that unserializes results.
  */
 public function __get($key)
 {
     if ($key == 'results') {
         if ($this->_results === false) {
             $this->_results = json_decode($this->data['results']);
         }
         return $this->_results;
     }
     return parent::__get($key);
 }
Example #7
0
 /**
  * Gets a property or relation.
  *
  * @param string $property The property or relation to fetch.
  * 
  * @return mixed
  */
 public function &__get($property)
 {
     $value = parent::__get($property);
     if ($property == 'metas') {
         // Sort metas alphabetically by meta name property.
         uasort($value, function ($a, $b) {
             return strcmp($a->name, $b->name);
         });
     }
     return $value;
 }
Example #8
0
 /**
  * Gets a property or relation.
  *
  * @param string $property The property or relation to fetch.
  * 
  * @return mixed
  */
 public function &__get($property)
 {
     $value = parent::__get($property);
     if ($property == 'options') {
         // Sort options alphabetically by option value property.
         uasort($value, function ($a, $b) {
             return strcmp($a->value, $b->value);
         });
     }
     return $value;
 }
Example #9
0
 /**
  * Override the getter for head to include the description
  * and keywords fields as meta tags.
  */
 public function __get($key)
 {
     if ($key == 'head') {
         $head = '';
         if (isset($this->data['description'])) {
             $head .= '<meta name="description" content="' . Template::sanitize($this->data['description']) . "\" />\n";
         }
         if (isset($this->data['keywords'])) {
             $head .= '<meta name="keywords" content="' . Template::sanitize($this->data['keywords']) . "\" />\n";
         }
         return $head;
     }
     return parent::__get($key);
 }
Example #10
0
 /**
  * @param $name
  * @return mixed translated value of the key/value column OR table attribute value
  */
 public function __get($name)
 {
     $r = parent::__get($name);
     if (isset($r)) {
         return $r;
     }
     try {
         if ($trans = $this->translations()->filter('language')->find_one()) {
             $r = $trans->{$name};
             if (isset($r)) {
                 return $r;
             }
         }
     } catch (Exception $e) {
         print_r($e);
     }
 }
Example #11
0
File: Form.php Project: Alm001/form
 /**
  * Dynamic getter that unserializes fields and actions.
  */
 public function __get($key)
 {
     if ($key == 'field_list') {
         if ($this->_fields === false) {
             $this->_fields = json_decode($this->data['fields']);
         }
         return $this->_fields;
     } elseif ($key == 'actions') {
         if ($this->_actions === false) {
             $this->_actions = json_decode($this->data['actions']);
         }
         return $this->_actions;
     }
     return parent::__get($key);
 }
Example #12
0
 /**
  * Dynamic getter for user properties. If you get the field specified
  * in the child class's `$_extended_field` property, it will automatically
  * unserialize it into an array for you.
  *
  * If an extended property has been defined in the `$verify` list, you can
  * also get it directly using the usual `$model->property` syntax.
  */
 public function __get($key)
 {
     if ($key == $this->_extended_field) {
         if ($this->_extended === false) {
             if (isset($this->data[$this->_extended_field])) {
                 $this->_extended = (array) json_decode($this->data[$this->_extended_field]);
             } else {
                 $this->data[$this->_extended_field] = json_encode(array());
                 $this->_extended = array();
             }
         }
         return $this->_extended;
     } elseif (isset($this->_extended_verify[$key])) {
         return $this->ext($key);
     }
     return parent::__get($key);
 }
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'protected':
             $blnFound = false;
             if ($this->ipProtected) {
                 $strCurrentIp = $_SERVER['REMOTE_ADDR'];
                 $arrAllowedIps = explode(',', $this->allowedIps);
                 foreach ($arrAllowedIps as $strIp) {
                     if (strpos($strIp, '[') !== false) {
                         $strPrefix = '';
                         $intStart = 0;
                         $intStop = 255;
                         preg_replace_callback('@((?:[0-9]{1,3}\\.){3})\\[([0-9]{1,3})\\.\\.([0-9]{1,3})\\]@i', function ($arrMatches) use(&$strPrefix, &$intStart, &$intStop) {
                             $strPrefix = $arrMatches[1];
                             $intStart = $arrMatches[2];
                             $intStop = $arrMatches[3];
                         }, $strIp);
                         for ($i = $intStart; $i <= $intStop; $i++) {
                             if ($strCurrentIp == $strPrefix . $i) {
                                 $blnFound = true;
                                 break;
                             }
                         }
                     } else {
                         if ($strCurrentIp == $strIp) {
                             $blnFound = true;
                         }
                     }
                 }
             }
             if ($blnFound) {
                 return '';
             } else {
                 return parent::__get($strKey);
             }
             break;
         default:
             return parent::__get($strKey);
     }
 }