static function bootstrapStage2() { /* Initialise une installation existante (avec Wtk, styles, etc.). */ require_once 'Wtk.php'; Wtk::init(); Wtk_Document_Style::$path = array(Strass::getPrefix() . 'static/styles/', 'data/styles/'); Wtk_Document_Style::$basestyle = Strass::getPrefix() . 'static/styles/strass/'; }
public function routeStartup(Zend_Controller_Request_Abstract $request) { if (Strass::onDevelopment()) { $level = E_ALL & ~(E_STRICT | E_DEPRECATED); ini_set('display_errors', 1); } else { $level = 0; ini_set('display_errors', 0); } Orror::init($level, array($this, 'errorHandler'), array($this, 'kill'), false); }
function _preRender($controller) { $config = Zend_Registry::get('config'); $page = Zend_Registry::get('page'); /* création du document, widget racine */ $request = $controller->getRequest(); $cn = strtolower($request->getControllerName()); $an = strtolower($request->getActionName()); $mn = strtolower($request->getModuleName()); $association = $config->get('system/association'); $view = $controller->view; $document = new Wtk_Document($page->metas); $document->sitemap = '/sitemap'; $document->addFlags($mn, $cn, $an); $style = $config->get('system/style', 'joubert'); try { $document->setStyle(Wtk_Document_Style::factory($style)); } catch (Wtk_Document_Style_NotFound $e) { error_log("Style " . $style . " inconnu."); } $document->addStyleComponents('layout', 'common', $cn, $mn, $association); if ($view->unite) { $unite = $view->unite; } else { try { $t = new Unites(); $unite = $t->findRacine(); } catch (Exception $e) { $unite = null; } } if ($unite) { $document->addFlags($unite->slug, $unite->findParentTypesUnite()->slug); } $document->addFlags(Strass::onDevelopment() ? 'development' : 'production'); $document->addFlags($association); $document->header->addFlags($association); $document->footer->addSection('wrapper'); $link = new Wtk_Link('/', $page->metas->site); $document->header->setTitle($link); foreach ($page->formats as $format) { if ($format->suffix != $this->suffix) { $document->addAlternative($controller->view->url(array('format' => $format->suffix)), $format->title, $format->mimeType); } } $view->page = $page; $view->document = $document; }
function offline() { if (file_exists('cache')) { rename('cache', 'private/cache'); } // config Zend_Registry::set('config_basedir', 'config/'); $config = array(); $tmp = new Strass_Config_Php('knema/db'); $newpath = 'private/strass.sqlite'; rename($tmp->config->dbname, $newpath); $tmp->config->dbname = $newpath; $config['db'] = $tmp->toArray(); $tmp = new Strass_Config_Php('knema/site'); $config['site'] = $tmp->toArray(); $tmp = new Strass_Config_Php('strass/inscription'); $config['inscription'] = $tmp->toArray(); $tmp = new Strass_Config_Php('knema/menu'); $config['menu'] = $tmp->toArray(); Zend_Registry::set('config_basedir', 'private/config/'); $config = new Strass_Config_Php('strass', $config); $config->write(); // Renommages rename("resources/styles/" . $config->site->style, "data/styles/" . $config->site->style); shell_exec("rsync -av data/statiques/ private/statiques/"); self::rrmdir('data/statiques'); rename("private/statiques/strass/unites", "private/unites"); rename("data/images/strass/unites/", "data/unites"); rename("data/images/strass/photos/", "data/photos"); rename("data/images/strass/individus/", "data/avatars/"); rename("data/images/strass/journaux/", "data/journaux"); rename("data/intro.wiki", "private/unites/intro.wiki"); // Nettoyages @unlink('resources/templates/.htaccess'); self::rrmdir('resources/'); @unlink('config/.htaccess'); self::rrmdir('config/'); @unlink('data/db/.htaccess'); self::rrmdir('data/db/'); self::rrmdir('data/images/'); self::rrmdir('private/statiques/strass'); @self::rrmdir('private/statiques/scout'); Strass::setInstalled(); }
function run() { $this->writeConfig(); $this->initDb(); $this->initAdmin(); $logger = new Strass_Logger('installeur'); $logger->info("Installation terminée"); Strass::setInstalled(); }
<?php /*-*- php -*-*/ $paths = explode(':', get_include_path()); array_shift($paths); array_unshift($paths, '.', dirname(__FILE__) . '/include'); set_include_path(implode(':', $paths)); require_once 'Strass.php'; return Strass::main();
function postDispatch() { $format = $this->_getParam('format'); $page = Zend_Registry::get('page'); if (!in_array($format, $this->_formats)) { $format = 'html'; } //throw new Strass_Controller_Action_Exception("Ce document n'est pas disponible dans ce format."); $available_formats = (require Strass::getPrefix() . 'include/Strass/formats.php'); foreach ($available_formats as $name) { if (!($f = Strass_Format::factory($name))) { continue; } if (in_array($f->suffix, $this->_formats)) { $page->addFormat($f); } } // choper le format actuel $page->selectFormat($format); $this->viewSuffix = $page->format->viewSuffix . '.php'; $response = $this->getResponse(); // rendu effectif du document. $output = $page->format->render($this); $response->setHeader('Content-Type', $page->format->mimeType . '; charset=utf-8'); if ($page->format->download) { $filename = $page->format->getFilename($this->view); $response->setHeader('Content-Disposition', 'attachment; filename=' . urlencode($filename)); } $response->appendBody($output); }
<?php $_ENV['STRASS_UNIT_TEST'] = 1; putenv('STRASS_UNIT_TEST=1'); $paths = explode(':', get_include_path()); array_shift($paths); array_unshift($paths, '.', dirname(dirname(__FILE__)) . '/../include'); set_include_path(implode(':', $paths)); require_once 'Strass.php'; require_once 'Orror.php'; chdir(realpath(getenv('STRASS_ROOT'))); Strass::bootstrap(); Orror::init(E_ALL | E_STRICT); Strass_Cache::setup(); Strass_Db::setup(); Zend_Registry::set('config', new Zend_Config(array(), true));
$aide->addParagraph("Si vous êtes inscrit, identifiez-vous. Sinon, ", $this->lien(array('controller' => 'membres', 'action' => 'inscription'), "inscrivez-vous", true), "."); } } else { if ($error instanceof Strass_Controller_Action_Exception) { $dialog->title = $titre = $error->getMessage(); $aide->addText($error->aide); } else { if ($this->response->getHttpResponseCode() == 404) { $dialog->title = $titre = "Page inexistante !"; } else { if ($i == 0) { $dialog->title = "Bug !"; $titre = null; $dialog->addFlags('bug'); $aide->addText("Désolé pour la gêne occasionée. " . "Le bug est enregistré dans le journal et nous ferons notre possible " . "pour le corriger. //En attendant, essayez de le contourner !//"); if (Strass::onDevelopment()) { $dialog->addFlags('showtrace'); } } } } } $section = $details->addSection(null, $titre)->addFlags('error'); $section->addText("{{" . get_class($error) . "}}: // " . $error->getMessage() . " // \n"); $section->addText("à {{" . $error->getFile() . ":" . $error->getLine() . "}}\n"); $backtrace = $section->addSection("backtrace" . $i, "Backtrace")->addFlags('trace'); $list = $backtrace->addList()->setOrdered()->setReversed(); foreach ($error->getTrace() as $step) { extract($step); $list->addItem()->addText("{{" . (isset($file) ? $file . ":" . $line . " " : "") . " " . (isset($class) ? $class . "::" : "") . $step['function'] . "}}"); }