Beispiel #1
0
 /**
  * Testing the setSize method to see if validation fails.
  *
  * @since 1.0
  */
 public function testSetSizeInvalid()
 {
     $this->txt = new Text();
     $this->txt->setSize(4);
     try {
         $this->txt->setValue('Too many characters!');
         $this->fail('testing the setSize method to see if validation fails');
     } catch (IllegalArguementException $e) {
         $this->assertEquals('Not a valid text value!', $e->getMessage(), 'testing the setSize method to see if validation fails');
     }
 }
Beispiel #2
0
 /**
  * constructor for the class.
  *
  * @since 1.0
  */
 public function __construct()
 {
     self::$logger = new Logger('ArticleComment');
     // ensure to call the parent constructor
     parent::__construct();
     $this->articleOID = new Relation();
     $this->articleOID->setRelatedClass('Alpha\\Model\\Article');
     $this->articleOID->setRelatedClassField('OID');
     $this->articleOID->setRelatedClassDisplayField('description');
     $this->articleOID->setRelationType('MANY-TO-ONE');
     $this->content = new Text();
     $this->content->setAllowHTML(false);
 }
Beispiel #3
0
 /**
  * Renders the HTML and javascript for the text box.
  *
  * @return string
  *
  * @since 1.0
  */
 public function render()
 {
     $config = ConfigProvider::getInstance();
     $html = '<div class="form-group">';
     $html .= '  <label for="' . $this->name . '">' . $this->label . '</label>';
     $html .= '<textarea class="form-control" maxlength="' . $this->textObject->getSize() . '" id="text_field_' . $this->name . '_' . $this->identifier . '" rows="' . $this->rows . '" name="' . $this->name . '">';
     if ($this->textObject->getAllowHTML()) {
         $html .= InputFilter::decode($this->textObject->getValue(), true);
     } else {
         $html .= InputFilter::decode($this->textObject->getValue());
     }
     $html .= '</textarea>';
     $html .= '</div>';
     if ($this->textObject->getRule() != '') {
         $html .= '<input type="hidden" id="text_field_' . $this->name . '_' . $this->identifier . '_msg" value="' . $this->textObject->getHelper() . '"/>';
         $html .= '<input type="hidden" id="text_field_' . $this->name . '_' . $this->identifier . '_rule" value="' . $this->textObject->getRule() . '"/>';
     }
     return $html;
 }
Beispiel #4
0
 /**
  * Loads the content of the ArticleObject from the specified file path.
  *
  * @param $filePath
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\FileNotFoundException
  */
 public function loadContentFromFile($filePath)
 {
     try {
         $this->content->setValue(file_get_contents($filePath));
         $this->filePath = $filePath;
     } catch (\Exception $e) {
         throw new FileNotFoundException($e->getMessage());
     }
 }