本文整理汇总了PHP中eZContentObjectTreeNode::updateAndStoreModified方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::updateAndStoreModified方法的具体用法?PHP eZContentObjectTreeNode::updateAndStoreModified怎么用?PHP eZContentObjectTreeNode::updateAndStoreModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::updateAndStoreModified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unhideSubTree
/**
* Unhide a subtree
*
* Unhide algorithm:
* if ( parent node is visible )
* {
* 1) Mark root node as not hidden and visible.
* 2) Recursively mark child nodes as visible (except for nodes previosly marked as hidden, and all their children).
* }
* else
* {
* Mark root node as not hidden.
* }
*
* Transaction unsafe. If you call several transaction unsafe methods you must enclose
* the calls within a db transaction; thus within db->begin and db->commit.
*
* @param eZContentObjectTreeNode $node Root node of the subtree
* @param bool $modifyRootNode Whether to modify the root node (true/false)
*/
static function unhideSubTree(eZContentObjectTreeNode $node, $modifyRootNode = true)
{
$nodeID = $node->attribute('node_id');
$nodePath = $node->attribute('path_string');
$nodeInvisible = $node->attribute('is_invisible');
$parentNode = $node->attribute('parent');
if (!$parentNode instanceof eZContentObjectTreeNode) {
eZDebug::writeError("Parent of Node #{$nodeID} doesn't exist or inaccesible.", __METHOD__);
return;
}
$time = time();
if (eZAudit::isAuditEnabled()) {
// Set audit params.
$objectID = $node->attribute('contentobject_id');
$objectName = $node->attribute('name');
eZAudit::writeAudit('content-hide', array('Node ID' => $nodeID, 'Object ID' => $objectID, 'Content Name' => $objectName, 'Time' => $time, 'Comment' => 'Node has been unhidden: eZContentObjectTreeNode::unhideSubTree()'));
}
$db = eZDB::instance();
$db->begin();
if (!$parentNode->attribute('is_invisible')) {
// 1) Mark root node as not hidden and visible.
if ($modifyRootNode) {
$db->query("UPDATE ezcontentobject_tree SET is_invisible=0, is_hidden=0, modified_subnode={$time} WHERE node_id={$nodeID}");
}
// 2) Recursively mark child nodes as visible (except for nodes previosly marked as hidden, and all their children).
// 2.1) $hiddenChildren = Fetch all hidden children for the root node
$hiddenChildren = $db->arrayQuery("SELECT path_string FROM ezcontentobject_tree " . "WHERE node_id <> {$nodeID} AND is_hidden=1 AND path_string LIKE '{$nodePath}%'");
$skipSubtreesString = '';
foreach ($hiddenChildren as $i) {
$skipSubtreesString .= " AND path_string NOT LIKE '" . $i['path_string'] . "%'";
}
// 2.2) Mark those children as visible which are not under nodes in $hiddenChildren
$db->query("UPDATE ezcontentobject_tree SET is_invisible=0, modified_subnode={$time} WHERE path_string LIKE '{$nodePath}%' {$skipSubtreesString}");
} else {
// Mark root node as not hidden.
if ($modifyRootNode) {
$db->query("UPDATE ezcontentobject_tree SET is_hidden=0, modified_subnode={$time} WHERE node_id={$nodeID}");
}
}
$node->updateAndStoreModified();
$db->commit();
eZContentObjectTreeNode::clearViewCacheForSubtree($node, $modifyRootNode);
}
示例2: unhideSubTree
static function unhideSubTree(eZContentObjectTreeNode $node, $modifyRootNode = true)
{
$nodeID = $node->attribute('node_id');
$nodePath = $node->attribute('path_string');
$nodeInvisible = $node->attribute('is_invisible');
$parentNode = $node->attribute('parent');
$time = time();
$db = eZDB::instance();
$db->begin();
if (!$parentNode->attribute('is_invisible')) {
// 1) Mark root node as not hidden and visible.
if ($modifyRootNode) {
$db->query("UPDATE ezcontentobject_tree SET is_invisible=0, is_hidden=0, modified_subnode={$time} WHERE node_id={$nodeID}");
}
// 2) Recursively mark child nodes as visible (except for nodes previosly marked as hidden, and all their children).
// 2.1) $hiddenChildren = Fetch all hidden children for the root node
$hiddenChildren = $db->arrayQuery("SELECT path_string FROM ezcontentobject_tree " . "WHERE node_id <> {$nodeID} AND is_hidden=1 AND path_string LIKE '{$nodePath}%'");
$skipSubtreesString = '';
foreach ($hiddenChildren as $i) {
$skipSubtreesString .= " AND path_string NOT LIKE '" . $i['path_string'] . "%'";
}
// 2.2) Mark those children as visible which are not under nodes in $hiddenChildren
$db->query("UPDATE ezcontentobject_tree SET is_invisible=0, modified_subnode={$time} WHERE path_string LIKE '{$nodePath}%' {$skipSubtreesString}");
} else {
// Mark root node as not hidden.
if ($modifyRootNode) {
$db->query("UPDATE ezcontentobject_tree SET is_hidden=0, modified_subnode={$time} WHERE node_id={$nodeID}");
}
}
$node->updateAndStoreModified();
$db->commit();
eZContentObjectTreeNode::clearViewCacheForSubtree($node, $modifyRootNode);
}