Exemple #1
0
 /**
  * Constructor
  * 
  * @param string $language Language
  * 
  * @return void
  */
 public function __construct($language = null)
 {
     parent::__construct();
     $this->setLanguage($language);
     $query = sprintf("\n            SELECT\n                fc.id AS id,\n                fc.lang AS lang,\n                fc.parent_id AS parent_id,\n                fc.name AS name,\n                fc.description AS description,\n                fc.user_id AS user_id\n            FROM\n                %sfaqcategories fc\n            WHERE\n                1=1", SQLPREFIX);
     if (!is_null($this->language)) {
         $query .= sprintf(" \n            AND \n                fc.lang = '%s'", $this->language);
     }
     $query .= "\n            ORDER BY fc.id";
     $result = $this->db->query($query);
     if (!$result) {
         throw new PMF_Exception($this->db->error());
     }
     while ($row = $this->db->fetch_assoc($result)) {
         $cat = new PMF_Category($row);
         $this->data[$row['id']] = $cat;
         if (!isset($this->children[$row['parent_id']])) {
             $this->children[$row['parent_id']] = array($cat);
         } else {
             $this->children[$row['parent_id']][] = $cat;
         }
     }
     if (!count($this->children)) {
         $emptyCategory = array('id' => -1, 'lang' => $this->language, 'name' => null, 'children' => 0, 'parent_id' => 0);
         $this->children[0] = new PMF_Category($emptyCategory);
     }
     foreach ($this->children as $parentid => $children) {
         if (!$parentid) {
             continue;
         }
         $parent = $this->data[$parentid];
         $parent->setChildcount(sizeof($children));
         foreach ($children as $child) {
             $child->setParent($parent);
         }
     }
 }
Exemple #2
0
 /**
  * Constructor
  * 
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
 }
Exemple #3
0
 /**
  * Constructor
  * 
  * @param string $language Language
  * 
  * @return void
  */
 public function __construct($language = null)
 {
     parent::__construct();
     $this->setLanguage($language);
 }