mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
66c3db1e8e
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@50107 467b73ca-7a2a-4603-9d3b-597d59a354a9
48 lines
1.1 KiB
PHP
Executable File
48 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package cms
|
|
* @subpackage newsletter
|
|
*/
|
|
|
|
/**
|
|
* Subclass of DropdownField for showing a list of the newsletter templates available.
|
|
* @package cms
|
|
* @subpackage newsletter
|
|
*/
|
|
class TemplateList extends DropdownField {
|
|
|
|
protected $templatePath;
|
|
|
|
function __construct( $name, $title, $value, $path, $form = null ) {
|
|
$this->templatePath = $path;
|
|
parent::__construct( $name, $title, $this->getTemplates(), $value, $form );
|
|
}
|
|
|
|
private function getTemplates() {
|
|
$templates = array( "" => _t('TemplateList.NONE', 'None') );
|
|
|
|
$absPath = Director::baseFolder();
|
|
if( $absPath{strlen($absPath)-1} != "/" )
|
|
$absPath .= "/";
|
|
|
|
$absPath .= $this->templatePath;
|
|
if(is_dir($absPath)) {
|
|
$templateDir = opendir( $absPath );
|
|
|
|
// read all files in the directory
|
|
while( ( $templateFile = readdir( $templateDir ) ) !== false ) {
|
|
// *.ss files are templates
|
|
if( preg_match( '/(.*)\.ss$/', $templateFile, $match ) )
|
|
$templates[$match[1]] = $match[1];
|
|
}
|
|
}
|
|
|
|
return $templates;
|
|
}
|
|
|
|
function setController( $controller ) {
|
|
$this->controller = $controller;
|
|
}
|
|
}
|
|
?>
|