当前位置: 首页>>代码示例>>PHP>>正文


PHP JControllerLegacy::addModelPath方法代码示例

本文整理汇总了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.');
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:13,代码来源:JControllerLegacyTest.php

示例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);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:55,代码来源:controller.php

示例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);
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:17,代码来源:plugin.php

示例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);
 }
开发者ID:irovast,项目名称:eyedock,代码行数:40,代码来源:auto.php


注:本文中的JControllerLegacy::addModelPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。