PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/kernel/setup/steps/ezstep_installer.php

http://github.com/ezsystems/ezpublish
PHP | 742 lines | 514 code | 73 blank | 155 comment | 67 complexity | f5ed7c76f9a63e71bd672a9b6b01e456 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * File containing the eZStepInstaller class.
  4. *
  5. * @copyright Copyright (C) eZ Systems AS. All rights reserved.
  6. * @license For full copyright and license information view LICENSE file distributed with this source code.
  7. * @version //autogentag//
  8. * @package kernel
  9. */
  10. /*!
  11. \class eZStepInstaller ezstep_class_definition.ph
  12. \brief The class EZStepInstaller provide a framework for eZStep installer classes
  13. */
  14. class eZStepInstaller
  15. {
  16. const DB_ERROR_EMPTY_PASSWORD = 1;
  17. const DB_ERROR_NONMATCH_PASSWORD = 2;
  18. const DB_ERROR_CONNECTION_FAILED = 3;
  19. const DB_ERROR_NOT_EMPTY = 4;
  20. const DB_ERROR_NO_DATABASES = 5;
  21. const DB_ERROR_NO_DIGEST_PROC = 6;
  22. const DB_ERROR_VERSION_INVALID = 7;
  23. const DB_ERROR_CHARSET_DIFFERS = 8;
  24. const DB_ERROR_ALREADY_CHOSEN = 10;
  25. const DB_DATA_APPEND = 1;
  26. const DB_DATA_REMOVE = 2;
  27. const DB_DATA_KEEP = 3;
  28. const DB_DATA_CHOOSE = 4;
  29. /**
  30. * Default constructor for eZ Publish installer classes
  31. *
  32. * @param \eZTemplate $tpl
  33. * @param \eZHTTPTool $http
  34. * @param \eZINI $ini
  35. * @param array $persistenceList
  36. * @param string $identifier
  37. * @param string $name
  38. */
  39. public function __construct( eZTemplate $tpl, eZHTTPTool $http, eZINI $ini, array &$persistenceList,
  40. $identifier, $name )
  41. {
  42. $this->Tpl = $tpl;
  43. $this->Http = $http;
  44. $this->Ini = $ini;
  45. $this->PersistenceList =& $persistenceList;
  46. $this->Identifier = $identifier;
  47. $this->Name = $name;
  48. $this->INI = eZINI::instance( 'kickstart.ini', '.' );
  49. $this->KickstartData = false;
  50. $this->PersistenceList['use_kickstart'][$identifier] = true;
  51. // If we have read data for this step earlier we do not use kickstart
  52. if ( isset( $this->PersistenceList['kickstart'][$identifier] ) and
  53. $this->PersistenceList['kickstart'][$identifier] )
  54. {
  55. $this->PersistenceList['use_kickstart'][$identifier] = false;
  56. }
  57. if ( $this->INI->hasGroup( $this->Identifier ) )
  58. {
  59. $this->KickstartData = $this->INI->group( $this->Identifier );
  60. $this->PersistenceList['kickstart'][$identifier] = true;
  61. }
  62. }
  63. /**
  64. * Processespost data from this class.
  65. *
  66. * Abstract (virtual) method for step classes to use.
  67. *
  68. * @return bool True if post data accepted, or false if post data is rejected.
  69. */
  70. function processPostData()
  71. {
  72. }
  73. /*!
  74. \virtual
  75. Performs test needed by this class.
  76. This class may access class variables to store data needed for viewing if output failed
  77. \return true if all tests passed and continue with next default step,
  78. number of next step if all tests passed and next step is "hard coded",
  79. false if tests failed
  80. */
  81. function init()
  82. {
  83. }
  84. /**
  85. * Virtual (abstract)
  86. *
  87. * Display information and forms needed to pass this step.
  88. * return result to use in template.
  89. *
  90. * @return array
  91. */
  92. function display()
  93. {
  94. $result = array();
  95. return $result;
  96. }
  97. /**
  98. * @param \eZLocale $primaryLanguage
  99. * @param \eZLocale[]|null $allLanguages
  100. * @param bool $canUseUnicode
  101. * @return bool|string
  102. */
  103. function findAppropriateCharset( $primaryLanguage, $allLanguages, $canUseUnicode )
  104. {
  105. $commonCharsets = array();
  106. if ( is_array( $allLanguages ) and count( $allLanguages ) > 0 )
  107. {
  108. $language = $allLanguages[ 0 ];
  109. $charsets = $language->allowedCharsets();
  110. foreach ( $charsets as $charset )
  111. {
  112. $commonCharsets[] = eZCharsetInfo::realCharsetCode( $charset );
  113. }
  114. $commonCharsets = array_unique( $commonCharsets );
  115. for ( $i = 1; $i < count( $allLanguages ); ++$i )
  116. {
  117. $language = $allLanguages[$i];
  118. $charsets = $language->allowedCharsets();
  119. $realCharsets = array();
  120. foreach ( $charsets as $charset )
  121. {
  122. $realCharsets[] = eZCharsetInfo::realCharsetCode( $charset );
  123. }
  124. $realCharsets = array_unique( $realCharsets );
  125. $commonCharsets = array_intersect( $commonCharsets, $realCharsets );
  126. }
  127. }
  128. $usableCharsets = array_values( $commonCharsets );
  129. $charset = false;
  130. if ( count( $usableCharsets ) > 0 )
  131. {
  132. if ( in_array( eZCharsetInfo::realCharsetCode( $primaryLanguage->charset() ), $usableCharsets ) )
  133. $charset = eZCharsetInfo::realCharsetCode( $primaryLanguage->charset() );
  134. else // Pick the first charset
  135. $charset = $usableCharsets[0];
  136. }
  137. else
  138. {
  139. if ( $canUseUnicode )
  140. {
  141. $charset = eZCharsetInfo::realCharsetCode( 'utf-8' );
  142. }
  143. // else
  144. // {
  145. // // Pick preferred primary language
  146. // $charset = $primaryLanguage->charset();
  147. // }
  148. }
  149. return $charset;
  150. }
  151. /**
  152. * @param \eZLocale $primaryLanguage
  153. * @param \eZLocale[]|null $allLanguages
  154. * @param bool $canUseUnicode
  155. * @return array
  156. */
  157. function findAppropriateCharsetsList( $primaryLanguage, $allLanguages, $canUseUnicode )
  158. {
  159. $commonCharsets = array();
  160. if ( is_array( $allLanguages ) and count( $allLanguages ) > 0 )
  161. {
  162. $language = $allLanguages[ 0 ];
  163. $charsets = $language->allowedCharsets();
  164. foreach ( $charsets as $charset )
  165. {
  166. $commonCharsets[] = eZCharsetInfo::realCharsetCode( $charset );
  167. }
  168. $commonCharsets = array_unique( $commonCharsets );
  169. for ( $i = 1; $i < count( $allLanguages ); ++$i )
  170. {
  171. $language = $allLanguages[$i];
  172. $charsets = $language->allowedCharsets();
  173. $realCharsets = array();
  174. foreach ( $charsets as $charset )
  175. {
  176. $realCharsets[] = eZCharsetInfo::realCharsetCode( $charset );
  177. }
  178. $realCharsets = array_unique( $realCharsets );
  179. $commonCharsets = array_intersect( $commonCharsets, $realCharsets );
  180. }
  181. }
  182. $usableCharsets = array_values( $commonCharsets );
  183. if ( count( $usableCharsets ) > 0 )
  184. {
  185. if ( in_array( $primaryLanguage->charset(), $usableCharsets ) )
  186. {
  187. array_unshift( $usableCharsets, $primaryLanguage->charset() );
  188. $usableCharsets = array_unique( $usableCharsets );
  189. }
  190. }
  191. else
  192. {
  193. if ( $canUseUnicode )
  194. {
  195. $usableCharsets[] = eZCharsetInfo::realCharsetCode( 'utf-8' );
  196. }
  197. }
  198. return $usableCharsets;
  199. }
  200. /**
  201. * @return array
  202. */
  203. function availableSitePackages()
  204. {
  205. $packageList = eZPackage::fetchPackages( array(), array( 'type' => 'site' ) );
  206. return $packageList;
  207. }
  208. /**
  209. * @return array
  210. */
  211. function extraDataList()
  212. {
  213. return array( 'title', 'url', 'database',
  214. 'access_type', 'access_type_value', 'admin_access_type_value',
  215. 'existing_database' );
  216. }
  217. /**
  218. * @return bool
  219. */
  220. function chosenSitePackage()
  221. {
  222. if ( isset( $this->PersistenceList['chosen_site_package']['0'] ) )
  223. {
  224. return $this->PersistenceList['chosen_site_package']['0'];
  225. }
  226. else
  227. return false;
  228. }
  229. /**
  230. * @return array
  231. */
  232. function chosenSiteType()
  233. {
  234. if ( isset( $this->PersistenceList['chosen_site_package']['0'] ) )
  235. {
  236. $siteTypeIdentifier = $this->PersistenceList['chosen_site_package']['0'];
  237. $chosenSiteType['identifier'] = $siteTypeIdentifier;
  238. $extraList = $this->extraDataList();
  239. foreach ( $extraList as $extraItem )
  240. {
  241. if ( isset( $this->PersistenceList['site_extra_data_' . $extraItem][$siteTypeIdentifier] ) )
  242. {
  243. $chosenSiteType[$extraItem] = $this->PersistenceList['site_extra_data_' . $extraItem][$siteTypeIdentifier];
  244. }
  245. }
  246. }
  247. return $chosenSiteType;
  248. }
  249. /**
  250. * @param string $sitePackageName
  251. * @return bool
  252. */
  253. function selectSiteType( $sitePackageName )
  254. {
  255. $package = eZPackage::fetch( $sitePackageName );
  256. if ( !$package )
  257. return false;
  258. $this->PersistenceList['chosen_site_package']['0'] = $sitePackageName;
  259. $this->PersistenceList['site_extra_data_title'][$sitePackageName] = $package->attribute('summary');
  260. return true;
  261. }
  262. /**
  263. * @param array $siteType
  264. */
  265. function storeSiteType( $siteType )
  266. {
  267. $extraList = $this->extraDataList();
  268. $siteIdentifier = $siteType['identifier'];
  269. foreach ( $extraList as $extraItem )
  270. {
  271. if ( isset( $siteType[$extraItem] ) )
  272. {
  273. $this->PersistenceList['site_extra_data_' . $extraItem][$siteIdentifier] = $siteType[$extraItem];
  274. }
  275. }
  276. $this->PersistenceList['chosen_site_package']['0'] = $siteIdentifier;
  277. if ( $this->hasKickstartData() )
  278. $this->storePersistenceData();
  279. }
  280. /**
  281. *
  282. */
  283. function storePersistenceData()
  284. {
  285. foreach ( $this->PersistenceList as $key => $value )
  286. {
  287. eZSetupSetPersistencePostVariable( $key, $value );
  288. }
  289. }
  290. function storeExtraSiteData( $siteIdentifier, $dataIdentifier, $value )
  291. {
  292. if ( !isset( $this->PersistenceList['site_extra_data_' . $dataIdentifier] ) )
  293. $this->PersistenceList['site_extra_data_' . $dataIdentifier] = array();
  294. $this->PersistenceList['site_extra_data_' . $dataIdentifier][$siteIdentifier] = $value;
  295. }
  296. /**
  297. * @param string $dataIdentifier
  298. * @return bool
  299. */
  300. function extraData( $dataIdentifier )
  301. {
  302. if ( isset( $this->PersistenceList['site_extra_data_' . $dataIdentifier] ) )
  303. return $this->PersistenceList['site_extra_data_' . $dataIdentifier];
  304. return false;
  305. }
  306. /**
  307. * @param string $siteIdentifier
  308. * @param string $dataIdentifier
  309. * @return bool
  310. */
  311. function extraSiteData( $siteIdentifier, $dataIdentifier )
  312. {
  313. if ( isset( $this->PersistenceList['site_extra_data_' . $dataIdentifier][$siteIdentifier] ) )
  314. return $this->PersistenceList['site_extra_data_' . $dataIdentifier][$siteIdentifier];
  315. return false;
  316. }
  317. /**
  318. * @param string|bool $dbCharset Default charset used if false
  319. * @param array $overrideDBParameters
  320. * @return array
  321. */
  322. function checkDatabaseRequirements( $dbCharset = false, $overrideDBParameters = array() )
  323. {
  324. $result = array( 'error_code' => false,
  325. 'use_unicode' => false,
  326. 'db_version' => false,
  327. 'db_require_version' => false,
  328. 'site_charset' => false,
  329. 'status' => false );
  330. $databaseMap = eZSetupDatabaseMap();
  331. $databaseInfo = $this->PersistenceList['database_info'];
  332. $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
  333. $dbDriver = $databaseInfo['info']['driver'];
  334. if ( $dbCharset === false )
  335. $dbCharset = 'iso-8859-1';
  336. $dbParameters = array( 'server' => $databaseInfo['server'],
  337. 'port' => $databaseInfo['port'],
  338. 'user' => $databaseInfo['user'],
  339. 'password' => $databaseInfo['password'],
  340. 'socket' => trim( $databaseInfo['socket'] ) == '' ? false : $databaseInfo['socket'],
  341. 'database' => $databaseInfo['database'],
  342. 'charset' => $dbCharset );
  343. $dbParameters = array_merge( $dbParameters, $overrideDBParameters );
  344. // PostgreSQL requires us to specify database name.
  345. // We use template1 here since it exists on all PostgreSQL installations.
  346. if( $dbParameters['database'] == '' and $this->PersistenceList['database_info']['type'] == 'pgsql' )
  347. $dbParameters['database'] = 'template1';
  348. try
  349. {
  350. $db = eZDB::instance( $dbDriver, $dbParameters, true );
  351. $result['db_instance'] = $db;
  352. $result['connected'] = $db->isConnected();
  353. }
  354. catch( eZDBNoConnectionException $e )
  355. {
  356. $result['error_code'] = self::DB_ERROR_CONNECTION_FAILED;
  357. return $result;
  358. }
  359. // Check if the version of the database fits the minimum required
  360. $dbVersion = $db->databaseServerVersion();
  361. $result['db_version'] = $dbVersion['string'];
  362. $result['db_required_version'] = $databaseInfo['info']['required_version'];
  363. if ( $dbVersion != null )
  364. {
  365. if ( version_compare( $result['db_version'], $databaseInfo['info']['required_version'] ) == -1 )
  366. {
  367. $result['connected'] = false;
  368. $result['error_code'] = self::DB_ERROR_VERSION_INVALID;
  369. return $result;
  370. }
  371. }
  372. // If we have PostgreSQL we need to make sure we have the 'digest' procedure available.
  373. if ( $db->databaseName() == 'postgresql' and $dbParameters['database'] != 'template1' )
  374. {
  375. $sql = "SELECT count(*) AS count FROM pg_proc WHERE proname='digest'";
  376. $rows = $db->arrayQuery( $sql );
  377. $count = $rows[0]['count'];
  378. // If it is 0 we don't have it
  379. if ( $count == 0 )
  380. {
  381. $result['error_code'] = self::DB_ERROR_NO_DIGEST_PROC;
  382. return $result;
  383. }
  384. }
  385. $result['use_unicode'] = false;
  386. if ( $db->isCharsetSupported( 'utf-8' ) )
  387. {
  388. $result['use_unicode'] = true;
  389. }
  390. // If we regional info we can start checking the charset
  391. if ( isset( $this->PersistenceList['regional_info'] ) )
  392. {
  393. if ( isset( $this->PersistenceList['regional_info']['site_charset'] ) and
  394. strlen( $this->PersistenceList['regional_info']['site_charset'] ) > 0 )
  395. {
  396. $charsetsList = array( $this->PersistenceList['regional_info']['site_charset'] );
  397. }
  398. else
  399. {
  400. // Figure out charset automatically if it is not set yet
  401. $primaryLanguage = null;
  402. $allLanguages = array();
  403. $allLanguageCodes = array();
  404. $variationsLanguages = array();
  405. $primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
  406. $extraLanguageCodes = isset( $this->PersistenceList['regional_info']['languages'] ) ? $this->PersistenceList['regional_info']['languages'] : array();
  407. $extraLanguageCodes = array_diff( $extraLanguageCodes, array( $primaryLanguageCode ) );
  408. /*
  409. if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
  410. {
  411. $variations = $this->PersistenceList['regional_info']['variations'];
  412. foreach ( $variations as $variation )
  413. {
  414. $locale = eZLocale::create( $variation );
  415. if ( $locale->localeCode() == $primaryLanguageCode )
  416. {
  417. $primaryLanguage = $locale;
  418. }
  419. else
  420. {
  421. $variationsLanguages[] = $locale;
  422. }
  423. }
  424. }
  425. */
  426. if ( $primaryLanguage === null )
  427. $primaryLanguage = eZLocale::create( $primaryLanguageCode );
  428. $allLanguages[] = $primaryLanguage;
  429. foreach ( $extraLanguageCodes as $extraLanguageCode )
  430. {
  431. $allLanguages[] = eZLocale::create( $extraLanguageCode );
  432. $allLanguageCodes[] = $extraLanguageCode;
  433. }
  434. $charsetsList = $this->findAppropriateCharsetsList( $primaryLanguage, $allLanguages, $result['use_unicode'] );
  435. }
  436. $checkedCharset = $db->checkCharset( $charsetsList, $currentCharset );
  437. if ( $checkedCharset === false )
  438. {
  439. // If the current charset is utf-8 or utf8mb4 we use that instead
  440. // since they can represent any character possible in the chosen languages
  441. if ( in_array( $currentCharset, array( 'utf-8', 'utf8mb4' ) ) )
  442. {
  443. $result['site_charset'] = 'utf-8';
  444. }
  445. else
  446. {
  447. $result['connected'] = false;
  448. $this->PersistenceList['database_info']['requested_charset'] = implode( ", ", $charsetsList );
  449. $this->PersistenceList['database_info']['current_charset'] = $currentCharset;
  450. $result['error_code'] = self::DB_ERROR_CHARSET_DIFFERS;
  451. return $result;
  452. }
  453. }
  454. else if ( $checkedCharset === true )
  455. {
  456. $result['site_charset'] = $charsetsList[ 0 ];
  457. }
  458. else
  459. {
  460. $result['site_charset'] = $checkedCharset;
  461. }
  462. }
  463. $result['status'] = true;
  464. return $result;
  465. }
  466. /**
  467. * @param array $errorInfo
  468. * @return array|bool
  469. */
  470. function databaseErrorInfo( $errorInfo )
  471. {
  472. $code = $errorInfo['error_code'];
  473. $dbError = false;
  474. switch ( $code )
  475. {
  476. case self::DB_ERROR_CONNECTION_FAILED:
  477. {
  478. if ( $errorInfo['database_info']['type'] == 'pgsql' )
  479. {
  480. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  481. 'Please make sure that the username and the password is correct. Verify that your PostgreSQL database is configured correctly.'
  482. .'<br>See the PHP documentation for more information about this.'
  483. .'<br>Remember to start postmaster with the -i option.'
  484. .'<br>Note that PostgreSQL 7.2 is not supported.' ),
  485. 'url' => array( 'href' => 'http://www.php.net/manual/en/ref.pgsql.php',
  486. 'text' => 'PHP documentation' ),
  487. 'number' => self::DB_ERROR_CONNECTION_FAILED );
  488. }
  489. else
  490. {
  491. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  492. 'The database would not accept the connection, please review your settings and try again.' ),
  493. 'url' => false,
  494. 'number' => self::DB_ERROR_CONNECTION_FAILED );
  495. }
  496. break;
  497. }
  498. case self::DB_ERROR_NONMATCH_PASSWORD:
  499. {
  500. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  501. 'Password entries did not match.' ),
  502. 'url' => false,
  503. 'number' => self::DB_ERROR_NONMATCH_PASSWORD );
  504. break;
  505. }
  506. case self::DB_ERROR_NOT_EMPTY:
  507. {
  508. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  509. 'The selected database was not empty, please choose from the alternatives below.' ),
  510. 'url' => false,
  511. 'number' => self::DB_ERROR_NOT_EMPTY );
  512. $dbNotEmpty = 1;
  513. break;
  514. }
  515. case self::DB_ERROR_NO_DATABASES:
  516. {
  517. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  518. 'The selected user has not got access to any databases. Change user or create a database for the user.' ),
  519. 'url' => false,
  520. 'number' => self::DB_ERROR_NO_DATABASES );
  521. break;
  522. }
  523. case self::DB_ERROR_NO_DIGEST_PROC:
  524. {
  525. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  526. "The 'digest' function is not available in your database, you cannot run eZ Publish without this. See the documentation for more information." ),
  527. 'url' => array( 'href' => 'http://ez.no/doc/ez_publish/technical_manual/current/installation/normal_installation/requirements_for_doing_a_normal_installation#digest_function',
  528. 'text' => 'PostgreSQL digest FAQ' ),
  529. 'number' => self::DB_ERROR_NO_DATABASES );
  530. break;
  531. }
  532. case self::DB_ERROR_VERSION_INVALID:
  533. {
  534. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  535. "Your database version %version does not fit the minimum requirement which is %req_version.
  536. See the requirements page for more information.",
  537. null,
  538. array( '%version' => $errorInfo['database_info']['version'],
  539. '%req_version' => $errorInfo['database_info']['required_version'] ) ),
  540. 'url' => array( 'href' => 'http://ez.no/ez_publish/documentation/general_information/what_is_ez_publish/ez_publish_requirements',
  541. 'text' => 'eZ Publish requirements' ),
  542. 'number' => self::DB_ERROR_NO_DATABASES );
  543. break;
  544. }
  545. case self::DB_ERROR_CHARSET_DIFFERS:
  546. {
  547. $dbError = array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
  548. "The database [%database_name] cannot be used, the setup wizard wants to create the site in [%req_charset] but the database has been created using character set [%charset]. You will have to choose a database having support for [%req_charset] or modify [%database_name] .",
  549. null,
  550. array( '%database_name' => $errorInfo['site_type']['database'],
  551. '%charset' => $errorInfo['database_info']['current_charset'],
  552. '%req_charset' => $errorInfo['database_info']['requested_charset'] ) ),
  553. 'url' => false,
  554. 'number' => self::DB_ERROR_CHARSET_DIFFERS );
  555. break;
  556. }
  557. }
  558. return $dbError;
  559. }
  560. /**
  561. * @return bool True if the step has kickstart data available.
  562. */
  563. function hasKickstartData()
  564. {
  565. if ( !$this->isKickstartAllowed() )
  566. return false;
  567. return $this->KickstartData !== false;
  568. }
  569. /**
  570. * @return array|bool All kickstart data as an associative array or false if no data available
  571. */
  572. function kickstartData()
  573. {
  574. return $this->KickstartData;
  575. }
  576. /**
  577. * @return bool True if kickstart functionality can be used.
  578. */
  579. function isKickstartAllowed()
  580. {
  581. $identifier = $this->Identifier;
  582. if ( isset( $this->PersistenceList['use_kickstart'][$identifier] ) and
  583. !$this->PersistenceList['use_kickstart'][$identifier] )
  584. return false;
  585. if ( isset( $GLOBALS['eZStepAllowKickstart'] ) )
  586. return $GLOBALS['eZStepAllowKickstart'];
  587. return true;
  588. }
  589. /**
  590. * @return bool True if the kickstart functionality should continue to the next step.
  591. */
  592. function kickstartContinueNextStep()
  593. {
  594. if ( isset( $this->KickstartData['Continue'] ) and
  595. $this->KickstartData['Continue'] == 'true' )
  596. return true;
  597. return false;
  598. }
  599. /*!
  600. Sets whether kickstart data can be checked or not.
  601. */
  602. function setAllowKickstart( $allow )
  603. {
  604. $GLOBALS['eZStepAllowKickstart'] = $allow;
  605. }
  606. /**
  607. * @return array Urls to access user and admin siteaccesses
  608. */
  609. function siteaccessURLs()
  610. {
  611. $siteType = $this->chosenSiteType();
  612. $url = $siteType['url'];
  613. if ( !preg_match( "#^[a-zA-Z0-9]+://(.*)$#", $url ) )
  614. {
  615. $url = 'http://' . $url;
  616. }
  617. $currentURL = $url;
  618. $adminURL = $url;
  619. if ( $siteType['access_type'] == 'url' )
  620. {
  621. $ini = eZINI::instance();
  622. if ( $ini->hasVariable( 'SiteSettings', 'DefaultAccess' ) )
  623. {
  624. $siteType['access_type_value'] = $ini->variable( 'SiteSettings', 'DefaultAccess' );
  625. }
  626. $url .= '/' . $siteType['access_type_value'];
  627. $adminURL .= '/' . $siteType['admin_access_type_value'];
  628. }
  629. else if ( $siteType['access_type'] == 'hostname' )
  630. {
  631. $url = $siteType['access_type_value'];
  632. $adminURL = $siteType['admin_access_type_value'];
  633. if ( !preg_match( "#^[a-zA-Z0-9]+://(.*)$#", $url ) )
  634. {
  635. $url = 'http://' . $url;
  636. }
  637. if ( !preg_match( "#^[a-zA-Z0-9]+://(.*)$#", $adminURL ) )
  638. {
  639. $adminURL = 'http://' . $adminURL;
  640. }
  641. $url .= eZSys::indexDir( false );
  642. $adminURL .= eZSys::indexDir( false );
  643. }
  644. else if ( $siteType['access_type'] == 'port' )
  645. {
  646. $url = eZHTTPTool::createRedirectURL( $currentURL, array( 'override_port' => $siteType['access_type_value'] ) );
  647. $adminURL = eZHTTPTool::createRedirectURL( $currentURL, array( 'override_port' => $siteType['admin_access_type_value'] ) );
  648. }
  649. $siteaccessURL = array( 'url' => $url,
  650. 'admin_url' => $adminURL );
  651. return $siteaccessURL;
  652. }
  653. public $Tpl;
  654. public $Http;
  655. public $Ini;
  656. public $PersistenceList;
  657. // The identifier of the current step
  658. public $Identifier;
  659. // The name of the current step
  660. public $Name;
  661. /// Kickstart INI file, if one is found
  662. public $INI;
  663. /// The kickstart data as an associative array or \c false if no data available
  664. public $KickstartData;
  665. }
  666. ?>