예제 #1
0
파일: index.php 프로젝트: truffo/eep
 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::contentobject_info:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->fetchContentObjectFromId($objectId);
             break;
         case self::contentobject_datamap:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->fetchDataMapFromId($objectId);
             break;
         case self::contentobject_related:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->fetchRelated($objectId, false, $additional);
             break;
         case self::contentobject_reverserelated:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->fetchReverseRelated($objectId, $additional);
             break;
         case self::contentobject_delete:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->delete($objectId);
             break;
         case self::contentobject_contentnode:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             echo $this->convertToNodeId($objectId) . "\n";
             break;
         case self::contentobject_republish:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             eep::republishObject($objectId);
             echo "republished " . $objectId . "\n";
             break;
         case self::contentobject_clearcache:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->clearObjectCache($objectId);
             break;
         case self::contentobject_sitemapxml:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->sitemapxml($objectId, $param2, $param3, $param4);
             // objid, domain, change-frequency, priority
             break;
         case self::contentobject_deleteversions:
             $objectId = $eepCache->readFromCache(eepCache::use_key_object);
             if ($param1) {
                 $objectId = $param1;
             }
             if (!eepValidate::validateContentObjectId($objectId)) {
                 throw new Exception("This is not an object id: [" . $objectId . "]");
             }
             $this->deleteversions($objectId);
             break;
         case self::contentobject_fetchbyremoteid:
             $this->fetchbyremoteid($param1);
             break;
     }
 }
예제 #2
0
파일: index.php 프로젝트: truffo/eep
 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 "'use' available keys: " . implode(", ", $this->availableCommands) . "\n";
             echo "\n" . $this->help . "\n";
             break;
         case self::use_dump:
             $this->dumpCache();
             break;
         case eepCache::use_key_contentclass:
             $contentClass = eZContentClass::fetchByIdentifier($param1);
             if (!$contentClass) {
                 throw new Exception("This content class does not exist: [" . $param1 . "]");
             }
             // note that a value == "" means to clear the setting
             $eepCache->writetoCache(eepCache::use_key_contentclass, $param1);
             break;
         case eepCache::use_key_contentnode:
             if (!eepValidate::validateContentNodeId($param1)) {
                 throw new Exception("This is not an node id: [" . $param1 . "]");
             }
             $eepCache->writetoCache(eepCache::use_key_contentnode, $param1);
             break;
         case eepCache::use_key_object:
             if (!eepValidate::validateContentObjectId($param1)) {
                 throw new Exception("This is not an object id: [" . $param1 . "]");
             }
             $eepCache->writetoCache(eepCache::use_key_object, $param1);
             break;
         case eepCache::use_key_attribute:
             // todo, verify that this is indeed a content class attribute
             $eepCache->writetoCache(eepCache::use_key_attribute, $param1);
             break;
         case eepCache::use_key_siteaccess:
             // todo, verify that this is indeed a site access
             $eepCache->writetoCache(eepCache::use_key_siteaccess, $param1);
             break;
         case eepCache::use_key_ezroot:
             if ("/" == substr($param1, 0, 1)) {
                 // absolute path
                 $eZPublishRootPath = $param1;
             } else {
                 // relative path
                 $eZPublishRootPath = getcwd() . "/" . $param1;
             }
             $eepCache->writetoCache(eepCache::use_key_ezroot, realpath($eZPublishRootPath));
             // if you require this now, you might clash with an existing
             // autoload, so just save the new path in the cache, and the
             // next run will load the new autoload
             //require $eZPublishRootPath.'/autoload.php';
             break;
     }
 }
예제 #3
0
파일: index.php 프로젝트: truffo/eep
 private function create_quick($parentNodeId, $classIdentifier)
 {
     if (!eepValidate::validateContentNodeId($parentNodeId)) {
         throw new Exception("This is an invalid parent node id: [" . $parentNodeId . "]");
     }
     $results = $this->create($parentNodeId, $classIdentifier, array());
     echo "new object id " . $results["contentobjectid"] . "\n";
     echo "new node id " . $results["mainnodeid"] . "\n";
 }
