RELEASE .'.'. substr( $_VERSION->DEV_LEVEL, 0, 1); if( file_exists( $patchPath ) ) { $success = patchFiles( $patchPath ); } else { $success = false; } // Modify the admin icons $database->setQuery( "SELECT id FROM #__components WHERE name= 'NokKaew'" ); $id = $database->loadResult(); //add new admin menu images $database->setQuery( "UPDATE #__components " . "SET admin_menu_img = '../components/com_nokkaew/images/nokkaew_icon.png'" . ", admin_menu_link = 'option=com_nokkaew' " . "WHERE id='$id'"); $database->query(); $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/content.png', name = 'Translation' WHERE parent='$id' AND name = 'Translation'"); $database->query(); $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/config.png', name = 'Language configuration' WHERE parent='$id' AND name = 'Language configuration'"); $database->query(); $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/controlpanel.png' WHERE parent='$id' AND name = 'Content element configuration'"); $database->query(); $database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/credits.png' WHERE parent='$id' AND name = 'About'"); $database->query(); // Add module and bot $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);"); $database->query(); $moduleID = $database->insertid(); $database->setQuery( "INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES ($moduleID, 0);"); $database->query(); $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', '');"); $database->query(); $adminDir = dirname(__FILE__); rename( $adminDir. "/mambots/search/nokcontent.searchbot.php", "$mosConfig_absolute_path/mambots/search/nokcontent.searchbot.php"); rename( $adminDir. "/mambots/search/nokcontent.searchbot.x", "$mosConfig_absolute_path/mambots/search/nokcontent.searchbot.xml"); rename( $adminDir. "/modules/mod_nokkaew.php", "$mosConfig_absolute_path/modules/mod_nokkaew.php"); rename( $adminDir. "/modules/mod_nokkaew.x", "$mosConfig_absolute_path/modules/mod_nokkaew.xml"); // Information text require( dirname(__FILE__) . "/nokkaew.class.php"); require( dirname(__FILE__) . "/admin.nokkaew.html.php"); HTML_nokkaew_help::showPostInstall( $success ); return; } /** This function is patching the original files * The path will be scaned for .php which will be backuped & replaced * - If the original file couldn't be found for backup this is no problem * - If the new file couldn't replace the old one an error occurs and the function * returns false * - subdirectories will be patched recursivly * * @param string path to the directory of the files * @return boolean success for all files & directories */ function patchFiles( $patchPath, $subPath="" ) { global $mosConfig_absolute_path; $success = true; $filesindir = mosReadDirectory( "$patchPath/$subPath" ,""); foreach ($filesindir as $filename) { $filePath = ($subPath!="" ? "$subPath/" : "") .$filename; if( is_dir( "$patchPath/$filePath" ) ) { $success = patchFiles( $patchPath, $filePath ); } else { @copy( "$mosConfig_absolute_path/$filePath", "$patchPath/$filePath.bak"); //Backup $success = @copy( "$patchPath/$filePath", "$mosConfig_absolute_path/$filePath"); //Replace } if( !$success ) break; } return $success; } ?>