本文整理汇总了PHP中modResource::getLock方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::getLock方法的具体用法?PHP modResource::getLock怎么用?PHP modResource::getLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::getLock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareResourceNode
//.........这里部分代码省略.........
$class[] = $this->permissions['resource_quick_create'];
}
}
if (!empty($this->permissions['resource_quick_update'])) {
$class[] = $this->permissions['resource_quick_update'];
}
if (!empty($this->permissions['delete_document'])) {
$class[] = $this->permissions['delete_document'];
}
if (!empty($this->permissions['undelete_document'])) {
$class[] = $this->permissions['undelete_document'];
}
if (!empty($this->permissions['publish_document'])) {
$class[] = $this->permissions['publish_document'];
}
if (!empty($this->permissions['unpublish_document'])) {
$class[] = $this->permissions['unpublish_document'];
}
$active = false;
if ($this->getProperty('currentResource') == $resource->id && $this->getProperty('currentAction') == 'resource/update') {
$active = true;
}
$qtip = '';
if (!empty($qtipField) && !empty($resource->{$qtipField})) {
$qtip = '<b>' . strip_tags($resource->{$qtipField}) . '</b>';
} else {
if ($resource->longtitle != '') {
$qtip = '<b>' . strip_tags($resource->longtitle) . '</b><br />';
}
if ($resource->description != '') {
$qtip = '<i>' . strip_tags($resource->description) . '</i>';
}
}
// Check for an icon class on the resource template
$tplIcon = $resource->Template ? $resource->Template->icon : '';
// Assign an icon class based on the class_key
$classKey = strtolower($resource->get('class_key'));
if (substr($classKey, 0, 3) == 'mod') {
$classKey = substr($classKey, 3);
}
$classKeyIcon = $this->modx->getOption('mgr_tree_icon_' . $classKey, null, 'tree-resource', true);
if (!empty($tplIcon)) {
$iconCls[] = $tplIcon;
} else {
$iconCls[] = $classKeyIcon;
}
switch ($classKey) {
case 'weblink':
$iconCls[] = $this->modx->getOption('mgr_tree_icon_weblink', null, 'tree-weblink');
break;
case 'symlink':
$iconCls[] = $this->modx->getOption('mgr_tree_icon_symlink', null, 'tree-symlink');
break;
case 'staticresource':
$iconCls[] = $this->modx->getOption('mgr_tree_icon_staticresource', null, 'tree-static-resource');
break;
}
// Icons specific with the context and resource ID for super specific tweaks
$iconCls[] = 'icon-' . $resource->get('context_key') . '-' . $resource->get('id');
$iconCls[] = 'icon-parent-' . $resource->get('context_key') . '-' . $resource->get('parent');
// Modifiers to indicate resource _state_
if ($hasChildren || $resource->isfolder) {
if (empty($tplIcon) && $classKeyIcon == 'tree-resource') {
$iconCls[] = $this->modx->getOption('mgr_tree_icon_folder', null, 'tree-folder');
}
$iconCls[] = 'parent-resource';
}
// Add icon class - and additional description to the tooltip - if the resource is locked.
$locked = $resource->getLock();
if ($locked && $locked != $this->modx->user->get('id')) {
$iconCls[] = 'locked-resource';
/** @var modUser $lockedBy */
$lockedBy = $this->modx->getObject('modUser', $locked);
if ($lockedBy) {
$qtip .= ' - ' . $this->modx->lexicon('locked_by', array('username' => $lockedBy->get('username')));
}
}
// Add the ID to the item text if the user has the permission
$idNote = $this->modx->hasPermission('tree_show_resource_ids') ? ' <span dir="ltr">(' . $resource->id . ')</span>' : '';
// Used in the preview_url, if sessions are disabled on the resource context we add an extra url param
$sessionEnabled = '';
if ($ctxSetting = $this->modx->getObject('modContextSetting', array('context_key' => $resource->get('context_key'), 'key' => 'session_enabled'))) {
$sessionEnabled = $ctxSetting->get('value') == 0 ? array('preview' => 'true') : '';
}
$text = strip_tags($resource->get($nodeField));
if (empty($text)) {
$text = $resource->get($nodeFieldFallback);
$text = strip_tags($text);
}
$itemArray = array('text' => $text . $idNote, 'id' => $resource->context_key . '_' . $resource->id, 'pk' => $resource->id, 'cls' => implode(' ', $class), 'iconCls' => implode(' ', $iconCls), 'type' => 'modResource', 'selected' => $active, 'classKey' => $resource->class_key, 'ctx' => $resource->context_key, 'hide_children_in_tree' => $resource->hide_children_in_tree, 'qtip' => $qtip, 'preview_url' => !$resource->get('deleted') ? $this->modx->makeUrl($resource->get('id'), $resource->get('context_key'), $sessionEnabled, 'full', array('xhtml_urls' => false)) : '', 'page' => empty($noHref) ? '?a=' . (!empty($this->permissions['edit_document']) ? 'resource/update' : 'resource/data') . '&id=' . $resource->id : '', 'allowDrop' => true);
if (!$hasChildren) {
$itemArray['hasChildren'] = false;
$itemArray['children'] = array();
$itemArray['expanded'] = true;
} else {
$itemArray['hasChildren'] = true;
}
$itemArray = $resource->prepareTreeNode($itemArray);
return $itemArray;
}
示例2: prepareResourceNode
/**
* Prepare a Resource for being shown in the tree
*
* @param modResource $resource
* @return array
*/
public function prepareResourceNode(modResource $resource)
{
$qtipField = $this->getProperty('qtipField');
$nodeField = $this->getProperty('nodeField');
$noHref = $this->getProperty('noHref', false);
$hasChildren = (int) $resource->get('childrenCount') > 0 && $resource->get('hide_children_in_tree') == 0 ? true : false;
$class = array();
$class[] = 'icon-' . strtolower(str_replace('mod', '', $resource->get('class_key')));
$class[] = $resource->isfolder ? 'icon-folder' : 'x-tree-node-leaf icon-resource';
if (!$resource->get('published')) {
$class[] = 'unpublished';
}
if ($resource->get('deleted')) {
$class[] = 'deleted';
}
if ($resource->get('hidemenu')) {
$class[] = 'hidemenu';
}
if (!empty($this->permissions['save_document'])) {
$class[] = $this->permissions['save_document'];
}
if (!empty($this->permissions['view_document'])) {
$class[] = $this->permissions['view_document'];
}
if (!empty($this->permissions['edit_document'])) {
$class[] = $this->permissions['edit_document'];
}
if (!empty($this->permissions['resource_duplicate'])) {
$class[] = $this->permissions['resource_duplicate'];
}
if ($resource->allowChildrenResources) {
if (!empty($this->permissions['new_document'])) {
$class[] = $this->permissions['new_document'];
}
if (!empty($this->permissions['new_symlink'])) {
$class[] = $this->permissions['new_symlink'];
}
if (!empty($this->permissions['new_weblink'])) {
$class[] = $this->permissions['new_weblink'];
}
if (!empty($this->permissions['new_static_resource'])) {
$class[] = $this->permissions['new_static_resource'];
}
if (!empty($this->permissions['resource_quick_create'])) {
$class[] = $this->permissions['resource_quick_create'];
}
if (!empty($this->permissions['resource_quick_update'])) {
$class[] = $this->permissions['resource_quick_update'];
}
}
if (!empty($this->permissions['delete_document'])) {
$class[] = $this->permissions['delete_document'];
}
if (!empty($this->permissions['undelete_document'])) {
$class[] = $this->permissions['undelete_document'];
}
if (!empty($this->permissions['publish_document'])) {
$class[] = $this->permissions['publish_document'];
}
if (!empty($this->permissions['unpublish_document'])) {
$class[] = $this->permissions['unpublish_document'];
}
if ($hasChildren) {
$class[] = 'haschildren';
}
if ($this->getProperty('currentResource') == $resource->id && $this->getProperty('currentAction') == $this->actions['resource/update']) {
$class[] = 'active-node';
}
$qtip = '';
if (!empty($qtipField)) {
$qtip = '<b>' . strip_tags($resource->{$qtipField}) . '</b>';
} else {
if ($resource->longtitle != '') {
$qtip = '<b>' . strip_tags($resource->longtitle) . '</b><br />';
}
if ($resource->description != '') {
$qtip = '<i>' . strip_tags($resource->description) . '</i>';
}
}
$locked = $resource->getLock();
if ($locked && $locked != $this->modx->user->get('id')) {
$class[] = 'icon-locked';
/** @var modUser $lockedBy */
$lockedBy = $this->modx->getObject('modUser', $locked);
if ($lockedBy) {
$qtip .= ' - ' . $this->modx->lexicon('locked_by', array('username' => $lockedBy->get('username')));
}
}
$idNote = $this->modx->hasPermission('tree_show_resource_ids') ? ' <span dir="ltr">(' . $resource->id . ')</span>' : '';
$itemArray = array('text' => strip_tags($resource->{$nodeField}) . $idNote, 'id' => $resource->context_key . '_' . $resource->id, 'pk' => $resource->id, 'cls' => implode(' ', $class), 'type' => 'modResource', 'classKey' => $resource->class_key, 'ctx' => $resource->context_key, 'hide_children_in_tree' => $resource->hide_children_in_tree, 'qtip' => $qtip, 'preview_url' => !$resource->get('deleted') ? $this->modx->makeUrl($resource->get('id'), $resource->get('context_key'), '', 'full') : '', 'page' => empty($noHref) ? '?a=' . (!empty($this->permissions['edit_document']) ? $this->actions['resource/update'] : $this->actions['resource/data']) . '&id=' . $resource->id : '', 'allowDrop' => true);
if (!$hasChildren) {
$itemArray['hasChildren'] = false;
$itemArray['children'] = array();
$itemArray['expanded'] = true;
//.........这里部分代码省略.........