Пример #1
0
 private function trash_list()
 {
     $params = false;
     $asCount = false;
     $trashObjects = eZContentObjectTrashNode::trashList($params, $asCount);
     eep::displayNodeList($trashObjects, "Garbage Nodes");
 }
Пример #2
0
 private function dumpCache()
 {
     $eepCache = eepCache::getInstance();
     $all = $eepCache->getAll();
     $results[] = array("key", "value");
     foreach ($all as $key => $value) {
         $results[] = array($key, $value);
     }
     // do output
     eep::printTable($results, "eep cache");
 }
Пример #3
0
 private function allobjects($sectionId, $additional)
 {
     $limit = 1000;
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = 0;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $title = "Objects in section " . $sectionId . " (offset=" . $offset . " limit=" . $limit . ")";
     $list = eZSectionFunctionCollection::fetchObjectList($sectionId, $offset, $limit);
     eep::displayObjectList($list["result"], $title);
     //var_dump($list);
 }
Пример #4
0
 public function run($argv, $additional)
 {
     $command = @$argv[2];
     $param1 = @$argv[3];
     $param2 = @$argv[4];
     global $eepPath;
     $eepCache = eepCache::getInstance();
     $availableModules = $eepCache->readFromCache(eepCache::misc_key_availablemodules);
     if (!in_array($command, $availableModules)) {
         throw new Exception("Command '" . $command . "' not recognized.");
     }
     switch ($command) {
         case "help":
             sort($availableModules);
             echo "\nAvailable modules: " . implode($availableModules, ", ") . "\n";
             echo "\nModules path: " . $eepPath . "/modules/\n";
             echo "\n" . $this->help . "\n";
             $aliases = eep::getListOfAliases();
             $table = array();
             $table[] = array("Alias", "Command or Module");
             foreach ($aliases as $alias => $full) {
                 $table[] = array($alias, $full);
             }
             eep::printTable($table, "Available shortcuts");
             break;
         default:
             // this is an infamous hack; redirect the request to a different
             // module, and the help function there
             global $argv;
             global $argc;
             $argv[1] = $command;
             // the module, not actually used
             $argv[2] = "help";
             // the command, which is help
             global $eepPath;
             require_once $eepPath . "/modules/" . $command . "/index.php";
             break;
     }
 }
Пример #5
0
 public function run($argv, $additional)
 {
     $command = @$argv[2];
     $param1 = @$argv[3];
     $param2 = @$argv[4];
     $param3 = @$argv[5];
     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::crondaemon_addtask:
             if (0 == strlen($param1) || 0 == strlen($param2)) {
                 throw new Exception("This requires at least two parameters.");
             }
             eep::addTask($param1, $param2, $param3);
             break;
     }
 }
Пример #6
0
 private function attribute_migrate($classIdentifier, $srcAttribute, $conversion, $destAttribute)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
     }
     $classDataMap = $contentClass->attribute("data_map");
     if (!isset($classDataMap[$srcAttribute])) {
         throw new Exception("Content class '" . $classIdentifier . "' does not contain this attribute: [" . $srcAttribute . "]");
     }
     if (!isset($classDataMap[$destAttribute])) {
         throw new Exception("Content class '" . $classIdentifier . "' does not contain this attribute: [" . $destAttribute . "]");
     }
     $classId = $contentClass->attribute("id");
     $objects = eZContentObject::fetchSameClassList($classId, false);
     $numObjects = count($objects);
     $conversionFunc = null;
     switch ($conversion) {
         default:
             echo "This mapping is not supported: [" . $conversion . "]\n";
             return;
             break;
         case "rot13":
             $conversionFunc = "convertStringToRot13";
             break;
         case "time2integer":
             $conversionFunc = "convertTimeToInteger";
             break;
         case "trim":
             $conversionFunc = "convertTrim";
             break;
         case "date2ts":
             $conversionFunc = "dateToTS";
             break;
     }
     foreach ($objects as $n => $object) {
         $object = eZContentObject::fetch($object["id"]);
         if ($object) {
             // copy data with conversion
             $dataMap = $object->DataMap();
             $src = $dataMap[$srcAttribute];
             $dest = $dataMap[$destAttribute];
             $dest->fromString(eep::$conversionFunc($src->toString()));
             $dest->store();
             // publish to get changes recognized, eg object title updated
             eep::republishObject($object->attribute("id"));
         }
         echo "Percent complete: " . sprintf("% 3.3f", ($n + 1.0) / $numObjects * 100.0) . "%\r";
         // clear caches
         unset($GLOBALS["eZContentObjectContentObjectCache"]);
         unset($GLOBALS["eZContentObjectDataMapCache"]);
         unset($GLOBALS["eZContentObjectVersionCache"]);
         unset($object);
     }
     echo "\n";
 }
