/** * 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 categorize($package, $category) { $categories = new Categories($this->channel); if (!$categories->exists($category)) { echo 'That category doesn\'t exist yet. Use add-category first' . PHP_EOL; } $categories->linkPackageToCategory($package, $category); $rcat = new REST\Category($this->restpath, $this->channel, 'rest/', $categories); $rcat->savePackages($category); $rcat->savePackagesInfo($category); }
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"; }