[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: template.class.php 331 2005-10-02 15:48:09Z stingrey $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @subpackage Installer 7 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 17 18 // ensure user has access to this function 19 if (!$acl->acl_check( 'administration', 'manage', 'users', $GLOBALS['my']->usertype, 'components', 'com_templates' )) { 20 mosRedirect( 'index2.php', _NOT_AUTH ); 21 } 22 23 /** 24 * Template installer 25 * @package Joomla 26 * @subpackage Installer 27 */ 28 class mosInstallerTemplate extends mosInstaller { 29 /** 30 * Custom install method 31 * @param boolean True if installing from directory 32 */ 33 function install( $p_fromdir = null ) { 34 global $mosConfig_absolute_path,$database; 35 36 if (!$this->preInstallCheck( $p_fromdir, 'template' )) { 37 return false; 38 } 39 40 $xmlDoc =& $this->xmlDoc(); 41 $mosinstall =& $xmlDoc->documentElement; 42 43 $client = ''; 44 if ($mosinstall->getAttribute( 'client' )) { 45 $validClients = array( 'administrator' ); 46 if (!in_array( $mosinstall->getAttribute( 'client' ), $validClients )) { 47 $this->setError( 1, 'Unknown client type ['.$mosinstall->getAttribute( 'client' ).']' ); 48 return false; 49 } 50 $client = 'admin'; 51 } 52 53 // Set some vars 54 $e = &$mosinstall->getElementsByPath( 'name', 1 ); 55 $this->elementName($e->getText()); 56 $this->elementDir( mosPathName( $mosConfig_absolute_path 57 . ($client == 'admin' ? '/administrator' : '') 58 . '/templates/' . strtolower(str_replace(" ","_",$this->elementName()))) 59 ); 60 61 if (!file_exists( $this->elementDir() ) && !mosMakePath( $this->elementDir() )) { 62 $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"' ); 63 return false; 64 } 65 66 if ($this->parseFiles( 'files' ) === false) { 67 return false; 68 } 69 if ($this->parseFiles( 'images' ) === false) { 70 return false; 71 } 72 if ($this->parseFiles( 'css' ) === false) { 73 return false; 74 } 75 if ($this->parseFiles( 'media' ) === false) { 76 return false; 77 } 78 if ($e = &$mosinstall->getElementsByPath( 'description', 1 )) { 79 $this->setError( 0, $this->elementName() . '<p>' . $e->getText() . '</p>' ); 80 } 81 82 return $this->copySetupFile('front'); 83 } 84 /** 85 * Custom install method 86 * @param int The id of the module 87 * @param string The URL option 88 * @param int The client id 89 */ 90 function uninstall( $id, $option, $client=0 ) { 91 global $database, $mosConfig_absolute_path; 92 93 // Delete directories 94 $path = $mosConfig_absolute_path 95 . ($client == 'admin' ? '/administrator' : '' ) 96 . '/templates/' . $id; 97 98 $id = str_replace( '..', '', $id ); 99 if (trim( $id )) { 100 if (is_dir( $path )) { 101 return deldir( mosPathName( $path ) ); 102 } else { 103 HTML_installer::showInstallMessage( 'Directory does not exist, cannot remove files', 'Uninstall - error', 104 $this->returnTo( $option, 'template', $client ) ); 105 } 106 } else { 107 HTML_installer::showInstallMessage( 'Template id is empty, cannot remove files', 'Uninstall - error', 108 $this->returnTo( $option, 'template', $client ) ); 109 exit(); 110 } 111 } 112 /** 113 * return to method 114 */ 115 function returnTo( $option, $element, $client ) { 116 return "index2.php?option=com_templates&client=$client"; 117 } 118 } 119 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |