コード例 #1
0
ファイル: Pdf.php プロジェクト: xiaoguizhidao/koala-framework
 protected function _getDownloadUrl()
 {
     $downloadTagVars = $this->_component->getData()->getChildComponent('-downloadTag')->getComponent()->getTemplateVars();
     $domain = $this->_component->getData()->getDomain();
     $protocol = Kwf_Util_Https::domainSupportsHttps($domain) ? 'https' : 'http';
     return $protocol . '://' . $domain . $downloadTagVars['url'];
 }
コード例 #2
0
 public function indexAction()
 {
     $this->view->config = array('responsive' => Kwf_Config::getValue('kwc.responsive'));
     $this->view->xtype = 'kwf.component.preview';
     $this->view->initialUrl = null;
     if (preg_match('#^https?://#', $this->_getParam('url'))) {
         $this->view->initialUrl = $this->_getParam('url');
     }
     if (!$this->view->initialUrl) {
         $https = Kwf_Util_Https::domainSupportsHttps($_SERVER['HTTP_HOST']);
         $protocol = $https ? 'https://' : 'http://';
         $this->view->initialUrl = $protocol . $_SERVER['HTTP_HOST'] . Kwf_Setup::getBaseUrl() . '/';
     }
 }
コード例 #3
0
 /**
  * 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::domainSupportsHttps($host) ? 'https' : 'http') . '://' . $host;
     $this->host = $host;
     $this->applicationName = Kwf_Registry::get('config')->application->name;
 }
コード例 #4
0
 public static function callUtil($method, $params, $options = array())
 {
     $outputType = '';
     if (isset($params['type']) && $params['type'] == 'user') {
         $outputType = 'apc user';
     } else {
         if (isset($params['type']) && $params['type'] == 'file') {
             $outputType = 'optcode';
         }
     }
     $params['password'] = self::_getHttpPassword();
     $config = Kwf_Registry::get('config');
     $d = $config->server->domain;
     if (!$d) {
         if (isset($options['outputFn'])) {
             call_user_func($options['outputFn'], "error: {$outputType}: domain not set");
         }
         return false;
     }
     $domains = array(array('domain' => $d));
     if ($config->server->preliminaryDomain) {
         $domains[0]['alternative'] = $config->server->preliminaryDomain;
     }
     if (!isset($domains[0]['alternative']) && $config->server->noRedirectPattern) {
         $domains[0]['alternative'] = str_replace(array('^', '\\', '$'), '', $config->server->noRedirectPattern);
     }
     foreach ($domains as $d) {
         $s = microtime(true);
         if (Kwf_Util_Https::domainSupportsHttps($d['domain'])) {
             $urlPart = "https://";
         } else {
             $urlPart = "http://";
         }
         $baseUrl = Kwf_Setup::getBaseUrl();
         $url = "{$urlPart}{$d['domain']}{$baseUrl}/kwf/util/apc/{$method}";
         $config = array('timeout' => 60, 'keepalive' => true);
         if (extension_loaded('curl')) {
             $config['adapter'] = 'Zend_Http_Client_Adapter_Curl';
             $config['curloptions'] = array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false);
         }
         $client = new Zend_Http_Client($url, $config);
         $client->setMethod(Zend_Http_Client::POST);
         $client->setParameterPost($params);
         $client->setConfig(array('timeout' => 60, 'keepalive' => true));
         $body = null;
         $outputMessage = 'could not reach web per http';
         try {
             $response = $client->request();
             $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
             $body = $response->getBody();
             $outputMessage = $body;
         } catch (Exception $e) {
             $result = false;
         }
         $url2 = null;
         if (!$result && isset($d['alternative'])) {
             $url2 = "{$urlPart}{$d['alternative']}{$baseUrl}/kwf/util/apc/{$method}";
             $client = new Zend_Http_Client($url2, $config);
             $client->setMethod(Zend_Http_Client::POST);
             $client->setParameterPost($params);
             try {
                 $response = $client->request();
                 $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
                 $body = $response->getBody();
                 $outputMessage = $body;
             } catch (Exception $e) {
                 $result = false;
             }
         }
         if (isset($options['outputFn'])) {
             $outputUrl = $url;
             if ($url2) {
                 $outputUrl .= " / {$url2}";
             }
             $time = round((microtime(true) - $s) * 1000);
             if ($result) {
                 call_user_func($options['outputFn'], "{$outputUrl} ({$time}ms) {$outputMessage} ");
             } else {
                 call_user_func($options['outputFn'], "error: {$outputType} {$outputUrl} {$outputMessage}\n\n");
             }
         }
     }
     if (isset($options['returnBody']) && $options['returnBody']) {
         return $body;
     } else {
         return $result;
     }
 }
コード例 #5
0
 private function _getAbsoluteUrl($url)
 {
     if ($url && substr($url, 0, 1) == '/' && substr($url, 0, 2) != '//') {
         //can already be absolute, due to Event_CreateMediaUrl (eg. varnish cache)
         $domain = $this->getData()->getDomain();
         $protocol = Kwf_Util_Https::domainSupportsHttps($domain) ? 'https' : 'http';
         $url = "{$protocol}://{$domain}{$url}";
     }
     return $url;
 }
コード例 #6
0
 /**
  * Returns absolute url including domain and protocol (http://)
  *
  * @return string
  */
 public function getAbsoluteUrl()
 {
     $https = Kwf_Util_Https::domainSupportsHttps($this->getDomain());
     $protocol = $https ? 'https' : 'http';
     return $protocol . '://' . $this->getDomain() . $this->url;
 }
