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


PHP JForm::getMessage方法代码示例

本文整理汇总了PHP中JForm::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::getMessage方法的具体用法?PHP JForm::getMessage怎么用?PHP JForm::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JForm的用法示例。


在下文中一共展示了JForm::getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preprocessForm

 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     $lang = JFactory::getLanguage();
     $component = $this->getState('category.component');
     $section = $this->getState('category.section');
     $extension = JFactory::getApplication()->input->get('extension', null);
     // Get the component form if it exists
     $name = 'category' . ($section ? '.' . $section : '');
     // Looking first in the component models/forms folder
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/models/forms/{$name}.xml");
     // Old way: looking in the component folder
     if (!file_exists($path)) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/{$name}.xml");
     }
     if (file_exists($path)) {
         $lang->load($component, JPATH_BASE, null, false, true);
         $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, true);
         if (!$form->loadFile($path, false)) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $component);
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/helpers/category.php");
     if (file_exists($path)) {
         require_once $path;
         $cName = ucfirst($eName) . ucfirst($section) . 'HelperCategory';
         if (class_exists($cName) && is_callable(array($cName, 'onPrepareForm'))) {
             $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, $lang->getDefault(), false, false);
             call_user_func_array(array($cName, 'onPrepareForm'), array(&$form));
             // Check for an error.
             if ($form instanceof Exception) {
                 $this->setError($form->getMessage());
                 return false;
             }
         }
     }
     // Set the access control rules field component value.
     $form->setFieldAttribute('rules', 'component', $component);
     $form->setFieldAttribute('rules', 'section', $name);
     // Association category items
     $assoc = $this->getAssoc();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_category');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('extension', $extension);
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
开发者ID:ajodochus,项目名称:joomlaForDocker,代码行数:86,代码来源:category.php

示例2: preprocessForm

 /**
  * Method to preprocess the form.
  *
  * @param   JForm   $form    A JForm object.
  * @param   mixed   $data    The data expected for the form.
  * @param   string  $groups  The name of the plugin group to import.
  *
  * @return  void
  *
  * @see     JFormField
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     // Initialise variables.
     $lang = JFactory::getLanguage();
     $extension = $this->getState('category.extension');
     $component = $this->getState('category.component');
     $section = $this->getState('category.section');
     // Get the component form if it exists
     jimport('joomla.filesystem.path');
     $name = 'category' . ($section ? '.' . $section : '');
     // Looking first in the component models/forms folder
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/models/forms/{$name}.xml");
     // Old way: looking in the component folder
     if (!file_exists($path)) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/{$name}.xml");
     }
     if (file_exists($path)) {
         $lang->load($component, JPATH_BASE, null, false, false);
         $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false);
         if (!$form->loadFile($path, false)) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Try to find the component helper.
     $eName = str_replace('com_', '', $component);
     $path = JPath::clean(JPATH_ADMINISTRATOR . "/components/{$component}/helpers/category.php");
     if (file_exists($path)) {
         require_once $path;
         $cName = ucfirst($eName) . ucfirst($section) . 'HelperCategory';
         if (class_exists($cName) && is_callable(array($cName, 'onPrepareForm'))) {
             $lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPATH_BASE . '/components/' . $component, $lang->getDefault(), false, false);
             call_user_func_array(array($cName, 'onPrepareForm'), array(&$form));
             // Check for an error.
             if ($form instanceof Exception) {
                 $this->setError($form->getMessage());
                 return false;
             }
         }
     }
     // Set the access control rules field component value.
     $form->setFieldAttribute('rules', 'component', $component);
     $form->setFieldAttribute('rules', 'section', $name);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:59,代码来源:category.php


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