Exemplo n.º 1
0
 /**
  * Validate the form
  *
  * @param  array $data
  * @return boolean
  */
 public function isValid($data)
 {
     if (!parent::isValid($data)) {
         return false;
     }
     $hasErrors = false;
     $missingLabel = false;
     $missingURI = false;
     $duplicateURI = false;
     $uids = array();
     if ($pageLinks = $this->getValue(self::HIDDEN_ELEMENT_ID)) {
         if ($pageLinks = json_decode($pageLinks, true)) {
             foreach ($pageLinks as $pageLink) {
                 if (!$missingLabel && trim($pageLink['label']) == '') {
                     $this->addError('All navigation links must have both labels.');
                     $hasErrors = true;
                     $missingLabel = true;
                 }
                 if (!$missingURI && trim($pageLink['uri']) == '') {
                     $this->addError(__('All navigation links must have URIs.'));
                     $hasErrors = true;
                     $missingURI = true;
                 }
                 if (trim($pageLink['uri']) != '') {
                     try {
                         $page = new Omeka_Navigation_Page_Uri();
                         $page->setHref($pageLink['uri']);
                         $uid = $this->_nav->createPageUid($page->getHref());
                         if (!in_array($uid, $uids)) {
                             $uids[] = $uid;
                         } else {
                             if (!$duplicateURI) {
                                 $this->addError(__('All navigation links must have different URIs.'));
                                 $duplicateURI = true;
                                 $hasErrors = true;
                             }
                         }
                     } catch (Omeka_Navigation_Page_Uri_Exception $e) {
                         $this->addError(__('Invalid URI for "%s" navigation link:  "%s"', $pageLink['label'], $pageLink['uri']));
                         $hasErrors = true;
                     }
                 }
             }
         }
     }
     $hasErrors = $hasErrors || $this->_postHasDeletedUndeletablePage();
     return !$hasErrors;
 }
Exemplo n.º 2
0
 /**
  * Validate the form post
  */
 public function isValid($post)
 {
     $isValid = true;
     // Too much POST data, return with an error.
     if (empty($post) && (int) $_SERVER['CONTENT_LENGTH'] > 0) {
         $maxSize = $this->getMaxFileSize()->toString();
         $this->xml_import_file->addError(__('The file you have uploaded exceeds the maximum post size ' . 'allowed by the server. Please upload a file smaller ' . 'than %s.', $maxSize));
         return false;
     }
     // Check custom delimiters.
     if ($post['column_delimiter_name'] == 'custom') {
         if (strlen($post['column_delimiter']) != 1) {
             $this->column_delimiter->addError(__('The custom delimiter you choose cannot be whitespace and must be one character long.'));
             $isValid = false;
         }
     }
     if (!$isValid) {
         return false;
     }
     return parent::isValid($post);
 }
Exemplo n.º 3
0
 /**
  * Validate the form post
  */
 public function isValid($post)
 {
     // Too much POST data, return with an error.
     if (empty($post) && (int) $_SERVER['CONTENT_LENGTH'] > 0) {
         $maxSize = $this->getMaxFileSize()->toString();
         $this->csv_file->addError(__('The file you have uploaded exceeds the maximum post size ' . 'allowed by the server. Please upload a file smaller ' . 'than %s.', $maxSize));
         return false;
     }
     return parent::isValid($post);
 }