예제 #1
0
	public function create () {
		$this->requireParameter("name");
		$this->requireParameter("parent");
		
		$category = new Category;
		$category->setName($this->getParameter("name"));
		$category->setDescription($this->getParameter("description", ""));
		$category->setParent($this->getParameter("parent"));
		
		$category = CategoryManager::getInstance()->addCategory($category);
		
		return array("data" => $this->serializeCategory($category));
	}
예제 #2
0
function addCategoryRecursive ($aCategories, $currentId, $parent) {
	global $newCategories;
	
	foreach ($aCategories as $aCategory) {
		if ($aCategory["parentnode"] == $currentId) {
			echo "Adding ".sprintf("%40s", $aCategory["name"])."\r";			
			$oCategory = new Category();
			$oCategory->setName(convertText($aCategory["name"]));
			$oCategory->setDescription("");
			$oCategory->setParent($parent->getId());
			$category = CategoryManager::getInstance()->addCategory($oCategory);
			
			addCategoryRecursive($aCategories, $aCategory["id"], $category);
			
			$newCategories[$aCategory["id"]] = $oCategory;
		}
	}
	
}