Beispiel #1
0
 public function isValid($data)
 {
     $ret = parent::isValid($data);
     if ($this->getElement('title') && !$this->getElement('title')->hasErrors()) {
         $fileExistsValidator = new Zend_Validate_File_NotExists();
         $fileExistsValidator->setDirectory(UPLOAD_PATH . DIRECTORY_SEPARATOR . 'static')->setMessage('cms_form_error_title_exists');
         if (!$fileExistsValidator->isValid($data['title'] . '.html')) {
             $this->getElement('title')->addErrors($fileExistsValidator->getMessages());
             $ret = false;
         }
     }
     return $ret;
 }
Beispiel #2
0
 /**
  * Ensures that setDirectory() returns expected value
  *
  * @return void
  */
 public function testSetDirectory()
 {
     $validator = new Zend_Validate_File_NotExists('temp');
     $validator->setDirectory('gif');
     $this->assertEquals('gif', $validator->getDirectory());
     $this->assertEquals(array('gif'), $validator->getDirectory(true));
     $validator->setDirectory('jpg, temp');
     $this->assertEquals('jpg,temp', $validator->getDirectory());
     $this->assertEquals(array('jpg', 'temp'), $validator->getDirectory(true));
     $validator->setDirectory(array('zip', 'ti'));
     $this->assertEquals('zip,ti', $validator->getDirectory());
     $this->assertEquals(array('zip', 'ti'), $validator->getDirectory(true));
 }