Esempio n. 1
0
 /**
  * Render html for the save panel buttons
  * 
  * @param string $content
  * @return string
  */
 public function render($content)
 {
     $noAttribs = $this->getOption('noAttribs');
     $record = $this->getRecord();
     $content = $this->getOption('content');
     $this->removeOption('content');
     $this->removeOption('noAttribs');
     $this->removeOption('openOnly');
     $this->removeOption('closeOnly');
     $this->removeOption('record');
     $attribs = null;
     if (!$noAttribs) {
         $attribs = $this->getOptions();
     }
     $html = "<input id='save-changes' class='submit big green button' type='submit' value='" . __('Save Changes') . "' name='submit' />";
     if ($record) {
         if ($this->hasPublicPage() && $record->exists()) {
             set_theme_base_url('public');
             $publicPageUrl = record_url($record, 'show');
             revert_theme_base_url();
             $html .= "<a href='{$publicPageUrl}' class='big blue button' target='_blank'>" . __('View Public Page') . "</a>";
         }
         if (is_allowed($record, 'delete')) {
             $recordDeleteConfirm = record_url($record, 'delete-confirm');
             $html .= "<a href='{$recordDeleteConfirm}' class='big red button delete-confirm'>" . __('Delete') . "</a>";
         }
     }
     //used by SavePanelHook to locate where to insert hook content
     $html .= "<div id='button-field-line'></div>";
     return $html;
 }
 public function testSetAndRevertBaseUri()
 {
     $this->assertTrue(defined('PUBLIC_BASE_URL'));
     $this->assertTrue(defined('ADMIN_BASE_URL'));
     $this->assertTrue(defined('CURRENT_BASE_URL'));
     $this->assertEquals(PUBLIC_BASE_URL, CURRENT_BASE_URL);
     $baseUrl = $this->frontController->getBaseUrl();
     $this->assertEquals($baseUrl, PUBLIC_BASE_URL);
     set_theme_base_url('admin');
     $this->assertEquals($this->frontController->getBaseUrl(), ADMIN_BASE_URL);
     revert_theme_base_url();
     $this->assertEquals($this->frontController->getBaseUrl(), PUBLIC_BASE_URL);
 }
Esempio n. 3
0
 /**
  * Returns href for this page
  *
  * This method uses {@link Zend_Controller_Action_Helper_Url} to assemble
  * the href based on the page's properties.
  *
  * @return string  page href
  */
 public function getHref()
 {
     $themeOption = $this->_theme;
     if ($themeOption === null) {
         return parent::getHref();
     }
     // clear cache if themeOption is the empty string,
     // which corresponds to current base url
     if ($themeOption == '') {
         $this->_hrefCache = null;
     }
     // create an href for the correct theme
     set_theme_base_url($themeOption);
     $href = parent::getHref();
     revert_theme_base_url();
     return $href;
 }
Esempio n. 4
0
/**
 * Get a URL to the admin theme.
 *
 * @package Omeka\Function\View\Navigation
 * @uses set_theme_base_url()
 * @uses revert_theme_base_url()
 * @param mixed $args
 * @return string
 */
