Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r583 - in registry/trunk/app: Config/Schema Controller Lib Model View/Addresses View/CoEnrollmentAttributes View/CoPeople View/OrgIdentities

Subject: COmanage Developers List

List archive

[comanage-dev] r583 - in registry/trunk/app: Config/Schema Controller Lib Model View/Addresses View/CoEnrollmentAttributes View/CoPeople View/OrgIdentities


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r583 - in registry/trunk/app: Config/Schema Controller Lib Model View/Addresses View/CoEnrollmentAttributes View/CoPeople View/OrgIdentities
  • Date: Thu, 5 Sep 2013 17:29:00 -0400

Author: benno
Date: 2013-09-05 17:29:00 -0400 (Thu, 05 Sep 2013)
New Revision: 583

Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Controller/StandardController.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Lib/util.php
registry/trunk/app/Model/Address.php
registry/trunk/app/Model/AppModel.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/Model/Name.php
registry/trunk/app/View/Addresses/fields.inc
registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
registry/trunk/app/View/CoPeople/fields.inc
registry/trunk/app/View/OrgIdentities/fields.inc
Log:
Add language to Name and Address (CO-115)

Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2013-08-31 11:37:18 UTC (rev
582)
+++ registry/trunk/app/Config/Schema/schema.xml 2013-09-05 21:29:00 UTC (rev
583)
@@ -198,6 +198,7 @@
<field name="family" type="C" size="128" />
<field name="suffix" type="C" size="32" />
<field name="type" type="C" size="2" />
+ <field name="language" type="C" size="16" />
<field name="co_person_id" type="I">
<constraint>REFERENCES cm_co_people(id)</constraint>
</field>
@@ -331,6 +332,7 @@
<field name="postal_code" type="C" size="16" />
<field name="country" type="C" size="128" />
<field name="type" type="C" size="2" />
+ <field name="language" type="C" size="16" />
<field name="co_person_role_id" type="I">
<constraint>REFERENCES cm_co_person_roles(id)</constraint>
</field>
@@ -581,6 +583,7 @@
<field name="required" type="I" />
<field name="ordr" type="I" />
<field name="copy_to_coperson" type="L" />
+ <field name="language" type="C" size="16" />
<field name="created" type="T" />
<field name="modified" type="T" />


