<commit_before><?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 cc=80; */

/**
 * @package     omeka
 * @subpackage  solr-search
 * @copyright   2012 Rector and Board of Visitors, University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html
 */


class SolrSearch_ReindexController extends Omeka_Controller_AbstractActionController
{

    /**
     * Display the "Index Items" form.
     */
    public function indexAction()
    {
        $form = $this->_getReindexForm();
        $this->view->form = $form;
    }

    /**
     * Reindex items when form is submitted.
     */
    public function updateAction()
    {
        $form = $this->_getReindexForm();

        if ($this->_request->isPost()) {
            if ($form->isValid($this->_request->getPost())) {
                try{

                    SolrSearch_IndexHelpers::deleteAll(array());
                    SolrSearch_IndexHelpers::indexAll(array());

                    $this->_helper->flashMessenger(
                        __('Reindexing finished.'),
                        'success'
                    );

                } catch (Exception $err) {
                    $this->_helper->flashMessenger($err->getMessage(), 'error');
                }
            }
        }	
    }

    /**
     * Construct the form.
     *
     * @return Zend_Form
     */
    private function _getReindexForm()
    {
        include "Zend/Form/Element.php";
        $form = new Zend_Form();
        $form->setAction('update');
        $form->setMethod('post');
        $form->setAttrib('enctype', 'multipart/form-data');

        //Submit button
        $form->addElement('submit', 'submit');
        $submitElement=$form->getElement('submit');
        $submitElement->setLabel(__('Clear & Reindex'));
        $submitElement->setAttrib('class', 'btn btn-danger btn-large');

        return $form;
    }
}<commit_msg>In the reindex controller, collapses the 'update' action into the 'index' action.<commit_after><?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 cc=80; */

/**
 * @package     omeka
 * @subpackage  solr-search
 * @copyright   2012 Rector and Board of Visitors, University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html
 */


class SolrSearch_ReindexController extends Omeka_Controller_AbstractActionController
{

    /**
     * Display the "Index Items" form.
     */
    public function indexAction()
    {

        $form = $this->_getReindexForm();

        if ($this->_request->isPost()) {
            if ($form->isValid($this->_request->getPost())) {
                try{

                    SolrSearch_IndexHelpers::deleteAll(array());
                    SolrSearch_IndexHelpers::indexAll(array());

                    $this->_helper->flashMessenger(
                        __('Reindexing finished.'),
                        'success'
                    );

                } catch (Exception $err) {
                    $this->_helper->flashMessenger($err->getMessage(), 'error');
                }
            }
        }	

        $this->view->form = $form;

    }

    /**
     * Construct the form.
     *
     * @return Zend_Form
     */
    private function _getReindexForm()
    {
        include "Zend/Form/Element.php";
        $form = new Zend_Form();
        $form->setMethod('post');
        $form->setAttrib('enctype', 'multipart/form-data');

        //Submit button
        $form->addElement('submit', 'submit');
        $submitElement=$form->getElement('submit');
        $submitElement->setLabel(__('Clear & Reindex'));
        $submitElement->setAttrib('class', 'btn btn-large');

        return $form;
    }
}
{'fraction_non_alphanumeric': 0.14173654314308898, 'fraction_numerical': 0.005950770895320531, 'mean_word_length': 1.934920634920635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5428961', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1015, 'n_words': 192}