Esempio n. 1
0
 /**
  *
  * @param string $adapter
  * @param mixed $config
  * @return Taplod_Db_Adapter_Abstract
  */
 public static function factory($adapter, $config = array())
 {
     if ($config instanceof Taplod_Config) {
         $config = $config->toArray();
     }
     if (!is_array($config)) {
         require_once 'Taplod/Db/Exception.php';
         throw new Taplod_Db_Exception('Adapter parameters must be in an array');
     }
     if (!is_string($adapter) || empty($adapter)) {
         /**
          * @see Taplod_Db_Exception
          */
         require_once 'Taplod/Db/Exception.php';
         throw new Taplod_Db_Exception('Adapter name must be specified in a string');
     }
     $adapterNamespace = 'Taplod_Db_Adapter';
     if (isset($config['adapterNamespace'])) {
         $adapterNamespace = $config['adapterNamespace'];
     }
     $adapterName = $adapterNamespace . '_' . $adapter;
     Taplod_Loader::loadClass($adapterName);
     $dbAdapter = new $adapterName($config);
     if (!$dbAdapter instanceof Taplod_Db_Adapter_Abstract) {
         require_once 'Db/Exception.php';
         throw new Taplod_Db_Exception("Adapter Class '{$adapterName}' does not extend Taplod_Db_Adapter_Abstract");
     }
     return $dbAdapter;
 }
Esempio n. 2
0
 /**
  * Vérifie l'existance d'un fichier et l'inclus
  *
  * @param string $filename
  * @return void
  */
 public static function loadFile($filename)
 {
     $filename = trim($filename);
     if (Taplod_Loader::fileExists($filename)) {
         try {
             include_once $filename;
         } catch (exception $e) {
             echo "error";
             die($e->getMessage());
         }
         return;
     }
     require_once 'Taplod/Exception.php';
     throw new Taplod_Exception("File '{$filename}' was not found.");
 }
Esempio n. 3
0
 public function __construct($data = 'pages.csv', $datatype = 'csv')
 {
     if ($data instanceof Taplod_Config) {
         $data = $data->toArray();
         foreach ($data as $pageName => $labelData) {
             $parentLabel = '';
             if (isset($labelData['parentLabel'])) {
                 $parentLabel = $labelData['parentLabel'];
             }
         }
     } elseif (!is_array($data)) {
         switch ($datatype) {
             case 'csv':
                 if (Taplod_Loader::fileExists($data)) {
                     $this->_use_include_path = true;
                     $pageDataPath = '';
                 } else {
                     if (!defined('APPLICATION_PATH')) {
                         trigger_error('Application path not found, please define it.', E_USER_WARNING);
                         return false;
                     }
                     $pageDataPath = realpath(APPLICATION_PATH . '../') . '/';
                     if (Loader::fileExists($pageDataPath . $data)) {
                         throw new Taplod_Exception("{$pageDataPath}/{$data} doesn't exists.");
                     }
                 }
                 $h = fopen($pageDataPath . $data, 'r', $this->_use_include_path);
                 if ($h !== false) {
                     while (($data = fgetcsv($h, 1024, ';')) !== false) {
                         $parentLabel = '';
                         if (isset($data[2])) {
                             $parentLabel = $data[2];
                         }
                         self::__set($data[0], array('label' => $data[1], 'parentLabel' => $parentLabel));
                     }
                     fclose($h);
                 } else {
                     die('erro.');
                 }
                 break;
             case 'sqlite':
                 break;
         }
     }
 }
Esempio n. 4
0
<?php

/**
 * @category Ayaq
 * @copyright Copyright (c) 2009, Bellière Ludovic
 * @license http://opensource.org/licenses/mit-license.php MIT license
 */
error_reporting(E_ALL);
session_name('zombie_quizz');
session_start();
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
set_include_path(realpath(APPLICATION_PATH . '/../inc') . PATH_SEPARATOR . get_include_path());
require_once 'functions.php';
require_once 'Taplod/Loader.php';
Taplod_Loader::registerAutoload();
$config = new Taplod_Config(require '../config.php');
Taplod_ObjectCache::set('config', $config);
try {
    require APPLICATION_PATH . '/bootstrap.php';
} catch (Exception $exception) {
    echo '<html><body><center>' . 'An exception occured while bootstrapping the application.';
    if (defined('APPLICATION_ENVIRONMENT') && APPLICATION_ENVIRONMENT != 'production') {
        echo '<br /><br />' . $exception->getMessage() . '<br />' . '<div align="left">Stack Trace:' . '<pre>' . $exception->getTraceAsString() . '</pre></div>';
        if ($exception instanceof Taplod_Db_Exception) {
            $trace = $exception->getTrace();
            echo '<div align="left">Query Trace:' . '<pre>' . $trace[0]['args'][0] . '</pre></div>';
        }
    }
    echo '</center></body></html>';
    exit(1);
}
Esempio n. 5
0
 public function getHelper($name)
 {
     $name = ucfirst($name);
     $prefix = 'Taplod_Templates_Helper';
     $prefix_path = 'Taplod/Templates/Helper/';
     if (!array_key_exists($name, $this->_helpers)) {
         $file = $prefix . '_' . $name;
         try {
             Taplod_Loader::loadClass($file);
         } catch (Taplod_Exception $exception) {
             require_once 'Taplod/Templates/Exception.php';
             throw new Taplod_Templates_Exception("Cannot load '{$name}' helper.<br/>" . $exception->getMessage());
         }
         $this->_helpers[$name] = new $file();
         if (method_exists($this->_helpers[$name], 'setTemplate')) {
             $this->_helpers[$name]->setTemplate($this);
         }
     }
     return $this->_helpers[$name];
 }