本文整理汇总了PHP中eZDateTime::currentTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDateTime::currentTimeStamp方法的具体用法?PHP eZDateTime::currentTimeStamp怎么用?PHP eZDateTime::currentTimeStamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZDateTime
的用法示例。
在下文中一共展示了eZDateTime::currentTimeStamp方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例7: 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());
//.........这里部分代码省略.........
示例8: 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);
示例9: createNewVersion
/**
* Creates a new version for content.
* If content is a new one, a new node assignment will be created with 'parent_node_id' option ({@link self::setOptions()})
* @param SQLIContent $content
* @internal
* @return eZContentObjectVersion
*/
private function createNewVersion(SQLIContent $content)
{
eZDebug::accumulatorStart('sqlicontentpublisher_version', 'sqlicontentpublisher', 'Version creation');
$contentObject = $content->getRawContentObject();
if ($content->isNew()) {
$nodeAssignment = $this->createNodeAssignmentForContent($content, $this->options['parent_node_id'], true);
// Main node assignment for new object
$version = $contentObject->currentVersion();
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
} else {
$version = $content->getDraft();
}
eZDebug::accumulatorStop('sqlicontentpublisher_version');
return $version;
}
示例10: 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;
}