Пример #1
0
	/**
	 * Test the getInput method.
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

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

		$field = new JFormFieldPassword($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.
	}
Пример #2
0
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     $this->element = $element;
     $element['label'] = $this->prepareText($element['label']);
     $element['description'] = $this->prepareText($element['description']);
     $element['translateDescription'] = false;
     return parent::setup($element, $value, $group);
 }
Пример #3
0
 public function __construct($form = null)
 {
     parent::__construct($form);
     JHtml::_('behavior.mootools');
     $doc = JFactory::getDocument();
     $doc->addStyleSheet(JURI::root(true) . '/media/plg_system_rvs_passwordchecker/css/default.css');
     $doc->addScript(JURI::root(true) . '/media/plg_system_rvs_passwordchecker/js/pwd_meter.js');
     $doc->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\t\$('jform_password1').addEvent('keyup', function() {\n\t\t\t\tchkPass(this.value);\t\t\t\t\n\t\t\t});\n\t\t});\n\t\t");
 }
Пример #4
0
 /**
  * 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);
     }
 }
Пример #5
0
 /**
  * Method to get the field input markup
  *
  * @return  string  The field input markup
  * @since   3.1
  */
 protected function getInput()
 {
     if ($this->value) {
         // Hide password field and change its name
         $name = $this->name;
         $this->name = $this->name . '-disabled';
         $this->value = '';
         if ($this->element['class']) {
             $this->element['class'] = $this->element['class'] . ' hidden';
         } else {
             $this->element['class'] = 'hidden';
         }
         return '<span id="' . $this->id . '_info">
     <span class="label label-info hasTooltip" title="' . JText::_('COM_JOOMGALLERY_CATMAN_PASSWORD_PROTECTED_TIP') . '">' . JText::_('COM_JOOMGALLERY_CATMAN_PASSWORD_PROTECTED') . '</span>
     <button class="btn btn-mini hasTooltip" title="' . JText::_('COM_JOOMGALLERY_CATMAN_PASSWORD_RESET_TIP') . '" onclick="jQuery(\'#' . $this->id . '\').attr(\'name\', \'' . $name . '\').removeClass(\'hidden\').focus();jQuery(\'#' . $this->id . '_info\').addClass(\'hide\');return false;">
       <i class="icon-cancel"></i>
     </button>
   </span>' . parent::getInput();
     } else {
         return parent::getInput();
     }
 }
Пример #6
0
 /**
  * Tests meter attribute setup by using the magic set method
  *
  * @covers JFormFieldPassword::__set
  *
  * @return void
  */
 public function testSetMeter()
 {
     $field = new JFormFieldPassword();
     $element = simplexml_load_string('<field name="myName" type="password" />');
     $this->assertTrue($field->setup($element, ''), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertFalse($field->meter, 'Line:' . __LINE__ . ' The property is false by default.');
     $field->meter = true;
     $this->assertTrue($field->meter, 'Line:' . __LINE__ . ' The magic set method should set the property correctly.');
 }
 /**
  * Tests meter attribute setup by JFormFieldText::setup method
  *
  * @covers JFormField::setup
  * @covers JFormField::__get
  *
  * @return void
  */
 public function testSetupMeter()
 {
     $field = new JFormFieldPassword();
     $element = simplexml_load_string('<field name="myName" type="password" strengthmeter="true" />');
     $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->meter, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }