public function run($argv, $additional) { $command = @$argv[2]; $param1 = @$argv[3]; $param2 = @$argv[4]; if (!in_array($command, $this->availableCommands)) { throw new Exception("Command '" . $command . "' not recognized."); } $eepCache = eepCache::getInstance(); switch ($command) { case "help": echo "\nAvailable commands:: " . implode(", ", $this->availableCommands) . "\n"; echo "\n" . $this->help . "\n"; break; case self::contentclass_listattributes: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } AttributeFunctions::listAttributes($classIdentifier); break; case self::contentclass_deleteclass: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } $this->deleteClass($classIdentifier); break; case self::contentclass_fetchallinstances: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } $this->fetchallinstances($classIdentifier, $additional); break; case self::contentclass_appendtogroup: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } if ($param2) { $groupIdentifier = $param2; } else { $groupIdentifier = null; } $this->appendToGroup($classIdentifier, $groupIdentifier); break; case self::contentclass_removefromgroup: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } if ($param2) { $groupIdentifier = $param2; } else { $groupIdentifier = null; } $this->removeFromGroup($classIdentifier, $groupIdentifier); break; // eep createclass <Display name> <Content class group identifier> // eep createclass <Display name> <Content class group identifier> case self::contentclass_createclass: $displayName = $param1; // convert the display name to lowercase and solo underscores $classIdentifier = strtolower(trim($displayName)); $classIdentifier = preg_replace("/[^a-z0-9]/", "_", $classIdentifier); $classIdentifier = preg_replace("/_[_]+/", "_", $classIdentifier); if (0 == strlen($classIdentifier)) { throw new Exception("Empty content class identifier"); } $classId = eZContentClass::classIDByIdentifier($classIdentifier); if ($classId) { throw new Exception("This content class identifier is already used: '" . $classIdentifier . "'"); } $groupIdentifier = $param2; $groupObject = eZContentClassGroup::fetchByName($groupIdentifier); if (!is_object($groupObject)) { throw new Exception("Failed to locate the content class group '" . $groupIdentifier . "'"); } $groupId = $groupObject->ID; $this->createClass($displayName, $classIdentifier, $groupIdentifier, $groupId); echo "created " . $classIdentifier . " ok\n"; break; // eep contentclass setclassobjectidentifier <class identifier> <object naming string or pattern> // eep contentclass setclassobjectidentifier <class identifier> <object naming string or pattern> case self::contentclass_setclassobjectidentifier: $classIdentifier = $param1; $classId = eZContentClass::classIDByIdentifier($classIdentifier); $contentClass = eZContentClass::fetch($classId); if (!is_object($contentClass)) { throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]"); } $contentClass->setAttribute('contentobject_name', $param2); $contentClass->store(); break; case self::contentclass_setiscontainer: $classIdentifier = $param1; $classId = eZContentClass::classIDByIdentifier($classIdentifier); $contentClass = eZContentClass::fetch($classId); if (!is_object($contentClass)) { throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]"); } $newSetting = 0; if (0 != $param2) { $newSetting = 1; } $contentClass->setAttribute('is_container', $newSetting); $contentClass->store(); break; } }
public function run($argv, $additional) { $command = @$argv[2]; $param1 = @$argv[3]; $param2 = @$argv[4]; if (!in_array($command, $this->availableCommands)) { throw new Exception("Command '" . $command . "' not recognized."); } $eepCache = eepCache::getInstance(); switch ($command) { case "help": echo "\nAvailable commands:: " . implode(", ", $this->availableCommands) . "\n"; echo "\n" . $this->help . "\n"; break; case self::list_contentclasses: $this->listContentClasses(); break; case self::list_attributes: $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass); if ($param1) { $classIdentifier = $param1; } AttributeFunctions::listAttributes($classIdentifier); break; case self::list_all_attributes: $this->listAllAttributes(); break; case self::list_children: $parentNodeId = $eepCache->readFromCache(eepCache::use_key_contentnode); if ($param1) { $parentNodeId = $param1; } $this->listChildNodes($parentNodeId, $additional); break; case self::list_siteaccesses: $this->listSiteAccesses(); break; case self::list_allinifiles: $this->allinifiles(); break; case self::list_subtree: $subtreeNodeId = $eepCache->readFromCache(eepCache::use_key_contentnode); if ($param1) { $subtreeNodeId = $param1; } $this->listSubtree($subtreeNodeId, $additional); break; case self::list_subtreeordered: $subtreeNodeId = $eepCache->readFromCache(eepCache::use_key_contentnode); if ($param1) { $subtreeNodeId = $param1; } $this->listSubtreeOrdered($subtreeNodeId, $additional); break; case self::list_extensions: $this->listExtensions(); break; } }