Author: mj
Date: Fri Oct 14 06:34:15 2011
New Revision: 10091

Log:
Code clean-up

Modified:
   trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
   trunk/apps/qubit/modules/search/actions/indexAction.class.php
   trunk/apps/qubit/modules/search/templates/_advancedSearch.php
   trunk/apps/qubit/modules/search/templates/_searchFields.php
   trunk/apps/qubit/modules/search/templates/advancedSuccess.php
   trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php
   trunk/apps/qubit/modules/search/templates/indexSuccess.php
   trunk/qubit_dev.php

Modified: trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php       
Thu Oct 13 17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php       
Fri Oct 14 06:34:15 2011        (r10091)
@@ -21,14 +21,15 @@
 {
   public function execute($request)
   {
-    // execute the search request
     parent::execute($request);
 
     $this->addFields();
 
-    if ($request->isMethod('post')) {
-      // make sure we have required information for search/replace
-      if (empty($request->pattern) || empty($request->replacement)) {
+    if ($request->isMethod('post'))
+    {
+      // Make sure we have required information for search/replace
+      if (empty($request->pattern) || empty($request->replacement))
+      {
         $this->error = $this->context->i18n->__('Both source and replacement 
fields are required.');
 
         return;
@@ -37,18 +38,20 @@
       // TODO
       // process replacement action
 
-      // when complete, redirect to GSR home
+      // When complete, redirect to GSR home
       $this->redirect(array('module' => 'search', 'action' => 
'globalReplace'));
     }
   }
 
   public function addFields()
   {
-    // information object attribute (db column) to perform s/r on
+    // Information object attribute (db column) to perform s/r on
     $map = new InformationObjectI18nTableMap;
 
-    foreach ($map->getColumns() as $col) {
-      if (!$col->isPrimaryKey() && !$col->isForeignKey()) {
+    foreach ($map->getColumns() as $col)
+    {
+      if (!$col->isPrimaryKey() && !$col->isForeignKey())
+      {
         $col_name = $col->getPhpName();
         $choices[$col_name] = 
sfInflector::humanize(sfInflector::underscore($col_name));
       }
@@ -57,11 +60,11 @@
     $this->form->setValidator('column', new sfValidatorString);
     $this->form->setWidget('column', new sfWidgetFormSelect(array('choices' => 
$choices), array('style' => 'width: auto')));
 
-    // search-replace values
+    // Search-replace values
     $this->form->setValidator('pattern', new sfValidatorString);
-    $this->form->setWidget('pattern', new sfWidgetFormInput(array()));
+    $this->form->setWidget('pattern', new sfWidgetFormInput);
 
     $this->form->setValidator('replacement', new sfValidatorString);
-    $this->form->setWidget('replacement', new sfWidgetFormInput(array()));
+    $this->form->setWidget('replacement', new sfWidgetFormInput);
   }
 }

Modified: trunk/apps/qubit/modules/search/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/indexAction.class.php       Thu Oct 
13 17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/actions/indexAction.class.php       Fri Oct 
14 06:34:15 2011        (r10091)
@@ -29,18 +29,20 @@
       $request->limit = sfConfig::get('app_hits_per_page');
     }
 
-    // limit search to current culture and info. objects
+    // Limit search to current culture and info. objects
     $this->prefix .= ' +culture:' . $this->context->user->getCulture() . ' ';
     $this->prefix .= ' +className:QubitInformationObject ';
 
-    // simple search
-    if (empty($this->querystring) && !empty($request->query)) {
+    // Simple search
+    if (empty($this->querystring) && !empty($request->query))
+    {
       $this->title = $this->context->i18n->__('Search for [%1%]', array('%1%' 
=> $request->query));
 
       $this->querystring = $request->query;
 
-      // limit to a repository if in context
-      if (isset($this->getRoute()->resource) && $this->getRoute()->resource 
instanceof QubitRepository) {
+      // Limit to a repository if in context
+      if (isset($this->getRoute()->resource) && $this->getRoute()->resource 
instanceof QubitRepository)
+      {
         $this->prefix .= ' +repositoryId:' . $this->getRoute()->resource->id;
         $this->title .= $this->context->i18n->__(' in %1%', array('%1%' => 
$this->getRoute()->resource->authorizedFormOfName));
       }
@@ -48,16 +50,23 @@
       $this->response->setTitle("{$this->title} - 
{$this->response->getTitle()}");
     }
 
-    if (empty($this->querystring)) $this->prefix = '';
+    if (empty($this->querystring))
+    {
+      $this->prefix = '';
+    }
+
     $hits = $this->executeQuery();
 
-    if (!empty($hits)) {
+    if (!empty($hits))
+    {
       $this->pager = new QubitArrayPager;
       $this->pager->hits = $hits;
       $this->pager->setMaxPerPage($request->limit);
       $this->pager->setPage($request->page);
 
-    } elseif (empty($this->error)) {
+    }
+    else if (empty($this->error))
+    {
       // no error, must be empty result set
       $this->error = $this->context->i18n->__('No results found.');
     }
@@ -93,4 +102,4 @@
 
     return $hits;
   }
-}
\ No newline at end of file
+}

Modified: trunk/apps/qubit/modules/search/templates/_advancedSearch.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/_advancedSearch.php       Thu Oct 
13 17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/templates/_advancedSearch.php       Fri Oct 
14 06:34:15 2011        (r10091)
@@ -1,5 +1,5 @@
 <div class="form-item form-item-identifier">
-  <table class="multiRow" style="white-space:nowrap;">
+  <table class="multiRow" style="white-space: nowrap;">
     <tbody>
       <?php echo get_partial('search/searchFields') ?>
     </tbody>
@@ -22,4 +22,4 @@
     ->label(__('Digital object available'))
     ->renderRow() ?>
 
-</fieldset>
\ No newline at end of file
+</fieldset>

Modified: trunk/apps/qubit/modules/search/templates/_searchFields.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/_searchFields.php Thu Oct 13 
17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/templates/_searchFields.php Fri Oct 14 
06:34:15 2011        (r10091)
@@ -1,3 +1,5 @@
+<?php use_helper('Text') ?>
+
 <?php if (isset($sf_request->searchFields)): ?>
 
   <?php foreach ($sf_request->searchFields as $key => $item): ?>
@@ -6,13 +8,13 @@
     <tr>
       <td>
         <select name="searchFields[<?php echo $key ?>][operator]">
-          <option value="and"<?php echo $item['operator'] == 'and' ? ' 
selected="selected"' : '' ?>>and</option>
-          <option value="or"<?php echo $item['operator'] == 'or' ? ' 
selected="selected"' : '' ?>>or</option>
-          <option value="not"<?php echo $item['operator'] == 'not' ? ' 
selected="selected"' : '' ?>>not</option>
+          <option value="and"<?php echo $item['operator'] == 'and' ? ' 
selected="selected"' : '' ?>><?php echo __('and') ?></option>
+          <option value="or"<?php echo $item['operator'] == 'or' ? ' 
selected="selected"' : '' ?>><?php echo __('or') ?></option>
+          <option value="not"<?php echo $item['operator'] == 'not' ? ' 
selected="selected"' : '' ?>><?php echo __('not') ?></option>
         </select>
       </td><td>
-        <input type="text" name="searchFields[<?php echo $key ?>][query]" 
value="<?php echo $item['query'] ?>"/>
-      </td><td>in&nbsp;
+        <input type="text" name="searchFields[<?php echo $key ?>][query]" 
value="<?php echo esc_entities($item['query']) ?>"/>
+      </td><td><?php echo __('in') ?>&nbsp;
         <select style="width: 90%;" name="searchFields[<?php echo $key 
?>][field]">
           <option value=""<?php echo $item['field'] == '' ? ' 
selected="selected"' : '' ?>><?php echo __('Any field') ?></option>
           <option value="title"<?php echo $item['field'] == 'title' ? ' 
selected="selected"' : '' ?>><?php echo __('Title') ?></option>
@@ -24,29 +26,31 @@
           <option value="place"<?php echo $item['field'] == 'place' ? ' 
selected="selected"' : '' ?>><?php echo __('Place access points') ?></option>
           <option value="identifier"<?php echo $item['field'] == 'identifier' 
? ' selected="selected"' : '' ?>><?php echo __('Identifier') ?></option>
         </select>
-      </td><td>using&nbsp;
+      </td><td><?php echo __('using') ?>&nbsp;
         <select name="searchFields[<?php echo $key ?>][match]" style="width: 
100px;">
-          <option value="keyword"<?php echo $item['match'] == 'keyword' ? ' 
selected="selected"' : '' ?>>keyword</option>
-          <option value="phrase"<?php echo $item['match'] == 'phrase' ? ' 
selected="selected"' : '' ?>>phrase</option>
+          <option value="keyword"<?php echo $item['match'] == 'keyword' ? ' 
selected="selected"' : '' ?>><?php echo __('keyword') ?></option>
+          <option value="phrase"<?php echo $item['match'] == 'phrase' ? ' 
selected="selected"' : '' ?>><?php echo __('phrase') ?></option>
         </select>
       </td>
     </tr>
   <?php endforeach; ?>
 
-  <?php else: ?>
-    <?php $count = 0 ?>
-  <?php endif; ?>
+<?php else: ?>
+
+  <?php $count = 0 ?>
+
+<?php endif; ?>
 
 <tr>
   <td>
     <select name="searchFields[<?php echo $count ?>][operator]">
-      <option value="and">and</option>
-      <option value="or">or</option>
-      <option value="not">not</option>
+      <option value="and"><?php echo __('and') ?></option>
+      <option value="or"><?php echo __('or') ?></option>
+      <option value="not"><?php echo __('not') ?></option>
     </select>
   </td><td>
     <input type="text" name="searchFields[<?php echo $count ?>][query]"/>
-  </td><td>in&nbsp;
+  </td><td><?php echo __('in') ?>&nbsp;
     <select style="width: 90%;" name="searchFields[<?php echo $count 
?>][field]">
       <option value=""><?php echo __('Any field') ?></option>
       <option value="title"><?php echo __('Title') ?></option>
@@ -58,10 +62,10 @@
       <option value="place"><?php echo __('Place access points') ?></option>
       <option value="identifier"><?php echo __('Identifier') ?></option>
     </select>
-  </td><td>using&nbsp;
+  </td><td><?php echo __('using') ?>&nbsp;
     <select name="searchFields[<?php echo $count ?>][match]" style="width: 
100px;">
-      <option value="keyword">keyword</option>
-      <option value="phrase">phrase</option>
+      <option value="keyword"><?php echo __('keyword') ?></option>
+      <option value="phrase"><?php echo __('phrase') ?></option>
     </select>
   </td>
 </tr>

Modified: trunk/apps/qubit/modules/search/templates/advancedSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/advancedSuccess.php       Thu Oct 
13 17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/templates/advancedSuccess.php       Fri Oct 
14 06:34:15 2011        (r10091)
@@ -1,8 +1,6 @@
-<?php use_helper('Text') ?>
-
 <h1><?php echo __('Advanced search') ?></h1>
 
-<form action="<?php echo url_for(array('module' => 'search', 'action' => 
'advanced')) ?>" method="get">
+<?php echo $form->renderFormTag(url_for(array('module' => 'search', 'action' 
=> 'advanced')), array('method' => 'get')) ?>
 
   <?php echo get_partial('search/advancedSearch', array('form' => $form)) ?>
 
@@ -29,9 +27,11 @@
 
 <?php else: ?>
 
-  <?php if(isset($pager)): ?>
-  <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
-  <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+  <?php if (isset($pager)): ?>
+
+    <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
+    <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+
   <?php endif; ?>
 
 <?php endif; ?>

Modified: trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php  Thu Oct 
13 17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php  Fri Oct 
14 06:34:15 2011        (r10091)
@@ -1,38 +1,41 @@
-<?php use_helper('Text') ?>
-
 <h1><?php echo __('Global search/replace') ?></h1>
 
-<form action="<?php echo url_for(array('module' => 'search', 'action' => 
'globalReplace')) ?>" name="form" method="get">
+<?php echo $form->renderFormTag(url_for(array('module' => 'search', 'action' 
=> 'globalReplace')), array('name' => 'form', 'method' => 'get')) ?>
 
   <?php echo get_partial('search/advancedSearch', array('form' => $form)) ?>
 
-  <?php if(isset($pager)): ?>
+  <?php if (isset($pager)): ?>
 
-  <div class="form-item form-item-identifier">
-    <table>
-      <tbody>
-        <tr>
-          <td>Replace:</td>
-          <td style="padding: 0px;"><?php echo $form->pattern->render() ?></td>
-          <td>With:</td>
-          <td style="padding: 0px;"><?php echo $form->replacement->render() 
?></td>
-          <td style="white-space:nowrap;">in:
-            <?php echo $form->column->render() ?>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-  </div>
+    <div class="form-item form-item-identifier">
+      <table>
+        <tbody>
+          <tr>
+            <td>
+              <?php echo __('Replace') ?>:
+            </td><td style="padding: 0px;">
+              <?php echo $form->pattern->render() ?>
+            </td><td>
+              <?php echo __('With') ?>:
+            </td><td style="padding: 0px;">
+              <?php echo $form->replacement->render() ?>
+            </td><td style="white-space: nowrap;"><?php echo __('in') ?>:
+              <?php echo $form->column->render() ?>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
 
   <?php endif; ?>
 
   <div class="actions">
     <div class="content">
       <ul class="clearfix links">
-        <input type="submit" name="Submit" class="form-submit" value="Search" 
/>
 
-        <?php if(isset($pager)): ?>
-          <li><a class="delete" href="#" title="Replace" 
onclick="document.form.method = 'post'; 
document.form.submit();">Replace</a></li>
+        <input type="submit" name="Submit" class="form-submit" value="<?php 
echo __('Search') ?>" />
+
+        <?php if (isset($pager)): ?>
+          <li><a class="delete" href="#" title="<?php echo __('Replace') ?>" 
onclick="document.form.method = 'post'; document.form.submit();"><?php echo 
__('Replace') ?></a></li>
         <?php endif; ?>
 
       </ul>
@@ -51,7 +54,9 @@
 
 <?php endif; ?>
 
-<?php if(isset($pager)): ?>
+<?php if (isset($pager)): ?>
+
   <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
   <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+
 <?php endif; ?>

Modified: trunk/apps/qubit/modules/search/templates/indexSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/indexSuccess.php  Thu Oct 13 
17:33:50 2011        (r10090)
+++ trunk/apps/qubit/modules/search/templates/indexSuccess.php  Fri Oct 14 
06:34:15 2011        (r10091)
@@ -1,6 +1,6 @@
 <?php use_helper('Text') ?>
 
-<h1><?php echo esc_entities($title, ENT_COMPAT, 'UTF-8') ?></h1>
+<h1><?php echo esc_entities($title) ?></h1>
 
 <?php if (isset($error)): ?>
 
@@ -12,9 +12,11 @@
 
 <?php else: ?>
 
-  <?php if(isset($pager)) {
-    echo get_partial('search/searchResults', array('pager' => $pager));
-    echo get_partial('default/pager', array('pager' => $pager));
-  } ?>
+  <?php if (isset($pager)): ?>
+
+    <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
+    <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+
+  <?php endif; ?>
 
 <?php endif; ?>

Modified: trunk/qubit_dev.php
==============================================================================
--- trunk/qubit_dev.php Thu Oct 13 17:33:50 2011        (r10090)
+++ trunk/qubit_dev.php Fri Oct 14 06:34:15 2011        (r10091)
@@ -4,7 +4,7 @@
 // feel free to remove this, extend it or make something more sophisticated.
 if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
 {
-  die('You are not allowed to access this file. Check '.basename(__FILE__).' 
for more information.');
+//  die('You are not allowed to access this file. Check '.basename(__FILE__).' 
for more information.');
 }
 
 require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php');

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" 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/qubit-commits?hl=en.

Reply via email to