Esempio n. 1
0
File: index.php Progetto: truffo/eep
 public function run($argv, $additional)
 {
     $command = @$argv[2];
     $param1 = @$argv[3];
     $param2 = @$argv[4];
     $param3 = @$argv[5];
     $param4 = @$argv[6];
     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::attribute_delete:
             $classIdentifier = $param1;
             $attributeIdentifier = $param2;
             AttributeFunctions::deleteAttribute($classIdentifier, $attributeIdentifier);
             break;
         case self::attribute_newattributexml:
             $attr = new AttributeFunctions();
             echo $attr->newAttributeXML;
             break;
         case self::attribute_update:
             $classIdentifier = $param1;
             $xml = file_get_contents($param2);
             if (false === $xml) {
                 throw new Exception("Failed to locate parameter xml file: '" . $param2 . "'");
             }
             $dom = new DOMDocument();
             $dom->preserveWhiteSpace = false;
             $loadResult = $dom->loadXML($xml);
             if (false === $loadResult) {
                 throw new Exception("XML file '" . $param2 . "' does not contain valid XML");
             }
             $xpath = new DOMXPath($dom);
             AttributeFunctions::updateAttribute($classIdentifier, $xpath);
             break;
         case self::attribute_setfield:
             $classIdentifier = $param1;
             $attributeIdentifier = $param2;
             $fieldIdentifier = $param3;
             $fieldValue = $param4;
             AttributeFunctions::setField($classIdentifier, $attributeIdentifier, $fieldIdentifier, $fieldValue);
             break;
         case self::attribute_info:
             $classIdentifier = $param1;
             $attributeIdentifier = $param2;
             $fieldIdentifier = $param3;
             AttributeFunctions::info($classIdentifier, $attributeIdentifier, $fieldIdentifier);
             break;
         case self::attribute_migrate:
             $classIdentifier = $param1;
             $srcAttribute = $param2;
             $conversion = $param3;
             $destAttribute = $param4;
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             $this->attribute_migrate($classIdentifier, $srcAttribute, $conversion, $destAttribute);
             break;
         case self::attribute_fromstring:
             $contentObjectId = $param1;
             $attributeIdentifier = $param2;
             $newValue = $param3;
             AttributeFunctions::fromString($contentObjectId, $attributeIdentifier, $newValue);
             break;
         case self::attribute_tostring:
             $contentObjectId = $param1;
             $attributeIdentifier = $param2;
             echo AttributeFunctions::toString($contentObjectId, $attributeIdentifier) . "\n";
             break;
         case self::attribute_createalias:
             $contentObjectId = $param1;
             $attributeIdentifier = $param2;
             $aliasName = $param3;
             echo AttributeFunctions::createAlias($contentObjectId, $attributeIdentifier, $aliasName) . "\n";
             break;
         case self::attribute_contentobjectid:
             $contentObjectAttributeId = $param1;
             $version = $param2 ? $param2 : 1;
             echo AttributeFunctions::contentobjectid($contentObjectAttributeId, $version) . "\n";
             break;
     }
 }