当前位置: 首页>>代码示例>>PHP>>正文


PHP Attribute::getValueInstance方法代码示例

本文整理汇总了PHP中Attribute::getValueInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::getValueInstance方法的具体用法?PHP Attribute::getValueInstance怎么用?PHP Attribute::getValueInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attribute的用法示例。


在下文中一共展示了Attribute::getValueInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveBundlesForScreen


//.........这里部分代码省略.........
                             foreach ($this->getFieldConflicts() as $vs_conflict_field) {
                                 $po_request->addActionError($o_e, $vs_conflict_field);
                             }
                             break;
                         default:
                             $po_request->addActionError($o_e, $vs_f);
                             break;
                     }
                 }
             }
         }
     }
     // save attributes
     $va_inserted_attributes_by_element = array();
     if (isset($va_fields_by_type['attribute']) && is_array($va_fields_by_type['attribute'])) {
         //
         // name of attribute request parameters are:
         // 	For new attributes
         // 		{$vs_form_prefix}_attribute_{element_set_id}_{element_id|'locale_id'}_new_{n}
         //		ex. ObjectBasicForm_attribute_6_locale_id_new_0 or ObjectBasicForm_attribute_6_desc_type_new_0
         //
         // 	For existing attributes:
         // 		{$vs_form_prefix}_attribute_{element_set_id}_{element_id|'locale_id'}_{attribute_id}
         //
         // look for newly created attributes; look for attributes to delete
         $va_inserted_attributes = array();
         $reserved_elements = array();
         foreach ($va_fields_by_type['attribute'] as $vs_placement_code => $vs_f) {
             $vs_element_set_code = preg_replace("/^ca_attribute_/", "", $vs_f);
             //does the attribute's datatype have a saveElement method - if so, use that instead
             $vs_element = $this->_getElementInstance($vs_element_set_code);
             $vn_element_id = $vs_element->getPrimaryKey();
             $vs_element_datatype = $vs_element->get('datatype');
             $vs_datatype = Attribute::getValueInstance($vs_element_datatype);
             if (method_exists($vs_datatype, 'saveElement')) {
                 $reserved_elements[] = $vs_element;
                 continue;
             }
             $va_attributes_to_insert = array();
             $va_attributes_to_delete = array();
             $va_locales = array();
             $vs_batch_mode = $_REQUEST[$vs_placement_code . $vs_form_prefix . '_attribute_' . $vn_element_id . '_batch_mode'];
             if ($vb_batch && $vs_batch_mode == '_delete_') {
                 // Remove all attributes and continue
                 $this->removeAttributes($vn_element_id, array('force' => true));
                 continue;
             }
             foreach ($_REQUEST as $vs_key => $vs_val) {
                 // is it a newly created attribute?
                 if (preg_match('/' . $vs_placement_code . $vs_form_prefix . '_attribute_' . $vn_element_id . '_([\\w\\d\\-_]+)_new_([\\d]+)/', $vs_key, $va_matches)) {
                     if ($vb_batch) {
                         switch ($vs_batch_mode) {
                             case '_disabled_':
                                 // skip
                                 continue 2;
                                 break;
                             case '_add_':
                                 // just try to add attribute as in normal non-batch save
                                 // noop
                                 break;
                             case '_replace_':
                                 // remove all existing attributes before trying to save
                                 $this->removeAttributes($vn_element_id, array('force' => true));
                                 continue;
                                 break;
                         }
开发者ID:idiscussforum,项目名称:providence,代码行数:67,代码来源:BundlableLabelableBaseModelWithAttributes.php

示例2: editValue

 /**
  * Edits the value of the currently loaded ca_attribute_values record. 
  * Returns the value_id of the edited value on success, false on failure and
  * null on "silent" failure, in which case no error message is displayed to the user.
  *
  * @param string $ps_value The user-input value to parse
  *
  * @return int Returns the value_id of the value on success. If the value cannot be edited due to an error, false is returned. "Silent" failures, for which the user should not see an error message, are indicated by a null return value.
  */
 public function editValue($ps_value, $pa_options = null)
 {
     if (!$this->getPrimaryKey()) {
         return null;
     }
     if ($this->inTransaction()) {
         $pa_options['transaction'] = $this->getTransaction();
     }
     $t_element = ca_attributes::getElementInstance($this->get('element_id'));
     $pa_element_info = $t_element->getFieldValuesArray();
     $this->setMode(ACCESS_WRITE);
     $o_attr_value = Attribute::getValueInstance($t_element->get('datatype'));
     $pa_element_info['displayLabel'] = $t_element->getLabelForDisplay(false);
     $va_values = $o_attr_value->parseValue($ps_value, $pa_element_info, $pa_options);
     if (isset($va_values['_dont_save']) && $va_values['_dont_save']) {
         return true;
     }
     if (is_array($va_values)) {
         $this->useBlobAsFileField(false);
         if (!$o_attr_value->numErrors()) {
             foreach ($va_values as $vs_key => $vs_val) {
                 if (substr($vs_key, 0, 1) === '_') {
                     continue;
                 }
                 if ($vs_key === 'value_blob' && (isset($va_values['_file']) && $va_values['_file'])) {
                     $this->useBlobAsFileField(true);
                     // force value_blob field to be treated as FT_FILE by BaseModel
                     $this->set($vs_key, $vs_val, array('original_filename' => $va_values['value_longtext2']));
                     $this->set('source_info', md5_file($vs_val));
                 } else {
                     if ($vs_key === 'value_blob' && (isset($va_values['_media']) && $va_values['_media'])) {
                         $this->useBlobAsMediaField(true);
                         // force value_blob field to be treated as FT_MEDIA by BaseModel
                         $this->set($vs_key, $vs_val, array('original_filename' => $va_values['value_longtext2']));
                         $this->set('source_info', md5_file($vs_val));
                     } else {
                         $this->set($vs_key, $vs_val);
                     }
                 }
             }
         } else {
             // error
             $this->errors = $o_attr_value->errors;
             return false;
         }
     } else {
         if ($va_values === false) {
             $this->errors = $o_attr_value->errors;
         }
         return $va_values;
     }
     $this->update();
     if ($this->numErrors()) {
         return false;
     }
     return $this->getPrimaryKey();
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:66,代码来源:ca_attribute_values.php

示例3: _getChangeLogFromRawData


//.........这里部分代码省略.........
                                             }
                                             if (!$vs_proc_val) {
                                                 $vs_proc_val = '???';
                                             }
                                         } else {
                                             $vs_proc_val = _t("Not set");
                                         }
                                     } else {
                                         $vs_proc_val = _t('Non-existent');
                                     }
                                 } else {
                                     // Adjust display of value for different field types
                                     switch ($va_field_info['FIELD_TYPE']) {
                                         case FT_BIT:
                                             $vs_proc_val = $vs_value ? 'Yes' : 'No';
                                             break;
                                         default:
                                             $vs_proc_val = $vs_value;
                                             break;
                                     }
                                     // Adjust display of value for lists
                                     if ($va_field_info['LIST']) {
                                         $t_list = new ca_lists();
                                         if ($t_list->load(array('list_code' => $va_field_info['LIST']))) {
                                             $vn_list_id = $t_list->getPrimaryKey();
                                             $t_list_item = new ca_list_items();
                                             if ($t_list_item->load(array('list_id' => $vn_list_id, 'item_value' => $vs_value))) {
                                                 $vs_proc_val = $t_list_item->getLabelForDisplay();
                                             }
                                         }
                                     } else {
                                         if ($va_field_info['BOUNDS_CHOICE_LIST']) {
                                             // TODO
                                         }
                                     }
                                 }
                             }
                             $va_changes[] = array('label' => $va_field_info['LABEL'], 'description' => strlen((string) $vs_proc_val) ? $vs_proc_val : $vs_blank_placeholder, 'value' => $vs_value);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this a label row?
                     if ($va_log_entry['logged_table_num'] == $vn_label_table_num) {
                         foreach ($va_log_entry['snapshot'] as $vs_field => $vs_value) {
                             $va_changes[] = array('label' => $t_item_label->getFieldInfo($vs_field, 'LABEL'), 'description' => $vs_value);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this an attribute?
                     if ($va_log_entry['logged_table_num'] == 3) {
                         // attribute_values
                         if ($t_element = ca_attributes::getElementInstance($va_log_entry['snapshot']['element_id'])) {
                             if ($o_attr_val = Attribute::getValueInstance($t_element->get('datatype'))) {
                                 $o_attr_val->loadValueFromRow($va_log_entry['snapshot']);
                                 $vs_attr_val = $o_attr_val->getDisplayValue();
                             } else {
                                 $vs_attr_val = '?';
                             }
                             // Convert list-based attributes to text
                             if ($vn_list_id = $t_element->get('list_id')) {
                                 $t_list = new ca_lists();
                                 $vs_attr_val = $t_list->getItemFromListForDisplayByItemID($vn_list_id, $vs_attr_val, true);
                             }
                             if (!$vs_attr_val) {
                                 $vs_attr_val = $vs_blank_placeholder;
                             }
                             $vs_label = $t_element->getLabelForDisplay();
                             $va_attributes[$va_log_entry['snapshot']['attribute_id']]['values'][] = array('label' => $vs_label, 'value' => $vs_attr_val);
                             $va_changes[] = array('label' => $vs_label, 'description' => $vs_attr_val);
                         }
                     }
                     // ---------------------------------------------------------------
                     // is this a related (many-many) row?
                     $va_keys = $o_datamodel->getOneToManyRelations($t_item->tableName(), $t_obj->tableName());
                     if (sizeof($va_keys) > 0) {
                         if (method_exists($t_obj, 'getLeftTableNum')) {
                             if ($t_obj->getLeftTableNum() == $t_item->tableNum()) {
                                 // other side of rel is on right
                                 $t_related_table = $o_datamodel->getInstanceByTableNum($t_obj->getRightTableNum(), true);
                                 $t_related_table->load($va_log_entry['snapshot'][$t_obj->getRightTableFieldName()]);
                             } else {
                                 // other side of rel is on left
                                 $t_related_table = $o_datamodel->getInstanceByTableNum($t_obj->getLeftTableNum(), true);
                                 $t_related_table->load($va_log_entry['snapshot'][$t_obj->getLeftTableFieldName()]);
                             }
                             $t_rel = $o_datamodel->getInstanceByTableNum($t_obj->tableNum(), true);
                             $va_changes[] = array('label' => caUcFirstUTF8Safe($t_related_table->getProperty('NAME_SINGULAR')), 'idno' => ($vs_idno_field = $t_related_table->getProperty('ID_NUMBERING_ID_FIELD')) ? $t_related_table->get($vs_idno_field) : null, 'description' => $t_related_table->getLabelForDisplay(), 'table_name' => $t_related_table->tableName(), 'table_num' => $t_related_table->tableNum(), 'row_id' => $t_related_table->getPrimaryKey(), 'rel_type_id' => $va_log_entry['snapshot']['type_id'], 'rel_typename' => $t_rel->getRelationshipTypename('ltor', $va_log_entry['snapshot']['type_id']));
                         }
                     }
                     // ---------------------------------------------------------------
                     // record log line
                     if (sizeof($va_changes)) {
                         $va_log_output[$vn_unit_id][] = array('datetime' => $vs_datetime, 'user_fullname' => $vs_user, 'user_email' => $vs_email, 'user' => $vs_user . ' (' . $vs_email . ')', 'changetype_display' => $va_change_types[$va_log_entry['changetype']], 'changetype' => $va_log_entry['changetype'], 'changes' => $va_changes, 'subject' => $vs_subject_display_name, 'subject_id' => $vn_subject_row_id, 'subject_table_num' => $vn_subject_table_num, 'logged_table_num' => $va_log_entry['logged_table_num'], 'logged_table' => $t_obj->tableName(), 'logged_row_id' => $va_log_entry['logged_row_id']);
                     }
                 }
             }
         }
     }
     return $va_log_output;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:ApplicationChangeLog.php

