/**
  * installs an uploaded template
  */
 function _performUploadTemplate()
 {
     // handle the uploaded file
     $files = HttpVars::getFiles();
     $uploads = new FileUploads($files);
     if (count($files) == 0 || $files["templateFile"]["name"] == "") {
         $this->_view = new AdminTemplatedView($this->_blogInfo, "newglobaltemplate");
         $this->_view->setValue("templateFolder", TemplateSetStorage::getBaseTemplateFolder());
         $this->_view->setErrorMessage($this->_locale->tr("error_must_upload_file"));
         $this->setCommonData();
         return false;
     }
     $config =& Config::getConfig();
     $tmpFolder = $config->getValue('temp_folder');
     // move it to the temporary folder
     $result = $uploads->process($tmpFolder);
     // and from there, unpack it
     $upload = new FileUpload($files['templateFile']);
     $templateSandbox = new TemplateSandbox();
     $valid = $templateSandbox->checkTemplateSet($upload->getFileName(), $tmpFolder . '/');
     if ($valid < 0) {
         $this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_checkTemplateSandboxResult($valid));
         $this->setCommonData();
         return false;
     }
     // the template was ok, so then we can proceed and move it to the main
     // template folder, add it to our array of templates
     //
     // :KLUDGE:
     //
     // maybe we should simply move the files rather than unpacking the whole
     // thing again, but this indeed makes things easier! ;)
     $unpacker = new Unpacker();
     $templateFolder = $config->getValue('template_folder');
     $fileToUnpack = $tmpFolder . '/' . $upload->getFileName();
     if (!$unpacker->unpack($fileToUnpack, $templateFolder)) {
         $this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
         $tf = new Textfilter();
         $this->_view->setErrorMessage($this->_locale->pr('error_installing_template', $tf->filterAllHtml($upload->getFileName())));
         $this->setCommonData();
         return false;
     }
     // if the template set was installed ok in the template folder, we can record
     // it as a valid set
     $ts = new TemplateSetStorage();
     $fileParts = explode(".", $upload->getFileName());
     $templateName = $fileParts[0];
     $ts->addTemplate($templateName);
     $this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr('template_installed_ok', $templateName));
     $this->setCommonData();
     return true;
 }