本文整理汇总了PHP中eZDateTime类的典型用法代码示例。如果您正苦于以下问题:PHP eZDateTime类的具体用法?PHP eZDateTime怎么用?PHP eZDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObject
/**
* Performs PDF content generation and caching
*
* @param $url String URL
* @param $denisty Integer
* @param $keys Mixed Keys for Cache key(s) - either as a string or an array of strings
* @param $subtree_expiry Mixed The parameter $subtreeExpiryParameter is expiry value is usually taken
* from the template operator and can be one of:
* - A numerical value which represents the node ID (the fastest approach)
* - A string containing 'content/view/full/xxx' where xx is the node ID number,
* the number will be extracted.
* - A string containing a nice url which will be decoded into a node ID using
* the database (slowest approach).
* @param $expiry Integer The number of seconds that the pdf cache should be allowed to live.A value of
* zero will produce a cache block that will never expire
* @param $ignore_content_expiry Boolean Disables cache expiry when new content is published.
* @return void
*/
public function getObject($url = '', $density, $keys, $subtree_expiry, $expiry, $ignore_content_expiry = false)
{
$pngUrl = '';
$obj = false;
$mtime = eZDateTime::currentTimeStamp();
$httpExpiry = $this->cacheTTL;
if (strpos("://", $url) === false) {
$url = eZSys::serverURL() . $url;
}
//eZDebug::writeError($url, 'sPdf2png::exportPng');
if ($this->cacheEnabled) {
$use_global_expiry = !$ignore_content_expiry;
//$keys = self::getCacheKeysArray($keys);
$expiry = is_numeric($expiry) ? $expiry : $this->cacheTTL;
list($handler, $pngUrl) = eZTemplateCacheBlock::retrieve($keys, $subtree_expiry, $expiry, $use_global_expiry);
if ($pngUrl instanceof eZClusterFileFailure || !file_get_contents($pngUrl)) {
eZDebug::writeError("cache invalid", 'sPdf2png::exportPng');
$obj = $this->generatePng($url, $density, $keys);
$handler->storeCache(array('scope' => 'template-block', 'binarydata' => $obj['url']));
}
//eZDebug::writeError("cache", 'sPdf2png::exportPng');
} else {
$obj = $this->generatePng($url, $density, $keys);
}
if (!$obj) {
$obj = $this->getPngData($pngUrl);
}
$obj['url'] = self::getWwwDir() . $obj['url'];
return $obj;
}
示例2: updateUser
/**
* Updates user with provided auth data
*
* @param eZUser $user
* @param array $authResult
*
* @return bool
*/
public static function updateUser($user, $authResult)
{
$currentTimeStamp = eZDateTime::currentTimeStamp();
$contentObject = $user->contentObject();
if (!$contentObject instanceof eZContentObject) {
return false;
}
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$db = eZDB::instance();
$db->begin();
$version->setAttribute('modified', $currentTimeStamp);
$version->store();
self::fillUserObject($version->dataMap(), $authResult);
if ($authResult['email'] != $user->Email) {
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user->setAttribute('email', $email);
$user->store();
}
$contentObject->setName($contentObject->contentClass()->contentObjectName($contentObject));
$contentObject->store();
$db->commit();
return $user;
}
示例3: save
/**
* Save article draft for later approval
*/
public function save()
{
$user = eZUser::fetchByName('admin');
$params = array('class_identifier' => 'article', 'creator_id' => $user->attribute('contentobject_id'), 'parent_node_id' => $this->location, 'name' => $this->header, 'attributes' => array('title' => $this->header, 'intro' => $this->xmlConvert($this->ingress), 'body' => $this->xmlConvert($this->text)));
// Manipulate version (setting state to draft)
$contentObject = eZContentFunctions::createAndPublishObject($params);
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
}
示例4: exportPDF
/**
* Performs PDF content generation and caching
*
* @param $xhtml String XHTML content
* @param $pdf_file_name String Name that will be used when serving the PDF file (not for storage)
* @param $keys Mixed Keys for Cache key(s) - either as a string or an array of strings
* @param $subtree_expiry Mixed The parameter $subtreeExpiryParameter is expiry value is usually taken
* from the template operator and can be one of:
* - A numerical value which represents the node ID (the fastest approach)
* - A string containing 'content/view/full/xxx' where xx is the node ID number,
* the number will be extracted.
* - A string containing a nice url which will be decoded into a node ID using
* the database (slowest approach).
* @param $expiry Integer The number of seconds that the pdf cache should be allowed to live.A value of
* zero will produce a cache block that will never expire
* @param $ignore_content_expiry Boolean Disables cache expiry when new content is published.
* @return void
*/
public function exportPDF($xhtml = '', $pdf_file_name = '', $keys, $subtree_expiry, $expiry, $ignore_content_expiry = false)
{
if ($pdf_file_name == '') {
$pdf_file_name = 'file';
}
$data = '';
$size = 0;
$mtime = eZDateTime::currentTimeStamp();
$httpExpiry = $this->cacheTTL;
if ($this->cacheEnabled) {
$keys = self::getCacheKeysArray($keys);
$expiry = is_numeric($expiry) ? $expiry : $this->cacheTTL;
if ($expiry > 0) {
$httpExpiry = $expiry;
}
if (isset($subtree_expiry)) {
$ignore_content_expiry = true;
}
list($handler, $data) = eZTemplateCacheBlock::retrieve($keys, $subtree_expiry, $expiry, !$ignore_content_expiry);
if ($data instanceof eZClusterFileFailure || $handler->size() == 0) {
$data = $this->generatePDF($xhtml);
// check if error occurred during pdf generation
if ($data === false) {
return;
}
$handler->storeCache(array('scope' => 'template-block', 'binarydata' => $data));
$size = strlen($data);
} else {
$size = $handler->size();
$mtime = $handler->mtime();
}
} else {
$data = $this->generatePDF($xhtml);
// check if error occurred during pdf generation
if ($data === false) {
return;
}
$size = $this->size;
}
$this->flushPDF($data, $pdf_file_name, $size, $mtime, $httpExpiry);
}
示例5: createObject
function createObject($classIdentifier, $parentNodeID, $name)
{
$user = eZUser::currentUser();
$Class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$Class) {
eZDebug::writeError("No class with identifier {$classIdentifier}", "classCreation");
return false;
}
$contentObject = $Class->instantiate($user->attribute('contentobject_id'));
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$attributes = $contentObject->attribute('contentobject_attributes');
$attributes[0]->fromString($name);
$attributes[0]->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
return true;
}
示例6: readline
$action = $mode;
} else {
$action = readline("Remote ID '{$nonUniqueRemoteIDData['remote_id']}' is used for {$nonUniqueRemoteIDData['cnt']} different tree nodes. Do you want to see the details (d) or do you want this inconsistency to be fixed automatically (a) ?");
while (!in_array($action, array('a', 'd'))) {
$action = readline('Invalid option. Type either d for details or a to fix automatically.');
}
}
$treeNodes = eZPersistentObject::fetchObjectList(eZContentObjectTreeNode::definition(), null, array('remote_id' => $nonUniqueRemoteIDData['remote_id']), array('modified_subnode' => 'asc'));
switch ($action) {
case 'd':
$cli->output('');
$cli->output('Select the number of the tree node that you want to keep the current remote ID. The other listed tree nodes will get a new one.');
$cli->output('');
foreach ($treeNodes as $i => $treeNode) {
$nodeID = $treeNode->attribute('node_id');
$dateTime = new eZDateTime($treeNode->attribute('modified_subnode'));
$formattedDateTime = $dateTime->toString(true);
$pathIdentificationString = $treeNode->attribute('path_identification_string');
$cli->output("{$i}) {$pathIdentificationString} (Node ID: {$nodeID}, modified_subnode: {$formattedDateTime} )");
$cli->output('');
}
do {
$skip = readline('Number of nodes that should keep the current remote ID: ');
} while (!array_key_exists($skip, $treeNodes));
break;
case 'a':
default:
$skip = 0;
}
$cli->output('Fixing...');
foreach ($treeNodes as $i => $treeNode) {
示例7: createSubNode
function createSubNode($node, $name)
{
$namedChildrenArray = $node->childrenByName($name);
$subNode = false;
//pk
if (!$node->canCreate()) {
$this->setError(self::ERROR_ACCESSDENIED, ezpI18n::tr('extension/ezodf/import/error', "Folder for images could not be created, access denied."));
return false;
}
if (empty($namedChildrenArray)) {
$class = eZContentClass::fetchByIdentifier("folder");
$creatorID = $this->currentUserID;
//$creatorID = 14; // 14 == admin
$parentNodeID = $placeNodeID;
$contentObject = $class->instantiate($creatorID, 1);
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $node->attribute('node_id'), 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$dataMap = $contentObject->dataMap();
$titleAttribudeIdentifier = 'name';
$dataMap[$titleAttribudeIdentifier]->setAttribute('data_text', $name);
$dataMap[$titleAttribudeIdentifier]->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
$subNode = $contentObject->mainNode();
} else {
if (count($namedChildrenArray) == 1) {
$subNode = $namedChildrenArray[0];
}
}
return $subNode;
}
示例8: createAndPublishObject
/**
* Creates and publishes a new content object.
*
* This function takes all the variables passes in the $params
* argument and creates a new content object out of it.
*
* Here is an example
* <code>
* <?php
*
* // admin user
* $creatorID = 14;
*
* // folder content class
* $classIdentifier = 'folder';
*
* // root node
* $parentNodeID = 2;
*
* // have a look at the folder content class' definition ;)
* // basically the array is the following :
* // key : attribute identifier ( not attribute ID !! )
* // value : value for this attribute
* //
* // Please refer to each fromString/toString function to see
* // how to organize your data
*
* $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?>
* <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
* xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
* xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">';
*
* $attributeList = array( 'name' => 'A newly created folder object',
* 'short_name' => 'A new folder',
* 'short_description' => $xmlDeclaration .'<paragraph>This is the short description</paragraph></section>',
* 'description' => $xmlDeclaration . '<section><section><header>Some header</header><paragraph>Some paragraph
* with a <link target="_blank" url_id="1">link</link></paragraph>
* </section></section></section>',
* 'show_children' => true);
*
* // Creates the data import array
* $params = array();
* $params['creator_id'] = $creatorID;
* $params['class_identifier'] = $classIdentifier;
* $params['parent_node_id'] = $parentNodeID;
* $params['attributes'] = $attributeList;
*
* $contentObject = eZContentFunctions::createAndPublishObject( $params );
*
* if( $contentObject )
* {
* // do anything you want here
* }
*
* ?>
* </code>
*
* @param array $params An array with all the informations to store.
* This array must contains a strict list of key/value pairs.
* The possible keys are the following :
* - 'parent_node_id' : The parentNodeID for this new object.
* - 'class_identifier' : The classIdentifier for this new object.
* using the classID is not possible.
* - 'creator_id' : The eZUser::contentObjectID to use as creator
* of this new eZContentObject, uses current user
* and stores object id in current session if not set
* - 'attributes' : The list of attributes to store, in order to now
* which values you can use for this key, you have to
* read the code of the fromString and toString functions
* of the attribute's datatype you use
* - 'storage_dir' :
* - 'remote_id' : The value for the remoteID (optional)
* - 'section_id' : The value for the sectionID (optional)
* @return eZContentObject|false An eZContentObject object if success, false otherwise
*/
static function createAndPublishObject($params)
{
$parentNodeID = $params['parent_node_id'];
$classIdentifier = $params['class_identifier'];
$creatorID = isset($params['creator_id']) ? $params['creator_id'] : false;
$attributesData = isset($params['attributes']) ? $params['attributes'] : false;
$storageDir = isset($params['storage_dir']) ? $params['storage_dir'] : '';
$contentObject = false;
$parentNode = eZContentObjectTreeNode::fetch($parentNodeID, false, false);
if (is_array($parentNode)) {
$contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
if ($contentClass instanceof eZContentClass) {
$db = eZDB::instance();
$db->begin();
$languageCode = isset($params['language']) ? $params['language'] : false;
$sectionID = isset($params['section_id']) ? $params['section_id'] : 0;
$contentObject = $contentClass->instantiate($creatorID, $sectionID, false, $languageCode);
if (array_key_exists('remote_id', $params)) {
$contentObject->setAttribute('remote_id', $params['remote_id']);
}
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1, 'sort_field' => $contentClass->attribute('sort_field'), 'sort_order' => $contentClass->attribute('sort_order')));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
//.........这里部分代码省略.........
示例9: while
if (!$class) {
$cli->error("No class with identifier {$createClass}");
$script->shutdown(1);
}
$fp = @fopen($inputFileName, "r");
if (!$fp) {
$cli->error("Can not open file {$inputFileName} for reading");
$script->shutdown(1);
}
while ($objectData = fgetcsv($fp, $csvLineLength, ';', '"')) {
$contentObject = $class->instantiate($creator);
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $nodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$attributes = $contentObject->attribute('contentobject_attributes');
while (list($key, $attribute) = each($attributes)) {
$dataString = $objectData[$key];
switch ($datatypeString = $attribute->attribute('data_type_string')) {
case 'ezimage':
case 'ezbinaryfile':
case 'ezmedia':
$dataString = eZDir::path(array($storageDir, $dataString));
break;
default:
}
$attribute->fromString($dataString);
示例10: foreach
$nodeObject = eZContentObjectTreeNode::fetch($nodeID);
if ($nodeObject != null) {
$counter = eZViewCounter::fetch($nodeID);
if ($counter == null) {
$counter = eZViewCounter::create($nodeID);
}
$counter->increase();
}
}
foreach ($pathArray as $path) {
$nodeID = eZURLAliasML::fetchNodeIDByPath($path);
if ($nodeID) {
$counter = eZViewCounter::fetch($nodeID);
if ($counter == null) {
$counter = eZViewCounter::create($nodeID);
}
$counter->increase();
}
}
$dt = new eZDateTime();
$fh = fopen($updateViewLogPath, "w");
if ($fh) {
fwrite($fh, "# Finished at " . $dt->toString() . "\n");
fwrite($fh, "# Last updated entry:" . "\n");
fwrite($fh, $lastLine . "\n");
fclose($fh);
}
$cli->output("Finished at " . $dt->toString() . "\n");
if (!$isQuiet) {
$cli->output("View count have been updated!\n");
}
示例11: foreach
// Try prepending each of the existing pathPrefixes, to see if one of them matches an existing node
$nodeID = eZURLAliasML::fetchNodeIDByPath($pathPrefixes[$pathPrefixIndex] . $path);
}
if ($nodeID) {
if (!isset($nodeIDHashCounter[$nodeID])) {
$nodeIDHashCounter[$nodeID] = $count;
} else {
$nodeIDHashCounter[$nodeID] += $count;
}
}
}
foreach ($nodeIDHashCounter as $nodeID => $count) {
if (eZContentObjectTreeNode::fetch($nodeID) != null) {
$counter = eZViewCounter::fetch($nodeID);
if ($counter == null) {
$counter = eZViewCounter::create($nodeID);
$counter->setAttribute('count', $count);
$counter->store();
} else {
$counter->increase($count);
}
}
}
$dt = new eZDateTime();
$fh = fopen($updateViewLogPath, "w");
if ($fh) {
fwrite($fh, "# Finished at " . $dt->toString() . "\n" . "# Last updated entry:" . "\n" . $lastLine . "\n");
fclose($fh);
}
$cli->output("Finished at " . $dt->toString() . "\n");
$cli->output("View count have been updated!\n");
示例12: getCurrentDraft
/**
* Returns current draft for current content object.
* If there is no current draft, a new one will be created in provided language.
* @param string|bool $lang Valid locale xxx-XX. If not provided, default edit language will be used
* @see eZContentObject::createNewVersionIn()
* @return eZContentObjectVersion
*/
public function getCurrentDraft($lang = false)
{
$currentDraft = null;
$db = eZDB::instance();
// First check if we already have a draft
$aFilter = array('contentobject_id' => $this->contentObject->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)));
$res = eZContentObjectVersion::fetchFiltered($aFilter, null, null);
if (count($res) > 0 && $res[0] instanceof eZContentObjectVersion) {
$currentDraft = $res[0];
// FIXME : Fetch may result several drafts. We should take the last one (highest version)
$currentDraft->setAttribute('modified', eZDateTime::currentTimeStamp());
$currentDraft->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$currentDraft->store();
} else {
$db->begin();
$currentDraft = $this->contentObject->createNewVersionIn($lang, false, $this->contentObject->attribute('current_version'));
$currentDraft->store();
$db->commit();
}
return $currentDraft;
}
示例13: eZDateTime
*
* @copyright Copyright (C) 1999-2010 eZ Systems AS. All rights reserved.
* @license http://ez.no/licenses/gnu_gpl GNU GPLv2
*
*/
/**
* Send comment notification to user who subscribed the content
*
*/
$cli = eZCLI::instance();
if (!$isQuiet) {
$cli->output("Start sending comment notification...");
}
// 1. check ezcomment_notification table
$db = eZDB::instance();
$now = new eZDateTime();
$currentTime = $now->toTime()->timeStamp();
$ezcommentsINI = eZINI::instance('ezcomments.ini');
$sendingNumber = $ezcommentsINI->variable('NotificationSettings', 'NotificationNumberPerExecuation');
$mailContentType = $ezcommentsINI->variable('NotificationSettings', 'MailContentType');
$mailFrom = $ezcommentsINI->variable('NotificationSettings', 'MailFrom');
$contentObjectIDList = $db->arrayQuery('SELECT DISTINCT contentobject_id, language_id' . ' FROM ezcomment_notification ' . 'WHERE status=1' . ' AND send_time < ' . $currentTime, array('offset' => 0, 'limit' => $sendingNumber));
$notificationCount = 0;
$mailCount = 0;
foreach ($contentObjectIDList as $contentObjectArray) {
$contentObjectID = $contentObjectArray['contentobject_id'];
$contentLanguage = $contentObjectArray['language_id'];
$notifications = $db->arrayQuery('SELECT * FROM ezcomment_notification ' . 'WHERE contentobject_id = ' . $contentObjectID);
// fetch content object
$contentObject = eZContentObject::fetch($contentObjectID, true);
$contentLanguageLocale = eZContentLanguage::fetch($contentLanguage)->attribute('locale');
示例14: writeUpdateToken
/**
* Writes a "token file"
* This is useful whenever there are log files which get parse based on cronjobs
* and we have to remember the last line which has been found
*/
protected static function writeUpdateToken($tokenFile, $tokenLine)
{
$sys = eZSys::instance();
$updateViewLogPath = $sys->varDirectory() . "/" . eZPerfLoggerINI::variable('FileSettings', 'LogDir', 'site.ini') . "/" . $tokenFile;
$dt = new eZDateTime();
if (!file_put_contents($updateViewLogPath, "# Finished at " . $dt->toString() . "\n" . "# Last updated entry:" . "\n" . $tokenLine . "\n")) {
eZPerfLoggerDebug::writeError("Could not store last date of perf-log file parsing in {$updateViewLogPath}, double-counting might occur", __METHOD__);
}
}
示例15: batchInitializeObjectAttributeData
function batchInitializeObjectAttributeData( $classAttribute )
{
$defaultType = $classAttribute->attribute( self::DEFAULT_FIELD );
switch( $defaultType )
{
case self::DEFAULT_CURRENT_DATE:
{
$default = time();
} break;
case self::DEFAULT_ADJUSTMENT:
{
$adjustments = $this->classAttributeContent( $classAttribute );
$value = new eZDateTime();
$secondAdjustment = $classAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 ? $adjustments['second'] : 0;
$value->adjustDateTime( $adjustments['hour'], $adjustments['minute'], $secondAdjustment, $adjustments['month'], $adjustments['day'], $adjustments['year'] );
$default = $value->timeStamp();
} break;
default:
{
$default = 0;
}
}
return array( 'data_int' => $default, 'sort_key_int' => $default );
}