コード例 #1
0
ファイル: HtmlToPdf.php プロジェクト: bartlewis/code-samples
 /**
  * Initialize the module.
  *
  * Make sure required params are in the application.xml and perform garbage
  * collection.
  *
  * @param TXmlElement
  */
 public function init($config)
 {
     parent::init($config);
     if (!$this->getEnabled()) {
         return;
     }
     if (!$this->getScratchDirectory()) {
         throw new TConfigurationException('Missing param: ScratchDirectory');
     }
     if (!$this->getScript()) {
         throw new TConfigurationException('Missing param: Script');
     }
     //Clean out old files in scratch directory 1 out of every 100 times.
     if (rand(1, 100) == 100) {
         $scratchDirectory = $this->getScratchDirectory();
         $scratchFiles = array();
         foreach (glob($scratchDirectory . '*-htmltopdf-scratch.pdf') as $file) {
             $scratchFiles[] = $file;
         }
         foreach (glob($scratchDirectory . '*-htmltopdf-scratch.html') as $file) {
             $scratchFiles[] = $file;
         }
         //Delete all scratch files created more than an hour ago.
         foreach ($scratchFiles as $scratchFile) {
             if (filectime($scratchFile) < mktime() - 3600) {
                 unlink($scratchFile);
             }
         }
     }
 }
コード例 #2
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     require "config.php";
     //Set UTF-8 encoding
     mb_internal_encoding('UTF-8');
     $this->Database->setDataSourceName($dsn);
 }
コード例 #3
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     require "config.php";
     //Set UTF-8 encoding
     mb_internal_encoding('UTF-8');
     //This should prevent te removal of multibyte unicode characters with escapeshellarg
     if (false == setlocale(LC_CTYPE, "UTF8", $lang)) {
         die("skip setlocale() failed, unicode characters might fail!\n");
     }
     $this->Database->setDataSourceName($dsn);
 }
コード例 #4
0
 public function init($config)
 {
     if (!$this->_DBHandler) {
         throw new TConfigurationException('You must set DBHandler property!');
     }
     if (!$this->_UserTable) {
         throw new TConfigurationException('You must set UserTable property!');
     }
     if (!$this->_GroupTable) {
         throw new TConfigurationException('You must set GroupTable property!');
     }
     parent::init($config);
 }
コード例 #5
0
 /**
  * Get and set the language setting from/to the cookie.
  * @param TEventParameter event parameter.
  */
 function onLoad($param)
 {
     $app = $this->Application->getGlobalization();
     $cookiename = $this->ID . '_lang';
     if (isset($_COOKIE[$cookiename])) {
         $culture = $_COOKIE[$cookiename];
         if (CultureInfo::validCulture($culture)) {
             $app->Culture = $culture;
         }
     }
     $settings = $this->getSettings();
     $app->Culture = $settings['lang'];
     setcookie($cookiename, $app->Culture, time() + 604800);
     parent::onLoad($param);
 }
コード例 #6
0
 public function init($config)
 {
     parent::init($config);
 }
コード例 #7
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     $this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
 }
コード例 #8
0
ファイル: TRpcService.php プロジェクト: quantrocket/planlogiq
 public function __construct(TRpcServer $rpcServer)
 {
     parent::__construct();
     $this->rpcServer = $rpcServer;
     foreach ($this->registerMethods() as $_methodName => $_methodDetails) {
         $this->rpcServer->addRpcMethod($_methodName, $_methodDetails);
     }
 }
コード例 #9
0
 /**
  * @return string full qualified page name including module name if any.
  */
 public function getPageName()
 {
     return is_null($this->module) ? $this->getID() : $this->module->getID() . ':' . $this->getID();
 }
