コード例 #1
0
 protected function _getMasterClass($component)
 {
     $masterClass = Kwc_Admin::getComponentFile($component->componentClass, 'PdfMaster', 'php', true);
     if (!$masterClass) {
         $masterClass = 'Kwf_Pdf_TcPdf';
     }
     return $masterClass;
 }
コード例 #2
0
 public function replaceOutput($renderer)
 {
     if ($this->isLoggedIn()) {
         return false;
     }
     $template = Kwc_Admin::getComponentFile($this, 'Component', 'tpl');
     $renderer = new Kwf_Component_Renderer();
     $view = new Kwf_Component_View($renderer);
     $view->assign($this->getTemplateVars());
     return $renderer->render($view->render($template));
 }
コード例 #3
0
 protected function _getEmptyImageData()
 {
     $emptyImage = $this->_getSetting('emptyImage');
     if (!$emptyImage) {
         return null;
     }
     $ext = substr($emptyImage, strrpos($emptyImage, '.') + 1);
     $filename = substr($emptyImage, 0, strrpos($emptyImage, '.'));
     $file = Kwc_Admin::getComponentFile($this, $filename, $ext);
     $s = getimagesize($file);
     return array('filename' => $emptyImage, 'file' => $file, 'mimeType' => $s['mime'], 'dimensions' => array('width' => $s[0], 'height' => $s[1], 'rotation' => 0));
 }
コード例 #4
0
 public function replaceOutput($renderer)
 {
     if ($this->isLoggedIn()) {
         return false;
     }
     $form = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_componentId, array('ignoreVisible' => true))->getChildComponent('-form');
     $templateVars = array();
     $templateVars['form'] = $form;
     $template = Kwc_Admin::getComponentFile($this, 'Component', 'tpl');
     $view = new Kwf_Component_View();
     $view->assign($templateVars);
     return $view->render($template);
 }
コード例 #5
0
 public function processOutput($output, $renderer)
 {
     // Da das Plugin nach dem Rendern ausgeführt wird, muss schon der
     // fertige Content hier reinkommen
     if ($output != 'root plugin(plugin(c1_child c1_childchild))') {
         return 'not ok from plugin. output was: ' . $output;
     } else {
         $template = Kwc_Admin::getComponentFile($this, 'Component', 'tpl');
         $renderer = new Kwf_Component_Renderer();
         $view = new Kwf_Component_View($renderer);
         $view->child = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_componentId)->getChildComponent('-pluginChild');
         return $renderer->render($view->render($template));
     }
 }
コード例 #6
0
ファイル: View.php プロジェクト: nsams/koala-framework
 /**
  * Create a .txt.tpl or .html.tpl file and set $template to the path.
  * @param string|Kwc_Abstract|Kwf_Component_Data $template: If it's a
  *          string it should point to the template in /views/mails. It's
  *          also possible to use a 'Kwc_Abstract' or 'Kwf_Component_Data'
  *          (This is used when the template destination is in this component-folder).
  *          There are no absolute paths allowed.
  * @param string $masterTemplate
  */
 public function __construct($template, $masterTemplate = 'Master')
 {
     parent::__construct();
     if (is_object($template) || in_array($template, Kwc_Abstract::getComponentClasses())) {
         if (is_object($template)) {
             if ($template instanceof Kwc_Abstract) {
                 $template = $template->getData();
             }
             if (!$template instanceof Kwf_Component_Data) {
                 throw new Kwf_Exception("template must be instance of 'Kwc_Abstract' or 'Kwf_Component_Data'");
             }
             $template = $template->componentClass;
         }
         $this->_txtTemplate = Kwc_Admin::getComponentFile($template, 'Component', 'txt.tpl');
         if (!$this->_txtTemplate) {
             throw new Kwf_Exception("Component class '{$template}' needs at least a .txt.tpl mail template.");
         }
         $this->_htmlTemplate = Kwc_Admin::getComponentFile($template, 'Component', 'html.tpl');
     } else {
         if (substr($template, 0, 1) == '/') {
             throw new Kwf_Exception("Absolute mail template paths are not allowed. You called '{$template}'.");
         }
         if (false === $this->getScriptPath("{$template}.txt.tpl")) {
             $template = "mails/{$template}";
             if (false === $this->getScriptPath("{$template}.txt.tpl")) {
                 throw new Kwf_Exception("There has to exist at least a .txt.tpl mail template for '{$template}'.");
             }
         }
         $this->_txtTemplate = "{$template}.txt.tpl";
         if (false !== $this->getScriptPath("{$template}.html.tpl")) {
             $this->_htmlTemplate = "{$template}.html.tpl";
         }
     }
     $this->_mailTplViewMasterTemplate = $masterTemplate;
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Registry::get('config')->server->domain;
     }
     $this->webUrl = (Kwf_Util_Https::supportsHttps() ? 'https' : 'http') . '://' . $host;
     $this->host = $host;
     $this->applicationName = Kwf_Registry::get('config')->application->name;
 }
コード例 #7
0
 public function jsonCreateAction()
 {
     $class = $this->_getParam('class');
     $type = $this->_getParam('type');
     if (!in_array($type, array('tpl', 'css'))) {
         throw new Kwf_Exception("Invalid type");
     }
     $path = str_replace('_', '/', $class);
     $path = str_replace('.', '', $path);
     //security
     if (file_exists($path . '.' . $type)) {
         throw new Kwf_ClientException("File does already exist.");
     }
     $srcFile = Kwc_Admin::getComponentFile($class, $type);
     if (!$srcFile) {
         throw new Kwf_ClientException("No file exists that could be copied.");
     }
     if (!copy($srcFile, $path . '.' . $type)) {
         throw new Kwf_Exception("Can't copy '{$srcFile}' to '{$path}.{$type}'");
     }
     $this->view->path = $path . '.' . $type;
 }
コード例 #8
0
 /**
  * Returns path of a template file for a given component
  *
  * @param string componentClass
  * @param string template filename without extension
  * @return string
  */
 public static function getTemplateFile($componentClass, $filename = 'Component')
 {
     return Kwc_Admin::getComponentFile($componentClass, $filename, array('tpl', 'twig'));
 }
コード例 #9
0
 public function componentFile(Kwf_Component_Data $data, $filename)
 {
     $ext = substr($filename, strrpos($filename, '.') + 1);
     $filename = substr($filename, 0, strrpos($filename, '.'));
     return Kwc_Admin::getComponentFile($data->componentClass, $filename, $ext);
 }
コード例 #10
0
 public function getPdfWriter($pdf)
 {
     if (!isset($this->_pdfWriter)) {
         $class = Kwc_Admin::getComponentFile($this->getData()->chained->componentClass, 'Pdf', 'php', true);
         $this->_pdfWriter = new $class($this, $pdf);
     }
     return $this->_pdfWriter;
 }