Example #1
0
 public function editSearchAction()
 {
     // Customize search record types.
     $csrf = new Omeka_Form_SessionCsrf();
     $this->view->searchRecordTypes = get_search_record_types();
     $this->view->customSearchRecordTypes = get_custom_search_record_types();
     $this->view->csrf = $csrf;
     if ($this->getRequest()->isPost()) {
         if (!$csrf->isValid($_POST)) {
             $this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
             return;
         }
         if (isset($_POST['submit_save_changes'])) {
             if (isset($_POST['search_record_types'])) {
                 $option = serialize($_POST['search_record_types']);
             } else {
                 $option = serialize(array());
             }
             set_option('search_record_types', $option);
             $this->_helper->flashMessenger(__('You have changed which records are searchable in Omeka. Please re-index the records using the form below.'), 'success');
         }
         // Index the records.
         if (isset($_POST['submit_index_records'])) {
             Zend_Registry::get('bootstrap')->getResource('jobs')->sendLongRunning('Job_SearchTextIndex');
             $this->_helper->flashMessenger(__('Indexing records. This may take a while. You may continue administering your site.'), 'success');
         }
         $this->_helper->redirector('edit-search');
     }
 }
Example #2
0
/**
 * Get all record types that have been customized to be searchable.
 *
 * @package Omeka\Function\Search
 * @uses get_search_record_types()
 * @return array
 */
function get_custom_search_record_types()
{
    // Get the custom search record types from the database.
    $customSearchRecordTypes = unserialize(get_option('search_record_types'));
    if (!is_array($customSearchRecordTypes)) {
        $customSearchRecordTypes = array();
    }
    // Compare the custom list to the full list.
    $searchRecordTypes = get_search_record_types();
    foreach ($searchRecordTypes as $key => $value) {
        // Remove record types that have been omitted.
        if (!in_array($key, $customSearchRecordTypes)) {
            unset($searchRecordTypes[$key]);
        }
    }
    return $searchRecordTypes;
}
Example #3
0
<?php

$pageTitle = __('Search') . ' ' . __('(%s total)', $total_results);
echo head(array('title' => $pageTitle, 'bodyclass' => 'search'));
$searchRecordTypes = get_search_record_types();
?>
<h1><?php 
echo $pageTitle;
?>
</h1>
<?php 
echo search_filters();
if ($total_results) {
    echo pagination_links();
    ?>
<table id="search-results">
    <thead>
        <tr>
            <th><?php 
    echo __('Title');
    ?>
</th>
            <th><?php 
    echo __('Description');
    ?>
</th>
            <th><?php 
    echo __('Item Number');
    ?>
</th>
            <th><?php 
Example #4
0
 private function _addOptions()
 {
     $task = new Installer_Task_Options();
     $task->setOptions(array('administrator_email' => $this->_getValue('administrator_email'), 'copyright' => $this->_getValue('copyright'), 'site_title' => $this->_getValue('site_title'), 'author' => $this->_getValue('author'), 'description' => $this->_getValue('description'), 'thumbnail_constraint' => $this->_getValue('thumbnail_constraint'), 'square_thumbnail_constraint' => $this->_getValue('square_thumbnail_constraint'), 'fullsize_constraint' => $this->_getValue('fullsize_constraint'), 'per_page_admin' => $this->_getValue('per_page_admin'), 'per_page_public' => $this->_getValue('per_page_public'), 'show_empty_elements' => $this->_getValue('show_empty_elements'), 'path_to_convert' => $this->_getValue('path_to_convert'), Theme::ADMIN_THEME_OPTION => Installer_Default::DEFAULT_ADMIN_THEME, Theme::PUBLIC_THEME_OPTION => Installer_Default::DEFAULT_PUBLIC_THEME, Omeka_Validate_File_Extension::WHITELIST_OPTION => Omeka_Validate_File_Extension::DEFAULT_WHITELIST, Omeka_Validate_File_MimeType::WHITELIST_OPTION => Omeka_Validate_File_MimeType::DEFAULT_WHITELIST, File::DISABLE_DEFAULT_VALIDATION_OPTION => (string) (!extension_loaded('fileinfo')), Omeka_Db_Migration_Manager::VERSION_OPTION_NAME => OMEKA_VERSION, 'display_system_info' => true, 'html_purifier_is_enabled' => 1, 'html_purifier_allowed_html_elements' => implode(',', Omeka_Filter_HtmlPurifier::getDefaultAllowedHtmlElements()), 'html_purifier_allowed_html_attributes' => implode(',', Omeka_Filter_HtmlPurifier::getDefaultAllowedHtmlAttributes()), 'tag_delimiter' => ',', Omeka_Navigation::PUBLIC_NAVIGATION_MAIN_OPTION_NAME => Omeka_Navigation::getNavigationOptionValueForInstall(Omeka_Navigation::PUBLIC_NAVIGATION_MAIN_OPTION_NAME), 'search_record_types' => serialize(get_search_record_types()), 'api_enable' => false, 'api_per_page' => 50, 'show_element_set_headings' => 1));
     $task->install($this->_db);
 }
Example #5
0
 /**
  * Save a search text row.
  * 
  * Call this statically only when necessary. Used primarily when in a record 
  * that does not implement Mixin_Search but contains text that is needed for 
  * another record's search text. For example, when saving a child record 
  * that contains search text that should be saved to its parent record.
  * 
  * @param string $recordType
  * @param int $recordId
  * @param string $text
  * @param string $title
  * @param int $public
  */
 public static function saveSearchText($recordType, $recordId, $text, $title, $public = 1)
 {
     // Index this record only if it's of a type that is registered in the
     // search_record_types filter.
     if (!array_key_exists($recordType, get_search_record_types())) {
         return;
     }
     $searchText = Zend_Registry::get('bootstrap')->getResource('Db')->getTable('SearchText')->findByRecord($recordType, $recordId);
     // Either don't save the search text or delete an existing search text
     // row if the record has no assigned text.
     if (!trim($text)) {
         if ($searchText) {
             $searchText->delete();
         }
         return;
     }
     if (!$searchText) {
         $searchText = new SearchText();
         $searchText->record_type = $recordType;
         $searchText->record_id = $recordId;
     }
     $searchText->public = $public ? 1 : 0;
     $searchText->title = $title;
     $searchText->text = $text;
     $searchText->save();
 }