本文整理汇总了PHP中ca_lists::numItemsInList方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::numItemsInList方法的具体用法?PHP ca_lists::numItemsInList怎么用?PHP ca_lists::numItemsInList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::numItemsInList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
# ------------------------------------
}
}
示例2: GetHierarchyLevel
/**
* Given a item_id (request parameter 'id') returns a list of direct children for use in the hierarchy browser
* Returned data is JSON format
*/
public function GetHierarchyLevel()
{
$ps_bundle = (string) $this->request->getParameter('bundle', pString);
$pa_ids = explode(";", $ps_ids = $this->request->getParameter('id', pString));
if (!sizeof($pa_ids)) {
$pa_ids = array(null);
}
$t_item = $this->opo_item_instance;
$vs_template = $t_item->getAppConfig()->get('ca_list_items_hierarchy_browser_display_settings');
$va_lists = array();
if ($ps_lists = $this->request->getParameter('lists', pString)) {
$va_lists = explode(";", $ps_lists);
}
if (($vn_max_items_per_page = $this->request->getParameter('max', pInteger)) < 1 || $vn_max_items_per_page > 1000) {
$vn_max_items_per_page = 100;
}
$va_level_data = array();
foreach ($pa_ids as $pn_id) {
$va_tmp = explode(":", $pn_id);
$vn_id = $va_tmp[0];
$vn_start = (int) $va_tmp[1];
if ($vn_start < 0) {
$vn_start = 0;
}
if (!$vn_id && method_exists($t_item, "getHierarchyList")) {
if (!($pn_list_id = $this->request->getParameter('list_id', pInteger))) {
// no id so by default return list of available hierarchies
$va_list_items = $t_item->getHierarchyList();
if (sizeof($va_lists)) {
// filter out lists that weren't specified
foreach ($va_list_items as $vn_list_id => $va_list) {
if (!in_array($vn_list_id, $va_lists) && !in_array($va_list['list_code'], $va_lists)) {
unset($va_list_items[$vn_list_id]);
}
}
} else {
if ($this->request->getParameter('voc', pInteger)) {
// Only show vocabularies
foreach ($va_list_items as $vn_list_id => $va_list) {
if (!$va_list['use_as_vocabulary']) {
unset($va_list_items[$vn_list_id]);
}
}
}
}
}
} else {
if ($t_item->load($vn_id)) {
// id is the id of the parent for the level we're going to return
$t_list = new ca_lists($vn_list_id = $t_item->get('list_id'));
$vs_label_table_name = $this->opo_item_instance->getLabelTableName();
$vs_label_display_field_name = $this->opo_item_instance->getLabelDisplayField();
$va_list_items = $t_list->getItemsForList($vn_list_id, array('returnHierarchyLevels' => false, 'item_id' => $vn_id, 'extractValuesByUserLocale' => true, 'sort' => $t_list->get('sort_type'), 'directChildrenOnly' => true, 'limit' => $vn_max_items_per_page, 'start' => $vn_start));
// output
$va_display_values = caProcessTemplateForIDs($vs_template, 'ca_list_items', array_keys($va_list_items), array('requireLinkTags' => true, 'returnAsArray' => true));
$vn_c = 0;
foreach ($va_list_items as $vn_item_id => $va_item) {
unset($va_item['description']);
unset($va_item['icon']);
if (!$va_item[$vs_label_display_field_name]) {
$va_item[$vs_label_display_field_name] = $va_item['idno'];
}
if (!$va_item[$vs_label_display_field_name]) {
$va_item[$vs_label_display_field_name] = '???';
}
$va_item['name'] = $va_display_values[$vn_c];
if (!$va_item['name']) {
$va_item['name'] = '??? ' . $vn_item_id;
}
$va_item['table'] = 'ca_list_items';
// Child count is only valid if has_children is not null
$va_item['children'] = 0;
$va_list_items[$vn_item_id] = $va_item;
$vn_c++;
}
if (sizeof($va_list_items)) {
$o_db = new Db();
$qr_res = $o_db->query("\n\t\t\t\t\t\t\t\tSELECT count(*) c, parent_id\n\t\t\t\t\t\t\t\tFROM ca_list_items\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\tparent_id IN (" . join(",", array_keys($va_list_items)) . ") AND deleted = 0\n\t\t\t\t\t\t\t\tGROUP BY parent_id\n\t\t\t\t\t\t\t");
while ($qr_res->nextRow()) {
$va_list_items[$qr_res->get('parent_id')]['children'] = $qr_res->get('c');
}
}
}
}
$va_list_items['_sortOrder'] = array_keys($va_list_items);
$va_list_items['_primaryKey'] = $t_item->primaryKey();
// pass the name of the primary key so the hierbrowser knows where to look for item_id's
$va_list_items['_itemCount'] = $t_list ? $t_list->numItemsInList() : ($qr_res ? $qr_res->numRows() : 0);
$va_level_data[$pn_id] = $va_list_items;
}
if (!$this->request->getParameter('init', pInteger)) {
// only set remember "last viewed" if the load is done interactively
// if the GetHierarchyLevel() call is part of the initialization of the hierarchy browser
// then all levels are loaded, sometimes out-of-order; if we record these initialization loads
// as the 'last viewed' we can end up losing the true 'last viewed' value
//
//.........这里部分代码省略.........
示例3: validateSetting
/**
* Checks validity of setting value for attribute; used by ca_metadata_elements to
* validate settings before they are saved.
*
* @param array $pa_element_info Associative array containing data from a ca_metadata_elements row
* @param string $ps_setting_key Alphanumeric setting code
* @param string $ps_value Value of setting
* @param string $ps_error Variable to place error message in, if setting fails validation
* @return boolean True if value is valid for setting, false if not. If validation fails an error message is returned in $ps_error
*/
public function validateSetting($pa_element_info, $ps_setting_key, $ps_value, &$ps_error)
{
$ps_error = '';
switch ($ps_setting_key) {
case 'render':
switch ($ps_value) {
case 'yes_no_checkboxes':
$t_list = new ca_lists((int) $pa_element_info['list_id']);
// Yes/no must be used with lists that have exactly two items
if ((int) $t_list->numItemsInList() != 2) {
$ps_error = _t('The list must have exactly two items to be used as a yes/no checkbox');
return false;
}
break;
case 'checklist':
// Check list is only valid for top-level elements
if ((int) $pa_element_info['parent_id'] > 0) {
$ps_error = _t('Sub-elements may not be used as checklists');
return false;
}
break;
}
break;
}
return true;
}
示例4: validateSetting
/**
* Checks validity of setting value for attribute; used by ca_metadata_elements to
* validate settings before they are saved.
*
* @param array $pa_element_info Associative array containing data from a ca_metadata_elements row
* @param string $ps_setting_key Alphanumeric setting code
* @param string $ps_value Value of setting
* @param string $ps_error Variable to place error message in, if setting fails validation
* @return boolean True if value is valid for setting, false if not. If validation fails an error message is returned in $ps_error
*/
public function validateSetting($pa_element_info, $ps_setting_key, $ps_value, &$ps_error)
{
$ps_error = '';
switch ($ps_setting_key) {
case 'render':
switch ($ps_value) {
case 'yes_no_checkboxes':
$t_list = new ca_lists((int) $pa_element_info['list_id']);
// Yes/no must be used with lists that have exactly two items
if ((int) $t_list->numItemsInList() != 2) {
$ps_error = _t('The list must have exactly two items to be used as a yes/no checkbox');
return false;
}
break;
case 'checklist':
// Check list is only valid for top-level elements
if ((int) $pa_element_info['parent_id'] > 0) {
$ps_error = _t('Sub-elements may not be used as checklists');
return false;
}
break;
}
break;
}
if (preg_match("/^hideIfSelected/", $ps_setting_key)) {
if (isset($pa_element_info['settings']['render']) && !is_null($pa_element_info['settings']['render'])) {
if (!in_array($pa_element_info['settings']['render'], array('radio_buttons', 'select', 'yes_no_checkboxes'))) {
$ps_error = _t("dependent field visibility is only supported for radio buttons and drop-down (select) menus");
return false;
}
}
}
return true;
}