コード例 #10
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     //$this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
     require "config.php";
     //Set UTF-8 encoding
     mb_internal_encoding('UTF-8');
     $this->Database->setDataSourceName($dsn);
     $this->Database->SetFetchMode("Associative");
     //Some SQL statements don't work with sqlite
     if (strncasecmp($dsn, "sqlite", 6) == 0) {
         $sqlite = true;
     } else {
         $sqlite = false;
     }
     // Get list of all tables in current database
     $tables = $this->Database->MetaTables();
     /*
      ** Array of tables required.
      **  To add a table, add the table name to this array, and
      **  add the CREATE TABLE commands to the switch statement within
      **  the foreach loop below
      */
     $requiredTables = array("groupprivileges", "groups", "repositories", "repo_descriptions", "svnserve_pwd", "userprivileges", "users", "usersgroups", "usertickets");
     /*
      ** 2006-06-07 PDurden - Determine what tables are missing using
      **    array_diff()
      */
     $missingTables = array_diff($requiredTables, $tables);
     $numMissing = count($missingTables);
     if ($numMissing > 0) {
         echo "<pre>\n";
         if ($numMissing == count($requiredTables)) {
             echo "All tables are missing.\n";
         } else {
             if ($numMissing < 2) {
                 echo "There is 1 table missing.\n";
             } else {
                 echo "There are {$numMissing} tables missing.\n";
             }
         }
         echo "Creating requried tables...";
         /*
          ** Iterate though missing tables and create any needed tables.
          */
         foreach ($missingTables as $tableName) {
             $ac = "";
             //auto_increment statement doesn't work with sqlite
             if (!$sqlite) {
                 $ac = " auto_increment";
             }
             //echo "  $tableName\n";
             switch ($tableName) {
                 case "usertickets":
                     $this->Database->Execute("\r\n              CREATE TABLE usertickets (\r\n                  email varchar(128) NOT NULL default '',\r\n                  ticket varchar(32) NOT NULL default '',\r\n                  repositorygrants tinyint(11) NOT NULL default '0'\r\n              );\r\n            ");
                     break;
                 case "usersgroups":
                     //Usersgroups
                     $this->Database->Execute("\r\n              CREATE TABLE usersgroups (\r\n                userid integer default '0',\r\n                groupid integer default '0'\r\n              );\r\n            ");
                     break;
                 case "users":
                     $this->Database->Execute("\r\n              CREATE TABLE users (\r\n                  id integer primary key" . $ac . ",\r\n                  name varchar(32) NOT NULL default '',\r\n                  password varchar(32) NOT NULL default '',\r\n                  email varchar(128) NOT NULL default '',\r\n                  admin integer NOT NULL default '0',\r\n                  repositorygrants tinyint(11) NOT NULL default '0',\r\n                  svnserve_password varchar(32) NOT NULL default ''\r\n              );\r\n            ");
                     break;
                 case "userprivileges":
                     $this->Database->Execute("\r\n              CREATE TABLE userprivileges (\r\n                  id integer primary key" . $ac . ",\r\n                  userid integer NOT NULL default '0',\r\n                  repositoryid integer NOT NULL default '0',\r\n                  access tinyint(4) NOT NULL default '0',\r\n                  path varchar(255) NOT NULL default ''  \t\t\t\t\t\r\n              ); \r\n            ");
                     break;
                 case "svnserve_pwd":
                     $this->Database->Execute("\r\n              CREATE TABLE svnserve_pwd (\r\n                ownerid integer primary key" . $ac . ",\t\t\t\t\t\r\n                password varchar(32) NOT NULL default ''\r\n              );\t\t\t\r\n            ");
                     break;
                 case "groups":
                     //Groups
                     $this->Database->Execute("\r\n              CREATE TABLE groups (\r\n                id integer primary key" . $ac . ",\r\n                name varchar(32) NOT NULL default '',\r\n                adminid integer NOT NULL default '0'\t\t\t\t\t\t\t\t\t\r\n              );\r\n            ");
                     break;
                 case "groupprivileges":
                     $this->Database->Execute("\r\n              CREATE TABLE groupprivileges (\r\n                id INTEGER PRIMARY KEY" . $ac . ",\r\n                groupid INTEGER NOT NULL DEFAULT '0',\r\n                repositoryid INTEGER NOT NULL DEFAULT '0',\r\n                access TINYINT(4) NOT NULL DEFAULT '0',\r\n                path VARCHAR(255) NOT NULL DEFAULT ''\r\n              );\r\n            ");
                     break;
                 case "repositories":
                     $this->Database->Execute("\r\n              CREATE TABLE repositories (\r\n                id integer  primary key" . $ac . ",\r\n                name varchar(32) NOT NULL default '',\r\n                ownerid integer NOT NULL default '0',\r\n                description varchar(128) NOT NULL default ''\r\n              );\t\t\t\r\n            ");
                     break;
                 case "repo_descriptions":
                     $this->Database->Execute("\r\n              CREATE TABLE repo_descriptions (\r\n                id integer  primary key" . $ac . ",\r\n                repo_id INTEGER NOT NULL DEFAULT '0',\r\n                description varchar(128) NOT NULL default ''\r\n              );\t\t\t\r\n            ");
                     break;
                 default:
                     echo "  ERROR: I do not know how to create \"{$tableName}\" \n";
                     break;
             }
         }
         echo "\n\nPlease reload page!\n</PRE>";
         exit(0);
     }
 }
コード例 #11
0
 /**
  * Override the parent implementation. Initialize the vehicle list.
  */
 public function onLoad($param)
 {
     parent::onLoad($param);
     $this->vehicleList = new RentalVehicles();
 }