function install($addonName, $installDump = TRUE) { global $REX; $state = TRUE; $install_dir = $this->baseFolder($addonName); $install_file = $install_dir . 'install.inc.php'; $install_sql = $install_dir . 'install.sql'; $config_file = $install_dir . 'config.inc.php'; $files_dir = $install_dir . 'files'; // Prüfen des Addon Ornders auf Schreibrechte, // damit das Addon später wieder gelöscht werden kann $state = rex_is_writable($install_dir); if ($state === TRUE) { if (is_readable($install_file)) { $this->includeInstaller($addonName, $install_file); // Wurde das "install" Flag gesetzt? // Fehlermeldung ausgegeben? Wenn ja, Abbruch $instmsg = $this->apiCall('getProperty', array($addonName, 'installmsg', '')); if (!$this->apiCall('isInstalled', array($addonName)) || $instmsg) { $state = $this->I18N('no_install', $addonName) . '<br />'; if ($instmsg == '') { $state .= $this->I18N('no_reason'); } else { $state .= $instmsg; } } else { // check if config file exists if (is_readable($config_file)) { if (!$this->apiCall('isActivated', array($addonName))) { $this->includeConfig($addonName, $config_file); } } else { $state = $this->I18N('config_not_found'); } if ($installDump === TRUE && $state === TRUE && is_readable($install_sql)) { $state = rex_install_dump($install_sql); if ($state !== TRUE) { $state = 'Error found in install.sql:<br />' . $state; } } // Installation ok if ($state === TRUE) { // regenerate Addons file $state = $this->generateConfig(); } } } else { $state = $this->I18N('install_not_found'); } } // Dateien kopieren if ($state === TRUE && is_dir($files_dir)) { if (!rex_copyDir($files_dir, $this->mediaFolder($addonName), $REX['MEDIAFOLDER'])) { $state = $this->I18N('install_cant_copy_files'); } } if ($state !== TRUE) { $this->apiCall('setProperty', array($addonName, 'install', 0)); } return $state; }
function rex_copyDir($srcdir, $dstdir, $startdir = "") { global $REX; $debug = FALSE; $state = TRUE; if (!is_dir($dstdir)) { $dir = ''; foreach (explode(DIRECTORY_SEPARATOR, $dstdir) as $dirPart) { $dir .= $dirPart . DIRECTORY_SEPARATOR; if (strpos($startdir, $dir) !== 0 && !is_dir($dir)) { if ($debug) { echo "Create dir '{$dir}'<br />\n"; } mkdir($dir); chmod($dir, $REX['DIRPERM']); } } } if ($curdir = opendir($srcdir)) { while ($file = readdir($curdir)) { if ($file != '.' && $file != '..' && $file != '.svn') { $srcfile = $srcdir . DIRECTORY_SEPARATOR . $file; $dstfile = $dstdir . DIRECTORY_SEPARATOR . $file; if (is_file($srcfile)) { $isNewer = TRUE; if (is_file($dstfile)) { $isNewer = filemtime($srcfile) - filemtime($dstfile) > 0; } if ($isNewer) { if ($debug) { echo "Copying '{$srcfile}' to '{$dstfile}'..."; } if (copy($srcfile, $dstfile)) { touch($dstfile, filemtime($srcfile)); chmod($dstfile, $REX['FILEPERM']); if ($debug) { echo "OK<br />\n"; } } else { if ($debug) { echo "Error: File '{$srcfile}' could not be copied!<br />\n"; } return FALSE; } } } else { if (is_dir($srcfile)) { $state = rex_copyDir($srcfile, $dstfile, $startdir) && $state; } } } } closedir($curdir); } return $state; }
* * @author andreas[dot]eberhard[at]redaxo[dot]de Andreas Eberhard * @author <a href="http://rex.andreaseberhard.de">rex.andreaseberhad.de</a> * * @author Dave Holloway * @author <a href="http://www.GN2-Netwerk.de">www.GN2-Netwerk.de</a> * * @package redaxo4 * @version svn:$Id$ */ // Addon-Konfiguration include dirname(__FILE__) . '/config.inc.php'; // Schreibberechtigung für Konfigurationsetzen @chmod(dirname(__FILE__) . '/config.inc.php', 0755); // Install ok $REX['ADDON']['install'][$rxa_tinymce['name']] = 1; // REDAXO 3.2.3, 4.0.x, 4.1.x - Dateien in Ordner files/addons/ kopieren if ($rxa_tinymce['rexversion'] == '32' or $rxa_tinymce['rexversion'] == '40' or $rxa_tinymce['rexversion'] == '41') { $source_dir = $REX['INCLUDE_PATH'] . '/addons/' . $rxa_tinymce['name'] . '/files'; $dest_dir = $REX['MEDIAFOLDER'] . '/addons/' . $rxa_tinymce['name']; $start_dir = $REX['MEDIAFOLDER'] . '/addons'; if (is_dir($source_dir)) { if (!is_dir($start_dir)) { mkdir($start_dir); } if (!rex_copyDir($source_dir, $dest_dir, $start_dir)) { $REX['ADDON']['installmsg'][$rxa_tinymce['name']] = 'Verzeichnis ' . $source_dir . ' konnte nicht nach ' . $dest_dir . ' kopiert werden!'; $REX['ADDON']['install'][$rxa_tinymce['name']] = 0; } } }