本文整理汇总了PHP中eZCLI::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZCLI::instance方法的具体用法?PHP eZCLI::instance怎么用?PHP eZCLI::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZCLI
的用法示例。
在下文中一共展示了eZCLI::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveIfNeeded
function moveIfNeeded($oldPath, $newPath) {
global $fileToRemove;
$success = true;
$cli = eZCLI::instance();
if (!file_exists($newPath)) {
if (!file_exists($oldPath)) {
$cli->warning('Source file not exist : ' . $oldPath);
return false;
}
eZDir::mkdir( dirname( $newPath ), false, true );
$success = copy($oldPath, $newPath);
$cli = eZCLI::instance();
if ($success) {
$fileToRemove[] = $oldPath;
$cli->notice('Move ' . $oldPath . ' => ' . $newPath);
} else {
$cli->warning('Fail to move ' . $oldPath . ' => ' . $newPath);
}
} else {
$fileToRemove[] = $oldPath;
}
return $success;
}
示例2: execute
public static function execute($exclusiveParentID = 1)
{
$db = eZDB::instance();
$cli = eZCLI::instance();
//1. delete the assignments from eznode_assignment table
// delete the assignments which don't have relevant entry in ezconentobject_tree
// select the data that doesn't exist in either eznode_assignment or ezcontentobject_tree
$deletedAssignmentList = $db->arrayQuery("SELECT * FROM eznode_assignment WHERE id NOT IN " . "(SELECT assign.id FROM eznode_assignment assign, ezcontentobject_tree tree WHERE " . "assign.contentobject_id = tree.contentobject_id AND assign.parent_node = tree.parent_node_id)");
$deletedCount = 0;
foreach ($deletedAssignmentList as $deletedAssignment) {
// select the content object which is published.
//If the object of the assignment is in trash or draft, it's not the one to be deleted
$tempAssignID = $deletedAssignment["id"];
$content = eZContentObject::fetch($deletedAssignment["contentobject_id"], false);
if ($content && $deletedAssignment['parent_node'] != $exclusiveParentID) {
if ($content["status"] == eZContentObject::STATUS_PUBLISHED) {
// iterate the data to be deleted, delete them
$cli->notice('Node assignment [ id: ' . $deletedAssignment['id'] . ' ] for contentobject [ id: ' . $deletedAssignment['contentobject_id'] . ' ] is not consistent with entries in contentobject_tree' . ' table thus will be removed.');
$sql = "DELETE FROM eznode_assignment WHERE id = " . $tempAssignID;
$result = $db->query($sql);
if ($result === false) {
$cli->notice('Node assignment [ id: ' . $deletedAssignment['id'] . ' ] ' . 'could not be removed. Please restore your database from backup and try again.');
return;
}
$deletedCount++;
}
}
}
//2. Delete the duplicated entries which have same contentobject_id, contentobject_version and is_main
// The process of deleting duplicated entries deletes the old entries, keeps the latest entry in the
// duplicated entry list.
$tempDeleteList = array();
$duplicatedContentList = $db->arrayQuery("SELECT contentobject_id, contentobject_version, is_main, parent_node\n FROM eznode_assignment\n GROUP BY contentobject_id, contentobject_version, is_main, parent_node\n HAVING COUNT(*) > 1");
foreach ($duplicatedContentList as $duplicatedContent) {
$assignmentList = $db->arrayQuery("SELECT * FROM eznode_assignment" . " WHERE contentobject_id = " . $duplicatedContent['contentobject_id'] . " AND contentobject_version = " . $duplicatedContent["contentobject_version"] . " AND parent_node =" . $duplicatedContent["parent_node"] . " ORDER BY id DESC");
$assignmentListCount = count($assignmentList);
//Find the duplicated entries( array index start from 1 ) and delete them. Leave the one entry( array index is 0 )
for ($i = 1; $i < $assignmentListCount; $i++) {
if ($assignmentList[$i]["parent_node"] != $exclusiveParentID) {
$tempAssignID = $assignmentList[$i]["id"];
$cli->notice('Node assignment [ id: ' . $tempAssignID . ' ] for contentobject [ id: ' . $assignmentList[$i]["contentobject_id"] . '] is duplicated thus will be removed.');
$sql = "DELETE FROM eznode_assignment WHERE id = " . $tempAssignID;
$result = $db->query($sql);
if ($result === false) {
$cli->notice('Node assignment [ id: ' . $tempAssignID . ' ] ' . 'could not be removed. Please restore your database from backup and try again.');
return;
}
$deletedCount++;
}
}
}
if ($deletedCount != 0) {
$cli->output($deletedCount . ' node assignments have been deleted.');
} else {
$cli->output('None of available node assignments has been deleted.');
}
}
示例3: changeSiteAccessSetting
function changeSiteAccessSetting($siteAccess)
{
$cli = eZCLI::instance();
if (file_exists('settings/siteaccess/' . $siteAccess)) {
$cli->output("Using siteaccess {$siteAccess} for nice url update");
} else {
$cli->notice("Siteaccess {$siteAccess} does not exist, using default siteaccess");
}
}
示例4: __construct
/**
* Private constructor.
* To instantiate factory, please use Singleton pattern : <code>$factory = SQLIImportFactory::instance();</code>
* @see self::instance()
*/
private function __construct()
{
$this->importINI = eZINI::instance('sqliimport.ini');
$this->cli = eZCLI::instance();
$this->aAvailableSourceHandlers = $this->importINI->variable('ImportSettings', 'AvailableSourceHandlers');
$this->robotUser = $this->setLoggedInUser();
$this->output = new ezcConsoleOutput();
SQLIImportToken::setIsImportScript(true);
}
示例5: changeSiteAccessSetting
function changeSiteAccessSetting($siteAccess)
{
$cli = eZCLI::instance();
if (in_array($siteAccess, eZINI::instance()->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) {
$cli->output("Using siteaccess {$siteAccess} for nice url update");
} else {
$cli->notice("Siteaccess {$siteAccess} does not exist, using default siteaccess");
}
}
示例6: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
$cli = eZCLI::instance();
if (file_exists('settings/siteaccess/' . $optionData)) {
$siteaccess = $optionData;
$cli->output("Using siteaccess {$siteaccess} for cronjob");
} else {
$cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
}
}
示例7: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
$cli = eZCLI::instance();
if (in_array($optionData, eZINI::instance()->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) {
$siteaccess = $optionData;
$cli->output("Using siteaccess {$siteaccess} for content object name update");
} else {
$cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
}
}
示例8: updateClass
function updateClass($classId, $scheduledScript)
{
$cli = eZCLI::instance();
/*
// If the class is not stored yet, store it now
$class = eZContentClass::fetch( $classId, true, eZContentClass::VERSION_STATUS_TEMPORARY );
if ( $class )
{
$cli->output( "Storing class" );
$class->storeDefined( $class->fetchAttributes() );
}
*/
// Fetch the stored class
$class = eZContentClass::fetch($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
if (!$class) {
$cli->error('No class in a modified version status with ID: ' . $classId);
return;
}
// Fetch attributes and definitions
$attributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
$oldClassAttributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_DEFINED);
// Delete object attributes which have been removed.
foreach ($oldClassAttributes as $oldClassAttribute) {
$attributeExist = false;
$oldClassAttributeID = $oldClassAttribute->attribute('id');
foreach ($attributes as $newClassAttribute) {
if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
$attributeExist = true;
}
}
if (!$attributeExist) {
foreach (eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID) as $objectAttribute) {
$objectAttribute->removeThis($objectAttribute->attribute('id'));
}
}
}
$class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
// Add object attributes which have been added.
foreach ($attributes as $newClassAttribute) {
$attributeExist = false;
foreach ($oldClassAttributes as $oldClassAttribute) {
if ($oldClassAttribute->attribute('id') == $newClassAttribute->attribute('id')) {
$attributeExist = true;
break;
}
}
if (!$attributeExist) {
$objects = null;
$newClassAttribute->initializeObjectAttributes($objects);
}
}
if ($scheduledScript !== false) {
$scheduledScript->updateProgress(100);
}
}
示例9: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
$ini = eZINI::instance();
$cli = eZCLI::instance();
$availableSiteAccessList = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
if (in_array($optionData, $availableSiteAccessList)) {
$siteaccess = $optionData;
$cli->output("Using siteaccess {$siteaccess} for database cleanup");
} else {
$cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
}
}
示例10: run
/**
* Executes the purge operation
*
* @todo Endless loop on fetch list. The expired items are returned over and over again
*/
public function run()
{
$cli = eZCLI::instance();
if ( $this->optMemoryMonitoring == true )
{
eZLog::rotateLog( self::LOG_FILE );
$cli->output( "Logging memory usage to " . self::LOG_FILE );
}
if ( $this->optIterationSleep > 0 )
$sleep = ( $this->optIterationSleep * 1000000 );
else
$sleep = false;
$limit = array( 0, $this->optIterationLimit );
$cli->output( "Purging expired items:" );
self::monitor( "start" );
// Fetch a limited list of purge items from the handler itself
$clusterHandler = eZClusterFileHandler::instance();
while ( $filesList = $clusterHandler->fetchExpiredItems( $this->optScopes, $limit, $this->optExpiry ) )
{
self::monitor( "iteration start" );
foreach( $filesList as $file )
{
$cli->output( "- $file" );
if ( $this->optDryRun == false )
{
self::monitor( "purge" );
$fh = eZClusterFileHandler::instance( $file );
$fh->purge( false, false );
unset( $fh );
}
}
if ( $sleep !== false )
usleep( $sleep );
// the offset only has to be increased in dry run mode
// since each batch is not deleted
if ( $this->optDryRun == true )
{
$limit[0] += $limit[1];
}
self::monitor( "iteration end" );
}
self::monitor( "end" );
}
示例11: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
$cli = eZCLI::instance();
if (file_exists('settings/siteaccess/' . $optionData)) {
$siteaccess = $optionData;
return "Using siteaccess {$siteaccess} for cronjob";
} elseif (isExtensionSiteaccess($optionData)) {
$siteaccess = $optionData;
eZExtension::prependExtensionSiteAccesses($siteaccess);
return "Using extension siteaccess {$siteaccess} for cronjob";
} else {
return "Siteaccess {$optionData} does not exist, using default siteaccess";
}
}
示例12: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
global $cronPart;
$cli = eZCLI::instance();
if (file_exists('settings/siteaccess/' . $optionData)) {
$siteaccess = $optionData;
$cli->output("Using siteaccess {$siteaccess} for cronjob");
} elseif (isExtensionSiteaccess($optionData)) {
$siteaccess = $optionData;
$cli->output("Using extension siteaccess {$siteaccess} for cronjob");
eZExtension::prependExtensionSiteAccesses($siteaccess);
} else {
$cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
}
}
示例13: save
/**
* Saves the xml content
*
* @param $filename Path to file
*/
function save($filename = 'sitemap.xml')
{
$file = eZClusterFileHandler::instance($filename);
if ($file->exists()) {
eZDebug::writeDebug("Time: " . date('d.m.Y H:i:s') . ". Action: " . $filename . " exists. File will be remove.");
if (!$isQuiet) {
$cli = eZCLI::instance();
$cli->output("Time: " . date('d.m.Y H:i:s') . ". Action: " . $filename . " exists. File will be remove.");
$cli->output("\n");
}
$file->delete();
}
$xml = $this->dom->saveXML();
return $file->storeContents($xml, 'sitemap', 'text/xml');
}
示例14: changeSiteAccessSetting
function changeSiteAccessSetting(&$siteaccess, $optionData)
{
global $isQuiet;
$cli = eZCLI::instance();
if (file_exists('settings/siteaccess/' . $optionData)) {
$siteaccess = $optionData;
if (!$isQuiet) {
$cli->notice("Using siteaccess {$siteaccess} for database cleanup");
}
} else {
if (!$isQuiet) {
$cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess");
}
}
}
示例15: warning
function warning($text, $position = false)
{
if ($position) {
$str = $position['file'] . ':' . $position['from'][0] . ' C' . $position['from'][1];
if (isset($position['to'])) {
$str .= ' -> L' . $position['to'][0] . ' C' . $position['to'][1];
}
$str .= ':';
}
$str .= $text;
if (class_exists('ezcli')) {
$cli = eZCLI::instance();
$cli->warning($str);
} else {
eZDebug::writeWarning($str, __METHOD__);
}
}