Skip to content

4.1.1 Customization: COLLECTIONs HEADER #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ collections.grid.ContainerCollections = function(config) {

window.history.replaceState({}, '', window.location.href);

if(MODx.config.mostra_cs_testata == true)
{
this.getTestataCollection(config);
}

this.initBreadCrumbs(config);

if (collections.template.allowDD) {
Expand Down Expand Up @@ -1177,7 +1182,50 @@ Ext.extend(collections.grid.ContainerCollections,MODx.grid.Grid,{
});
this.getTopToolbar().add(this.bc);
}

,getTestataCollection: function(config) {

var collection = parseInt(MODx.request.id);

MODx.Ajax.request({
url: MODx.config.connector_url
,params: {
action: 'Collections\\Processors\\Extra\\Testata'
,collection: collection
,selection: 0
}
,listeners: {
success: {
fn: function(r) {
this.printTestataCollection(r);
},scope: this
},
failure: {
fn: function(){
this.store.removeAll();
this.currentFolder = collections.template.parent;
this.getStore().baseParams.parent = collections.template.parent;
this.getBottomToolbar().changePage(1);
},
scope: this
}
}
});


}
,printTestataCollection: function(r) {
this.testata = ({
items : [{
html: '<div class="titoloTestataCS">'+r.results[1]+'</div>'+
'<div class="menuTestataCS">'+r.results[0]+'</div>'
,bodyCssClass: 'contentTestataCS'
,anchor: '100%'
}]
});
this.getTopToolbar().insert(1,this.testata);
}

,setPaginationState: function(start, limit) {
var query = Ext.urlDecode(location.search.replace('?', ''));
var folder = query.folder || collections.template.parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,38 @@ Ext.extend(collections.grid.ContainerSelection,collections.grid.ContainerCollect
}
}
}


,getTestataCollection: function(config) {

var collection = parseInt(MODx.request.id);

MODx.Ajax.request({
url: MODx.config.connector_url
,params: {
action: 'Collections\\Processors\\Extra\\Testata'
,collection: collection
,selection: 1
}
,listeners: {
success: {
fn: function(r) {
this.printTestataCollection(r);
},scope: this
},
failure: {
fn: function(){
this.store.removeAll();
this.currentFolder = collections.template.parent;
this.getStore().baseParams.parent = collections.template.parent;
this.getBottomToolbar().changePage(1);
},
scope: this
}
}
});


}
,getDragDropText: function(){
if (this.config.baseParams.sort != 'menuindex') {
if (this.store.sortInfo == undefined || this.store.sortInfo.field != 'menuindex') {
Expand Down
2 changes: 2 additions & 0 deletions core/components/collections/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
$_lang['setting_collections.tree_tbar_collection_desc'] = 'Show "New Collection" button in Tree tool bar';
$_lang['setting_collections.tree_tbar_selection'] = 'Tree Tool Bar - Selection';
$_lang['setting_collections.tree_tbar_selection_desc'] = 'Show "New Selection" button in Tree tool bar';
$_lang['setting_collections.mostra_cs_testata'] = 'Show Header for Collection/Selection';
$_lang['setting_collections.mostra_cs_testata_desc'] = 'Decide if you want to show Header for Collection/Selection';


// System lexicons
Expand Down
64 changes: 64 additions & 0 deletions core/components/collections/src/Processors/Extra/Testata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
namespace Collections\Processors\Extra;

use MODX\Revolution\modResource;
use MODX\Revolution\Processors\Processor;

class Testata extends Processor
{
public function process()
{
$collection = (int)$this->getProperty('collection', 0);
$selection = (int)$this->getProperty('selection', 0);

if ($collection <= 0) {
return $this->failure();
}
$resource = $this->modx->getObject(modResource::class, $collection);
if (!$resource) {
return $this->failure();
}

//Discrimino a seconda che sia selezione oppure no per icona
$resource->published?$classPub ='pubblicata':$classPub ='ritirata';
if($selection)
{
$icona ='<i class="icon selectioncontainer"></i>';
}else{
$icona ='<i class="icon collectioncontainer"></i>';
}

//Contesto
$contextKey = $resource->context_key;
$context = $this->modx->getContext( $contextKey );
$contextName = $context->name;

//Prima creo menu
//Prima parte del menu il contesto con la sua icona
$menu = '<span class="eleMenu contesto"><i class="icon tree-context"></i>'.$contextName.'</span>';

$pids = $this->modx->getParentIds($collection, 10, array('context' => $contextKey));
$gids = array_reverse($pids);
foreach($gids as $gid)
{
if($gid == 0){continue;}

$genit = $this->modx->getObject(modResource::class, $gid);
if (!$genit){continue;}
$genit->published?$classPubGen ='pubblicata':$classPubGen ='ritirata';
$genit->hidemenu?$classMenuGen ='nomenu':$classMenuGen ='simenu';
$menu .= '<span class="eleMenu '.$classPubGen.' '.$classMenuGen.'">'.$genit->pagetitle.'</span>';
}
//Ultimo elemento del menu la sua icona
$menu .= '<span class="ultimo '.$classPub.'">'.$icona.'</span>';

$RisAjax [] = $menu;

//Adesso nome a cui aggiungo icona
$nome = $icona;
$nome .= $resource->pagetitle;
$RisAjax [] = $nome;

return $this->outputArray($RisAjax);
}
}