本文整理汇总了PHP中ca_metadata_elements::getElementsInSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_metadata_elements::getElementsInSet方法的具体用法?PHP ca_metadata_elements::getElementsInSet怎么用?PHP ca_metadata_elements::getElementsInSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_metadata_elements
的用法示例。
在下文中一共展示了ca_metadata_elements::getElementsInSet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caGetAdvancedSearchFormElementNames
/**
* Returns array of name for bundles in the specified form. The array is keyed on bundle name (in <table>.<name> format) with values set to arrays of bundle-specific form options (no such options are currently supported however)
*
* @param string $ps_code The code for the form
* @param string $ps_target The type of search the form targets. This should be a table name (ca_objects, ca_entities, etc.). If omitted defaults to ca_objects.
* @return array An array of bundle names with associated bundle-level form option arrays
*/
function caGetAdvancedSearchFormElementNames($ps_code, $ps_target = 'ca_objects', $pa_options = null)
{
$o_config = Configuration::load(Configuration::load()->get('advanced_search_config'));
$va_forms = $o_config->getAssoc($ps_target);
$va_form_elements = array();
if (isset($va_forms[$ps_code]) && is_array($va_forms[$ps_code])) {
$t_element = new ca_metadata_elements();
foreach ($va_forms[$ps_code]['bundles'] as $vs_bundle => $va_info) {
$va_tmp = explode('.', $vs_bundle);
if ($t_element->load(array('element_code' => $va_tmp[1]))) {
if ($t_element->get('datatype') > 0) {
$va_form_elements[$vs_bundle] = $va_info;
continue;
}
if (isset($pa_options['includeSubElements']) && $pa_options['includeSubElements']) {
if (sizeof($va_sub_elements = $t_element->getElementsInSet()) > 1) {
foreach ($va_sub_elements as $vn_element_id => $va_element_info) {
if ($va_tmp[1] == $va_element_info['element_code']) {
continue;
}
if ($va_element_info['datatype'] == 0) {
continue;
}
$va_form_elements[$va_tmp[0] . '.' . $va_element_info['element_code']] = array();
}
}
}
}
$va_form_elements[$vs_bundle] = $va_info;
}
return $va_form_elements;
}
return null;
}
示例2: saveBundlesForScreen
//.........这里部分代码省略.........
}
}
// do inserts
foreach ($va_attributes_to_insert as $va_attribute_to_insert) {
$this->clearErrors();
$this->addAttribute($va_attribute_to_insert, $vn_element_id, $vs_f);
}
if (!$vb_batch) {
// check for attributes to update
if (is_array($va_attrs = $this->getAttributesByElement($vn_element_id))) {
$t_element = new ca_metadata_elements();
$va_attrs_update_list = array();
foreach ($va_attrs as $o_attr) {
$this->clearErrors();
$vn_attribute_id = $o_attr->getAttributeID();
if (isset($va_inserted_attributes[$vn_attribute_id]) && $va_inserted_attributes[$vn_attribute_id]) {
continue;
}
if (isset($va_attributes_to_delete[$vn_attribute_id]) && $va_attributes_to_delete[$vn_attribute_id]) {
continue;
}
$vn_element_set_id = $o_attr->getElementID();
$va_attr_update = array('locale_id' => $po_request->getParameter($vs_placement_code . $vs_form_prefix . '_attribute_' . $vn_element_set_id . '_locale_id_' . $vn_attribute_id, pString));
//
// Check to see if there are any values in the element set that are not in the attribute we're editing
// If additional sub-elements were added to the set after the attribute we're updating was created
// those sub-elements will not have corresponding values returned by $o_attr->getValues() above.
// Because we use the element_ids in those values to pull request parameters, if an element_id is missing
// it effectively becomes invisible and cannot be set. This is a fairly unusual case but it happens, and when it does
// it's really annoying. It would be nice and efficient to simply create the missing values at configuration time, but we wouldn't
// know what to set the values to. So what we do is, after setting all of the values present in the attribute from the request, grab
// the configuration for the element set and see if there are any elements in the set that we didn't get values for.
//
$va_sub_elements = $t_element->getElementsInSet($vn_element_set_id);
foreach ($va_sub_elements as $vn_i => $va_element_info) {
if ($va_element_info['datatype'] == 0) {
continue;
}
//$vn_element_id = $o_attr_val->getElementID();
$vn_element_id = $va_element_info['element_id'];
$vs_k = $vs_placement_code . $vs_form_prefix . '_attribute_' . $vn_element_set_id . '_' . $vn_element_id . '_' . $vn_attribute_id;
if (isset($_FILES[$vs_k]) && ($va_val = $_FILES[$vs_k])) {
if ($va_val['size'] > 0) {
// is there actually a file?
$va_val['_uploaded_file'] = true;
$va_attr_update[$vn_element_id] = $va_val;
continue;
}
}
$vs_attr_val = $po_request->getParameter($vs_k, pString);
$va_attr_update[$vn_element_id] = $vs_attr_val;
}
$this->clearErrors();
$this->editAttribute($vn_attribute_id, $vn_element_set_id, $va_attr_update, $vs_f);
}
}
}
}
}
if (!$vb_batch) {
// hierarchy moves are not supported in batch mode
if (is_array($va_fields_by_type['special'])) {
foreach ($va_fields_by_type['special'] as $vs_placement_code => $vs_bundle) {
if ($vs_bundle !== 'hierarchy_location') {
continue;
}
示例3: getTemplatePlaceholderListForBundle
/**
* Returns list of valid template placeholders for the specified bundle. These placeholders always begin
* with a caret ("^") and will be replaced with content values when a bundle display is rendered by xxx()
*
* @param $ps_bundle_name - name of bundle
* @return array - list of placeholders as keys; values are text description of value; will return null if bundle name is invalid
*/
public function getTemplatePlaceholderListForBundle($ps_bundle_name)
{
$o_dm = $this->getAppDatamodel();
$t_instance = null;
$va_tmp = explode('.', $ps_bundle_name);
switch (sizeof($va_tmp)) {
case 2:
$vs_table = $va_tmp[0];
$vs_bundle = $va_tmp[1];
if ($vs_bundle == 'rel') {
$vs_bundle = 'preferred_labels';
}
break;
case 1:
if (!($t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true))) {
$vs_table = $o_dm->getTableName($this->get('table_num'));
$vs_bundle = $va_tmp[0];
} else {
$vs_table = $va_tmp[0];
$vs_bundle = 'preferred_labels';
}
break;
default:
return null;
break;
}
if (!$t_instance) {
if (!($t_instance = $o_dm->getInstanceByTableName($vs_table, true))) {
return null;
}
}
$va_key = array('^label' => array('label' => _t('Placement label'), 'description' => _t('The label for this placement as defined in the placements settings. The value used will be adjusted to reflect the current user's locale.')));
if ($t_instance->hasField($vs_bundle)) {
// is intrinsic field
$va_key["^{$vs_bundle}"] = array('label' => $t_instance->getFieldInfo($vs_bundle, 'LABEL'), 'description' => $t_instance->getFieldInfo($vs_bundle, 'DESCRIPTION'));
return $va_key;
}
$va_element_codes = array_flip($t_instance->getApplicableElementCodes(null, false, false));
if ($va_element_codes[$vs_bundle]) {
$t_element = new ca_metadata_elements();
if ($this->inTransaction()) {
$t_element->setTransaction($this->getTransaction());
}
if ($t_element->load(array('element_code' => $vs_bundle))) {
// is attribute
$va_hier = $t_element->getElementsInSet();
if (is_array($va_hier) && sizeof($va_hier) > 0) {
// is container with children
foreach ($va_hier as $va_node) {
if ($va_node['datatype'] == 0) {
continue;
}
// skip containers
$va_key['^' . $va_node['element_code']] = array('label' => $t_instance->getAttributeLabel($va_node['element_code']), 'description' => $t_instance->getAttributeDescription($va_node['element_code']));
}
return $va_key;
}
// is simple single-element attribute
$va_key["^{$vs_bundle}"] = array('label' => $t_instance->getAttributeLabel($vs_bundle), 'description' => $t_instance->getAttributeDescription($vs_bundle));
return $va_key;
}
}
if ($vs_bundle == 'preferred_labels') {
if ($t_label = $t_instance->getLabelTableInstance()) {
foreach ($t_label->getFormFields() as $vs_field => $va_field_info) {
$va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']);
}
return $va_key;
}
}
if ($vs_bundle == 'nonpreferred_labels') {
if ($t_label = $t_instance->getLabelTableInstance()) {
foreach ($t_label->getFormFields() as $vs_field => $va_field_info) {
$va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']);
}
return $va_key;
}
}
if ($vs_bundle == 'ca_object_representations') {
if ($vs_table == 'ca_objects') {
$t_rep = new ca_object_representations();
foreach ($t_rep->getFormFields() as $vs_field => $va_field_info) {
$va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']);
}
$va_key['^media:{version name}'] = array('label' => _t('Specified version of media'), 'description' => _t('The version of the media representation specified by {version name} for display.'));
return $va_key;
}
}
return null;
}
示例4: htmlFormElement
/**
* Return HTML form element for editing.
*
* @param array $pa_element_info An array of information about the metadata element being edited
* @param array $pa_options array Options include:
* usewysiwygeditor = overrides element level setting for visual text editor [Default=false]
* forSearch = settings and options regarding visual text editor are ignored [Default=false]
* class = the CSS class to apply to all visible form elements [Default=null]
* width = the width of the form element [Default=field width defined in metadata element definition]
* height = the height of the form element [Default=field height defined in metadata element definition]
* t_subject = an instance of the model to which the attribute belongs; required if suggestExistingValues lookups are enabled [Default is null]
* request = the RequestHTTP object for the current request; required if suggestExistingValues lookups are enabled [Default is null]
* suggestExistingValues = suggest values based on existing input for this element as user types [Default is false]
*
* @return string
*/
public function htmlFormElement($pa_element_info, $pa_options = null)
{
$va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('fieldWidth', 'fieldHeight', 'minChars', 'maxChars', 'suggestExistingValues', 'usewysiwygeditor', 'isDependentValue', 'dependentValueTemplate'));
if (isset($pa_options['usewysiwygeditor'])) {
$va_settings['usewysiwygeditor'] = $pa_options['usewysiwygeditor'];
}
if (isset($pa_options['forSearch']) && $pa_options['forSearch']) {
unset($va_settings['usewysiwygeditor']);
}
$vs_width = trim(isset($pa_options['width']) && $pa_options['width'] > 0 ? $pa_options['width'] : $va_settings['fieldWidth']);
$vs_height = trim(isset($pa_options['height']) && $pa_options['height'] > 0 ? $pa_options['height'] : $va_settings['fieldHeight']);
$vs_class = trim(isset($pa_options['class']) && $pa_options['class'] ? $pa_options['class'] : '');
$vs_element = '';
if (!preg_match("!^[\\d\\.]+px\$!i", $vs_width)) {
$vs_width = (int) $vs_width * 6 . "px";
}
if (!preg_match("!^[\\d\\.]+px\$!i", $vs_height)) {
$vs_height = (int) $vs_height * 16 . "px";
}
if ($va_settings['usewysiwygeditor']) {
$o_config = Configuration::load();
if (!is_array($va_toolbar_config = $o_config->getAssoc('wysiwyg_editor_toolbar'))) {
$va_toolbar_config = array();
}
AssetLoadManager::register("ckeditor");
$vs_element = "<script type='text/javascript'>jQuery(document).ready(function() {\n\t\t\t\t\t\tvar ckEditor = CKEDITOR.replace( '{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttoolbar : " . json_encode(array_values($va_toolbar_config)) . ", /* this does the magic */\n\t\t\t\t\t\t\twidth: '{$vs_width}',\n\t\t\t\t\t\t\theight: '{$vs_height}',\n\t\t\t\t\t\t\ttoolbarLocation: 'top',\n\t\t\t\t\t\t\tenterMode: CKEDITOR.ENTER_BR\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tckEditor.on('instanceReady', function(){ \n\t\t\t\t\t\t\t ckEditor.document.on( 'keydown', function(e) {if (caUI && caUI.utils) { caUI.utils.showUnsavedChangesWarning(true); } });\n\t\t\t\t\t\t});\n \t});\t\t\t\t\t\t\t\t\t\n</script>";
}
$va_opts = array('size' => $vs_width, 'height' => $vs_height, 'value' => '{{' . $pa_element_info['element_id'] . '}}', 'maxlength' => $va_settings['maxChars'], 'class' => $vs_class, 'id' => '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}', 'class' => "{$vs_class}" . ($va_settings['usewysiwygeditor'] ? " ckeditor" : ''));
if (caGetOption('readonly', $pa_options, false)) {
$va_opts['disabled'] = 1;
}
$vs_element .= caHTMLTextInput('{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}', $va_opts);
if ($va_settings['isDependentValue']) {
AssetLoadManager::register('displayTemplateParser');
$t_element = new ca_metadata_elements($pa_element_info['element_id']);
$va_elements = $t_element->getElementsInSet($t_element->getHierarchyRootID());
$va_element_dom_ids = array();
foreach ($va_elements as $vn_i => $va_element) {
if ($va_element['datatype'] == __CA_ATTRIBUTE_VALUE_CONTAINER__) {
continue;
}
$va_element_dom_ids[$va_element['element_code']] = "#{fieldNamePrefix}" . $va_element['element_id'] . "_{n}";
}
$vs_element .= "<script type='text/javascript'>jQuery(document).ready(function() {\n \t\t\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}').html(caDisplayTemplateParser.processDependentTemplate('" . addslashes($va_settings['dependentValueTemplate']) . "', " . json_encode($va_element_dom_ids, JSON_FORCE_OBJECT) . "));\n \t\t\t\t";
$vs_element .= "jQuery('" . join(", ", $va_element_dom_ids) . "').bind('keyup', function(e) { \n \t\t\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}').html(caDisplayTemplateParser.processDependentTemplate('" . addslashes($va_settings['dependentValueTemplate']) . "', " . json_encode($va_element_dom_ids, JSON_FORCE_OBJECT) . "));\n \t\t\t\t});";
$vs_element .= "});</script>";
}
$vs_bundle_name = $vs_lookup_url = null;
if (isset($pa_options['t_subject']) && is_object($pa_options['t_subject'])) {
$vs_bundle_name = $pa_options['t_subject']->tableName() . '.' . $pa_element_info['element_code'];
if ($pa_options['request']) {
if (isset($pa_options['lookupUrl']) && $pa_options['lookupUrl']) {
$vs_lookup_url = $pa_options['lookupUrl'];
} else {
$vs_lookup_url = caNavUrl($pa_options['request'], 'lookup', 'AttributeValue', 'Get', array('max' => 500, 'bundle' => $vs_bundle_name));
}
}
}
if ($va_settings['suggestExistingValues'] && $vs_lookup_url && $vs_bundle_name) {
$vs_element .= "<script type='text/javascript'>\n \t\t\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}').autocomplete( \n\t\t\t\t\t\t{ \n\t\t\t\t\t\t\tsource: '{$vs_lookup_url}',\n\t\t\t\t\t\t\tminLength: 3, delay: 800\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n \t\t\t\t</script>\n";
}
return $vs_element;
}
示例5: settingHTMLFormElement
//.........这里部分代码省略.........
$va_opts['value'] = array_pop($vs_value);
} else {
if ($vs_value) {
$va_opts['value'] = $vs_value;
} else {
$va_opts['value'] = null;
}
}
}
if ($vs_list_code) {
$t_list = new ca_lists();
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = $t_list->getListAsHTMLFormElement($vs_list_code, $vs_input_name, $va_attr, $va_opts);
} else {
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = caHTMLSelect($vs_input_name, $va_rel_opts, $va_attr, $va_opts);
}
} else {
if (strlen($va_properties['showSortableBundlesFor']) > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$o_dm = Datamodel::load();
if (!($t_rel = $o_dm->getInstanceByTableName($va_properties['showSortableBundlesFor'], true))) {
break;
}
$va_elements = ca_metadata_elements::getSortableElements($va_properties['showSortableBundlesFor']);
$va_select_opts = array(_t('User defined sort order') => '', _t('Order created') => 'relation_id', _t('Preferred label') => $va_properties['showSortableBundlesFor'] . ".preferred_labels." . $t_rel->getLabelDisplayField());
foreach ($va_elements as $vn_element_id => $va_element) {
if (!$va_element['display_label']) {
continue;
}
$va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_properties['showSortableBundlesFor'] . "." . $va_element['element_code'];
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
} elseif ((int) $va_properties['showSortableElementsFor'] > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$t_element = new ca_metadata_elements($va_properties['showSortableElementsFor']);
if (!$t_element->getPrimaryKey()) {
return '';
}
$va_elements = $t_element->getElementsInSet();
$va_select_opts = array(_t('Order created') => '');
foreach ($va_elements as $vn_i => $va_element) {
if ((int) $va_element['element_id'] == (int) $va_properties['showSortableElementsFor']) {
continue;
}
if (!$va_element['display_label']) {
continue;
}
$va_select_opts[_t('Element: %1', $va_element['display_label'])] = $va_element['element_code'];
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
} elseif ((int) $va_properties['showMetadataElementsWithDataType'] > 0) {
require_once __CA_MODELS_DIR__ . '/ca_metadata_elements.php';
$va_rep_elements = ca_metadata_elements::getElementsAsList(true, $va_properties['table'], null, true, false, true, array($va_properties['showMetadataElementsWithDataType']));
if (is_array($va_rep_elements)) {
$va_select_opts = array();
foreach ($va_rep_elements as $vs_element_code => $va_element_info) {
$va_select_opts[$va_element_info['display_label']] = $vs_element_code;
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
$vs_select_element = caHTMLSelect($vs_input_name, $va_select_opts, array(), $va_opts);
}
} else {
// Regular drop-down with configured options
if ($vn_height > 1) {
$va_attr['multiple'] = 1;
$vs_input_name .= '[]';
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height, 'value' => is_array($vs_value) ? $vs_value[0] : $vs_value, 'values' => is_array($vs_value) ? $vs_value : array($vs_value));
if (!isset($va_opts['value'])) {
$va_opts['value'] = -1;
}
// make sure default list item is never selected
$vs_select_element = caHTMLSelect($vs_input_name, $va_properties['options'], array(), $va_opts);
}
}
if ($vs_select_element) {
$vs_return .= $vs_select_element;
} else {
return '';
}
break;
# --------------------------------------------
# --------------------------------------------
default:
break;
# --------------------------------------------
}
$vs_return .= '</div>' . "\n";
TooltipManager::add('.' . $vs_label_id, "<h3>" . $va_properties["label"] . "</h3>" . $va_properties["description"]);
return $vs_return;
}
示例6: getElementType
private static function getElementType($pa_element_info)
{
$va_table_fields = $va_element_opts = array();
$vn_element_id = $pa_element_info['element_id'];
switch ($pa_element_info['datatype']) {
case 0:
//container
/* Retrieve child elements of the container. */
$t_element = new ca_metadata_elements((int) $pa_element_info['element_id']);
if ($t_element->getPrimaryKey()) {
$va_children = $t_element->getElementsInSet();
foreach ($va_children as $va_child) {
if ($va_child['element_id'] == $vn_element_id) {
continue;
}
$va_table_fields += SolrConfiguration::getElementType($va_child);
}
}
break;
case 1:
// text
// text
case 3:
// list
// list
case 5:
// url
// url
case 6:
// currency
// currency
case 8:
// length
// length
case 9:
// weight
// weight
case 13:
// LCSH
// LCSH
case 14:
// geonames
// geonames
case 15:
// file
// file
case 16:
// media
// media
case 19:
// taxonomy
// taxonomy
case 20:
// information service
$va_element_opts['type'] = 'text';
break;
case 2:
// daterange
$va_element_opts['type'] = 'daterange';
$va_table_fields['_ca_attribute_' . $vn_element_id . '_text'] = array('type' => 'text');
break;
case 4:
// geocode
$va_element_opts['type'] = 'geocode';
$va_table_fields['_ca_attribute_' . $vn_element_id . '_text'] = array('type' => 'text');
break;
case 10:
// timecode
// timecode
case 12:
// numeric/float
$va_element_opts['type'] = 'float';
break;
case 11:
// integer
$va_element_opts['type'] = 'int';
break;
default:
$va_element_opts['type'] = 'text';
break;
}
$va_table_fields['_ca_attribute_' . $vn_element_id] = $va_element_opts;
return $va_table_fields;
}
示例7: getElementsForForm
/**
*
*/
public function getElementsForForm($pa_options = null)
{
$va_placements = $this->getPlacements();
$t_element = new ca_metadata_elements();
$va_elements = array();
foreach ($va_placements as $vn_i => $va_placement) {
$va_tmp = explode('.', $va_placement['bundle_name']);
if ($t_element->load(array('element_code' => $va_tmp[1]))) {
if ($t_element->get('datatype') > 0) {
$va_elements[] = $va_placement['bundle_name'];
}
if (sizeof($va_sub_elements = $t_element->getElementsInSet()) > 1) {
foreach ($va_sub_elements as $vn_element_id => $va_element_info) {
if ($va_tmp[1] == $va_element_info['element_code']) {
continue;
}
$va_elements[] = $va_tmp[0] . '.' . $va_element_info['element_code'];
}
}
} else {
$va_elements[] = $va_placement['bundle_name'];
}
}
return $va_elements;
}