Source for file CMS3_PackageInstaller.php
Documentation is available at CMS3_PackageInstaller.php
// CMS3 - A Three Content Management System.
// Copyright (C) 2007 Jop... (Jonas F. Jensen).
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*This file defines CMS3_PackageInstaller
* @package PackageInstaller
* @author Jonas F. Jensen <jopsen@gmail.com>
* @copyright 2007 Jonas F. Jensen.
* @license http://www.gnu.org/licenses/gpl.txt
*PackageManager provides the logic for installation and removal of packages.
*This plugin doesn't provide any user interface only API interface for package operations, must be staticly linked.
//ISystemCallback implementation
* Handles a callback from ajax application.
* @param string data Data attached to this callback
//Check for error on HTTP level
if ($_FILES["image"]["error"] >
0){
/* this is a modification of similar code found here: http://php.net/manual/en/features.file-upload.errors.php */
switch ($_FILES["image"]["error"]) {
case UPLOAD_ERR_INI_SIZE:
$msg =
"The uploaded file exceeds the upload_max_filesize directive (" .
ini_get("upload_max_filesize") .
") in php.ini.";
case UPLOAD_ERR_FORM_SIZE:
$msg =
"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.";
$msg =
"The uploaded file was only partially uploaded.";
$msg =
"No file was uploaded.";
case UPLOAD_ERR_NO_TMP_DIR:
$msg =
"Missing a temporary folder.";
case UPLOAD_ERR_CANT_WRITE:
$msg =
"Failed to write file to disk";
$msg =
"Unknown File Error";
//Log the error to system log
$this->Owner->Log($this->GetPluginID(), "Error during upload, HTTP/php error code: " .
$msg);
//Move the uploaded package using package manager
if(!$this->Owner->GetPlugin("PackageManager")->UploadPackage($_FILES["package"]["tmp_name"], substr($_FILES["package"]["name"],0,-
4)))
//Log possible move error
$this->Owner->Log($this->GetPluginID(), "Unable to move uploaded package: " .
$_FILES["package"]["name"]);
//Redirect back to configuration guide... File upload isn't ajax since you can't do that, perhaps it possible using a iframe proxy.
header("Location: " .
$this->Owner->GetCMS3URL() .
"System/Configure/PackageInstaller");
}elseif($data ==
"Verify"){
//print the output from PackageManager
print
$this->Owner->GetPlugin("PackageManager")->VerifyPackage($_POST["SelectedPackage"]) ?
"Good signature" :
"Bad signature";
}elseif($data ==
"Install"){
//print the output from PackageManager
print
$this->Owner->GetPlugin("PackageManager")->InstallPackage($_POST["SelectedPackage"]);
//Nothing smart to do, just return a soft 404
print
"Error: 404, data not found.";
//IConfigure implementation
* Gets an absolute address of an icon for this plugin
return $this->Owner->GetCMS3URL() .
"bin/" .
$this->GetPluginID() .
"/config.png";
return "Install package";
* Gets a dojo based ajax guide for configuration of the plugin.
* @param IEmbedmentOutputHandler OutputHandler
* @return IEmbedmentOutputHandler
public function &Configure($Identifier =
null, &$EmbedmentOutputHandler ){
//Load templates from files
foreach($this->Owner->GetPlugin("PackageManager")->ListPackages() as $Package)
$Options .=
"<option value='" .
$Package .
"' >" .
$Package .
"</option>\n";
$EmbedmentOutputHandler->ExtentHeader($Head);
$EmbedmentOutputHandler->SetBody($Body);
return $EmbedmentOutputHandler;
//Implementation of IPlugin
* Gets the pluginID of the plugin.
return "PackageInstaller";
Documentation generated on Mon, 30 Apr 2007 01:59:04 +0200 by phpDocumentor 1.3.1