/[drupal]/contributions/modules/civicrm_localize/civicrm_localize.module
ViewVC logotype

Diff of /contributions/modules/civicrm_localize/civicrm_localize.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Oct 3 23:49:19 2007 UTC revision 1.2, Thu Oct 4 20:14:25 2007 UTC
# Line 15  function civicrm_localize_form_alter($fo Line 15  function civicrm_localize_form_alter($fo
15    switch ($form_id) {    switch ($form_id) {
16      case 'user_register':      case 'user_register':
17      case 'user_edit':      case 'user_edit':
18        // Match the text inside label tags.        _civicrm_localize_alter($form);
       $regex = '|(<label.*?>)(.*?)(<\/.*?>)|';  
       foreach (element_children($form) as $key) {  
         // CiviCRM elements have no '#type' set. Assume if there is no '#type' that this  
         // is a field we need to alter.  
         if (isset($form[$key]['#value']) && !isset($form[$key]['#type'])) {  
           $form[$key]['#value'] = preg_replace_callback($regex, '_civicrm_localize_replace', $form[$key]['#value']);  
         }  
       }  
19        break;        break;
20    }    }
21  }  }
22    
23  /**  /**
24     * Helper function for iterating and processing forms.
25     */
26    function _civicrm_localize_alter(&$element) {
27      // Match the text inside label tags.
28      $regex = '|(<label.*?>)(.*?)(<\/.*?>)|';
29      foreach (element_children($element) as $key) {
30        // CiviCRM elements have no '#type' set. Assume if there is no '#type' that this
31        // is a field we need to alter.
32        if (isset($element[$key]['#value']) && !isset($element[$key]['#type'])) {
33          $element[$key]['#value'] = preg_replace_callback($regex, '_civicrm_localize_replace', $element[$key]['#value']);
34        }
35      }
36    }
37    
38    /**
39   * Helper function for localization.   * Helper function for localization.
40   */   */
41  function _civicrm_localize_replace($matches) {  function _civicrm_localize_replace($matches) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2