Example #1
0
 /**
  * Use this function to customize your own javascript rule.
  * $this->regex must be null if you want to customize here.
  *
  * @access	public
  * @param	JXMLElement	$fieldNode	The JXMLElement object representing the <field /> tag for the form field object.
  *
  * @return	string	A JSON string representing the javascript rules validation.
  */
 public function getJsonRule($fieldNode)
 {
     /* 	TODO : Fill the associative array below, or create a JSON string manually
      * 	Note : $this->regex must be null
      */
     $values = array();
     $json = RtiprintHelperHtmlValidator::jsonFromArray($values);
     return "{" . LN . $json . LN . "}";
 }
Example #2
0
 /**
  * Use this function to customize your own javascript rule.
  * $this->regex must be null if you want to customize here.
  *
  * @access	public
  * @param	JXMLElement	$fieldNode	The JXMLElement object representing the <field /> tag for the form field object.
  *
  * @return	string	A JSON string representing the javascript rules validation.
  */
 public function getJsonRule($fieldNode)
 {
     $regex = '';
     $allowedExtensionsText = '*.*';
     if (isset($fieldNode['allowedExtensions'])) {
         $allowedExtensions = $fieldNode['allowedExtensions'];
         $allowedExtensionsText = preg_replace("/\\|/", "<br/>", $allowedExtensions);
         //Remove eventual '*.'
         $allowedExtensions = preg_replace("/\\*\\./", "", $allowedExtensions);
         $regex = '\\.(' . $allowedExtensions . ')$';
     }
     $values = array("#regex" => 'new RegExp("' . $regex . '", \'i\')');
     if (isset($fieldNode['msg-incorrect'])) {
         $values["alertText"] = LI_PREFIX . JText::_($fieldNode['msg-incorrect']);
     } else {
         $values["alertText"] = LI_PREFIX . JText::sprintf('RTIPRINT_ERROR_ALLOWED_FILES', $allowedExtensionsText);
     }
     $json = RtiprintHelperHtmlValidator::jsonFromArray($values);
     return "{" . LN . $json . LN . "}";
 }
Example #3
0
 /**
  * Defines the headers of your template.
  *
  * @access	public static
  *
  * @return	void	
  * @return	void
  */
 public static function headerDeclarations()
 {
     if (self::$loaded) {
         return;
     }
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $siteUrl = JURI::root(true);
     $baseSite = 'components' . DS . COM_RTIPRINT;
     $baseAdmin = 'administrator' . DS . 'components' . DS . COM_RTIPRINT;
     $componentUrl = $siteUrl . '/' . str_replace(DS, '/', $baseSite);
     $componentUrlAdmin = $siteUrl . '/' . str_replace(DS, '/', $baseAdmin);
     //Required libraries
     //jQuery Loading : Abstraction to handle cross versions of Joomla
     JDom::_('framework.jquery');
     JDom::_('framework.jquery.chosen');
     JDom::_('framework.bootstrap');
     JDom::_('html.icon.glyphicon');
     JDom::_('html.icon.icomoon');
     //Load the jQuery-Validation-Engine (MIT License, Copyright(c) 2011 Cedric Dugas http://www.position-absolute.com)
     self::addScript($doc, $baseAdmin, 'js' . DS . 'jquery.validationEngine.js');
     self::addStyleSheet($doc, $baseAdmin, 'css' . DS . 'validationEngine.jquery.css');
     RtiprintHelperHtmlValidator::loadLanguageScript();
     //CSS
     if ($app->isAdmin()) {
         self::addStyleSheet($doc, $baseAdmin, 'css' . DS . 'rtiprint.css');
         self::addStyleSheet($doc, $baseAdmin, 'css' . DS . 'toolbar.css');
     } else {
         if ($app->isSite()) {
             self::addStyleSheet($doc, $baseSite, 'css' . DS . 'rtiprint.css');
             self::addStyleSheet($doc, $baseSite, 'css' . DS . 'toolbar.css');
         }
     }
     self::$loaded = true;
 }
Example #4
0
 /**
  * Method to get the field input markup.
  *
  * @access	public
  *
  * @return	string	The field input markup.
  *
  * @since	11.1
  */
 public function getInput()
 {
     if (!$this->canView()) {
         return;
     }
     //Loads the front javascript and HTML validator (inspirated by JDom.)
     //Hidden messages strings are created in order to fill the javascript message alert.
     //When an error occurs, the messages appears under each field.
     //On loading, the informations messages for each field are shown when values are empties.
     //Each validation occurs on the 'change' event, and merged together in alert box on form submit.
     //If the field is required without validation rule, the helper is called only for the required message implementation.
     $input = $this->input;
     $input .= RtiprintHelperHtmlValidator::loadValidators($this->element, $this->id);
     return $input;
 }