Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
BlockPluginsListbuilderHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.listbuilder.MultipleListsListbuilderHandler');
17 
23  parent::MultipleListsListbuilderHandler();
24  $this->addRoleAssignment(
25  ROLE_ID_MANAGER,
26  array('fetch')
27  );
28  }
29 
33  function authorize($request, &$args, $roleAssignments) {
34  import('lib.pkp.classes.security.authorization.PkpContextAccessPolicy');
35  $this->addPolicy(new PkpContextAccessPolicy($request, $roleAssignments));
36  return parent::authorize($request, $args, $roleAssignments);
37  }
38 
42  function initialize($request) {
43  parent::initialize($request);
44  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_MANAGER);
45 
46  // Basic configuration
47  $this->setTitle('manager.setup.layout.blockManagement');
48  $this->setSaveFieldName('blocks');
49 
50  // Name column
51  $nameColumn = new ListbuilderGridColumn($this, 'name', 'common.name');
52 
53  // Add lists.
54  $this->addList(new ListbuilderList('leftContext', 'manager.setup.layout.leftSidebar'));
55  $this->addList(new ListbuilderList('unselected', 'manager.setup.layout.unselected'));
56  $this->addList(new ListbuilderList('rightContext', 'manager.setup.layout.rightSidebar'));
57 
58  import('lib.pkp.controllers.listbuilder.settings.BlockPluginsListbuilderGridCellProvider');
59  $nameColumn->setCellProvider(new BlockPluginsListbuilderGridCellProvider());
60  $this->addColumn($nameColumn);
61  }
62 
63 
64  //
65  // Overridden template methods
66  //
70  function setListsData($request, $filter) {
71  $leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
72  $plugins =& PluginRegistry::loadCategory('blocks');
73  foreach ($plugins as $key => $junk) {
74  if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
75  if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) $disabledBlockPlugins[$key] =& $plugins[$key];
76  } else switch ($plugins[$key]->getBlockContext()) {
77  case BLOCK_CONTEXT_LEFT_SIDEBAR:
78  $leftBlockPlugins[$key] =& $plugins[$key];
79  break;
80  case BLOCK_CONTEXT_RIGHT_SIDEBAR:
81  $rightBlockPlugins[$key] =& $plugins[$key];
82  break;
83  }
84  }
85 
86  $lists =& $this->getLists();
87  $lists['leftContext']->setData($leftBlockPlugins);
88  $lists['rightContext']->setData($rightBlockPlugins);
89  $lists['unselected']->setData($disabledBlockPlugins);
90  }
91 }
92 
93 ?>
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
addColumn($column)
static & loadCategory($category, $enabledOnly=false, $mainContextId=null)
Class to control access to PKP applications&#39; setup components.
addRoleAssignment($roleIds, $operations)
Class for block plugins administration.
Base class for a listbuilder list. This is used by MultipleListsListbuilderHandler to implement multi...
Represents a column within a listbuilder.
authorize($request, &$args, $roleAssignments)
Class defining basic operations for handling multiple lists listbuilder UI elements.