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

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

		$field = new JFormFieldEditor($form);

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

		$this->markTestIncomplete('Problems encountered in next assertion');

		$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.
	}
Example #2
0
 protected function getInput()
 {
     $this->value = str_replace('<br />', "\n", JText::_($this->value));
     JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
     JEVHelper::ConditionalFields($this->element, $this->form->getName());
     return parent::getInput();
 }
Example #3
0
 public function getLabel()
 {
     $after_label = '';
     if (isset($this->element['viewname']) && $this->element['viewname'] == 'membership') {
         $after_label = '<div class="clr"></div><p class="rsmembership_after_label">' . JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_DESCRIPTION_PLACEHOLDERS') . '<br /><br />' . '<span class="rsmembership_' . (strpos($this->value, '{price}') !== false ? 'green' : 'red') . '">{price}</span> - ' . JText::_('COM_RSMEMBERSHIP_PLACEHOLDER_PRICE') . '</p>' . '<span class="rsmembership_' . (strpos($this->value, '{stock}') !== false ? 'green' : 'red') . '">{stock}</span> - ' . JText::_('COM_RSMEMBERSHIP_PLACEHOLDER_STOCK') . '</p>';
     }
     return parent::getLabel() . $after_label;
 }
Example #4
0
 /**
  * Method to get the field label markup
  *
  * @return  string  The field label markup
  * @since   2.0
  */
 protected function getLabel()
 {
     $label = '';
     $cbname = $this->element['cbname'] ? $this->element['cbname'] : 'change[]';
     $cbvalue = $this->element['cbvalue'] ? $this->element['cbvalue'] : $this->name;
     $cbid = str_replace(array('[', ']'), array('', ''), $cbname . $cbvalue);
     $cbhtml = '<input id="' . $cbid . '" type="checkbox" name="' . $cbname . '" value="' . $cbvalue . '" />';
     $label = parent::getLabel();
     $insertpos = strpos($label, '>');
     $label = substr_replace($label, $cbhtml, $insertpos + 1, 0);
     return $label;
 }
Example #5
0
 public function getInput()
 {
     $result = "";
     $langs = JFactory::getLanguage()->getKnownLanguages();
     $oldId = $this->id;
     $oldName = $this->name;
     $oldValue = $this->value;
     $lt = json_decode($oldValue);
     if ($lt == null) {
         $lt = new stdClass();
         // added fallback logic in case the current value is not in JSON format
         // this might be because in older versions there where no multilanguage fields.
         if (!empty($this->value) && json_last_error() == JSON_ERROR_SYNTAX) {
             foreach ($langs as $tag => $lang) {
                 $lt->{$tag} = $this->value;
             }
         }
     }
     $defaultLanguageTag = JComponentHelper::getParams('com_languages')->get('site');
     $defaultLanguage = $langs[$defaultLanguageTag];
     if ($defaultLanguage != null) {
         unset($langs[$defaultLanguageTag]);
         $langs = array_merge(array($defaultLanguageTag => $defaultLanguage), $langs);
     }
     if (count($langs) > 1) {
         $result .= '<small>' . JText::_('COM_EVENTGALLERY_LOCALIZEDEDITOR_WARNING') . '</small>';
     }
     foreach ($langs as $tag => $lang) {
         $defaultLangMarker = $tag == $defaultLanguageTag ? "*" : "";
         $this->value = isset($lt->{$tag}) === true ? $lt->{$tag} : '';
         $this->id = $oldId . str_replace('-', '_', $tag);
         $this->name = $oldName . str_replace('-', '_', $tag);
         $result .= '<div style="clear:both">';
         $result .= "<h4 >{$tag} {$defaultLangMarker}</h4>";
         $result .= parent::getInput();
         $result .= '</div>';
     }
     $this->id = $oldId;
     $this->value = $oldValue;
     $this->name = $oldName;
     $hiddenField = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"/>';
     return $result . $hiddenField;
 }
 /**
  * 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->static;
             break;
         default:
             return parent::__get($name);
     }
 }
Example #7
0
 protected function getInput()
 {
     $this->value = str_replace('<br />', "\n", JText::_($this->value));
     return parent::getInput();
 }
Example #8
0
 /**
  * Method to get the field input markup for the editor area
  *
  * @return  string  The field input markup.
  *
  * @since   1.6
  */
 protected function getEditor($name, $value, $form)
 {
     $editor = new JFormFieldEditor();
     $editor->name = $name;
     $editor->value = $value;
     $editor->form = $form;
     return $editor->getInput();
 }