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


PHP JFormField::setup方法代码示例

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


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

示例1: setup

 /**
  * Method to attach a JForm object to the field.
  *  Catch upload files when form setup.
  *
  * @param   object  &$element  The JXmlElement object representing the <field /> tag for the form field object.
  * @param   mixed   $value     The form field value to validate.
  * @param   string  $group     The field name group control value. This acts as as an array container for the field.
  *                              For example if the field has name="foo" and the group value is set to "bar" then the
  *                              full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     parent::setup($element, $value, $group);
     if (JRequest::getVar($this->element['name'] . '_delete') == 1) {
         $this->value = '';
     } else {
         // Upload Image
         // ===============================================
         if (isset($_FILES['jform']['name']['profile'])) {
             foreach ($_FILES['jform']['name']['profile'] as $key => $var) {
                 if (!$var) {
                     continue;
                 }
                 // Get Field Attr
                 $width = $this->element['save_width'] ? $this->element['save_width'] : 800;
                 $height = $this->element['save_height'] ? $this->element['save_height'] : 800;
                 // Build File name
                 $src = $_FILES['jform']['tmp_name']['profile'][$key];
                 $var = explode('.', $var);
                 $date = JFactory::getDate('now', JFactory::getConfig()->get('offset'));
                 $name = md5((string) $date . $width . $height . $src) . '.' . array_pop($var);
                 $url = "images/cck/{$date->year}/{$date->month}/{$date->day}/" . $name;
                 // A Event for extend.
                 JFactory::getApplication()->triggerEvent('onCCKEngineUploadImage', array(&$url, &$this, &$this->element));
                 $dest = JPATH_ROOT . '/' . $url;
                 // Upload First
                 JFile::upload($src, $dest);
                 // Resize image
                 $img = new JImage();
                 $img->loadFile(JPATH_ROOT . '/' . $url);
                 $img = $img->resize($width, $height);
                 switch (array_pop($var)) {
                     case 'gif':
                         $type = IMAGETYPE_GIF;
                         break;
                     case 'png':
                         $type = IMAGETYPE_PNG;
                         break;
                     default:
                         $type = IMAGETYPE_JPEG;
                         break;
                 }
                 // save
                 $img->toFile($dest, $type, array('quality' => 85));
                 // Set in Value
                 $this->value = $url;
             }
         }
     }
     return true;
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:63,代码来源:uploadimage.php

示例2: setup

 /**
  * Method to attach a JForm object to the field.
  *  Catch upload files when form setup.
  *
  * @param   SimpleXMLElement $element  The JXmlElement object representing the <field /> tag for the form field object.
  * @param   mixed            $value    The form field value to validate.
  * @param   string           $group    The field name group control value. This acts as as an array container for the field.
  *                                     For example if the field has name="foo" and the group value is set to "bar" then the
  *                                     full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     parent::setup($element, $value, $group);
     $container = \Windwalker\DI\Container::getInstance();
     $input = $container->get('input');
     $delete = isset($_REQUEST['jform']['profile'][$this->element['name'] . '_delete']) ? $_REQUEST['jform']['profile'][$this->element['name'] . '_delete'] : 0;
     if ($delete == 1) {
         $this->value = '';
     } else {
         // Upload Image
         // ===============================================
         if (isset($_FILES['jform']['name']['profile'])) {
             foreach ($_FILES['jform']['name']['profile'] as $key => $var) {
                 if (!$var) {
                     continue;
                 }
                 // Get Field Attr
                 $width = $this->element['save_width'] ? $this->element['save_width'] : 800;
                 $height = $this->element['save_height'] ? $this->element['save_height'] : 800;
                 // Build File name
                 $src = $_FILES['jform']['tmp_name']['profile'][$key];
                 $var = explode('.', $var);
                 $date = DateHelper::getDate();
                 $name = md5((string) $date . $width . $height . $src) . '.' . array_pop($var);
                 $url = "images/cck/{$date->year}/{$date->month}/{$date->day}/" . $name;
                 // A Event for extend.
                 $container->get('event.dispatcher')->trigger('onCCKEngineUploadImage', array(&$url, &$this, &$this->element));
                 $dest = JPATH_ROOT . '/' . $url;
                 // Upload First
                 JFile::upload($src, $dest);
                 // Resize image
                 $img = new JImage();
                 $img->loadFile(JPATH_ROOT . '/' . $url);
                 $img = $img->resize($width, $height);
                 switch (array_pop($var)) {
                     case 'gif':
                         $type = IMAGETYPE_GIF;
                         break;
                     case 'png':
                         $type = IMAGETYPE_PNG;
                         break;
                     default:
                         $type = IMAGETYPE_JPEG;
                         break;
                 }
                 // Save
                 $img->toFile($dest, $type, array('quality' => 85));
                 // Set in Value
                 $this->value = $url;
                 // Clean cache
                 $thumb = $this->getThumbPath();
                 if (is_file(JPATH_ROOT . '/' . $thumb)) {
                     \JFile::delete(JPATH_ROOT . '/' . $thumb);
                 }
             }
         }
     }
     return true;
 }
开发者ID:ForAEdesWeb,项目名称:AEW13,代码行数:71,代码来源:uploadimage.php

示例3: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see     JFormField::setup()
  * @since   3.2
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     if ($result == true) {
         $this->contentType = (string) $this->element['content_type'];
     }
     return $result;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:22,代码来源:ordering.php

示例4: setup

 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $this->countertype = (string) $this->element['countertype'];
     }
     return $return;
 }
开发者ID:naka211,项目名称:studiekorrektur,代码行数:8,代码来源:vmordernumbercounters.php

示例5: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see     JFormField::setup()
  * @since   3.6.3
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $this->linked = isset($this->element['linked']) ? (int) $this->element['linked'] : 'position';
     }
     return $return;
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:22,代码来源:moduleorder.php

示例6: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   object  &$element  The JXmlElement object representing the <field /> tag for the form field object.
  * @param   mixed   $value     The form field value to validate.
  * @param   string  $group     The field name group control value. This acts as as an array container for the field.
  *                             For example if the field has name="foo" and the group value is set to "bar" then the
  *                             full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function setup(&$element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     // Force field to be required. There's no reason to have a captcha if it is not required.
     // Obs: Don't put required="required" in the xml file, you just need to have validate="captcha"
     $this->required = true;
     $class = $this->element['class'];
     if (strpos($class, 'required') === false) {
         $this->element['class'] = $class . ' required';
     }
     return $result;
 }
开发者ID:raeldc,项目名称:joomla-cms,代码行数:25,代码来源:captcha.php

示例7: setup

 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $this->max = isset($this->element['max']) ? $this->element['max'] : null;
         $this->min = isset($this->element['min']) ? $this->element['min'] : null;
         $this->unit = isset($this->element['unit']) ? $this->element['unit'] : null;
         $this->help = isset($this->element['help']) ? $this->element['help'] : null;
         $this->icon = isset($this->element['icon']) ? $this->element['icon'] : null;
         $this->maxLength = isset($this->element['maxlength']) ? $this->element['maxlength'] : '';
     }
     return $return;
 }
开发者ID:ashanrupasinghe,项目名称:slbcv1,代码行数:13,代码来源:sywverbosetext.php

示例8: setup

 public function setup(&$element, $value, $group = null)
 {
     $success = parent::setup($element, $value, $group);
     if (!$success) {
         return false;
     }
     //echo var_export($this->form);die();
     return true;
     // load any custom fields
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin("jevents");
     $id = intval(str_replace("extras", "", $this->name));
     $res = $dispatcher->trigger('onEditMenuItem', array(&$this->data, &$this->value, $this->type, $this->name, $this->id, $this->form));
     return true;
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:15,代码来源:jevextras.php

示例9: setup

	public function setup(SimpleXMLElement $element, $value, $group = null) {
            $return = parent::setup($element, $value, $group);
            if($return) {
                if(version_compare(JVERSION,3.2,'>=')) {
                    $td = ($this->getAttribute('translate_default') == 'true')?true:false;
                    $default = ($this->value == $this->default)?$this->default:false;
                } else {
                    $td = ($element->attributes()->translate_default == 'true')?true:false;
                    $default = ($this->value == $element->attributes()->default)?$element->attributes()->default:false;                
                }
                if($td && $default) {
                    $this->value = JText::_($default);   
                }
            }
            return $return;
        }
开发者ID:networksoft,项目名称:networksoft.com.co,代码行数:16,代码来源:aetextarea.php

示例10: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     $plugin = $this->element['plugin'] ? (string) $this->element['plugin'] : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
     if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null) {
         $this->hidden = true;
     } else {
         // Force field to be required. There's no reason to have a captcha if it is not required.
         // Obs: Don't put required="required" in the xml file, you just need to have validate="captcha"
         $this->required = true;
         $class = $this->element['class'];
         if (strpos($class, 'required') === false) {
             $this->element['class'] = $class . ' required';
         }
     }
     return $result;
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:30,代码来源:captcha.php

示例11: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     $app = JFactory::getApplication();
     $default = $app->get('captcha');
     if ($app->isSite()) {
         $default = $app->getParams()->get('captcha', $default);
     }
     $plugin = $this->element['plugin'] ? (string) $this->element['plugin'] : $default;
     $this->plugin = $plugin;
     if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null) {
         $this->hidden = true;
     } else {
         // Force field to be required. There's no reason to have a captcha if it is not required.
         // Obs: Don't put required="required" in the xml file, you just need to have validate="captcha"
         $this->required = true;
         if (strpos($this->class, 'required') === false) {
             $this->class = $this->class . ' required';
         }
     }
     $this->namespace = $this->element['namespace'] ? (string) $this->element['namespace'] : $this->form->getName();
     return $result;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:36,代码来源:captcha.php

示例12: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see     JFormField::setup()
  * @since   3.2
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     // Handle the default attribute
     $default = (string) $element['default'];
     if ($default) {
         $test = $this->form->getValue((string) $element['name'], $group);
         $value = $test == $default ? $default : null;
     }
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $checked = (string) $this->element['checked'];
         $this->checked = $checked == 'true' || $checked == 'checked' || $checked == '1';
         empty($this->value) || $this->checked ? null : ($this->checked = true);
     }
     return $return;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:30,代码来源:checkbox.php

示例13: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see     JFormField::setup()
  * @since   3.2
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     if ($result == true) {
         $inputmode = (string) $this->element['inputmode'];
         $dirname = (string) $this->element['dirname'];
         $this->inputmode = '';
         $inputmode = preg_replace('/\\s+/', ' ', trim($inputmode));
         $inputmode = explode(' ', $inputmode);
         if (!empty($inputmode)) {
             $defaultInputmode = in_array('default', $inputmode) ? JText::_("JLIB_FORM_INPUTMODE") . ' ' : '';
             foreach (array_keys($inputmode, 'default') as $key) {
                 unset($inputmode[$key]);
             }
             $this->inputmode = $defaultInputmode . implode(" ", $inputmode);
         }
         // Set the dirname.
         $dirname = (string) $dirname == 'dirname' || $dirname == 'true' || $dirname == '1';
         $this->dirname = $dirname ? $this->getName($this->fieldname . '_dir') : false;
         $this->maxLength = (int) $this->element['maxlength'];
     }
     return $result;
 }
开发者ID:Tommar,项目名称:remate,代码行数:37,代码来源:text.php

示例14: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see 	JFormField::setup()
  * @since   3.2
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     if ($result == true) {
         $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
         $this->authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by';
         $this->asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
         $this->link = (string) $this->element['link'];
         $this->preview = (string) $this->element['preview'];
         $this->directory = (string) $this->element['directory'];
         $this->previewWidth = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 200;
         $this->previewHeight = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 200;
     }
     return $result;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:29,代码来源:media.php

示例15: setup

 /**
  * Method to attach a JForm object to the field.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  *
  * @see     JFormField::setup()
  * @since   3.2
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $return = parent::setup($element, $value, $group);
     if ($return) {
         $this->section = $this->element['section'] ? (string) $this->element['section'] : '';
         $this->component = $this->element['component'] ? (string) $this->element['component'] : '';
         $this->assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
     }
     return $return;
 }
开发者ID:N6REJ,项目名称:joomla-cms,代码行数:24,代码来源:rules.php


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