Ejemplo n.º 1
0
 /**
  * Creates $this->sysPage if it does not exist yet
  *
  * @return void
  */
 protected function createSysPageIfNecessary()
 {
     if (!is_object($this->sysPage)) {
         $this->sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
         $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
     }
 }
 /**
  * Creates $this->sysPage if it does not exist yet
  *
  * @return void
  */
 protected function createSysPageIfNecessary()
 {
     if (!is_object($this->sysPage)) {
         $this->sysPage = $this->apiWrapper->getPageRepository();
         $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
     }
 }
Ejemplo n.º 3
0
 /**
  * Initialize object
  * @return void
  */
 public function initializeObject()
 {
     if (is_array($GLOBALS['TSFE']->fe_user->user) === TRUE) {
         $groups = array(-2, 0);
         $groups = array_merge($groups, (array) array_values($GLOBALS['TSFE']->fe_user->groupData['uid']));
     } else {
         $groups = array(-1, 0);
     }
     $this->pageSelect = new t3lib_pageSelect();
     $this->pageSelect->init((bool) $this->arguments['showHidden']);
     $clauses = array();
     foreach ($groups as $group) {
         $clause = "fe_group = '" . $group . "' OR fe_group LIKE '" . $group . ",%' OR fe_group LIKE '%," . $group . "' OR fe_group LIKE '%," . $group . ",%'";
         array_push($clauses, $clause);
     }
     array_push($clauses, "fe_group = '' OR fe_group = '0'");
     $this->pageSelect->where_groupAccess = ' AND (' . implode(' OR ', $clauses) . ')';
 }
	/**
	 * Fetch the page path (in the correct language)
	 * Return it in an array like:
	 *   array(
	 *     'pagepath' => 'product_omschrijving/another_page_title/',
	 *     'langID' => '2',
	 *   );
	 *
	 * @param	integer		Page ID
	 * @param	string		MP variable string
	 * @param	integer		Language id
	 * @return	array		The page path etc.
	 */
	function IDtoPagePathSegments($id, $mpvar, $langID) {
		// Check to see if we already built this one in this session
		$cacheKey = $id . '.' . $mpvar . '.' . $langID;
		if (!isset($this->IDtoPagePathCache[$cacheKey])) {

			// Get rootLine for current site (overlaid with any language overlay records).
			if (!is_object($this->sys_page)) { // Create object if not found before:
				// Initialize the page-select functions.
				$this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
				$this->sys_page->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
			}
			$this->sys_page->sys_language_uid = $langID;
			$rootLine = $this->sys_page->getRootLine($id, $mpvar);
			$cc = count($rootLine);
			$newRootLine = array();
			$rootFound = FALSE;
			if (!$GLOBALS['TSFE']->tmpl->rootLine) {
				$GLOBALS['TSFE']->tmpl->start($GLOBALS['TSFE']->rootLine);
			}
			// Pass #1 -- check if linking a page in subdomain inside main domain
			$innerSubDomain = false;
			for ($a = $cc - 1; $a >= 0; $a--) {
				if ($rootLine[$a]['is_siteroot']) {
					if ($this->pObj->enableDevLog) {
						t3lib_div::devLog('Found siteroot in the rootline for id=' . $id, 'realurl', 0);
					}
					$rootFound = true;
					$innerSubDomain = true;
					for ( ; $a < $cc; $a++) {
						$newRootLine[] = $rootLine[$a];
					}
					break;
				}
			}
			if (!$rootFound) {
				// Pass #2 -- check normal page
				if ($this->pObj->enableDevLog) {
					t3lib_div::devLog('Starting to walk rootline for id=' . $id . ' from index=' . $a, 'realurl', 0, $rootLine);
				}
				for ($a = 0; $a < $cc; $a++) {
					if ($GLOBALS['TSFE']->tmpl->rootLine[0]['uid'] == $rootLine[$a]['uid']) {
						if ($this->pObj->enableDevLog) {
							t3lib_div::devLog('Found rootline', 'realurl', 0, array('uid' => $id, 'rootline start pid' => $rootLine[$a]['uid']));
						}
						$rootFound = true;
						for ( ; $a < $cc; $a++) {
							$newRootLine[] = $rootLine[$a];
						}
						break;
					}
				}
			}
			if ($rootFound) {
				// Translate the rootline to a valid path (rootline contains localized titles at this point!):
				$pagepath = $this->rootLineToPath($newRootLine, $langID);
				if ($this->pObj->enableDevLog) {
					t3lib_div::devLog('Got page path', 'realurl', 0, array('uid' => $id, 'pagepath' => $pagepath));
				}
				$rootpage_id = $this->conf['rootpage_id'];
				if ($innerSubDomain) {
					$parts = parse_url($pagepath);
					if ($this->pObj->enableDevLog) {
						t3lib_div::devLog('$innerSubDomain=true, showing page path parts', 'realurl', 0, $parts);
					}
					if ($parts['host'] == '') {
						$domain = '';
						foreach ($newRootLine as $rl) {
							$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName', 'sys_domain', 'pid=' . $rl['uid'] . ' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
							if (count($rows)) {
								$domain = $rows[0]['domainName'];
								if ($this->pObj->enableDevLog) {
									t3lib_div::devLog('Found domain', 'realurl', 0, $domain);
								}
								$rootpage_id = $rl['uid'];
							}
						}
					}
				}
				$this->IDtoPagePathCache[$cacheKey] = array(
						'pagepath' => $pagepath,
						'langID' => $langID,
						'rootpage_id' => $rootpage_id,
					);
			}
			else { // Outside of root line:
				$this->IDtoPagePathCache[$cacheKey] = false;
			}
		}

		return $this->IDtoPagePathCache[$cacheKey];
	}
 /**
  * Get The Page ID
  * This gets the id of the page, checks if the page is in the domain and if the page is accessible
  * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage, $this->idParts
  *
  * @return	void
  * @access private
  */
 function fetch_the_id()
 {
     $GLOBALS['TT']->push('fetch_the_id initialize/', '');
     // Initialize the page-select functions.
     $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
     $this->sys_page->versioningPreview = $this->fePreview === 2 || intval($this->workspacePreview) || t3lib_div::_GP('ADMCMD_view') ? TRUE : FALSE;
     $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
     $this->sys_page->init($this->showHiddenPage);
     // Set the valid usergroups for FE
     $this->initUserGroups();
     // Sets sys_page where-clause
     $this->setSysPageWhereClause();
     // Splitting $this->id by a period (.). First part is 'id' and second part - if exists - will overrule the &type param if given
     $pParts = explode('.', $this->id);
     $this->id = $pParts[0];
     // Set it.
     if (isset($pParts[1])) {
         $this->type = $pParts[1];
     }
     // Splitting $this->id by a comma (,). First part is 'id' and other parts are just stored for use in scripts.
     $this->idParts = explode(',', $this->id);
     // Splitting by a '+' sign - used for base64/md5 methods of parameter encryption for simulate static documents.
     list($pgID, $SSD_p) = explode('+', $this->idParts[0], 2);
     if ($SSD_p) {
         $this->idPartsAnalyze($SSD_p);
     }
     $this->id = $pgID;
     // Set id
     // If $this->id is a string, it's an alias
     $this->checkAndSetAlias();
     // The id and type is set to the integer-value - just to be sure...
     $this->id = intval($this->id);
     $this->type = intval($this->type);
     $GLOBALS['TT']->pull();
     // We find the first page belonging to the current domain
     $GLOBALS['TT']->push('fetch_the_id domain/', '');
     $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
     // the page_id of the current domain
     if (!$this->id) {
         if ($this->domainStartPage) {
             $this->id = $this->domainStartPage;
             // If the id was not previously set, set it to the id of the domain.
         } else {
             $theFirstPage = $this->sys_page->getFirstWebPage($this->id);
             // Find the first 'visible' page in that domain
             if ($theFirstPage) {
                 $this->id = $theFirstPage['uid'];
             } else {
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit('No pages are found on the rootlevel!');
                 } else {
                     $message = 'No pages are found on the rootlevel!';
                     t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
                     header('HTTP/1.0 503 Service Temporarily Unavailable');
                     $this->printError($message);
                     exit;
                 }
             }
         }
     }
     $GLOBALS['TT']->pull();
     $GLOBALS['TT']->push('fetch_the_id rootLine/', '');
     $requestedId = $this->id;
     // We store the originally requested id
     $this->getPageAndRootlineWithDomain($this->domainStartPage);
     $GLOBALS['TT']->pull();
     if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
         $pNotFoundMsg = array(1 => 'ID was not an accessible page', 2 => 'Subsection was found and not accessible', 3 => 'ID was outside the domain', 4 => 'The requested page alias does not exist');
         $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
     }
     // set no_cache if set
     if ($this->page['no_cache']) {
         $this->set_no_cache();
     }
     // Init SYS_LASTCHANGED
     $this->register['SYS_LASTCHANGED'] = intval($this->page['tstamp']);
     if ($this->register['SYS_LASTCHANGED'] < intval($this->page['SYS_LASTCHANGED'])) {
         $this->register['SYS_LASTCHANGED'] = intval($this->page['SYS_LASTCHANGED']);
     }
 }