Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wax100 committed Mar 5, 2021
1 parent 46f84f2 commit ba9f2fc
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 0 deletions.
34 changes: 34 additions & 0 deletions core/src/Revolution/modResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -1584,4 +1584,38 @@ public function clearCache($context = '')
$this->xpdo->invokeEvent('OnResourceCacheUpdate', ['id' => $this->get('id')]);
}
}

/**
* Returns array with all neighborhood resources
*
* @return array $arr Array with neighborhood from left and right
*/
public function getNeighborhood()
{
$arr = array();

$q = $this->xpdo->newQuery('modResource', array('parent' => $this->parent));
$q->sortby('menuindex', 'ASC');
$q->select('id');
if ($q->prepare() && $q->stmt->execute()) {
$ids = $q->stmt->fetchAll(PDO::FETCH_COLUMN);
$current = array_search($this->id, $ids);

$right = $left = array();
foreach ($ids as $k => $v) {
if ($k > $current) {
$right[] = $v;
} elseif ($k < $current) {
$left[] = $v;
}
}

$arr = array(
'left' => array_reverse($left),
'right' => $right,
);
}

return $arr;
}
}
45 changes: 45 additions & 0 deletions manager/assets/modext/sections/resource/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ Ext.extend(MODx.page.UpdateResource,MODx.Component,{
,scope: this
});

btns.push(this.getAdditionalButtons(config));

btns.push({
process: 'Resource/Update'
,text: _('save') + ' <i class="icon icon-check"></i>'
Expand All @@ -242,5 +244,48 @@ Ext.extend(MODx.page.UpdateResource,MODx.Component,{

return btns;
}

,getAdditionalButtons: function (config) {
return [{
text: '<i class="icon icon-arrow-left"></i>',
handler: this.prevPage,
disabled: !config['prev_page'],
scope: this,
tooltip: _('prev_page'),
keys: [{key: 37, alt: true, scope: this, fn: this.prevPage}]
}, {
text: '<i class="icon icon-arrow-up"></i>',
handler: this.upPage,
scope: this,
disabled: !config['up_page'],
tooltip: _('up_page'),
keys: [{key: 38, alt: true, scope: this, fn: this.upPage}]
}, {
text: '<i class="icon icon-arrow-right"></i>',
handler: this.nextPage,
disabled: !config['next_page'],
scope: this,
tooltip: _('next_page'),
keys: [{key: 39, alt: true, scope: this, fn: this.nextPage}]
}];
}

,prevPage: function () {
if (this.config['prev_page'] > 0) {
MODx.loadPage('resource/update', 'id=' + this.config['prev_page'])
}
}

,nextPage: function () {
if (this.config['next_page'] > 0) {
MODx.loadPage('resource/update', 'id=' + this.config['next_page'])
}
}

,upPage: function () {
if (this.config['up_page'] > 0) {
MODx.loadPage('resource/update', 'id=' + this.config['up_page'])
}
}
});
Ext.reg('modx-page-resource-update',MODx.page.UpdateResource);
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function loadCustomCssJs()
$this->addJavascript($mgrUrl . 'assets/modext/widgets/resource/modx.panel.resource.static.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/update.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/static/update.js');
$neighborhood = $this->resource->getNeighborhood();
$data = [
'xtype' => 'modx-page-static-update',
'resource' => $this->resource->get('id'),
Expand All @@ -44,6 +45,13 @@ public function loadCustomCssJs()
'canCreate' => (int)$this->modx->hasPermission('new_document'),
'canDelete' => (int)$this->modx->hasPermission('delete_document'),
'show_tvs' => (int)!empty($this->tvCounts),
'next_page' => !empty($neighborhood['right'][0])
? $neighborhood['right'][0]
: 0,
'prev_page' => !empty($neighborhood['left'][0])
? $neighborhood['left'][0]
: 0,
'up_page' => $this->resource->parent
];
$this->addHtml('<script>
MODx.config.publish_document = "' . $this->canPublish . '";
Expand Down
8 changes: 8 additions & 0 deletions manager/controllers/default/resource/symlink/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function loadCustomCssJs()
$this->addJavascript($mgrUrl . 'assets/modext/widgets/resource/modx.panel.resource.symlink.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/update.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/symlink/update.js');
$neighborhood = $this->resource->getNeighborhood();
$data = [
'xtype' => 'modx-page-symlink-update',
'resource' => $this->resource->get('id'),
Expand All @@ -44,6 +45,13 @@ public function loadCustomCssJs()
'canDuplicate' => (int)$this->canDuplicate,
'canDelete' => (int)$this->canDelete,
'show_tvs' => (int)!empty($this->tvCounts),
'next_page' => !empty($neighborhood['right'][0])
? $neighborhood['right'][0]
: 0,
'prev_page' => !empty($neighborhood['left'][0])
? $neighborhood['left'][0]
: 0,
'up_page' => $this->resource->parent
];
$this->addHtml('<script>
MODx.config.publish_document = "' . $this->canPublish . '";
Expand Down
8 changes: 8 additions & 0 deletions manager/controllers/default/resource/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function loadCustomCssJs()
$this->addJavascript($mgrUrl . 'assets/modext/widgets/resource/modx.panel.resource.tv.js');
$this->addJavascript($mgrUrl . 'assets/modext/widgets/resource/modx.panel.resource.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/update.js');
$neighborhood = $this->resource->getNeighborhood();
$data = [
'xtype' => 'modx-page-resource-update',
'resource' => $this->resource->get('id'),
Expand All @@ -61,6 +62,13 @@ public function loadCustomCssJs()
'canDelete' => (int)$this->canDelete,
'show_tvs' => (int)!empty($this->tvCounts),
'mode' => 'update',
'next_page' => !empty($neighborhood['right'][0])
? $neighborhood['right'][0]
: 0,
'prev_page' => !empty($neighborhood['left'][0])
? $neighborhood['left'][0]
: 0,
'up_page' => $this->resource->parent
];
$this->addHtml('<script>
MODx.config.publish_document = "' . $this->canPublish . '";
Expand Down
8 changes: 8 additions & 0 deletions manager/controllers/default/resource/weblink/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function loadCustomCssJs()
$this->addJavascript($mgrUrl . 'assets/modext/widgets/resource/modx.panel.resource.weblink.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/update.js');
$this->addJavascript($mgrUrl . 'assets/modext/sections/resource/weblink/update.js');
$neighborhood = $this->resource->getNeighborhood();
$data = [
'xtype' => 'modx-page-weblink-update',
'resource' => $this->resource->get('id'),
Expand All @@ -44,6 +45,13 @@ public function loadCustomCssJs()
'canDuplicate' => (int)$this->canDuplicate,
'canDelete' => (int)$this->canDelete,
'show_tvs' => (int)!empty($this->tvCounts),
'next_page' => !empty($neighborhood['right'][0])
? $neighborhood['right'][0]
: 0,
'prev_page' => !empty($neighborhood['left'][0])
? $neighborhood['left'][0]
: 0,
'up_page' => $this->resource->parent
];
$this->addHtml('<script>
MODx.config.publish_document = "' . $this->canPublish . '";
Expand Down

0 comments on commit ba9f2fc

Please sign in to comment.