本文整理汇总了PHP中JControllerLegacy::addModelPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JControllerLegacy::addModelPath方法的具体用法?PHP JControllerLegacy::addModelPath怎么用?PHP JControllerLegacy::addModelPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JControllerLegacy
的用法示例。
在下文中一共展示了JControllerLegacy::addModelPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddModelPath
/**
* @testdox Ensure addModelPath() adds a model path to the internal array
*
* @covers JControllerLegacy::addModelPath
*/
public function testAddModelPath()
{
$path = JPath::clean(JPATH_ROOT . '/addmodelpath');
JControllerLegacy::addModelPath($path);
// The default path is the class file folder/forms
$valid = JPATH_PLATFORM . '/joomla/form/fields';
$this->assertTrue(in_array($path, JModelLegacy::addIncludePath()), 'Line:' . __LINE__ . ' The path should be added to the JModel paths.');
}
示例2: quickAddAjax
/**
* An ajax connector for QuickAdd JS.
*/
public function quickAddAjax()
{
// Init Variables
$input = JFactory::getApplication()->input;
$data = $input->post->get($input->get('formctrl'), array(), 'array');
$result = new JRegistry();
$result->set('Result', false);
$model_name = $input->get('model_name');
$component = $input->get('component');
$extension = $input->get('extension');
// Include Needed Classes
JControllerLegacy::addModelPath(JPATH_BASE . "/components/com_{$component}/models");
JForm::addFormPath(JPATH_BASE . "/components/com_{$component}/models/forms");
JForm::addFieldPath(JPATH_BASE . "/components/com_{$component}/models/fields");
JTable::addIncludePath(JPATH_BASE . "/components/com_{$component}/tables");
AKHelper::_('lang.loadLanguage', $extension, null);
// Get Model
$model = $this->getModel(ucfirst($model_name), ucfirst($component) . 'Model', array('ignore_request' => true));
// For WindWalker Component only
if (is_callable(array($model, 'getFieldsName'))) {
$fields_name = $model->getFieldsName();
$data = AKHelper::_('array.pivotToTwoDimension', $data, $fields_name);
}
// Get Form
$form = $model->getForm($data, false);
if (!$form) {
$result->set('errorMsg', $model->getError());
jexit($result);
}
// Test whether the data is valid.
$validData = $model->validate($form, $data);
// Check for validation errors.
if ($validData === false) {
// Get the validation messages.
$errors = $model->getErrors();
$errorMsg = is_string($errors[0]) ? $errors[0] : $errors[0]->getMessage();
$result->set('errorMsg', $errorMsg);
jexit($result);
}
// Do Save
if (!$model->save($validData)) {
// Return Error Message.
$result->set('errorMsg', JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()));
jexit($result);
}
// Set ID
$data['id'] = $model->getstate($model_name . '.id');
// Set Result
$result->set('Result', true);
$result->set('data', $data);
jexit($result);
}
示例3: saveSettings
/**
*
* @param type $params
*/
public static function saveSettings($params)
{
$oPlugin = JchPlatformPlugin::getPlugin();
$oPlugin->params = $params->toArray();
$oData = new JRegistry($oPlugin);
$aData = $oData->toArray();
$oController = new JControllerLegacy();
$oController->addModelPath(JPATH_ADMINISTRATOR . '/components/com_plugins/models', 'PluginsModel');
$oPluginModel = $oController->getModel('Plugin', 'PluginsModel');
if ($oPluginModel->save($aData) === FALSE) {
JchOptimizeLogger::log(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $oPluginModel->getError()), $params);
}
}
示例4: orderPlugins
/**
*
* @return type
*/
protected function orderPlugins()
{
$aOrder = array('jscsscontrol', 'eorisis_jquery', 'jqueryeasy', 'jch_optimize', 'plugin_googlemap3', 'cdnforjoomla', 'bigshotgoogleanalytics', 'GoogleAnalytics', 'jat3', 'cache', 'jSGCache', 'jotcache', 'vmcache_last');
$aPlugins = $this->getPlugins();
$aLowerPlugins = array_values(array_filter($aOrder, function ($aVal) use($aPlugins) {
return array_key_exists($aVal, $aPlugins);
}));
$iNoPlugins = count($aPlugins);
$iNoLowerPlugins = count($aLowerPlugins);
$iBaseOrder = $iNoPlugins - $iNoLowerPlugins;
$cid = array();
$order = array();
foreach ($aPlugins as $key => $value) {
if (in_array($key, $aLowerPlugins)) {
$value['ordering'] = $iBaseOrder + 1 + array_search($key, $aLowerPlugins);
} elseif ($value['ordering'] >= $iBaseOrder) {
$value['ordering'] = $iBaseOrder - 1;
}
$cid[] = $value['extension_id'];
$order[] = $value['ordering'];
}
JArrayHelper::toInteger($cid);
JArrayHelper::toInteger($order);
$aOrder = array();
$aOrder['cid'] = $cid;
$aOrder['order'] = $order;
$oController = new JControllerLegacy();
$oController->addModelPath(JPATH_ADMINISTRATOR . '/components/com_plugins/models', 'PluginsModel');
$oPluginModel = $oController->getModel('Plugin', 'PluginsModel');
if ($oPluginModel->saveorder($aOrder['cid'], $aOrder['order']) === FALSE) {
$oController->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $oPluginModel->getError()), 'error');
} else {
$oController->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'));
}
$this->display($oController);
}