Annotation of /trunk/install.nokkaew.php
Parent Directory
|
Revision Log
Revision 3 - (view) (download)
| 1 : | andphe | 3 | <?php |
| 2 : | // NOKKAEW - is "Parrot" in thai name | ||
| 3 : | // Copyright (C) copyright 2006 MamboHub.com | ||
| 4 : | // All rights reserved. The NokKaew project is a extention hack and | ||
| 5 : | // component for the Mambo Open Server. It enables Mambo OS to handle multi | ||
| 6 : | // lingual sites especially in all dynamic contents which are stored in the | ||
| 7 : | // database. | ||
| 8 : | // | ||
| 9 : | // This program is free software; you can redistribute it and/or | ||
| 10 : | // modify it under the terms of the GNU General Public License | ||
| 11 : | // as published by the Free Software Foundation; either version 2 | ||
| 12 : | // of the License, or (at your option) any later version. | ||
| 13 : | // | ||
| 14 : | // This program is distributed in the hope that it will be useful, | ||
| 15 : | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 : | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 : | // GNU General Public License for more details. | ||
| 18 : | // | ||
| 19 : | // You should have received a copy of the GNU General Public License | ||
| 20 : | // along with this program; if not, write to the Free Software | ||
| 21 : | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. | ||
| 22 : | // | ||
| 23 : | // The "GNU General Public License" (GPL) is available at | ||
| 24 : | // http://www.gnu.org/copyleft/gpl.html | ||
| 25 : | // -------------------------------------------------------------------------------- | ||
| 26 : | // $Id: install.nokkaew.php,v 1.4 2006/06/28 11:45:34 akede Exp $ | ||
| 27 : | // | ||
| 28 : | // Don't allow direct linking | ||
| 29 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 30 : | |||
| 31 : | global $mosConfig_absolute_path; | ||
| 32 : | |||
| 33 : | function com_install() | ||
| 34 : | { | ||
| 35 : | global $_VERSION, $database, $mosConfig_absolute_path; | ||
| 36 : | |||
| 37 : | // Patching the core | ||
| 38 : | $patchPath = dirname(__FILE__) ."/patch"; | ||
| 39 : | $patchPath .= '/'. $_VERSION->RELEASE .'.'. substr( $_VERSION->DEV_LEVEL, 0, 1); | ||
| 40 : | if( file_exists( $patchPath ) ) { | ||
| 41 : | $success = patchFiles( $patchPath ); | ||
| 42 : | } else { | ||
| 43 : | $success = false; | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | // Modify the admin icons | ||
| 47 : | $database->setQuery( "SELECT id FROM #__components WHERE name= 'NokKaew'" ); | ||
| 48 : | $id = $database->loadResult(); | ||
| 49 : | |||
| 50 : | //add new admin menu images | ||
| 51 : | $database->setQuery( "UPDATE #__components " . | ||
| 52 : | "SET admin_menu_img = '../components/com_nokkaew/images/nokkaew_icon.png'" . | ||
| 53 : | ", admin_menu_link = 'option=com_nokkaew' " . | ||
| 54 : | "WHERE id='$id'"); | ||
| 55 : | $database->query(); | ||
| 56 : | $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/content.png', name = '<b>Translation</b>' WHERE parent='$id' AND name = 'Translation'"); | ||
| 57 : | $database->query(); | ||
| 58 : | $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/config.png', name = '<b>Language configuration</b>' WHERE parent='$id' AND name = 'Language configuration'"); | ||
| 59 : | $database->query(); | ||
| 60 : | $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/controlpanel.png' WHERE parent='$id' AND name = 'Content element configuration'"); | ||
| 61 : | $database->query(); | ||
| 62 : | $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/credits.png' WHERE parent='$id' AND name = 'About'"); | ||
| 63 : | $database->query(); | ||
| 64 : | |||
| 65 : | // Add module and bot | ||
| 66 : | $database->setQuery( "INSERT INTO `#__modules` (`title`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `published`, `module`, `numnews`, `access`, `showtitle`, `params`, `iscore`, `client_id`) VALUES ('Select Language', '', 1, 'left', 0, '0000-00-00 00:00:00', 1, 'mod_nokkaew', 0, 0, 1, '', 0, 0);"); | ||
| 67 : | $database->query(); | ||
| 68 : | $moduleID = $database->insertid(); | ||
| 69 : | $database->setQuery( "INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES ($moduleID, 0);"); | ||
| 70 : | $database->query(); | ||
| 71 : | $database->setQuery( "INSERT INTO `#__mambots` (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES ('multi lingual content searchbot', 'nokcontent.searchbot', 'search', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '');"); | ||
| 72 : | $database->query(); | ||
| 73 : | |||
| 74 : | $adminDir = dirname(__FILE__); | ||
| 75 : | rename( $adminDir. "/mambots/search/nokcontent.searchbot.php", "$mosConfig_absolute_path/mambots/search/nokcontent.searchbot.php"); | ||
| 76 : | rename( $adminDir. "/mambots/search/nokcontent.searchbot.x", "$mosConfig_absolute_path/mambots/search/nokcontent.searchbot.xml"); | ||
| 77 : | |||
| 78 : | rename( $adminDir. "/modules/mod_nokkaew.php", "$mosConfig_absolute_path/modules/mod_nokkaew.php"); | ||
| 79 : | rename( $adminDir. "/modules/mod_nokkaew.x", "$mosConfig_absolute_path/modules/mod_nokkaew.xml"); | ||
| 80 : | |||
| 81 : | // Information text | ||
| 82 : | require( dirname(__FILE__) . "/nokkaew.class.php"); | ||
| 83 : | require( dirname(__FILE__) . "/admin.nokkaew.html.php"); | ||
| 84 : | HTML_nokkaew_help::showPostInstall( $success ); | ||
| 85 : | |||
| 86 : | return; | ||
| 87 : | } | ||
| 88 : | |||
| 89 : | /** This function is patching the original files | ||
| 90 : | * The path will be scaned for .php which will be backuped & replaced | ||
| 91 : | * - If the original file couldn't be found for backup this is no problem | ||
| 92 : | * - If the new file couldn't replace the old one an error occurs and the function | ||
| 93 : | * returns false | ||
| 94 : | * - subdirectories will be patched recursivly | ||
| 95 : | * | ||
| 96 : | * @param string path to the directory of the files | ||
| 97 : | * @return boolean success for all files & directories | ||
| 98 : | */ | ||
| 99 : | function patchFiles( $patchPath, $subPath="" ) { | ||
| 100 : | global $mosConfig_absolute_path; | ||
| 101 : | $success = true; | ||
| 102 : | |||
| 103 : | $filesindir = mosReadDirectory( "$patchPath/$subPath" ,""); | ||
| 104 : | foreach ($filesindir as $filename) { | ||
| 105 : | $filePath = ($subPath!="" ? "$subPath/" : "") .$filename; | ||
| 106 : | if( is_dir( "$patchPath/$filePath" ) ) { | ||
| 107 : | $success = patchFiles( $patchPath, $filePath ); | ||
| 108 : | } else { | ||
| 109 : | @copy( "$mosConfig_absolute_path/$filePath", "$patchPath/$filePath.bak"); //Backup | ||
| 110 : | $success = @copy( "$patchPath/$filePath", "$mosConfig_absolute_path/$filePath"); //Replace | ||
| 111 : | } | ||
| 112 : | |||
| 113 : | if( !$success ) break; | ||
| 114 : | } | ||
| 115 : | return $success; | ||
| 116 : | } | ||
| 117 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

