/** * Creates a channel category * * @param string $name Category name * @param string $description Description of the category * @param string $alias Alias of the category * * @return Pyrus\SimpleChannelServer\Categories */ public function create($name, $description, $alias = null) { if (!$alias) { $alias = $name; } $this->_categories[$name] = array('d' => $description, 'a' => $alias); $category = new REST\Category($this->_restDir, $this->channel, 'rest/', $this); $category->saveAllCategories(); return $this; }
function handleAddCategory() { if ($_SERVER['argc'] < 3) { $this->printCategoryUsage(); return false; } $args = array(); $args['category'] = $_SERVER['argv'][2]; $args['description'] = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : $_SERVER['argv'][2]; $this->getSCS(); $categories = new Categories($this->channel); $categories->create($args['category'], $args['description']); $category = new REST\Category($this->dir . '/rest', $this->channel, 'rest/', $categories); $category->saveAllCategories(); $category->savePackagesInfo($args['category']); echo "Added category ", $args['category'], "\n"; }