예제 #1
0
 function save($df)
 {
     $this->type = 'varchar';
     require_once 'modules/ModuleBuilder/parsers/parser.label.php';
     $parser = new ParserLabel($df->getModuleName(), $df->getPackageName());
     foreach (array('City', 'State', 'PostalCode', 'Country') as $addressFieldName) {
         $systemLabel = strtoupper("LBL_" . $this->name . '_' . $addressFieldName);
         $parser->handleSave(array("label_" . $systemLabel => $this->label_value . ' ' . $addressFieldName), $GLOBALS['current_language']);
         $addressField = new TemplateField();
         $addressField->len = $addressFieldName == 'PostalCode' ? 20 : 100;
         $addressField->name = $this->name . '_' . strtolower($addressFieldName);
         $addressField->label = $addressField->vname = $systemLabel;
         $addressField->save($df);
     }
     // finally save the base street address field
     parent::save($df);
 }
예제 #2
0
 function save($df)
 {
     // Bug 58560 - Set the group name since addresses are part of a group
     $this->group = $df->getDBName($this->name);
     require_once 'modules/ModuleBuilder/parsers/parser.label.php';
     $parser = new ParserLabel($df->getModuleName(), $df->getPackageName());
     // Clean up the labels so they more accurately reflect the actual field
     if (!empty($this->label_value)) {
         $labelValue = $this->label_value;
     } else {
         $labelValue = empty($_REQUEST['labelValue']) ? '' : $_REQUEST['labelValue'];
     }
     // If there is a label to use, space it here for use below
     if (!empty($labelValue)) {
         $labelValue .= ' ';
     }
     // To prevent mutilple calls to the metadata api cache rebuilder, queue
     MetaDataManager::enableCacheRefreshQueue();
     // To keep consistency with OOTB address groups, add Street to the fields
     foreach (array('Street', 'City', 'State', 'PostalCode', 'Country') as $addressFieldName) {
         $systemLabel = strtoupper("LBL_" . $this->name . '_' . $addressFieldName);
         // Use the entered label value as a prefix instead of the field name
         $parser->handleSave(array("label_" . $systemLabel => $labelValue . $addressFieldName), $GLOBALS['current_language']);
         if ($addressFieldName === 'Street') {
             $addressField = new TemplateAddressStreet();
             $addressField->len = 150;
         } else {
             $addressField = new TemplateField();
             $addressField->len = $addressFieldName === 'PostalCode' ? 20 : 100;
         }
         $addressField->name = $this->name . '_' . strtolower($addressFieldName);
         $addressField->label = $addressField->vname = $systemLabel;
         // Bug 58560 - Add the group to this field so it gets written to the custom vardefs
         $addressField->group = $this->group;
         // Maintain unified search setting for 'Street'
         $addressField->supports_unified_search = $addressField == 'Street';
         $addressField->save($df);
     }
     // Handle the metadata api update now
     MetaDataManager::runCacheRefreshQueue();
 }
예제 #3
0
 function action_saveProperty()
 {
     require_once 'modules/ModuleBuilder/parsers/parser.label.php';
     $modules = $_REQUEST['view_module'];
     if (!empty($_REQUEST['subpanel'])) {
         $modules = $_REQUEST['subpanel'];
     }
     $parser = new ParserLabel($modules, isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null);
     // if no language provided, then use the user's current language which is most likely what they intended
     $language = isset($_REQUEST['selected_lang']) ? $_REQUEST['selected_lang'] : $GLOBALS['current_language'];
     $parser->handleSave($_REQUEST, $language);
     $json = getJSONobj();
     echo $json->encode(array("east" => array("action" => "deactivate")));
 }
 /**
  * Save label for id field
  *
  * @param string $idLabelName
  * @param DynamicField $df
  */
 protected function saveIdLabel($idLabelName, $df)
 {
     if ($df instanceof DynamicField) {
         $module = $df->module;
     } elseif ($df instanceof MBModule) {
         $module = $df->name;
     } else {
         Log::fatal('Unsupported DynamicField type');
     }
     $viewPackage = isset($df->package) ? $df->package : null;
     $idLabelValue = string_format($GLOBALS['mod_strings']['LBL_RELATED_FIELD_ID_NAME_LABEL'], array($this->label_value, $GLOBALS['app_list_strings']['moduleListSingular'][$this->ext2]));
     $idFieldLabelArr = array("label_{$idLabelName}" => $idLabelValue);
     foreach (ModuleBuilder::getModuleAliases($module) as $moduleName) {
         if ($df instanceof DynamicField) {
             $parser = new ParserLabel($moduleName, $viewPackage);
             $parser->handleSave($idFieldLabelArr, $GLOBALS['current_language']);
         } elseif ($df instanceof MBModule) {
             $df->setLabel($GLOBALS['current_language'], $idLabelName, $idLabelValue);
             $df->save();
         }
     }
 }
예제 #5
0
 /**
  * Adds a label to the module's mod_strings for the current language
  * Note that the system label name
  *
  * @param string $displayLabel The label value to be displayed
  * @return string The core of the system label name - returns currency_id5 for example, when the full label would then be LBL_CURRENCY_ID5
  * TODO: Only the core is returned for historical reasons - switch to return the real system label
  */
 function addLabel($displayLabel)
 {
     $mod_strings = return_module_language($GLOBALS['current_language'], $this->module);
     $limit = 10;
     $count = 0;
     $field_key = $this->getDBName($displayLabel, false);
     $systemLabel = $field_key;
     if (!$this->use_existing_labels) {
         // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php
         while (isset($mod_strings[$systemLabel]) && $count <= $limit) {
             $systemLabel = $field_key . "_{$count}";
             $count++;
         }
     }
     $selMod = !empty($_REQUEST['view_module']) ? $_REQUEST['view_module'] : $this->module;
     require_once 'modules/ModuleBuilder/parsers/parser.label.php';
     $parser = new ParserLabel($selMod, isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null);
     $parser->handleSave(array('label_' . $systemLabel => $displayLabel), $GLOBALS['current_language']);
     return $systemLabel;
 }