コード例 #1
0
 public function listTemplateAction()
 {
     $templates = Axis_Collect_MailTemplate::collect();
     $data = array();
     $i = 0;
     foreach ($templates as $templateKey => $template) {
         $data[$i] = array('name' => $template, 'id' => $templateKey);
         $i++;
     }
     return $this->_helper->json->setData($data)->sendSuccess();
 }
コード例 #2
0
ファイル: Mail.php プロジェクト: rommmka/axiscommerce
 /**
  * Retrieve template info by id
  * 
  * @param int $id
  * @return array
  */
 public function getInfo($id)
 {
     if (!is_numeric($id) || !($info = $this->find($id)->current())) {
         Axis::message()->addError(Axis::translate('core')->__('Template not found'));
         return array();
     }
     $info = $info->toArray();
     $templates = Axis_Collect_MailTemplate::collect();
     $file = Axis::config()->system->path . '/app/design/mail/' . $templates[$info['template']] . '_' . $info['type'] . '.phtml';
     $content = '';
     if (is_readable($file)) {
         $content = @file_get_contents($file);
     }
     $info['content'] = $content;
     return $info;
 }
コード例 #3
0
ファイル: MailTemplate.php プロジェクト: rguedes/axiscommerce
 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_templates) {
         $path = Axis::config()->system->path . '/app/design/mail';
         $templates = array();
         if (!file_exists($path)) {
             return false;
         }
         $dh = opendir($path);
         while ($file = readdir($dh)) {
             if (!is_dir($path . '/' . $file) && substr($file, -11) == '_html.phtml' && is_file($path . '/' . substr($file, 0, -11) . '_txt.phtml')) {
                 $templates[substr($file, 0, -11)] = substr($file, 0, -11);
             }
         }
         closedir($dh);
         self::$_templates = $templates;
     }
     return self::$_templates;
 }