當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JFormHelper類代碼示例

本文整理匯總了PHP中JFormHelper的典型用法代碼示例。如果您正苦於以下問題:PHP JFormHelper類的具體用法?PHP JFormHelper怎麽用?PHP JFormHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JFormHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadField

 /**
  * Method to load, setup and return a JFormField object based on field data.
  *
  * @param   string  $element  The XML element object representation of the form field.
  * @param   string  $group    The optional dot-separated form group path on which to find the field.
  * @param   mixed   $value    The optional value to use as the default for the field.
  *
  * @return  mixed  The JFormField object for the field or boolean false on error.
  *
  * @since   11.1
  */
 protected function loadField($element, $group = null, $value = null)
 {
     // Get the field type.
     $type = $element['type'] ? (string) $element['type'] : 'text';
     // Load the JFormField object for the field.
     /** @var $field JFormField */
     $field = JFormHelper::loadFieldType($type, true);
     // If the object could not be loaded, get a text field object.
     if ($field === false) {
         $field = JFormHelper::loadFieldType('text', true);
     }
     // Get the value for the form field if not set.
     // Default to the translated version of the 'default' attribute
     // if 'translate_default' attribute if set to 'true' or '1'
     // else the value of the 'default' attribute for the field.
     if ($value === null) {
         $default = (string) $element['default'];
         if (($translate = $element['translate_default']) && ((string) $translate == 'true' || (string) $translate == '1')) {
             $lang = JFactory::getLanguage();
             if ($lang->hasKey($default)) {
                 $debug = $lang->setDebug(false);
                 $default = JText::_($default);
                 $lang->setDebug($debug);
             } else {
                 $default = JText::_($default);
             }
         }
     }
     if ($field->setup($element, $value, $group)) {
         return $field;
     } else {
         return false;
     }
 }
開發者ID:networksoft,項目名稱:networksoft.com.co,代碼行數:45,代碼來源:JoomlaFieldWrapper.php

示例2: renderInput

 function renderInput($values = null, $options = array())
 {
     if (!$this->_isCompatible) {
         return '';
     }
     $tags = array();
     if (!empty($values)) {
         foreach ($values as $v) {
             if (is_object($v)) {
                 $tags[] = $v->tag_id;
             } else {
                 $tags[] = (int) $v;
             }
         }
     }
     if (empty($options['name'])) {
         $options['name'] = 'tags';
     }
     if (empty($options['mode'])) {
         $options['mode'] = 'ajax';
     }
     if (!isset($options['class'])) {
         $options['class'] = 'inputbox span12 small';
     }
     if (!isset($options['multiple'])) {
         $options['multiple'] = true;
     }
     $xmlConf = new SimpleXMLElement('<field name="' . $options['name'] . '" type="tag" mode="' . $options['mode'] . '" label="" class="' . $options['class'] . '" multiple="' . ($options['multiple'] ? 'true' : 'false') . '"></field>');
     JFormHelper::loadFieldClass('tag');
     $jform = new JForm('hikashop');
     $fieldTag = new JFormFieldTag();
     $fieldTag->setForm($jform);
     $fieldTag->setup($xmlConf, $tags);
     return $fieldTag->input;
 }
開發者ID:q0821,項目名稱:esportshop,代碼行數:35,代碼來源:tags.php

