/** * Starting from Omeka 1.3, is_admin_theme() should respond to a front * controller parameter, NOT a constant, as using a constant reduces * testability to zero. * * Since this test is flagged as an admin test, is_admin_theme() should be * true by default. Then it should be false when we change the front * controller param. */ public function testIsAdminThemeDependsOnFrontController() { $this->_frontController->setParam('admin', false); $this->assertFalse(is_admin_theme()); $this->_frontController->setParam('admin', true); $this->assertTrue(is_admin_theme()); }
/** * Add the appropriate view scripts directories for a given request. * This is pretty much the glue between the plugin broker and the * View object, since it uses data from the plugin broker to determine what * script paths will be available to the view. * * @param Zend_Controller_Request_Abstract $request Request object. * @return void */ public function preDispatch(Zend_Controller_Request_Abstract $request) { // Getting the module name from the request object is pretty much the main // reason why this needs to be in a controller plugin and can't be localized // to the view script. $moduleName = $request->getModuleName(); $isPluginModule = !in_array($moduleName, array('default', null)); $themeType = is_admin_theme() ? 'admin' : 'public'; $pluginScriptDirs = $this->_pluginMvc->getViewScriptDirs($themeType); // Remove the current plugin, if any, from the set of "normal" plugin paths if ($isPluginModule && isset($pluginScriptDirs[$moduleName])) { $currentPluginScriptDirs = $pluginScriptDirs[$moduleName]; unset($pluginScriptDirs[$moduleName]); } // Add all the "normal" plugin paths foreach ($pluginScriptDirs as $modulePaths) { $this->_addPathsToView($modulePaths); } // Add the theme and core paths $this->_addThemePaths($themeType); // Add plugin and theme-override paths for current plugin if ($isPluginModule) { if (isset($currentPluginScriptDirs)) { $this->_addPathsToView($currentPluginScriptDirs); } $this->_addOverridePathForPlugin($themeType, $moduleName); } }
/** * Adds the homepage route to the router (as specified by the navigation settings page) * The route will not be added if the user is currently on the admin theme. * * @param Zend_Controller_Router_Rewrite $router The router */ private function _addHomepageRoute($router) { // Don't add the route if the user is on the admin theme if (!is_admin_theme()) { $homepageUri = get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME); $homepageUri = trim($homepageUri); $withoutAdminUri = $this->_leftTrim($this->_leftTrim($homepageUri, ADMIN_BASE_URL), '/' . ADMIN_WEB_DIR); if ($withoutAdminUri != $homepageUri) { // homepage uri is an admin link $homepageUri = WEB_ROOT . '/' . ADMIN_WEB_DIR . $withoutAdminUri; $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router); } else { // homepage uri is not an admin link // left trim root directory off of the homepage uri $homepageUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL); // make sure the new homepage is not the default homepage if ($homepageUri == '' || $homepageUri == self::DEFAULT_ROUTE_NAME || $homepageUri == PUBLIC_BASE_URL) { return; } $homepageRequest = new Zend_Controller_Request_Http(); $homepageRequest->setBaseUrl(WEB_ROOT); // web root includes server and root directory $homepageRequest->setRequestUri($homepageUri); $router->route($homepageRequest); $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); if ($dispatcher->isDispatchable($homepageRequest)) { // homepage is an internal link $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route(self::DEFAULT_ROUTE_NAME, $homepageRequest->getParams())); } else { // homepage is some external link or a broken internal link $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router); } } } }
/** * Defines public routes. * * @return void */ public function hookDefineRoutes($args) { if (is_admin_theme()) { return; } $args['router']->addConfig(new Zend_Config_Ini(dirname(__FILE__) . '/routes.ini', 'routes')); }
/** * Return a URL to a record. * * @uses Omeka_Record_AbstractRecord::getCurrentRecord() * @uses Omeka_Record_AbstractRecord::getRecordUrl() * @uses Omeka_View_Helper_Url::url() * @uses Omeka_View_Helper_GetRecordFullIdentifier::getRecordFullIdentifier() * @throws Omeka_View_Exception * @param Omeka_Record_AbstractRecord|string $record * @param string|null $action * @param bool $getAbsoluteUrl * @param array $queryParams * @return string */ public function recordUrl($record, $action = null, $getAbsoluteUrl = false, $queryParams = array()) { if (is_admin_theme() && !get_option('clean_url_use_admin')) { return parent::recordUrl($record, $action, $getAbsoluteUrl, $queryParams); } // Get the current record from the view if passed as a string. if (is_string($record)) { $record = $this->view->getCurrentRecord($record); } if (!$record instanceof Omeka_Record_AbstractRecord) { throw new Omeka_View_Exception(__('Invalid record passed while getting record URL.')); } // Get the clean url if any. $cleanUrl = $this->_getCleanUrl($record, $action); if ($cleanUrl) { $url = $cleanUrl; if ($getAbsoluteUrl) { $url = $this->view->serverUrl() . $url; } if ($queryParams) { $query = http_build_query($queryParams); // Append params if query is already part of the URL. if (strpos($url, '?') === false) { $url .= '?' . $query; } else { $url .= '&' . $query; } } return $url; } return parent::recordUrl($record, $action, $getAbsoluteUrl, $queryParams); }
/** * Adds the homepage route to the router (as specified by the navigation settings page) * The route will not be added if the user is currently on the admin theme. * * @param Zend_Controller_Router_Rewrite $router The router */ private function _addHomepageRoute($router) { // Don't add the route if the user is on the admin theme if (is_admin_theme()) { return; } $homepageUri = trim(get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME)); if (strpos($homepageUri, ADMIN_BASE_URL) === 0) { // homepage uri is an admin link $this->_addHomepageRedirect($homepageUri, $router); } else { if (strpos($homepageUri, '?') === false) { // left trim root directory off of the homepage uri $relativeUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL); // make sure the new homepage is not the default homepage if ($relativeUri == '' || $relativeUri == '/') { return; } $homepageRequest = new Zend_Controller_Request_Http(); $homepageRequest->setRequestUri($homepageUri); $router->route($homepageRequest); $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); if ($dispatcher->isDispatchable($homepageRequest)) { // homepage is an internal link $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route('/', $homepageRequest->getParams())); return; } } } // homepage is some external link, a broken internal link, or has a // query string $this->_addHomepageRedirect($homepageUri, $router); }
public function indexAction() { if (!is_admin_theme()) { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->redirector->gotoUrl(MASTER_URL); } }
protected function _preventAdminAccess($request) { $user = current_user(); // If we're logged in, then prevent access to the admin for guest users if ($user && $user->role == 'guest' && is_admin_theme()) { $this->_getRedirect()->gotoUrl(WEB_ROOT . '/guest-user/user/me'); } }
/** * Use global settings for determining browse page limits. * * @return int */ public function _getBrowseRecordsPerPage() { if (is_admin_theme()) { return (int) get_option('per_page_admin'); } else { return (int) get_option('per_page_public'); } }
public function indexAction() { if (is_admin_theme()) { // There is no API endpoint on the admin theme. $this->_helper->redirector('index', 'index'); } $this->view->title = get_option('site_title'); $this->view->site_url = Omeka_Record_Api_AbstractRecordAdapter::getResourceUrl('/site'); $this->view->resource_url = Omeka_Record_Api_AbstractRecordAdapter::getResourceUrl('/resources'); }
public function filterElementsSelectOptions($elementSets) { //make this magic happen only on the advanced search page if (!is_admin_theme()) { $elementsWeWant = array('Title', 'Date', 'Text', 'Creator', 'Description', 'To', 'From', 'Email Body', 'Local URL', 'Date Published', 'Date Accessed', 'Contributor Name', 'Contributor Age', 'Contributor Gender', 'Contributor Race', 'Current Location'); foreach ($elementSets as $elementSet => $elements) { foreach ($elements as $id => $element) { if (!in_array($element, $elementsWeWant)) { unset($elementSets[$elementSet][$id]); } } } } return $elementSets; }
/** * This is a filter function. * * If the relation text begins with thumb:, then the thumb: portion * is stripped and the remaining urn is displayed as a thumbnail. * If the relation text begins with full:, the full: portion * is stripped and the remaining urn is displayed as a link. * * Any other relation text not meeting the criteria is simply returned as is. * * @param string - the text from the Relation field * @return string - this will be an img tag if thumb:, a href tag if full:, or currently existing text. */ public function replaceDigitalObjectRelations($text, $args) { //If the relation has a full string, check to see if it has a thumb relation. If so, then //display the thumb and link it out to the full image. Otherwise just make it a link. if (preg_match(get_option('digitalobjectlinkerplugin_preg_full_image_string'), $text)) { //Strip the full: from the text. $fulllink = substr($text, strlen(get_option('digitalobjectlinkerplugin_full_image_tag'))); //The only way that I could find to get all relations during the filter was to pull the relations from the database. //Trying to pull from the metadata function seemed to throw this into an infinite loop. //This first gets the element_id for the 'Relation' element from the 'Element' table (omeka_elements if you are looking in the db). //Second, it then finds all of the 'Relation' element texts from the 'ElementText' table (omeka_element_texts) using //the record ID which was passed in from the filter and the element_id that was retrieved. $element = get_db()->getTable('Element')->findByElementSetNameAndElementName('Dublin Core', 'Relation'); $elementID = $element->id; //Record ID that was passed in from the filter. $recordID = $args['record']->id; //We no longer need the element object that we retrieved so releas it. release_object($element); //Create the select for the ElementText table. $select = get_db()->select()->from(array(get_db()->ElementText), array('text'))->where('record_id=' . $recordID . ' AND element_id = ' . $elementID); //Fetch all of the relations. They come back as an array in this form: //array(0 => array('text' => full:urn...), 1 => array('text' => thumb:urn....)) $relations = get_db()->getTable('ElementText')->fetchAll($select); //Logger::log($relations); //As long as at least one relation was returned, we can continue. if (count($relations) > 0) { foreach ($relations as $relation) { //Make sure the relation is not the full relation that we are filtering. If it isn't, //check to see if it is the thumb relation. if ($relation['text'] != $text && preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $relation['text'])) { //Create a thumb image that links out to the full image. $thumblink = substr($relation['text'], strlen(get_option('digitalobjectlinkerplugin_thumb_tag'))); if (!empty($thumblink)) { //Determine the width and height of the thumb. $width = is_admin_theme() ? get_option('digitalobjectlinkerplugin_width_admin') : get_option('digitalobjectlinkerplugin_width_public'); return "<div class=\"item-relation\"><a href=\"" . $fulllink . "\" target=\"_blank\"><img src=\"" . $thumblink . "\" alt=\"" . $thumblink . "\" height=\"" . $width . "\"></img></a></div>"; } } } } //If it reaches this point, the relations did not contain a thumbnail so return a plain link. return "<a href=\"" . $fulllink . "\" target=\"_blank\">" . $fulllink . "</a>"; } elseif (!preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $text)) { return $text; } else { return "<div></div>"; } }
public function showAction() { parent::showAction(); $db = $this->_helper->db; $itemTable = $db->getTable('Item'); $itemAlias = $itemTable->getTableAlias(); $select = $itemTable->getSelectForFindBy(array(), is_admin_theme() ? 10 : 5); $rrTable = $db->getTable('RecordRelationsRelation'); $rrAlias = $rrTable->getTableAlias(); $select->joinInner(array($rrAlias => $rrTable->getTableName()), "{$rrAlias}.subject_id = {$itemAlias}.id", array()); $select->where("{$rrAlias}.object_id = ?", $this->view->collection->id); $select->where("{$rrAlias}.object_record_type = 'Collection'"); $select->where("{$rrAlias}.property_id = ?", get_record_relations_property_id(DCTERMS, 'isPartOf')); $select->where("{$rrAlias}.subject_record_type = 'Item'"); $this->view->items = $itemTable->fetchObjects($select); }
/** * Add the appropriate view scripts directories for a given request. * This is pretty much the glue between the plugin broker and the * View object, since it uses data from the plugin broker to determine what * script paths will be available to the view. * * @param Zend_Controller_Request_Abstract $request Request object. * @return void */ public function preDispatch(Zend_Controller_Request_Abstract $request) { // Getting the module name from the request object is pretty much the main // reason why this needs to be in a controller plugin and can't be localized // to the view script. $moduleName = $request->getModuleName(); $isPluginModule = !in_array($moduleName, array('default', null)); $themeType = is_admin_theme() ? 'admin' : 'public'; if ($isPluginModule) { // Make it so that plugin view/assets load before the theme (and only for the specific plugin/theme). $this->_setupPathsForPlugin($moduleName, $themeType); } else { // Make it so that plugin view/assets load after the theme (and for all possibly plugins). $this->_setupPathsForTheme($themeType); } }
/** * Return the number of results to display per page. * * An authorized user can modify this using the "per_page" query parameter. * * @return int */ protected function _getBrowseRecordsPerPage() { // Return the per page if the current user has permission to modify it. if ($this->_helper->acl->isAllowed('modifyPerPage', 'Search')) { $perPage = (int) $this->getRequest()->get('per_page'); if ($perPage) { return $perPage; } } if (is_admin_theme()) { $perPage = (int) get_option('per_page_admin'); } else { $perPage = (int) get_option('per_page_public'); } return $perPage; }
/** * Set up routing for the upgrade controller. * * Only allows authorized users to upgrade, and blocks the public site when * an upgrade is needed. * * @internal Decision logic for routing to the upgrade controller takes place * in dispatchLoopStartup so it OVERRIDES Admin controller plugin logic, * which otherwise causes an endless redirect. * * @param Zend_Controller_Request_Abstract $request Request object. * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { // Block access to the upgrade controller. if ($request->getControllerName() == 'upgrade' && $request->getModuleName() == 'default' && !$this->_dbCanUpgrade()) { $request->setControllerName('index')->setActionName('index')->setDispatched(false); } if ($this->_dbNeedsUpgrade()) { if (!is_admin_theme()) { die("Public site is unavailable until the upgrade completes."); } // This is a workaround to avoid the authentication requirement. Zend_Controller_Front::getInstance()->unregisterPlugin('Omeka_Controller_Plugin_Admin'); if ($request->getControllerName() != 'upgrade') { $this->_upgrade($request); } } }
public function indexAction() { // Load the SimplePage page on homepage if (!is_admin_theme()) { // Get the page object from the passed ID. $pageId = 1; $page = $this->_helper->db->getTable('SimplePagesPage')->find($pageId); // Set the page object to the view. $this->view->simple_pages_page = $page; $this->view->is_home_page = true; } $this->_helper->viewRenderer->renderScript('index.php'); /* $ip = $_SERVER['REMOTE_ADDR']; if( $ip != '127.0.0.1' && $ip != '78.237.199.87' && $ip != '90.46.97.234' && $ip != '81.57.71.101' && $ip != '109.2.202.238' && $ip != '81.57.71.101' && $ip != '46.218.2.138' && $ip != '46.218.2.130' && $ip != '192.168.0.10' && $ip != '176.144.49.134' && $ip != '80.12.63.24' && $ip != '80.12.35.92' && $ip != '90.2.144.87' && $ip != '92.151.133.33' && $ip != '92.94.137.205' && $ip != '90.46.77.185' && $ip != '82.123.250.106' && $ip != '90.2.201.217' && $ip != '82.123.65.126' && $ip != '92.139.153.201' ) { $this->_helper->viewRenderer->setNoRender(); echo "<div style='width:100%; margin-top:50px; text-align:center;'>"; echo " <img src='".WEB_ROOT."/themes/cg35/images/landing.jpg'>"; echo "</div>"; } else { $this->_helper->viewRenderer->renderScript('index.php'); } */ }
/** * Peform common processing for the publicly accessible actions. * * Set a view script variable for header and footer view scripts and * don't allow logged-in users access. * * The script variables are set for actions in $_publicActions, so * the scripts for those actions should use these variables. */ protected function _handlePublicActions() { $action = $this->_request->getActionName(); if (!in_array($action, $this->_publicActions)) { return; } // If a user is already logged in, they should always get redirected back to the dashboard. if ($loggedInUser = $this->getInvokeArg('bootstrap')->getResource('Currentuser')) { $this->_helper->redirector('index', 'index'); } if (is_admin_theme()) { $header = 'login-header'; $footer = 'login-footer'; } else { $header = 'header'; $footer = 'footer'; } $this->view->header = $header; $this->view->footer = $footer; }
public function filterCollectionsBrowseParams($params) { // Only apply to public side. if (!is_admin_theme()) { $req = Zend_Controller_Front::getInstance()->getRequest(); $requestParams = $req->getParams(); $sortParam = Omeka_Db_Table::SORT_PARAM; $sortDirParam = Omeka_Db_Table::SORT_DIR_PARAM; // Browse Collections if ($requestParams['controller'] == 'collections' && $requestParams['action'] == 'browse') { // If no sort, sort by Dublin Core Date, ascendant. if (get_option('defaultsort_collection_enabled') && !isset($params['sort_field']) || empty($params['sort_field']) || $params['sort_field'] == 'added') { $params['sort_field'] = get_option('defaultsort_collections_option'); $params['sort_dir'] = get_option('defaultsort_collections_direction'); // Set the param itself, so that the correct class may be added to the HTML output in browse_sort_links() $req->setParam($sortParam, get_option('defaultsort_collections_option')); $req->setParam($sortDirParam, get_option('defaultsort_items_direction')); } } } return $params; }
public function filterDisplayElements($elementsBySet) { if ($this->_overrideFilter()) { return $elementsBySet; } $key = is_admin_theme() ? 'admin' : 'public'; $itemTypeSetName = ElementSet::ITEM_TYPE_NAME; // Account for the renamed Item Type Metadata set. foreach ($this->_settings[$key] as $elementSet => $elements) { if ($elementSet == $itemTypeSetName) { foreach (array_keys($elementsBySet) as $currentSet) { if (substr_compare($currentSet, $itemTypeSetName, -strlen($itemTypeSetName), strlen($itemTypeSetName)) === 0) { $elementSet = $currentSet; break; } } } foreach (array_keys($elements) as $element) { unset($elementsBySet[$elementSet][$element]); } } return $elementsBySet; }
/** * Retrieve the number of records to display on any given browse page. * This can be modified as a query parameter provided that a user is * actually logged in. * * @return integer */ protected function _getBrowseRecordsPerPage($pluralName = null) { return is_admin_theme() ? (int) get_option('per_page_admin') : (int) get_option('per_page_public'); }
/** * Override the default simple-search URI to automagically integrate into * the theme; leaves admin section alone for default search. * * @param string $uri URI for Simple Search. * @return string */ public function filterSearchFormDefaultAction($uri) { if (!is_admin_theme()) { $uri = url('solr-search/results/interceptor'); } return $uri; }
/** * Contribution define_routes hook * Defines public-only routes that set the contribution controller as the * only accessible one. */ public function hookDefineRoutes($args) { $router = $args['router']; // Only apply custom routes on public theme. // The wildcards on both routes make these routes always apply for the // contribution controller. // get the base path $bp = get_option('contribution_page_path'); if ($bp) { $router->addRoute('contributionCustom', new Zend_Controller_Router_Route("{$bp}/:action/*", array('module' => 'contribution', 'controller' => 'contribution', 'action' => 'contribute'))); } else { $router->addRoute('contributionDefault', new Zend_Controller_Router_Route('contribution/:action/*', array('module' => 'contribution', 'controller' => 'contribution', 'action' => 'contribute'))); } if (is_admin_theme()) { $router->addRoute('contributionAdmin', new Zend_Controller_Router_Route('contribution/:controller/:action/*', array('module' => 'contribution', 'controller' => 'index', 'action' => 'index'))); } }
/** * Return the number of records to display per page. * * By default this will read from the _browseRecordsPerPage property, which * in turn defaults to null, disabling pagination. This can be * overridden in subclasses by redefining the property or this method. * * Setting the property to self::RECORDS_PER_PAGE_SETTING will enable * pagination using the admin-configued page limits. * * @param string|null $pluralName * @return integer|null */ protected function _getBrowseRecordsPerPage($pluralName = null) { $perPage = $this->_browseRecordsPerPage; // Use the user-configured page if ($perPage === self::RECORDS_PER_PAGE_SETTING) { $options = $this->getFrontController()->getParam('bootstrap')->getResource('Options'); if (is_admin_theme()) { $perPage = (int) $options['per_page_admin']; } else { $perPage = (int) $options['per_page_public']; } } // If users are allowed to modify the # of items displayed per page, // then they can pass the 'per_page' query parameter to change that. if ($this->_helper->acl->isAllowed('modifyPerPage') && ($queryPerPage = $this->getRequest()->get('per_page'))) { $perPage = (int) $queryPerPage; } // Any integer zero or below disables pagination. if ($perPage < 1) { $perPage = null; } if ($pluralName) { $perPage = apply_filters("{$pluralName}_browse_per_page", $perPage, array('controller' => $this)); } return $perPage; }
public function loginAction() { if (!is_admin_theme()) { $referer = rtrim($_SERVER['HTTP_REFERER'], '/'); $master = rtrim(MASTER_URL, '/'); $login = $master . '/users/login'; if (isset($_SERVER['HTTP_REFERER']) && is_integer(strpos($referer, $master)) && $referer != $master && $referer != $login && !strpos($referer, '/users/activate')) { $session = new Zend_Session_Namespace(); $session->redirect = $_SERVER['HTTP_REFERER']; } } // require_once is necessary because lacking form autoloading. require_once APP_DIR . '/forms/Login.php'; $loginForm = new Omeka_Form_Login(); $loginForm = apply_filters('login_form', $loginForm); $this->view->form = $loginForm; if (!$this->getRequest()->isPost()) { return; } if ($loginForm instanceof Zend_Form && !$loginForm->isValid($_POST)) { return; } User::upgradeHashedPassword($loginForm->getValue('username'), $loginForm->getValue('password')); $authAdapter = new Omeka_Auth_Adapter_UserTable($this->_helper->db->getDb()); $pluginBroker = $this->getInvokeArg('bootstrap')->getResource('Pluginbroker'); // If there are no plugins filtering the login adapter, set the // credentials for the default adapter. if (!$pluginBroker || !$pluginBroker->getFilters('login_adapter')) { $authAdapter->setIdentity($loginForm->getValue('username'))->setCredential($loginForm->getValue('password')); } else { $authAdapter = apply_filters('login_adapter', $authAdapter, array('login_form' => $loginForm)); } $authResult = $this->_auth->authenticate($authAdapter); if (!$authResult->isValid()) { if ($log = $this->_getLog()) { $ip = $this->getRequest()->getClientIp(); $log->info("Failed login attempt from '{$ip}'."); } $this->_helper->flashMessenger($this->getLoginErrorMessages($authResult), 'error'); return; } if ($loginForm && $loginForm->getValue('remember')) { // Remember that a user is logged in for the default amount of // time (2 weeks). Zend_Session::rememberMe(); } else { // If a user doesn't want to be remembered, expire the cookie as // soon as the browser is terminated. Zend_Session::forgetMe(); } $session = new Zend_Session_Namespace(); if ($session->redirect) { $this->_helper->redirector->gotoUrl($session->redirect); } else { $this->_helper->redirector->gotoUrl('/'); } }
public function hookCollectionsBrowseSql($args) { $select = $args['select']; $params = $args['params']; $db = get_db(); $collectionsTable = $db->getTable('Collection'); //make all sorting go by date in public if (!is_admin_theme()) { //when SELECT arrives here, it's already ordered by added, so kill that $select->reset($select::ORDER); $collectionsTable->applySorting($select, "Newspaper Metadata,start_year", "ASC"); } $select->join($db->NewspapersNewspaper, "{$db->NewspapersNewspaper}.collection_id = collections.id", array()); if (isset($params['states'])) { $states = $params['states']; } if (!empty($states)) { $select->where("{$db->NewspapersNewspaper}.state IN (?)", $states); } if (isset($params['advanced'])) { $terms = $params['advanced']; } else { $terms = array(); } $advancedIndex = 0; foreach ($terms as $v) { // Do not search on blank rows. if (empty($v['element_id']) || empty($v['type'])) { continue; } $value = isset($v['terms']) ? $v['terms'] : null; $type = $v['type']; $elementId = (int) $v['element_id']; $alias = "_advanced_{$advancedIndex}"; //copied from Item advanced search filter, and limited to what I //use in the modified SearchByMetadata $inner = true; $extraJoinCondition = ''; // Determine what the WHERE clause should look like. switch ($type) { case 'is exactly': $predicate = ' = ' . $db->quote($value); break; case 'contains': $predicate = "LIKE " . $db->quote('%' . $value . '%'); break; default: throw new Omeka_Record_Exception(__('Invalid search type given!')); } // Note that $elementId was earlier forced to int, so manual quoting // is unnecessary here $joinCondition = "{$alias}.record_id = collections.id AND {$alias}.record_type = 'Collection' AND {$alias}.element_id = {$elementId}"; if ($extraJoinCondition) { $joinCondition .= ' ' . $extraJoinCondition; } if ($inner) { $select->joinInner(array($alias => $db->ElementText), $joinCondition, array()); } else { $select->joinLeft(array($alias => $db->ElementText), $joinCondition, array()); } $select->where("{$alias}.text {$predicate}"); $advancedIndex++; } }
/** * Defines public routes "main_path / my_collection | generic / dc:identifier". * * @todo Rechecks performance of routes definition. */ public function hookDefineRoutes($args) { if (is_admin_theme() && !get_option('clean_url_use_admin')) { return; } $router = $args['router']; $mainPath = get_option('clean_url_main_path'); $collectionGeneric = get_option('clean_url_collection_generic'); $itemGeneric = get_option('clean_url_item_generic'); $fileGeneric = get_option('clean_url_file_generic'); $allowedForItems = unserialize(get_option('clean_url_item_alloweds')); $allowedForFiles = unserialize(get_option('clean_url_file_alloweds')); // Note: order of routes is important: Zend checks from the last one // (most specific) to the first one (most generic). // Get all collections identifiers with one query. $collectionsIdentifiers = get_view()->getRecordTypeIdentifiers('Collection', false); if (!empty($collectionsIdentifiers)) { // Use one regex for all collections. Default is case insensitve. $collectionsRegex = array_map('preg_quote', $collectionsIdentifiers); // To avoid a bug with identifiers that contain a "/", that is not // escaped with preg_quote(). $collectionsRegex = '(' . str_replace('/', '\\/', implode('|', $collectionsRegex)) . ')'; // Add a collection route. $route = $mainPath . $collectionGeneric; $router->addRoute('cleanUrl_collections', new Zend_Controller_Router_Route($route . ':record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'collection-show'), array('record_identifier' => $collectionsRegex))); // Add a collection route for files. if (in_array('collection', $allowedForFiles)) { $router->addRoute('cleanUrl_collections_file', new Zend_Controller_Router_Route($route . ':collection_identifier/:record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-collection-file'), array('collection_identifier' => $collectionsRegex))); } // Add a collection / item route for files. if (in_array('collection_item', $allowedForFiles)) { $router->addRoute('cleanUrl_collections_item_file', new Zend_Controller_Router_Route($route . ':collection_identifier/:item_identifier/:record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-collection-item-file'), array('collection_identifier' => $collectionsRegex))); } // Add a collection route for items. if (in_array('collection', $allowedForItems)) { $router->addRoute('cleanUrl_collections_item', new Zend_Controller_Router_Route($route . ':collection_identifier/:record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-collection-item'), array('collection_identifier' => $collectionsRegex))); } } // Add a generic route for files. if (in_array('generic', $allowedForFiles)) { $route = $mainPath . $fileGeneric; $router->addRoute('cleanUrl_generic_file', new Zend_Controller_Router_Route($route . ':record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-file', 'collection_id' => NULL))); } // Add a generic / item route for files. if (in_array('generic_item', $allowedForFiles)) { $route = $mainPath . $itemGeneric; $router->addRoute('cleanUrl_generic_item_file', new Zend_Controller_Router_Route($route . ':item_identifier/:record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-item-file', 'collection_id' => NULL))); } // Add a generic route for items. if (in_array('generic', $allowedForItems)) { $route = $mainPath . trim($itemGeneric, '/'); $router->addRoute('cleanUrl_generic_items_browse', new Zend_Controller_Router_Route($route, array('module' => 'clean-url', 'controller' => 'index', 'action' => 'items-browse'))); $router->addRoute('cleanUrl_generic_item', new Zend_Controller_Router_Route($route . '/:record_identifier', array('module' => 'clean-url', 'controller' => 'index', 'action' => 'route-item', 'collection_id' => NULL))); } }
function hookDefineRoutes($args) { // Don't add these routes on the admin side to avoid conflicts. if (is_admin_theme()) { return; } $router = $args['router']; // Add custom routes based on the page slug. $router->addRoute('ajax-upload-audio', new Zend_Controller_Router_Route('items/upload-audio/:id', array('module' => 'audio-recorder', 'controller' => 'recording', 'action' => 'upload'))); if (get_option('audio_recorder_item_record_route')) { $router->addRoute('item-record-audio', new Zend_Controller_Router_Route('items/record/:id', array('module' => 'audio-recorder', 'controller' => 'recording', 'action' => 'record'))); } }
$head = array('title' => html_escape($title)); echo head($head); ?> <style type="text/css"> #scripto-diff tr {border: none !important;} #scripto-diff td {padding: 2px !important;} td.diff-marker {width: 10px;} td.diff-deletedline {background-color: #FFEDED;} td.diff-addedline {background-color: #EDFFEF;} ins.diffchange {background-color: #BDFFC8;} del.diffchange {background-color: #FFBDBD;} </style> <div class="container"> <div class="content-block browse-page"> <?php if (!is_admin_theme()) { ?> <h1><?php echo $head['title']; ?> </h1> <?php } ?> <div id="primary"> <?php echo flash(); ?> <div id="scripto-diff" class="scripto"> <!-- navigation -->
<?php foreach ($record_types as $key => $value) { ?> <?php echo $this->formCheckbox('record_types[]', $key, in_array($key, $filters['record_types']) ? array('checked' => true, 'id' => 'record_types-' . $key) : null); ?> <?php echo $value; ?> <br> <?php } ?> </fieldset> <?php } elseif (is_admin_theme()) { ?> <p><a href="<?php echo url('settings/edit-search'); ?> "><?php echo __('Go to search settings to select record types to use.'); ?> </a></p> <?php } ?> <p><?php echo link_to_item_search(__('Advanced Search (Items only)')); ?> </p>