Exemplo n.º 1
0
 /**
  * Display the rules
  *
  * @param int $language Language selection identifier; default: 0
  * @param int $parent_id Category to display rules from; default: 0
  * @return null
  * @access public
  */
 public function display_rules($language = 0, $parent_id = 0)
 {
     // Grab all the rules in the current user's language
     $entities = $this->rule_operator->get_rules($language, $parent_id);
     // Initialize a variable to hold the right_id value
     $last_right_id = 0;
     // Process each rule entity for display
     /* @var $entity \phpbb\boardrules\entity\rule */
     foreach ($entities as $entity) {
         if ($entity->get_left_id() < $last_right_id) {
             continue;
             // The current rule is a child of a previous rule, do not display it
         }
         // Set output block vars for display in the template
         $this->template->assign_block_vars('rules', array('RULE_TITLE' => $entity->get_title(), 'S_IS_CATEGORY' => $entity->get_right_id() - $entity->get_left_id() > 1 ? true : false, 'U_DELETE' => "{$this->u_action}&amp;action=delete&amp;rule_id=" . $entity->get_id(), 'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;rule_id=" . $entity->get_id(), 'U_MOVE_DOWN' => "{$this->u_action}&amp;action=move_down&amp;rule_id=" . $entity->get_id() . '&amp;hash=' . generate_link_hash('down' . $entity->get_id()), 'U_MOVE_UP' => "{$this->u_action}&amp;action=move_up&amp;rule_id=" . $entity->get_id() . '&amp;hash=' . generate_link_hash('up' . $entity->get_id()), 'U_RULE' => "{$this->u_action}&amp;language={$language}&amp;parent_id=" . $entity->get_id()));
         // Store the current right_id value
         $last_right_id = $entity->get_right_id();
     }
     // Prepare rule breadcrumb path navigation
     $entities = $this->rule_operator->get_rule_parents($language, $parent_id);
     // Process each rule entity for breadcrumb display
     foreach ($entities as $entity) {
         // Set output block vars for display in the template
         $this->template->assign_block_vars('breadcrumb', array('RULE_TITLE' => $entity->get_title(), 'S_CURRENT_LEVEL' => $entity->get_id() == $parent_id, 'U_RULE' => "{$this->u_action}&amp;language={$language}&amp;parent_id=" . $entity->get_id()));
     }
     // Set output vars for display in the template
     $this->template->assign_vars(array('U_ACTION' => "{$this->u_action}&amp;language={$language}&amp;parent_id={$parent_id}", 'U_ADD_RULE' => "{$this->u_action}&amp;language={$language}&amp;parent_id={$parent_id}&amp;action=add", 'U_MAIN' => "{$this->u_action}&amp;language={$language}&amp;parent_id=0"));
 }