コード例 #7
0
 /**
  * Gibt den personalisierten HTML-Quelltext der Mail zurück
  */
 public function getHtml(Kwc_Mail_Recipient_Interface $recipient = null, $addViewTracker = false)
 {
     $renderer = new Kwf_Component_Renderer_Mail();
     $renderer->setRenderFormat(Kwf_Component_Renderer_Mail::RENDER_HTML);
     $renderer->setRecipient($recipient);
     $renderer->setHtmlStyles($this->getHtmlStyles());
     $ret = $renderer->renderComponent($this->getData());
     Kwf_Benchmark::checkpoint('html: render');
     $ret = $this->_processPlaceholder($ret, $recipient);
     Kwf_Benchmark::checkpoint('html: placeholder');
     $redirectComponent = $this->getData()->getChildComponent('_redirect');
     if ($redirectComponent) {
         $redirectComponent = $redirectComponent->getComponent();
         $ret = $redirectComponent->replaceLinks($ret, $recipient);
     }
     Kwf_Benchmark::checkpoint('html: replaceLinks');
     if ($addViewTracker && $this->_getSetting('trackViews')) {
         $params = array();
         if ($recipient->id) {
             $params['recipientId'] = urlencode($recipient->id);
         }
         if ($shortcut = $redirectComponent->getRecipientModelShortcut(get_class($recipient->getModel()))) {
             $params['recipientModelShortcut'] = urlencode($shortcut);
         }
         $https = Kwf_Util_Https::domainSupportsHttps($this->getData()->getDomain());
         $protocol = $https ? 'https' : 'http';
         $imgUrl = $protocol . '://' . $this->getData()->getDomain() . Kwf_Media::getUrl($this->getData()->componentClass, $this->getData()->componentId, 'views', 'blank.gif');
         $imgUrl .= '?' . http_build_query($params);
         $ret .= '<img src="' . $imgUrl . '" width="1" height="1" />';
         Kwf_Benchmark::checkpoint('html: view tracker');
     }
     $ret = ltrim($this->_getSetting('docType') . "\n" . $ret);
     return $ret;
 }
コード例 #8
0
ファイル: Model.php プロジェクト: nsams/koala-framework
 public function getUserLoginUrl($row)
 {
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Registry::get('config')->server->domain;
     }
     $url = Kwf_Controller_Front_Component::getInstance()->getWebRouter()->getRoute('admin')->assemble(array('module' => 'index', 'controller' => 'index', 'action' => 'index'));
     $ret = (Kwf_Util_Https::domainSupportsHttps($host) ? 'https' : 'http') . '://' . $host . '/' . $url;
     $root = Kwf_Component_Data_Root::getInstance();
     if ($root && $this->_allowFrontendUrls($row)) {
         $component = $root->getComponentByClass('Kwc_User_Login_Component', array('limit' => 1));
         if ($component) {
             $ret = $component->getAbsoluteUrl(true);
         }
     }
     return $ret;
 }
コード例 #9
0
 /**
  * Returns preview url
  *
  * @return string
  */
 public function getPreviewUrl()
 {
     if ($domain = $this->getBaseProperty('preliminaryDomain')) {
         $https = Kwf_Util_Https::domainSupportsHttps($domain);
         $protocol = $https ? 'https' : 'http';
         $url = $protocol . '://' . $domain . $this->url;
     } else {
         $url = $this->getAbsoluteUrl();
     }
     return Kwf_Setup::getBaseUrl() . '/admin/component/preview/?url=' . urlencode($url . '?kwcPreview');
 }
コード例 #10
0
ファイル: Data.php プロジェクト: nsams/koala-framework
 /**
  * Returns absolute url including domain and protocol (http://)
  *
  * @return string
  */
 public function getAbsoluteUrl($useHttps = false)
 {
     $https = Kwf_Util_Https::domainSupportsHttps($this->getDomain());
     if ($https && !$useHttps) {
         //if component requests https use it even if $useHttps is false
         $https = Kwf_Util_Https::doesComponentRequestHttps($this);
     }
     $protocol = $https ? 'https' : 'http';
     return $protocol . '://' . $this->getDomain() . $this->url;
 }