86 if ($this->
getName() !=
'scaffold')
87 $this->cfg->name = $this->
getName();
89 if (!empty($this->cfg->name)) {
90 $this->cfg->overload(
'module_scaffold_'.$this->cfg->name);
92 $this->table =
db::get(
'table', $this->cfg->name, array(
93 'name'=>$this->cfg->name
95 $this->cols = $this->table->getCols();
96 $this->related = array_keys($this->table->getRelated());
97 $this->fields = $this->table->getField();
101 $this->cfg->tplPrm = array(
102 'layout'=>$this->cfg->layout,
103 'module'=>
'scaffold',
104 'action'=>$this->cfg->name.ucfirst($this->cfg->viewAction),
105 'defaultModule'=>
'scaffold',
106 'default'=>$this->cfg->viewAction,
107 'cache'=>$this->cfg->cache
122 if (empty($this->cfg->name)) {
124 $tables = $db->getTables();
126 foreach($tables as $t) {
127 if (!strpos($t,
'_') && !strpos($t,
db::getCfg(
'i18n')))
128 $links[$t] =
request::uriDef(array(
'module'=>$t,
'action'=>
'',
'param'=>
''));
139 return strtolower($this->prmExec[
'prefix']) ==
'scaffold';
143 $iconType = $this->cfg->iconType ? $this->cfg->iconType : $this->cfg->name;
145 $this->filterTable = null;
147 if (!empty($this->cfg->filter)) {
148 $this->filterTable =
factory::getHelper(
'filterTable', array_merge($this->cfg->filterOpts, array(
149 'table'=>$this->table,
150 'fields'=>is_array($this->cfg->filter)? $this->cfg->filter : null,
152 if ($this->cfg->addFilterTableJs)
154 if ($this->filterTable->hasValues())
155 $this->filterTable->getForm()->getCfg()->formPlus = str_replace(
'class="',
'class="filterTableActive ', $this->filterTable->getForm()->getCfg()->formPlus);
156 $this->
hook(
'listFilter');
157 $query = array(
'where'=>$this->
updateFilterWhere($this->filterTable->getWhere()));
161 'table'=>$this->table,
163 'name'=>$this->cfg->name.
'DataTable',
164 'iconType'=>$iconType,
165 'cache'=>$this->cfg->cache,
166 'fields'=>$this->cfg->list,
173 'show'=>
tr::__(
'scaffold_show'),
174 'edit'=>
tr::__(
'scaffold_goEdit'),
175 'delete'=>
tr::__(
'scaffold_delete'),
177 'multiple'=>$this->cfg->multiple,
178 'multipleAction'=>$this->cfg->multipleAction,
181 if ($this->cfg->multipleDelete) {
182 $conf[
'multiple'] = array_merge($conf[
'multiple'], array(
184 'label'=>
tr::__(
'scaffold_delete'),
195 'filterTable'=>$this->filterTable,
196 'dataTable'=>$this->dataTable,
197 'iconType'=>$iconType,
198 'allowAdd'=>$this->cfg->allowAdd,
210 $fctName =
'multiple'.ucfirst($action);
211 $uAction =
'Multiple'.ucfirst($action);
213 $this->
hook(
'before'.$uAction);
214 $actionConf = $this->cfg->getInArray(
'multiple', $action);
216 if (is_array($actionConf) && isset($actionConf[
'callback']) && is_callable($actionConf[
'callback'])) {
217 $call = $actionConf[
'callback'];
218 }
else if (is_callable(array($this, $fctName)))
219 $call = array($this, $fctName);
221 call_user_func($call, $this->ids);
222 $this->
hook(
'after'.$uAction);
233 $this->table->delete($this->table->getWhere(array(
235 'name'=>$this->table->getRawName().
'.'.$this->table->getIdent(),
254 protected function hook($action) {}
259 $this->row = $this->table->find($id);
262 $this->
form = $this->row->getForm($this->
getFields(
'show'), array(
'mode'=>
'view',
'sectionName'=>
tr::__(
'scaffold_show')),
false);
263 $this->
form->action =
request::uriDef(array(
'module'=>$this->table->getName(),
'action'=>
'edit',
'param'=>$id));
264 $this->
form->method =
'get';
266 $this->
form->setSubmitplus(
'<a href="'.$this->indexPage.
'">'.
tr::__(
'scaffold_back').
'</a>');
268 $this->
hook(
'formShow');
277 if (!$this->cfg->allowAdd) {
293 $uAction = ucfirst($action);
294 $this->row = $id ? $this->table->find($id) : $this->table->getRow();
298 if ($action ==
'duplic') {
300 $this->row = $this->table->getRow();
301 $this->row->setValues($tmp->getValues());
302 $this->row->setValues($tmp->getValues(
'flat'));
306 $this->
hook($action);
308 $this->
form = $this->row->getForm($this->
getFields($action), array_merge(array(
'sectionName'=>
tr::__(
'scaffold_'.$action)), $this->cfg->formOpts));
309 $this->
hook(
'formInit');
310 $this->
hook(
'formInit'.$uAction);
314 $this->
hook(
'formPost'.$uAction);
317 $this->
hook(
'before'.$uAction);
318 if ($this->row->save()) {
319 $this->
hook(
'after'.$uAction);
327 $this->
form->setSubmitplus(
'<a href="'.$this->indexPage.
'">'.
tr::__(
'scaffold_back').
'</a>');
329 $this->
hook(
'form'.$uAction);
339 $this->row = $this->table->find($id);
340 $this->
hook(
'delete');
341 $this->
hook(
'beforeDelete');
343 $this->row->delete();
344 $this->
hook(
'afterDelete');
355 $tmp = $this->cfg->get($action);
359 if ($this->cfg->autoRelated)
360 $ret = array_merge($ret, $this->related);
361 if (count($this->table->getI18nFields())) {
362 foreach($this->table->getI18nFields() as $v)
execScaffoldAdd($prm=null)
static __($key, $show=false, $out=true)
execScaffoldEdit($prm=null)
updateFilterWhere(db_where $where=null)
static getHelper($className, array $cfg=array())
execScaffoldList($prm=null)
execScaffoldShow($prm=null)
addEditForm($action, $id=null)
setViewVar($name, $value)
execScaffoldIndex($prm=null)
execScaffoldDuplic($prm=null)
static mergeCfg(array &$prm, array $cfg)
multipleDelete(array $ids)
static get($type, $table, array $prm=array())
static uriDef(array $prm=array(), array $use=array('lang', 'module', 'action', 'param', 'out'))
execScaffoldDelete($prm=null)
static getInstance($cfg=null)
setViewVars(array $values)
static get($className, array $cfg=array())