예제 #1
0
 private static function forwardInfo()
 {
     $url = PHPWS_Core::getCurrentUrl();
     if ($url == 'index.php' || $url == '') {
         return;
     }
     if (UTF8_MODE) {
         $preg = '/[^\\w\\-\\pL]/u';
     } else {
         $preg = '/[^\\w\\-]/';
     }
     // Should ignore the ? and everything after it
     $qpos = strpos($url, '?');
     if ($qpos !== FALSE) {
         $url = substr($url, 0, $qpos);
     }
     $aUrl = explode('/', preg_replace('|/+$|', '', $url));
     $module = array_shift($aUrl);
     $mods = PHPWS_Core::getModules(true, true);
     if (!in_array($module, $mods)) {
         $GLOBALS['Forward'] = $module;
         return;
     }
     if (preg_match('/[^\\w\\-]/', $module)) {
         return;
     }
     $_REQUEST['module'] = $_GET['module'] =& $module;
     $count = 1;
     $continue = 1;
     $i = 0;
     // Try and save some old links references
     if (count($aUrl) == 1) {
         $_GET['id'] = $_REQUEST['id'] = $aUrl[0];
         return;
     }
     while (isset($aUrl[$i])) {
         $key = $aUrl[$i];
         if (!$i && is_numeric($key)) {
             $_GET['id'] = $key;
             return;
         }
         $i++;
         if (isset($aUrl[$i])) {
             $value = $aUrl[$i];
             if (preg_match('/&/', $value)) {
                 $remain = explode('&', $value);
                 $j = 1;
                 $value = $remain[0];
                 while (isset($remain[$j])) {
                     $sub = explode('=', $remain[$j]);
                     $_REQUEST[$sub[0]] = $_GET[$sub[0]] = $sub[1];
                     $j++;
                 }
             }
             $_GET[$key] = $_REQUEST[$key] = $value;
         }
         $i++;
     }
 }