Modified: registry/trunk/app/Controller/StandardController.php
===================================================================
--- registry/trunk/app/Controller/StandardController.php 2013-08-31
11:37:18 UTC (rev 582)
+++ registry/trunk/app/Controller/StandardController.php 2013-09-05
21:29:00 UTC (rev 583)
@@ -412,7 +412,7 @@
$atomic = false;
}
}
-
+
if($model->saveAll($data, array('atomic' => $atomic)))
{
if(!$this->recordHistory('edit', $data, $curdata)

Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-08-31 11:37:18 UTC (rev 582)
+++ registry/trunk/app/Lib/lang.php 2013-09-05 21:29:00 UTC (rev 583)
@@ -215,6 +215,53 @@
IdentifierEnum::Mail => 'Mail',
IdentifierEnum::OpenID => 'OpenID',
IdentifierEnum::UID => 'UID'),
+
+ // As a moderately arbitrary decision, the languages listed here those
with at least
+ // 100m speakers per Ethnologue (by way of wikipedia)
+ //
http://en.wikipedia.org/wiki/List_of_languages_by_total_number_of_speakers
+ // as well as any official languages of REFEDS participants not in the
above list
+ // https://refeds.org/resources_list.html
+ // The key is the ISO 639-2 two letter tag
+ // http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
+ // See also http://people.w3.org/rishida/names/languages.html
+ // and
http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
+ 'en.language' => array(
+ 'af' => 'Afrikaans',
+ 'ar' => 'Arabic (العربية)',
+ 'bn' => 'Bengali',
+ 'zh-Hans' => 'Chinese - Simplified (简体中文)',
+ 'zh-Hant' => 'Chinese - Traditional (繁體中文)',
+ 'hr' => 'Croatian (Hrvatski)',
+ 'cs' => 'Czech (čeština)',
+ 'da' => 'Danish (Dansk)',
+ 'nl' => 'Dutch (Nederlands) / Flemish',
+ 'en' => 'English',
+ 'et' => 'Estonian (Eesti Keel)',
+ 'fi' => 'Finnish (Suomi)',
+ 'fr' => 'French (Français)',
+ 'de' => 'German (Deutsch)',
+ 'el' => 'Greek (ελληνικά)',
+ 'he' => 'Hebrew (עִבְרִית)',
+ 'hi' => 'Hindi (हिंदी)',
+ 'hu' => 'Hungarian (Magyar)',
+ 'id' => 'Indonesian (Bahasa Indonesia)',
+ 'it' => 'Italian (Italiano)',
+ 'ja' => 'Japanese (日本語)',
+ 'lv' => 'Latvian (Latviešu Valoda)',
+ 'lt' => 'Lithuanian (Lietuvių Kalba)',
+ 'ms' => 'Malaysian (Bahasa Malaysia)',
+ 'no' => 'Norwegian (Norsk)',
+ 'pl' => 'Polish (Język Polski)',
+ 'pt' => 'Portuguese (Português)',
+ 'ro' => 'Romanian (Limba Română)',
+ 'ru' => 'Russian (Pyccĸий)',
+ 'sr' => 'Serbian (српски / Srpski)',
+ 'sl' => 'Slovene (Slovenski Jezik)',
+ 'es' => 'Spanish (Español)',
+ 'sv' => 'Swedish (Svenska)',
+ 'tr' => 'Turkish (Türkçe)',
+ 'ur' => 'Urdu (اُردُو)'
+ ),

'en.name' => array(NameEnum::Author => 'Author',
NameEnum::FKA => 'FKA',
@@ -383,6 +430,7 @@
'fd.address' => 'Address',
// The next set must be named fd.model.validation-field
'fd.address.country' => 'Country',
+ 'fd.address.language' => 'Language',
'fd.address.line1' => 'Address Line 1',
'fd.address.line2' => 'Address Line 2',
'fd.address.locality' => 'City',
@@ -515,6 +563,7 @@
'fd.index' => 'Index',
'fd.inv.for' => 'Invitation for %1$s',
'fd.inv.to' => 'Invitation to %1$s',
+ 'fd.language' => 'Language',
'fd.lan.desc' => 'Lowercase alphanumeric characters only',
'fd.link.location' => 'Link Location',
'fd.link.order' => 'Link Order',
@@ -529,10 +578,11 @@
'fd.name.s.desc' => '(Jr, III, etc)',
// The next set must be named fd.model.validation-field
'fd.name.honorific' => 'Honorific',
- 'fd.name.given' => 'Given Name',
+ 'fd.name.given' => 'Given Name',
'fd.name.middle' => 'Middle Name',
'fd.name.family' => 'Family Name',
'fd.name.suffix' => 'Suffix',
+ 'fd.name.language' => 'Language',
'fd.no' => 'No',
'fd.null' => 'Null',
'fd.o' => 'Organization',
@@ -566,7 +616,7 @@
'fd.valid_through' => 'Valid Through',
'fd.valid_through.desc' => '(leave blank for indefinite validity)',
'fd.yes' => 'Yes',
-
+
// Menu
'me.account' => 'My Account',
'me.changepassword' => 'Change Password',

Modified: registry/trunk/app/Lib/util.php
===================================================================
--- registry/trunk/app/Lib/util.php 2013-08-31 11:37:18 UTC (rev 582)
+++ registry/trunk/app/Lib/util.php 2013-09-05 21:29:00 UTC (rev 583)
@@ -92,6 +92,55 @@
}

/**
+ * Obtain the preferred language requested by the browser, if supported.
+ *
+ * @since COmanage Registry v0.8.2
+ * @return string Language code, or an empty string
+ */
+
+function getPreferredLanguage() {
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
+
+ if($lang == 'zh') {
+ // For the Chinese scripts, determine traditional vs simplified.
+ // First map old style notation to new style.
+
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5);
+
+ if($lang == 'zh-CN') {
+ return 'zh-Hans';
+ }
+ if($lang == 'zh-TW') {
+ return 'zh-Hant';
+ }
+
+ // Still here? Maybe it's new style.
+
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 7);
+
+ if($lang == 'zh-Hans' || $lang == 'zh-Hant') {
+ return $lang;
+ }
+
+ // Else we don't know what to do with this Chinese variant. Go with
simplified.
+
+ return 'zh-Hans';
+ }
+
+ // See if this is a defined language.
+
+ global $cm_lang, $cm_texts;
+
+ if(isset($cm_texts[ $cm_lang ]['en.lang'][ $lang ])) {
+ return $lang;
+ }
+
+ // We don't recognize this language
+
+ return "";
+}
+
+/**
* Escape a string so it is suitable for echoing into Javascript function
parameters.
* Specifically, quotes are replaced with XML representations.
*

Modified: registry/trunk/app/Model/Address.php
===================================================================
--- registry/trunk/app/Model/Address.php 2013-08-31 11:37:18 UTC (rev
582)
+++ registry/trunk/app/Model/Address.php 2013-09-05 21:29:00 UTC (rev
583)
@@ -86,6 +86,11 @@
'required' => false,
'allowEmpty' => true
),
+ 'language' => array(
+ 'rule' => array('validateLanguage'),
+ 'required' => false,
+ 'allowEmpty' => true
+ ),
'co_person_role_id' => array(
'rule' => 'numeric',
'required' => false

Modified: registry/trunk/app/Model/AppModel.php
===================================================================
--- registry/trunk/app/Model/AppModel.php 2013-08-31 11:37:18 UTC (rev
582)
+++ registry/trunk/app/Model/AppModel.php 2013-09-05 21:29:00 UTC (rev
583)
@@ -286,7 +286,7 @@
* @return boolean True if all field strings parses to a valid timestamp,
false otherwise
*/

