本文整理汇总了PHP中JArrayHelper::getColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::getColumn方法的具体用法?PHP JArrayHelper::getColumn怎么用?PHP JArrayHelper::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::getColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
$cid = JRequest::getVar('cid', array(0), '', 'array');
$id = intval($cid[0]);
$db =& JFactory::getDBO();
$acl = JFactory::getACL();
$query = "SELECT id, name FROM #__groups WHERE id = {$id}";
$db->setQuery($query);
$row = $db->loadObject();
$query = "SELECT id_group FROM #__noixacl_groups_level WHERE id_levels like '%{$id}%'";
$db->setQuery($query);
$rowGroups = $db->loadObjectList();
$levelGroups = JArrayHelper::getColumn($rowGroups, 'id_group');
/**
* get groups
*/
$aclGroups = $acl->sort_groups();
/**
* format groups
*/
$groups = $acl->format_groups($aclGroups, 'html', 28);
$this->assignRef('accesslevel', $row);
$this->assignRef('levelGroups', $levelGroups);
$this->assignRef('groups', $groups);
$text = !$cid[0] ? JText::_('NOIXACL_VIEW_ACCESSLEVEL_TEXT_EDIT') : JText::_('NOIXACL_VIEW_ACCESSLEVEL_TEXT_NEW');
JToolBarHelper::title(JText::_('NOIXACL_VIEW_ACCESSLEVEL_TEXT_GROUP') . ': <small><small>[ ' . $text . ' ]</small></small>', 'user.png');
JToolBarHelper::save();
JToolBarHelper::apply();
JToolBarHelper::cancel();
parent::display($tpl);
}
示例2: getItems
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (isset($this->cache[$store])) {
return $this->cache[$store];
}
// Load the list items.
$query = $this->_getListQuery();
try {
$count = (int) $this->getState('list.count_elements');
$items = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));
if ($count) {
$pks = JArrayHelper::getColumn($items, 'id');
$elements = $this->getElementCount($pks);
}
foreach ($items as $item) {
$item->element_count = $count ? $elements[$item->id] : 0;
$item->orphaned = empty($item->project_exists);
}
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
示例3: getItems
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (isset($this->cache[$store])) {
return $this->cache[$store];
}
// Load the list items.
$query = $this->_getListQuery();
try {
$items = $this->_getList($query, 0, 0);
$pks = JArrayHelper::getColumn($items, 'id');
$elements = $this->getRevisionCount($pks);
foreach ($items as $item) {
$item->revision_count = $elements[$item->id];
}
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
示例4: getItems
/**
* Overrides the getItems method to attach additional metrics to the list.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6.1
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId('getItems');
// Try to load the data from internal storage.
if (!empty($this->cache[$store])) {
return $this->cache[$store];
}
// Load the list items.
$items = parent::getItems();
// If emtpy or an error, just return.
if (empty($items)) {
return array();
}
// Getting the following metric by joins is WAY TOO SLOW.
// Faster to do three queries for very large menu trees.
// Get the menu types of menus in the list.
$db = $this->getDbo();
$menuTypes = JArrayHelper::getColumn($items, 'menutype');
// Quote the strings.
$menuTypes = implode(',', array_map(array($db, 'quote'), $menuTypes));
// Get the published menu counts.
$query = $db->getQuery(true)->select('m.menutype, COUNT(DISTINCT m.id) AS count_published')->from('#__menu AS m')->where('m.published = 1')->where('m.menutype IN (' . $menuTypes . ')')->group('m.menutype');
$db->setQuery($query);
try {
$countPublished = $db->loadAssocList('menutype', 'count_published');
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
// Get the unpublished menu counts.
$query->clear('where')->where('m.published = 0')->where('m.menutype IN (' . $menuTypes . ')');
$db->setQuery($query);
try {
$countUnpublished = $db->loadAssocList('menutype', 'count_published');
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
// Get the trashed menu counts.
$query->clear('where')->where('m.published = -2')->where('m.menutype IN (' . $menuTypes . ')');
$db->setQuery($query);
try {
$countTrashed = $db->loadAssocList('menutype', 'count_published');
} catch (RuntimeException $e) {
$this->setError($e->getMessage);
return false;
}
// Inject the values back into the array.
foreach ($items as $item) {
$item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0;
$item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0;
$item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
示例5: getItems
public function getItems()
{
if (!$this->pid) {
return array();
}
$user = JFactory::getUser();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$nd = $db->getNullDate();
$query->select('a.id, a.milestone_id, a.title, a.created')->select('m.start_date AS m_start, m.end_date AS m_end')->from('#__pf_task_lists AS a')->join('LEFT', '#__pf_projects AS p ON p.id = a.project_id')->join('LEFT', '#__pf_milestones AS m ON m.id = a.milestone_id')->where('a.project_id = ' . $this->pid)->where('a.state != -2');
// Filter access
if (!$user->authorise('core.admin')) {
$query->where('a.access IN(' . implode(', ', $user->getAuthorisedViewLevels()) . ')');
}
$query->order('a.id ASC');
$db->setQuery($query);
$data = $db->loadObjectList();
if (!is_array($data)) {
return array();
}
// Prepare data
$datas = array();
$keys = JArrayHelper::getColumn($data, 'id');
$completed = $this->getCompleted($keys);
foreach ($data as $i => $item) {
// Set dates
$item->start_date = $this->getStartDate($item->id, $item->milestone_id, $item->m_start);
$item->end_date = $this->getEndDate($item->id, $item->milestone_id, $item->m_end);
// Skip item if no start or end is set
if ($item->start_date == $nd || $item->end_date == $nd) {
continue;
}
$item->complete = $completed[$item->id];
$item->start_time = floor(strtotime($item->start_date) / 86400) * 86400;
$item->end_time = floor(strtotime($item->end_date) / 86400) * 86400;
$start_date = new JDate($item->start_date);
$end_date = new JDate($item->end_date);
$item->start_date = $start_date->format('Y-m-d H:i:s');
$item->end_date = $end_date->format('Y-m-d H:i:s');
$item->duration = $item->end_time - $item->start_time;
$duration = strtotime($item->end_date) - strtotime($item->start_date);
$item->fduration = $this->time2string($duration);
$item->type = 'tasklist';
if (!isset($datas[$item->start_time])) {
$datas[$item->start_time] = array();
}
$datas[$item->start_time][] = $item;
}
ksort($datas, SORT_NUMERIC);
$items = array();
foreach ($datas as $key => $vals) {
foreach ($vals as $val) {
$items[] = $val;
}
}
return $items;
}
示例6: getItems
/**
* Method to get a list of items.
* Overriden to inject convert the attribs field into a JParameter object.
*
* @return mixed $items An array of objects on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
$base_path = JPATH_ROOT . '/media/com_projectfork/repo/0/logo';
$base_url = JURI::root(true) . '/media/com_projectfork/repo/0/logo';
$tasks_exists = PFApplicationHelper::enabled('com_pftasks');
$repo_exists = PFApplicationHelper::enabled('com_pfrepo');
$pks = JArrayHelper::getColumn($items, 'id');
// Get aggregate data
$progress = array();
$total_tasks = array();
$completed_tasks = array();
$total_files = array();
if ($tasks_exists) {
JLoader::register('PFtasksModelTasks', JPATH_SITE . '/components/com_pftasks/models/tasks.php');
$tmodel = JModelLegacy::getInstance('Tasks', 'PFtasksModel', array('ignore_request' => true));
$progress = $tmodel->getAggregatedProgress($pks, 'project_id');
$total_tasks = $tmodel->getAggregatedTotal($pks, 'project_id');
$completed_tasks = $tmodel->getAggregatedTotal($pks, 'project_id', 1);
}
if ($repo_exists) {
JLoader::register('PFrepoModelFiles', JPATH_SITE . '/components/com_pfrepo/models/files.php');
$fmodel = JModelLegacy::getInstance('Files', 'PFrepoModel', array('ignore_request' => true));
$total_files = $fmodel->getProjectCount($pks);
}
// Loop over each row to inject data
foreach ($items as $i => &$item) {
$params = new JRegistry();
$params->loadString($item->attribs);
// Convert the parameter fields into objects.
$items[$i]->params = clone $this->getState('params');
// Create slug
$items[$i]->slug = $items[$i]->alias ? $items[$i]->id . ':' . $items[$i]->alias : $items[$i]->id;
// Try to find the logo img
$items[$i]->logo_img = null;
if (JFile::exists($base_path . '/' . $item->id . '.jpg')) {
$items[$i]->logo_img = $base_url . '/' . $item->id . '.jpg';
} elseif (JFile::exists($base_path . '/' . $item->id . '.jpeg')) {
$items[$i]->logo_img = $base_url . '/' . $item->id . '.jpeg';
} elseif (JFile::exists($base_path . '/' . $item->id . '.png')) {
$items[$i]->logo_img = $base_url . '/' . $item->id . '.png';
} elseif (JFile::exists($base_path . '/' . $item->id . '.gif')) {
$items[$i]->logo_img = $base_url . '/' . $item->id . '.gif';
}
// Inject task count
$items[$i]->tasks = isset($total_tasks[$item->id]) ? $total_tasks[$item->id] : 0;
// Inject completed task count
$items[$i]->completed_tasks = isset($completed_tasks[$item->id]) ? $completed_tasks[$item->id] : 0;
// Inject progress
$items[$i]->progress = isset($progress[$item->id]) ? $progress[$item->id] : 0;
// Inject attached files
$items[$i]->attachments = isset($total_files[$item->id]) ? $total_files[$item->id] : 0;
}
return $items;
}
示例7: getItems
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (isset($this->cache[$store])) {
return $this->cache[$store];
}
// Load the items
$items = array();
$count = (int) $this->getState('list.count_elements');
$parent = (int) $this->getState('filter.parent_id', 1);
$dir = $this->getInstance('Directory', 'PFrepoModel', $config = array('ignore_request' => true));
if ($parent == 1) {
// Load the list items.
$query = $this->_getListQuery();
try {
$items['directory'] = $dir->getItem($parent);
$items['directories'] = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));
$items['notes'] = array();
$items['files'] = array();
if ($count) {
$pks = JArrayHelper::getColumn($items['directories'], 'id');
$elements = $this->getElementCount($pks);
}
foreach ($items['directories'] as $item) {
$item->element_count = $count ? $elements[$item->id] : 0;
$item->orphaned = empty($item->project_exists);
}
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
} else {
// Get the models
$dirs = $this->getInstance('Directories', 'PFrepoModel', $config = array());
$notes = $this->getInstance('Notes', 'PFrepoModel', $config = array());
$files = $this->getInstance('Files', 'PFrepoModel', $config = array());
// Get the data
try {
$items['directory'] = $dir->getItem($parent);
$items['directories'] = $dirs->getItems();
$items['notes'] = $notes->getItems();
$items['files'] = $files->getItems();
} catch (RuntimeException $e) {
$this->setError($e->getMessage());
return false;
}
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
示例8: generateLayout
public function generateLayout(&$article, &$params, $dispatcher)
{
if ($template = TZ_Portfolio_PlusTemplate::getTemplate(true)) {
$tplparams = $template->params;
if ($tplparams->get('use_single_layout_builder', 1)) {
$core_types = TZ_Portfolio_PlusPluginHelper::getCoreContentTypes();
$this->core_types = JArrayHelper::getColumn($core_types, 'value');
$this->_generateLayout($article, $params, $dispatcher);
return $this->generateLayout;
}
}
return false;
}
示例9: search
/**
* Method to display a search view.
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function search()
{
$sphinx_search_model = $this->getModel('Search', 'CatalogueModel');
$result = $sphinx_search_model->getItems();
$app = JFactory::getApplication('site');
$jinput = $app->input;
$category_id = $jinput->get('cid');
$ids = JArrayHelper::getColumn($result, 'id');
$app->setUserState('com_catalogue.category.' . $category_id . '.filter.sphinx_ids', $ids);
/*
* $result = array('result' => array('total' => count($ids)));
* echo json_encode($result);
* $app->close();
*/
$this->display();
}
示例10: getContentTypes
public static function getContentTypes()
{
if ($core_types = self::getCoreContentTypes()) {
$types = JArrayHelper::getColumn($core_types, 'value');
$includeTypes = $core_types;
$dispatcher = JEventDispatcher::getInstance();
if ($contentPlugins = self::importPlugin('content')) {
if ($pluginTypes = $dispatcher->trigger('onAddContentType')) {
foreach ($pluginTypes as $i => $plgType) {
if (is_array($plgType) && count($plgType)) {
foreach ($plgType as $j => $type) {
if (in_array($type->value, $types)) {
unset($pluginTypes[$i][$j]);
}
}
} else {
if (in_array($plgType->value, $types)) {
unset($pluginTypes[$i]);
}
}
}
$includeTypes = array_merge($includeTypes, $pluginTypes);
return $includeTypes;
}
}
return $core_types;
}
return false;
}
示例11: buildQuery
//.........这里部分代码省略.........
// $$$ rob if no ordering applied i had results where main record (e.g. UK) was shown in 2 lines not next to each other
// causing them not to be merged and a 6 rows shown when limit set to 5. So below, if no order by set then order by main pk asc
$by = trim($table->order_by) === '' ? array() : (array) json_decode($table->order_by);
if (empty($by)) {
$dir = (array) json_decode($table->order_dir);
array_unshift($dir, 'ASC');
$table->order_dir = json_encode($dir);
$by = (array) json_decode($table->order_by);
array_unshift($by, $table->db_primary_key);
$table->order_by = json_encode($by);
}
// $$$ rob build order first so that we know of any elements we need to include in the select statement
$query = $this->buildQueryOrder($query);
$this->selectedOrderFields = (array) $this->selectedOrderFields;
$this->selectedOrderFields = array_unique(array_merge($lookUps, $this->selectedOrderFields));
$query->select(implode(', ', $this->selectedOrderFields) . ' FROM ' . $db->qn($table->db_table_name));
$query = $this->buildQueryJoin($query);
$query = $this->buildQueryWhere($input->get('incfilters', 1), $query);
$query = $this->buildQueryGroupBy($query);
// Can't limit the query here as this gives incorrect _data array.
// $db->setQuery($query, $this->limitStart, $this->limitLength);
$db->setQuery($query);
FabrikHelperHTML::debug((string) $query, 'table:mergeJoinedData get ids');
$ids = array();
$idRows = $db->loadObjectList();
$maxPossibleIds = count($idRows);
// An array of the lists pk values
$mainKeys = array();
foreach ($idRows as $r) {
$mainKeys[] = $db->q($r->__pk_val0);
}
// Chop up main keys for list limitstart, length to cull the data down to the correct length as defined by the page nav/ list settings
$mainKeys = array_unique($mainKeys);
if ($this->limitLength > 0) {
$mainKeys = array_slice($mainKeys, $this->limitStart, $this->limitLength);
}
/**
* $$$ rob get an array containing the PRIMARY key values for each joined tables data.
* Stop as soon as we have a set of ids totaling the sum of records contained in $idRows
*/
while (count($ids) < $maxPossibleIds && $lookupC >= 0) {
$ids = JArrayHelper::getColumn($idRows, '__pk_val' . $lookupC);
for ($idx = count($ids) - 1; $idx >= 0; $idx--) {
if ($ids[$idx] == '') {
unset($ids[$idx]);
} else {
$ids[$idx] = $db->q($ids[$idx]);
}
}
if (count($ids) < $maxPossibleIds) {
$lookupC--;
}
}
}
// Now lets actually construct the query that will get the required records:
$query->clear();
unset($this->orderBy);
$query = $this->buildQuerySelect('list', $query);
JDEBUG ? $profiler->mark('queryselect: got') : null;
$query = $this->buildQueryJoin($query);
JDEBUG ? $profiler->mark('queryjoin: got') : null;
if ($this->mergeJoinedData()) {
/* $$$ rob We've already used buildQueryWhere to get our list of main pk ids.
* so lets use that list of ids to create the where statement. This will return 5/10/20 etc
* records from our main table, as per our page nav, even if a main record has 3 rows of joined
* data. If no ids found then do where "2 = -2" to return no records (was "1 = -1", changed to make
* it easier to know where this is coming form when debugging)
*/
if (!empty($ids)) {
if ($lookUpNames[$lookupC] !== $table->db_primary_key) {
$query->where($lookUpNames[$lookupC] . ' IN (' . implode(array_unique($ids), ',') . ')');
}
if (!empty($mainKeys)) {
// Limit to the current page
$query->where($table->db_primary_key . ' IN (' . implode($mainKeys, ',') . ')');
} else {
$query->where('2 = -2');
}
} else {
$query->where('2 = -2');
}
} else {
// $$$ rob we aren't merging joined records so lets just add the standard where query
// Incfilters set when exporting as CSV
$query = $this->buildQueryWhere($input->get('incfilters', 1), $query);
}
$query = $this->buildQueryGroupBy($query);
$query = $this->buildQueryOrder($query);
$query = $this->pluginQuery($query);
$this->mainQuery = $query;
/*
$params = $this->getParams();
if ($params->get('force_collate', '') !== '')
{
$query .= ' COLLATE ' . $params->get('force_collate', '') . ' ';
}
*/
return (string) $query;
}
示例12: onSaveArticleFieldValue
public function onSaveArticleFieldValue($value)
{
if (!$this->article_id) {
return false;
}
$_value = $this->prepareFieldValue($value);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$result = true;
$table_name = '#__tz_portfolio_plus_field_content_map';
$query->select('m.*');
$query->from($table_name . ' AS m');
$query->where('m.fieldsid = ' . $this->id);
$query->where('m.contentid = ' . $this->article_id);
$db->setQuery($query);
$countData = $db->loadResult();
if ($countData > 0) {
if ($groupid = TZ_Portfolio_PlusFrontHelperExtraFields::getFieldGroupsByArticleId($this->article_id)) {
$groupid = JArrayHelper::getColumn($groupid, 'id');
if (count($groupid)) {
$query->join('INNER', '#__tz_portfolio_plus_field_fieldgroup_map AS fm ON fm.fieldsid = m.fieldsid');
$query->where('fm.groupid IN(' . implode(',', $groupid) . ')');
}
}
$db->setQuery($query);
$countGData = $db->loadResult();
$query->clear();
if ($_value !== "" && !is_null($_value) && $countGData > 0) {
$query->update($table_name);
$query->set('value = ' . $db->quote($_value));
$query->where('fieldsid = ' . $this->id);
$query->where('contentid = ' . $this->article_id);
$db->setQuery($query);
$result = $db->execute();
} else {
$query->delete($table_name);
$query->where('fieldsid = ' . $this->id);
$query->where('contentid = ' . $this->article_id);
$db->setQuery($query);
$result = $db->execute();
}
} else {
if ($_value !== "" && !is_null($_value)) {
$query->clear();
$query->insert($table_name);
$query->columns('fieldsid, contentid, value, ordering');
$query->values($this->id . ',' . $this->article_id . ',' . $db->quote($_value) . ', 0');
$db->setQuery($query);
$result = $db->execute();
}
}
return $result;
}
示例13: getItems
/**
* Method to get a list of items.
* Overriden to inject convert the attribs field into a JParameter object.
*
* @return mixed $items An array of objects on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
$labels = $this->getInstance('Labels', 'PFModel');
$tasks_exists = PFApplicationHelper::enabled('com_pftasks');
$pks = JArrayHelper::getColumn($items, 'id');
// Get aggregate data
$progress = array();
$total_tasks = array();
$completed_tasks = array();
if ($tasks_exists) {
JLoader::register('PFtasksModelTasks', JPATH_SITE . '/components/com_pftasks/models/tasks.php');
$tmodel = JModelLegacy::getInstance('Tasks', 'PFtasksModel', array('ignore_request' => true));
$progress = $tmodel->getAggregatedProgress($pks, 'milestone_id');
$total_tasks = $tmodel->getAggregatedTotal($pks, 'milestone_id');
$completed_tasks = $tmodel->getAggregatedTotal($pks, 'milestone_id', 1);
}
foreach ($items as $i => &$item) {
// Convert the parameter fields into objects.
$params = new JRegistry();
$params->loadString($item->attribs);
$items[$i]->params = clone $this->getState('params');
// Create slugs
$items[$i]->slug = $items[$i]->alias ? $items[$i]->id . ':' . $items[$i]->alias : $items[$i]->id;
$items[$i]->project_slug = $items[$i]->project_alias ? $items[$i]->project_id . ':' . $items[$i]->project_alias : $items[$i]->project_id;
// Get the labels
if ($items[$i]->label_count > 0) {
$items[$i]->labels = $labels->getConnections('com_pfmilestones.milestone', $items[$i]->id);
}
if (!isset($items[$i]->watching)) {
$items[$i]->watching = 0;
}
// Inject task count
$items[$i]->tasks = isset($total_tasks[$item->id]) ? $total_tasks[$item->id] : 0;
// Inject completed task count
$items[$i]->completed_tasks = isset($completed_tasks[$item->id]) ? $completed_tasks[$item->id] : 0;
// Inject progress
$items[$i]->progress = isset($progress[$item->id]) ? $progress[$item->id] : 0;
}
return $items;
}
示例14: getItems
/**
* Method to get a list of items.
* Overriden to inject convert the attribs field into a JParameter object.
*
* @return mixed $items An array of objects on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
$labels = $this->getInstance('Labels', 'PFModel');
// Get the global params
$global_params = JComponentHelper::getParams('com_pfforum', true);
$null_date = JFactory::getDbo()->getNullDate();
// Get reply count
$pks = JArrayHelper::getColumn($items, 'id');
$replies = $this->getReplyCount($pks);
foreach ($items as $i => &$item) {
// Convert the parameter fields into objects.
$params = new JRegistry();
$params->loadString($item->attribs);
$items[$i]->params = clone $this->getState('params');
// Create slugs
$items[$i]->slug = $items[$i]->alias ? $items[$i]->id . ':' . $items[$i]->alias : $items[$i]->id;
$items[$i]->project_slug = $items[$i]->project_alias ? $items[$i]->project_id . ':' . $items[$i]->project_alias : $items[$i]->project_id;
// Reply count
$item->replies = $replies[$item->id];
// Get the labels
if ($items[$i]->label_count > 0) {
$items[$i]->labels = $labels->getConnections('com_pfforum.topic', $items[$i]->id);
}
}
return $items;
}
示例15: getSelect2HTML
protected function getSelect2HTML($value, $multiple = false)
{
$access = (int) $this->form->getValue('access');
$pks = JArrayHelper::getColumn($value, 'id');
$html = array();
if (!$access) {
$access = (int) JFactory::getConfig()->get('access');
}
$url = "index.php?option=com_pfusers&view=userref&filter_access=" . $access . "&tmpl=component&layout=select2&format=json";
$html[] = '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . implode(',', $pks) . '" class="inputbox input-large"/>';
$html[] = '<script type="text/javascript">';
$html[] = 'jQuery("#' . $this->id . '").select2({';
$html[] = ' allowClear: true,';
$html[] = ' minimumInputLength: 0,';
$html[] = ' multiple: true,';
$html[] = ' ajax:';
$html[] = ' {';
$html[] = ' url: "' . $url . '",';
$html[] = ' dataType: "json",';
$html[] = ' quietMillis: 200,';
$html[] = ' data: function (term, page)';
$html[] = ' {';
$html[] = ' return {filter_search: term, limit: 10, limitstart: ((page - 1) * 10)};';
$html[] = ' },';
$html[] = ' results: function (data, page)';
$html[] = ' {';
$html[] = ' var more = (page * 10) < data.total;';
$html[] = ' return {results: data.items, more: more};';
$html[] = ' }';
$html[] = ' }';
if (count($pks)) {
$html[] = ' ,initSelection: function(element, callback)';
$html[] = ' {';
$html[] = ' callback(' . $this->getJsonUsers($pks) . ');';
$html[] = ' }';
}
$html[] = '});';
$html[] = '</script>';
return $html;
}