Пример #7
0
 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;
     }
 }
Пример #8
0
 private function fetchall()
 {
     $limit = false;
     $results = array();
     $results[] = array("ID", "Name");
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = false;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $allInstances = eZContentClassGroup::fetchList(false, false);
     $title = "Viewing all groups";
     foreach ($allInstances as $group) {
         $results[] = array($group["id"], $group["name"]);
     }
     eep::printTable($results, $title);
 }
Пример #9
0
 private function fields($objectId)
 {
     $parameters = array();
     $parameters['q'] = 'meta_id_si:' . $objectId;
     $query = array('baseURL' => false, 'request' => '/select', 'parameters' => $parameters);
     $search = eZFunctionHandler::execute('ezfind', 'rawSolrRequest', $query);
     if ($search['response']['numFound'] > 0) {
         $results = array();
         $header = array('Field', 'Has data', 'Multi valued');
         $results[] = $header;
         foreach ($search['response']['docs'][0] as $index => $doc) {
             $hasData = 'no';
             $multiValued = 'no';
             if (is_array($doc) && count($doc)) {
                 $hasData = 'yes';
                 $multiValued = 'yes';
             } elseif ($doc !== '') {
                 $hasData = 'yes';
             }
             $results[] = array($index, $hasData, $multiValued);
         }
         eep::printTable($results, "List ezfind fields [{$objectId}]");
     } else {
         echo "No results\n";
     }
 }
Пример #10
0
 static function displayObjectList($list, $title)
 {
     $results = array();
     $results[] = array("Id", "NId", "SId", "V", "Remote Id", "Class Id", "Name");
     foreach ($list as $n => $object) {
         $results[] = array($object->ID, $object->mainNodeID(), $object->SectionID, $object->CurrentVersion, $object->RemoteID, $object->contentClassIdentifier(), strlen($object->Name) > 60 ? substr($object->Name, 0, 57) . "..." : $object->Name);
         //unset($object);
         //unset( $list[$n] );
         //unset( $GLOBALS[ 'eZContentObjectContentObjectCache' ] );
         //unset( $GLOBALS[ 'eZContentObjectDataMapCache' ] );
         //unset( $GLOBALS[ 'eZContentObjectVersionCache' ] );
     }
     eep::printTable($results, $title);
 }
Пример #11
0
 private function fetchallinstances($classIdentifier, $additional)
 {
     $limit = false;
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = false;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $allInstances = eZContentObject::fetchSameClassList($classId, false, $offset, $limit);
     $title = "All instances of content class '" . $classIdentifier . "'";
     eep::displayNonObjectList($allInstances, $title);
 }
