本文整理汇总了PHP中JModelList类的典型用法代码示例。如果您正苦于以下问题:PHP JModelList类的具体用法?PHP JModelList怎么用?PHP JModelList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JModelList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*
* @since 1.0.0
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $this->state->get('params');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Get payment methods.
$paymentMethods = CMDonationHelper::getPaymentMethods();
// Get campaigns.
$campaigns = JModelList::getInstance('Campaigns', 'CMDonationModel')->getCampaignsForFilter();
// Build campaign options for filter and index for displaying campaign name.
$campaignOptions = array();
$campaignIndex = array();
if (!empty($campaigns)) {
foreach ($campaigns as $campaign) {
$campaignOptions[] = JHtml::_('select.option', $campaign->id, htmlspecialchars($campaign->name));
$campaignIndex[$campaign->id] = $campaign->name;
}
}
$this->assignRef('paymentMethods', $paymentMethods);
$this->assignRef('campaigns', $campaigns);
$this->assignRef('campaignOptions', $campaignOptions);
$this->assignRef('campaignIndex', $campaignIndex);
$this->submenu = CMDonationHelper::addSubmenu('donations');
$this->addToolbar();
parent::display($tpl);
}
示例2: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$jemsettings = JemHelper::config();
# it's needed to set the parent option
parent::populateState('a.dates', 'asc');
}
示例3: __construct
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'lno', 'a.lno', 'labname', 'labname', 'pic', 'a.pic', 'state', 'a.state', 'admin', 'a.admin', 'phone', 'a.phone', 'description', 'a.description');
}
parent::__construct($config);
}
示例4: _getList
/**
* Returns an object list
*
* @param string The query
* @param int Offset
* @param int The number of records
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering');
$search = $this->getState('filter.search');
// Replace slashes so preg_match will work
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
$db->setQuery($query);
$result = $db->loadObjectList();
$lang = JFactory::getLanguage();
$this->translate($result);
if (!empty($search)) {
foreach ($result as $i => $item) {
if (!preg_match("/{$search}/i", $item->name)) {
unset($result[$i]);
}
}
}
JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
} else {
$query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
示例5: __construct
public function __construct(array $config)
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('name', 'brand', 'diameter', 'density', 'number');
}
parent::__construct($config);
}
示例6: __construct
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'businessName');
}
parent::__construct($config);
}
示例7: __construct
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('name', 'f.name', 'id', 'f.id', 'label', 'f.label', 'label', 'f.label', 'tooltip', 'f.tooltip', 'type', 'f.type', 'in_search', 'f.in_search', 'search_type', 'f.search_type', 'published', 'f.published');
}
parent::__construct($config);
}
示例8: __construct
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('file_id', 'a.file_id', 'file_title', 'a.file_title', 'file_alias', 'a.file_alias', 'description, a.description', 'description_long', 'a.description_long', 'file_pic', 'a.file_pic', 'images', 'a.images', 'price', 'a.price', 'release', 'a.release', 'file_language', 'a.file_language', 'system', 'a.system', 'license', 'a.license', 'url_license', 'a.url_license', 'size', 'a.size', 'date_added', 'a.date_added', 'file_date', 'a.file_date', 'publish_from', 'a.publish_from', 'publish_to', 'a.publish_to', 'use_timeframe', 'a.use_timeframe', 'url_download', 'a.url_download', 'preview_filename', 'a.preview_filename', 'other_file_id', 'a.other_file_id', 'md5_value', 'a.md5_value', 'sha1_value', 'a.sha1_value', 'extern_file', 'a.extern_file', 'extern_site', 'a.extern_site', 'mirror_1', 'a.mirror_1', 'mirror_2', 'a.mirror_2', 'extern_site_mirror-1', 'a.extern_site_mirror_1', 'extern_site_mirror_2', 'a.extern_site_mirror_2', 'url_home', 'a.url_home', 'author', 'a.author', 'url_author', 'a.url_author', 'created_id', 'a.created_id', 'created_mail', 'a.created_mail', 'modified_id', 'a.modified_id', 'modified_date', 'a.modified_date', 'submitted_by', 'a.submitted_by', 'set_aup_points', 'a.set_aup_points', 'downloads', 'a.downloads', 'cat_id', 'a.cat_id', 'category_title', 'changelog', 'a.changelog', 'password', 'a.password', 'password_md5', 'a.password_md5', 'views', 'a.views', 'metakey', 'a.metakey', 'metadesc', 'a.metadesc', 'robots', 'a.robots', 'update_active', 'a.update_active', 'custom_field_1', 'a.custom_field_1', 'custom_field_2', 'a.custom_field_2', 'custom_field_3', 'a.custom_field_3', 'custom_field_4', 'a.custom_field_4', 'custom_field_5', 'a.custom_field_5', 'custom_field_6', 'a.custom_field_6', 'custom_field_7', 'a.custom_field_7', 'custom_field_8', 'a.custom_field_8', 'custom_field_9', 'a.custom_field_9', 'custom_field_10', 'a.custom_field_10', 'custom_field_11', 'a.custom_field_11', 'custom_field_12', 'a.custom_field_12', 'custom_field_13', 'a.custom_field_13', 'custom_field_14', 'a.custom_field_14', 'access', 'a.access', 'access_level', 'language', 'a.language', 'ordering', 'a.ordering', 'published', 'a.published', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time');
}
parent::__construct($config);
}
示例9: _getList
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering', 'ordering');
if (in_array($ordering, array('pages', 'name'))) {
$this->_db->setQuery($query);
$result = $this->_db->loadObjectList();
$this->translate($result);
$lang = JFactory::getLanguage();
JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
} else {
if ($ordering == 'ordering') {
$query->order('position ASC');
}
$query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
if ($ordering == 'position') {
$query->order('ordering ASC');
}
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
示例10: __construct
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array();
}
parent::__construct($config);
}
示例11: getItems
/**
* Method to get an array of data items.
*
* @return array An array of data items
*
* @since 12.2
*/
public function getItems()
{
JDeveloperLoader::import("archive");
$extension = JTable::getInstance("Extension", "JTable");
// Get a storage key.
$store = $this->getStoreId('getItems');
// Load the list items.
$items = parent::getItems();
// Add information
foreach ($items as $item) {
// Is Component already installed?
$item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("mod_", $item->name, $item->version);
$item->installed = JDeveloperInstall::isInstalled("module", "mod_" . $item->name);
if ($item->installed) {
$extension->load(array("name" => "mod_" . $item->name, "type" => "module"));
$item->enabled = (bool) $extension->enabled;
} else {
$item->enabled = false;
}
}
// If emtpy or an error, just return.
if (empty($items)) {
return array();
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
示例12: populateState
/**
* Autopopulate the model
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication('administrator');
$data = JRequest::getVar('filters');
if (empty($data)) {
$data = array();
$data['select'] = $app->getUserState('com_localise.select');
$data['search'] = $app->getUserState('com_localise.translations.search');
} else {
$app->setUserState('com_localise.select', $data['select']);
$app->setUserState('com_localise.translations.search', isset($data['search']) ? $data['search'] : '');
}
$this->setState('filter.search', isset($data['search']['expr']) ? $data['search']['expr'] : '');
$this->setState('filter.storage', isset($data['select']['storage']) ? $data['select']['storage'] : '');
$this->setState('filter.origin', isset($data['select']['origin']) ? $data['select']['origin'] : '');
$this->setState('filter.state', isset($data['select']['state']) ? $data['select']['state'] : '');
$this->setState('filter.type', isset($data['select']['type']) ? $data['select']['type'] : '');
$this->setState('filter.client', isset($data['select']['client']) ? $data['select']['client'] : '');
$this->setState('filter.tag', isset($data['select']['tag']) ? $data['select']['tag'] : '');
$params = JComponentHelper::getParams('com_localise');
$this->setState('params', $params);
$reference = $params->get('reference', 'en-GB');
$this->setState('translations.reference', $reference);
// Call auto-populate parent method
parent::populateState('filename', 'asc');
}
示例13: getItems
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Get the list of items from the database.
$items = parent::getItems();
$client = JApplicationHelper::getClientInfo($this->getState('stfilter.client_id', 0));
$lang = JFactory::getLanguage();
// Loop through the results to add the XML metadata,
// and load language support.
foreach ($items as &$item) {
$path = JPath::clean($client->path . '/modules/' . $item->module . '/' . $item->module . '.xml');
if (file_exists($path)) {
$item->xml = simplexml_load_file($path);
} else {
$item->xml = null;
}
// 1.5 Format; Core files or language packs then
// 1.6 3PD Extension Support
$lang->load($item->module . '.sys', $client->path, null, false, true) || $lang->load($item->module . '.sys', $client->path . '/modules/' . $item->module, null, false, true);
$item->name = JText::_($item->name);
if (isset($item->xml) && ($text = trim($item->xml->description))) {
$item->desc = JText::_($text);
} else {
$item->desc = JText::_('COM_MODULES_NODESCRIPTION');
}
}
$items = JArrayHelper::sortObjects($items, 'name', 1, true, true);
// TODO: Use the cached XML from the extensions table?
return $items;
}
示例14: getStoreId
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.category');
return parent::getStoreId($id);
}
示例15: __construct
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JControllerLegacy
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array('id', 'a.id', 'tdate', 'a.tdate', 'sport', 's.sport', 'method', 'a.method', 'description', 'a.description', 'comment', 'a.comment', 'location', 'a.location');
}
parent::__construct($config);
}