本文整理汇总了PHP中ca_lists::getListAsHTMLFormElement方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getListAsHTMLFormElement方法的具体用法?PHP ca_lists::getListAsHTMLFormElement怎么用?PHP ca_lists::getListAsHTMLFormElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::getListAsHTMLFormElement方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: htmlFormElement
//.........这里部分代码省略.........
# Generate auto generated <select> (from foreign key, from ca_lists or from field-defined choice list)
#
# TODO: CLEAN UP THIS CODE, RUNNING VARIOUS STAGES THROUGH HELPER FUNCTIONS; ALSO FORMALIZE AND DOCUMENT VARIOUS OPTIONS
// -----
// from ca_lists
// -----
if (!($vs_list_code = $pa_options['list_code'])) {
if (isset($va_attr['LIST_CODE']) && $va_attr['LIST_CODE']) {
$vs_list_code = $va_attr['LIST_CODE'];
}
}
if ($vs_list_code) {
$va_many_to_one_relations = $this->_DATAMODEL->getManyToOneRelations($this->tableName());
if ($va_many_to_one_relations[$ps_field]) {
$vs_key = 'item_id';
} else {
$vs_key = 'item_value';
}
$vs_null_option = null;
if (!$pa_options["nullOption"] && $vb_is_null) {
$vs_null_option = _t("- NONE -");
} else {
if ($pa_options["nullOption"]) {
$vs_null_option = $pa_options["nullOption"];
}
}
$t_list = new ca_lists();
$va_list_attrs = array('id' => $pa_options['id']);
//if ($vn_max_pixel_width) { $va_list_attrs['style'] = $vs_width_style; }
if (method_exists($this, 'getTypeFieldName') && $ps_field == $this->getTypeFieldName()) {
$va_limit_list = caGetTypeListForUser($this->tableName(), array('access' => __CA_BUNDLE_ACCESS_EDIT__));
}
// NOTE: "raw" field value (value passed into method, before the model default value is applied) is used so as to allow the list default to be used if needed
$vs_element = $t_list->getListAsHTMLFormElement($vs_list_code, $pa_options["name"] . $vs_multiple_name_extension, $va_list_attrs, array('value' => $vm_raw_field_value, 'key' => $vs_key, 'nullOption' => $vs_null_option, 'readonly' => $pa_options['readonly'], 'restrictTypeListForTable' => $this->tableName(), 'limitToItemsWithID' => $va_limit_list ? $va_limit_list : null));
if (isset($pa_options['hide_select_if_no_options']) && $pa_options['hide_select_if_no_options'] && !$vs_element) {
$vs_element = "";
$ps_format = '^ERRORS^ELEMENT';
}
} else {
// -----
// from related table
// -----
$va_many_to_one_relations = $this->_DATAMODEL->getManyToOneRelations($this->tableName());
if (isset($va_many_to_one_relations[$ps_field]) && $va_many_to_one_relations[$ps_field]) {
#
# Use foreign key to populate <select>
#
$o_one_table = $this->_DATAMODEL->getTableInstance($va_many_to_one_relations[$ps_field]["one_table"]);
$vs_one_table_primary_key = $o_one_table->primaryKey();
if ($o_one_table->isHierarchical()) {
#
# Hierarchical <select>
#
$va_hier = $o_one_table->getHierarchyAsList(0, $vs_display_use_count, $va_display_use_count_filters, $vb_display_omit_items__with_zero_count);
if (!is_array($va_hier)) {
return '';
}
$va_display_fields = $va_attr["DISPLAY_FIELD"];
if (!in_array($vs_one_table_primary_key, $va_display_fields)) {
$va_display_fields[] = $o_one_table->tableName() . "." . $vs_one_table_primary_key;
}
if (!is_array($va_display_fields) || sizeof($va_display_fields) < 1) {
$va_display_fields = array("*");
}
$vs_hier_parent_id_fld = $o_one_table->getProperty("HIER_PARENT_ID_FLD");
$va_options = array();
示例2:
</div>
<?php
break;
case 'bubbles':
default:
if ((bool) $va_settings['restrictToTermsRelatedToCollection']) {
?>
<div id="<?php
print $vs_id_prefix;
?>
Item_{n}" class="labelInfo">
<table class="attributeListItem" cellpadding="5" cellspacing="0">
<tr>
<td class="attributeListItem">
<?php
if ($vs_checklist = ca_lists::getListAsHTMLFormElement(null, $vs_id_prefix . "_id{n}", null, array('render' => 'checklist', 'limitToItemsRelatedToCollections' => $t_instance->get('ca_collections.collection_id', array('returnAsArray' => true)), 'limitToItemsRelatedToCollectionWithRelationshipTypes' => $va_settings['restrictToTermsOnCollectionWithRelationshipType'], 'limitToListIDs' => $va_settings['restrict_to_lists'], 'maxColumns' => 3))) {
print $vs_checklist;
} else {
?>
<h2><?php
print _t('No collection terms selected');
?>
</h2>
<?php
}
if (isset($va_settings['restrictToTermsOnCollectionUseRelationshipType']) && is_array($va_settings['restrictToTermsOnCollectionUseRelationshipType'])) {
?>
<input type="hidden" name="<?php
print $vs_id_prefix;
?>
_type_id{n}" id="<?php
示例3: settingHTMLFormElement
//.........这里部分代码省略.........
$va_rel_opts[$va_list_info['name'] . ' (' . $va_list_info['list_code'] . ')'] = $vn_list_id;
}
}
}
}
$va_attr = array();
if ($vn_height > 1) {
$va_attr['multiple'] = 1;
$vs_input_name .= '[]';
}
$va_opts = array('id' => $vs_input_id, 'width' => $vn_width, 'height' => $vn_height);
if ($vn_height > 1) {
if ($vs_value && !is_array($vs_value)) {
$vs_value = array($vs_value);
}
$va_opts['values'] = $vs_value;
} else {
if (is_array($vs_value)) {
$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') => '');
示例4: Index
//.........这里部分代码省略.........
// pass view list to view for rendering
$this->view->setVar('current_view', $vs_view);
$this->view->setVar('sorts', $this->opa_sorts);
// pass sort list to view for rendering
$this->view->setVar('current_sort', $vs_sort);
$this->view->setVar('current_sort_direction', $vs_sort_direction);
$this->view->setVar('current_items_per_page', $vn_items_per_page);
$this->view->setVar('items_per_page', $this->opa_items_per_page);
$this->view->setVar('t_subject', $t_model);
$this->view->setVar('mode_name', _t('search'));
$this->view->setVar('mode', 'search');
$this->view->setVar('mode_type_singular', $this->searchName('singular'));
$this->view->setVar('mode_type_plural', $this->searchName('plural'));
$this->view->setVar('search_history', $this->opo_result_context->getSearchHistory());
$this->view->setVar('result_context', $this->opo_result_context);
$this->view->setVar('uses_hierarchy_browser', $this->usesHierarchyBrowser());
$this->view->setVar('access_values', $va_access_values);
$this->view->setVar('browse', $po_search);
$t_display = $this->view->getVar('t_display');
if (!is_array($va_display_list = $this->view->getVar('display_list'))) {
$va_display_list = array();
}
if ($vs_view == 'editable') {
$va_initial_data = array();
$va_row_headers = array();
$vn_item_count = 0;
if ($vo_result) {
$vs_pk = $vo_result->primaryKey();
while ($vn_item_count < 100 && $vo_result->nextHit()) {
$va_result = array('item_id' => $vn_id = $vo_result->get($vs_pk));
foreach ($va_display_list as $vn_placement_id => $va_bundle_info) {
$va_result[str_replace(".", "-", $va_bundle_info['bundle_name'])] = $t_display->getDisplayValue($vo_result, $vn_placement_id, array('request' => $this->request));
}
$va_initial_data[] = $va_result;
$vn_item_count++;
$va_row_headers[] = $vn_item_count . " " . caEditorLink($this->request, caNavIcon($this->request, __CA_NAV_BUTTON_EDIT__), 'caResultsEditorEditLink', $this->ops_tablename, $vn_id);
}
}
$this->view->setVar('initialData', $va_initial_data);
$this->view->setVar('rowHeaders', $va_row_headers);
}
//
// Bottom line
//
$va_bottom_line = array();
$vb_bottom_line_is_set = false;
foreach ($va_display_list as $vn_placement_id => $va_placement) {
if (isset($va_placement['settings']['bottom_line']) && $va_placement['settings']['bottom_line']) {
$va_bottom_line[$vn_placement_id] = caProcessBottomLineTemplate($this->request, $va_placement, $vo_result, array('pageStart' => ($vn_page_num - 1) * $vn_items_per_page, 'pageEnd' => ($vn_page_num - 1) * $vn_items_per_page + $vn_items_per_page));
$vb_bottom_line_is_set = true;
} else {
$va_bottom_line[$vn_placement_id] = '';
}
}
$this->view->setVar('bottom_line', $vb_bottom_line_is_set ? $va_bottom_line : null);
switch ($pa_options['output_format']) {
# ------------------------------------
case 'LABELS':
$this->_genLabels($vo_result, $this->request->getParameter("label_form", pString), $vs_search, $vs_search);
break;
# ------------------------------------
# ------------------------------------
case 'EXPORT':
$this->_genExport($vo_result, $this->request->getParameter("export_format", pString), $vs_search, $vs_search);
break;
# ------------------------------------
# ------------------------------------
case 'HTML':
default:
// generate type menu and type value list
if (method_exists($t_model, "getTypeList")) {
$this->view->setVar('type_list', $t_model->getTypeList());
}
if ($this->opb_uses_hierarchy_browser) {
AssetLoadManager::register('hierBrowser');
// only for interfaces that use the hierarchy browser
$t_list = new ca_lists();
if ($vs_type_list_code = $t_model->getTypeListCode()) {
$this->view->setVar('num_types', $t_list->numItemsInList($vs_type_list_code));
$this->view->setVar('type_menu', $t_list->getListAsHTMLFormElement($vs_type_list_code, 'type_id', array('id' => 'hierTypeList')));
}
// set last browse id for hierarchy browser
$this->view->setVar('browse_last_id', intval($this->request->session->getVar($this->ops_tablename . '_browse_last_id')));
}
$this->opo_result_context->setAsLastFind();
$this->opo_result_context->saveContext();
if (isset($pa_options['vars']) && is_array($pa_options['vars'])) {
foreach ($pa_options['vars'] as $vs_key => $vs_val) {
$this->view->setVar($vs_key, $vs_val);
}
}
if (isset($pa_options['view']) && $pa_options['view']) {
$this->render($pa_options['view']);
} else {
$this->render('Search/' . $this->ops_tablename . '_search_basic_html.php');
}
break;
# ------------------------------------
}
}
示例5: htmlFormElement
/**
* Generates HTML form widget for attribute value
*
* @param $pa_element_info array Array with information about the metadata element with which this value is associated. Keys taken to be ca_metadata_elements field names and the 'settings' field must be deserialized into an array.
* @param $pa_options array Array of options. Supported options are:
* width - The width of the list drop-down in characters unless suffixed with 'px' in which case width will be set in pixels.
* any option supported by ca_lists::getListAsHTMLFormElement with the exception of 'render' and 'maxColumns', which are set out of information in $pa_element_info
* @return string HTML code for form element
*/
public function htmlFormElement($pa_element_info, $pa_options = null)
{
$vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue'];
if ($pa_element_info['parent_id'] && $pa_element_info['settings']['render'] == 'checklist') {
$pa_element_info['settings']['render'] = '';
}
// checklists can only be top-level
if ((!isset($pa_options['width']) || !strlen($pa_options['width'])) && isset($pa_element_info['settings']['listWidth']) && strlen($pa_element_info['settings']['listWidth']) > 0) {
$pa_options['width'] = $pa_element_info['settings']['listWidth'];
}
if ((!isset($pa_options['height']) || !strlen($pa_options['height'])) && isset($pa_element_info['settings']['listHeight']) && strlen($pa_element_info['settings']['listHeight']) > 0) {
$pa_options['height'] = $pa_element_info['settings']['listHeight'];
}
if (isset($pa_options['nullOption']) && strlen($pa_options['nullOption'])) {
$vb_null_option = $pa_options['nullOption'];
} else {
$vb_null_option = !$vb_require_value ? _t('-NONE-') : null;
}
return ca_lists::getListAsHTMLFormElement($pa_element_info['list_id'], '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}', array('id' => '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}'), array_merge($pa_options, array('render' => isset($pa_element_info['settings']['render']) ? $pa_element_info['settings']['render'] : '', 'maxColumns' => $pa_element_info['settings']['maxColumns'], 'element_id' => $pa_element_info['element_id'], 'nullOption' => $vb_null_option)));
}
示例6: caHTMLTextInput
</div>
<br class="clear"/>
<?php
}
?>
<div class="col">
<?php
print "<span class='header'>" . _t("Create set") . ":</span><br/>";
?>
<form id="caCreateSetFromResults">
<?php
print caHTMLTextInput('set_name', array('id' => 'caCreateSetFromResultsInput', 'class' => 'searchSetsTextInput', 'value' => $o_result_context->getSearchExpression()), array('width' => '150px'));
print " ";
print caHTMLSelect('set_create_mode', array(_t('from results') => 'from_results', _t('from checked') => 'from_checked'), array('id' => 'caCreateSetFromResultsMode', 'class' => 'searchSetsSelect'), array('value' => null, 'width' => '140px'));
if ($t_list->getAppConfig()->get('enable_set_type_controls')) {
print $t_list->getListAsHTMLFormElement('set_types', 'set_type', array('id' => 'caCreateSetTypeID', 'class' => 'searchSetsSelect'), array('value' => null, 'width' => '140px'));
}
print caBusyIndicatorIcon($this->request, array('id' => 'caCreateSetFromResultsIndicator')) . "\n";
?>
<a href='#' onclick="caCreateSetFromResults(); return false;" class="button"><?php
print _t('Create');
?>
›</a>
<?php
if ($this->request->user->canDoAction('can_batch_edit_' . $t_subject->tableName())) {
print '<div class="searchSetsBatchEdit">' . caHTMLCheckboxInput('batch_edit', array('id' => 'caCreateSetBatchEdit', 'value' => 1)) . " " . _t('Open set for batch editing') . "</div>\n";
}
?>
</form>
</div>
示例7: getTypeListAsHTMLFormElement
/**
* Returns HTML <select> form element with type list
*
* @param string $ps_name The name of the returned form element
* @param array $pa_attributes An optional array of HTML attributes to place into the returned <select> tag
* @param array $pa_options An array of options. Supported options are anything supported by ca_lists::getListAsHTMLFormElement as well as:
* childrenOfCurrentTypeOnly = Returns only types below the current type
* restrictToTypes = Array of type_ids to restrict type list to
* @return string HTML for list element
*/
public function getTypeListAsHTMLFormElement($ps_name, $pa_attributes = null, $pa_options = null)
{
$t_list = new ca_lists();
if (isset($pa_options['childrenOfCurrentTypeOnly']) && $pa_options['childrenOfCurrentTypeOnly']) {
$pa_options['childrenOnlyForItemID'] = $this->get('type_id');
}
$pa_options['limitToItemsWithID'] = caGetTypeRestrictionsForUser($this->tableName(), $pa_options);
if (isset($pa_options['restrictToTypes']) && is_array($pa_options['restrictToTypes'])) {
$pa_options['restrictToTypes'] = caMakeTypeIDList($this->tableName(), $pa_options['restrictToTypes'], $pa_options);
if (!$pa_options['limitToItemsWithID'] || !is_array($pa_options['limitToItemsWithID'])) {
$pa_options['limitToItemsWithID'] = $pa_options['restrictToTypes'];
} else {
$pa_options['limitToItemsWithID'] = array_intersect($pa_options['limitToItemsWithID'], $pa_options['restrictToTypes']);
}
}
return $t_list->getListAsHTMLFormElement($this->getTypeListCode(), $ps_name, $pa_attributes, $pa_options);
}
示例8: caNavUrl
*
* CollectiveAccess is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This source code is free and modifiable under the terms of
* GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
* the "license.txt" file for details, or visit the CollectiveAccess web site at
* http://www.CollectiveAccess.org
*
* ----------------------------------------------------------------------
*/
$t_set = $this->getVar('t_set');
$va_set_list = $this->getVar('set_list');
$t_list = new ca_lists();
$vs_set_type_menu = '<div class="sf-small-menu form-header-button rounded" style="padding: 6px;">' . '<div style="float:right; margin: 3px;">' . '<a href="#" onclick="_navigateToNewForm(jQuery(\'#typeList\').val(), jQuery(\'#tableList\').val());">' . caNavIcon($this->request, __CA_NAV_BUTTON_ADD_LARGE__) . '</a>' . '</div>' . '<form action="#">' . _t('Create New') . ' ' . $t_list->getListAsHTMLFormElement('set_types', 'set_type', array('id' => 'typeList')) . ' ' . _t('containing') . ' ' . caHTMLSelect('table_num', $this->getVar('table_list'), array('id' => 'tableList')) . '</form>' . '</div>';
?>
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery('#caSetList').caFormatListTable();
});
function _navigateToNewForm(type_id, table_num) {
document.location = '<?php
print caNavUrl($this->request, 'manage/sets', 'SetEditor', 'Edit', array('set_id' => 0, 'type_id' => ''));
?>
' + type_id + '/table_num/' + table_num;
}
/* ]]> */
</script>
示例9: getTypeListAsHTMLFormElement
/**
* Returns HTML <select> form element with type list
*
* @param string $ps_name The name of the returned form element
* @param array $pa_attributes An optional array of HTML attributes to place into the returned <select> tag
* @param array $pa_options An array of options. Supported options are anything supported by ca_lists::getListAsHTMLFormElement as well as:
* childrenOfCurrentTypeOnly = Returns only types below the current type
* restrictToTypes = Array of type_ids to restrict type list to
* inUse = Return only types that are used by at least one record. [Default is false]
* checkAccess = Array of access values to filter returned values on. Available for any related table with an "access" field (ca_objects, ca_entities, etc.). If omitted no filtering is performed. [Default is null]
* @return string HTML for list element
*/
public function getTypeListAsHTMLFormElement($ps_name, $pa_attributes = null, $pa_options = null)
{
$t_list = new ca_lists();
if (isset($pa_options['childrenOfCurrentTypeOnly']) && $pa_options['childrenOfCurrentTypeOnly']) {
$pa_options['childrenOnlyForItemID'] = $this->get('type_id');
}
$pa_options['limitToItemsWithID'] = caGetTypeRestrictionsForUser($this->tableName(), $pa_options);
if (caGetOption('inUse', $pa_options, false)) {
$vs_access_sql = '';
$va_sql_params = array();
if (($va_check_access = caGetOption('checkAccess', $pa_options, null)) && is_array($va_check_access) && sizeof($va_check_access) && $this->hasField('access')) {
array_walk($va_check_access, function (&$pm_item, $ps_key) {
$pm_item = (int) $pm_item;
});
$vs_access_sql = " AND (access IN (?))";
$va_sql_params[] = $va_check_access;
$qr_types_in_use = $this->getDb()->query("SELECT DISTINCT type_id FROM " . $this->tableName() . ($this->hasField('deleted') ? " WHERE deleted = 0 {$vs_access_sql}" : ""), $va_sql_params);
}
if (!is_array($pa_options['limitToItemsWithID'])) {
$pa_options['limitToItemsWithID'] = array();
}
if ($qr_types_in_use->numRows() > 0) {
$pa_options['limitToItemsWithID'] += $qr_types_in_use->getAllFieldValues('type_id');
}
}
if (isset($pa_options['restrictToTypes']) && is_array($pa_options['restrictToTypes'])) {
$pa_options['restrictToTypes'] = caMakeTypeIDList($this->tableName(), $pa_options['restrictToTypes'], $pa_options);
if (!$pa_options['limitToItemsWithID'] || !is_array($pa_options['limitToItemsWithID'])) {
$pa_options['limitToItemsWithID'] = $pa_options['restrictToTypes'];
} else {
$pa_options['limitToItemsWithID'] = array_intersect($pa_options['limitToItemsWithID'], $pa_options['restrictToTypes']);
}
}
return $t_list->getListAsHTMLFormElement($this->getTypeListCode(), $ps_name, $pa_attributes, $pa_options);
}
示例10: htmlFormElement
/**
* Generates HTML form widget for attribute value
*
* @param $pa_element_info array Array with information about the metadata element with which this value is associated. Keys taken to be ca_metadata_elements field names and the 'settings' field must be deserialized into an array.
* @param $pa_options array Array of options. Supported options are:
* width - The width of the list drop-down in characters unless suffixed with 'px' in which case width will be set in pixels.
* any option supported by ca_lists::getListAsHTMLFormElement with the exception of 'maxColumns', which is set out of information in $pa_element_info
* @return string HTML code for form element
*/
public function htmlFormElement($pa_element_info, $pa_options = null)
{
/** @var RequestHTTP $o_request */
$o_request = $pa_options['request'];
$vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue'];
if ($pa_element_info['parent_id'] && $pa_element_info['settings']['render'] == 'checklist') {
$pa_element_info['settings']['render'] = '';
}
// checklists can only be top-level
if ((!isset($pa_options['width']) || !strlen($pa_options['width'])) && isset($pa_element_info['settings']['listWidth']) && strlen($pa_element_info['settings']['listWidth']) > 0) {
$pa_options['width'] = $pa_element_info['settings']['listWidth'];
}
if ((!isset($pa_options['height']) || !strlen($pa_options['height'])) && isset($pa_element_info['settings']['listHeight']) && strlen($pa_element_info['settings']['listHeight']) > 0) {
$pa_options['height'] = $pa_element_info['settings']['listHeight'];
}
$vs_class = trim(isset($pa_options['class']) && $pa_options['class'] ? $pa_options['class'] : '');
if (isset($pa_options['nullOption']) && strlen($pa_options['nullOption'])) {
$vb_null_option = $pa_options['nullOption'];
} else {
$vb_null_option = !$vb_require_value ? $pa_element_info['settings']['nullOptionText'] ? $pa_element_info['settings']['nullOptionText'] : _t('Not set') : null;
}
$vs_render = caGetOption('render', $pa_options, caGetOption('render', $pa_element_info['settings'], ''));
$vb_auto_shrink = (bool) caGetOption('auto_shrink', $pa_options, caGetOption('auto_shrink', $pa_element_info['settings'], false));
$vn_max_columns = $pa_element_info['settings']['maxColumns'];
if (!$vb_require_value) {
$vn_max_columns++;
}
if (!isset($pa_options['useDefaultWhenNull'])) {
$pa_options['useDefaultWhenNull'] = isset($pa_element_info['settings']['useDefaultWhenNull']) ? (bool) $pa_element_info['settings']['useDefaultWhenNull'] : false;
}
$vs_element = ca_lists::getListAsHTMLFormElement($pa_element_info['list_id'], '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}', array('class' => $vs_class, 'id' => '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}'), array_merge($pa_options, array('render' => $vs_render, 'maxColumns' => $vn_max_columns, 'element_id' => $pa_element_info['element_id'], 'nullOption' => $vb_null_option, 'auto_shrink' => $vb_auto_shrink)));
// dependant field visibility
if (Configuration::load()->get('enable_dependent_field_visibility')) {
// only get into outputting all the JS below if hideIfSelected is set for at least one list item for this element
$vb_print_js = false;
if (is_array($pa_element_info['settings'])) {
foreach ($pa_element_info['settings'] as $vs_setting_key => $vm_setting_val) {
if (preg_match('/^hideIfSelected/', $vs_setting_key)) {
$vb_print_js = true;
}
}
}
if ($vb_print_js) {
$t_list = new ca_lists();
$vb_yes_was_set = false;
$vs_select = '';
foreach ($t_list->getItemsForList($pa_element_info['list_id']) as $va_items_by_locale) {
foreach ($va_items_by_locale as $vn_locale_id => $va_item) {
$vs_hide_js = '';
if (is_array($pa_element_info['settings']['hideIfSelected_' . $va_item['idno']])) {
// @todo maybe only generate JS for bundles on current screen? could figure that out from request
foreach ($pa_element_info['settings']['hideIfSelected_' . $va_item['idno']] as $vs_key) {
$va_tmp = self::resolveHideIfSelectedKey($vs_key);
if (!is_array($va_tmp)) {
continue;
}
$vs_hide_js .= "jQuery(\"a[name='Screen" . $va_tmp[0] . "_" . $va_tmp[1] . "']\").next().hide();\n";
}
}
switch ($pa_element_info['settings']['render']) {
case 'radio_buttons':
$vs_select = "jQuery('[id^={fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}]')";
$vs_selector_for_val = "jQuery('input[name={fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}]:checked').val()";
$vs_condition = $vs_selector_for_val . " === '" . $va_item['item_id'] . "'";
break;
case 'yes_no_checkboxes':
$vs_select = "jQuery('[id^={fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}]')";
if ($vb_yes_was_set) {
$vs_condition = "!(jQuery('input[name={fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}]').is(':checked'))";
} else {
$vb_yes_was_set = true;
$vs_condition = "jQuery('input[name={fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}]').is(':checked')";
}
break;
case 'select':
case null:
$vs_select = "jQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}')";
$vs_selector_for_val = "jQuery(this).find(':selected').val()";
$vs_condition = $vs_selector_for_val . " === '" . $va_item['item_id'] . "'";
break;
default:
continue;
}
$vs_element .= "\n<script type='text/javascript'>\n\tjQuery(document).ready(function() {\n\t\tvar select = {$vs_select};\n\t\tselect.change(function() {\n\t\t\tif ({$vs_condition}) {\n\t\t\t\tjQuery('div.bundleLabel').show();\n\t\t\t\t{$vs_hide_js}\n\t\t\t}\n\t\t});\n\n\t\tif ({$vs_condition}) {\n\t\t\t{$vs_hide_js}\n\t\t}\n\t});\n</script>\n\t";
}
}
}
}
return $vs_element;
}
示例11: htmlFormElement
/**
* Generates HTML form widget for attribute value
*
* @param $pa_element_info array Array with information about the metadata element with which this value is associated. Keys taken to be ca_metadata_elements field names and the 'settings' field must be deserialized into an array.
* @param $pa_options array Array of options. Supported options are:
* width - The width of the list drop-down in characters unless suffixed with 'px' in which case width will be set in pixels.
* any option supported by ca_lists::getListAsHTMLFormElement with the exception of 'maxColumns', which is set out of information in $pa_element_info
* @return string HTML code for form element
*/
public function htmlFormElement($pa_element_info, $pa_options = null)
{
$vb_require_value = is_null($pa_element_info['settings']['requireValue']) ? true : (bool) $pa_element_info['settings']['requireValue'];
if ($pa_element_info['parent_id'] && $pa_element_info['settings']['render'] == 'checklist') {
$pa_element_info['settings']['render'] = '';
}
// checklists can only be top-level
if ((!isset($pa_options['width']) || !strlen($pa_options['width'])) && isset($pa_element_info['settings']['listWidth']) && strlen($pa_element_info['settings']['listWidth']) > 0) {
$pa_options['width'] = $pa_element_info['settings']['listWidth'];
}
if ((!isset($pa_options['height']) || !strlen($pa_options['height'])) && isset($pa_element_info['settings']['listHeight']) && strlen($pa_element_info['settings']['listHeight']) > 0) {
$pa_options['height'] = $pa_element_info['settings']['listHeight'];
}
$vs_class = trim(isset($pa_options['class']) && $pa_options['class'] ? $pa_options['class'] : '');
if (isset($pa_options['nullOption']) && strlen($pa_options['nullOption'])) {
$vb_null_option = $pa_options['nullOption'];
} else {
$vb_null_option = !$vb_require_value ? $pa_element_info['settings']['nullOptionText'] ? $pa_element_info['settings']['nullOptionText'] : _t('Not set') : null;
}
$vs_render = caGetOption('render', $pa_options, caGetOption('render', $pa_element_info['settings'], ''));
$vb_auto_shrink = (bool) caGetOption('auto_shrink', $pa_options, caGetOption('auto_shrink', $pa_element_info['settings'], false));
$vn_max_columns = $pa_element_info['settings']['maxColumns'];
if (!$vb_require_value) {
$vn_max_columns++;
}
if (!isset($pa_options['useDefaultWhenNull'])) {
$pa_options['useDefaultWhenNull'] = isset($pa_element_info['settings']['useDefaultWhenNull']) ? (bool) $pa_element_info['settings']['useDefaultWhenNull'] : false;
}
return ca_lists::getListAsHTMLFormElement($pa_element_info['list_id'], '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}', array('class' => $vs_class, 'id' => '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}'), array_merge($pa_options, array('render' => $vs_render, 'maxColumns' => $vn_max_columns, 'element_id' => $pa_element_info['element_id'], 'nullOption' => $vb_null_option, 'auto_shrink' => $vb_auto_shrink)));
}