Author: mj
Date: Mon Oct 17 15:44:57 2011
New Revision: 10125
Log:
Complete global search/replace workflow/UI and fix some search issues
Modified:
trunk/apps/qubit/modules/search/actions/advancedAction.class.php
trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
trunk/apps/qubit/modules/search/actions/indexAction.class.php
trunk/apps/qubit/modules/search/templates/_searchResults.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
Modified: trunk/apps/qubit/modules/search/actions/advancedAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/advancedAction.class.php Mon Oct
17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/actions/advancedAction.class.php Mon Oct
17 15:44:57 2011 (r10125)
@@ -126,9 +126,9 @@
// enclose phrase searches in quotes (strip existing ones)
if ('phrase' == $searchField['match']) {
- $term = '"'.str_replace(array('"', "'"), '',
$searchField['query']).'"';
+ $term = '"'.str_replace(array('"', "'"), '',
strtolower($searchField['query'])).'"';
} else {
- $term = $searchField['query'];
+ $term = strtolower($searchField['query']);
}
// select which boolean operator to use
Modified: trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
Mon Oct 17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/actions/globalReplaceAction.class.php
Mon Oct 17 15:44:57 2011 (r10125)
@@ -25,6 +25,8 @@
$this->addFields();
+ $this->title = $this->context->i18n->__('Global search/replace');
+
if ($request->isMethod('post'))
{
// Make sure we have required information for search/replace
@@ -34,6 +36,12 @@
return;
}
+ // Make sure we have confirmed the action
+ else if (!isset($request->confirm))
+ {
+ $this->title = $this->context->i18n->__('Are you sure you want to
replace "%1%" with "%2%" in %3%?', array('%1%' => $request->pattern, '%2%' =>
$request->replacement, '%3%' =>
sfInflector::humanize(sfInflector::underscore($request->column))));
+ return;
+ }
// Process replacement on each IO
// NB: could this be made faster by reading a batch of IDs?
@@ -96,9 +104,15 @@
$this->form->setWidget('replacement', new sfWidgetFormInput);
$this->form->setValidator('caseSensitive', new sfValidatorBoolean);
- $this->form->setWidget('caseSensitive', new
sfWidgetFormInputCheckbox(array(), array('value' => 1)));
+ $this->form->setWidget('caseSensitive', new sfWidgetFormInputCheckbox);
$this->form->setValidator('allowRegex', new sfValidatorBoolean);
$this->form->setWidget('allowRegex', new sfWidgetFormInputCheckbox);
+
+ if ($this->request->isMethod('post') && !isset($this->request->confirm) &&
!empty($this->request->pattern) && !empty($this->request->replacement))
+ {
+ $this->form->setValidator('confirm', new sfValidatorBoolean);
+ $this->form->setWidget('confirm', new sfWidgetFormInputHidden(array(),
array('value' => true)));
+ }
}
}
Modified: trunk/apps/qubit/modules/search/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/search/actions/indexAction.class.php Mon Oct
17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/actions/indexAction.class.php Mon Oct
17 15:44:57 2011 (r10125)
@@ -39,6 +39,12 @@
}
$query = $this->parseQuery();
+
+ if (!empty($this->error))
+ {
+ return;
+ }
+
$query = $this->filterQuery($query);
try
@@ -77,7 +83,7 @@
{
$this->error = $e->getMessage();
- return;
+ return null;
}
$query = new Zend_Search_Lucene_Search_Query_Boolean();
Modified: trunk/apps/qubit/modules/search/templates/_searchResults.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/_searchResults.php Mon Oct
17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/templates/_searchResults.php Mon Oct
17 15:44:57 2011 (r10125)
@@ -1,6 +1,6 @@
<div class="section">
<?php foreach ($pager->getResults() as $hit): ?>
- <?php $doc =& $hit->getDocument(); ?>
+ <?php $doc = $hit->getDocument(); ?>
<div class="clearfix search-results <?php echo 0 == @++$row % 2 ? 'even' :
'odd' ?>">
<?php if ('true' == $doc->hasDigitalObject): ?>
Modified: trunk/apps/qubit/modules/search/templates/advancedSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/advancedSuccess.php Mon Oct
17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/templates/advancedSuccess.php Mon Oct
17 15:44:57 2011 (r10125)
@@ -15,23 +15,21 @@
</div>
-</form>
-
-<?php if (isset($error)): ?>
+ <?php if (isset($error)): ?>
- <div class="search-results">
- <ul>
- <li><?php echo $error ?></li>
- </ul>
- </div>
+ <div class="error">
+ <ul>
+ <li><?php echo $error ?></li>
+ </ul>
+ </div>
-<?php else: ?>
+ <?php endif; ?>
- <?php if (isset($pager)): ?>
+</form>
- <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
- <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
+<?php if (isset($pager)): ?>
- <?php endif; ?>
+ <?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
+ <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
-<?php endif; ?>
+<?php endif; ?>
\ No newline at end of file
Modified: trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php Mon Oct
17 15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/templates/globalReplaceSuccess.php Mon Oct
17 15:44:57 2011 (r10125)
@@ -1,7 +1,19 @@
-<h1><?php echo __('Global search/replace') ?></h1>
+<h1><?php echo esc_entities($title) ?></h1>
<?php echo $form->renderFormTag(url_for(array('module' => 'search', 'action'
=> 'globalReplace')), array('name' => 'form', 'method' => 'get')) ?>
+ <?php if (isset($form->confirm)): ?>
+
+ <h3 style="font-weight: normal;"><?php echo __('This will permanently modify
%1% records.', array('%1%' => count($pager->hits))) ?></h3>
+ <div class="error">
+ <h2><?php echo __('This action cannot be undone!') ?></li></h2>
+ </div>
+
+ <?php echo $form->renderHiddenFields() ?>
+ <div style="display: none;">
+
+ <?php endif; ?>
+
<?php echo get_partial('search/advancedSearch', array('form' => $form)) ?>
<?php if (isset($pager)): ?>
@@ -38,25 +50,34 @@
<?php endif; ?>
+ <?php if (isset($form->confirm)): ?>
+ </div>
+ <?php endif; ?>
+
<div class="actions">
<div class="content">
<ul class="clearfix links">
- <input type="submit" name="Submit" class="form-submit" value="<?php
echo __('Search') ?>" />
+ <?php if (isset($form->confirm)): ?>
- <?php if (isset($pager)): ?>
- <li><a class="delete" href="#" title="<?php echo __('Replace') ?>"
id="confirmReplace"><?php echo __('Replace') ?></a></li>
- <?php endif; ?>
+ <li><a href="#" title="<?php echo __('Cancel') ?>"
onclick="document.form.submit();"><?php echo __('Cancel') ?></a></li>
+ <li><input class="danger form-submit" type="submit" value="<?php
echo __('Replace') ?>" onclick="document.form.method = 'post';"/></li>
+ <?php else: ?>
+ <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; ?>
+
+ <?php endif; ?>
</ul>
</div>
</div>
-</form>
-
<?php if (isset($error)): ?>
- <div class="search-results">
+ <div class="error">
<ul>
<li><?php echo $error ?></li>
</ul>
@@ -64,34 +85,11 @@
<?php endif; ?>
-<?php if (isset($pager)): ?>
+</form>
+
+<?php if (isset($pager) && !isset($form->confirm)): ?>
<?php echo get_partial('search/searchResults', array('pager' => $pager)) ?>
<?php echo get_partial('default/pager', array('pager' => $pager)) ?>
-<?php endif; ?>
-
-<script type="text/javascript">
-//<![CDATA[
-Drupal.behaviors.confirmReplaceDialog = {
- attach: function (context)
- {
- (function ($)
- {
- // FIXME: replace this with a jquery confirm modal
- $('#confirmReplace').click(function ()
- {
- var conf = confirm('Are you sure you wish to perform this
search/replace? This action CANNOT be undone.');
- if (conf)
- {
- document.form.method = 'post';
- document.form.submit();
- }
- });
-
- })(jQuery)
- }
-}
-
-//]]>
-</script>
+<?php endif; ?>
\ No newline at end of file
Modified: trunk/apps/qubit/modules/search/templates/indexSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/search/templates/indexSuccess.php Mon Oct 17
15:32:27 2011 (r10124)
+++ trunk/apps/qubit/modules/search/templates/indexSuccess.php Mon Oct 17
15:44:57 2011 (r10125)
@@ -13,7 +13,7 @@
<?php if (isset($error)): ?>
- <div class="search-results">
+ <div class="error">
<ul>
<li><?php echo $error ?></li>
</ul>
--
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.