Пример #1
0
	/**
	 * Create the root node for the category tree.
	 */
	public function createRootNode () {
		$rootNode = new Category();
		$rootNode->setName("Root Category");
		$rootNode->setDescription("");
		
		$this->getNodeManager()->createRoot($rootNode);
	}
Пример #2
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));
	}
Пример #3
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;
		}
	}
	
}