Author: pmacadden
Date: 2010-03-09 13:34:18 +0100 (Tue, 09 Mar 2010)
New Revision: 28431
Added:
plugins/dcSwishPlugin/trunk/config/
plugins/dcSwishPlugin/trunk/config/routing.yml
plugins/dcSwishPlugin/trunk/config/swish.config.sample
plugins/dcSwishPlugin/trunk/lib/
plugins/dcSwishPlugin/trunk/lib/SwishManager.class.php
plugins/dcSwishPlugin/trunk/lib/SwishPager.class.php
plugins/dcSwishPlugin/trunk/lib/SwishResultWrapper.class.php
plugins/dcSwishPlugin/trunk/lib/form/
plugins/dcSwishPlugin/trunk/lib/form/SwishSearchForm.class.php
plugins/dcSwishPlugin/trunk/lib/task/
plugins/dcSwishPlugin/trunk/lib/task/swishBuildTask.class.php
plugins/dcSwishPlugin/trunk/modules/
plugins/dcSwishPlugin/trunk/modules/dc_swish/
plugins/dcSwishPlugin/trunk/modules/dc_swish/actions/
plugins/dcSwishPlugin/trunk/modules/dc_swish/actions/actions.class.php
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_pagination.php
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_search_result.php
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_sort.php
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/downloadSuccess.php
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/indexSuccess.php
Log:
initial commit
Added: plugins/dcSwishPlugin/trunk/config/routing.yml
===================================================================
--- plugins/dcSwishPlugin/trunk/config/routing.yml
(rev 0)
+++ plugins/dcSwishPlugin/trunk/config/routing.yml 2010-03-09 12:34:18 UTC
(rev 28431)
@@ -0,0 +1,11 @@
+dc_swish:
+ url: /dc_swish
+ param: { module: dc_swish, action: index }
+
+dc_swish_download:
+ url: /dc_swish-download
+ param: { module: dc_swish, action: download }
+
+dc_swish_search:
+ url: /dc_swish-search
+ param: { module: dc_swish, action: search }
Added: plugins/dcSwishPlugin/trunk/config/swish.config.sample
===================================================================
--- plugins/dcSwishPlugin/trunk/config/swish.config.sample
(rev 0)
+++ plugins/dcSwishPlugin/trunk/config/swish.config.sample 2010-03-09
12:34:18 UTC (rev 28431)
@@ -0,0 +1,182 @@
+IndexFile ./data/swish/index.swish-e
+
+IndexDir /
+
+IndexName "dcSwishPlugin index"
+IndexDescription "All dcSwish documents"
+IndexPointer "http://localhost/"
+IndexAdmin "r...@localhost"
+
+DefaultContents HTML2
+
+MetaNames first author swishdocpath swishtitle
+# List of all the meta names used in the file to index, must be on one line.
+# If no metanames DO NOT deleted the line.
+# New in 2.0 -> automatic option will extract metanames dinamically
+# eg:
+# MetaNames automatic
+
+IndexReport 0
+# This is how detailed you want reporting. You can specify numbers
+# 0 to 3 - 0 is totally silent, 3 is the most verbose.
+
+FollowSymLinks no
+# Put "yes" to follow symbolic links in indexing, else "no".
+
+FuzzyIndexingMode Stemming_es
+#UseStemming no
+# Put yes to apply word stemming algorithm during indexing,
+# else no. See the manual for info about stemming. Default is
+# no.
+
+#PropertyNames author
+# List of meta tags names that can be retrieved with the -p option.
+# Index size increases as by the formula in the manual.
+# Comment out if no PropertyNames. Case insensitive
+
+IgnoreTotalWordCountWhenRanking yes
+# Put yes to ignore the total number of words in the file
+# when calculating ranking. Often better with merges and
+# small files. Default is no.
+
+ReplaceRules remove "/mnt/eicidoc"
+#ReplaceRules replace "[a-z_0-9]*_m.*\.html" "index.html"
+#ReplaceRules replace "/ghill" "moreghillmore"
+# ReplaceRules allow you to make changes to file pathnames
+# before they're indexed. This directive uses C library
+# regex.h regular expressions.
+# NOTE: do not use replace <string> "" to remove a string,
+# use remove <string> instead - you might get a core dump otherwise.
+
+#MinWordLimit 3
+# Set the minimum length of an indexable word. Every shorter word
+# will not be indexed.
+# Commenting out the line will give the defaults
+
+#MaxWordLimit 5
+# Set the maximum length of an indexable word. Every longer word
+# will not be indexed.
+# Commenting out the line will give the defaults
+
+#WordCharacters abcdefghijklmnopqrstuvwxyz\&#;0123456789.@|,-'"[](~...@$%^{}_+?
+# WORDCHARS is a string of characters which SWISH permits to
+# be in words. Any strings which do not include these characters
+# will not be indexed. You can choose from any character in
+# the following string:
+#
+# abcdefghijklmnopqrstuvwxyz0123456789_\|/-+...@$%^'"`~,.[]{}()
+#
+# Note that if you omit "0123456789&#;" you will not be able to
+# index HTML entities. DO NOT use the asterisk (*), lesser than
+# and greater than signs (<), (>), or colon (:).
+#
+# Including any of these four characters may cause funny things to happen.
+# NOTE: Do not escape \ nor " and they cannot be the first letter in the string
+# Commenting out the line will give the defaults
+
+#BeginCharacters m"
+# Of the characters that you decide can go into words, this is
+# a list of characters that words can begin with. It should be
+# a subset of (or equal to) WordCharacters
+# Same rule of syntax as for WordCharacters
+
+#EndCharacters \"\
+# Of the characters that you decide can go into words, this is
+# a list of characters that words can begin with. It should be
+# a subset of (or equal to) WordCharacters
+# Same rule of syntax as for WordCharacters
+
+#IgnoreLastChar
+# Array that contains the char that, if considered valid in the middle of
+# a word need to be disreguarded when at the end. It is important to also
+# set the given char's in the ENDCHARS array, otherwise the word will not
+# be indexed because considered invalid.
+# Commenting out the line will give the defaults
+# NOTE: if " is the first char in the string it needs to be escaped with \
+# Do not escape otherwise
+
+#IgnoreFirstChar
+# Array that contains the char that, if considered valid in the middle of
+# a word need to be disreguarded when at the beginning. This was to solve
+# the problem of parenthesis when there is no space between ( and the
+# beginning of the word.
+# Remember to add the char's to the BEGINCHARS list also.
+# Commenting out the line will give the defaults
+# NOTE: if " is the first char in the string it needs to be escaped with \
+# Do not escape otherwise
+
+#IgnoreLimit 50 1000
+# This automatically omits words that appear too often in the files
+# (these words are called stopwords). Specify a whole percentage
+# and a number, such as "80 256". This omits words that occur in
+# over 80% of the files and appear in over 256 files. Comment out
+# to turn of auto-stopwording.
+
+IgnoreWords File: /usr/share/doc/swish-e/examples/conf/stopwords/english.txt
+IgnoreWords File: /usr/share/doc/swish-e/examples/conf/stopwords/spanish.txt
+# The IgnoreWords option allows you to specify words to ignore.
+# Comment out for no stopwords; the word "SwishDefault" will
+# include a list of default stopwords. Words should be separated by spaces
+# and may span multiple directives.
+# New in 2.0. File option reads stopwords from an external file
+# eg:
+# IgnoreWords File:filename
+
+IndexComments 0
+# This option allows the user decide if to index the comments in the files
+# default is 1. Set to 0 if comment indexing is not required.
+
+#TranslateCharacters string1 string2
+# This option allows to index the characters in string1 to be indexed
+# as the characteres in string2.
+# This is done after htnl entities are converted
+# This option is useful in languages like spanish, french, ...
+# eg:
+#TranslateCharacters _áéíóúñ -aeioun
+# This will index a_b as a-b and ámo as amo
+
+##################################
+# DIRECTIVES for FILESYSTEMS ONLY
+# Comment out if using HTTP
+###################################
+
+#IndexOnly .html .xml .txt .pdf .doc .xls .ppt .vsd .mpp .jpg .gif .zip .tar
.gz
+IndexOnly .txt .pdf .doc .xls .ppt .zip
+# Only files with these suffixes will be indexed.
+
+#NoContents .gif .xbm .au .mov .mpg .png .ps .rpm .deb .tgz .gz .tar .bz2 .zip
.ppt .xls .z ,ST
+IndexContents TXT .xls .txt .vsd .ppt .mpp .jpg .gif .zip .tar .gz
+#NoContents .jpg .gif .zip .tar .gz
+NoContents .zip
+#TruncateDocSize 100000
+
+FileRules filename contains # % ~ .bak .orig .old old. .gif
+#FileRules title contains construction example pointers
+#FileRules filename is index
+# Files matching the above criteria will *not* be indexed.
+# The patter matching uses the C library regex.h
+
+StoreDescription TXT 15000
+StoreDescription HTML2 <body> 15000
+StoreDescription XML <desc> 15000
+
+FilterDir /usr/share/doc/swish-e/examples/filter-bin
+#FileFilter .pdf _pdf2html.pl "'%p'"
+#FileFilter .pdf /usr/bin/pdftotext "'%p' -"
+#Filefilter .gz gzip-filter.sh
+Filefilter .pdf swish_filter.pl %p
+Filefilter .doc swish_filter.pl %p
+Filefilter .xls /usr/bin/xls2csv %p
+Filefilter .ppt /usr/bin/catppt %p
+Filefilter .vsd /usr/bin/wvSummary %p
+Filefilter .mpp /usr/bin/wvSummary %p
+Filefilter .jpg /bin/echo %p
+Filefilter .gif /bin/echo %p
+Filefilter .zip /bin/echo %p
+Filefilter .tar /bin/echo %p
+Filefilter .gz /bin/echo %p
+#Filefilter .dot wword-filter.sh
+#Filefilter .ps ghostscript-filter.sh
+FileFilterMatch "/usr/bin/unzip" "-p %p content.xml"
/\.(sxw|sxc|sxg|sxi|odt)$/i
+# filter for mails
+FileFilterMatch "/user/ludo/bin/swish-mail" %p /\,S$/
Added: plugins/dcSwishPlugin/trunk/lib/SwishManager.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/lib/SwishManager.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/lib/SwishManager.class.php 2010-03-09
12:34:18 UTC (rev 28431)
@@ -0,0 +1,84 @@
+<?php
+
+class SwishManager
+{
+ const RANK = "swishrank";
+ const PATH = "swishdocpath";
+ const TITLE = "swishtitle";
+ const SIZE = "swishdocsize";
+ const MODIFIED = "swishlastmodified";
+
+ static private $instances=array();
+ private $swish,$swish_search;
+
+ private function __construct($index)
+ {
+ $this->swish=new Swish($index);
+ $this->swish_search=$this->swish->prepare();
+ }
+
+ public static function getDefaultSort()
+ {
+ return array(self::RANK, 'desc');
+ }
+
+
+ public static function getInstance($index)
+ {
+ if (empty($index) )
+ {
+ $index = sfConfig::get('app_dc_swish_index', "swish_index_default");
+ }
+ if (!array_key_exists($index,self::$instances))
+ {
+ self::$instances[$index]=new SwishManager($index);
+ }
+ return self::$instances[$index];
+ }
+
+ public static function doCount($query,$index)
+ {
+ $sm=SwishManager::getInstance($index);
+ $qs=$sm->getQueryString($query);
+ if ( empty($qs) )
+ {
+ return 0;
+ }
+ $result=$sm->search($query);
+ return $result->hits;
+ }
+
+ public static function doSelect($query, $index, $offset, $limit, $sort=null)
+ {
+ $sm=SwishManager::getInstance($index);
+ $result=$sm->search($query,$sort);
+ $result->seekResult($offset);
+ $i=0;
+ $ret=array();
+ while( ( $current=$result->nextResult() ) && ($i++ < $limit) )
+ {
+ $ret[]=new SwishResultWrapper($current);
+ }
+ return $ret;
+ }
+
+ public function search($query,$sort=null)
+ {
+ if (!is_null($sort))
+ {
+ $this->swish_search->setSort($this->getSortString($sort));
+ }
+ return $this->swish_search->execute($this->getQueryString($query));
+ }
+
+ protected function getQueryString($query)
+ {
+ return
(is_array($query)&&array_key_exists('query',$query))?$query['query']:(!is_array($query)?$query:null);
+ }
+
+ protected function getSortString($sort)
+ {
+ return is_array($sort)?$sort[0]." ".$sort[1]:$sort;
+ }
+
+}
Added: plugins/dcSwishPlugin/trunk/lib/SwishPager.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/lib/SwishPager.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/lib/SwishPager.class.php 2010-03-09
12:34:18 UTC (rev 28431)
@@ -0,0 +1,121 @@
+<?php
+class SwishPager extends sfPager
+{
+ private
+ $index=null,
+ $limit=0,
+ $offset=0;
+
+
+ public function setSwishIndex($i)
+ {
+ $this->index=$i;
+ }
+
+ public function getSwishIndex()
+ {
+ return $this->index;
+ }
+
+ public function __construct($maxPerPage = 10, $index=null)
+ {
+ $this->setSwishIndex($index);
+ parent::__construct('SwishManager', $maxPerPage);
+ }
+
+
+ public function init()
+ {
+ $hasMaxRecordLimit = ($this->getMaxRecordLimit() !== false);
+ $maxRecordLimit = $this->getMaxRecordLimit();
+
+ $query = $this->getQuery();
+ $count = call_user_func(array($this->getClass(), 'doCount'), $query,
$this->getSwishIndex());
+ $this->setNbResults($hasMaxRecordLimit ? min($count, $maxRecordLimit) :
$count);
+
+ if (($this->getPage() == 0 || $this->getMaxPerPage() == 0))
+ {
+ $this->setLastPage(0);
+ }
+ else
+ {
+ $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));
+ $this->setOffset( ($this->getPage() - 1) * $this->getMaxPerPage() );
+
+ if ($hasMaxRecordLimit)
+ {
+ $maxRecordLimit = $maxRecordLimit - $offset;
+ if ($maxRecordLimit > $this->getMaxPerPage())
+ {
+ $limit=$this->getMaxPerPage();
+ }
+ else
+ {
+ $limit=$maxRecordLimit;
+ }
+ }
+ else
+ {
+ $limit=$this->getMaxPerPage();
+ }
+ $this->setLimit($limit);
+ }
+ }
+
+ public function getResults()
+ {
+ return call_user_func(array($this->getClass(), 'doSelect'),
$this->getQuery(), $this->getSwishIndex(),
$this->getOffset(),$this->getLimit(),$this->getSort());
+ }
+
+ protected function retrieveObject($offset)
+ {
+ $results = call_user_func(array($this->getClass(), 'doSelect'),
$this->getQuery(), $this->getSwishIndex(),
max($this->getOffset()-1,0),1,$this->getSort());
+ return is_array($results) && isset($results[0]) ? $results[0] : null;
+ }
+
+ public function setLimit($l)
+ {
+ $this->limit=$l;
+ }
+
+ public function getLimit()
+ {
+ return $this->limit;
+ }
+
+ public function setOffset($o)
+ {
+ $this->offset=$o;
+ }
+
+ public function getOffset()
+ {
+ return $this->offset;
+ }
+
+ public function setQuery($q)
+ {
+ $this->query=$q;
+ }
+
+ public function setSort($s)
+ {
+ $this->sort=$s;
+ }
+
+ public function getSort()
+ {
+ return $this->sort;
+ }
+
+ public function getQuery()
+ {
+ return $this->query;
+ }
+
+ public function getQueryString()
+ {
+ return $this->query['query'];
+ }
+
+}
Added: plugins/dcSwishPlugin/trunk/lib/SwishResultWrapper.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/lib/SwishResultWrapper.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/lib/SwishResultWrapper.class.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,62 @@
+<?php
+class SwishResultWrapper
+{
+ private
+ $rank,
+ $path,
+ $size,
+ $lastmodified,
+ $title,
+ $description;
+
+ public function __construct(SwishResult $s)
+ {
+ $this->rank= @$s->swishrank;
+ $this->path= @$s->swishdocpath;
+ $this->size = @$s->swishdocsize;
+ $this->lastmodified = @$s->swishlastmodified;
+ $this->title = @$s->swishtitle;
+ $this->description = @$s->swishdescription;
+ }
+
+ public function getRank()
+ {
+ return $this->rank;
+ }
+
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ public function getSize()
+ {
+ return $this->size;
+ }
+
+ public function getLastModified()
+ {
+ return $this->lastmodified;
+ }
+
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ public function getObfuscatedPath()
+ {
+ return base64_encode($this->getPath());
+ }
+
+ public static function getUnobfuscatedPath($p)
+ {
+ return base64_decode($p);
+ }
+
+}
Added: plugins/dcSwishPlugin/trunk/lib/form/SwishSearchForm.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/lib/form/SwishSearchForm.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/lib/form/SwishSearchForm.class.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,17 @@
+<?php
+
+class SwishSearchForm extends sfForm
+{
+ public function configure()
+ {
+ $this->setWidgets(array(
+ 'query' => new sfWidgetFormInput()
+ ));
+
+ $this->setValidators(array(
+ 'query' => new sfValidatorString(array('required' => false)),
+ ));
+
+ $this->widgetSchema->setNameFormat('swish[%s]');
+ }
+}
Added: plugins/dcSwishPlugin/trunk/lib/task/swishBuildTask.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/lib/task/swishBuildTask.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/lib/task/swishBuildTask.class.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,45 @@
+<?php
+
+class swishBuildTask extends sfBaseTask
+{
+ protected function configure()
+ {
+ // // add your own arguments here
+ // $this->addArguments(array(
+ // new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My
argument'),
+ // ));
+
+ $this->addOptions(array(
+ //new sfCommandOption('application', null,
sfCommandOption::PARAMETER_REQUIRED, 'The application name'),
+ //new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED,
'The environment', 'dev'),
+ //new sfCommandOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
+ // add your own options here
+ ));
+
+ $this->namespace = 'swish';
+ $this->name = 'build';
+ $this->briefDescription = 'Builds the swish index';
+ $this->detailedDescription = <<<EOF
+The [swish:build|INFO] task builds the swish index.
+Call it with:
+
+ [php symfony swish:build|INFO]
+EOF;
+ }
+
+ protected function execute($arguments = array(), $options = array())
+ {
+ // initialize the database connection
+ //$databaseManager = new sfDatabaseManager($this->configuration);
+ //$connection = $databaseManager->getDatabase($options['connection'] ?
$options['connection'] : null)->getConnection();
+
+ // add your code here
+
+ if (!file_exists("data/swish"))
+ {
+ mkdir("data/swish");
+ }
+
+ system("swish-e -c config/swish.config");
+ }
+}
Added: plugins/dcSwishPlugin/trunk/modules/dc_swish/actions/actions.class.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/actions/actions.class.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/actions/actions.class.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * main actions.
+ *
+ * @package swish
+ * @subpackage main
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
+ */
+class dc_swishActions extends sfActions
+{
+ /**
+ * Executes index action
+ *
+ * @param sfRequest $request A request object
+ */
+ public function executeIndex(sfWebRequest $request)
+ {
+ $this->swish_form = new SwishSearchForm();
+
+ // sorting
+ if ($request->getParameter('sort'))
+ {
+ $this->setSort(array($request->getParameter('sort'),
$request->getParameter('sort_type')));
+ }
+
+ // pager
+ if ($request->getParameter('page'))
+ {
+ $this->setPage($request->getParameter('page'));
+ }
+
+ $this->pager = $this->getPager();
+ $this->sort=$this->getSort();
+ $this->display = sfConfig::get("app_dc_swish_display", array());
+ }
+
+ public function executeSearch(sfWebRequest $request)
+ {
+ $this->setPage(1);
+ $this->swish_form = new SwishSearchForm();
+ $this->swish_form->bind($request->getParameter('swish'));
+ if ($this->swish_form->isValid())
+ {
+ $this->setQuery($this->swish_form->getValues());
+ $this->redirect('@dc_swish');
+ }
+ $this->pager = $this->getPager();
+ $this->sort=$this->getSort();
+ $this->display = sfConfig::get("app_dc_swish_display", array());
+ $this->setTemplate('index');
+ }
+
+ public function executeDownload(sfWebRequest $request)
+ {
+ sfConfig::set('sf_web_debug', false);
+ $result=$request->getParameter('resource');
+ $this->setLayout(false);
+ $this->path=SwishResultWrapper::getUnobfuscatedPath($result);
+ $this->getResponse()->clearHttpHeaders();
+ $this->getResponse()->setContentType(mime_content_type($this->path));
+ $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment;
filename="' .basename($this->path).'"');
+ $this->getResponse()->setHttpHeader('Content-length',
filesize($this->path));
+ }
+
+ protected function getPager()
+ {
+ $pager = new SwishPager();
+ $pager->setQuery($this->getQuery());
+ $pager->setPage($this->getPage());
+ $pager->setSort($this->getSort());
+ $pager->init();
+ return $pager;
+ }
+
+ protected function setPage($page)
+ {
+ $this->getUser()->setAttribute('swish.page', $page, 'swish_plugin');
+ }
+
+ protected function getPage()
+ {
+ return $this->getUser()->getAttribute('swish.page', 1, 'swish_plugin');
+ }
+
+ protected function getSort()
+ {
+ if (!is_null($sort = $this->getUser()->getAttribute('swish.sort', null,
'swish_plugin')))
+ {
+ return $sort;
+ }
+ $this->setSort(SwishManager::getDefaultSort());
+ return $this->getUser()->getAttribute('swish.sort', null, 'swish_plugin');
+ }
+
+
+
+ protected function setSort(array $sort)
+ {
+ if (!is_null($sort[0]) && is_null($sort[1]))
+ {
+ $sort[1] = 'desc';
+ }
+ $this->getUser()->setAttribute('swish.sort', $sort, 'swish_plugin');
+ }
+
+
+ protected function setQuery(array $swish_query)
+ {
+ return $this->getUser()->setAttribute('swish.query', $swish_query,
'swish_plugin');
+ }
+
+ protected function getQuery()
+ {
+ return $this->getUser()->getAttribute('swish.query', array(),
'swish_plugin');
+ }
+
+}
Added: plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_pagination.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_pagination.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_pagination.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,23 @@
+ <a href="<?php echo url_for('@dc_swish') ?>?page=1">
+ <?php echo
image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/first.png',
array('alt' => __('First page', array(), 'sf_admin'), 'title' => __('First
page', array(), 'sf_admin'))) ?>
+ </a>
+
+ <a href="<?php echo url_for('@dc_swish') ?>?page=<?php echo
$pager->getPreviousPage() ?>">
+ <?php echo
image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/previous.png',
array('alt' => __('Previous page', array(), 'sf_admin'), 'title' =>
__('Previous page', array(), 'sf_admin'))) ?>
+ </a>
+
+ <?php foreach ($pager->getLinks() as $page): ?>
+ <?php if ($page == $pager->getPage()): ?>
+ <?php echo $page ?>
+ <?php else: ?>
+ <a href="<?php echo url_for('@dc_swish') ?>?page=<?php echo $page
?>"><?php echo $page ?></a>
+ <?php endif; ?>
+ <?php endforeach; ?>
+
+ <a href="<?php echo url_for('@dc_swish') ?>?page=<?php echo
$pager->getNextPage() ?>">
+ <?php echo
image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/next.png',
array('alt' => __('Next page', array(), 'sf_admin'), 'title' => __('Next page',
array(), 'sf_admin'))) ?>
+ </a>
+
+ <a href="<?php echo url_for('@dc_swish') ?>?page=<?php echo
$pager->getLastPage() ?>">
+ <?php echo
image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/last.png',
array('alt' => __('Last page', array(), 'sf_admin'), 'title' => __('Last page',
array(), 'sf_admin'))) ?>
+ </a>
Added: plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_search_result.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_search_result.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_search_result.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,13 @@
+<div style="border-bottom: 1px solid black">
+ <?php foreach ($display as $field): ?>
+ <strong><?php echo __("%s%", array("%s%" =>
sfInflector::humanize($field))) ?></strong>
+ <?php if ($field == "path"): ?>
+ <?php echo
link_to($swish_result->getPath(),'@dc_swish_download',array("query_string"=>'resource='.$swish_result->getObfuscatedPath()),array('title'=>__("View
file")))?>
+ <?php elseif ($field == "lastmod"): ?>
+ <?php echo format_date($swish_result->getLastModified())?>
+ <?php else: ?>
+ <?php echo call_user_func(array($swish_result,
"get".sfInflector::camelize($field))) ?>
+ <?php endif ?>
+ <br/>
+ <?php endforeach ?>
+</div>
Added: plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_sort.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_sort.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/_sort.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,21 @@
+<?php echo __("Sort by")?>
+
+<?php if (in_array("rank", $display)): ?>
+<?php echo link_to(__('Rank', array(), 'messages'), '@dc_swish',
array('query_string' => 'sort='.SwishManager::RANK.'&sort_type='.($sort[1] ==
'asc' ? 'desc' : 'asc'), 'title' => __('Sort by this field', array(),
'messages'))) ?>
+<?php endif ?>
+
+<?php if (in_array("path", $display)): ?>
+|
+<?php echo link_to(__('Path', array(), 'messages'), '@dc_swish',
array('query_string' => 'sort='.SwishManager::PATH.'&sort_type='.($sort[1] ==
'asc' ? 'desc' : 'asc'), 'title' => __('Sort by this field', array(),
'messages'))) ?>
+<?php endif ?>
+
+<?php if (in_array("size", $display)): ?>
+|
+<?php echo link_to(__('Size', array(), 'messages'), '@dc_swish',
array('query_string' => 'sort='.SwishManager::SIZE.'&sort_type='.($sort[1] ==
'asc' ? 'desc' : 'asc'), 'title' => __('Sort by this field', array(),
'messages'))) ?>
+<?php endif ?>
+
+<?php if (in_array("lastmod", $display)): ?>
+|
+<?php echo link_to(__('Last modified', array(), 'messages'), '@dc_swish',
array('query_string' => 'sort='.SwishManager::MODIFIED.'&sort_type='.($sort[1]
== 'asc' ? 'desc' : 'asc'), 'title' => __('Sort by this field', array(),
'messages'))) ?>
+<?php endif ?>
+
Added:
plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/downloadSuccess.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/downloadSuccess.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/downloadSuccess.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1 @@
+<?php echo file_get_contents($path)?>
Added: plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/indexSuccess.php
===================================================================
--- plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/indexSuccess.php
(rev 0)
+++ plugins/dcSwishPlugin/trunk/modules/dc_swish/templates/indexSuccess.php
2010-03-09 12:34:18 UTC (rev 28431)
@@ -0,0 +1,28 @@
+<?php use_helper('I18N', 'Date') ?>
+<form action="<?php echo url_for('@dc_swish_search') ?>" method="POST">
+ <table>
+ <?php echo $swish_form ?>
+ <tr>
+ <td colspan="2">
+ <input type="submit" />
+ </td>
+ </tr>
+ </table>
+</form>
+<div class="sf_admin_list">
+ <?php if (!$pager->getNbResults()): ?>
+ <p><?php echo __('No result', array(), 'sf_admin') ?></p>
+ <?php else: ?>
+ <?php include_partial('sort',array('sort'=> $sort, "display" => $display))
?>
+
+ <?php foreach ($pager->getResults() as $swish_result): ?>
+ <?php include_partial('search_result', array('swish_result' =>
$swish_result, "display" => $display)) ?>
+ <?php endforeach ?>
+
+ <?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1%
results', array('%1%' => $pager->getNbResults()), $pager->getNbResults(),
'sf_admin') ?>
+ <?php echo __('for query:
%query%',array('%query%'=>$pager->getQueryString()))?>
+ <?php if ($pager->haveToPaginate()): ?>
+ <?php include_partial('pagination', array('pager' => $pager)) ?>
+ <?php endif; ?>
+ <?php endif ?>
+</div>
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.