示例3: getField

 public function getField($type, $attributes = array(), $field_value = '')
 {
     static $types = null;
     $defaults = array('name' => '', 'id' => '');
     if (!$types) {
         jimport('joomla.form.helper');
         $types = array();
     }
     if (!in_array($type, $types)) {
         JFormHelper::loadFieldClass($type);
     }
     try {
         $attributes = array_merge($defaults, $attributes);
         $xml = new JXMLElement('<?xml version="1.0" encoding="utf-8"?><field />');
         foreach ($attributes as $key => $value) {
             if ('_options' == $key) {
                 foreach ($value as $_opt_value) {
                     $xml->addChild('option', $_opt_value->text)->addAttribute('value', $_opt_value->value);
                 }
                 continue;
             }
             $xml->addAttribute($key, $value);
         }
         $class = 'JFormField' . $type;
         $field = new $class();
         $field->setup($xml, $field_value);
         return $field;
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:rcorral,項目名稱:com_jm,代碼行數:31,代碼來源:helper.php

示例4: createStatuses

 public static function createStatuses()
 {
     $app = JFactory::getApplication();
     $filter_steps = $app->getUserStateFromRequest('com_imc.issues.filter.steps', 'steps', array());
     //get issue statuses
     JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_imc/models/fields');
     $step = JFormHelper::loadFieldType('Step', false);
     $statuses = $step->getOptions();
     if (empty($filter_steps)) {
         $str = '<ul class="imc_ulist imc_ulist_inline">';
         foreach ($statuses as $status) {
             $str .= '<li>';
             $str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . 'checked="checked"' . '>';
             $str .= '<span class="root">' . ' ' . $status->text . '</span>';
             $str .= '</li>';
         }
         $str .= '</ul>';
     } else {
         $str = '<ul class="imc_ulist imc_ulist_inline">';
         foreach ($statuses as $status) {
             $str .= '<li>';
             $str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . (in_array($status->value, $filter_steps) ? 'checked="checked"' : '') . '>';
             $str .= '<span class="root">' . ' ' . $status->text . '</span>';
             $str .= '</li>';
         }
         $str .= '</ul>';
     }
     return $str;
 }
開發者ID:Ricardolau,項目名稱:imc,代碼行數:29,代碼來源:helper.php

示例5: display

 function display($tpl = null)
 {
     JFormHelper::addFormPath(JPATH_ADMINISTRATOR . '/components/com_j2store/models/forms');
     JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_j2store/models/fields');
     $this->form = JForm::getInstance('storeprofile', 'storeprofile');
     $this->addToolBar();
     parent::display();
 }
開發者ID:ForAEdesWeb,項目名稱:AEW4,代碼行數:8,代碼來源:view.html.php

示例6: getInput

 /**
  * Method to get the field input markup.
  *
  * @return    string    The field input markup.
  * @since    1.6
  */
 protected function getInput()
 {
     // use as type here the default basic data field type (as example: Text/Calendar/Textarea/Editor)
     // see http://docs.joomla.org/Standard_form_field_types
     $field = JFormHelper::loadFieldType('Calendar');
     $field->setForm($this->form);
     $field->setup($this->element, $this->value);
     return $field->getInput();
 }
開發者ID:madcsaba,項目名稱:li-de,代碼行數:15,代碼來源:jdcustomfield11.php

示例7: display

 /**
  * display method of Cp view
  * @return void
  **/
 function display($tpl = null)
 {
     // Initialiase variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = empty($this->item->product_id);
     $document = JFactory::getDocument();
     if (JRequest::getVar('tmpl', '') != 'component') {
         $document->addScript(JURI::base(true) . '/components/com_cp/assets/js/jquery-1.10.1.min.js');
         $document->addScriptDeclaration('jQuery.noConflict();');
         $document->addScript(JURI::base(true) . '/components/com_cp/assets/js/jquery-ui-1.10.3.custom.min.js');
         $document->addScript(JURI::base(true) . '/components/com_cp/assets/js/scripts.js');
         $document->addStyleSheet(JURI::base(true) . '/components/com_cp/assets/css/style.css');
         $document->addStyleSheet(JURI::base(true) . '/components/com_cp/assets/css/smoothness/jquery-ui-1.8.21.custom.css');
         $document->addStyleDeclaration('body { min-width: 1170px; }');
     }
     // Create the form
     JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $text = $isNew ? JText::_('COM_CP_NEW') : JText::_('COM_CP_EDIT');
     JToolBarHelper::title($text . ' ' . JText::_('COM_CP_PRODUCT_PAGE_TITLE'));
     if ($isNew && $user->authorise('core.create', 'com_cp')) {
         JToolBarHelper::apply('cpproducts.apply');
         JToolBarHelper::save('cpproducts.save');
         JToolBarHelper::save2new('cpproducts.save2new');
         JToolBarHelper::cancel('cpproducts.cancel');
     } else {
         if ($user->authorise('core.edit', 'com_cp')) {
             JToolBarHelper::apply('cpproducts.apply');
             JToolBarHelper::save('cpproducts.save');
             if ($user->authorise('core.edit', 'com_cp')) {
                 JToolBarHelper::save2new('cpproducts.save2new');
             }
             JToolBarHelper::cancel('cpproducts.cancel', 'COM_CP_CLOSE');
         }
     }
     $helper = new CPHelper();
     if ($isNew) {
         $countFiles = 0;
     } else {
         $countFiles = count($this->item->media);
     }
     // Initialize media files script
     $document->addScriptDeclaration('var mediaCount = ' . $countFiles . '; var delText = "' . JText::_('COM_CP_DELETE') . '"; var siteURL = "' . JURI::root() . '";');
     $params = JComponentHelper::getParams('com_cp');
     $this->assignRef('params', $params);
     $this->item->cities = $helper->listCities($this->item->country_code, $this->item->city, 'jform[city]', 'jform_city');
     parent::display($tpl);
 }
開發者ID:jmangarret,項目名稱:webtuagencia24,代碼行數:60,代碼來源:view.html.php

示例8: __construct

 public function __construct(&$subject, $config)
 {
     if (!class_exists('joomlamailerMCAPI')) {
         return;
     }
     parent::__construct($subject, $config);
     JFormHelper::addFieldPath(__DIR__ . '/fields');
     $this->api = $this->getApiInstance();
     $this->debug = JFactory::getConfig()->get('debug');
     $this->listId = $this->params->get('listid');
 }
開發者ID:rodhoff,項目名稱:MNW,代碼行數:11,代碼來源:joomlamailer.php

示例9: populateState

 protected function populateState($ordering = null, $direction = null)
 {
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
     $this->setState('filter.state', $published);
     JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $catID = $this->getUserStateFromRequest($this->context . '.filter.category', 'filter_category');
     $this->setState('filter.category', $catID);
     $visibility = $this->getUserStateFromRequest($this->context . '.filter.visibility', 'filter_visibility');
     $this->setState('filter.category', $visibility);
     parent::populateState('a.ordering', 'asc');
 }
開發者ID:gmansillo,項目名稱:simplefilemanager,代碼行數:13,代碼來源:simplefilemanagers.php

示例10: displayAll

 function displayAll($id, $map, $color)
 {
     if (HIKASHOP_J25) {
         $xmlConf = new SimpleXMLElement('<field name="' . $map . '" type="color" label=""></field>');
         JFormHelper::loadFieldClass('color');
         $jform = new JForm('hikashop');
         $fieldTag = new JFormFieldColor();
         $fieldTag->setForm($jform);
         $fieldTag->setup($xmlConf, $color);
         return $fieldTag->input;
     }
     $code = '<input type="text" name="' . $map . '" id="color' . $id . '" onchange=\'applyColorExample' . $id . '()\' class="inputbox" size="10" value="' . $color . '" />' . ' <input size="10" maxlength="0" style=\'cursor:pointer;background-color:' . $color . '\' onclick="if(document.getElementById(\'colordiv' . $id . '\').style.display == \'block\'){document.getElementById(\'colordiv' . $id . '\').style.display = \'none\';}else{document.getElementById(\'colordiv' . $id . '\').style.display = \'block\';}" id=\'colorexample' . $id . '\' />' . '<div id=\'colordiv' . $id . '\' style=\'display:none;position:absolute;background-color:white;border:1px solid grey;z-index:999\'>' . $this->display($id) . '</div>';
     return $code;
 }
開發者ID:rodhoff,項目名稱:MNW,代碼行數:14,代碼來源:color.php

示例11: getInput

 /**
  * Method to get the field input markup.
  *
  * @return    string    The field input markup.
  * @since    1.6
  */
 protected function getInput()
 {
     global $jlistConfig;
     $app = JFactory::getApplication();
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers');
     JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
     $field = JFormHelper::loadFieldType('Text');
     $field->setForm($this->form);
     if ($this->value != '') {
         $field->setup($this->element, $this->value);
     } else {
         $field->setup($this->element, htmlspecialchars(trim($jlistConfig['custom.field.10.values']), ENT_COMPAT, 'UTF-8'));
     }
     return $field->getInput();
 }
開發者ID:madcsaba,項目名稱:li-de,代碼行數:21,代碼來源:jdcustomfield10.php

示例12: getField

 /**
  * Method to get the HTML of a certain field
  *
  * @param null
  * @return string
  */
 public static function getField($type, $name, $value = null, $array = 'magebridge')
 {
     jimport('joomla.form.helper');
     jimport('joomla.form.form');
     $fileType = preg_replace('/^magebridge\\./', '', $type);
     include_once JPATH_ADMINISTRATOR . '/components/com_magebridge/fields/' . $fileType . '.php';
     $form = new JForm('magebridge');
     $field = JFormHelper::loadFieldType($type);
     if (is_object($field) == false) {
         $message = JText::sprintf('COM_MAGEBRIDGE_UNKNOWN_FIELD', $type);
         JFactory::getApplication()->enqueueMessage($message, 'error');
         return null;
     }
     $field->setName($name);
     $field->setValue($value);
     return $field->getHtmlInput();
 }
開發者ID:apiceweb,項目名稱:MageBridgeCore,代碼行數:23,代碼來源:form.php

示例13: onAfterInitialise

 /**
  * Method to register custom library.
  *
  * @return  void
  */
 public function onAfterInitialise()
 {
     if (!$this->isRedcoreComponent()) {
         return;
     }
     $redcoreLoader = JPATH_LIBRARIES . '/redcore/bootstrap.php';
     if (file_exists($redcoreLoader)) {
         require_once $redcoreLoader;
         // For Joomla! 2.5 compatibility we add some core functions
         if (version_compare(JVERSION, '3.0', '<')) {
             RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redcore/joomla', false, true);
         }
     }
     // Make available the fields
     JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redcore/form/fields');
     // Make available the rules
     JFormHelper::addRulePath(JPATH_LIBRARIES . '/redcore/form/rules');
 }
開發者ID:prox91,項目名稱:joomla-dev,代碼行數:23,代碼來源:redcore.php

示例14: getItems

 function getItems()
 {
     $items = array();
     foreach ($this->element->children() as $element) {
         // clone element to make it as field
         $fdata = preg_replace('/<(\\/?)item(\\s|>)/mi', '<\\1field\\2', $element->asXML());
         $felement = new SimpleXMLElement($fdata);
         $field = JFormHelper::loadFieldType((string) $felement['type']);
         if ($field === false) {
             $field = JFormHelper::loadFieldType('text');
         }
         // Setup the JFormField object.
         $field->setForm($this->form);
         if ($field->setup($felement, null, $this->group . '.' . $this->fieldname)) {
             $items[] = $field;
         }
     }
     return $items;
 }
開發者ID:anawu2006,項目名稱:PeerLearning,代碼行數:19,代碼來源:jaitems.php

示例15: onAfterInitialise

 /**
  * Method to register custom library.
  *
  * @return  void
  */
 public function onAfterInitialise()
 {
     $isAdmin = JFactory::getApplication()->isAdmin();
     if (!$isAdmin || !$this->isRedradComponent()) {
         return;
     }
     $redradLoader = JPATH_LIBRARIES . '/redrad/bootstrap.php';
     if (file_exists($redradLoader) && !class_exists('Inflector')) {
         require_once $redradLoader;
         // For Joomla! 2.5 compatibility we add some core functions
         if (version_compare(JVERSION, '3.0', '<')) {
             RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redrad/joomla', false, true);
         }
     }
     // Make available the fields
     JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redrad/form/fields');
     // Make available the rules
     JFormHelper::addRulePath(JPATH_LIBRARIES . '/redrad/form/rules');
 }
開發者ID:prox91,項目名稱:joomla-dev,代碼行數:24,代碼來源:redrad.php


注:本文中的JFormHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。