예제 #2
0
 public static function loadHeaderTags(&$template)
 {
     $page_metatags = null;
     $theme = Layout::getCurrentTheme();
     $key = Key::getCurrent();
     if (Key::checkKey($key, false)) {
         $page_metatags = Layout::getMetaPage($key->id);
         if (PHPWS_Error::isError($page_metatags)) {
             PHPWS_Error::log($page_metatags);
             $page_metatags = null;
         }
     }
     if (!isset($_SESSION['javascript_enabled'])) {
         $jsHead[] = '<noscript><meta http-equiv="refresh" content="0;url=index.php?nojs=1&ret=' . urlencode(PHPWS_Core::getCurrentUrl()) . '"/></noscript>';
     }
     if (isset($_GET['nojs'])) {
         $_SESSION['javascript_enabled'] = false;
         PHPWS_Core::reroute(urldecode($_GET['ret']));
     } elseif (!isset($_SESSION['javascript_enabled'])) {
         $_SESSION['javascript_enabled'] = true;
     }
     if (isset($GLOBALS['Layout_JS'])) {
         foreach ($GLOBALS['Layout_JS'] as $script => $javascript) {
             $jsHead[] = $javascript['head'];
         }
     }
     if (!empty($jsHead)) {
         $template['JAVASCRIPT'] = implode("\n", $jsHead);
     }
     Layout::importStyleSheets();
     Layout::submitHeaders($theme, $template);
     if (!empty($GLOBALS['Layout_Links'])) {
         $template['STYLE'] .= "\n" . implode("\n", $GLOBALS['Layout_Links']);
     }
     $template['METATAGS'] = Layout::getMetaTags($page_metatags);
     if ($page_metatags) {
         $template['PAGE_TITLE'] = $page_metatags['page_title'] . PAGE_TITLE_DIVIDER . $_SESSION['Layout_Settings']->getPageTitle(true);
     } else {
         $template['PAGE_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle();
     }
     $template['ONLY_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE);
     // Depricated
     // The Site's Name, as set in Layout 'Meta Tags' interface.
     $template['SITE_NAME'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE);
     $template['BASE'] = Layout::getBase();
     $template['HTTP'] = PHPWS_Core::getHttp();
     // 'http' or 'https'
     // Complete URL of the site's home page
     $template['HOME_URL'] = PHPWS_Core::getHomeHttp(true, true, true);
 }
예제 #3
0
 public function isCurrentUrl()
 {
     static $current_url = null;
     static $redirect_url = null;
     /**
      * If the current link's url starts with http and does not match
      * the current home address, return false because it is an offsite link.
      */
     $home = preg_quote(PHPWS_HOME_HTTP);
     if (preg_match('@^http@i', $this->url) && !preg_match("@{$home}@i", $this->url)) {
         return false;
     }
     if (!$current_url) {
         $current_url = preg_quote(PHPWS_Core::getCurrentUrl(true, false));
     }
     if (!$redirect_url) {
         $redirect_url = preg_quote(PHPWS_Core::getCurrentUrl());
     }
     if (preg_match("@{$redirect_url}\$@", $this->url)) {
         return true;
     } else {
         return false;
     }
 }
 public function saveLastView()
 {
     $_SESSION['DBPager_Last_View'][$this->table] = PHPWS_Core::getCurrentUrl();
 }
예제 #5
0
 public function view()
 {
     Layout::addStyle('pagesmith');
     if (Current_User::allow('pagesmith', 'edit_page', $this->id)) {
         MiniAdmin::add('pagesmith', $this->editLink(dgettext('pagesmith', 'Edit this page')));
         MiniAdmin::add('pagesmith', $this->frontPageToggle());
     }
     $this->loadTemplate();
     $this->_tpl->loadStyle();
     $this->flag();
     $this->loadSections();
     if (!empty($this->title) && !PHPWS_Core::atHome()) {
         Layout::addPageTitle($this->title);
     }
     if (!$this->hide_title) {
         $this->_content['page_title'] =& $this->title;
     }
     $anchor_title = $tpl['ANCHOR'] = preg_replace('/\\W/', '-', $this->title);
     if (Current_User::allow('pagesmith') && $this->_key->show_after > time()) {
         $tpl['SHOW_AFTER'] = t('Page hidden until %s', strftime('%F %H:%M', $this->_key->show_after));
     }
     $tpl['CONTENT'] = PHPWS_Template::process($this->_content, 'pagesmith', $this->_tpl->page_path . 'page.tpl');
     $this->pageLinks($tpl);
     if (PHPWS_Settings::get('pagesmith', 'back_to_top')) {
         $tpl['BACK_TO_TOP'] = sprintf('<a href="%s#%s">%s</a>', PHPWS_Core::getCurrentUrl(), $anchor_title, '<i class="fa fa-arrow-circle-up"></i> ' . dgettext('pagesmith', 'Back to top'));
     }
     $content = PHPWS_Template::process($tpl, 'pagesmith', 'page_frame.tpl');
     return $content;
 }
예제 #6
0
 public static function autoForward()
 {
     $current_url = PHPWS_Core::getCurrentUrl();
     if (preg_match('@pagesmith/\\d+@', $current_url)) {
         $page_name = str_replace('/', ':', $current_url);
         $db = new PHPWS_DB('access_shortcuts');
         $db->addColumn('keyword');
         $db->addWhere('url', $page_name);
         $db->setLimit(1);
         $keyword = $db->select('one');
         if (!empty($keyword)) {
             PHPWS_Core::reroute($keyword);
             exit;
         }
     }
 }
예제 #7
0
 public static function pushUrlHistory()
 {
     if (!isset($_SESSION['PHPWS_UrlHistory'])) {
         $_SESSION['PHPWS_UrlHistory'] = array();
     }
     array_push($_SESSION['PHPWS_UrlHistory'], PHPWS_Core::getCurrentUrl());
 }
예제 #8
0
파일: Menu.php 프로젝트: HaldunA/phpwebsite
 public function atLink($url)
 {
     $compare = PHPWS_Core::getCurrentUrl();
     return $url == $compare;
 }
 public function loadLink()
 {
     $this->link = \PHPWS_Core::getCurrentUrl(true, false);
 }
예제 #10
0
 /**
  * Fixes plain anchors. Makes them relative to the current page.
  * If false, then anchors will not be relative to the url that called them.
  * Example: This is how an anchor is normally saved:
  * <a href="anchor">Anchor</a>
  * This would work fine IF the page was the home page. But once you get into
  * modules with mod_rewrites or index.php?something=1, then this same
  * anchor would not take you where you expect.
  */
 public function fixAnchors($text)
 {
     $home_http = PHPWS_Core::getCurrentUrl();
     return preg_replace('/href="#([\\w\\-]+)"/', sprintf('href="%s#\\1"', $home_http), $text);
 }
예제 #11
0
 /**
  * Displays the page layout and lets user enter text fields, blocks, etc.
  */
 public function pageLayout()
 {
     javascript('jquery');
     javascript('jquery_ui');
     javascript('ckeditor');
     Layout::addStyle('pagesmith', 'admin.css');
     Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'mod/pagesmith/javascript/pageedit/script.js"></script>', 'pageedit');
     Layout::addStyle('pagesmith');
     $page = $this->ps->page;
     $pg_tpl_name =& $page->_tpl->name;
     $this->ps->killSaved($page->id);
     if (!empty($page->_content)) {
         foreach ($page->_content as $key => $cnt) {
             if (!PageSmith::checkLorum($cnt)) {
                 $_SESSION['PS_Page'][$page->id][$key] = $cnt;
             }
         }
     }
     $form = new PHPWS_Form('pagesmith');
     $form->addHidden('module', 'pagesmith');
     $form->addHidden('aop', 'post_page');
     $form->addHidden('tpl', $page->template);
     $form->addHidden('pid', $page->parent_page);
     $template_list = $this->ps->getTemplateList();
     $form->addSelect('template_list', $template_list);
     $form->setMatch('template_list', $page->template);
     $form->addSubmit('change_tpl', dgettext('pagesmith', 'Change template'));
     if ($page->id) {
         $form->addHidden('id', $page->id);
     }
     if (empty($page->_tpl) || $page->_tpl->error) {
         $this->ps->content = dgettext('pagesmith', 'Unable to load page template.');
         return;
     }
     $form->addSubmit('submit', dgettext('pagesmith', 'Save page'));
     $form->setClass('submit', 'btn btn-success');
     $page->loadKey();
     if ($page->_key->id && $page->_key->show_after) {
         $publish_date = $page->_key->show_after;
     } else {
         $publish_date = time();
     }
     $this->pageTemplateForm($form);
     $tpl = $form->getTemplate();
     $tpl['PUBLISH_DATE_LABEL'] = 'Show page after this date and time';
     $tpl['PUBLISH_VALUE'] = strftime('%Y-%m-%dT%H:%M:%S', $publish_date);
     $tpl['PAGE_TITLE'] = $page->title;
     $jsvars['page_title_input'] = 'pagesmith_title';
     $jsvars['page_title_id'] = sprintf('%s-page-title', $pg_tpl_name);
     javascriptMod('pagesmith', 'pagetitle', $jsvars);
     $tpl['HIDE_CHECK'] = $page->hide_title ? 'checked="checked"' : null;
     if (!empty($page->_orphans)) {
         $tpl['ORPHAN_LINK'] = sprintf('<a href="%s#orphans">%s</a>', PHPWS_Core::getCurrentUrl(), dgettext('pagesmith', 'Orphans'));
         $tpl['ORPHANS'] = $this->listOrphans($page->_orphans);
     }
     // We wrap the textarea in a form just so ckeditor will allow use of the "Save" button.
     $modal = new \Modal('edit-section', '<form><textarea id="block-edit-textarea"></textarea></form>', dgettext('pagesmith', 'Edit text area'));
     $modal->addButton('<button id="save-page" class="btn btn-success">' . dgettext('pagesmith', 'Save') . '</button>');
     $modal->setWidthPercentage(90);
     $tpl['CONTENT_MODAL'] = $modal->__toString();
     $title_modal = new \Modal('edit-title', '<input class="form-control" type="text" id="page-title-input" name="page_title" value="" />', dgettext('pagesmith', 'Edit page title'));
     $title_modal->addButton('<button id="save-title" class="btn btn-success">' . dgettext('pagesmith', 'Save') . '</button>');
     $tpl['TITLE_MODAL'] = $title_modal->__toString();
     $this->ps->content = PHPWS_Template::process($tpl, 'pagesmith', 'page_form.tpl');
 }