Guest User

Untitled

a guest
Jun 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. public function configure()
  2. {
  3. parent::configure();
  4.  
  5. $parentChoices = $this->getParentChoices();
  6.  
  7.  
  8. $this->widgetSchema['root_id'] = new sfWidgetFormChoice(array(
  9. 'choices' => $parentChoices
  10. ));
  11. $this->validatorSchema['root_id'] = new sfValidatorChoice(array(
  12. 'choices' => array_keys($parentChoices)
  13. ));
  14.  
  15. }
  16.  
  17. protected function getParentChoices()
  18. {
  19. //Get settings from config file for hiding models pages
  20. $models_off = sfConfig::get('dm_hide_pages_tree_models', null);
  21. $actions_off = sfConfig::get('dm_hide_pages_tree_actions', null);
  22. $where_string = '';
  23.  
  24. //Compile query string for excluding models with many childrens(from config file)
  25. foreach($models_off as $key=>$name)
  26. {
  27. $list_actions = $actions_off[$name];
  28. ($list_actions !== null && count($list_actions) > 0) && $actions_links = ' AND p.action IN ("'.implode('","',$list_actions).'")';
  29. if ($where_string!='')
  30. {
  31. $where_string = ' NOT (p.module = "'.$name.'"'.$actions_links.')';
  32. }
  33. else
  34. {
  35. $where_string = ' AND NOT (p.module = "'.$name.'"'.$actions_links.')';
  36. }
  37. }
  38.  
  39. $_parentChoices = dmDb::table('DmPage')->createQuery('p')
  40. ->withI18n()
  41. ->where($where_string)
  42. ->select('p.id, p.level, pTranslation.name')
  43. ->orderBy('p.lft')
  44. ->fetchPDO();
  45.  
  46. $parentChoices = array();
  47.  
  48. foreach($_parentChoices as $values)
  49. {
  50. $parentChoices[$values[0]] = str_repeat('  ', $values[1]).'- '.$values[2];
  51. }
  52.  
  53. return $parentChoices;
  54. }
Add Comment
Please, Sign In to add comment