本文整理汇总了PHP中TYPO3\CMS\Frontend\Page\PageRepository::init方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRepository::init方法的具体用法?PHP PageRepository::init怎么用?PHP PageRepository::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\Page\PageRepository
的用法示例。
在下文中一共展示了PageRepository::init方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
$this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
$this->pageRepo = new PageRepository();
$this->pageRepo->init(false);
}
示例2: __construct
/**
* Initializes the class.
*/
public function __construct()
{
$this->databaseConnection = $GLOBALS['TYPO3_DB'];
$this->tsfe = $GLOBALS['TSFE'];
// Warning! It is important to init the new object and not reuse any existing object
// $this->pageRepository->sys_language_uid must stay 0 because we will do overlays manually
$this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->pageRepository->init(FALSE);
}
示例3: __construct
/**
* Initializes the class.
*/
public function __construct()
{
$this->databaseConnection = $GLOBALS['TYPO3_DB'];
$this->tsfe = $GLOBALS['TSFE'];
$this->configuration = ConfigurationReader::getInstance();
$this->emptySegmentValue = $this->configuration->get('init/emptySegmentValue');
$this->rootPageId = (int) $this->configuration->get('pagePath/rootpage_id');
$this->utility = Utility::getInstance();
$this->cache = $this->utility->getCache();
$this->pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->pageRepository->init(FALSE);
}
示例4: init
/**
* Standard initialization
*
* @return void
*/
public function init()
{
parent::init();
$temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail');
if (!is_array($temp['properties'])) {
// init empty array
$temp['properties'] = array();
}
$this->params = $temp['properties'];
$this->implodedParams = DirectMailUtility::implodeTSParams($this->params);
if ($this->params['userTable'] && is_array($GLOBALS['TCA'][$this->params['userTable']])) {
$this->userTable = $this->params['userTable'];
$this->allowedTables[] = $this->userTable;
}
$this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode');
// initialize the page selector
$this->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->sys_page->init(true);
// initialize IconFactory
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
// initialize backend user language
if ($this->getLanguageService()->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->getLanguageService()->lang, 'static_languages') . BackendUtility::BEenableFields('sys_language') . BackendUtility::deleteClause('sys_language') . BackendUtility::deleteClause('static_languages'));
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->sys_language_uid = $row['uid'];
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
// load contextual help
$this->cshTable = '_MOD_' . $this->MCONF['name'];
if ($GLOBALS["BE_USER"]->uc['edit_showFieldHelp']) {
$this->getLanguageService()->loadSingleTableDescription($this->cshTable);
}
$this->updatePageTS();
}
示例5: createSysPageIfNecessary
/**
* Creates $this->sysPage if it does not exist yet
*
* @return void
*/
protected function createSysPageIfNecessary()
{
if (!is_object($this->sysPage)) {
$this->sysPage = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
}
}
示例6: init
/**
* first initialization of global variables
*
* @return void no return values: initialize global variables
*/
function init()
{
$this->MCONF = $GLOBALS['MCONF'];
parent::init();
// get TS Params
$temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail');
$this->params = $temp['properties'];
$this->implodedParams = BackendUtility::implodeTSParams($this->params);
$this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode');
// initialize the page selector
$this->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->sys_page->init(true);
// initialize backend user language
if ($GLOBALS["LANG"]->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) {
$res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS["TYPO3_DB"]->fullQuoteStr($GLOBALS["LANG"]->lang, 'static_languages') . BackendUtility::BEenableFields('sys_language') . BackendUtility::deleteClause('sys_language') . BackendUtility::deleteClause('static_languages'));
while ($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
$this->sys_language_uid = $row['uid'];
}
}
// load contextual help
$this->cshTable = '_MOD_' . $this->MCONF['name'];
if ($GLOBALS["BE_USER"]->uc['edit_showFieldHelp']) {
$GLOBALS["LANG"]->loadSingleTableDescription($this->cshTable);
}
}
示例7: createSysPageIfNecessary
/**
* 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());
}
}
示例8: enableFieldsDoesNotHideVersionedRecordsWhenCheckingVersionOverlays
/**
* @test
*/
public function enableFieldsDoesNotHideVersionedRecordsWhenCheckingVersionOverlays()
{
$table = $this->getUniqueId('aTable');
$GLOBALS['TCA'] = array($table => array('ctrl' => array('versioningWS' => 2)));
$this->pageSelectObject->versioningPreview = TRUE;
$this->pageSelectObject->init(FALSE);
$conditions = $this->pageSelectObject->enableFields($table, -1, array(), TRUE);
$this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.t3ver_state<=0')), 'No versioning placeholders');
$this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.pid<>-1')), 'No ecords from page -1');
}
示例9: fetch_the_id
/**
* 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
* @todo Define visibility
*/
public function fetch_the_id()
{
$GLOBALS['TT']->push('fetch_the_id initialize/', '');
// Initialize the page-select functions.
$this->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->sys_page->versioningPreview = $this->fePreview === 2 || intval($this->workspacePreview) || \TYPO3\CMS\Core\Utility\GeneralUtility::_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
$idParts = explode('.', $this->id, 2);
$this->id = $idParts[0];
if (isset($idParts[1])) {
$this->type = $idParts[1];
}
// Splitting $this->id by a comma (,).
// First part is 'id' and other parts are just stored for use in scripts.
// Still used in the old wapversion.lib files.
$this->idParts = explode(',', $this->id);
$this->id = $this->idParts[0];
// Hook for further id manipulation
if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'])) {
$_params = array('id' => $this->id);
$newId = FALSE;
foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['modifyPageId'] as $_funcRef) {
$deprecationMessage = 'Hook $TYPO3_CONF_VARS[SC_OPTIONS][tslib/class.tslib_fe.php][modifyPageId] is ' . 'deprecated since 6.0 and will be removed two versions later';
if (!is_object($_funcRef) || !is_a($_funcRef, 'Closure')) {
$deprecationMessage .= '- used by ' . $_funcRef;
}
\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog($deprecationMessage);
$newIdFromFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this);
if ($newIdFromFunc !== FALSE) {
$newId = $newIdFromFunc;
}
}
if ($newId !== FALSE) {
$this->id = $newId;
}
}
// 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/', '');
// The page_id of the current domain
$this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
if (!$this->id) {
if ($this->domainStartPage) {
// If the id was not previously set, set it to the id of the domain.
$this->id = $this->domainStartPage;
} else {
// Find the first 'visible' page in that domain
$theFirstPage = $this->sys_page->getFirstWebPage($this->id);
if ($theFirstPage) {
$this->id = $theFirstPage['uid'];
} else {
$message = 'No pages are found on the rootlevel!';
if ($this->checkPageUnavailableHandler()) {
$this->pageUnavailableAndExit($message);
} else {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1301648975);
}
}
}
}
$GLOBALS['TT']->pull();
$GLOBALS['TT']->push('fetch_the_id rootLine/', '');
// We store the originally requested id
$requestedId = $this->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]);
}
if ($this->page['url_scheme'] > 0) {
$newUrl = '';
$requestUrlScheme = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
if ((int) $this->page['url_scheme'] === \t3lib_utility_http::SCHEME_HTTP && $requestUrlScheme == 'https') {
$newUrl = 'http://' . substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8);
} elseif ((int) $this->page['url_scheme'] === \t3lib_utility_http::SCHEME_HTTPS && $requestUrlScheme == 'http') {
$newUrl = 'https://' . substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7);
}
//.........这里部分代码省略.........
示例10: fetch_the_id
/**
* 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
*
* @throws ServiceUnavailableException
* @return void
* @access private
*/
public function fetch_the_id()
{
$timeTracker = $this->getTimeTracker();
$timeTracker->push('fetch_the_id initialize/', '');
// Initialize the page-select functions.
$this->sys_page = GeneralUtility::makeInstance(PageRepository::class);
$this->sys_page->versioningPreview = $this->fePreview === 2 || (int) $this->workspacePreview || (bool) GeneralUtility::_GP('ADMCMD_view');
$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
$idParts = explode('.', $this->id, 2);
$this->id = $idParts[0];
if (isset($idParts[1])) {
$this->type = $idParts[1];
}
// 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 = (int) $this->id;
$this->type = (int) $this->type;
$timeTracker->pull();
// We find the first page belonging to the current domain
$timeTracker->push('fetch_the_id domain/', '');
// The page_id of the current domain
$this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
if (!$this->id) {
if ($this->domainStartPage) {
// If the id was not previously set, set it to the id of the domain.
$this->id = $this->domainStartPage;
} else {
// Find the first 'visible' page in that domain
$theFirstPage = $this->sys_page->getFirstWebPage($this->id);
if ($theFirstPage) {
$this->id = $theFirstPage['uid'];
} else {
$message = 'No pages are found on the rootlevel!';
if ($this->checkPageUnavailableHandler()) {
$this->pageUnavailableAndExit($message);
} else {
GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
throw new ServiceUnavailableException($message, 1301648975);
}
}
}
}
$timeTracker->pull();
$timeTracker->push('fetch_the_id rootLine/', '');
// We store the originally requested id
$this->requestedId = $this->id;
$this->getPageAndRootlineWithDomain($this->domainStartPage);
$timeTracker->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]);
}
if ($this->page['url_scheme'] > 0) {
$newUrl = '';
$requestUrlScheme = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
if ((int) $this->page['url_scheme'] === HttpUtility::SCHEME_HTTP && $requestUrlScheme == 'https') {
$newUrl = 'http://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8);
} elseif ((int) $this->page['url_scheme'] === HttpUtility::SCHEME_HTTPS && $requestUrlScheme == 'http') {
$newUrl = 'https://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7);
}
if ($newUrl !== '') {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$headerCode = HttpUtility::HTTP_STATUS_303;
} else {
$headerCode = HttpUtility::HTTP_STATUS_301;
}
HttpUtility::redirect($newUrl, $headerCode);
}
}
// Set no_cache if set
if ($this->page['no_cache']) {
$this->set_no_cache('no_cache is set in page properties');
}
// Init SYS_LASTCHANGED
$this->register['SYS_LASTCHANGED'] = (int) $this->page['tstamp'];
if ($this->register['SYS_LASTCHANGED'] < (int) $this->page['SYS_LASTCHANGED']) {
$this->register['SYS_LASTCHANGED'] = (int) $this->page['SYS_LASTCHANGED'];
}
if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) {
foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) {
$parameters = array('parentObject' => $this);
GeneralUtility::callUserFunction($functionReference, $parameters, $this);
}
//.........这里部分代码省略.........
示例11: purge
public function purge($simulate)
{
$this->output->info('Purge deleted');
$this->purgeDeleted('sys_file_reference', $simulate);
$this->db->exec_DELETEquery('sys_file_reference', 'tablenames = \'\' OR fieldname = \'\'');
$delete = new PreparedStatement('DELETE FROM sys_file_reference WHERE uid = ?', 'sys_file_reference');
$this->output->info('Purge references pointing to deleted records');
$res = $this->db->exec_SELECTquery('*', 'sys_file_reference', '');
$pageTools = new PageRepository();
$pageTools->init(FALSE);
while ($row = $this->db->sql_fetch_assoc($res)) {
$cnt = $this->db->exec_SELECTcountRows('uid', $row['tablenames'], 'uid = ' . $row['uid_foreign'] . $pageTools->enableFields($row['tablenames']));
if (!$cnt) {
if ($simulate) {
$this->output->info('Would delete reference ' . $row['uid']);
} else {
$delete->execute(array($row['uid']));
$this->output->info('Deleted reference ' . $row['uid']);
}
}
}
$delete->free();
$this->output->info('Purge sys_file records with no references');
$delete = new PreparedStatement('DELETE FROM sys_file WHERE uid = ?', 'sys_file');
$res = $this->db->exec_SELECTquery('uid', 'sys_file', 'uid NOT IN (select uid_local from sys_file_reference group by uid_local)');
while ($row = $this->db->sql_fetch_assoc($res)) {
if ($simulate) {
$this->output->info('Would delete file record %s', array($row['uid']));
} else {
$delete->execute(array($row['uid']));
$this->output->info('Deleted file record <b>%s</b>', array($row['uid']));
}
}
$this->output->info('Purge actual files with no record');
$prefixRegex = '/^' . preg_quote(PATH_site, '/') . '(fileadmin|uploads)/';
$files = new \RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PATH_site, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::UNIX_PATHS), RecursiveIteratorIterator::LEAVES_ONLY | RecursiveIteratorIterator::CHILD_FIRST), $prefixRegex);
$exists = new PreparedStatement('SELECT uid FROM sys_file WHERE identifier = ?', 'sys_file');
$fileSize = 0;
foreach ($files as $file) {
$filename = (string) $file;
if (!is_file($filename)) {
continue;
}
$fileId = preg_replace($prefixRegex, '', $filename);
$exists->execute(array($fileId));
$result = $exists->fetchAll();
if (empty($result[0]['uid'])) {
$fileSize += filesize($filename);
if ($simulate) {
$this->output->info('<i>Would delete file %s</i>', array($filename));
} else {
unlink($filename);
$this->output->info('Delete file %s', array($filename));
}
}
}
$size = GeneralUtility::formatSize($fileSize);
if ($simulate) {
$this->output->info('Would delete %s of files', array($size));
$this->output->info('Would truncate table sys_file_processedfile');
} else {
$this->output->info('Deleted %s of files', array($size));
$this->db->exec_TRUNCATEquery('sys_file_processedfile');
$this->output->info('Truncated table sys_file_processedfile');
}
}
示例12: initializeObject
/**
* Initialize object
*/
public function initializeObject()
{
$this->pageRepository->init(false);
$this->pageRepository->sys_language_uid = $this->getSystemLanguage();
}