Skip to content

Commit

Permalink
Breadcrumbs refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pHAlkaline committed Aug 25, 2020
1 parent 1bc9e26 commit 3892699
Show file tree
Hide file tree
Showing 33 changed files with 727 additions and 803 deletions.
53 changes: 26 additions & 27 deletions app/Controller/AccountsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
*
* pHKondo : pHKondo software for condominium property managers (http://phalkaline.eu)
Expand All @@ -25,7 +26,6 @@
* @license http://opensource.org/licenses/GPL-2.0 GNU General Public License, version 2 (GPL-2.0)
*
*/

App::uses('AppController', 'Controller');

/**
Expand All @@ -51,18 +51,17 @@ class AccountsController extends AppController {
public function index() {
$options['conditions'] = array('Account.condo_id' => $this->getPhkRequestVar('condo_id'));
//$options['order'] = null;


if (isset($this->Paginator->settings['conditions'])) {
$options['conditions'] = array_replace_recursive($this->Paginator->settings['conditions'], $options['conditions']);
}
$this->Paginator->settings = array_replace_recursive($this->Paginator->settings , array(


$this->Paginator->settings = array_replace_recursive($this->Paginator->settings, array(
'conditions' => $options['conditions']));
$this->setFilter(array('Account.title', 'Account.bank', 'Account.balcony'));
$this->set('accounts', $this->Paginator->paginate('Account'));

}

/**
Expand All @@ -75,9 +74,9 @@ public function index() {
public function view($id = null) {
if (!$this->Account->exists($id)) {
$this->Flash->error(__('Invalid account'));
$this->redirect(array('action' => 'index','?'=>$this->request->query));
$this->redirect(array('action' => 'index', '?' => $this->request->query));
}
$options = array('conditions' => array('Account.id'=> $id));
$options = array('conditions' => array('Account.id' => $id));
$account = $this->Account->find('first', $options);
$this->set(compact('account'));
$this->setPhkRequestVar('account_id', $id);
Expand All @@ -94,7 +93,7 @@ public function add() {
$this->Account->create();
if ($this->Account->save($this->request->data)) {
$this->Flash->success(__('The account has been saved'));
$this->redirect(array('action' => 'view', $this->Account->id,'?'=>$this->request->query));
$this->redirect(array('action' => 'view', $this->Account->id, '?' => $this->request->query));
} else {
$this->Flash->error(__('The account could not be saved. Please, try again.'));
}
Expand All @@ -113,12 +112,12 @@ public function add() {
public function edit($id = null) {
if (!$this->Account->exists($id)) {
$this->Flash->error(__('Invalid account'));
$this->redirect(array('action' => 'index','?'=>$this->request->query));
$this->redirect(array('action' => 'index', '?' => $this->request->query));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Account->save($this->request->data)) {
$this->Flash->success(__('The account has been saved'));
$this->redirect(array('action' => 'view', $id, '?'=>$this->request->query));
$this->redirect(array('action' => 'view', $id, '?' => $this->request->query));
} else {
$this->Flash->error(__('The account could not be saved. Please, try again.'));
}
Expand Down Expand Up @@ -147,16 +146,16 @@ public function delete($id = null) {
$this->Account->id = $id;
if (!$this->Account->exists()) {
$this->Flash->error(__('Invalid account'));
$this->redirect(array('action' => 'index','?'=>$this->request->query));
$this->redirect(array('action' => 'index', '?' => $this->request->query));
}

if ($this->Account->delete()) {
$this->Flash->success(__('Account deleted'));
$this->redirect(array('action' => 'index','?'=>$this->request->query));
$this->redirect(array('action' => 'index', '?' => $this->request->query));
}

$this->Flash->error(__('Account can not be deleted'));
$this->redirect(array('action' => 'view', $id,'?'=>$this->request->query));
$this->redirect(array('action' => 'view', $id, '?' => $this->request->query));
}

public function beforeFilter() {
Expand All @@ -170,23 +169,23 @@ public function beforeFilter() {
public function beforeRender() {
parent::beforeRender();
$breadcrumbs = array(
array('link' => Router::url(array('controller' => 'pages', 'action' => 'home'),true), 'text' => __('Home'), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'index'),true), 'text' => __n('Condo','Condos',2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id')),true), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''),
array('link' => '', 'text' => __n('Account','Accounts',2), 'active' => 'active')
//array('link' => Router::url(array('controller' => 'pages', 'action' => 'home'),true), 'text' => __('Home'), 'active' => ''),
//array('link' => Router::url(array('controller' => 'condos', 'action' => 'index'),true), 'text' => __n('Condo','Condos',2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text') . ' ( ' . $this->phkRequestData['fiscal_year_text'] . ' ) ', 'active' => ''),
array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index', '?' => $this->request->query), true), 'text' => __n('Account', 'Accounts', 2), 'active' => 'active')
);
switch ($this->action) {
case 'view':
$breadcrumbs[3] = array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index','?'=>$this->request->query),true), 'text' => __n('Account','Accounts',2), 'active' => '');
$breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('account_text'), 'active' => 'active');
$breadcrumbs[1] = array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index', '?' => $this->request->query), true), 'text' => __n('Account', 'Accounts', 2), 'active' => '');
$breadcrumbs[2] = array('link' => '', 'text' => $this->getPhkRequestVar('account_text'), 'active' => 'active');
break;
case 'edit':
$breadcrumbs[3] = array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index','?'=>$this->request->query),true), 'text' => __n('Account','Accounts',2), 'active' => '');
$breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('account_text'), 'active' => 'active');
$breadcrumbs[1] = array('link' => Router::url(array('controller' => 'accounts', 'action' => 'index', '?' => $this->request->query), true), 'text' => __n('Account', 'Accounts', 2), 'active' => '');
$breadcrumbs[2] = array('link' => '', 'text' => $this->getPhkRequestVar('account_text'), 'active' => 'active');
break;
}
$headerTitle=__n('Account','Accounts',2);
$this->set(compact('breadcrumbs','headerTitle'));
$headerTitle = __n('Account', 'Accounts', 2);
$this->set(compact('breadcrumbs', 'headerTitle'));
}

}
16 changes: 8 additions & 8 deletions app/Controller/AdministratorsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ public function beforeFilter() {
public function beforeRender() {
parent::beforeRender();
$breadcrumbs = array(
array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view',$this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''),
array('link' => '', 'text' => __n('Administrator','Administrators',2), 'active' => 'active')
//array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
//array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view',$this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text').' ( '.$this->phkRequestData['fiscal_year_text'].' ) ', 'active' => ''),
array('link' => Router::url(array('controller' => 'administrators', 'action' => 'index', '?' => $this->request->query), true), 'text' => __n('Administrator','Administrators',2), 'active' => 'active')
);
switch ($this->action) {
case 'view':
$breadcrumbs[3] = array('link' => Router::url(array('controller' => 'administrators', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Administrator','Administrators',2), 'active' => '');
$breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('administrator_text'), 'active' => 'active');
$breadcrumbs[1] = array('link' => Router::url(array('controller' => 'administrators', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Administrator','Administrators',2), 'active' => '');
$breadcrumbs[2] = array('link' => '', 'text' => $this->getPhkRequestVar('administrator_text'), 'active' => 'active');
break;
case 'edit':
$breadcrumbs[3] = array('link' => Router::url(array('controller' => 'administrators', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Administrator','Administrators',2), 'active' => '');
$breadcrumbs[4] = array('link' => '', 'text' => $this->getPhkRequestVar('administrator_text'), 'active' => 'active');
$breadcrumbs[1] = array('link' => Router::url(array('controller' => 'administrators', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Administrator','Administrators',2), 'active' => '');
$breadcrumbs[2] = array('link' => '', 'text' => $this->getPhkRequestVar('administrator_text'), 'active' => 'active');
break;
}
$headerTitle=__n('Administrator','Administrators',2);
Expand Down
34 changes: 17 additions & 17 deletions app/Controller/AttachmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class AttachmentsController extends AppController {
*/
public function index() {
$breadcrumbs = array(
array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''),
array('link' => '', 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
//array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
//array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text') . ' ( ' . $this->phkRequestData['fiscal_year_text'] . ' ) ', 'active' => ''),
array('link' => Router::url(array('controller' => 'attachments', 'action' => 'index', '?' => $this->request->query), true), 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
);


Expand All @@ -67,32 +67,32 @@ public function index() {
*/
public function fraction_attachments() {
$breadcrumbs = array(
array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''),
array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''),
//array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
//array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text') . ' ( ' . $this->phkRequestData['fiscal_year_text'] . ' ) ', 'active' => ''),
array('link' => Router::url(array('controller' => 'fractions', 'action' => 'index', '?' => $this->request->query)), 'text' => __n('Fraction', 'Fractions', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'fractions', 'action' => 'view', $this->getPhkRequestVar('fraction_id'))), 'text' => $this->getPhkRequestVar('fraction_text'), 'active' => ''),
array('link' => '', 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
array('link' => Router::url(array('controller' => 'attachments', 'action' => 'fraction_attachments', '?' => $this->request->query), true), 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
);


$this->set(compact('breadcrumbs'));
$this->render('notfound');
}

/**
* ensurance_attachments method
*
* @return void
*/
public function insurance_attachments() {
$breadcrumbs = array(
array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text'), 'active' => ''),
array('link' => Router::url(array('controller' => 'insurances', 'action' => 'index','?'=>$this->request->query)), 'text' => __n('Insurance', 'Insurances', 2), 'active' => ''),
//array('link' => Router::url(array('controller' => 'pages', 'action' => 'home')), 'text' => __('Home'), 'active' => ''),
//array('link' => Router::url(array('controller' => 'condos', 'action' => 'index')), 'text' => __n('Condo', 'Condos', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'condos', 'action' => 'view', $this->getPhkRequestVar('condo_id'))), 'text' => $this->getPhkRequestVar('condo_text') . ' ( ' . $this->phkRequestData['fiscal_year_text'] . ' ) ', 'active' => ''),
array('link' => Router::url(array('controller' => 'insurances', 'action' => 'index', '?' => $this->request->query)), 'text' => __n('Insurance', 'Insurances', 2), 'active' => ''),
array('link' => Router::url(array('controller' => 'insurances', 'action' => 'view', $this->getPhkRequestVar('insurance_id'))), 'text' => $this->getPhkRequestVar('insurance_text'), 'active' => ''),
array('link' => '', 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
array('link' => Router::url(array('controller' => 'attachments', 'action' => 'insurance_attachments', '?' => $this->request->query), true), 'text' => __n('Attachment', 'Attachments', 2), 'active' => 'active')
);


Expand All @@ -104,13 +104,13 @@ public function beforeFilter() {
parent::beforeFilter();
if (!$this->getPhkRequestVar('condo_id')) {
$this->Flash->error(__('Invalid condo'));
$this->redirect(array('controller'=>'condos','action' => 'index'));
$this->redirect(array('controller' => 'condos', 'action' => 'index'));
}
}

public function beforeRender() {
parent::beforeRender();
$headerTitle=__n('Attachment', 'Attachments', 2);
$headerTitle = __n('Attachment', 'Attachments', 2);
$this->set(compact('headerTitle'));
}

Expand Down
Loading

0 comments on commit 3892699

Please sign in to comment.