예제 #4
0
파일: index.php 프로젝트: truffo/eep
 private function listSubtreeOrdered($subtreeNodeId, $additional)
 {
     if (!eepValidate::validateContentNodeId($subtreeNodeId)) {
         throw new Exception("This is not an node id: [" . $subtreeNodeId . "]");
     }
     $title = "All nodes in subtree [" . $subtreeNodeId . "]";
     $params["Depth"] = 0;
     $params['AsObject'] = false;
     $params["IgnoreVisibility"] = true;
     $params["Limitation"] = array();
     $params['SortBy'] = array(array("path_string", 0));
     $params['ExtendedAttributeFilter'] = array();
     $sortOrder = "depthfirst";
     if (isset($additional["order"]) && strcmp($additional["order"], "breadthfirst") == 0) {
         $sortOrder = "breadthfirst";
         $params['SortBy'] = array(array("depth", "asc"), array("path", 0));
     }
     $title .= " " . $sortOrder;
     if (isset($additional["limit"])) {
         if (0 != $additional["limit"]) {
             $params["Limit"] = $additional["limit"];
             $title .= " (Limit=" . $params["Limit"] . ")";
         }
     }
     if (isset($additional["offset"])) {
         $params["Offset"] = $additional["offset"];
         $title .= " (Offset=" . $params["Offset"] . ")";
     }
     $titleRow = array("contentobject_id" => "Object", "node_id" => "Node", "class_identifier" => "Class", "path_identification_string" => "Path identification string", "path_string" => "Path string", "hidden_invisible" => "H/I", "remote_id" => "Remote ID");
     $truncate = 0;
     if (isset($additional["truncate"])) {
         if (0 < $additional["truncate"]) {
             $title .= " (Truncate=" . $additional["truncate"] . ")";
             $truncate = $additional["truncate"];
         }
     } else {
         $title .= " (Truncate=30)";
         $truncate = 30;
     }
     $allchildren = array();
     //display title first row
     array_unshift($allchildren, $titleRow);
     $rootNode = eZContentObjectTreeNode::fetch($subtreeNodeId, false, false);
     $pathString = $rootNode["path_string"];
     $pathIdentificationString = $rootNode["path_identification_string"];
     if ($truncate > 0) {
         if (strlen($pathString) > $truncate) {
             $pathString = "..." . substr($pathString, strlen($pathString) - $truncate);
         }
         if (strlen($pathIdentificationString) > $truncate) {
             $pathIdentificationString = "..." . substr($pathIdentificationString, strlen($pathIdentificationString) - $truncate);
         }
     }
     $rootNodeRow = array("contentobject_id" => $rootNode["id"], "node_id" => $rootNode["node_id"], "class_identifier" => $rootNode["class_identifier"], "path_identification_string" => $pathIdentificationString, "path_string" => $pathString, "hidden_invisible" => $rootNode["is_hidden"] . "/" . $rootNode["is_invisible"], "remote_id" => $rootNode["remote_id"]);
     if (isset($additional["order"]) && strcmp($additional["order"], "breadthfirst") == 0) {
         array_push($allchildren, $rootNodeRow);
     }
     $dbresults = eZContentObjectTreeNode::subTreeByNodeID($params, $subtreeNodeId);
     foreach ($dbresults as $result) {
         //for some reason sometimes the $db returns null rows
         if (!$result) {
             continue;
         }
         $pathString = $result["path_string"];
         $pathIdentificationString = $result["path_identification_string"];
         if ($truncate > 0) {
             if (strlen($pathString) > $truncate) {
                 $pathString = "..." . substr($pathString, strlen($pathString) - $truncate);
             }
             if (strlen($pathIdentificationString) > $truncate) {
                 $pathIdentificationString = "..." . substr($pathIdentificationString, strlen($pathIdentificationString) - $truncate);
             }
         }
         array_push($allchildren, array("contentobject_id" => $result["id"], "node_id" => $result["node_id"], "class_identifier" => $result["class_identifier"], "path_identification_string" => $pathIdentificationString, "path_string" => $pathString, "hidden_invisible" => $result["is_hidden"] . "/" . $result["is_invisible"], "remote_id" => $result["remote_id"]));
     }
     if (!isset($additional["order"]) || strcmp($additional["order"], "breadthfirst") != 0) {
         array_push($allchildren, $rootNodeRow);
     }
     eep::printTable($allchildren, $title);
 }
예제 #5
0
파일: index.php 프로젝트: truffo/eep
 private function setSortOrder($nodeId, $sortField, $sortOrder)
 {
     $availableSortFields = array("PATH" => eZContentObjectTreeNode::SORT_FIELD_PATH, "PUBLISHED" => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED, "MODIFIED" => eZContentObjectTreeNode::SORT_FIELD_MODIFIED, "SECTION" => eZContentObjectTreeNode::SORT_FIELD_SECTION, "DEPTH" => eZContentObjectTreeNode::SORT_FIELD_DEPTH, "CLASS_IDENTIFIER" => eZContentObjectTreeNode::SORT_FIELD_CLASS_IDENTIFIER, "CLASS_NAME" => eZContentObjectTreeNode::SORT_FIELD_CLASS_NAME, "PRIORITY" => eZContentObjectTreeNode::SORT_FIELD_PRIORITY, "NAME" => eZContentObjectTreeNode::SORT_FIELD_NAME, "MODIFIED_SUBNODE" => eZContentObjectTreeNode::SORT_FIELD_MODIFIED_SUBNODE, "NODE_ID" => eZContentObjectTreeNode::SORT_FIELD_NODE_ID, "CONTENTOBJECT_ID" => eZContentObjectTreeNode::SORT_FIELD_CONTENTOBJECT_ID);
     $availableSortDirections = array("DESC" => eZContentObjectTreeNode::SORT_ORDER_DESC, "ASC" => eZContentObjectTreeNode::SORT_ORDER_ASC);
     if (!eepValidate::validateContentNodeId($nodeId)) {
         throw new Exception("This is not a node id: [" . $nodeId . "]");
     }
     if (!isset($availableSortFields[$sortField])) {
         throw new Exception("This sort field is not recognized: [" . $sortField . "]");
     }
     if (!isset($availableSortDirections[$sortOrder])) {
         throw new Exception("This sort field is not recognized: [" . $sortOrder . "]");
     }
     $node = eZContentObjectTreeNode::fetch($nodeId);
     $node->setAttribute('sort_field', $availableSortFields[$sortField]);
     $node->setAttribute('sort_order', $availableSortDirections[$sortOrder]);
     $node->store();
     echo "set sort order on node id: " . $nodeId . " on attribute: " . $sortField . " to " . $sortOrder . "\n";
 }