PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/kernel/setup/steps/ezstep_installer.php

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