comanage-dev - [comanage-dev] r433 - in registry/trunk/app: Controller Lib Model View/Standard
Subject: COmanage Developers List
List archive
[comanage-dev] r433 - in registry/trunk/app: Controller Lib Model View/Standard
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r433 - in registry/trunk/app: Controller Lib Model View/Standard
- Date: Thu, 31 Jan 2013 23:34:07 -0500
Author: benno
Date: 2013-01-31 23:34:07 -0500 (Thu, 31 Jan 2013)
New Revision: 433
Modified:
registry/trunk/app/Controller/CoPersonRolesController.php
registry/trunk/app/Controller/CoPetitionsController.php
registry/trunk/app/Controller/StandardController.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/CoIdentifierAssignment.php
registry/trunk/app/View/Standard/add.ctp
registry/trunk/app/View/Standard/edit.ctp
registry/trunk/app/View/Standard/view.ctp
Log:
Refactor page title generation (CO-538)
Modified: registry/trunk/app/Controller/CoPersonRolesController.php
===================================================================
--- registry/trunk/app/Controller/CoPersonRolesController.php 2013-01-30
03:37:24 UTC (rev 432)
+++ registry/trunk/app/Controller/CoPersonRolesController.php 2013-02-01
04:34:07 UTC (rev 433)
@@ -58,8 +58,7 @@
*/
function add() {
- if(!$this->restful && $this->request->is('get'))
- {
+ if(!$this->restful && $this->request->is('get')) {
// Create a stub person role. It's unclear that title should
// autopopulate, and if it need not it's further unclear that we
// really need to set this variable.
@@ -72,6 +71,10 @@
}
parent::add();
+
+ // Append the person's name to the page title
+ $this->set('title_for_layout',
+ $this->viewVars['title_for_layout'] . " (" .
generateCn($this->viewVars['co_people'][0]['Name']) . ")");
}
/**
Modified: registry/trunk/app/Controller/CoPetitionsController.php
===================================================================
--- registry/trunk/app/Controller/CoPetitionsController.php 2013-01-30
03:37:24 UTC (rev 432)
+++ registry/trunk/app/Controller/CoPetitionsController.php 2013-02-01
04:34:07 UTC (rev 433)
@@ -245,6 +245,15 @@
}
parent::beforeRender();
+
+ // Possibly override the title
+
+ if($this->action == 'view' || $this->action == 'edit') {
+ $this->set('title_for_layout',
+ _txt('op.' . $this->action . '-f',
+ array(_txt('ct.co_petitions.1'),
+
generateCn($this->viewVars['co_petitions'][0]['EnrolleeCoPerson']['Name']))));
+ }
}
/**
Modified: registry/trunk/app/Controller/StandardController.php
===================================================================
--- registry/trunk/app/Controller/StandardController.php 2013-01-30
03:37:24 UTC (rev 432)
+++ registry/trunk/app/Controller/StandardController.php 2013-02-01
04:34:07 UTC (rev 433)
@@ -88,7 +88,7 @@
$atomic = true;
}
- if($model->saveAll($data,array('atomic' => $atomic))) {
+ if($model->saveAll($data, array('atomic' => $atomic))) {
if(!$this->recordHistory('add', $data)
|| !$this->checkWriteFollowups($data)) {
if(!$this->restful) {
@@ -299,12 +299,6 @@
if(isset($this->edit_recursion))
$model->recursive = $this->edit_recursion;
- if(!$this->restful)
- {
- // Set page title
- $this->set('title_for_layout', _txt('op.edit-a', array(_txt('ct.' .
$modelpl . '.1'))));
- }
-
// Make sure $id exists
$curdata = $model->read();
@@ -322,6 +316,30 @@
return;
}
+ if(!$this->restful) {
+ // Set page title -- note we do similar logic in view()
+
+ $t = _txt('ct.' . $modelpl . '.1');
+
+ if(!empty($curdata['Name'])) {
+ $t = generateCn($curdata['Name']);
+ } elseif(!empty($curdata[$req][ $model->displayField ])) {
+ $t = $curdata[$req][ $model->displayField ];
+ }
+
+ if($this->requires_person) {
+ if(!empty($curdata[$req]['co_person_id'])) {
+ $t .= " (" . _txt('ct.co_people.1') . ")";
+ } elseif(!empty($curdata[$req]['co_person_role_id'])) {
+ $t .= " (" . _txt('ct.co_person_roles.1') . ")";
+ } elseif(!empty($curdata[$req]['org_identity_id'])) {
+ $t .= " (" . _txt('ct.org_identities.1') . ")";
+ }
+ }
+
+ $this->set('title_for_layout', _txt('op.edit-a', array($t)));
+ }
+
if($this->restful)
{
// Validate
@@ -812,32 +830,43 @@
$obj = $model->read();
}
- if(empty($obj))
- {
- if($this->restful)
+ if(empty($obj)) {
+ if($this->restful) {
$this->restResultHeader(404, $req . " Unknown");
- else
- {
+ } else {
$this->Session->setFlash(_txt('er.notfound', array(_txt('ct.' .
$modelpl . '.1'), $id)), '', array(), 'error');
$this->performRedirect();
}
- }
- else
- {
- if($this->restful)
- {
+ } else {
+ if($this->restful) {
$this->set($modelpl, $this->convertResponse(array(0 => $obj)));
$this->restResultHeader(200, "OK");
- }
- else
- {
- // Set page title
- $this->set('title_for_layout', _txt('op.view-a', array(_txt('ct.' .
$modelpl . '.1'))));
+ } else {
+ // Set page title -- note we do similar logic in edit()
+ $t = _txt('ct.' . $modelpl . '.1');
+
+ if(!empty($obj['Name'])) {
+ $t = generateCn($obj['Name']);
+ } elseif(!empty($obj[$req][ $model->displayField ])) {
+ $t = $obj[$req][ $model->displayField ];
+ }
+
+ if($this->requires_person) {
+ if(!empty($obj[$req]['co_person_id'])) {
+ $t .= " (" . _txt('ct.co_people.1') . ")";
+ } elseif(!empty($obj[$req]['co_person_role_id'])) {
+ $t .= " (" . _txt('ct.co_person_roles.1') . ")";
+ } elseif(!empty($obj[$req]['org_identity_id'])) {
+ $t .= " (" . _txt('ct.org_identities.1') . ")";
+ }
+ }
+
+ $this->set('title_for_layout', _txt('op.view-a', array($t)));
+
$this->set($modelpl, array(0 => $obj));
-
- if($this->requires_person)
- {
+
+ if($this->requires_person) {
// We need to call checkPersonID to set a redirect path.
$this->checkPersonID("set", $obj);
Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-01-30 03:37:24 UTC (rev 432)
+++ registry/trunk/app/Lib/lang.php 2013-02-01 04:34:07 UTC (rev 433)
@@ -529,7 +529,7 @@
'op.deny' => 'Deny',
'op.edit' => 'Edit',
'op.edit.ea' => 'Edit Enrollment Attributes',
- 'op.edit-a' => 'Edit "%1$s"',
+ 'op.edit-a' => 'Edit %1$s',
'op.edit-f' => 'Edit %1$s for %2$s',
'op.enroll' => 'Enroll',
'op.find.inv' => 'Find a Person to Invite to %1$s',
@@ -558,7 +558,8 @@
'op.unlink' => 'Unlink',
'op.unlink.confirm' => 'Are you sure you wish to unlink this identity?',
'op.view' => 'View',
- 'op.view-a' => 'View "%1$s"',
+ 'op.view-a' => 'View %1$s',
+ 'op.view-f' => 'View %1$s for %2$s',
// Results
'rs.added' => 'Added',
Modified: registry/trunk/app/Model/CoIdentifierAssignment.php
===================================================================
--- registry/trunk/app/Model/CoIdentifierAssignment.php 2013-01-30 03:37:24
UTC (rev 432)
+++ registry/trunk/app/Model/CoIdentifierAssignment.php 2013-02-01 04:34:07
UTC (rev 433)
@@ -38,7 +38,7 @@
public $hasMany = array("CoSequentialIdentifierAssignment");
// Default display field for cake generated views
- public $displayField = "identifier_type";
+ public $displayField = "description";
// Validation rules for table elements
public $validate = array(
Modified: registry/trunk/app/View/Standard/add.ctp
===================================================================
--- registry/trunk/app/View/Standard/add.ctp 2013-01-30 03:37:24 UTC (rev
432)
+++ registry/trunk/app/View/Standard/add.ctp 2013-02-01 04:34:07 UTC (rev
433)
@@ -2,7 +2,7 @@
/**
* COmanage Registry Standard Add View
*
- * Copyright (C) 2010-12 University Corporation for Advanced Internet
Development, Inc.
+ * Copyright (C) 2010-13 University Corporation for Advanced Internet
Development, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* KIND, either express or implied. See the License for the specific
language governing
* permissions and limitations under the License.
*
- * @copyright Copyright (C) 2011-12 University Corporation for Advanced
Internet Development, Inc.
+ * @copyright Copyright (C) 2010-13 University Corporation for Advanced
Internet Development, Inc.
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v0.1
@@ -25,30 +25,11 @@
// Get a pointer to our model
$model = $this->name;
$req = Inflector::singularize($model);
- $modelpl = Inflector::tableize($req);
// Since this is an add operation, we may not have any data.
// (Currently, only controllers like CoPersonRole prepopulate fields for
rendering.)
-
- // Figure out a heading
- $h = _txt('op.add.new', array(_txt('ct.'.$modelpl.'.1')));
- if(isset($$modelpl)) {
- // Get a pointer to our data
- $d = $$modelpl;
-
- if(isset($d[0]['Name']))
- $h .= " (" . Sanitize::html(generateCn($d[0]['Name'])) . ")";
- elseif(isset($d[0]['CoPerson']['Name']))
- $h .= " (" . Sanitize::html(generateCn($d[0]['CoPerson']['Name'])) .
")";
- elseif(isset($d[0]['OrgIdentity']['Name']))
- $h .= " (" . Sanitize::html(generateCn($d[0]['OrgIdentity']['Name']))
. ")";
- // CO Person Role rendering gets some info from co_people
- elseif(isset($co_people[0]['Name']))
- $h .= " (" . Sanitize::html(generateCn($co_people[0]['Name'])) . ")";
- }
-
- $params = array('title' => $h);
+ $params = array('title' => $title_for_layout);
print $this->element("pageTitle", $params);
$submit_label = _txt('op.add');
Modified: registry/trunk/app/View/Standard/edit.ctp
===================================================================
--- registry/trunk/app/View/Standard/edit.ctp 2013-01-30 03:37:24 UTC (rev
432)
+++ registry/trunk/app/View/Standard/edit.ctp 2013-02-01 04:34:07 UTC (rev
433)
@@ -2,7 +2,7 @@
/**
* COmanage Registry Standard Edit View
*
- * Copyright (C) 2010-12 University Corporation for Advanced Internet
Development, Inc.
+ * Copyright (C) 2010-13 University Corporation for Advanced Internet
Development, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* KIND, either express or implied. See the License for the specific
language governing
* permissions and limitations under the License.
*
- * @copyright Copyright (C) 2011-12 University Corporation for Advanced
Internet Development, Inc.
+ * @copyright Copyright (C) 2010-13 University Corporation for Advanced
Internet Development, Inc.
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v0.1
@@ -25,36 +25,8 @@
// Get a pointer to our model
$model = $this->name;
$req = Inflector::singularize($model);
- $modelpl = Inflector::tableize($req);
-
- // Get a pointer to our data
- $d = $$modelpl;
- // Figure out a heading
- // XXX this should probably get moved into the controllers (duped in
view.ctp)
- $h = "";
-
- if(isset($d[0]['Name']))
- $h = _txt('op.edit-a', array(Sanitize::html(generateCn($d[0]['Name']))));
- elseif(isset($d[0]['CoPerson']['Name']))
- $h = _txt('op.edit-a',
array(Sanitize::html(generateCn($d[0]['CoPerson']['Name'])))) . " (" .
_txt('co') . ")";
- elseif(isset($d[0]['OrgIdentity']['Name']))
- $h = _txt('op.edit-a',
array(Sanitize::html(generateCn($d[0]['OrgIdentity']['Name'])))) . " (" .
_txt('org') . ")";
- // CO Person Role rendering gets some info from co_people
- elseif(isset($co_people[0]['Name']))
- $h = _txt('op.edit-a',
array(Sanitize::html(generateCn($co_people[0]['Name']))));
- elseif(isset($d[0][$req]['line1']))
- $h = _txt('op.edit-a', array(Sanitize::html($d[0][$req]['line1'])));
- elseif(isset($d[0][$req]['label']))
- $h = _txt('op.edit-a', array(Sanitize::html($d[0][$req]['label'])));
- elseif(isset($d[0][$req]['name']))
- $h = _txt('op.edit-a', array(Sanitize::html($d[0][$req]['name'])));
- elseif(isset($d[0][$req]['description']))
- $h = _txt('op.edit-a',
array(Sanitize::html($d[0][$req]['description'])));
- else
- $h = _txt('op.edit');
-
- $params = array('title' => $h);
+ $params = array('title' => $title_for_layout);
print $this->element("pageTitle", $params);
$submit_label = _txt('op.save');
Modified: registry/trunk/app/View/Standard/view.ctp
===================================================================
--- registry/trunk/app/View/Standard/view.ctp 2013-01-30 03:37:24 UTC (rev
432)
+++ registry/trunk/app/View/Standard/view.ctp 2013-02-01 04:34:07 UTC (rev
433)
@@ -29,35 +29,8 @@
// Get a pointer to our data
$d = $$modelpl;
-
- // Figure out a heading
- $h = "";
- // XXX This should probably get refactored into the models (duped in
edit.ctp)
- if(isset($d[0]['Name']))
- $h = _txt('op.view-a', array(Sanitize::html(generateCn($d[0]['Name']))));
- elseif(isset($d[0]['CoPerson']['Name']))
- $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['CoPerson']['Name'])))) . " (" .
_txt('co') . ")";
- elseif(isset($d[0]['OrgIdentity']['Name']))
- $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['OrgIdentity']['Name'])))) . " (" .
_txt('org') . ")";
- // For CO Petitions
- elseif(isset($d[0]['EnrolleeCoPerson']['Name']))
- $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['EnrolleeCoPerson']['Name'])))) . " ("
. _txt('co') . ")";
- // CO Person Role rendering gets some info from co_people
- elseif(isset($co_people[0]['Name']))
- $h = _txt('op.view-a',
array(Sanitize::html(generateCn($co_people[0]['Name']))));
- elseif(isset($d[0][$req]['line1']))
- $h = _txt('op.view-a', array(Sanitize::html($d[0][$req]['line1'])));
- elseif(isset($d[0][$req]['label']))
- $h = _txt('op.view-a', array(Sanitize::html($d[0][$req]['label'])));
- elseif(isset($d[0][$req]['name']))
- $h = _txt('op.view-a', array(Sanitize::html($d[0][$req]['name'])));
- elseif(isset($d[0][$req]['description']))
- $h = _txt('op.view-a',
array(Sanitize::html($d[0][$req]['description'])));
- else
- $h = _txt('op.view');
-
- $params = array('title' => $h);
+ $params = array('title' => $title_for_layout);
print $this->element("pageTitle", $params);
print '<div style="float:left">';
- [comanage-dev] r433 - in registry/trunk/app: Controller Lib Model View/Standard, svnlog, 01/31/2013
Archive powered by MHonArc 2.6.16.