/** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! * @param string $className active record class name. * @return Config the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * @param SnapActiveRecord $model * @param array $attribute * @param array $htmlOptions * @return string */ public function autoGenerateInput($model, $attribute, $htmlOptions = array()) { $dbAttribs = $model->getTableSchema()->columns[$attribute]; if (isset($this->_contentTypesConfig[$model->id]['input_types'][$attribute])) { $method = $this->_contentTypesConfig[$model->id]['input_types'][$attribute]; if (is_array($method) && isset($method['widget']['class'])) { return $this->_loadWidget($model, $attribute, $method); } elseif (is_array($method) && isset($method['class'])) { $methodName = $method['class']; $params = array_merge(array($model, $attribute), $method['params']); return call_user_func_array(array($this, $methodName), $params); } else { return $this->{$method}($model, $attribute, $htmlOptions); } } else { if (isset($this->_defaultTypes[$dbAttribs->dbType])) { $formType = $this->_defaultTypes[$dbAttribs->dbType]; if (isset($formType['widget']['class'])) { return $this->_loadWidget($model, $attribute, $formType); } } else { return $this->textFieldControlGroup($model, $attribute, $htmlOptions); } } }
public function beforeSave() { if (empty($this->title)) { $this->title = $this->Content ? $this->Content->title : 'No Title'; } if (empty($this->external_path) && $this->Content) { $this->Content->path = $this->createPath(); $this->Content->save(); } return parent::beforeSave(); }
public function beforeSave() { if (empty($this->path)) { $mainMenu = SnapUtil::config('general/site.default_menu'); $MI = MenuItem::model()->findByAttributes(array('menu_id' => $mainMenu, 'content_id' => $this->id)); if ($MI && !empty($this->id)) { $this->path = $MI->createPath(); } else { $this->path = '/' . $this->type . '/' . $this->title; } } $this->path = SnapFormat::slugify($this->path); return parent::beforeSave(); }