- function validateExtendedType($a, $d) {
+ public function validateExtendedType($a, $d) {
// First obtain active extended types, if any.

$extTypes = array();
@@ -328,6 +328,27 @@
}

/**
+ * Determine if a string represents a defined/supported language. This
function
+ * is intended to be used as a validation rule.
+ *
+ * @since COmanage Registry v0.8.2
+ * @param array Array of fields to validate
+ * @return boolean True if all field strings parses to a valid timestamp,
false otherwise
+ */
+
+ public function validateLanguage($a) {
+ global $cm_lang, $cm_texts;
+
+ foreach(array_keys($a) as $f) {
+ if(!isset($cm_texts[ $cm_lang ]['en.language'][ $a[$f] ])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Determine if a string represents a valid timestamp. This function is
intended
* to be used as a validation rule.
*
@@ -336,7 +357,7 @@
* @return boolean True if all field strings parses to a valid timestamp,
false otherwise
*/

- function validateTimestamp($a) {
+ public function validateTimestamp($a) {
// Note we are assuming the >= PHP 5.1 behavior of strtotime here, which
is
// reasonable since we require >= PHP 5.2.


Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-08-31 11:37:18
UTC (rev 582)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-09-05 21:29:00
UTC (rev 583)
@@ -74,6 +74,11 @@
),
'copy_to_coperson' => array(
'rule' => 'boolean'
+ ),
+ 'language' => array(
+ 'rule' => array('validateLanguage'),
+ 'required' => false,
+ 'allowEmpty' => true
)
);

@@ -454,13 +459,23 @@
&&
!$attrModel->validate[$k]['allowEmpty']);

- // We hide type, status, and verified
- $attr['hidden'] = ($k == 'type' || $k == 'status' || $k ==
'verified' ? 1 : 0);
+ // We hide language, type, status, and verified
+ $attr['hidden'] = ($k == 'language'
+ || $k == 'type'
+ || $k == 'status'
+ || $k == 'verified' ? 1 : 0);

if($attr['hidden']) {
// Populate a default value.

switch($k) {
+ case 'language':
+ if(!empty($efAttr['CoEnrollmentAttribute']['language'])) {
+ $attr['default'] =
$efAttr['CoEnrollmentAttribute']['language'];
+ } else {
+ $attr['default'] = "";
+ }
+ break;
case 'type':
// Just use $attrType
$attr['default'] = $attrType;
@@ -478,7 +493,6 @@
} else {
// Label
$attr['group'] = $efAttr['CoEnrollmentAttribute']['label'];
-
$attr['label'] = _txt('fd.' . $attrName . '.' . $k);

// Description

Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2013-08-31 11:37:18 UTC (rev
582)
+++ registry/trunk/app/Model/CoPetition.php 2013-09-05 21:29:00 UTC (rev
583)
@@ -1376,7 +1376,7 @@
* @param Array Request data, as submitted to createPetition()
* @param Array Data assembled so far for saving (Validated data will be
added to this array)
* @param Array Enrollment Flow attributes, as returned by
CoEnrollmentAttribute::enrollmentFlowAttributes()
- * @param Array Array of updated validated data, or null on validation
error
+ * @return Array Array of updated validated data, or null on validation
error
*/

private function validateRelated($primaryModel, $requestData,
$validatedData, $efAttrs) {

Modified: registry/trunk/app/Model/Name.php
===================================================================
--- registry/trunk/app/Model/Name.php 2013-08-31 11:37:18 UTC (rev 582)
+++ registry/trunk/app/Model/Name.php 2013-09-05 21:29:00 UTC (rev 583)
@@ -85,6 +85,11 @@
'required' => false,
'allowEmpty' => true
),
+ 'language' => array(
+ 'rule' => array('validateLanguage'),
+ 'required' => false,
+ 'allowEmpty' => true
+ ),
'co_person_id' => array(
'rule' => 'numeric',
'required' => false,

Modified: registry/trunk/app/View/Addresses/fields.inc
===================================================================
--- registry/trunk/app/View/Addresses/fields.inc 2013-08-31 11:37:18
UTC (rev 582)
+++ registry/trunk/app/View/Addresses/fields.inc 2013-09-05 21:29:00
UTC (rev 583)
@@ -2,7 +2,7 @@
/**
* COmanage Registry Address Fields
*
- * 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) 2011-13 University Corporation for Advanced
Internet Development, Inc.
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v0.1
@@ -103,7 +103,7 @@
<td>
<?php
global $cm_lang, $cm_texts;
- $attrs['value'] = (isset($addresses) ?
$addresses[0]['Address']['type'] : "O");
+ $attrs['value'] = (isset($addresses[0]['Address']['type']) ?
$addresses[0]['Address']['type'] : "O");
$attrs['empty'] = false;

if($e) {
@@ -120,6 +120,34 @@
?>
</td>
</tr>
+ <tr class="line2">
+ <td>
+ <?php print _txt('fd.language'); ?>
+ </td>
+ <td>
+ <?php
+ global $cm_lang, $cm_texts;
+
+ $attrs = array();
+ $attrs['value'] = (isset($addresses[0]['Address']['language'])
+ ? $addresses[0]['Address']['language']
+ : getPreferredLanguage());
+ $attrs['empty'] = true;
+
+ if($e) {
+ print $this->Form->select('language',
+ $cm_texts[ $cm_lang ]['en.language'],
+ $attrs);
+
+ if($this->Form->isFieldError('language')) {
+ print $this->Form->error('language');
+ }
+ } else {
+ print _txt('en.language', null,
$addresses[0]['Address']['type']);
+ }
+ ?>
+ </td>
+ </tr>
<tr>
<td>
<i><font class="required"><?php echo _txt('fd.req');
?></font></i><br />

Modified: registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
===================================================================
--- registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-08-31
11:37:18 UTC (rev 582)
+++ registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-09-05
21:29:00 UTC (rev 583)
@@ -25,6 +25,7 @@
<script type="text/javascript">
function js_local_onload() {
toggle_attr_def_div();
+ toggle_attr_type_div();
toggle_copy_to_coperson_div();
}

@@ -134,6 +135,20 @@
}
}

+ function toggle_attr_type_div() {
+ var curattr =
document.getElementById('CoEnrollmentAttributeAttribute').value;
+
+ var curattrarr = curattr.split(":");
+ var curattrcode = curattrarr[0];
+ var curattrname = curattrarr[1];
+
+ if(curattrname == "address" || curattrname == "name") {
+ $("#type_div").show("fade");
+ } else {
+ $("#type_div").hide("fade");
+ }
+ }
+
function toggle_copy_to_coperson_div() {
var curattr =
document.getElementById('CoEnrollmentAttributeAttribute').value;
var attrtype = curattr[0];
@@ -201,7 +216,7 @@
?
$co_enrollment_attributes[0]['CoEnrollmentAttribute']['attribute']
: null);
$attrs['empty'] = false;
- $attrs['onchange'] =
"toggle_attr_def_div();toggle_copy_to_coperson_div();";
+ $attrs['onchange'] =
"toggle_attr_def_div();toggle_copy_to_coperson_div();toggle_attr_type_div();";

if($e) {
print $this->Form->select('attribute',
@@ -215,6 +230,25 @@
print
Sanitize::html($co_enrollment_attributes[0]['CoEnrollmentAttribute']['attribute']);
}
?>
+ <div id="type_div" style="display: none">
+ <?php
+ global $cm_lang, $cm_texts;
+
+ $attrs = array();
+ $attrs['value'] =
(isset($co_enrollment_attributes[0]['CoEnrollmentAttribute']['language'])
+ ?
$co_enrollment_attributes[0]['CoEnrollmentAttribute']['language']
+ : getPreferredLanguage());
+ $attrs['empty'] = true;
+
+ print $this->Form->select('language',
+ $cm_texts[ $cm_lang ]['en.language'],
+ $attrs);
+
+ if($this->Form->isFieldError('language')) {
+ print $this->Form->error('language');
+ }
+ ?>
+ </div>
<div id="copy_to_coperson_div" style="display: none">
<?php print ($e
? $this->Form->input('copy_to_coperson',

Modified: registry/trunk/app/View/CoPeople/fields.inc
===================================================================
--- registry/trunk/app/View/CoPeople/fields.inc 2013-08-31 11:37:18 UTC (rev
582)
+++ registry/trunk/app/View/CoPeople/fields.inc 2013-09-05 21:29:00 UTC (rev
583)
@@ -326,6 +326,34 @@
</td>
<?php endif; ?>
</tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th>
+ <?php print _txt('fd.language'); ?>
+ </th>
+ <td>
+ <?php
+ global $cm_lang, $cm_texts;
+
+ $attrs = array();
+ $attrs['value'] = (isset($co_people[0]['Name']['language'])
+ ? $co_people[0]['Name']['language']
+ : getPreferredLanguage());
+ $attrs['empty'] = true;
+
+ if($e) {
+ print $this->Form->select('Name.language',
+ $cm_texts[ $cm_lang
]['en.language'],
+ $attrs);
+
+ if($this->Form->isFieldError('Name.language')) {
+ print $this->Form->error('Name.language');
+ }
+ } else {
+ print _txt('en.language', null,
$co_people[0]['Name']['language']);
+ }
+ ?>
+ </td>
+ </tr>
<tr>
<th>
<i><font class="required"><?php print _txt('fd.req');
?></font></i><br />

Modified: registry/trunk/app/View/OrgIdentities/fields.inc
===================================================================
--- registry/trunk/app/View/OrgIdentities/fields.inc 2013-08-31 11:37:18
UTC (rev 582)
+++ registry/trunk/app/View/OrgIdentities/fields.inc 2013-09-05 21:29:00
UTC (rev 583)
@@ -195,6 +195,34 @@
</tr>
<tr class="line2">
<td>
+ <?php print _txt('fd.language'); ?>
+ </td>
+ <td>
+ <?php
+ global $cm_lang, $cm_texts;
+
+ $attrs = array();
+ $attrs['value'] =
(isset($org_identities[0]['Name']['language'])
+ ? $org_identities[0]['Name']['language']
+ : getPreferredLanguage());
+ $attrs['empty'] = true;
+
+ if($e) {
+ print $this->Form->select('Name.language',
+ $cm_texts[ $cm_lang
]['en.language'],
+ $attrs);
+
+ if($this->Form->isFieldError('Name.language')) {
+ print $this->Form->error('Name.language');
+ }
+ } else {
+ print _txt('en.language', null,
$org_identities[0]['Name']['language']);
+ }
+ ?>
+ </td>
+ </tr>
+ <tr class="line1">
+ <td>
<?php echo _txt('fd.affiliation'); ?><font
class="required">*</font>
</td>
<td>
@@ -221,7 +249,7 @@
?>
</td>
</tr>
- <tr class="line1">
+ <tr class="line2">
<td>
<?php echo _txt('fd.title'); ?>
</td>
@@ -229,7 +257,7 @@
<?php echo ($e ? $this->Form->input('title') :
Sanitize::html($org_identities[0]['OrgIdentity']['title'])); ?>
</td>
</tr>
- <tr class="line2">
+ <tr class="line1">
<td>
<?php echo _txt('fd.o'); ?>
</td>
@@ -237,7 +265,7 @@
<?php echo ($e ? $this->Form->input('o') :
Sanitize::html($org_identities[0]['OrgIdentity']['o'])); ?>
</td>
</tr>
- <tr class="line1">
+ <tr class="line2">
<td>
<?php echo _txt('fd.ou'); ?>
</td>



  • [comanage-dev] r583 - in registry/trunk/app: Config/Schema Controller Lib Model View/Addresses View/CoEnrollmentAttributes View/CoPeople View/OrgIdentities, svnlog, 09/05/2013

Archive powered by MHonArc 2.6.16.

Top of Page