summaryrefslogtreecommitdiff
path: root/buildscripts/index/api_index.php
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /buildscripts/index/api_index.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'buildscripts/index/api_index.php')
-rw-r--r--buildscripts/index/api_index.php240
1 files changed, 120 insertions, 120 deletions
diff --git a/buildscripts/index/api_index.php b/buildscripts/index/api_index.php
index c85fa267..339cb042 100644
--- a/buildscripts/index/api_index.php
+++ b/buildscripts/index/api_index.php
@@ -1,121 +1,121 @@
-<?php
-/*
- * Created on 10/05/2006
- */
-
-class api_index
-{
- const API_URL = '';
-
- private $_index;
- private $_api;
-
- public function __construct($index_file, $api)
- {
- $this->_api = $api;
- $this->_index = new Zend_Search_Lucene($index_file, true);
-
-
- }
-
- function create_index()
- {
- echo "Building search index...\n";
- $files = $this->get_file_list($this->_api);
- $count = 0;
- foreach($files as $file)
- {
- echo " processing $file...\n";
- $content = $this->get_details($file, $this->_api);
-
- $doc = new Zend_Search_Lucene_Document();
-
- $title = $content['namespace'].'.'.$content['class'];
-
- echo " Adding ".$title."\n";
-
- //unsearchable text
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $title));
- //$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
-
- //searchable
- $body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);
- $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
- $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
- $this->_index->addDocument($doc);
- $count++;
- }
- $this->_index->commit();
- echo "\n {$count} files indexed.\n";
- }
-
- function sanitize($input)
- {
- return htmlentities(strip_tags( $input ));
- }
-
-
- function get_file_list($path)
- {
-
- $d = dir($path);
-
- $files = array();
- while (false !== ($entry = $d->read()))
- {
- $filepath = $path.'/'.$entry;
-
- if(is_dir($filepath) && is_int(strpos($entry, 'System')))
- {
- $files = array_merge($files, $this->get_files($filepath));
- }
- }
-
- $d->close();
- return $files;
- }
-
- function get_files($path)
- {
- $d = dir($path);
-
- $files = array();
- while (false !== ($entry = $d->read()))
- {
- $filepath = $path.'/'.$entry;
- if(is_file($filepath) && $entry[0] !== '_')
- $files[] = realpath($filepath);
- }
- $d->close();
- return $files;
- }
-
- function get_doc_content($file)
- {
- $content = file_get_contents($file);
- $html = preg_replace('/<h1>/','~~~', $content);
- $html = preg_replace('/<![^~]+/m', '', $html);
- $html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
- $html = preg_replace('/&nbsp;|~+|\s{2,}/',' ',$html);
- $html = preg_replace('/\s{2,}/',' ',$html);
- $text = strip_tags($html);
- $text = str_replace(' , ',', ',$text);
- return $text;
- }
-
- function get_details($file, $base)
- {
- $result['content'] = $this->get_doc_content($file);
- $find = array($base, '.html', '-');
- $replace = array('', '', '.');
- $path = preg_split('/\/|\\\/', str_replace($find, $replace, $file));
- $result['namespace'] = $path[1];
- $result['class'] = $path[2];
- $result['link'] = self::API_URL.$path[1].'/'.$path[2].'.html';
- return $result;
- }
-}
-
-
+<?php
+/*
+ * Created on 10/05/2006
+ */
+
+class api_index
+{
+ const API_URL = '';
+
+ private $_index;
+ private $_api;
+
+ public function __construct($index_file, $api)
+ {
+ $this->_api = $api;
+ $this->_index = new Zend_Search_Lucene($index_file, true);
+
+
+ }
+
+ function create_index()
+ {
+ echo "Building search index...\n";
+ $files = $this->get_file_list($this->_api);
+ $count = 0;
+ foreach($files as $file)
+ {
+ echo " processing $file...\n";
+ $content = $this->get_details($file, $this->_api);
+
+ $doc = new Zend_Search_Lucene_Document();
+
+ $title = $content['namespace'].'.'.$content['class'];
+
+ echo " Adding ".$title."\n";
+
+ //unsearchable text
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $title));
+ //$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
+
+ //searchable
+ $body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
+ $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
+ $this->_index->addDocument($doc);
+ $count++;
+ }
+ $this->_index->commit();
+ echo "\n {$count} files indexed.\n";
+ }
+
+ function sanitize($input)
+ {
+ return htmlentities(strip_tags( $input ));
+ }
+
+
+ function get_file_list($path)
+ {
+
+ $d = dir($path);
+
+ $files = array();
+ while (false !== ($entry = $d->read()))
+ {
+ $filepath = $path.'/'.$entry;
+
+ if(is_dir($filepath) && is_int(strpos($entry, 'System')))
+ {
+ $files = array_merge($files, $this->get_files($filepath));
+ }
+ }
+
+ $d->close();
+ return $files;
+ }
+
+ function get_files($path)
+ {
+ $d = dir($path);
+
+ $files = array();
+ while (false !== ($entry = $d->read()))
+ {
+ $filepath = $path.'/'.$entry;
+ if(is_file($filepath) && $entry[0] !== '_')
+ $files[] = realpath($filepath);
+ }
+ $d->close();
+ return $files;
+ }
+
+ function get_doc_content($file)
+ {
+ $content = file_get_contents($file);
+ $html = preg_replace('/<h1>/','~~~', $content);
+ $html = preg_replace('/<![^~]+/m', '', $html);
+ $html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
+ $html = preg_replace('/&nbsp;|~+|\s{2,}/',' ',$html);
+ $html = preg_replace('/\s{2,}/',' ',$html);
+ $text = strip_tags($html);
+ $text = str_replace(' , ',', ',$text);
+ return $text;
+ }
+
+ function get_details($file, $base)
+ {
+ $result['content'] = $this->get_doc_content($file);
+ $find = array($base, '.html', '-');
+ $replace = array('', '', '.');
+ $path = preg_split('/\/|\\\/', str_replace($find, $replace, $file));
+ $result['namespace'] = $path[1];
+ $result['class'] = $path[2];
+ $result['link'] = self::API_URL.$path[1].'/'.$path[2].'.html';
+ return $result;
+ }
+}
+
+
?> \ No newline at end of file