Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

добавил поиск по проектам - на основе Lucene и Zend

  • Loading branch information...
commit 41fcadf33e9d1ab43dc5fdf6530c7a4eeb8a6b57 1 parent 96f1eb3
@FladeX authored
Showing with 25,933 additions and 3 deletions.
  1. +4 −0 apps/frontend/config/routing.yml
  2. +7 −0 apps/frontend/modules/projects/actions/actions.class.php
  3. +2 −2 apps/frontend/modules/projects/templates/indexSuccess.php
  4. +46 −0 apps/frontend/modules/projects/templates/searchSuccess.php
  5. +20 −0 config/ProjectConfiguration.class.php
  6. BIN  data/projects.dev.index/_b.cfs
  7. +1 −0  data/projects.dev.index/_b.sti
  8. BIN  data/projects.dev.index/_b_a.del
  9. BIN  data/projects.dev.index/_l.cfs
  10. +1 −0  data/projects.dev.index/_l.sti
  11. BIN  data/projects.dev.index/_m.cfs
  12. +1 −0  data/projects.dev.index/_m.sti
  13. BIN  data/projects.dev.index/_m_2.del
  14. BIN  data/projects.dev.index/_n.cfs
  15. +1 −0  data/projects.dev.index/_n.sti
  16. BIN  data/projects.dev.index/_o.cfs
  17. +1 −0  data/projects.dev.index/_o.sti
  18. BIN  data/projects.dev.index/_p.cfs
  19. +1 −0  data/projects.dev.index/_p.sti
  20. 0  data/projects.dev.index/optimization.lock.file
  21. 0  data/projects.dev.index/read-lock-processing.lock.file
  22. 0  data/projects.dev.index/read.lock.file
  23. BIN  data/projects.dev.index/segments.gen
  24. BIN  data/projects.dev.index/segments_t
  25. 0  data/projects.dev.index/write.lock.file
  26. BIN  data/projects.prod.index/_a.cfs
  27. +1 −0  data/projects.prod.index/_a.sti
  28. BIN  data/projects.prod.index/_b.cfs
  29. +1 −0  data/projects.prod.index/_b.sti
  30. BIN  data/projects.prod.index/_c.cfs
  31. +1 −0  data/projects.prod.index/_c.sti
  32. +1 −0  data/projects.prod.index/index.html
  33. 0  data/projects.prod.index/optimization.lock.file
  34. 0  data/projects.prod.index/read-lock-processing.lock.file
  35. 0  data/projects.prod.index/read.lock.file
  36. BIN  data/projects.prod.index/segments.gen
  37. BIN  data/projects.prod.index/segments_f
  38. 0  data/projects.prod.index/write.lock.file
  39. +52 −0 lib/model/doctrine/projects.class.php
  40. +43 −1 lib/model/doctrine/projectsTable.class.php
  41. +96 −0 lib/vendor/Zend/Exception.php
  42. +329 −0 lib/vendor/Zend/Loader.php
  43. +589 −0 lib/vendor/Zend/Loader/Autoloader.php
  44. +43 −0 lib/vendor/Zend/Loader/Autoloader/Interface.php
  45. +472 −0 lib/vendor/Zend/Loader/Autoloader/Resource.php
  46. +35 −0 lib/vendor/Zend/Loader/Exception.php
  47. +484 −0 lib/vendor/Zend/Loader/PluginLoader.php
  48. +39 −0 lib/vendor/Zend/Loader/PluginLoader/Exception.php
  49. +75 −0 lib/vendor/Zend/Loader/PluginLoader/Interface.php
  50. +37 −0 lib/vendor/Zend/Search/Exception.php
  51. +1,579 −0 lib/vendor/Zend/Search/Lucene.php
  52. +175 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer.php
  53. +92 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common.php
  54. +96 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php
  55. +47 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php
  56. +95 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php
  57. +47 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php
  58. +126 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php
  59. +49 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php
  60. +126 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php
  61. +49 −0 lib/vendor/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php
  62. +154 −0 lib/vendor/Zend/Search/Lucene/Analysis/Token.php
  63. +47 −0 lib/vendor/Zend/Search/Lucene/Analysis/TokenFilter.php
  64. +58 −0 lib/vendor/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php
  65. +70 −0 lib/vendor/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php
  66. +69 −0 lib/vendor/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php
  67. +101 −0 lib/vendor/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php
  68. +131 −0 lib/vendor/Zend/Search/Lucene/Document.php
  69. +151 −0 lib/vendor/Zend/Search/Lucene/Document/Docx.php
  70. +37 −0 lib/vendor/Zend/Search/Lucene/Document/Exception.php
  71. +481 −0 lib/vendor/Zend/Search/Lucene/Document/Html.php
  72. +129 −0 lib/vendor/Zend/Search/Lucene/Document/OpenXml.php
  73. +200 −0 lib/vendor/Zend/Search/Lucene/Document/Pptx.php
  74. +263 −0 lib/vendor/Zend/Search/Lucene/Document/Xlsx.php
  75. +37 −0 lib/vendor/Zend/Search/Lucene/Exception.php
  76. +443 −0 lib/vendor/Zend/Search/Lucene/FSM.php
  77. +66 −0 lib/vendor/Zend/Search/Lucene/FSMAction.php
  78. +226 −0 lib/vendor/Zend/Search/Lucene/Field.php
  79. +268 −0 lib/vendor/Zend/Search/Lucene/Index/DictionaryLoader.php
  80. +59 −0 lib/vendor/Zend/Search/Lucene/Index/DocsFilter.php
  81. +50 −0 lib/vendor/Zend/Search/Lucene/Index/FieldInfo.php
  82. +2,132 −0 lib/vendor/Zend/Search/Lucene/Index/SegmentInfo.php
  83. +271 −0 lib/vendor/Zend/Search/Lucene/Index/SegmentMerger.php
  84. +634 −0 lib/vendor/Zend/Search/Lucene/Index/SegmentWriter.php
  85. +230 −0 lib/vendor/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php
  86. +94 −0 lib/vendor/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php
  87. +144 −0 lib/vendor/Zend/Search/Lucene/Index/Term.php
  88. +80 −0 lib/vendor/Zend/Search/Lucene/Index/TermInfo.php
  89. +49 −0 lib/vendor/Zend/Search/Lucene/Index/TermsPriorityQueue.php
  90. +66 −0 lib/vendor/Zend/Search/Lucene/Index/TermsStream/Interface.php
  91. +841 −0 lib/vendor/Zend/Search/Lucene/Index/Writer.php
  92. +417 −0 lib/vendor/Zend/Search/Lucene/Interface.php
  93. +236 −0 lib/vendor/Zend/Search/Lucene/LockManager.php
  94. +973 −0 lib/vendor/Zend/Search/Lucene/MultiSearcher.php
  95. +171 −0 lib/vendor/Zend/Search/Lucene/PriorityQueue.php
  96. +612 −0 lib/vendor/Zend/Search/Lucene/Proxy.php
  97. +278 −0 lib/vendor/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php
  98. +94 −0 lib/vendor/Zend/Search/Lucene/Search/Highlighter/Default.php
  99. +53 −0 lib/vendor/Zend/Search/Lucene/Search/Highlighter/Interface.php
  100. +233 −0 lib/vendor/Zend/Search/Lucene/Search/Query.php
  101. +815 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Boolean.php
  102. +138 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Empty.php
  103. +493 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Fuzzy.php
  104. +139 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Insignificant.php
  105. +668 −0 lib/vendor/Zend/Search/Lucene/Search/Query/MultiTerm.php
  106. +576 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Phrase.php
  107. +127 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Preprocessing.php
  108. +287 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php
  109. +270 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php
  110. +341 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Preprocessing/Term.php
  111. +377 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Range.php
  112. +228 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Term.php
  113. +362 −0 lib/vendor/Zend/Search/Lucene/Search/Query/Wildcard.php
  114. +67 −0 lib/vendor/Zend/Search/Lucene/Search/QueryEntry.php
  115. +116 −0 lib/vendor/Zend/Search/Lucene/Search/QueryEntry/Phrase.php
  116. +77 −0 lib/vendor/Zend/Search/Lucene/Search/QueryEntry/Subquery.php
  117. +130 −0 lib/vendor/Zend/Search/Lucene/Search/QueryEntry/Term.php
  118. +110 −0 lib/vendor/Zend/Search/Lucene/Search/QueryHit.php
  119. +510 −0 lib/vendor/Zend/Search/Lucene/Search/QueryLexer.php
  120. +635 −0 lib/vendor/Zend/Search/Lucene/Search/QueryParser.php
  121. +401 −0 lib/vendor/Zend/Search/Lucene/Search/QueryParserContext.php
  122. +41 −0 lib/vendor/Zend/Search/Lucene/Search/QueryParserException.php
  123. +225 −0 lib/vendor/Zend/Search/Lucene/Search/QueryToken.php
  124. +551 −0 lib/vendor/Zend/Search/Lucene/Search/Similarity.php
  125. +110 −0 lib/vendor/Zend/Search/Lucene/Search/Similarity/Default.php
  126. +85 −0 lib/vendor/Zend/Search/Lucene/Search/Weight.php
  127. +137 −0 lib/vendor/Zend/Search/Lucene/Search/Weight/Boolean.php
  128. +57 −0 lib/vendor/Zend/Search/Lucene/Search/Weight/Empty.php
  129. +139 −0 lib/vendor/Zend/Search/Lucene/Search/Weight/MultiTerm.php
  130. +108 −0 lib/vendor/Zend/Search/Lucene/Search/Weight/Phrase.php
  131. +125 −0 lib/vendor/Zend/Search/Lucene/Search/Weight/Term.php
  132. +136 −0 lib/vendor/Zend/Search/Lucene/Storage/Directory.php
  133. +363 −0 lib/vendor/Zend/Search/Lucene/Storage/Directory/Filesystem.php
  134. +473 −0 lib/vendor/Zend/Search/Lucene/Storage/File.php
  135. +231 −0 lib/vendor/Zend/Search/Lucene/Storage/File/Filesystem.php
  136. +601 −0 lib/vendor/Zend/Search/Lucene/Storage/File/Memory.php
  137. +172 −0 lib/vendor/Zend/Search/Lucene/TermStreamsPriorityQueue.php
