本文整理汇总了PHP中JModelList::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelList::getInstance方法的具体用法?PHP JModelList::getInstance怎么用?PHP JModelList::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelList
的用法示例。
在下文中一共展示了JModelList::getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: display
/**
* Display the view
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$model = JModelList::getInstance('Domains', 'JNotificationModel');
$this->domains = $model->getItems();
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
示例3: filterByDate
function filterByDate()
{
$jinput = JFactory::getApplication()->input;
$fromDate = $jinput->getVar('fromDate');
$toDate = $jinput->getVar('toDate');
if ($fromDate == null || $toDate == null) {
$view = $this->getView('credits', 'html', 'qikeyview');
$view->display(null, null, "error");
} else {
$model = JModelList::getInstance('credits', 'QikeyModel');
$completedLessons = $model->getCompletedLessons($fromDate, $toDate);
$view = $this->getView('credits', 'html', 'qikeyview');
$view->display(null, $completedLessons, null);
}
}
示例4: display
function display($tpl = null, $filteredLessons = null, $errors = null)
{
// Assign data to the view
$this->msg = 'Credit Page';
$this->currentDate = new JDate('now');
$this->currentDate = $this->currentDate->format('Y-m-d', false, false);
$model = JModelList::getInstance('Credits', 'QikeyModel');
$this->profile = $model->getProfile();
if ($filteredLessons == null) {
$this->completedLessons = $model->getCompletedLessons();
if ($errors !== null) {
JFactory::getApplication()->enqueueMessage('Please Choose both a From and To date', 'notice');
}
} else {
$this->completedLessons = $filteredLessons;
}
$this->pagination = $model->getPagination();
//$this->assignRef( 'pagination', $pagination );
// Display the view
parent::display($tpl);
}
示例5: getOptions
protected function getOptions()
{
$options = array();
$model = JModelList::getInstance('Groups', 'TZ_Portfolio_PlusModel', array('ignore_request' => true));
// $model -> setState('filter.published','*');
if ($items = $model->getItems()) {
foreach ($items as $i => $item) {
$options[$i] = new stdClass();
$options[$i]->value = $item->id;
// if ($item -> published == 1)
// {
$options[$i]->text = $item->name;
// }
// else
// {
// $options[$i] -> text = '[' .$item -> title . ']';
// }
}
}
return array_merge(parent::getOptions(), $options);
}
示例6: display
/**
* Log view display method
* @return void
*/
function display($tpl = null)
{
// Load the items to display
$this->logmessage = $this->get('Items');
$this->setModel(JModelList::getInstance('log', 'CsviModel'));
$this->logresult = $this->get('Stats', 'log');
// Load the pagination
$this->pagination = $this->get('Pagination');
// Load the user state
$this->state = $this->get('State');
// Set the Run ID
$jinput = JFactory::getApplication()->input;
$this->run_id = $jinput->get('run_id', 0, 'int');
// Set the actions
$this->list['actions'] = $this->get('Actions');
$this->list['results'] = $this->get('Results');
// Get the panel
$this->loadHelper('panel');
// Add toolbar
JToolBarHelper::title(JText::_('COM_CSVI_LOG_DETAILS'), 'csvi_logdetails_48');
JToolBarHelper::custom('logdetails.cancel', 'csvi_cancel_32', 'csvi_cancel_32', JText::_('COM_CSVI_BACK'), false);
// Display it all
parent::display($tpl);
}
示例7: export_filtered
public function export_filtered($cid = array())
{
if (!JSession::checkToken('post') && !JSession::checkToken('get')) {
jexit('COM_DJCATALOG2_INVALID_TOKEN');
}
$app = JFactory::getApplication();
$task = $this->getTask();
$path = JPATH_ROOT . DS . 'media' . DS . 'djcatalog2' . DS . 'export' . DS . 'item';
if (!JFolder::exists($path)) {
JFolder::create($path);
}
if (!is_writable($path)) {
$this->setRedirect('index.php?option=com_djcatalog2&view=items', JText::_('COM_DJCATALOG2_FOLDER_NOT_WRITABLE') . ' ' . $path, 'error');
return false;
}
$enclosure = "\"";
$separator = ",";
$newline = PHP_EOL;
$user = JFactory::getUser();
if (!$user->authorise('core.manage', 'com_djcatalog2')) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
$this->setMessage($this->getError(), 'error');
$this->setRedirect('index.php?option=com_djcatalog2&view=items');
return false;
}
jimport('joomla.application.component.modellist');
$model = JModelList::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
$state = $model->getState();
$context = 'com_djcatalog2.items';
$start = $app->input->get('start', 0);
$limit = 1000;
$model->setState('list.select', 'a.*, c.name as category_name, p.name as producer_name, uc.name AS author');
if ($task == 'export_selected' && count($cid) > 0) {
$limit = $start = 0;
JArrayHelper::toInteger($cid);
$model->setState('filter.ids', implode(',', $cid));
} else {
$search = $model->getUserStateFromRequest($context . '.filter.search', 'filter_search');
$model->setState('filter.search', $search);
$published = $model->getUserStateFromRequest($context . '.filter.published', 'filter_published', '');
$model->setState('filter.published', $published);
$category = $model->getUserStateFromRequest($context . '.filter.category', 'filter_category', '');
$model->setState('filter.category', $category);
$producer = $model->getUserStateFromRequest($context . '.filter.producer', 'filter_producer', '');
$model->setState('filter.producer', $producer);
}
$model->setState('list.start', $start);
$model->setState('list.limit', $limit);
$params = JComponentHelper::getParams('com_djcatalog2');
$model->setState('params', $params);
$items = $model->getItems();
$db = JFactory::getDbo();
$db->setQuery('SHOW COLUMNS FROM #__djc2_items');
$columns = $db->loadColumn(0);
$columns = array_merge($columns, array('category_name', 'producer_name', 'author'));
$filename = $app->input->get('export_file', 'product-export-' . date("Y-m-d_H-i-s") . '.csv', 'raw');
$fp = fopen($path . DS . $filename, 'a');
if (!empty($columns) && (!$start || $start == 0)) {
fputcsv($fp, $columns, $separator, $enclosure);
}
foreach ($items as $id => $item) {
$itemRow = array();
foreach ($columns as $colname) {
if (!empty($items[$id]->{$colname})) {
$itemRow[$colname] = $items[$id]->{$colname};
}
if (!isset($itemRow[$colname])) {
$itemRow[$colname] = '';
}
}
fputcsv($fp, $itemRow, $separator, $enclosure);
}
fclose($fp);
$pagination = $model->getPagination();
if ($pagination->get('pages.total') > $pagination->get('pages.current')) {
header("refresh: 0; url=" . JURI::base() . 'index.php?option=com_djcatalog2&task=items.export_filtered&start=' . ($start += $limit) . '&export_file=' . $filename . '&' . JSession::getFormToken() . '=1');
echo '<p>' . $pagination->get('pages.current') . ' / ' . $pagination->get('pages.total') . '</p>';
} else {
//header("refresh: 0; url=".JURI::base().'index.php?option=com_djcatalog2&view=items');
$file_link = '<a href="' . JRoute::_('index.php?option=com_djcatalog2&task=download_file&path=' . base64_encode('media/djcatalog2/export/item/' . $filename)) . '">' . $filename . '</a>';
$this->setRedirect('index.php?option=com_djcatalog2&view=items', JText::_('COM_DJCATALOG2_EXPORT_SUCCESFULL') . ' ' . $file_link);
}
return true;
}
示例8: getModel
/**
* Proxy for getModel
*
* @copyright
* @author RolandD
* @todo
* @see
* @access public
* @param
* @return object of a database model
* @since 4.0
*/
public function getModel($name = 'AvailableFields', $prefix = 'CsviModel')
{
$model = JModelList::getInstance($name, $prefix, array('ignore_request' => true));
return $model;
}