コード例 #1
0
 /**
  * looked-up the email template_paths.
  * if not set, will look up both theme folder and project folder
  * in both cases, email folder exsits or Email folder exists
  * return an array containing all folders pointing to the bunch of email templates
  *
  * @return array
  */
 public static function template_paths()
 {
     if (!isset(self::$template_paths)) {
         if (class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
             $theme = $config->Theme;
         } elseif (SSViewer::current_custom_theme()) {
             $theme = SSViewer::current_custom_theme();
         } elseif (SSViewer::current_theme()) {
             $theme = SSViewer::current_theme();
         } else {
             $theme = false;
         }
         if ($theme) {
             if (file_exists("../" . THEMES_DIR . "/" . $theme . "/templates/email")) {
                 self::$template_paths[] = THEMES_DIR . "/" . $theme . "/templates/email";
             }
             if (file_exists("../" . THEMES_DIR . "/" . $theme . "/templates/Email")) {
                 self::$template_paths[] = THEMES_DIR . "/" . $theme . "/templates/Email";
             }
         }
         $project = project();
         if (file_exists("../" . $project . '/templates/email')) {
             self::$template_paths[] = $project . '/templates/email';
         }
         if (file_exists("../" . $project . '/templates/Email')) {
             self::$template_paths[] = $project . '/templates/Email';
         }
     } else {
         if (is_string(self::$template_paths)) {
             self::$template_paths = array(self::$template_paths);
         }
     }
     return self::$template_paths;
 }
コード例 #2
0
 /**
  * return array containing all possible email templates file name
  * under the folders of both theme and project specific folder.
  *
  * @return array
  */
 public function templateSource()
 {
     $paths = NewsletterAdmin::template_paths();
     $templates = array("SimpleNewsletterTemplate" => _t('TemplateList.SimpleNewsletterTemplate', 'Simple Newsletter Template'));
     if (isset($paths) && is_array($paths)) {
         $absPath = Director::baseFolder();
         if ($absPath[strlen($absPath) - 1] != "/") {
             $absPath .= "/";
         }
         foreach ($paths as $path) {
             $path = $absPath . $path;
             if (is_dir($path)) {
                 $templateDir = opendir($path);
                 // read all files in the directory
                 while (($templateFile = readdir($templateDir)) !== false) {
                     // *.ss files are templates
                     if (preg_match('/(.*)\\.ss$/', $templateFile, $match)) {
                         // only grab those haveing $Body coded
                         if (strpos("\$Body", file_get_contents($path . "/" . $templateFile)) === false) {
                             $templates[$match[1]] = preg_replace('/_?([A-Z])/', " \$1", $match[1]);
                         }
                     }
                 }
             }
         }
     }
     return $templates;
 }
コード例 #3
0
 /**
  * looked-up the email template_paths. 
  * if not set, will look up both theme folder and project folder
  * in both cases, email folder exsits or Email folder exists
  * return an array containing all folders pointing to the bunch of email templates
  *
  * @return array
  */
 public static function template_paths()
 {
     if (!isset(self::$template_paths)) {
         if (file_exists("../" . THEMES_DIR . "/" . SSViewer::current_theme() . "/templates/email")) {
             self::$template_paths[] = THEMES_DIR . "/" . SSViewer::current_theme() . "/templates/email";
         }
         if (file_exists("../" . THEMES_DIR . "/" . SSViewer::current_theme() . "/templates/Email")) {
             self::$template_paths[] = THEMES_DIR . "/" . SSViewer::current_theme() . "/templates/Email";
         }
         if (file_exists("../" . project() . '/templates/email')) {
             self::$template_paths[] = project() . '/templates/email';
         }
         if (file_exists("../" . project() . '/templates/Email')) {
             self::$template_paths[] = project() . '/templates/Email';
         }
     } else {
         if (is_string(self::$template_paths)) {
             self::$template_paths = array(self::$template_paths);
         }
     }
     return self::$template_paths;
 }