Пример #12
0
Файл: eep.php Проект: truffo/eep
require_once $eepPath . "/lib/AttributeFunctions.php";
require_once $eepPath . "/lib/eepLog.php";
require_once $eepPath . "/lib/eepValidate.php";
$eepLogger = new eepLog(eepSetting::LogFolder, eepSetting::LogFile);
$eepCache = eepCache::getInstance();
$argModule = "help";
// default module in case no other is requested
if (isset($argv[1])) {
    // expand the module name into it's full name if using an alias
    $argv[1] = eep::expandAliases($argv[1]);
    $argModule = $argv[1];
}
$argCommand = "";
if (isset($argv[2])) {
    // expand the function into it's full name if using an alias
    $argv[2] = eep::expandAliases($argv[2]);
    $argCommand = $argv[2];
}
// make sure that the module is simple as a security precaution
$argModule = str_replace(array("/", "\\", ".", ":"), "", $argModule);
// make sure that the module is one that is available
$availableModuleFolders = array();
$hDir = opendir($eepPath . "/modules");
$file = readdir($hDir);
while (false != $file) {
    if (!in_array($file, array(".", "..", ".svn"))) {
        $wholePath = $eepPath . "/modules/" . $file;
        if (is_dir($wholePath)) {
            $availableModuleFolders[] = $file;
        }
    }
Пример #13
0
 private function location($objectId, $parentNodeId)
 {
     if (!eepValidate::validateContentObjectId($objectId)) {
         throw new Exception("This is not an object id: [" . $objectId . "]");
     }
     if (!eepValidate::validateContentNodeId($parentNodeId)) {
         throw new Exception("This is not a node id: [" . $parentNodeId . "]");
     }
     $object = eZContentObject::fetch($objectId);
     $object->addLocation($parentNodeId);
     // this is a guess; but otherwise, the new node doesn't become available
     eep::republishObject($objectId);
 }
Пример #14
0
 private function ezflow_list_blocktypes($output)
 {
     $validOutput = array('simple', 'grouped');
     if (!in_array($output, $validOutput)) {
         $output = 'simple';
     }
     $db = eZDB::instance();
     $sql['simple'] = "SELECT block_type, id as block_id FROM `ezm_block` ORDER BY `block_type` ASC";
     $sql['grouped'] = "\n            SELECT \n                block_type, \n                COUNT(block_type) as count, \n                (SELECT \n                    GROUP_CONCAT(id) \n                FROM \n                    `ezm_block` t2 \n                WHERE \n                    t1.block_type = t2.block_type\n                ) as block_ids \n            FROM \n                `ezm_block` t1 \n            GROUP BY t1.block_type \n            ORDER BY t1.`block_type` ASC;";
     // header field names for each output mode
     $headers['simple'] = array("block_type", "block_id");
     $headers['grouped'] = array("block_type", "count", "block_ids");
     if ($query = $db->query($sql[$output])) {
         // add field headers row
         $results[] = $headers[$output];
         while ($row = $query->fetch_array(MYSQL_NUM)) {
             $result = array();
             foreach ($row as $index => $value) {
                 $result[] = $value;
             }
             $results[] = $result;
         }
         eep::printTable($results, "ezflow list blocktypes [{$output}]");
     }
 }
Пример #15
0
 private function listExtensions()
 {
     $definedByFolder = array();
     $siteINI = eZINI::instance("site.ini");
     $extensionPath = "./" . $siteINI->variable("ExtensionSettings", "ExtensionDirectory");
     $hDir = opendir($extensionPath);
     $file = readdir($hDir);
     while (false != $file) {
         if (!in_array($file, array(".", "..", ".svn"))) {
             if (is_dir($extensionPath . "/" . $file)) {
                 $definedByFolder[] = $file;
             }
         }
         $file = readdir($hDir);
     }
     $activeExtensions = $siteINI->variable("ExtensionSettings", "ActiveExtensions");
     $activeAccessExtensions = $siteINI->variable("ExtensionSettings", "ActiveAccessExtensions");
     $designINI = eZINI::instance("design.ini");
     $designExtensions = $designINI->variable("ExtensionSettings", "DesignExtensions");
     $moduleINI = eZINI::instance("module.ini");
     $moduleExtensions = $moduleINI->variable("ModuleSettings", "ExtensionRepositories");
     $results[] = array("folders", "ActiveExtensions", "A.A.Extensions", "design", "modules");
     // todo, there are more things that you could list here ... autoloads, cronjobs, workflow events ...
     // another thing that an extension might do is declare a siteaccess
     foreach ($definedByFolder as $folder) {
         $results[] = array($folder, in_array($folder, $activeExtensions) ? $folder : "", in_array($folder, $activeAccessExtensions) ? $folder : "", in_array($folder, $designExtensions) ? $folder : "", in_array($folder, $moduleExtensions) ? $folder : "");
     }
     eep::printTable($results, "list extensions");
 }
Пример #16
0
        $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::create_content:
                $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
                $parentNodeId = $eepCache->readFromCache(eepCache::use_key_contentnode);
                $this->createContentObject($classIdentifier, $parentNodeId, $param1);
                break;
            case self::create_quick:
                $nodeId = $param1;
                $classIdentifier = $param2;
                $this->create_quick($nodeId, $classIdentifier);
                break;
        }
    }
}
//------------------------------------------------------------------------------
$operation = new create_commands();
if (!isset($argv[2])) {
    $argv[2] = "help";
}
$additional = eep::extractAdditionalParams($argv);
$operation->run($argv, $additional);
Пример #17
0
 public static function info($classIdentifier, $attributeIdentifier, $fieldIdentifier)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
     }
     $classDataMap = $contentClass->attribute("data_map");
     if (!isset($classDataMap[$attributeIdentifier])) {
         throw new Exception("Content class '" . $classIdentifier . "' does not contain this attribute: [" . $attributeIdentifier . "]");
     }
     $fieldList = $classDataMap[$attributeIdentifier]->attributes();
     $results[] = array("Field Name", "Field Value", "Value Type");
     foreach ($fieldList as $fieldName) {
         $value = $classDataMap[$attributeIdentifier]->attribute($fieldName);
         $type = "string";
         if (is_array($value)) {
             $value = serialize($value);
             $type = "Array";
         }
         $results[] = array($fieldName, $value, $type);
     }
     eep::printTable($results, "Class attribute fields");
 }