Ejemplo n.º 1
0
 /**
  * Get option value.
  * The return value array|boolean|string depends on value.
  * If value is string then the return value is a string.
  * If value is array|object then return value is array.
  * If name not found in table then it will return false.
  *
  * @param string $name
  * @return string|array|boolean
  */
 public static function get($name)
 {
     /* @var $model \common\models\Option */
     $model = static::findOne(['name' => $name]);
     if ($model) {
         if (Json::isJson($model->value)) {
             return Json::decode($model->value);
         }
         return $model->value;
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * Get option value.
  * The return value array|boolean|string depends on option_value.
  * If option_value is string then the return value is a string.
  * If option_value is array|object then return value is array.
  * If option_name not found in table then it will return false.
  *
  * @param string $option_name
  *
  * @return string|array|boolean
  */
 public static function get($option_name)
 {
     /* @var $model \common\models\Option */
     $model = static::find()->where(['option_name' => $option_name])->one();
     if ($model) {
         if (Json::isJson($model->option_value)) {
             return Json::decode($model->option_value);
         } else {
             return $model->option_value;
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Get meta for current post.
  *
  * @param $meta_name
  *
  * @return mixed|null
  */
 public function getMeta($meta_name)
 {
     $model = PostMeta::find()->andWhere(['meta_name' => $meta_name])->andWhere(['post_id' => $this->id])->one();
     if ($model) {
         if (Json::isJson($model->meta_value)) {
             return Json::decode($model->meta_value);
         }
         return $model->meta_value;
     }
     return null;
 }
Ejemplo n.º 4
0
 /**
  * Get meta for current media.
  *
  * @param $meta_name
  *
  * @return boolean|array|string
  */
 public function getMeta($meta_name)
 {
     /* @var $model \common\models\MediaMeta */
     $model = MediaMeta::find()->andWhere(['meta_name' => $meta_name])->andWhere(['media_id' => $this->id])->one();
     if ($model) {
         if (Json::isJson($model->meta_value)) {
             return Json::decode($model->meta_value);
         }
         return $model->meta_value;
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Get meta for current post.
  *
  * @param $meta_name
  *
  * @return mixed|null
  */
 public function getMeta($meta_name)
 {
     /* @var $model \common\models\PostMeta*/
     $model = PostMeta::findOne(['meta_name' => $meta_name, 'post_id' => $this->id]);
     if ($model) {
         if (Json::isJson($model->meta_value)) {
             return Json::decode($model->meta_value);
         }
         return $model->meta_value;
     }
     return null;
 }
Ejemplo n.º 6
0
 /**
  * Get meta for current media.
  *
  * @param string $name
  * @return mixed|null|string
  */
 public function getMeta($name)
 {
     /* @var $model \common\models\MediaMeta */
     $model = MediaMeta::findOne(['name' => $name, 'media_id' => $this->id]);
     if ($model) {
         if (Json::isJson($model->value)) {
             return Json::decode($model->value);
         }
         return $model->value;
     }
     return null;
 }