本文整理汇总了PHP中eZContentObjectTreeNode::subTree方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::subTree方法的具体用法?PHP eZContentObjectTreeNode::subTree怎么用?PHP eZContentObjectTreeNode::subTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::subTree方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBrowseItems
/**
* Returns a struct containing the following values:
* - limit the number of element by page
* - offset the current offset
* - items array, each element contains
* - has_child boolean
* - can_create boolean
* - node eZContentObjectTreeNode
* - has_prev boolean, true if there's a previous page
* - has_next boolean, true if there's a next page
*
* @param eZContentObjectTreeNode $start the node where the browse will start
* @param eZContentClass $class class of the object to be created
* @param int $offset
* @return array
*/
private static function getBrowseItems( eZContentObjectTreeNode $start, eZContentClass $class, $offset = 0 )
{
$result = array(
'limit' => 10,
'offset' => $offset,
'items' => array(),
'has_prev' => ( $offset != 0 ),
'has_next' => false
);
$containerClasses = eZPersistentObject::fetchObjectList(
eZContentClass::definition(), null,
array(
'version' => eZContentClass::VERSION_STATUS_DEFINED,
'is_container' => 1
)
);
$classFilterArray = array();
foreach ( $containerClasses as $c )
{
$classFilterArray[] = $c->attribute( 'identifier' );
}
$children = $start->subTree(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1,
'Limit' => $result['limit'],
'Offset' => $offset
)
);
$count = $start->subTreeCount(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1
)
);
if ( $count > ( $offset + $result['limit'] ) )
{
$result['has_next'] = true;
}
foreach( $children as $node )
{
$elt = array();
$elt['node'] = $node;
$canCreateClassist = $node->canCreateClassList();
foreach( $canCreateClassist as $c )
{
if ( $c['id'] == $class->attribute( 'id' ) )
{
$elt['can_create'] = true;
break;
}
}
if ( !isset( $elt['can_create'] ) )
{
$elt['can_create'] = false;
}
$childrenContainerCount = $node->subTreeCount(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1
)
);
$elt['has_child'] = ( $childrenContainerCount > 0 );
$result['items'][] = $elt;
}
return $result;
}
示例2: clearViewCacheForSubtree
/**
* Clears the view cache for a subtree
*
* @param eZContentObjectTreeNode $node
* @param bool $clearForRootNode
* @return bool
*/
static function clearViewCacheForSubtree(eZContentObjectTreeNode $node, $clearForRootNode = true)
{
// Max nodes to fetch at a time
static $limit = 200;
if ($clearForRootNode) {
$objectID = $node->attribute('contentobject_id');
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
}
$offset = 0;
$params = array('AsObject' => false, 'Depth' => false, 'Limitation' => array());
// Empty array means no permission checking
$subtreeCount = $node->subTreeCount($params);
while ($offset < $subtreeCount) {
$params['Offset'] = $offset;
$params['Limit'] = $limit;
$subtreeChunk = $node->subTree($params);
$nNodesInChunk = count($subtreeChunk);
$offset += $nNodesInChunk;
if ($nNodesInChunk == 0) {
break;
}
$objectIDList = array();
foreach ($subtreeChunk as $curNode) {
$objectIDList[] = $curNode['id'];
}
unset($subtreeChunk);
eZContentCacheManager::clearContentCacheIfNeeded(array_unique($objectIDList));
}
return true;
}
示例3: fetchImages
public static function fetchImages(eZContentObjectTreeNode $node)
{
$images = array();
$ini = eZINI::instance('xrowsitemap.ini');
$params = array('Limit' => 999, 'ClassFilterType' => 'include', 'ClassFilterArray' => $ini->variable('SitemapSettings', 'ImageClasses'));
$nodeArray = $node->subTree($params);
foreach ($nodeArray as $imageNode) {
$imageadd = self::getImageConverter()->addImage($imageNode);
if (!empty($imageadd)) {
$images = array_merge($images, $imageadd);
}
}
return $images;
}
示例4: fetch
public function fetch()
{
return $this->mainNode->subTree($this->fetchParameters);
}
示例5: doDeliveries
function doDeliveries($quiet = false)
{
$cli = eZCLI::instance();
$issueLimit = 5;
// Number of issues the script will process each time
$deliveredCount = 0;
$deliveryLimit = 200;
// Number of deliveries the script will do each time. Should be multiples of 50
$newsletterIni = eZINI::instance('jajnewsletter.ini');
$newsletterIssuesNodeID = $newsletterIni->variable('ContentSettings', 'NewsletterIssuesNode');
$subscriptionUsersNodeID = $newsletterIni->variable('ContentSettings', 'SubscriptionUsersNode');
$fromName = $newsletterIni->variable('NewsletterSettings', 'FromName');
$fromEmail = $newsletterIni->variable('NewsletterSettings', 'FromEmail');
$replyTo = $newsletterIni->variable('NewsletterSettings', 'ReplyTo');
// Get list of newsletter issues with status In Progress
//$newsletterIssues =& eZContentObjectTreeNode::subTreeByNodeID(
$newsletterIssues =& eZContentObjectTreeNode::subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => array('newsletter_issue'), 'AttributeFilter' => array(array('newsletter_issue/status', '=', JAJ_NEWSLETTER_ISSUE_STATUS_PENDING)), 'Limit' => $issueLimit), $newsletterIssuesNodeID);
if (!$quiet) {
$cli->output('Newsletter issues awating delivery: ' . count($newsletterIssues) . ' (' . $issueLimit . ' max)');
}
foreach ($newsletterIssues as $issue) {
// Get newsletter and prepare
$issueObject = $issue->object();
$issueDatamap = $issueObject->dataMap();
$newsletterSubject = $issueDatamap['subject']->content();
if (!$quiet) {
$cli->output();
$cli->output('Delivering newsletter \'' . $newsletterSubject . '\' (Object id: ' . $issueObject->ID . ')');
}
$newsletterBody = JAJNewsletterOperations::prepareNewsletterIssue($issueObject);
if ($newsletterBody == false) {
if (!$quiet) {
$cli->notice('Failed to generate newsletter \'' . $newsletterSubject . '\' (Object id: ' . $issueObject->ID . ')');
}
continue;
}
// Go though users in delivery que in batch and deliver newsletter
$userLimit = 50;
while (true) {
// Get users in delivery que for current newsletteer
// TODO: Should only get items where jajdelivery.tstamp > 1 hour or something
//$userNodes =& eZContentObjectTreeNode::subTreeByNodeID(
$userNodes =& eZContentObjectTreeNode::subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => array('subscription_user'), 'ExtendedAttributeFilter' => array(id => 'jajdeliveryfilter', params => array('newsletter_object_id' => $issueObject->ID, 'status' => array(JAJ_NEWSLETTER_DELIVERY_STATUS_PENDING))), 'Limit' => $userLimit, 'Limitation' => array()), $subscriptionUsersNodeID);
$userCount = count($userNodes);
if (!$quiet) {
$cli->output(' Users found for batch delivery: ' . $userCount . ' (' . $userLimit . ' max in batch)');
}
foreach ($userNodes as $userNode) {
$userObject = $userNode->object();
$userDatamap = $userObject->dataMap();
$userEmail = $userDatamap['email']->content();
if (!$quiet) {
$cli->output(' Delivereing to: ' . $userEmail, false);
}
$htmlNewsletter = $newsletterBody['html'];
$plainNewsletter = $newsletterBody['plain'];
$htmlNewsletter = str_replace("__remote_id", $userObject->remoteID(), $htmlNewsletter);
$htmlNewsletter = str_replace("__object_id", $userObject->ID, $htmlNewsletter);
$plainNewsletter = str_replace("__remote_id", $userObject->remoteID(), $plainNewsletter);
$plainNewsletter = str_replace("__object_id", $userObject->ID, $plainNewsletter);
$newsletterDeliveryResult = JAJNewsletterOperations::deliver($newsletterSubject, $htmlNewsletter, $plainNewsletter, $fromName, $fromEmail, $replyTo, $userEmail);
$deliveryResult = JAJDelivery::fetchDelivery($issueObject->ID, $userObject->ID);
$delivery = $deliveryResult['result'];
$delivery->setAttribute('tstamp', time());
if ($newsletterDeliveryResult) {
if (!$quiet) {
$cli->output(' => OK');
}
$delivery->setAttribute('status', JAJ_NEWSLETTER_DELIVERY_STATUS_SENT);
} else {
$tries = $delivery->attribute('tries') + 1;
$delivery->setAttribute('tries', $tries);
if ($tries >= 3) {
$delivery->setAttribute('status', JAJ_NEWSLETTER_DELIVERY_STATUS_FAILED);
}
if (!$quiet) {
$cli->output(' => FAILED, tries: ' . $tries);
}
}
$delivery->sync();
$deliveredCount++;
}
eZContentObject::clearCache();
if ($userCount < $userLimit || $deliveredCount >= $deliveryLimit) {
break;
}
}
if ($deliveredCount >= $deliveryLimit) {
if (!$quiet) {
$cli->output('Reached delivery limit for script (' . $deliveredCount . '/' . $deliveryLimit . ')');
}
break;
}
// Change status to archived if delivery que for newsletter is empty
if (JAJDelivery::emptyDeliveryQue($issueObject->ID)) {
if (!$quiet) {
$cli->output('Delivery que for newsletter empty, changing status to archived');
}
$status = $issueDatamap["status"];
$status->setAttribute('data_text', JAJ_NEWSLETTER_ISSUE_STATUS_ARCHIVED);
//.........这里部分代码省略.........
示例6: deleteNodes
/**
* Delete childrens nodes of the nodeID specified
* @param eZContentObjectTreeNode $parentNode
*/
function deleteNodes($parentNode)
{
$cli = eZCLI::instance();
try
{
/* @type $nodeArray eZContentObjectTreeNode[] */
$nodeArray = $parentNode->subTree();
foreach ($nodeArray as $node)
{
$cli->output(
"Deleting node " . $node->attribute('main_node_id') . ' , "' . $node->attribute('url_alias') . "'\n"
);
//delete node
$objectID = $node->attribute('contentobject_id');
$node->remove();
$object =& eZContentObject::fetch($objectID);
$object->purge();
}
}
catch (Exception $e)
{
$cli->output($e->getMessage());
}
}
示例7: subTreeByEmail
function subTreeByEmail($email)
{
$users = eZContentObjectTreeNode::subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => array('subscription_user'), 'AttributeFilter' => array(array('subscription_user/email', '=', $email)), 'Limitation' => array()), JAJSubscriptionUser::subscriptionUsersNodeID());
return $users;
}
示例8: array
// Get list of users the newsletter allready has been delivered to
$rows = eZPersistentObject::fetchObjectList(JAJDelivery::definition(), array('subscription_user_id'), array('newsletter_issue_id' => $object->ID), array('subscription_user_id' => 'asc'), null, false);
// Extract user_ids
$delivered = array();
foreach ($rows as $row) {
array_push($delivered, $row['subscription_user_id']);
}
// Status for users we should send newsletter to
$valid_status = array(JAJ_USER_STATUS_PENDING, JAJ_USER_STATUS_CONFIRMED, JAJ_USER_STATUS_APPROVED);
$limit = 50;
$offset = 0;
// Loop through users, 50 at a time to avoid excessive memory usage
$recipient_count = 0;
while (true) {
//$users =& eZContentObjectTreeNode::subTreeByNodeID(
$users =& eZContentObjectTreeNode::subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => array('subscription_user'), 'AttributeFilter' => array(array('subscription_user/status', 'in', $valid_status)), 'ExtendedAttributeFilter' => array(id => 'eorfilter', params => array(array('subscription_user/subscriptions', $distributionLists, 'or'))), 'Limit' => $limit, 'Offset' => $offset, 'LoadDataMap' => false), $subscriptionUsersNode);
foreach ($users as $user) {
if (in_array($user->ContentObjectID, $delivered)) {
continue;
}
$row = array('newsletter_issue_id' => $object->ID, 'subscription_user_id' => $user->ContentObjectID);
$delivery = new JAJDelivery($row);
$delivery->store();
$recipient_count++;
}
eZContentObject::clearCache();
if (count($users) < $limit) {
break;
} else {
$offset += $limit;
}
示例9: trim
eZContentObject::clearCache();
}
$row[0] = trim($row[0]);
$row[1] = trim($row[1]);
if (!in_array($index, $rowSelection)) {
continue;
}
if (strlen($row[0]) == 0) {
$warnings[] = "Row " . ($index + 1) . " skipped, missing name";
continue;
}
if (!eZMail::validate($row[1])) {
$warnings[] = "Row " . ($index + 1) . " skipped, invalid email: '" . htmlspecialchars($row[1]) . "'";
continue;
}
$users =& eZContentObjectTreeNode::subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => array('subscription_user'), 'AttributeFilter' => array(array('subscription_user/email', '=', $row[1]))), $subscriptionUsersNode);
if (count($users) > 1) {
$warnings[] = "Row " . ($index + 1) . " skipped, found multiple subscribers with email: '" . htmlspecialchars($row[1]) . "'";
continue;
}
if (count($users) == 1) {
$user = $users[0];
$userObject = $user->object();
$userDataMap = $userObject->DataMap();
$userStatus = $userDataMap['status']->toString();
if (!in_array($userStatus, array('Approved', 'Confirmed', 'Pending'))) {
$warnings[] = "Row " . ($index + 1) . " skipped, subscriber exists with invalid status." . " Email: '" . htmlspecialchars($row[1]) . "'";
continue;
}
if ($userDataMap['subscriptions']->toString()) {
$userSubscriptions = explode("-", $userDataMap['subscriptions']->toString());