Example #1
0
 private function createFromDBRow($row)
 {
     $cat = new Category($row[DB::CATEGORY_NAME]);
     $cat->setAuthorId($row[DB::CATEGORY_AUTHOR])->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::CATEGORY_CREATION_DATE])));
     if ($this->loadChildren) {
         $this->loadChildren($cat);
     }
     if ($this->loadParent) {
         $this->loadParentName($cat);
     }
     if ($this->loadAccessCount) {
         $this->getAccessCount($cat);
     }
     return $cat;
 }
Example #2
0
 static function createCategoriesFromArray($array, $author_id, $parent = null)
 {
     if (!is_array($array)) {
         echo "<p>Trying to create category " . $array . "</p>";
         $catdao = new CategoryDao();
         if ($catdao->exists($array)) {
             return;
         }
         $cat = new Category($array, $parent);
         $cat->setAuthorId($author_id);
         $cat->setCreationDate(time());
         $catdao->save($cat);
         echo "<p style='color:green;'>Created category " . $array . "</p>";
     } else {
         foreach ($array as $index => $value) {
             if (!is_numeric($index)) {
                 self::createCategoriesFromArray($index, $author_id, $parent);
                 self::createCategoriesFromArray($value, $author_id, $index);
             } else {
                 self::createCategoriesFromArray($value, $author_id, $parent);
             }
         }
     }
 }