Skip to content

Commit

Permalink
set modules per theme, if the module does not have a theme it will sh…
Browse files Browse the repository at this point in the history
…ow in all themes
  • Loading branch information
dogmatic69 committed Jan 22, 2010
1 parent 0388248 commit b5dff82
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions extensions/libs/views/helpers/infinitas.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function loadModules($position = null){
$currentRoute = Router::currentRoute();

foreach($modules as $module){
if ($module['Theme']['name'] != '' && $module['Theme']['name'] != $this->theme) {
//skip modules that are not for the current theme
continue;
}

$moduleOut = '<div class="module '.$module['Module']['module'].'">';
if ($module['Module']['show_heading']) {
$moduleOut .= '<h2>'.__($module['Module']['name'],true).'</h2>';
Expand Down
6 changes: 4 additions & 2 deletions infinitas/management/controllers/modules_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function admin_add() {
$positions = $this->Module->Position->find('list');
$groups = $this->Module->Group->find('list');
$routes = array(0 => __('All Pages', true)) + $this->Module->Route->find('list');
$this->set(compact('positions', 'groups', 'routes'));
$themes = array(0 => __('All Themes', true)) + $this->Module->Theme->find('list');
$this->set(compact('positions', 'groups', 'routes', 'themes'));
}

function admin_edit($id = null) {
Expand All @@ -52,7 +53,8 @@ function admin_edit($id = null) {
$positions = $this->Module->Position->find('list');
$groups = $this->Module->Group->find('list');
$routes = array(0 => __('All Pages', true)) + $this->Module->Route->find('list');
$this->set(compact('positions', 'groups', 'routes'));
$themes = array(0 => __('All Themes', true)) + $this->Module->Theme->find('list');
$this->set(compact('positions', 'groups', 'routes', 'themes'));
}
}
?>
12 changes: 11 additions & 1 deletion infinitas/management/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class Module extends ManagementAppModel{
'className' => 'Management.ModulePosition',
'foreignKey' => 'position_id'
),
'Management.Group'
'Management.Group',
'Theme' => array(
'className' => 'Management.Theme',
'foreignKey' => 'theme_id'
),
);

var $hasAndBelongsToMany = array(
Expand Down Expand Up @@ -75,6 +79,12 @@ function getModules($position = null){
'Route.name',
'Route.url'
)
),
'Theme' => array(
'fields' => array(
'Theme.id',
'Theme.name'
)
)
)
)
Expand Down
1 change: 1 addition & 0 deletions infinitas/management/views/modules/admin_add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<?php
echo $this->Form->input( 'name' );
echo $this->Form->input( 'module' );
echo $this->Form->input( 'theme_id' );
echo $this->Form->input( 'position_id' );
echo $this->Form->input( 'group_id' );
echo $this->Form->input( 'active' );
Expand Down
1 change: 1 addition & 0 deletions infinitas/management/views/modules/admin_edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
echo $this->Form->input( 'id' );
echo $this->Form->input( 'name' );
echo $this->Form->input( 'module' );
echo $this->Form->input( 'theme_id' );
echo $this->Form->input( 'position_id' );
echo $this->Form->input( 'group_id' );
echo $this->Form->input( 'active' );
Expand Down
16 changes: 14 additions & 2 deletions infinitas/management/views/modules/admin_index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
'style' => 'width:25px;'
),
$this->Paginator->sort( 'name' ),
$this->Paginator->sort( 'Position', 'Position.Name' ),
$this->Paginator->sort( 'Theme', 'Theme.name' ),
$this->Paginator->sort( 'Position', 'Position.name' ),
$this->Paginator->sort( 'author' ),
$this->Paginator->sort( 'licence' ) => array(
'style' => 'width:75px;'
),
$this->Paginator->sort( 'Group', 'Group.Name' ) => array(
$this->Paginator->sort( 'Group', 'Group.name' ) => array(
'style' => 'width:75px;'
),
$this->Paginator->sort( 'Locked', true ) => array(
Expand All @@ -74,6 +75,17 @@
<td>
<?php echo $this->Html->link( Inflector::humanize($module['Module']['name']), array('action' => 'edit', $module['Module']['id'])); ?>&nbsp;
</td>
<td>
<?php
if (!empty($module['Theme']['name'])) {
echo $module['Theme']['name'];
}
else
{
echo __('All');
}
?>&nbsp;
</td>
<td>
<?php echo $module['Position']['name']; ?>&nbsp;
</td>
Expand Down

0 comments on commit b5dff82

Please sign in to comment.