Changeset fcf3700
- Timestamp:
- 04/30/10 15:46:52 (2 years ago)
- Branches:
- ('master', '8434b8322dd6f8ff37c17bd45b94e7a826f86b53')('vitrine', 'afe109c61a407808bd54d88bcccb1cde726a010a')
- Children:
- a04edbd9894622947728b10e2d889e6975b35391
- Parents:
- ad3626832640a4cfafb8e5960b72d0e8dec9819b
- git-author:
- maparent <maparent@9a151f2f-a8df-0310-a5c5-9fb547312938>2010-04-30 19:46:52+00:00
- git-committer:
- maparent <maparent@9a151f2f-a8df-0310-a5c5-9fb547312938>2010-04-30 19:46:52+00:00
- Location:
- trunk/html
- Files:
-
- 6 edited
-
admin/spider_admin.php (modified) (1 diff)
-
classes/AbstractSpider.php (modified) (5 diffs)
-
classes/SpiderFeed.php (modified) (1 diff)
-
classes/SpiderHTML.php (modified) (1 diff)
-
classes/SpiderOaiPmhClient.php (modified) (1 diff)
-
include/schema_validate.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/html/admin/spider_admin.php
r73ff047 rfcf3700 85 85 } 86 86 87 if($spider){echo "<form method='POST' action='' >\n";87 if($spider){echo "<form method='POST' action='' enctype='multipart/form-data'>\n"; 88 88 echo "<input type='hidden' name='spider_id' value='{$spider->getId()}'>\n"; 89 89 // Show admin UI -
trunk/html/classes/AbstractSpider.php
rf1a2cb0 rfcf3700 154 154 echo "<tr class='even'><td><b>"._("Feed URL")." : </b></td><td><input type='text' size='50' name='rep_base_url' value='{$this->getBaseUrl()}'></td></tr>\n"; 155 155 156 echo "<tr class='o od'><td><b>"._("Base synchronization theme")." : </b></td><td>";156 echo "<tr class='odd'><td><b>"._("Base synchronization theme")." : </b></td><td>"; 157 157 $vocabulary = new Vocabulary(VOC_EUREKA_THEME); 158 158 if (($selected_theme = $this->getBaseTheme()) == null) … … 178 178 echo sprintf(_("Last sync started %s and finised %s"), $this->getLastSyncStartTime(), $last_sync_date); 179 179 } 180 181 echo "</tr>\n"; 182 echo "<tr class='even'><td><b>"._("XSLT Transformation")."</b>"; 183 $transform = $this->getXslTransform(); 184 if (strlen($transform) == 0) { 185 echo ' (<i>'._("none").'</i>)'; 186 } 187 echo "</td>\n<td><INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='20000' />"; 188 echo "<input name='xsl_transform_import' type='file' /><br/>"; 189 echo "<textarea name='xsl_transform_content' rows='20' cols='80' wrap='off'>"; 190 echo htmlspecialchars($transform); 191 echo "</textarea>"; 192 echo "</td></tr>\n"; 193 180 194 echo $childUi; 181 195 echo "</table>\n"; … … 202 216 { 203 217 $this->setMetaDataExchangeFormat($_REQUEST['import_format']); 218 } 219 if (isset($_FILES['xsl_transform_import']['tmp_name']) 220 && $_FILES['xsl_transform_import']['tmp_name'] != '') { 221 $xsl = file_get_contents($_FILES['xsl_transform_import']['tmp_name']); 222 } else { 223 $xsl = $_REQUEST['xsl_transform_content']; 224 } 225 $xsl_dom = new DOMDocument(); 226 if ($xsl_dom->loadXml($xsl)) { 227 // TODO: Also check it is valid XSLT 228 $this->setXslTransform($xsl); 229 } else { 230 // If not XML, clear it. 231 $this->setXslTransform(''); 204 232 } 205 233 … … 387 415 } 388 416 417 public function getXslTransform() 418 { 419 return $this->row['xsl_transform']; 420 } 421 422 public function setXslTransform($xsl) 423 { 424 $db=AbstractDb::getObject(); 425 $xsl = $db->EscapeString($xsl); 426 $db->execSqlUpdate("UPDATE spiders SET xsl_transform = '{$xsl}' WHERE spider_id = {$this->getId()};", false); 427 $this->refresh(); 428 return true; 429 } 430 389 431 /** Run spider */ 390 432 abstract protected function harvest($verbose=false); … … 451 493 } 452 494 } 495 protected function transformDoc($xml_dom) { 496 if (!isset($this->xsl_proc_cache)) { 497 $this->xsl_proc_cache = null; 498 $xsl = $this->getXslTransform(); 499 if (isset($xsl) && $xsl != '') { 500 $xsl_proc = new XSLTProcessor(); 501 $xsl_dom = new DOMDocument(); 502 if ($xsl_dom->loadXml( $xsl )) { 503 $xsl_proc->importStylesheet( $xsl_dom ); 504 $this->xsl_proc_cache = $xsl_proc; 505 } 506 } 507 } 508 if ($this->xsl_proc_cache != null) { 509 $new_dom = $this->xsl_proc_cache->transformToDoc( $xml_dom ); 510 if ($new_dom) { 511 return $new_dom; 512 } 513 } 514 return $xml_dom; 515 } 453 516 } 454 517 -
trunk/html/classes/SpiderFeed.php
r632619d rfcf3700 67 67 else { 68 68 // Download the DOM document 69 $xml_dom = $xml_dom =DOMDocument :: load($this->getBaseURL());69 $xml_dom = DOMDocument :: load($this->getBaseURL()); 70 70 if($xml_dom == null) { 71 71 $this->reportAppend(sprintf(_("unable to retrieve feed at %s"), $this->getBaseURL())."<br>\n"); 72 72 } 73 73 else { 74 // TODO: Apply to items only? 75 $document = $this->transformDoc($document); 74 76 // Create a XPath query object 75 77 $xpath = new DOMXPath($xml_dom); -
trunk/html/classes/SpiderHTML.php
r25259d1 rfcf3700 163 163 else { 164 164 $log .= sprintf("<strong>Processing <a href='%s'>%s</a></strong></td></tr><tr><td>\n", $link_url, $link["caption"]); 165 $document = $this->transformDoc($document); 165 166 // Create an XPath for queries and register a default namespace for it. 166 167 $xpath = new DOMXPath($document); -
trunk/html/classes/SpiderOaiPmhClient.php
r7e23ae3 rfcf3700 265 265 // load the DOM in RAM 266 266 $xml_dom = DOMDocument :: loadXML($xml_file_content); 267 $xml_dom = $this->transformDoc($xml_dom); 267 268 if (OAI_PMH_VALIDATE_ENABLED && !$xml_dom->schemaValidate(OAI_PMH_VALIDATE_SCHEMA)) 268 269 { -
trunk/html/include/schema_validate.php
r72f6cf3 rfcf3700 409 409 } 410 410 411 $new_schema_version = 21; 412 if ($current_schema_version < $new_schema_version && $new_schema_version <= REQUIRED_SCHEMA_VERSION) 413 { 414 echo "<h2>"._("Preparing SQL statements to update schema to version:")." $new_schema_version</h2>"; 415 $sql .= "UPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 416 $sql .= "ALTER TABLE spiders ADD COLUMN xsl_transform text;\n"; 417 } 418 411 419 $db->execSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true); 412 420 $db->execSqlUpdate("VACUUM ANALYSE;\n", true);
Note: See TracChangeset
for help on using the changeset viewer.
