public function actionTemplate2() { Yii::import('ext.heart.opentbs.EHeartOpenTBS', true); EHeartOpenTBS::init(); // Initalize the TBS instance $TBS = new clsTinyButStrong(); // new instance of TBS $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin $templatePath = Yii::getPathOfAlias('ext.heart.opentbs'); $template = $templatePath . DIRECTORY_SEPARATOR . 'template.docx'; $TBS->LoadTemplate($template); $modelPath = Yii::getPathOfAlias('application.models'); $files = scandir($modelPath); $row = 2; $data = array(); foreach ($files as $file) { if (is_file($modelPath . '/' . $file) && CFileHelper::getExtension($file) === 'php' && !in_array($file, array('ContactForm.php', 'LoginForm.php', 'Admin.php', 'User.php'))) { $file_arr = explode(".", $file); $filename = $file_arr[0]; $data[$row - 2]['no'] = $row - 1; $data[$row - 2]['field1'] = $filename; $data[$row - 2]['field2'] = 'test/' . $filename; $row++; } } $data2[0]['title'] = "Template Generator"; $data2[0]['field1'] = 'Model'; $data2[0]['field2'] = 'Controller'; $TBS->NoErr = true; $TBS->MergeBlock('data', 'array', $data); $TBS->MergeBlock('data2', 'array', $data2); $TBS->Show(OPENTBS_DOWNLOAD, 'template.docx'); }
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(); } } }
/** * Register autoloader. */ public static function init() { if (!self::$_isInitialized) { $lib = Yii::getPathOfAlias(self::$libPathOpenTBS) . DIRECTORY_SEPARATOR . 'tbs_class.php'; if (!file_exists($lib)) { Yii::log("OpenTBS lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EHeartOpenTBS'); } else { spl_autoload_unregister(array('YiiBase', 'autoload')); //Yii::import(self::$libPathOpenTBS.DIRECTORY_SEPARATOR.'tbs_class.php', true); //Yii::import(self::$libPathOpenTBS.'/tbs_plugin_opentbs.php', true); $lib = Yii::getPathOfAlias(self::$libPathOpenTBS) . DIRECTORY_SEPARATOR . 'tbs_class.php'; require $lib; $lib = Yii::getPathOfAlias(self::$libPathOpenTBS) . DIRECTORY_SEPARATOR . 'tbs_plugin_opentbs.php'; require $lib; spl_autoload_register(array('YiiBase', 'autoload')); self::$_isInitialized = true; } } }