Changeset f4e524f
- Timestamp:
- 08/23/10 22:22:27 (21 months ago)
- Branches:
- ('master', '8434b8322dd6f8ff37c17bd45b94e7a826f86b53')('vitrine', 'afe109c61a407808bd54d88bcccb1cde726a010a')
- Children:
- df1a05b5c412f8cf82a7dada90cd6ab90cc88973
- Parents:
- aafb30da0fc9db2f5ca461894d47434abefdf7e3
- git-author:
- Benoit Grégoire <benoitg@coeus.ca>2010-08-23 22:22:27-04:00
- git-committer:
- Benoit Grégoire <benoitg@coeus.ca>2010-08-23 22:22:27-04:00
- Location:
- html
- Files:
-
- 2 added
- 8 edited
-
classes/EurekaUtils.php (modified) (4 diffs)
-
classes/Langstring.php (modified) (1 diff)
-
classes/Vocabulary.php (modified) (6 diffs)
-
classes/VocabularyRelation.php (modified) (5 diffs)
-
classes/VocabularyTerm.php (modified) (1 diff)
-
classes/exceptions/MissingVocabularyException.php (modified) (1 diff)
-
classes/exceptions/MissingVocabularyTermException.php (modified) (1 diff)
-
classes/exceptions/NoTaxonPathException.php (modified) (1 diff)
-
classes/exceptions/ObjectNotFoundException.php (added)
-
tests/test_pg_query_not_returning.php (added)
Legend:
- Unmodified
- Added
- Removed
-
html/classes/EurekaUtils.php
r3550449 rf4e524f 138 138 { 139 139 // Removed TLD check to let IP adress pass through \.[a-z]{2,3} 140 if (! eregi("^[0-9a-z]([-.]?[0-9a-z])*$", $splitted_str['host'], $regs))140 if (!preg_match("/^[0-9a-z]([-.]?[0-9a-z])*$/i", $splitted_str['host'])) 141 141 { 142 142 $errMsg = "host {$splitted_str['host']} not valid"; … … 152 152 if (array_key_exists('user', $splitted_str)) 153 153 { 154 if (! eregi("^([0-9a-z-]|[\_])*$", $splitted_str['user'], $regs))154 if (!preg_match("/^([0-9a-z-]|[\_])*$/i", $splitted_str['user'])) 155 155 { 156 156 $errMsg = "Invalid user {$slitted_str['user']}"; … … 161 161 if (array_key_exists('pass', $splitted_str)) 162 162 { 163 if (! eregi("^([0-9a-z-]|[\_])*$", $splitted_str['pass'], $regs))163 if (!preg_match("/^([0-9a-z-]|[\_])*$/i", $splitted_str['pass'])) 164 164 { 165 165 $errMsg = "Invalid password {$slitted_str['pass']}"; … … 170 170 if (array_key_exists('path', $splitted_str)) 171 171 { 172 if (! eregi("^[0-9a-z/_\.@~\-]*$", $splitted_str['path'], $regs))173 { 174 $errMsg = "Invalid path {$s litted_str['path']}";172 if (!preg_match("/^[0-9a-z\/_\.@~\-]*$/i", $splitted_str['path'])) 173 { 174 $errMsg = "Invalid path {$splitted_str['path']}"; 175 175 return false; 176 176 } -
html/classes/Langstring.php
raafb30d rf4e524f 246 246 if (!empty ($string)) 247 247 { 248 // If the update returns 0 ( no update ), try inserting the record 249 try 250 { 251 $this->mBd->executerSqlResUnique("SELECT * FROM langstring_entries WHERE locales_id {$equality_operator} {$id} AND langstrings_id = '$this->mId'", $row, false); 252 if ($row != null) { 253 if ($row['value'] != $string) { 254 $string = $this->mBd->EscapeString($string); 255 $this->mBd->execSqlUpdate("UPDATE langstring_entries SET value = '$string' WHERE langstrings_id = '$this->mId' AND locales_id = $id", false); 256 } 257 $this->dirtyCachedString(); 258 } 259 else { 260 $this->addString($string, $locale); 261 } 262 $retval = true; 263 } 264 catch (Exception $e) 265 { 266 $retval = false; 267 } 248 249 $this->mBd->executerSqlResUnique("SELECT * FROM langstring_entries WHERE locales_id {$equality_operator} {$id} AND langstrings_id = '$this->mId'", $row, false); 250 if ($row != null) { 251 if ($row['value'] != $string) { 252 $string = $this->mBd->EscapeString($string); 253 $this->mBd->execSqlUpdate("UPDATE langstring_entries SET value = '$string' WHERE langstrings_id = '$this->mId' AND locales_id = $id", false); 254 } 255 $this->dirtyCachedString(); 256 } 257 else { 258 // If we didn't find the row, try inserting the record 259 $this->addString($string, $locale); 260 } 261 $retval = true; 268 262 } 269 263 return $retval; -
html/classes/Vocabulary.php
raafb30d rf4e524f 145 145 } 146 146 // Try to import from URL, on fail throw an exception 147 if ($this->ImportFromURL($id, $debug) == false) 148 throw new MissingVocabularyException("Vocabulary not found, and unable to import since the id ($id) isn't a URL"); 147 $errorMsg = null; 148 if ($this->ImportFromURL($id, null, $errorMsg, $debug) == false) 149 throw new MissingVocabularyException("Vocabulary not found, and unable to import from id: ($id) because: $errorMsg"); 149 150 } 150 151 else … … 664 665 @param $overrideVocabSource Typically, for vocabularies like LOMFrv.0, where the source isn't a URL 665 666 */ 666 function ImportFromURL($url, $overrideVocabSource = null, $debug = false)667 function ImportFromURL($url, $overrideVocabSource = null, &$errorMsg = null, $debug = false) 667 668 { 668 669 $utils = new EurekaUtils(); 669 if (EurekaUtils::IsURL($url)) 670 $error = null; 671 if (EurekaUtils::IsURL($url, $errorMsg)) 670 672 { 671 673 if ($debug) 672 echo "trying to import from URL <br/>";674 echo "trying to import from URL $url<br/>"; 673 675 // The URL exists and the content of the file has been parsed 674 676 if ($dom = @ DOMDocument :: load($url)) … … 687 689 } 688 690 } 689 else 690 if ($debug) 691 echo "The VDEX did not validate against schema."; 692 } 693 } 694 else 695 if ($debug) 696 echo "<strong>the URL specified is invalid (should be http:// or ftp://) !</strong><br/>"; 691 else { 692 $errorMsg = "The VDEX did not validate against schema."; 693 if ($debug) 694 echo $errorMsg; 695 } 696 } 697 else { 698 $errorMsg = "Unable to load or parse XML at URL $url"; 699 } 700 } 701 else { 702 if ($debug) 703 echo "<strong>the URL specified is invalid ($errorMsg) !</strong><br/>"; 704 } 697 705 return false; 698 706 } … … 1015 1023 } 1016 1024 $vocabulary_relation = null; 1025 1017 1026 if ($updating) { 1018 1027 try { … … 1025 1034 } 1026 1035 } 1027 catch ( Exception $e){1036 catch (ObjectNotFoundException $e){ 1028 1037 //Do nothing, it just means the relationship didn't already exist 1029 1038 } … … 1051 1060 } 1052 1061 else { 1053 echo '<h1>ERROR: Vocabulary::import(); $format = '.$format.' Format inconnu!</h1>'; 1054 $retval=false; 1062 throw ImportException('ERROR: Vocabulary::import(); $format = '.$format.' is unknown!'); 1055 1063 } 1056 1064 return $retval; -
html/classes/VocabularyRelation.php
re0e292f rf4e524f 29 29 require_once 'RelationNN.php'; 30 30 require_once 'Vocabulary.php'; 31 require_once 'exceptions/ImportException.php'; 31 32 32 33 error_reporting(E_ALL); … … 152 153 if ($row == null) { 153 154 //$args = func_get_args();var_dump($args); 154 throw new Exception("Unable to find a relation with the specified parameters"); 155 156 throw new ObjectNotFoundException("Unable to find a relation with the specified parameters"); 155 157 } 156 158 return new self($row); … … 159 161 static public function getFromXml(Vocabulary $voc, DOMXPath $xpath, DOMNode $relationship) { 160 162 $values = self::parseFromXml($relationship, $debug=false); 161 return self::getFromFullId($voc, $values['source_term_vocabulary_identifier'], $values['source_term_identifier'], $values['target_term_vocabulary_identifier'], $values['target_term_identifier'], $values['vdex_7_4_1_relationship_type_source'], $values['vdex_7_4_2_relationship_type_value'], $values['vdex_7_1_identifier']); 163 $retval = self::getFromFullId($voc, $values['source_term_vocabulary_identifier'], $values['source_term_identifier'], $values['target_term_vocabulary_identifier'], $values['target_term_identifier'], $values['vdex_7_4_1_relationship_type_source'], $values['vdex_7_4_2_relationship_type_value'], $values['vdex_7_1_identifier']); 164 return $retval; 162 165 } 163 166 … … 516 519 function import($data, $format, $document, $debug=false) 517 520 { 518 if ($format == 'VDEX') 519 { 521 if ($format == 'VDEX') { 522 520 523 $values = self::parseFromXml($data, $debug); 524 521 525 $sql = "UPDATE vocabulary_relationships SET "; 522 526 /* vdex_7_1_identifier */ … … 542 546 $sql .= implode(', ', $sqlSetArray); 543 547 $sql .= " WHERE id={$this->mId}"; 548 549 //pretty_print_r($sql); 550 551 552 /* The following checks are necessary untill http://bugs.php.net/bug.php?id=52682 is fixed */ 553 try { 554 VocabularyTerm::getObject(array($source_term_identifier, $source_term_vocabulary_identifier)); 555 VocabularyTerm::getObject(array($target_term_identifier, $target_term_vocabulary_identifier)); 556 VocabularyTerm::getObject(array($vdex_7_4_2_relationship_type_value, $vdex_7_4_1_relationship_type_source)); 557 } 558 catch(MissingVocabularyTermException $e) { 559 throw new ImportException($e->getMessage()); 560 } 544 561 $this->mBd->execSqlUpdate($sql, false); 545 562 } 546 else 547 { 548 echo "<h1>VocabularyRelation::import(): Erreur: Le format '$format' n'est pas supporté</h1>"; 563 else { 564 throw new ImportException("VocabularyRelation::import(): Erreur: Le format '$format' n'est pas supporté"); 549 565 } 550 566 } -
html/classes/VocabularyTerm.php
raafb30d rf4e524f 1166 1166 1167 1167 /** Fonction d'importation d'un terme dans un vocabulaire 1168 * @param $data :the dom node1168 * @param $data Object the dom node 1169 1169 @param $format VDEX 1170 1170 @param $document DOMDocument where the node comes from -
html/classes/exceptions/MissingVocabularyException.php
r3550449 rf4e524f 23 23 * @author Copyright (C) 2005 François Proulx, Technologies Coeus inc. 24 24 */ 25 require_once("ObjectNotFoundException.php"); 25 26 26 class MissingVocabularyException extends Exception27 class MissingVocabularyException extends ObjectNotFoundException 27 28 { 28 29 public function __construct($message = "", $code = 0) -
html/classes/exceptions/MissingVocabularyTermException.php
r3550449 rf4e524f 23 23 * @author Copyright (C) 2005 François Proulx, Technologies Coeus inc. 24 24 */ 25 require_once("ObjectNotFoundException.php"); 25 26 26 class MissingVocabularyTermException extends Exception27 class MissingVocabularyTermException extends ObjectNotFoundException 27 28 { 28 29 public function __construct($message = "", $code = 0) -
html/classes/exceptions/NoTaxonPathException.php
r3550449 rf4e524f 23 23 * @author Copyright (C) 2005 François Proulx, Technologies Coeus inc. 24 24 */ 25 require_once("ObjectNotFoundException.php"); 25 26 26 class NoTaxonPathException extends Exception27 class NoTaxonPathException extends ObjectNotFoundException 27 28 { 28 29 public function __construct($message=null, $code=null)
Note: See TracChangeset
for help on using the changeset viewer.