function admin_url()
{
    set_theme_base_url('admin');
    $args = func_get_args();
    $url = call_user_func_array('url', $args);
    revert_theme_base_url();
    return $url;
}
Esempio n. 5
0
 /**
  * Creates an Omeka Navigation object by adding
  * pages generated by Omeka plugins and other contributors via a filter (e.x. 'public_navigation_main').
  * The filter should provide an array pages like they are added to Zend_Navigation_Container::addPages
  * However, the page types should only be one of the following types:
  * Omeka_Navigation_Page_Uri or Zend_Navigation_Page_Mvc.  
  * If the associated uri of any page is invalid, it will not add that page to the navigation. 
  * Also, it removes expired pages from formerly active plugins and other former handlers of the filter.
  * 
  * @param String $filterName    The name of the filter
  * @throws Zend_Navigation_Exception if a filter page is invalid  
  */
 public static function createNavigationFromFilter($filterName = '')
 {
     if ($filterName == '') {
         $filterName = self::PUBLIC_NAVIGATION_MAIN_FILTER_NAME;
     }
     // create a new navigation object from the filterName
     $filterNav = new Omeka_Navigation();
     $theme = null;
     // get default pages for the filter
     $pageLinks = array();
     switch ($filterName) {
         case self::PUBLIC_NAVIGATION_MAIN_FILTER_NAME:
             // add the standard Browse Items and Browse Collections links to the main nav
             $pageLinks = array(new Omeka_Navigation_Page_Mvc(array('label' => __('Browse Items'), 'controller' => 'items', 'action' => 'browse', 'visible' => true, 'theme' => 'public')), new Omeka_Navigation_Page_Mvc(array('label' => __('Browse Collections'), 'controller' => 'collections', 'action' => 'browse', 'visible' => true, 'theme' => 'public')));
             $theme = 'public';
             break;
     }
     // gather other page links from filter handlers (e.g. plugins)
     if ($theme) {
         set_theme_base_url($theme);
     }
     $pageLinks = apply_filters($filterName, $pageLinks);
     if ($theme) {
         revert_theme_base_url();
     }
     foreach ($pageLinks as $pageLink) {
         // normalize the page and its subpages
         $page = $filterNav->_normalizePageRecursive($pageLink, array('can_delete' => false, 'theme' => $theme));
         $filterNav->baseAddNormalizedPage($page);
     }
     return $filterNav;
 }
 /**
  * Send an email notification to the user who contributed the Item.
  *
  * This email will appear to have been sent from the address specified via
  * the 'contribution_email_sender' option.
  *
  * @param string $email Address to send to.
  * @param Item $item Item that was contributed via the form.
  * @return void
  */
 protected function _sendEmailNotifications($recipient, $item)
 {
     $fromAddress = get_option('contribution_email_sender');
     $siteTitle = get_option('site_title');
     $this->view->item = $item;
     //If this field is empty, don't send the email
     if (!empty($fromAddress)) {
         $contributorMail = new Zend_Mail('UTF-8');
         $body .= get_option('contribution_email');
         $url = record_url($item, 'show', true);
         $link = "<a href='{$url}'>{$url}</a>";
         $body .= "<p>" . __("Contribution URL (pending review by project staff): ") . $link . "</p>";
         $body .= "<p>" . __("Your username is %s", $recipient->username) . "</p>";
         $passwordRecoveryUrl = WEB_ROOT . "/users/forgot-password";
         $passwordRecoveryLink = "<a href='{$passwordRecoveryUrl}'>{$passwordRecoveryUrl}</a>";
         $body .= "<p>" . __("To log in and change your username, request a password here: ") . $passwordRecoveryLink . "<p>";
         $contributorMail->setBodyHtml($body);
         $contributorMail->setFrom($fromAddress, __("%s Administrator", $siteTitle));
         $contributorMail->addTo($recipient->email);
         $contributorMail->setSubject(__("Your %s Contribution", $siteTitle));
         $contributorMail->addHeader('X-Mailer', 'PHP/' . phpversion());
         try {
             $contributorMail->send();
         } catch (Zend_Mail_Exception $e) {
             _log($e);
         }
     }
     //notify admins who want notification
     $toAddresses = explode(",", get_option('contribution_email_recipients'));
     $fromAddress = get_option('administrator_email');
     foreach ($toAddresses as $toAddress) {
         if (empty($toAddress)) {
             continue;
         }
         $adminMail = new Zend_Mail('UTF-8');
         $body = "<p>";
         $body .= __("A new contribution to %s has been made.", get_option('site_title'));
         $body .= "</p>";
         set_theme_base_url('admin');
         $url = record_url($item, 'show', true);
         $link = "<a href='{$url}'>{$url}</a>";
         $body .= "<p>" . __("Contribution URL for review: ") . $link . "</p>";
         revert_theme_base_url();
         $adminMail->setBodyHtml($body);
         $adminMail->setFrom($fromAddress, "{$siteTitle}");
         $adminMail->addTo($toAddress);
         $adminMail->setSubject(__("New %s Contribution", $siteTitle));
         $adminMail->addHeader('X-Mailer', 'PHP/' . phpversion());
         try {
             $adminMail->send();
         } catch (Zend_Mail_Exception $e) {
             _log($e);
         }
     }
 }
 public function getRecordUrl($action = 'show')
 {
     switch ($action) {
         case 'show':
             set_theme_base_url('public');
             $url = url($this->path) . "#comment-" . $this->id;
             revert_theme_base_url();
             return $url;
             break;
         default:
             //sadly, I made the plugin name, and so the controller name, different
             //because of the extant, but not maintained, Comments plugin
             //return parent::getRecordUrl($action);
             return url("commenting/comment/{$action}/id/{$this->id}");
     }
 }
 /**
  * Set the base url of the static repository (gateway + static repository
  * url without scheme, but with encoded delimiter of port if any).
  *
  * @example http://example.org/gateway/institution.org%3A8080/path/to/repository_identifier.xml
  * @example http://example.org/gateway/example.org/repository/repository_identifier.xml
  *
  * @internal Should be run after _setStaticRepositoryUrlFromParameters()
  *
  * @param string $repositoryUrl The url of the repository.
  * @return string The base url.
  */
 private function _setStaticRepositoryBaseUrl($url)
 {
     if (plugin_is_active('OaiPmhGateway')) {
         // There is no function for absolute public url.
         set_theme_base_url('public');
         $baseUrl = absolute_url(array('repository' => substr(strstr($url, '://'), 3)), 'oaipmhgateway_query', array(), false, false);
         revert_theme_base_url();
     } else {
         $baseUrl = WEB_FILES . '/' . get_option('oai_pmh_static_repository_static_dir') . '/' . basename($url);
     }
     return $baseUrl;
 }
Esempio n. 9
0
 public function installedAction()
 {
     set_theme_base_url('install');
 }