Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function configure()
- {
- parent::configure();
- $parentChoices = $this->getParentChoices();
- $this->widgetSchema['root_id'] = new sfWidgetFormChoice(array(
- 'choices' => $parentChoices
- ));
- $this->validatorSchema['root_id'] = new sfValidatorChoice(array(
- 'choices' => array_keys($parentChoices)
- ));
- }
- protected function getParentChoices()
- {
- //Get settings from config file for hiding models pages
- $models_off = sfConfig::get('dm_hide_pages_tree_models', null);
- $actions_off = sfConfig::get('dm_hide_pages_tree_actions', null);
- $where_string = '';
- //Compile query string for excluding models with many childrens(from config file)
- foreach($models_off as $key=>$name)
- {
- $list_actions = $actions_off[$name];
- ($list_actions !== null && count($list_actions) > 0) && $actions_links = ' AND p.action IN ("'.implode('","',$list_actions).'")';
- if ($where_string!='')
- {
- $where_string = ' NOT (p.module = "'.$name.'"'.$actions_links.')';
- }
- else
- {
- $where_string = ' AND NOT (p.module = "'.$name.'"'.$actions_links.')';
- }
- }
- $_parentChoices = dmDb::table('DmPage')->createQuery('p')
- ->withI18n()
- ->where($where_string)
- ->select('p.id, p.level, pTranslation.name')
- ->orderBy('p.lft')
- ->fetchPDO();
- $parentChoices = array();
- foreach($_parentChoices as $values)
- {
- $parentChoices[$values[0]] = str_repeat(' ', $values[1]).'- '.$values[2];
- }
- return $parentChoices;
- }
Add Comment
Please, Sign In to add comment