diff --git a/application/controllers/admin/themes.php b/application/controllers/admin/themes.php index bbebe2eda39..1932153b73a 100755 --- a/application/controllers/admin/themes.php +++ b/application/controllers/admin/themes.php @@ -75,6 +75,50 @@ public function templatezip($templatename) } } + + /** + * Exports a deprecated template + * + * @access public + * @param string $templatename + * @return void + */ + public function deprecatedtemplatezip($templatename) + { + //$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename); + $templatename = sanitize_dirname($templatename); + $usertemplaterootdir = Yii::app()->getConfig("uploaddir").DIRECTORY_SEPARATOR."templates"; + $templatePath = $usertemplaterootdir.DIRECTORY_SEPARATOR.$templatename; + + + if (!Permission::model()->hasGlobalPermission('templates','export')){ + die('No permission'); + } + + $tempdir = Yii::app()->getConfig('tempdir'); + + $zipfile = "$tempdir/$templatename.zip"; + Yii::app()->loadLibrary('admin.pclzip'); + $zip = new PclZip($zipfile); + $zip->create($templatePath, PCLZIP_OPT_REMOVE_PATH, $templatePath); + + if (is_file($zipfile)) { + // Send the file for download! + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Content-Type: application/force-download"); + header("Content-Disposition: attachment; filename=$templatename.zip"); + header("Content-Description: File Transfer"); + + @readfile($zipfile); + + // Delete the temporary file + unlink($zipfile); + } + } + + /** * Retrieves a temporary template file from disk * diff --git a/application/models/Template.php b/application/models/Template.php index c2bb2ece09a..cea33001341 100755 --- a/application/models/Template.php +++ b/application/models/Template.php @@ -630,6 +630,28 @@ public function search() )); } + /** + * Retrieves a list of deprecated templates (the templates in upload/templates/) + */ + static public function getDeprecatedTemplates() + { + $usertemplaterootdir = Yii::app()->getConfig("uploaddir").DIRECTORY_SEPARATOR."templates"; + $aTemplateList = array(); + + if ( (is_dir($usertemplaterootdir)) && $usertemplaterootdir && $handle = opendir($usertemplaterootdir)){ + while (false !== ($file = readdir($handle))){ + if (!is_file("$usertemplaterootdir/$file") && $file != "." && $file != ".." && $file!=".svn"){ + $aTemplateList[$file]['directory'] = $usertemplaterootdir.DIRECTORY_SEPARATOR.$file; + $aTemplateList[$file]['name'] = $file; + } + } + closedir($handle); + } + ksort($aTemplateList); + + return $aTemplateList; + } + /** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! diff --git a/application/views/admin/themeoptions/index.php b/application/views/admin/themeoptions/index.php index 72861d0bc14..4336e8c7ac7 100644 --- a/application/views/admin/themeoptions/index.php +++ b/application/views/admin/themeoptions/index.php @@ -68,6 +68,45 @@ + + + + 0 ):?> +

+
+
+
+ + + + + + + + + + + + + + + + + +
+ hasGlobalPermission('templates','export') && function_exists("zip_open")):?> + + + + + +
+
+
+
+ + +