本文整理汇总了PHP中JModel::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JModel::getInstance方法的具体用法?PHP JModel::getInstance怎么用?PHP JModel::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModel
的用法示例。
在下文中一共展示了JModel::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// Initialise variables.
$html = array();
$recordId = (int) $this->form->getValue('id');
$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
// Get a reverse lookup of the base link URL to Title
$model = JModel::getInstance('menutypes', 'menusModel');
$rlu = $model->getReverseLookup();
switch ($this->value) {
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
default:
$link = $this->form->getValue('link');
// Clean the link back to the option, view and layout
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
break;
}
// Load the javascript and css
JHtml::_('behavior.framework');
JHtml::_('behavior.modal');
$html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
$html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />';
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
return implode("\n", $html);
}
示例2: addEvForm
function addEvForm()
{
$listid = JRequest::getInt('listid');
$viewName = 'calendar';
$usersConfig = JComponentHelper::getParams('com_fabrik');
$model =& $this->getModel($viewName);
$id = JRequest::getInt('visualizationid', $usersConfig->get('visualizationid', 0));
$model->setId($id);
$model->setupEvents();
if (array_key_exists($listid, $model->_events)) {
$datefield = $model->_events[$listid][0]['startdate'];
} else {
$config = JFactory::getConfig();
$prefix = $config->getValue('config.dbprefix');
$datefield = $prefix . 'fabrik_calendar_events___start_date';
}
$rowid = JRequest::getInt('rowid');
$listModel = JModel::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$table = $listModel->getTable();
JRequest::setVar('view', 'form');
JRequest::setVar('formid', $table->form_id);
JRequest::setVar('tmpl', 'component');
JRequest::setVar('ajax', '1');
$link = 'index.php?option=com_fabrik&view=form&formid=' . $table->form_id . '&rowid=' . $rowid . '&tmpl=component&ajax=1';
$link .= '&jos_fabrik_calendar_events___visualization_id=' . JRequest::getInt('jos_fabrik_calendar_events___visualization_id');
$start_date = JRequest::getVar('start_date', '');
if (!empty($start_date)) {
$link .= "&{$datefield}=" . $start_date;
}
// $$$ rob have to add this to stop the calendar filtering itself after adding an new event?
$link .= '&clearfilters=1';
$this->setRedirect($link);
}
示例3: _getField
private function _getField()
{
$i = 0;
$html = '';
$customfields = $this->form->getValue('customfield', 'params');
$customfields = $customfields['joomla'];
jimport('joomla.application.component.model');
JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_categories' . DS . 'models', 'categories');
$model = JModel::getInstance('Categories', 'CategoriesModel', array('ignore_request' => true));
$model->setState('list.limit', '200');
$model->setState('filter.extension', 'com_content');
$mitems = $model->getItems();
$children = array();
if ($mitems) {
foreach ($mitems as $v) {
$v->parent_id = $v->parentid;
$pt = $v->parentid;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$mitems = array();
foreach ($list as $item) {
$item->treename = str_repeat('- ', $item->level - 1) . $item->title;
$mitems[] = JHTML::_('select.option', $item->id, ' ' . $item->treename);
}
$output = JHTML::_('select.genericlist', $mitems, $this->name, 'class="inputbox" multiple="multiple" size="15"', 'value', 'text', $this->value, $this->id);
return $output;
}
示例4: display
function display($tpl = null)
{
$option = JRequest::getCmd('option');
$mainframe = JFactory::getApplication();
$uri = JFactory::getUri();
// Get data from the model
$items = $this->get('Items');
$this->assignRef('items', $items);
foreach ($this->items as $item) {
$item->count_projectdivisions = 0;
$mdlProjectDivisions = JModel::getInstance("divisions", "JoomleagueModel");
$item->count_projectdivisions = $mdlProjectDivisions->getProjectDivisionsCount($item->id);
$item->count_projectpositions = 0;
$mdlProjectPositions = JModel::getInstance("Projectposition", "JoomleagueModel");
$item->count_projectpositions = $mdlProjectPositions->getProjectPositionsCount($item->id);
$item->count_projectreferees = 0;
$mdlProjectReferees = JModel::getInstance("Projectreferees", "JoomleagueModel");
$item->count_projectreferees = $mdlProjectReferees->getProjectRefereesCount($item->id);
$item->count_projectteams = 0;
$mdlProjecteams = JModel::getInstance("Projectteams", "JoomleagueModel");
$item->count_projectteams = $mdlProjecteams->getProjectTeamsCount($item->id);
$item->count_matchdays = 0;
$mdlRounds = JModel::getInstance("Rounds", "JoomleagueModel");
$item->count_matchdays = $mdlRounds->getRoundsCount($item->id);
}
$this->addToolbar();
parent::display($tpl);
}
示例5: doCron
function doCron(&$pluginManager)
{
$db = FabrikWorker::getDbo();
$cid = JRequest::getVar('element_id', array(), 'method', 'array');
$query = $db->getQuery();
$query->select('id, plugin')->from('#__{package}_cron');
if (!empty($cid)) {
$query->where(" id IN (" . implode(',', $cid) . ")");
}
$db->setQuery($query);
$rows = $db->loadObjectList();
$viewModel = JModel::getInstance('view', 'FabrikFEModel');
$c = 0;
foreach ($rows as $row) {
//load in the plugin
$plugin =& $pluginManager->getPlugIn($row->plugin, 'cron');
$plugin->setId($row->id);
$params =& $plugin->getParams();
$thisViewModel = clone $viewModel;
$thisViewModel->setId($params->get('table'));
$table =& $viewModel->getTable();
$total = $thisViewModel->getTotalRecords();
$nav =& $thisViewModel->getPagination($total, 0, $total);
$data = $thisViewModel->getData();
// $$$ hugh - added table model param, in case plugin wants to do further table processing
$c = $c + $plugin->process($data, $thisViewModel);
}
$query = $db->getQuery();
$query->update('#__{package}_cron')->set('lastrun=NOW()')->where("id IN (" . implode(',', $cid) . ")");
$db->setQuery($query);
$db->query();
}
示例6: onValidateSelectShipping
/**
*
* @param array $values The input values from the form
* @return unknown_type
*/
function onValidateSelectShipping($values)
{
$return = new JObject();
$return->error = null;
// boolean
$return->message = null;
// string
if (empty($values['billing_address_id']) && empty($values['billing_input_phone_1'])) {
$return->error = true;
// boolean
$return->message = JText::_('Please Include a Phone Number with Your Billing Address');
// string
}
if (!empty($values['billing_address_id'])) {
// Load the address from the database
$model = JModel::getInstance('Addresses', 'TiendaModel');
$model->setId($values['billing_address_id']);
$address = $model->getItem();
// Does the address have a phone number associated with it?
// if not, what do you want to do?
if (empty($address->phone_1)) {
$return->error = true;
// boolean
$return->message = JText::_('Stored Address Missing Phone Number');
// string
}
}
return $return;
}
示例7: post
public function post()
{
// Set variables to be used
JMHelper::setSessionUser();
JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);
// Include dependencies
jimport('joomla.application.component.controller');
jimport('joomla.form.form');
jimport('joomla.database.table');
JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/tables');
// Get user data
$data = JRequest::getVar('jform', array(), 'post', 'array');
if (!isset($data['groups'])) {
$data['groups'] = array();
}
// Save user
$model = JModel::getInstance('User', 'UsersModel');
$model->getState('user.id');
// This is only here to trigger populateState()
$success = $model->save($data);
if ($model->getError()) {
$response = $this->getErrorResponse(400, $model->getError());
} elseif (!$success) {
$response = $this->getErrorResponse(400, JText::_('COM_JM_ERROR_OCURRED'));
} else {
$response = $this->getSuccessResponse(201, JText::_('COM_JM_SUCCESS'));
$response->id = $model->getState('user.id');
}
$this->plugin->setResponse($response);
}
示例8: getElementModel
/**
* get an element model
* @return object element model
*/
private function getElementModel()
{
if (!isset($this->_elementModel)) {
$this->_elementModel =& JModel::getInstance('element', 'FabrikModel');
}
return $this->_elementModel;
}
示例9: showAdminForm
function showAdminForm()
{
$model = JModel::getInstance('Gateways', 'JTheFactoryModel');
$params = $model->loadGatewayParams($this->name);
jimport('joomla.form.form');
$form = JForm::getInstance($this->name, $this->formxml);
$form->bind($params->toArray());
$fieldsets = $form->getFieldsets();
if (file_exists($this->pluginfolder . DS . 'logo.png')) {
echo "<div style='padding:15px;'><img src='" . $this->getLogo() . "' border='0'></div>";
}
echo "<form name='adminForm' action='index.php' method='post'>";
echo "<input name='option' type='hidden' value='" . APP_EXTENSION . "'>";
echo "<input name='task' type='hidden' value='gateways.save'>";
echo "<input name='classname' type='hidden' value='{$this->name}'>";
if (count($fieldsets)) {
foreach ($fieldsets as $fieldset) {
$fields = $form->getFieldset((string) $fieldset->name);
$this->showFieldSet($fields, (string) $fieldset->name);
}
} else {
$fields = $form->getFieldset();
$this->showFieldSet($fields);
}
echo "</form>";
self::setToolbar();
}
示例10: display
function display($tmpl = 'default')
{
FabrikHelperHTML::packageJS();
$model =& $this->getModel();
$usersConfig =& JComponentHelper::getParams('com_fabrik');
$model->setId(array('id' => JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))), 'package_id' => JRequest::getVar('package_id')));
$visualization =& $model->getVisualization();
$pluginParams =& $model->getPluginParams();
$pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
$plugin =& $pluginManager->getPlugIn($visualization->plugin, 'visualization');
$plugin->_row = $visualization;
if ($visualization->state == 0) {
return JError::raiseWarning(500, JText::_('SORRY THIS VISUALIZATION IS UNPUBLISHED'));
}
//plugin is basically a model
$pluginTask = JRequest::getVar('plugintask', 'render', 'request');
$plugin->_params = $pluginParams;
$tmpl = $plugin->getParams()->get('calendar_layout', $tmpl);
$plugin->{$pluginTask}($this);
$this->plugin =& $plugin;
$viewName = $this->getName();
$this->_setPath('template', $this->_basePath . DS . 'plugins' . DS . $this->_name . DS . $plugin->_name . DS . 'tmpl' . DS . $tmpl);
$ab_css_file = JPATH_SITE . "/components/com_fabrik/plugins/" . $viewName . "/" . $plugin->_name . "/tmpl/{$tmpl}/template.css";
if (file_exists($ab_css_file)) {
JHTML::stylesheet('template.css', 'components/com_fabrik/plugins/' . $viewName . '/' . $plugin->_name . '/tmpl/' . $tmpl . '/', true);
}
$model->getCustomJsAction();
if (isset($this->_isMambot) && $this->_isMambot) {
return $this->loadTemplate();
} else {
parent::display();
}
}
示例11: display
/**
* Displays the view.
*
* @param string $tpl the template name
*
* @return void
* @since 1.0
*/
public function display($tpl = null)
{
JHTML::_('behavior.modal');
$tStyleId = JRequest::getInt('t_style_id');
$modelTemps = JModel::getInstance('Templates', 'NewsletterModel');
$temps = (object) array('items' => $modelTemps->getStandardTemplates(), 'state' => $modelTemps->getState(), 'listOrder' => $modelTemps->getState('list.ordering'), 'listDirn' => $modelTemps->getState('list.direction'));
$this->assignRef('templates', $temps);
$script = $this->get('Script');
$this->script = $script;
$this->tplForm = $this->get('Form', 'template');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal') {
$this->addToolbar();
}
if ($tStyleId > 0) {
$model = $this->getModel();
$template = $model->getTemplateBy($tStyleId);
$this->assign('columns', $model->getColumnPlaceholders($template->content));
$this->assign('tplInfo', (object) $template->information);
$name = $this->tplForm->getValue('template_name');
if (empty($name)) {
$this->tplForm->setValue('template_name', null, $this->escape($this->tplInfo->name));
}
}
parent::display($tpl);
// Set the document
$this->setDocument();
}
示例12: save
function save()
{
$d = JRequest::get('post');
$model = JModel::getInstance('Contact', 'J' . APP_PREFIX . 'PricingModel');
$model->saveItemPrices($d);
$this->setRedirect('index.php?option=' . APP_EXTENSION . '&task=pricing.config&item=' . $this->itemname, JText::_('COM_BIDS_SETTINGS_SAVED'));
}
示例13: saveConfig
public function saveConfig($newParams)
{
$this->_migrateIplookup($newParams);
if (interface_exists('JModel')) {
$params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
} else {
$params = JModel::getInstance('Storage', 'AdmintoolsModel');
}
foreach ($newParams as $key => $value) {
// Do not save unnecessary parameters
if (!array_key_exists($key, $this->defaultConfig)) {
continue;
}
if ($key == 'awayschedule_from' || $key == 'awayschedule_to') {
// Sanity check for Away Schedule time format
if (!preg_match('#^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])$#', $value)) {
$value = '';
}
}
$params->setValue($key, $value);
}
// Dealing with special fields
if (is_array($newParams['reasons_nolog'])) {
$params->setValue('reasons_nolog', implode(',', $newParams['reasons_nolog']));
}
if (is_array($newParams['reasons_noemail'])) {
$params->setValue('reasons_noemail', implode(',', $newParams['reasons_noemail']));
}
$params->save();
}
示例14: showAdminFormParams
function showAdminFormParams($params)
{
JSFactory::loadExtLanguageFile("pm_saferpay");
$orders =& JModel::getInstance('orders', 'JshoppingModel');
//admin model
include dirname(__FILE__) . "/adminparamsform.php";
}
示例15: getInput
/**
* Method to get the field input markup with an image tag.
*
* @return string The field input markup.
*/
protected function getInput()
{
// This Form is used outside of our component, therefor fix the path
JLoader::import('mapicons', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models');
$model = JModel::getInstance('MapIcons', 'SimpleGeoTagModel');
$this->items = $model->getItems();
//var_dump($this->items);
// Add Google Map's js
$doc =& JFactory::getDocument();
/*
$lang = & JFactory::getLanguage();
$langcode = $lang->getTag();
$doc->addScript('http://maps.google.com/maps/api/js?sensor=false&language='.$langcode );
*/
// Add data to javascript array (for image preview)
$js = array();
$js[] = "var mapicons = ";
$js[] = json_encode($this->items);
$js[] = ";\n";
$js[] = "function setMapIcon (val) {\n";
$js[] = "\tvar mapicon = mapicons.filter(function(item, index, arr) { if(item[\"id\"] == val) return true; },val)[0];\n";
$js[] = "\tvar imgtag = \$('jform_metadata_mapicon_img')\n";
$js[] = "\timgtag.src = mapicon['image'];\n";
$js[] = "\timgtag.width = mapicon['size_width'];\n";
$js[] = "\timgtag.height = mapicon['size_height'];\n";
$js[] = "}\n";
$doc->addScriptDeclaration(implode($js));
$this->element['onchange'] = "setMapIcon(this.value)";
$html = parent::getInput();
$this->imgid = $this->id . '_' . $this->imgid;
$html = $html . '<img id="' . $this->imgid . '" src="" />';
return $html;
}