diff options
author | Egor <egor.26.93@gmail.com> | 2015-06-12 16:06:06 +0300 |
---|---|---|
committer | Egor <egor.26.93@gmail.com> | 2015-06-12 16:06:06 +0300 |
commit | 9abd184a386a2594398df9f5cd7bd6d5b9c240fc (patch) | |
tree | 6b237196dd4ae8bdee61093308f5c3dcdcc5c79e /codebase/Dhtmlx/Connector/Tools | |
parent | 5fbd0adda5155853e86001fad4c571008f09f01b (diff) | |
download | connector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.zip connector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.tar.gz connector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.tar.bz2 |
Updated structure. Added connectors.
Diffstat (limited to 'codebase/Dhtmlx/Connector/Tools')
-rw-r--r-- | codebase/Dhtmlx/Connector/Tools/AccessMaster.php | 3 | ||||
-rw-r--r-- | codebase/Dhtmlx/Connector/Tools/ConvertService.php | 69 | ||||
-rw-r--r-- | codebase/Dhtmlx/Connector/Tools/EventMaster.php | 5 | ||||
-rwxr-xr-x | codebase/Dhtmlx/Connector/Tools/LogMaster.php | 4 |
4 files changed, 76 insertions, 5 deletions
diff --git a/codebase/Dhtmlx/Connector/Tools/AccessMaster.php b/codebase/Dhtmlx/Connector/Tools/AccessMaster.php index ce47c6f..032ce69 100644 --- a/codebase/Dhtmlx/Connector/Tools/AccessMaster.php +++ b/codebase/Dhtmlx/Connector/Tools/AccessMaster.php @@ -1,8 +1,9 @@ <?php namespace Dhtmlx\Connector\Tools; + /*! Class which handles access rules. **/ -class AccessMaster{ +class AccessMaster { private $rules,$local; /*! constructor diff --git a/codebase/Dhtmlx/Connector/Tools/ConvertService.php b/codebase/Dhtmlx/Connector/Tools/ConvertService.php new file mode 100644 index 0000000..698d2be --- /dev/null +++ b/codebase/Dhtmlx/Connector/Tools/ConvertService.php @@ -0,0 +1,69 @@ +<?php +namespace Dhtmlx\Connector\Tools; + +/* + @author dhtmlx.com + @license GPL, see license.txt +*/ +class ConvertService { + private $url; + private $type; + private $name; + private $inline; + + public function __construct($url){ + $this->url = $url; + $this->pdf(); + EventMaster::attach_static("connectorInit",array($this, "handle")); + } + public function pdf($name = "data.pdf", $inline = false){ + $this->type = "pdf"; + $this->name = $name; + $this->inline = $inline; + } + public function excel($name = "data.xls", $inline = false){ + $this->type = "excel"; + $this->name = $name; + $this->inline = $inline; + } + public function handle($conn){ + $conn->event->attach("beforeOutput",array($this,"convert")); + } + private function as_file($size, $name, $inline){ + header('Content-Type: application/force-download'); + header('Content-Type: application/octet-stream'); + header('Content-Type: application/download'); + header('Content-Transfer-Encoding: binary'); + + header('Content-Length: '.$size); + if ($inline) + header('Content-Disposition: inline; filename="'.$name.'";'); + else + header('Content-Disposition: attachment; filename="'.basename($name).'";'); + } + public function convert($conn, $out){ + + $str_out = str_replace("<rows>","<rows profile='color'>", $out); + $str_out = str_replace("<head>","<head><columns>", $str_out); + $str_out = str_replace("</head>","</columns></head>", $str_out); + + if ($this->type == "pdf") + header("Content-type: application/pdf"); + else + header("Content-type: application/ms-excel"); + + $handle = curl_init($this->url); + curl_setopt($handle, CURLOPT_POST, true); + curl_setopt($handle, CURLOPT_HEADER, false); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handle, CURLOPT_POSTFIELDS, "grid_xml=".urlencode($str_out)); + + + $out->reset(); + $out->set_type("pdf"); + $out->add(curl_exec($handle)); + $this->as_file(strlen((string)$out), $this->name, $this->inline); + + curl_close($handle); + } +}
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/Tools/EventMaster.php b/codebase/Dhtmlx/Connector/Tools/EventMaster.php index d4c6c50..8a0e411 100644 --- a/codebase/Dhtmlx/Connector/Tools/EventMaster.php +++ b/codebase/Dhtmlx/Connector/Tools/EventMaster.php @@ -1,9 +1,10 @@ <?php - namespace Dhtmlx\Connector\Tools; +use \Exception; + /*! Class which allows to assign|fire events. */ -class EventMaster{ +class EventMaster { private $events;//!< hash of event handlers private $master; private static $eventsStatic=array(); diff --git a/codebase/Dhtmlx/Connector/Tools/LogMaster.php b/codebase/Dhtmlx/Connector/Tools/LogMaster.php index da4dd69..107f7d7 100755 --- a/codebase/Dhtmlx/Connector/Tools/LogMaster.php +++ b/codebase/Dhtmlx/Connector/Tools/LogMaster.php @@ -1,10 +1,10 @@ <?php - namespace Dhtmlx\Connector\Tools; + /*! Controls error and debug logging. Class designed to be used as static object. **/ -class LogMaster{ +class LogMaster { private static $_log=false;//!< logging mode flag private static $_output=false;//!< output error infor to client flag private static $session="";//!< all messages generated for current request |