View
4 apps/frontend/config/routing.yml
@@ -21,6 +21,10 @@ show_projects:
id: \d+
sf_method: [get]
+projects_search:
+ url: /search
+ param: { module: projects, action: search }
+
default_index:
url: /:module
param: { action: index }
View
7 apps/frontend/modules/projects/actions/actions.class.php
@@ -10,6 +10,13 @@
*/
class projectsActions extends sfActions
{
+ public function executeSearch(sfWebRequest $request)
+ {
+ $this->forwardUnless($query = $request->getParameter('query'), 'projects', 'index');
+
+ $this->projects = Doctrine_Core::getTable('projects')->getForLuceneQuery($query);
+ }
+
public function executeIndex(sfWebRequest $request)
{
$this->projects = Doctrine_Core::getTable('projects')->getActiveProjects();
View
4 apps/frontend/modules/projects/templates/indexSuccess.php
@@ -96,8 +96,8 @@
<div id="searchBlock" class="sidebarBlock">
<h3>Поиск</h3>
- <form action="#">
- <input id="searchQuery" type="text" name="query" />
+ <form action="<?php echo url_for('projects_search') ?>" method="get">
+ <input id="searchQuery" type="text" name="query" value="<?php echo $sf_request->getParameter('query') ?>" />
<input type="submit" value="Найти" />
</form>
</div>
View
46 apps/frontend/modules/projects/templates/searchSuccess.php
@@ -0,0 +1,46 @@
+<?php use_stylesheet('projects.css') ?>
+
+<?php slot('title', 'Поиск - posting.ru') ?>
+
+<?php slot('breadcrumbs', '<h2>Результаты поиска</h2>') ?>
+
+<div id="sidebar">
+ <div class="sidebarBlock">
+ <a id="addTaskLink" href="<?php echo url_for('projects/new') ?>">добавить задание</a>
+ </div>
+
+ <div id="searchBlock" class="sidebarBlock">
+ <h3>Поиск</h3>
+ <form action="<?php echo url_for('projects_search') ?>" method="get">
+ <input id="searchQuery" type="text" name="query" value="<?php echo $sf_request->getParameter('query') ?>" />
+ <input type="submit" value="Найти" />
+ </form>
+ </div>
+
+ <div class="sidebarBlock">
+ <div id="feedBlock" >
+ <a href="<?php echo url_for('projects', array('sf_format' => 'atom')) ?>">RSS-лента</a>
+ </div>
+ </div>
+
+</div>
+
+<div id="primaryContent">
+
+ <div id="priceMenu" class="innerMenu">
+ <div class="title">
+ <span>цена</span>/wmr
+ </div>
+
+ <ul>
+ <li><a href="#" class="current">любая</a></li>
+ <li><a href="#">до 150</a></li>
+ <li><a href="#">150-1000</a></li>
+ <li><a href="#">более 1000</a></li>
+ <li><a href="#">договорная</a></li>
+ </ul>
+ </div>
+
+ <?php include_partial('projects/list', array('projects' => $projects)) ?>
+
+</div><!-- #primaryContent -->
View
20 config/ProjectConfiguration.class.php
@@ -5,6 +5,26 @@
class ProjectConfiguration extends sfProjectConfiguration
{
+ static protected $zendLoaded = false;
+
+ static public function registerZend()
+ {
+ if (self::$zendLoaded)
+ {
+ return;
+ }
+
+ set_include_path(sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path());
+ require_once sfConfig::get('sf_lib_dir').'/vendor/Zend/Loader/Autoloader.php';
+ Zend_Loader_Autoloader::getInstance();
+ self::$zendLoaded = true;
+
+ Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
+
+ ini_set("iconv.internal_encoding", 'UTF-8');
+ Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
+ }
+
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin');
View
BIN  data/projects.dev.index/_b.cfs
Binary file not shown
View
1  data/projects.dev.index/_b.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.dev.index/_b_a.del
Binary file not shown
View
BIN  data/projects.dev.index/_l.cfs
Binary file not shown
View
1  data/projects.dev.index/_l.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.dev.index/_m.cfs
Binary file not shown
View
1  data/projects.dev.index/_m.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.dev.index/_m_2.del
Binary file not shown
View
BIN  data/projects.dev.index/_n.cfs
Binary file not shown
View
1  data/projects.dev.index/_n.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.dev.index/_o.cfs
Binary file not shown
View
1  data/projects.dev.index/_o.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.dev.index/_p.cfs
Binary file not shown
View
1  data/projects.dev.index/_p.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
0  data/projects.dev.index/optimization.lock.file
No changes.
View
0  data/projects.dev.index/read-lock-processing.lock.file
No changes.
View
0  data/projects.dev.index/read.lock.file
No changes.
View
BIN  data/projects.dev.index/segments.gen
Binary file not shown
View
BIN  data/projects.dev.index/segments_t
Binary file not shown
View
0  data/projects.dev.index/write.lock.file
No changes.
View
BIN  data/projects.prod.index/_a.cfs
Binary file not shown
View
1  data/projects.prod.index/_a.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.prod.index/_b.cfs
Binary file not shown
View
1  data/projects.prod.index/_b.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
BIN  data/projects.prod.index/_c.cfs
Binary file not shown
View
1  data/projects.prod.index/_c.sti
@@ -0,0 +1 @@
+a:2:{i:0;a:1:{i:0;a:2:{i:0;i:-1;i:1;s:0:"";}}i:1;a:1:{i:0;a:5:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;i:4;i:24;}}}
View
1  data/projects.prod.index/index.html
@@ -0,0 +1 @@
+
View
0  data/projects.prod.index/optimization.lock.file
No changes.
View
0  data/projects.prod.index/read-lock-processing.lock.file
No changes.
View
0  data/projects.prod.index/read.lock.file
No changes.
View
BIN  data/projects.prod.index/segments.gen
Binary file not shown
View
BIN  data/projects.prod.index/segments_f
Binary file not shown
View
0  data/projects.prod.index/write.lock.file
No changes.
View
52 lib/model/doctrine/projects.class.php
@@ -25,4 +25,56 @@ public function countActiveProjects()
return $this->getActiveProjectsQuery()->count();
}
+ public function updateLuceneIndex()
+ {
+ $index = projectsTable::getLuceneIndex();
+
+ // удалить существующие записи
+ foreach ($index->find('pk:'.$this->getId()) as $hit)
+ {
+ $index->delete($hit->id);
+ }
+
+ $doc = new Zend_Search_Lucene_Document();
+
+ // сохраняем первичный ключ вакансии для идентификации ее в результатах поиска
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId()));
+
+ // индексируем поля проекта
+ $doc->addField(Zend_Search_Lucene_Field::UnStored('text', $this->getText(), 'utf-8'));
+
+ // добавляем работу в индекс
+ $index->addDocument($doc);
+ $index->commit();
+ }
+
+ public function save(Doctrine_Connection $conn = null)
+ {
+ $conn = $conn ? $conn : $this->getTable()->getConnection();
+ $conn->beginTransaction();
+ try
+ {
+ $ret = parent::save($conn);
+ $this->updateLuceneIndex();
+ $conn->commit();
+ return $ret;
+ }
+ catch (Exception $e)
+ {
+ $conn->rollBack();
+ throw $e;
+ }
+ }
+
+ public function delete(Doctrine_Connection $conn = null)
+ {
+ $index = projectsTable::getLuceneIndex();
+
+ foreach ($index->find('pk:'.$this->getId()) as $hit)
+ {
+ $index->delete($hit->id);
+ }
+
+ return parent::delete($conn);
+ }
}
View
44 lib/model/doctrine/projectsTable.class.php
@@ -12,6 +12,48 @@ class projectsTable extends Doctrine_Table
*
* @return object projectsTable
*/
+ static public function getLuceneIndex()
+ {
+ ProjectConfiguration::registerZend();
+
+ if (file_exists($index = self::getLuceneIndexFile()))
+ {
+ return Zend_Search_Lucene::open($index);
+ }
+ else
+ {
+ return Zend_Search_Lucene::create($index);
+ }
+ }
+
+ static public function getLuceneIndexFile()
+ {
+ return sfConfig::get('sf_data_dir').'/projects.'.sfConfig::get('sf_environment').'.index';
+ //return sfConfig::get('sf_data_dir').'/projects.'.sfConfig::get('sf_environment').'.index';
+ }
+
+ public function getForLuceneQuery($query)
+ {
+ $hits = self::getLuceneIndex()->find($query);
+
+ $pks = array();
+ foreach ($hits as $hit) {
+ $pks[] = $hit->pk;
+ }
+
+ if (empty($pks)) {
+ return array();
+ }
+
+ $q = $this->createQuery('p')
+ ->whereIn('p.id', $pks)
+ ->limit(7);
+
+ $q = $this->addActiveProjectsQuery($q);
+
+ return $q->execute();
+ }
+
public function retrieveActiveProjects(Doctrine_Query $q)
{
return $this->addActiveProjectsQuery($q)->fetchOne();
@@ -52,7 +94,7 @@ public function addActiveProjectsQuery(Doctrine_Query $q = null)
return $q;
}
- public function getLatestProjects()
+ public function getLatestProjects() // for RSS
{
$q = Doctrine_Query::create()
->from('projects p');
View
96 lib/vendor/Zend/Exception.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
+ */
+
+/**
+* @category Zend
+* @package Zend
+* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+* @license http://framework.zend.com/license/new-bsd New BSD License
+*/
+class Zend_Exception extends Exception
+{
+ /**
+ * @var null|Exception
+ */
+ private $_previous = null;
+
+ /**
+ * Construct the exception
+ *
+ * @param string $msg
+ * @param int $code
+ * @param Exception $previous
+ * @return void
+ */
+ public function __construct($msg = '', $code = 0, Exception $previous = null)
+ {
+ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+ parent::__construct($msg, (int) $code);
+ $this->_previous = $previous;
+ } else {
+ parent::__construct($msg, (int) $code, $previous);
+ }
+ }
+
+ /**
+ * Overloading
+ *
+ * For PHP < 5.3.0, provides access to the getPrevious() method.
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ */
+ public function __call($method, array $args)
+ {
+ if ('getprevious' == strtolower($method)) {
+ return $this->_getPrevious();
+ }
+ return null;
+ }
+
+ /**
+ * String representation of the exception
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+ if (null !== ($e = $this->getPrevious())) {
+ return $e->__toString()
+ . "\n\nNext "
+ . parent::__toString();
+ }
+ }
+ return parent::__toString();
+ }
+
+ /**
+ * Returns previous Exception
+ *
+ * @return Exception|null
+ */
+ protected function _getPrevious()
+ {
+ return $this->_previous;
+ }
+}
View
329 lib/vendor/Zend/Loader.php
@@ -0,0 +1,329 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Loader.php 23775 2011-03-01 17:25:24Z ralph $
+ */
+
+/**
+ * Static methods for loading classes and files.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader
+{
+ /**
+ * Loads a class from a PHP file. The filename must be formatted
+ * as "$class.php".
+ *
+ * If $dirs is a string or an array, it will search the directories
+ * in the order supplied, and attempt to load the first matching file.
+ *
+ * If $dirs is null, it will split the class name at underscores to
+ * generate a path hierarchy (e.g., "Zend_Example_Class" will map
+ * to "Zend/Example/Class.php").
+ *
+ * If the file was not found in the $dirs, or if no $dirs were specified,
+ * it will attempt to load it from PHP's include_path.
+ *
+ * @param string $class - The full class name of a Zend component.
+ * @param string|array $dirs - OPTIONAL Either a path or an array of paths
+ * to search.
+ * @return void
+ * @throws Zend_Exception
+ */
+ public static function loadClass($class, $dirs = null)
+ {
+ if (class_exists($class, false) || interface_exists($class, false)) {
+ return;
+ }
+
+ if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Directory argument must be a string or an array');
+ }
+
+ // Autodiscover the path from the class name
+ // Implementation is PHP namespace-aware, and based on
+ // Framework Interop Group reference implementation:
+ // http://groups.google.com/group/php-standards/web/psr-0-final-proposal
+ $className = ltrim($class, '\\');
+ $file = '';
+ $namespace = '';
+ if ($lastNsPos = strripos($className, '\\')) {
+ $namespace = substr($className, 0, $lastNsPos);
+ $className = substr($className, $lastNsPos + 1);
+ $file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
+ }
+ $file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
+
+ if (!empty($dirs)) {
+ // use the autodiscovered path
+ $dirPath = dirname($file);
+ if (is_string($dirs)) {
+ $dirs = explode(PATH_SEPARATOR, $dirs);
+ }
+ foreach ($dirs as $key => $dir) {
+ if ($dir == '.') {
+ $dirs[$key] = $dirPath;
+ } else {
+ $dir = rtrim($dir, '\\/');
+ $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
+ }
+ }
+ $file = basename($file);
+ self::loadFile($file, $dirs, true);
+ } else {
+ self::loadFile($file, null, true);
+ }
+
+ if (!class_exists($class, false) && !interface_exists($class, false)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file");
+ }
+ }
+
+ /**
+ * Loads a PHP file. This is a wrapper for PHP's include() function.
+ *
+ * $filename must be the complete filename, including any
+ * extension such as ".php". Note that a security check is performed that
+ * does not permit extended characters in the filename. This method is
+ * intended for loading Zend Framework files.
+ *
+ * If $dirs is a string or an array, it will search the directories
+ * in the order supplied, and attempt to load the first matching file.
+ *
+ * If the file was not found in the $dirs, or if no $dirs were specified,
+ * it will attempt to load it from PHP's include_path.
+ *
+ * If $once is TRUE, it will use include_once() instead of include().
+ *
+ * @param string $filename
+ * @param string|array $dirs - OPTIONAL either a path or array of paths
+ * to search.
+ * @param boolean $once
+ * @return boolean
+ * @throws Zend_Exception
+ */
+ public static function loadFile($filename, $dirs = null, $once = false)
+ {
+ self::_securityCheck($filename);
+
+ /**
+ * Search in provided directories, as well as include_path
+ */
+ $incPath = false;
+ if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
+ if (is_array($dirs)) {
+ $dirs = implode(PATH_SEPARATOR, $dirs);
+ }
+ $incPath = get_include_path();
+ set_include_path($dirs . PATH_SEPARATOR . $incPath);
+ }
+
+ /**
+ * Try finding for the plain filename in the include_path.
+ */
+ if ($once) {
+ include_once $filename;
+ } else {
+ include $filename;
+ }
+
+ /**
+ * If searching in directories, reset include_path
+ */
+ if ($incPath) {
+ set_include_path($incPath);
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns TRUE if the $filename is readable, or FALSE otherwise.
+ * This function uses the PHP include_path, where PHP's is_readable()
+ * does not.
+ *
+ * Note from ZF-2900:
+ * If you use custom error handler, please check whether return value
+ * from error_reporting() is zero or not.
+ * At mark of fopen() can not suppress warning if the handler is used.
+ *
+ * @param string $filename
+ * @return boolean
+ */
+ public static function isReadable($filename)
+ {
+ if (is_readable($filename)) {
+ // Return early if the filename is readable without needing the
+ // include_path
+ return true;
+ }
+
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
+ && preg_match('/^[a-z]:/i', $filename)
+ ) {
+ // If on windows, and path provided is clearly an absolute path,
+ // return false immediately
+ return false;
+ }
+
+ foreach (self::explodeIncludePath() as $path) {
+ if ($path == '.') {
+ if (is_readable($filename)) {
+ return true;
+ }
+ continue;
+ }
+ $file = $path . '/' . $filename;
+ if (is_readable($file)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Explode an include path into an array
+ *
+ * If no path provided, uses current include_path. Works around issues that
+ * occur when the path includes stream schemas.
+ *
+ * @param string|null $path
+ * @return array
+ */
+ public static function explodeIncludePath($path = null)
+ {
+ if (null === $path) {
+ $path = get_include_path();
+ }
+
+ if (PATH_SEPARATOR == ':') {
+ // On *nix systems, include_paths which include paths with a stream
+ // schema cannot be safely explode'd, so we have to be a bit more
+ // intelligent in the approach.
+ $paths = preg_split('#:(?!//)#', $path);
+ } else {
+ $paths = explode(PATH_SEPARATOR, $path);
+ }
+ return $paths;
+ }
+
+ /**
+ * spl_autoload() suitable implementation for supporting class autoloading.
+ *
+ * Attach to spl_autoload() using the following:
+ * <code>
+ * spl_autoload_register(array('Zend_Loader', 'autoload'));
+ * </code>
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class
+ * @return string|false Class name on success; false on failure
+ */
+ public static function autoload($class)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ try {
+ @self::loadClass($class);
+ return $class;
+ } catch (Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Register {@link autoload()} with spl_autoload()
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class (optional)
+ * @param boolean $enabled (optional)
+ * @return void
+ * @throws Zend_Exception if spl_autoload() is not found
+ * or if the specified class does not have an autoload() method.
+ */
+ public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ require_once 'Zend/Loader/Autoloader.php';
+ $autoloader = Zend_Loader_Autoloader::getInstance();
+ $autoloader->setFallbackAutoloader(true);
+
+ if ('Zend_Loader' != $class) {
+ self::loadClass($class);
+ $methods = get_class_methods($class);
+ if (!in_array('autoload', (array) $methods)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
+ }
+
+ $callback = array($class, 'autoload');
+
+ if ($enabled) {
+ $autoloader->pushAutoloader($callback);
+ } else {
+ $autoloader->removeAutoloader($callback);
+ }
+ }
+ }
+
+ /**
+ * Ensure that filename does not contain exploits
+ *
+ * @param string $filename
+ * @return void
+ * @throws Zend_Exception
+ */
+ protected static function _securityCheck($filename)
+ {
+ /**
+ * Security check
+ */
+ if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Security check: Illegal character in filename');
+ }
+ }
+
+ /**
+ * Attempt to include() the file.
+ *
+ * include() is not prefixed with the @ operator because if
+ * the file is loaded and contains a parse error, execution
+ * will halt silently and this is difficult to debug.
+ *
+ * Always set display_errors = Off on production servers!
+ *
+ * @param string $filespec
+ * @param boolean $once
+ * @return boolean
+ * @deprecated Since 1.5.0; use loadFile() instead
+ */
+ protected static function _includeFile($filespec, $once = false)
+ {
+ if ($once) {
+ return include_once $filespec;
+ } else {
+ return include $filespec ;
+ }
+ }
+}
View
589 lib/vendor/Zend/Loader/Autoloader.php
@@ -0,0 +1,589 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id: Autoloader.php 23953 2011-05-03 05:47:39Z ralph $
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** Zend_Loader */
+require_once 'Zend/Loader.php';
+
+/**
+ * Autoloader stack and namespace autoloader
+ *
+ * @uses Zend_Loader_Autoloader
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Autoloader
+{
+ /**
+ * @var Zend_Loader_Autoloader Singleton instance
+ */
+ protected static $_instance;
+
+ /**
+ * @var array Concrete autoloader callback implementations
+ */
+ protected $_autoloaders = array();
+
+ /**
+ * @var array Default autoloader callback
+ */
+ protected $_defaultAutoloader = array('Zend_Loader', 'loadClass');
+
+ /**
+ * @var bool Whether or not to act as a fallback autoloader
+ */
+ protected $_fallbackAutoloader = false;
+
+ /**
+ * @var array Callback for internal autoloader implementation
+ */
+ protected $_internalAutoloader;
+
+ /**
+ * @var array Supported namespaces 'Zend' and 'ZendX' by default.
+ */
+ protected $_namespaces = array(
+ 'Zend_' => true,
+ 'ZendX_' => true,
+ );
+
+ /**
+ * @var array Namespace-specific autoloaders
+ */
+ protected $_namespaceAutoloaders = array();
+
+ /**
+ * @var bool Whether or not to suppress file not found warnings
+ */
+ protected $_suppressNotFoundWarnings = false;
+
+ /**
+ * @var null|string
+ */
+ protected $_zfPath;
+
+ /**
+ * Retrieve singleton instance
+ *
+ * @return Zend_Loader_Autoloader
+ */
+ public static function getInstance()
+ {
+ if (null === self::$_instance) {
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * Reset the singleton instance
+ *
+ * @return void
+ */
+ public static function resetInstance()
+ {
+ self::$_instance = null;
+ }
+
+ /**
+ * Autoload a class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public static function autoload($class)
+ {
+ $self = self::getInstance();
+
+ foreach ($self->getClassAutoloaders($class) as $autoloader) {
+ if ($autoloader instanceof Zend_Loader_Autoloader_Interface) {
+ if ($autoloader->autoload($class)) {
+ return true;
+ }
+ } elseif (is_array($autoloader)) {
+ if (call_user_func($autoloader, $class)) {
+ return true;
+ }
+ } elseif (is_string($autoloader) || is_callable($autoloader)) {
+ if ($autoloader($class)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Set the default autoloader implementation
+ *
+ * @param string|array $callback PHP callback
+ * @return void
+ */
+ public function setDefaultAutoloader($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new Zend_Loader_Exception('Invalid callback specified for default autoloader');
+ }
+
+ $this->_defaultAutoloader = $callback;
+ return $this;
+ }
+
+ /**
+ * Retrieve the default autoloader callback
+ *
+ * @return string|array PHP Callback
+ */
+ public function getDefaultAutoloader()
+ {
+ return $this->_defaultAutoloader;
+ }
+
+ /**
+ * Set several autoloader callbacks at once
+ *
+ * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders
+ * @return Zend_Loader_Autoloader
+ */
+ public function setAutoloaders(array $autoloaders)
+ {
+ $this->_autoloaders = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Get attached autoloader implementations
+ *
+ * @return array
+ */
+ public function getAutoloaders()
+ {
+ return $this->_autoloaders;
+ }
+
+ /**
+ * Return all autoloaders for a given namespace
+ *
+ * @param string $namespace
+ * @return array
+ */
+ public function getNamespaceAutoloaders($namespace)
+ {
+ $namespace = (string) $namespace;
+ if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
+ return array();
+ }
+ return $this->_namespaceAutoloaders[$namespace];
+ }
+
+ /**
+ * Register a namespace to autoload
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function registerNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (!isset($this->_namespaces[$ns])) {
+ $this->_namespaces[$ns] = true;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Unload a registered autoload namespace
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function unregisterNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (isset($this->_namespaces[$ns])) {
+ unset($this->_namespaces[$ns]);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get a list of registered autoload namespaces
+ *
+ * @return array
+ */
+ public function getRegisteredNamespaces()
+ {
+ return array_keys($this->_namespaces);
+ }
+
+ public function setZfPath($spec, $version = 'latest')
+ {
+ $path = $spec;
+ if (is_array($spec)) {
+ if (!isset($spec['path'])) {
+ throw new Zend_Loader_Exception('No path specified for ZF');
+ }
+ $path = $spec['path'];
+ if (isset($spec['version'])) {
+ $version = $spec['version'];
+ }
+ }
+
+ $this->_zfPath = $this->_getVersionPath($path, $version);
+ set_include_path(implode(PATH_SEPARATOR, array(
+ $this->_zfPath,
+ get_include_path(),
+ )));
+ return $this;
+ }
+
+ public function getZfPath()
+ {
+ return $this->_zfPath;
+ }
+
+ /**
+ * Get or set the value of the "suppress not found warnings" flag
+ *
+ * @param null|bool $flag
+ * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
+ */
+ public function suppressNotFoundWarnings($flag = null)
+ {
+ if (null === $flag) {
+ return $this->_suppressNotFoundWarnings;
+ }
+ $this->_suppressNotFoundWarnings = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Indicate whether or not this autoloader should be a fallback autoloader
+ *
+ * @param bool $flag
+ * @return Zend_Loader_Autoloader
+ */
+ public function setFallbackAutoloader($flag)
+ {
+ $this->_fallbackAutoloader = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Is this instance acting as a fallback autoloader?
+ *
+ * @return bool
+ */
+ public function isFallbackAutoloader()
+ {
+ return $this->_fallbackAutoloader;
+ }
+
+ /**
+ * Get autoloaders to use when matching class
+ *
+ * Determines if the class matches a registered namespace, and, if so,
+ * returns only the autoloaders for that namespace. Otherwise, it returns
+ * all non-namespaced autoloaders.
+ *
+ * @param string $class
+ * @return array Array of autoloaders to use
+ */
+ public function getClassAutoloaders($class)
+ {
+ $namespace = false;
+ $autoloaders = array();
+
+ // Add concrete namespaced autoloaders
+ foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
+ if ('' == $ns) {
+ continue;
+ }
+ if (0 === strpos($class, $ns)) {
+ if ((false === $namespace) || (strlen($ns) > strlen($namespace))) {
+ $namespace = $ns;
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ }
+ }
+ }
+
+ // Add internal namespaced autoloader
+ foreach ($this->getRegisteredNamespaces() as $ns) {
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders[] = $this->_internalAutoloader;
+ break;
+ }
+ }
+
+ // Add non-namespaced autoloaders
+ $autoloadersNonNamespace = $this->getNamespaceAutoloaders('');
+ if (count($autoloadersNonNamespace)) {
+ foreach ($autoloadersNonNamespace as $ns) {
+ $autoloaders[] = $ns;
+ }
+ unset($autoloadersNonNamespace);
+ }
+
+ // Add fallback autoloader
+ if (!$namespace && $this->isFallbackAutoloader()) {
+ $autoloaders[] = $this->_internalAutoloader;
+ }
+
+ return $autoloaders;
+ }
+
+ /**
+ * Add an autoloader to the beginning of the stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function unshiftAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_unshift($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_unshift($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append an autoloader to the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function pushAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_push($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_push($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Remove an autoloader from the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader
+ * @return Zend_Loader_Autoloader
+ */
+ public function removeAutoloader($callback, $namespace = null)
+ {
+ if (null === $namespace) {
+ $autoloaders = $this->getAutoloaders();
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->setAutoloaders($autoloaders);
+ }
+
+ foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) {
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ } else {
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Constructor
+ *
+ * Registers instance with spl_autoload stack
+ *
+ * @return void
+ */
+ protected function __construct()
+ {
+ spl_autoload_register(array(__CLASS__, 'autoload'));
+ $this->_internalAutoloader = array($this, '_autoload');
+ }
+
+ /**
+ * Internal autoloader implementation
+ *
+ * @param string $class
+ * @return bool
+ */
+ protected function _autoload($class)
+ {
+ $callback = $this->getDefaultAutoloader();
+ try {
+ if ($this->suppressNotFoundWarnings()) {
+ @call_user_func($callback, $class);
+ } else {
+ call_user_func($callback, $class);
+ }
+ return $class;
+ } catch (Zend_Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Set autoloaders for a specific namespace
+ *
+ * @param array $autoloaders
+ * @param string $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '')
+ {
+ $namespace = (string) $namespace;
+ $this->_namespaceAutoloaders[$namespace] = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Retrieve the filesystem path for the requested ZF version
+ *
+ * @param string $path
+ * @param string $version
+ * @return void
+ */
+ protected function _getVersionPath($path, $version)
+ {
+ $type = $this->_getVersionType($version);
+
+ if ($type == 'latest') {
+ $version = 'latest';
+ }
+
+ $availableVersions = $this->_getAvailableVersions($path, $version);
+ if (empty($availableVersions)) {
+ throw new Zend_Loader_Exception('No valid ZF installations discovered');
+ }
+
+ $matchedVersion = array_pop($availableVersions);
+ return $matchedVersion;
+ }
+
+ /**
+ * Retrieve the ZF version type
+ *
+ * @param string $version
+ * @return string "latest", "major", "minor", or "specific"
+ * @throws Zend_Loader_Exception if version string contains too many dots
+ */
+ protected function _getVersionType($version)
+ {
+ if (strtolower($version) == 'latest') {
+ return 'latest';
+ }
+
+ $parts = explode('.', $version);
+ $count = count($parts);
+ if (1 == $count) {
+ return 'major';
+ }
+ if (2 == $count) {
+ return 'minor';
+ }
+ if (3 < $count) {
+ throw new Zend_Loader_Exception('Invalid version string provided');
+ }
+ return 'specific';
+ }
+
+ /**
+ * Get available versions for the version type requested
+ *
+ * @param string $path
+ * @param string $version
+ * @return array
+ */
+ protected function _getAvailableVersions($path, $version)
+ {
+ if (!is_dir($path)) {
+ throw new Zend_Loader_Exception('Invalid ZF path provided');
+ }
+
+ $path = rtrim($path, '/');
+ $path = rtrim($path, '\\');
+ $versionLen = strlen($version);
+ $versions = array();
+ $dirs = glob("$path/*", GLOB_ONLYDIR);
+ foreach ((array) $dirs as $dir) {
+ $dirName = substr($dir, strlen($path) + 1);
+ if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) {
+ continue;
+ }
+
+ $matchedVersion = $matches[1];
+
+ if (('latest' == $version)
+ || ((strlen($matchedVersion) >= $versionLen)
+ && (0 === strpos($matchedVersion, $version)))
+ ) {
+ $versions[$matchedVersion] = $dir . '/library';
+ }
+ }
+
+ uksort($versions, 'version_compare');
+ return $versions;
+ }
+}
View
43 lib/vendor/Zend/Loader/Autoloader/Interface.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id: Interface.php 23775 2011-03-01 17:25:24Z ralph $
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * Autoloader interface
+ *
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Loader_Autoloader_Interface
+{
+ /**
+ * Autoload a class
+ *
+ * @abstract
+ * @param string $class
+ * @return mixed
+ * False [if unable to load $class]
+ * get_class($class) [if $class is successfully loaded]
+ */
+ public function autoload($class);
+}
View
472 lib/vendor/Zend/Loader/Autoloader/Resource.php
@@ -0,0 +1,472 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id: Resource.php 23860 2011-04-14 17:03:28Z matthew $
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** Zend_Loader_Autoloader_Interface */
+require_once 'Zend/Loader/Autoloader/Interface.php';
+
+/**
+ * Resource loader
+ *
+ * @uses Zend_Loader_Autoloader_Interface
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interface
+{
+ /**
+ * @var string Base path to resource classes
+ */
+ protected $_basePath;
+
+ /**
+ * @var array Components handled within this resource
+ */
+ protected $_components = array();
+
+ /**
+ * @var string Default resource/component to use when using object registry
+ */
+ protected $_defaultResourceType;
+
+ /**
+ * @var string Namespace of classes within this resource
+ */
+ protected $_namespace;
+
+ /**
+ * @var array Available resource types handled by this resource autoloader
+ */
+ protected $_resourceTypes = array();
+
+ /**
+ * Constructor
+ *
+ * @param array|Zend_Config $options Configuration options for resource autoloader
+ * @return void
+ */
+ public function __construct($options)
+ {
+ if ($options instanceof Zend_Config) {
+ $options = $options->toArray();
+ }
+ if (!is_array($options)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Options must be passed to resource loader constructor');
+ }
+
+ $this->setOptions($options);
+
+ $namespace = $this->getNamespace();
+ if ((null === $namespace)
+ || (null === $this->getBasePath())
+ ) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Resource loader requires both a namespace and a base path for initialization');
+ }
+
+ if (!empty($namespace)) {
+ $namespace .= '_';
+ }
+ require_once 'Zend/Loader/Autoloader.php';
+ Zend_Loader_Autoloader::getInstance()->unshiftAutoloader($this, $namespace);
+ }
+
+ /**
+ * Overloading: methods
+ *
+ * Allow retrieving concrete resource object instances using 'get<Resourcename>()'
+ * syntax. Example:
+ * <code>
+ * $loader = new Zend_Loader_Autoloader_Resource(array(
+ * 'namespace' => 'Stuff_',
+ * 'basePath' => '/path/to/some/stuff',
+ * ))
+ * $loader->addResourceType('Model', 'models', 'Model');
+ *
+ * $foo = $loader->getModel('Foo'); // get instance of Stuff_Model_Foo class
+ * </code>
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ * @throws Zend_Loader_Exception if method not beginning with 'get' or not matching a valid resource type is called
+ */
+ public function __call($method, $args)
+ {
+ if ('get' == substr($method, 0, 3)) {
+ $type = strtolower(substr($method, 3));
+ if (!$this->hasResourceType($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Invalid resource type $type; cannot load resource");
+ }
+ if (empty($args)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Cannot load resources; no resource specified");
+ }
+ $resource = array_shift($args);
+ return $this->load($resource, $type);
+ }
+
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception("Method '$method' is not supported");
+ }
+
+ /**
+ * Helper method to calculate the correct class path
+ *
+ * @param string $class
+ * @return False if not matched other wise the correct path
+ */
+ public function getClassPath($class)
+ {
+ $segments = explode('_', $class);
+ $namespaceTopLevel = $this->getNamespace();
+ $namespace = '';
+
+ if (!empty($namespaceTopLevel)) {
+ $namespace = array();
+ $topLevelSegments = count(explode('_', $namespaceTopLevel));
+ for ($i = 0; $i < $topLevelSegments; $i++) {
+ $namespace[] = array_shift($segments);
+ }
+ $namespace = implode('_', $namespace);
+ if ($namespace != $namespaceTopLevel) {
+ // wrong prefix? we're done
+ return false;
+ }
+ }
+
+ if (count($segments) < 2) {
+ // assumes all resources have a component and class name, minimum
+ return false;
+ }
+
+ $final = array_pop($segments);
+ $component = $namespace;
+ $lastMatch = false;
+ do {
+ $segment = array_shift($segments);
+ $component .= empty($component) ? $segment : '_' . $segment;
+ if (isset($this->_components[$component])) {
+ $lastMatch = $component;
+ }
+ } while (count($segments));
+
+ if (!$lastMatch) {
+ return false;
+ }
+
+ $final = substr($class, strlen($lastMatch) + 1);
+ $path = $this->_components[$lastMatch];
+ $classPath = $path . '/' . str_replace('_', '/', $final) . '.php';
+
+ if (Zend_Loader::isReadable($classPath)) {
+ return $classPath;
+ }
+
+ return false;
+ }
+
+ /**
+ * Attempt to autoload a class
+ *
+ * @param string $class
+ * @return mixed False if not matched, otherwise result if include operation
+ */
+ public function autoload($class)
+ {
+ $classPath = $this->getClassPath($class);
+ if (false !== $classPath) {
+ return include $classPath;
+ }
+ return false;
+ }
+
+ /**
+ * Set class state from options
+ *
+ * @param array $options
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setOptions(array $options)
+ {
+ // Set namespace first, see ZF-10836
+ if (isset($options['namespace'])) {
+ $this->setNamespace($options['namespace']);
+ unset($options['namespace']);
+ }
+
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Set namespace that this autoloader handles
+ *
+ * @param string $namespace
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setNamespace($namespace)
+ {
+ $this->_namespace = rtrim((string) $namespace, '_');
+ return $this;
+ }
+
+ /**
+ * Get namespace this autoloader handles
+ *
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->_namespace;
+ }
+
+ /**
+ * Set base path for this set of resources
+ *
+ * @param string $path
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setBasePath($path)
+ {
+ $this->_basePath = (string) $path;
+ return $this;
+ }
+
+ /**
+ * Get base path to this set of resources
+ *
+ * @return string
+ */
+ public function getBasePath()
+ {
+ return $this->_basePath;
+ }
+
+ /**
+ * Add resource type
+ *
+ * @param string $type identifier for the resource type being loaded
+ * @param string $path path relative to resource base path containing the resource types
+ * @param null|string $namespace sub-component namespace to append to base namespace that qualifies this resource type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function addResourceType($type, $path, $namespace = null)
+ {
+ $type = strtolower($type);
+ if (!isset($this->_resourceTypes[$type])) {
+ if (null === $namespace) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace');
+ }
+ $namespaceTopLevel = $this->getNamespace();
+ $namespace = ucfirst(trim($namespace, '_'));
+ $this->_resourceTypes[$type] = array(
+ 'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace,
+ );
+ }
+ if (!is_string($path)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Invalid path specification provided; must be string');
+ }
+ $this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/');
+
+ $component = $this->_resourceTypes[$type]['namespace'];
+ $this->_components[$component] = $this->_resourceTypes[$type]['path'];
+ return $this;
+ }
+
+ /**
+ * Add multiple resources at once
+ *
+ * $types should be an associative array of resource type => specification
+ * pairs. Each specification should be an associative array containing
+ * minimally the 'path' key (specifying the path relative to the resource
+ * base path) and optionally the 'namespace' key (indicating the subcomponent
+ * namespace to append to the resource namespace).
+ *
+ * As an example:
+ * <code>
+ * $loader->addResourceTypes(array(
+ * 'model' => array(
+ * 'path' => 'models',
+ * 'namespace' => 'Model',
+ * ),
+ * 'form' => array(
+ * 'path' => 'forms',
+ * 'namespace' => 'Form',
+ * ),
+ * ));
+ * </code>
+ *
+ * @param array $types
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function addResourceTypes(array $types)
+ {
+ foreach ($types as $type => $spec) {
+ if (!is_array($spec)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays');
+ }
+ if (!isset($spec['path'])) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element');
+ }
+ $paths = $spec['path'];
+ $namespace = null;
+ if (isset($spec['namespace'])) {
+ $namespace = $spec['namespace'];
+ }
+ $this->addResourceType($type, $paths, $namespace);
+ }
+ return $this;
+ }
+
+ /**
+ * Overwrite existing and set multiple resource types at once
+ *
+ * @see Zend_Loader_Autoloader_Resource::addResourceTypes()
+ * @param array $types
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setResourceTypes(array $types)
+ {
+ $this->clearResourceTypes();
+ return $this->addResourceTypes($types);
+ }
+
+ /**
+ * Retrieve resource type mappings
+ *
+ * @return array
+ */
+ public function getResourceTypes()
+ {
+ return $this->_resourceTypes;
+ }
+
+ /**
+ * Is the requested resource type defined?
+ *
+ * @param string $type
+ * @return bool
+ */
+ public function hasResourceType($type)
+ {
+ return isset($this->_resourceTypes[$type]);
+ }
+
+ /**
+ * Remove the requested resource type
+ *
+ * @param string $type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function removeResourceType($type)
+ {
+ if ($this->hasResourceType($type)) {
+ $namespace = $this->_resourceTypes[$type]['namespace'];
+ unset($this->_components[$namespace]);
+ unset($this->_resourceTypes[$type]);
+ }
+ return $this;
+ }
+
+ /**
+ * Clear all resource types
+ *
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function clearResourceTypes()
+ {
+ $this->_resourceTypes = array();
+ $this->_components = array();
+ return $this;
+ }
+
+ /**
+ * Set default resource type to use when calling load()
+ *
+ * @param string $type
+ * @return Zend_Loader_Autoloader_Resource
+ */
+ public function setDefaultResourceType($type)
+ {
+ if ($this->hasResourceType($type)) {
+ $this->_defaultResourceType = $type;
+ }
+ return $this;
+ }
+
+ /**
+ * Get default resource type to use when calling load()
+ *
+ * @return string|null
+ */
+ public function getDefaultResourceType()
+ {
+ return $this->_defaultResourceType;
+ }
+
+ /**
+ * Object registry and factory
+ *
+ * Loads the requested resource of type $type (or uses the default resource
+ * type if none provided). If the resource has been loaded previously,
+ * returns the previous instance; otherwise, instantiates it.
+ *
+ * @param string $resource
+ * @param string $type
+ * @return object
+ * @throws Zend_Loader_Exception if resource type not specified or invalid
+ */
+ public function load($resource, $type = null)
+ {
+ if (null === $type) {
+ $type = $this->getDefaultResourceType();
+ if (empty($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('No resource type specified');
+ }
+ }
+ if (!$this->hasResourceType($type)) {
+ require_once 'Zend/Loader/Exception.php';
+ throw new Zend_Loader_Exception('Invalid resource type specified');
+ }
+ $namespace = $this->_resourceTypes[$type]['namespace'];
+ $class = $namespace . '_' . ucfirst($resource);
+ if (!isset($this->_resources[$class])) {
+ $this->_resources[$class] = new $class;
+ }
+ return $this->_resources[$class];
+ }
+}
View
35 lib/vendor/Zend/Loader/Exception.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
+ */
+
+/**
+ * @see Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * @category Zend
+ * @package Zend_Loader
+ * @uses Zend_Exception
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Exception extends Zend_Exception
+{}
View
484 lib/vendor/Zend/Loader/PluginLoader.php
@@ -0,0 +1,484 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage PluginLoader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: PluginLoader.php 23775 2011-03-01 17:25:24Z ralph $
+ */
+
+/** Zend_Loader_PluginLoader_Interface */
+require_once 'Zend/Loader/PluginLoader/Interface.php';
+
+/** Zend_Loader */
+require_once 'Zend/Loader.php';
+
+/**
+ * Generic plugin class loader
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage PluginLoader
+ * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface
+{
+ /**
+ * Class map cache file
+ * @var string
+ */
+ protected static $_includeFileCache;
+
+ /**
+ * Instance loaded plugin paths
+ *
+ * @var array
+ */
+ protected $_loadedPluginPaths = array();
+
+ /**
+ * Instance loaded plugins
+ *
+ * @var array
+ */
+ protected $_loadedPlugins = array();
+
+ /**
+ * Instance registry property
+ *
+ * @var array
+ */
+ protected $_prefixToPaths = array();
+
+ /**
+ * Statically loaded plugin path mappings
+ *
+ * @var array
+ */
+ protected static $_staticLoadedPluginPaths = array();
+
+ /**
+ * Statically loaded plugins
+ *
+ * @var array
+ */