/**
	 * Test the getInput method.
	 *
	 * @return void
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load('<form><field name="textarea" type="textarea" /></form>'),
			$this->isTrue(),
			'Line:' . __LINE__ . ' XML string should load successfully.'
		);

		$field = new JFormFieldTextarea($form);

		$this->assertThat(
			$field->setup($form->getXml()->field, 'value'),
			$this->isTrue(),
			'Line:' . __LINE__ . ' The setup method should return true.'
		);

		$this->assertThat(
			strlen($field->input),
			$this->greaterThan(0),
			'Line:' . __LINE__ . ' The getInput method should return something without error.'
		);

		// TODO: Should check all the attributes have come in properly.
	}
 /**
  * Tests rows and columns attribute setup by JFormFieldTextare::setup method
  *
  * @covers JFormField::setup
  * @covers JFormField::__get
  *
  * @return void
  */
 public function testSetupRowsColumns()
 {
     $field = new JFormFieldTextarea();
     $element = simplexml_load_string('<field name="myName" type="textarea" rows="60" cols="70" />');
     $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->rows, $this->equalTo(60), 'Line:' . __LINE__ . '  The property should be computed from the XML.');
     $this->assertThat($field->columns, $this->equalTo(70), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }
Example #3
0
 protected function getInput()
 {
     $this->value = str_replace('<br />', "\n", strpos($this->value, " ") > 0 ? $this->value : JText::_($this->value));
     JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
     JEVHelper::ConditionalFields($this->element, $this->form->getName());
     return parent::getInput();
 }
    /**
     * Method to get the textarea field input markup.
     * Use the rows and columns attributes to specify the dimensions of the area.
     *
     * @return  string  The field input markup.
     * @since   11.1
     */
    protected function getInput()
    {
        // Initialize some field attributes.
        static $identifier;
        if (!isset($identifier)) {
            JHTML::_('behavior.modal');
            $identifier = 0;
        }
        $identifier++;
        // Initialize JavaScript field attributes.
        $button = '<br clear="left"/><br /><input type="button" class="btn" id="modal' . $identifier . '" href="../plugins/editors/arkeditor/form/fields/modals/typography.php" rel="{handler: \'iframe\' , size: {x:640, y:480}}" value="Expand View"/>
<script type="text/javascript">
window.addEvent(\'domready\', function()
{
	var dialog = document.getElementById("modal' . $identifier . '");
	dialog.addEvent("click",function()
	{
		SqueezeBox.fromElement(dialog,	{ parse: \'rel\'});
	});	
	
}); 
</script>';
        if ($this->value) {
            $this->value = base64_decode($this->value);
        }
        $textarea = parent::getInput();
        return str_replace('<textarea ', '<textarea style="overflow:auto; min-width:50%;" ', $textarea) . $button;
    }
Example #5
0
 public function setup(&$element, $value, $group = null)
 {
     if (isset($element->content) && empty($value)) {
         $value = $element->content;
     }
     return parent::setup($element, $value, $group);
 }
Example #6
0
    public function getInput()
    {
        $html = array();
        $html[] = parent::getInput();
        // Auto-populate config text if a preset configuration is selected
        // Also change preset selection to "Custom" if the text in this field has been modified
        // so that it will not be overwrited on save
        $script = '
			window.addEvent("domready", function() {
				var thisControl = $("' . $this->getId('digits_xml', 'digits_xml') . '");
				var textField = $("scdp_config_text");
				if(textField) {
					var text = textField.get("value").replace(/\\t/g, "    ");
					thisControl.set("value", text);
				}
				thisControl.addEvent("change", function(e) {
					var presetControl = $("' . $this->getId('digits_config', 'digits_config') . '");
					presetControl.set("value", "");
				});
			});
		';
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($script);
        $document->addStyleSheet(JURI::root(true) . '/modules/mod_smartcountdown/styles.css');
        return implode("\n", $html);
    }
 /**
  * Method to get the textarea field input markup.
  * Use the rows and columns attributes to specify the dimensions of the area.
  *
  * @return  string  The field input markup.
  *
  * @since   2.0
  */
 public function getInput()
 {
     if ($this->value) {
         $value = json_decode($this->value);
         $this->value = implode("\n", $value);
     }
     return parent::getInput();
 }
    /**
     * Method to get the textarea field input markup.
     * Use the rows and columns attributes to specify the dimensions of the area.
     *
     * @return  string  The field input markup.
     *
     * @since   11.1
     */
    protected function getInput()
    {
        $html = parent::getInput();
        $html .= $this->getCounterMask();
        // @TODO : Convert this into a snippet that loads only once
        // using the .charcounter selector
        $doc = JFactory::getDocument();
        $doc->addScriptDeclaration('
			jQuery(document).ready(function() {
				jQuery("#' . $this->id . '").on("keyup", function() { 
					jQuery("#usedchars_' . $this->id . '").text(jQuery("#' . $this->id . '").val().length);
					jQuery("#remainingchars_' . $this->id . '").text((' . $this->maxlength . ' - jQuery("#' . $this->id . '").val().length));
				});
			});
		');
        return $html;
    }
 /**
  * Method to get certain otherwise inaccessible properties from the form field object.
  *
  * @param   string  $name  The property name for which to the the value.
  *
  * @return  mixed  The property value or null.
  *
  * @since   2.0
  */
 public function __get($name)
 {
     switch ($name) {
         case 'static':
             if (empty($this->static)) {
                 $this->static = $this->getStatic();
             }
             return $this->static;
             break;
         case 'repeatable':
             if (empty($this->repeatable)) {
                 $this->repeatable = $this->getRepeatable();
             }
             return $this->repeatable;
             break;
         default:
             return parent::__get($name);
     }
 }
Example #10
0
 protected function getInput()
 {
     // interface elements
     $html = '<div id="ratingmanager_errors" data-exists-text="' . JText::_('PLG_CONTENT_GKRATING_ERROR_EXISTS') . '" data-empty-text="' . JText::_('PLG_CONTENT_GKRATING_ERROR_EMPTY') . '"></div><div class="ratingmanager_form"><label for="ratingmanager_feature">' . JText::_('PLG_CONTENT_GKRATING_FEATURE_LABEL') . '</label><input type="text" name="ratingmanager_feature" id="ratingmanager_feature" value="" placeholder="' . JText::_('PLG_CONTENT_GKRATING_FEATURE_PLACEHOLDER') . '">';
     $html .= '<label for="ratingmanager_value">' . JText::_('PLG_CONTENT_GKRATING_VALUE_LABEL') . '</label>';
     $html .= '<div class="input-prepend"><input type="number" name="ratingmanager_value" id="ratingmanager_value" min="1" max="10" step="0.5" value="5" />';
     $html .= '<input type="button" class="btn" id="ratingform_add" value="' . JText::_('PLG_CONTENT_GKRATING_ADD') . '" /></div>';
     $html .= '<ul class="ratingWrapper" data-remove-text="' . JText::_('PLG_CONTENT_GKRATING_REMOVE') . '">';
     if ($this->value && json_decode($this->value) !== NULL && is_array(json_decode($this->value))) {
         foreach (json_decode($this->value) as $k => $v) {
             $html .= '<li><span class="icon-menu"></span> <span class="rate-label">' . $v->label . '</span> - <span class="rate-value">' . $v->val . '</span><a href="#" class="rate-remove">' . JText::_('PLG_CONTENT_GKRATING_REMOVE') . '</a></label></li>';
         }
     }
     $html .= '</ul></div>';
     // render text area with DRY attitude :)
     $html .= parent::getInput();
     $plugin = JPluginHelper::getPlugin('content', 'gkrating');
     $params = new JRegistry($plugin->params);
     return $html;
 }
Example #11
0
 public function getLabel()
 {
     $output = parent::getLabel();
     $output = str_replace('</label>', $this->Addition('label') . '</label>', $output);
     return $output;
     if ($this->hidden) {
         return '';
     }
     // Get the label text from the XML element, defaulting to the element name.
     $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
     $text = $this->translateLabel ? JText::_($text) : $text;
     $text .= $this->Addition('label');
     // Forcing the Alias field to display the tip below
     $position = $this->element['name'] == 'alias' ? ' data-placement="bottom" ' : '';
     $description = $this->translateDescription && !empty($this->description) ? JText::_($this->description) : $this->description;
     $displayData = array('text' => $text, 'description' => $description, 'for' => $this->id, 'required' => (bool) $this->required, 'classes' => explode(' ', $this->labelclass), 'position' => $position);
     $text = $displayData['text'];
     $desc = $displayData['description'];
     $for = $displayData['for'];
     $req = $displayData['required'];
     $classes = array_filter((array) $displayData['classes']);
     $position = $displayData['position'];
     $id = $for . '-lbl';
     $title = '';
     // If a description is specified, use it to build a tooltip.
     if (!empty($desc)) {
         JHtml::_('bootstrap.tooltip');
         $classes[] = 'hasTooltip';
         $title = ' title="' . JHtml::tooltipText(null, $desc, 0) . '"';
     }
     // If required, there's a class for that.
     if ($req) {
         $classes[] = 'required';
     }
     $return = '<label id="' . $id . '" for="' . $for . '" class="' . implode(' ', $classes) . '" ' . $title . $position . '>' . $text;
     if ($req) {
         $return .= '<span class="star">&#160;*</span>';
     }
     $return .= '</label>';
     return $return;
 }
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $result = parent::setup($element, $value, $group);
     if ($result == true) {
         $this->height = $this->element['height'] ? (string) $this->element['height'] : '500';
         $this->width = $this->element['width'] ? (string) $this->element['width'] : '100%';
         $this->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($this->assetField) ? $this->form->getValue($this->assetField) : (string) $this->element['asset_id'];
         $buttons = (string) $this->element['buttons'];
         $hide = (string) $this->element['hide'];
         $editorType = (string) $this->element['editor'];
         if ($buttons == 'true' || $buttons == 'yes' || $buttons == '1') {
             $this->buttons = true;
         } elseif ($buttons == 'false' || $buttons == 'no' || $buttons == '0') {
             $this->buttons = false;
         } else {
             $this->buttons = !empty($hide) ? explode(',', $buttons) : array();
         }
         $this->hide = !empty($hide) ? explode(',', (string) $this->element['hide']) : array();
         $this->editorType = !empty($editorType) ? explode('|', trim($editorType)) : array();
     }
     return $result;
 }
    /**
     * Method to get the user field input markup.
     *
     * @return  string  The field input markup.
     *
     * @since   1.6.0
     */
    protected function getInput()
    {
        $html = parent::getInput();
        $html = str_replace('</span>', '<a href="#" class="btn btn-default" onclick="checkitout(this);" style="float:right;"><i class="fa fa-cogs"></i>Check out</a></span>', $html);
        $html = str_replace("fullwidth", "fullwidth linecodehere", $html);
        $script = '<script type="text/javascript">

					function checkitout(el){
						var auto_fulltext = 1;
						var textarea = el.parentNode.parentNode.getElementsByTagName("textarea")[1].value;
						var input_url = el.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByClassName("obkey")[0].innerText;
						if(input_url == "Click me"){
						 	alert ("Please choose the first input field!");
						 	return false;
						}else{
						 	var list_oe = document.getElementById("ob-oe");
						 	var list_li = list_oe.getElementsByTagName("li");
						 	if("" != textarea){
						 		auto_fulltext = 0;
						 	}
						 	var value_input;
						 	for(var i=0;i<list_li.length;i++){
						 		var innerhtm = list_li[i].innerHTML;
						 		var first_innertext = innerhtm.split("</text><br>")[0];
						 		if (input_url==first_innertext.split(">")[1]){
						 			value_input = list_li[i].getElementsByTagName("p")[0].innerText;
						 		}
							}
							if(!checkValidurl(value_input)){
								alert ("Please input the valid url!");
								return false;
							}
							var url = encodeURI("http://demo.foobla.com/html_parser/index.php?url="+value_input+"&code="+textarea+"&auto_fulltext="+auto_fulltext);
							window.open(url);
							//document.write(\'<iframe height="450"  allowTransparency="true" frameborder="0" scrolling="yes" style="width:100%;" src="\'+value_input+\'" type= "text/javascript"></iframe>\');

						}

						/*jQuery(\'#myModal\').on(\'shown.bs.modal\',function (e){
								jQuery(\'#modal_iframe\').attr("src", url);
							}).on("show.bs.modal", function () {
							jQuery(this).find(".modal-dialog").css("height", \'800px\').css("width", \'1000px\').css(\'margin-top\', \'100px\');
							});

							jQuery(\'#myModal\').modal({show: true});*/
					}
					function checkValidurl(url){
						url_validate = /(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/;
						if(!url_validate.test(url)){
						   return false;
						}
						else{
						   return true;
						}
					}
					function change_auto_fulltext(el){
						var list_li = el.parentNode.parentNode.parentNode.getElementsByClassName("col-md-6")[1];
						var select = list_li.getElementsByTagName("select")[0];
						if(select.value == 1 && el.value != ""){
							select.value = 0;
						}
					}
					</script>';
        $line_script = '<script type="text/javascript">
			(function($){
			$.fn.linenumbers = function(in_opts){
				// Settings and Defaults
				var opt = $.extend({
					col_width: \'25px\',
					start: 1,
					digits: 4.
				},in_opts);
				return this.each(function(){
					// Get some numbers sorted out for the CSS changes
					var new_textarea_width = (parseInt($(this).css(\'width\'))-parseInt(opt.col_width))+\'px\';
					var new_textarea_height = parseInt($(this).css(\'height\'))+\'px\';
					var new_textarea_lineheight = parseInt($(this).css(\'line-height\'))+\'px\';
					var padding_top = parseInt($(this).css(\'padding-top\'))+\'px\';
					// Create the div and the new textarea and style it
					$(this).before(\'<div style="width:\'+$(this).css(\'width\')+\';"><textarea style="width:\'+new_textarea_width+\';height:\'+new_textarea_height+\';padding-top:\'+padding_top+\';line-height:\'+new_textarea_lineheight+\';float:left;margin-right:\'+\'-\'+new_textarea_width+\';white-space:pre;overflow:hidden;" disabled="disabled"></textarea>\');
					$(this).after(\'<div style="clear:both;"></div></div>\');
					// Edit the existing textarea\'s styles
					$(this).css({\'font-family\':\'monospace\',\'resize\':\'none\',\'height\':new_textarea_height,\'width\':new_textarea_width,\'float\':\'right\'});
					// Define a simple variable for the line-numbers box
					var lnbox = $(this).parent().find(\'textarea[disabled="disabled"]\');
					// Bind some actions to all sorts of events that may change it\'s contents
					$(this).bind(\'blur focus change keyup keydown\',function(){
						// Break apart and regex the lines, everything to spaces sans linebreaks
						var lines = "\\n"+$(this).val();
						lines = lines.match(/[^\\n]*\\n[^\\n]*/gi);
						// declare output var
						var line_number_output=\'\';
						// declare spacers and max_spacers vars, and set defaults
						var max_spacers = \'\'; var spacers = \'\';
						for(var i=0;i<opt.digits;i++){
							max_spacers += \' \';
						}
						// Loop through and process each line
						$.each(lines,function(k,v){
							// Add a line if not blank
							if(k!=0){
								line_number_output += "\\n";
							}
							// Determine the appropriate number of leading spaces
							lencheck = k+opt.start+\'!\';
							spacers = max_spacers.substr(lencheck.length-1);
							// Add the line, trimmed and with out line number, to the output variable
							line_number_output += spacers+(k+opt.start)+\':\'+v.replace(/\\n/gi,\'\').replace(/./gi,\' \').substr(opt.digits+1);
						});
						// Give the text area out modified content.
						$(lnbox).val(line_number_output);
						// Change scroll position as they type, makes sure they stay in sync
						$(lnbox).scrollTop($(this).scrollTop());
					})
					// Lock scrolling together, for mouse-wheel scrolling
					$(this).scroll(function(){
						$(lnbox).scrollTop($(this).scrollTop());
					});
					// Fire it off once to get things started
					$(this).trigger(\'keyup\');
				});
			};
		})(jQuery);
		jQuery(\'document\').ready(function(){
			jQuery(\'.linecodehere\').linenumbers({col_width:\'35px\'});
		})
		</script>';
        return $html . $script . $line_script;
    }
 protected function getInput()
 {
     $this->value = str_replace('<br />', "\n", JText::_($this->value));
     return parent::getInput();
 }
Example #15
0
 /**
  * 
  * @return type
  */
 protected function getInput()
 {
     $oFileRetriever = JchOptimizeFileRetriever::getInstance($this->getParams());
     if ($GLOBALS['bTextArea']) {
         return parent::getInput();
     }
     if (!$oFileRetriever->isUrlFOpenAllowed()) {
         $GLOBALS['bTextArea'] = TRUE;
         JFactory::getApplication()->enqueueMessage(JText::_('Your host does not have cURL or allow_url_fopen enabled. ' . 'Will use text areas instead of multiselect options for exclude settings'), 'notice');
         return parent::getInput();
     }
     try {
         $aOptions = $this->getFieldOptions();
     } catch (Exception $ex) {
         JFactory::getApplication()->enqueueMessage($ex->getMessage(), 'warning');
         return parent::getInput();
     }
     $sField = JHTML::_('select.genericlist', $aOptions, $this->name . '[]', 'class="inputbox" multiple="multiple" size="5"', 'id', 'name', $this->value, $this->id);
     return $sField;
 }