/** * 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."); }
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; } } }