コード例 #1
0
ファイル: EHeartPDF.php プロジェクト: azizbekvahidov/foods
 /**
  * Register autoloader.
  */
 public static function init()
 {
     if (!self::$_isInitialized) {
         $lib = Yii::getPathOfAlias(self::$libPathPDF) . '.php';
         if (!file_exists($lib)) {
             Yii::log("TCPDF lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EHeartPDF');
         } else {
             spl_autoload_unregister(array('YiiBase', 'autoload'));
             Yii::import(self::$libPathPDF, true);
             spl_autoload_register(array('YiiBase', 'autoload'));
             self::$_isInitialized = true;
         }
     }
 }
コード例 #2
0
ファイル: EHeartExport.php プロジェクト: azizbekvahidov/foods
 public function init()
 {
     if (isset($_GET[$this->grid_mode_var])) {
         $this->grid_mode = $_GET[$this->grid_mode_var];
     }
     if (isset($_GET['exportType'])) {
         $this->exportType = $_GET['exportType'];
     }
     if ($this->grid_mode == 'export') {
         $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
         $this->initColumns();
     }
     if ($this->exportType == "PDF") {
         Yii::import('ext.heart.pdf.EHeartPDF', true);
         EHeartPDF::init();
         // create new PDF document
         $this->pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $this->pdf->SetCreator(PDF_CREATOR);
         $this->pdf->SetAuthor('YiiHeart');
     }
     if ($this->exportType == "WORD") {
         Yii::import('ext.heart.opentbs.EHeartOpenTBS', true);
         EHeartOpenTBS::init();
         $this->TBS = new clsTinyButStrong();
         // new instance of TBS
         $this->TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
         // load the OpenTBS plugin
         $templatePath = Yii::getPathOfAlias('ext.heart.opentbs');
         $template = $templatePath . DIRECTORY_SEPARATOR . 'template.docx';
         $this->TBS->LoadTemplate($template);
     } else {
         if ($this->grid_mode == 'export') {
             Yii::import('ext.heart.excel.EHeartExcel', true);
             EHeartExcel::init();
             $this->objPHPExcel = new PHPExcel();
             // Creating a workbook
             $this->objPHPExcel->getProperties()->setCreator($this->creator);
             $this->objPHPExcel->getProperties()->setTitle($this->title);
             $this->objPHPExcel->getProperties()->setSubject($this->subject);
             $this->objPHPExcel->getProperties()->setDescription($this->description);
             $this->objPHPExcel->getProperties()->setCategory($this->category);
         } else {
             parent::init();
         }
     }
 }