/master/administrator/components/com_multisites/patches/joomla/check_ifpresent.php

https://github.com/sherdog/GitWitty · PHP · 78 lines · 35 code · 8 blank · 35 comment · 6 complexity · cc6f525b72b739a0a94c59487e3b6037 MD5 · raw file

  1. <?php
  2. /**
  3. * @file check_ifpresent.php
  4. * @brief Checks if a file is present.
  5. * Is used to test if the 'define_multisites.php' file is present.
  6. *
  7. * @version 1.2.10
  8. * @author Edwin CHERONT (e.cheront@jms2win.com)
  9. * Edwin2Win sprlu (www.jms2win.com)
  10. * @copyright Joomla Multi Sites
  11. * Single Joomla! 1.5.x installation using multiple configuration (One for each 'slave' sites).
  12. * (C) 2008 Edwin2Win sprlu - all right reserved.
  13. * @license This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  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. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  24. * A full text version of the GNU GPL version 2 can be found in the LICENSE.php file.
  25. * @par History:
  26. * - V1.0.0 14-JUL-2008: Initial version
  27. * - V1.1.0 07-NOV-2008: Deploy the patch.
  28. * With V1.1.0, the file multisites.php is added and must be deployed
  29. * even when define_multisites.php is already present.
  30. */
  31. defined('JPATH_MUTLISITES_COMPONENT') or die( 'Restricted access' );
  32. //------------ _checkIfPresent ---------------
  33. /**
  34. * check if a file is present
  35. */
  36. function jms2win_checkIfPresent( $model, $file)
  37. {
  38. $filename = JPath::clean( JPATH_ROOT.DS.$file);
  39. if ( !file_exists( $filename)) {
  40. return '[NOK]|File Not Found'
  41. .'|[ACTION]|Add the file';
  42. }
  43. $str = file_get_contents( $filename);
  44. // if 'MultisitesLetterTree::getLetterTreeDir' is present
  45. $pos = strpos( $str, 'MultisitesLetterTree::getLetterTreeDir');
  46. if ($pos === false) { $wrapperIsPresent = false; }
  47. else { $wrapperIsPresent = true; }
  48. $result = "";
  49. $rc = '[OK]|File is present';
  50. if ( !$wrapperIsPresent) {
  51. $rc = '[NOK]';
  52. $result .= JText::_( 'The new Multisites directory structure to allow creating several thousand of slave sites from the front-end is not present');
  53. $jms_vers = MultisitesController::_getVersion();
  54. if ( version_compare( $jms_vers, '1.2.30') < 0) {
  55. $result .= '|[ACTION]';
  56. $result .= '|Download the <a href="http://www.jms2win.com/get-latest-version">latest jms version</a>.';
  57. $result .= '|JMS version 1.2.30 or higher is required to install this patch.';
  58. }
  59. else {
  60. $result .= '|[ACTION]';
  61. $result .= '|Install the new multisite detection';
  62. }
  63. }
  64. return $rc .'|'. $result;
  65. }
  66. //------------ _actionIfPresent ---------------
  67. function jms2win_actionIfPresent( $model, $file)
  68. {
  69. return $model->_deployPatches();
  70. }