コード例 #1
0
ファイル: Abstract.php プロジェクト: hugi2002/mylibrary
 /**
  * get Singleton  Sys_Model_Template
  *
  * @return Sys_Model_Template
  */
 public static function getObjectByID($id)
 {
     $obj = new Sys_Model_Template();
     $obj->find($id);
     return $obj;
 }
コード例 #2
0
ファイル: Sender.php プロジェクト: hugi2002/mylibrary
 public function getBodyContent()
 {
     try {
         $this->setIsNullParam('COMPANY_INFO', $this->_info());
         $this->setIsNullParam('COMPANY_NAME_TH', $this->_info(false));
         $this->setIsNullParam('CUSTOMER_NAME', App_Env::getUserFullName());
         if (count($this->_to) == 0) {
             $this->addTo(App_Env::getUserEmail());
         }
         if (count($this->_bcc) == 0) {
             $this->addBcc(App_Env::getSystemEmail());
         }
         // $mail = new Zend_Mail('utf-8');
         //$mail->setHeaderEncoding();
         ob_start();
         // ดึง layout ออกมา
         if ($this->_templete_id != '') {
             $templtet = new Sys_Model_Template();
             $templtet->find($this->_templete_id);
             $this->_subject = $templtet->name;
             //หา ค่า posible value
             $possibleAttributes = $templtet->possibleAttributes;
             $possibleAttributes_tmp1 = str_replace(array("<ul>", '</ul>', '<li>', '</li>'), ' ', $possibleAttributes);
             $possibleAttributes_tmp1 = preg_replace(array('/\\s\\s+/'), " ", $possibleAttributes_tmp1);
             $possibleAttributes_tmp2 = explode(" ", $possibleAttributes_tmp1);
             $data_key = array();
             $data_value = array();
             foreach ($possibleAttributes_tmp2 as $attr) {
                 $attr = trim($attr);
                 if ($attr != '') {
                     $value = trim($this->_templete_params[$attr]);
                     if ($value == '') {
                         $value = 'N/A';
                     }
                     $data_value[] = $value;
                     $data_key[] = $attr;
                 }
             }
             //print_r($data_key);
             //print_r($data_value);
             echo str_replace($data_key, $data_value, $templtet->getContent());
         } else {
             // กำหนดค่าโดยตรง
             echo $content = $this->_content;
             echo $footer = $this->_footer;
         }
         $html = ob_get_clean();
         $html = str_replace("http://www.dev2.scimaxthailand.com", WEB_DOMAIN, $html);
         return $html;
         //  exit();
     } catch (Exception $e) {
         //	$this->view->stat = 'error';
         //	$this->view->msg = $e->getMessage ();
         echo $e->getMessage();
         // throw new Exception($e->getMessage());
     }
 }