Overview
Comment: | Adaptation à la révision de MiniSkel pour permettre les tags imbriqués. Vérification de sécurité à la compilation plutôt qu'à l'exécution. Ajout d'une balise #LANGUE_VISITEUR. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
eb6cca0e56640d2e28583fa34c5c0e08 |
User & Date: | bohwaz on 2015-01-20 06:29:59 |
Other Links: | manifest | tags |
Context
2015-01-23
| ||
03:49 | Utiliser des signaux génériques pour les boucles de squelettes, plutôt que des hooks spécifiques. Si besoin on mettra ensuite en place un cache statique des associations pour ne pas taper dans SQLite à chaque fois qu'on veut savoir si un signal est associé à qq chose. check-in: 10409a3353 user: bohwaz tags: trunk | |
2015-01-20
| ||
06:29 | Adaptation à la révision de MiniSkel pour permettre les tags imbriqués. Vérification de sécurité à la compilation plutôt qu'à l'exécution. Ajout d'une balise #LANGUE_VISITEUR. check-in: eb6cca0e56 user: bohwaz tags: trunk | |
2015-01-18
| ||
07:10 | Correction pour sous-pages avec {parent} check-in: 88c2588e64 user: bohwaz tags: trunk | |
Changes
Modified src/include/lib/Garradin/Squelette.php from [d09cf367fb] to [1cd05c6913].
︙ | ︙ | |||
195 196 197 198 199 200 201 | if (file_exists(DATA_ROOT . '/www/squelettes/mes_filtres.php')) { require_once DATA_ROOT . '/www/squelettes/mes_filtres.php'; } } | < < | | > > > > > > > > > > > > | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | if (file_exists(DATA_ROOT . '/www/squelettes/mes_filtres.php')) { require_once DATA_ROOT . '/www/squelettes/mes_filtres.php'; } } private function _registerDefaultTags() { $config = Config::getInstance(); $this->assign('nom_asso', $config->get('nom_asso')); $this->assign('adresse_asso', $config->get('adresse_asso')); $this->assign('email_asso', $config->get('email_asso')); $this->assign('site_asso', $config->get('site_asso')); $this->assign('url_racine', WWW_URL); $this->assign('url_site', WWW_URL); $this->assign('url_atom', WWW_URL . 'feed/atom/'); $this->assign('url_elements', WWW_URL . 'squelettes/'); $this->assign('url_admin', WWW_URL . 'admin/'); $lang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? preg_replace('/^.*(\w{2}).*$/U', '$1', $_SERVER['HTTP_ACCEPT_LANGUAGE']) : ''; $this->assign('langue_visiteur', $lang); } public function __construct() { $this->_registerDefaultModifiers(); $this->_registerDefaultTags(); } protected function processInclude($args) { if (empty($args)) throw new \KD2\MiniSkelMarkupException("Le tag INCLURE demande à préciser le fichier à inclure."); $file = key($args); if (empty($file) || !preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $file)) throw new \KD2\MiniSkelMarkupException("INCLURE: le nom de fichier ne peut contenir que des caractères alphanumériques."); return new Squelette_Snippet(1, '$this->fetch("'.$file.'", false);'); } protected function processVariable($name, $applyDefault, $modifiers, $pre, $post, $context) { if ($context == self::CONTEXT_IN_ARG) { $out = new Squelette_Snippet(1, '$this->getVariable(\''.$name.'\')'); if ($pre) { |
︙ | ︙ | |||
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | return $out; } protected function processLoop($loopName, $loopType, $loopCriterias, $loopContent, $preContent, $postContent, $altContent) { $query = $loopStart = ''; $query_args = []; // Types de boucles natifs if ($loopType == 'articles' || $loopType == 'rubriques' || $loopType == 'pages') { $where = $order = ''; $limit = $begin = 0; $query = 'SELECT w.*, '; | > | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | return $out; } protected function processLoop($loopName, $loopType, $loopCriterias, $loopContent, $preContent, $postContent, $altContent) { $query = $loopStart = ''; $query_args = []; $db = DB::getInstance(); // Types de boucles natifs if ($loopType == 'articles' || $loopType == 'rubriques' || $loopType == 'pages') { $where = $order = ''; $limit = $begin = 0; $query = 'SELECT w.*, '; $query.= 'strftime(\'%s\', w.date_creation) AS date_creation, '; $query.= 'strftime(\'%s\', w.date_modification) AS date_modification'; if (trim($loopContent)) { $query .= ', r.contenu AS texte FROM wiki_pages AS w LEFT JOIN wiki_revisions AS r ON (w.id = r.id_page AND w.revision = r.revision) '; } else { |
︙ | ︙ | |||
444 445 446 447 448 449 450 | $query .= $where . ' ' . $order; if (!$limit || $limit > 100) $limit = 100; if ($limit) { | > > > > > > > > > | > > > < < | 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | $query .= $where . ' ' . $order; if (!$limit || $limit > 100) $limit = 100; if ($limit) { $query .= ' LIMIT '; if (is_numeric($begin)) { $query .= (int) $begin; } else { $query .= '?'; $query_args[] = ['\'.$this->variables[\'debut_liste\'].\'']; } $query .= ','.(int)$limit; } } else { // Type de boucles gérés par des plugins if ($plugin = $db->simpleQuerySingle('SELECT plugin FROM plugins_skel_boucles WHERE nom = ? LIMIT 1;', false, $loopType)) { $plugin = new \Garradin\Plugin($plugin); if (!file_exists($plugin->path() . '/skel_loop.php')) { |
︙ | ︙ | |||
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | } if (empty($query)) { $query = 'SELECT 0 LIMIT 0;'; } } $hash = sha1(uniqid(mt_rand(), true)); $out = new Squelette_Snippet(); $out->append(1, '$parent_hash = $this->current[\'_self_hash\'];'); $out->append(1, '$this->parent =& $parent_hash ? $this->_vars[$parent_hash] : null;'); if (!empty($search)) { $out->append(1, 'if (trim($this->getVariable(\'recherche\'))) { '); } | > > > > > > > > | < < | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | } if (empty($query)) { $query = 'SELECT 0 LIMIT 0;'; } } // Sécurité anti injection, à la compilation seulement $statement = $db->prepare($query); if (!$statement->readOnly()) { throw new \KD2\MiniSkelMarkupException("Requête en écriture illégale: '.$query.'"); } $hash = sha1(uniqid(mt_rand(), true)); $out = new Squelette_Snippet(); $out->append(1, '$parent_hash = $this->current[\'_self_hash\'];'); $out->append(1, '$this->parent =& $parent_hash ? $this->_vars[$parent_hash] : null;'); if (!empty($search)) { $out->append(1, 'if (trim($this->getVariable(\'recherche\'))) { '); } $out->append(1, '$statement = $db->prepare('.var_export($query, true).'); '); foreach ($query_args as $k=>$arg) { $out->append(1, '$value = ' . (is_array($arg) ? $arg[0] : var_export($arg, true)) . ';'); $out->append(1, '$statement->bindValue(' . ($k+1) . ', $value, $db->getArgType($value));'); } |
︙ | ︙ | |||
562 563 564 565 566 567 568 | if (!file_exists($path)) { throw new \KD2\MiniSkelMarkupException('Le squelette "'.$tpl_id.'" n\'existe pas.'); } $content = file_get_contents($path); $content = strtr($content, ['<?php' => '<?php', '<?' => '<?php echo \'<?\'; ?>']); | < > | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | if (!file_exists($path)) { throw new \KD2\MiniSkelMarkupException('Le squelette "'.$tpl_id.'" n\'existe pas.'); } $content = file_get_contents($path); $content = strtr($content, ['<?php' => '<?php', '<?' => '<?php echo \'<?\'; ?>']); $out = new Squelette_Snippet(2, $this->parse($content)); $out->prepend(1, '/* '.$tpl_id.' */ '. 'namespace Garradin; $db = DB::getInstance(); '. 'if ($this->parent) $parent_hash = $this->parent[\'_self_hash\']; '. // For included files 'else $parent_hash = false;'); if (!$no_display) { self::compile_store($tpl_id, $out); } } if (!$no_display) { require self::compile_get_path($tpl_id); } else { |
︙ | ︙ |