示例4: getFacetContent


//.........这里部分代码省略.........
                         // preserve order of list
                         $va_values_sorted_by_list_order = array();
                         if (is_array($va_list_item_cache)) {
                             foreach ($va_list_item_cache as $vn_item_id => $va_item) {
                                 if (isset($va_facet_list[$vn_item_id])) {
                                     $va_values_sorted_by_list_order[$vn_item_id] = $va_facet_list[$vn_item_id];
                                 }
                             }
                         }
                         return caSortArrayByKeyInValue($va_values_sorted_by_list_order, array('label'));
                         break;
                     case __CA_ATTRIBUTE_VALUE_OBJECTS__:
                     case __CA_ATTRIBUTE_VALUE_ENTITIES__:
                     case __CA_ATTRIBUTE_VALUE_PLACES__:
                     case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
                     case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
                     case __CA_ATTRIBUTE_VALUE_LOANS__:
                     case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
                     case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
                     case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
                         if ($t_rel_item = AuthorityAttributeValue::elementTypeToInstance($vn_element_type)) {
                             $va_ids = $qr_res->getAllFieldValues('value_integer1');
                             $va_auth_items = $t_rel_item->getPreferredDisplayLabelsForIDs($va_ids);
                             $qr_res->seek(0);
                         }
                         break;
                     default:
                         if (isset($va_facet_info['suppress']) && is_array($va_facet_info['suppress'])) {
                             $va_suppress_values = $va_facet_info['suppress'];
                         }
                         break;
                 }
                 while ($qr_res->nextRow()) {
                     $o_attr = Attribute::getValueInstance($vn_element_type, $qr_res->getRow(), true);
                     if (!($vs_val = trim($o_attr->getDisplayValue()))) {
                         continue;
                     }
                     if (is_array($va_suppress_values) && in_array($vs_val, $va_suppress_values)) {
                         continue;
                     }
                     if ($va_criteria[$vs_val]) {
                         continue;
                     }
                     // skip items that are used as browse critera - don't want to browse on something you're already browsing on
                     switch ($vn_element_type) {
                         case __CA_ATTRIBUTE_VALUE_LIST__:
                             $vn_child_count = 0;
                             if ($va_list_parent_ids[$vs_val]) {
                                 $vn_child_count++;
                             }
                             $va_values[$vs_val] = array('id' => str_replace('/', '/', $vs_val), 'label' => html_entity_decode($va_list_items[$vs_val]['name_plural'] ? $va_list_items[$vs_val]['name_plural'] : $va_list_items[$vs_val]['item_value']), 'parent_id' => $va_list_items[$vs_val]['parent_id'], 'child_count' => $vn_child_count);
                             break;
                         case __CA_ATTRIBUTE_VALUE_OBJECTS__:
                         case __CA_ATTRIBUTE_VALUE_ENTITIES__:
                         case __CA_ATTRIBUTE_VALUE_PLACES__:
                         case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
                         case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
                         case __CA_ATTRIBUTE_VALUE_LOANS__:
                         case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
                         case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
                         case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
                             $va_values[$vs_val] = array('id' => $vn_id, 'label' => html_entity_decode($va_auth_items[$vn_id] ? $va_auth_items[$vn_id] : $vs_val));
                             break;
                         case __CA_ATTRIBUTE_VALUE_CURRENCY__:
                             $va_values[sprintf("%014.2f", preg_replace("![\\D]+!", "", $vs_val))] = array('id' => str_replace('/', '/', $vs_val), 'label' => $vs_val);
                             break;
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:BrowseEngine.php

示例5: valueHTMLFormElement

 public static function valueHTMLFormElement($pn_datatype, $pa_element_info, $pa_options = null)
 {
     if ($o_value = Attribute::getValueInstance($pn_datatype)) {
         return $o_value->htmlFormElement($pa_element_info, $pa_options);
     }
     return null;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:7,代码来源:Attribute.php

示例6: setSetting

 /**
  * Set setting value 
  * (you must call insert() or update() to write the settings to the database)
  */
 public function setSetting($ps_setting, $pm_value, &$ps_error = null)
 {
     if (is_null($this->get('datatype'))) {
         return null;
     }
     if (!$this->isValidSetting($ps_setting)) {
         return null;
     }
     $o_value_instance = Attribute::getValueInstance($this->get('datatype'), null, true);
     if (!$o_value_instance->validateSetting($this->getFieldValuesArray(), $ps_setting, $pm_value, $vs_error)) {
         $ps_error = $vs_error;
         return false;
     }
     $va_settings = $this->getSettings();
     $va_available_settings = $this->getAvailableSettings();
     $va_properties = $va_available_settings[$ps_setting];
     if ($va_properties['formatType'] == FT_NUMBER && $va_properties['displayType'] == DT_CHECKBOXES && !$pm_value) {
         $pm_value = '0';
     }
     $va_settings[$ps_setting] = $pm_value;
     ca_metadata_elements::$s_settings_cache[$this->getPrimaryKey()] = $va_settings;
     return true;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:27,代码来源:ca_metadata_elements.php

示例7: setSetting

 /**
  * Set setting value 
  * (you must call insert() or update() to write the settings to the database)
  */
 public function setSetting($ps_setting, $pm_value, &$ps_error = null)
 {
     if (is_null($this->get('datatype'))) {
         return null;
     }
     if (!$this->isValidSetting($ps_setting)) {
         return null;
     }
     // MemoryCache key can't be false or null so use special key for soon-to-be-inserted elements
     $vm_cache_key = $this->getPrimaryKey() ? $this->getPrimaryKey() : 'no_key';
     $o_value_instance = Attribute::getValueInstance($this->get('datatype'), null, true);
     $vs_error = null;
     if (!$o_value_instance->validateSetting($this->getFieldValuesArray(), $ps_setting, $pm_value, $vs_error)) {
         $ps_error = $vs_error;
         return false;
     }
     $va_settings = $this->getSettings();
     $va_available_settings = $this->getAvailableSettings();
     $va_properties = $va_available_settings[$ps_setting];
     if ($va_properties['formatType'] == FT_NUMBER && $va_properties['displayType'] == DT_CHECKBOXES && !$pm_value) {
         $pm_value = '0';
     }
     $va_settings[$ps_setting] = $pm_value;
     MemoryCache::save($vm_cache_key, $va_settings, 'ElementSettings');
     return true;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:30,代码来源:ca_metadata_elements.php

示例8: getFacetContent


//.........这里部分代码省略.........
                     $vs_criteria_exclude_sql = ' AND (ca_attribute_values.value_longtext1 NOT IN (' . join(", ", caQuoteList(array_keys($va_criteria))) . ')) ';
                 }
                 $vs_sql = "\n\t\t\t\t\t\t\tSELECT count(DISTINCT value_longtext1) c\n\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_criteria_exclude_sql} {$vs_where_sql}\n\t\t\t\t\t\t\tLIMIT 1";
                 //print $vs_sql;
                 $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                 if ($qr_res->nextRow()) {
                     return (int) $qr_res->get('c') > 0 ? true : false;
                 }
                 return false;
             } else {
                 $vs_sql = "\n\t\t\t\t\t\t\tSELECT DISTINCT value_longtext1, value_decimal1, value_longtext2\n\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tca_attribute_values.element_id = ? {$vs_where_sql}";
                 //print $vs_sql;
                 $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                 $va_values = array();
                 $vn_element_type = $t_element->get('datatype');
                 $va_list_items = null;
                 $va_suppress_values = null;
                 if ($va_facet_info['suppress'] && !is_array($va_facet_info['suppress'])) {
                     $va_facet_info['suppress'] = array($va_facet_info['suppress']);
                 }
                 if ($vn_element_type == 3) {
                     // list
                     $t_list = new ca_lists();
                     $va_list_items = caExtractValuesByUserLocale($t_list->getItemsForList($t_element->get('list_id')));
                     if (isset($va_facet_info['suppress']) && is_array($va_facet_info['suppress'])) {
                         $va_suppress_values = ca_lists::getItemIDsFromList($t_element->get('list_id'), $va_facet_info['suppress']);
                     }
                 } else {
                     if (isset($va_facet_info['suppress']) && is_array($va_facet_info['suppress'])) {
                         $va_suppress_values = $va_facet_info['suppress'];
                     }
                 }
                 while ($qr_res->nextRow()) {
                     $o_attr = Attribute::getValueInstance($vn_element_type, $qr_res->getRow());
                     if (!($vs_val = trim($o_attr->getDisplayValue()))) {
                         continue;
                     }
                     if (is_array($va_suppress_values) && in_array($vs_val, $va_suppress_values)) {
                         continue;
                     }
                     switch ($vn_element_type) {
                         case 3:
                             // list
                             if ($va_criteria[$vs_val]) {
                                 continue;
                             }
                             // skip items that are used as browse critera - don't want to browse on something you're already browsing on
                             $vn_child_count = 0;
                             foreach ($va_list_items as $vn_id => $va_item) {
                                 if ($va_item['parent_id'] == $vs_val) {
                                     $vn_child_count++;
                                 }
                             }
                             $va_values[$vs_val] = array('id' => $vs_val, 'label' => $va_list_items[$vs_val]['name_plural'] ? $va_list_items[$vs_val]['name_plural'] : $va_list_items[$vs_val]['item_value'], 'parent_id' => $va_list_items[$vs_val]['parent_id'], 'child_count' => $vn_child_count);
                             break;
                         case 6:
                             // currency
                             $va_values[sprintf("%014.2f", preg_replace("![\\D]+!", "", $vs_val))] = array('id' => str_replace('/', '/', $vs_val), 'label' => $vs_val);
                             break;
                         default:
                             if ($va_criteria[$vs_val]) {
                                 continue;
                             }
                             // skip items that are used as browse critera - don't want to browse on something you're already browsing on
                             $va_values[$vs_val] = array('id' => str_replace('/', '/', $vs_val), 'label' => $vs_val);
                             break;
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:BrowseEngine.php


注:本文中的Attribute::getValueInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。