From 05fb4cbca4f93ea55d55da3b2e3a7f2f5a174b21 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 31 Jul 2013 20:33:27 -0400 Subject: markup modifiers: there was a plan for adding markup to ban reasons, but assignment was missing; escape markup there too --- inc/mod/ban.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/mod/ban.php b/inc/mod/ban.php index 9166223f..45973ae6 100644 --- a/inc/mod/ban.php +++ b/inc/mod/ban.php @@ -61,7 +61,8 @@ function ban($mask, $reason, $length, $board) { $query->bindValue(':mod', $mod['id']); $query->bindValue(':time', time()); if ($reason !== '') { - markup($reason); + $reason = escape_markup_modifiers($reason); + $reason = markup($reason); $query->bindValue(':reason', $reason); } else $query->bindValue(':reason', null, PDO::PARAM_NULL); -- cgit v1.3 From bc76d934fe30c9a6fcea27678dc155e903eb88c3 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 31 Jul 2013 20:41:56 -0400 Subject: fix previous commit; markup is called via reference --- inc/mod/ban.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/mod/ban.php b/inc/mod/ban.php index 45973ae6..71173326 100644 --- a/inc/mod/ban.php +++ b/inc/mod/ban.php @@ -62,7 +62,7 @@ function ban($mask, $reason, $length, $board) { $query->bindValue(':time', time()); if ($reason !== '') { $reason = escape_markup_modifiers($reason); - $reason = markup($reason); + markup($reason); $query->bindValue(':reason', $reason); } else $query->bindValue(':reason', null, PDO::PARAM_NULL); -- cgit v1.3 From e109d8179fa0e4e34d0191b287b31cbb40414e02 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 1 Aug 2013 01:43:33 -0400 Subject: the prefix work: fix it to be dependent on a board_regex config value --- inc/database.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/database.php b/inc/database.php index 7be001ea..95dfc775 100644 --- a/inc/database.php +++ b/inc/database.php @@ -87,7 +87,7 @@ function mysql_version() { function prepare($query) { global $pdo, $debug, $config; - $query = preg_replace('/``([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)``/u', '`' . $config['db']['prefix'] . '$1`', $query); + $query = preg_replace('/``('.$config['board_regex'].')``/u', '`' . $config['db']['prefix'] . '$1`', $query); sql_open(); @@ -100,7 +100,7 @@ function prepare($query) { function query($query) { global $pdo, $debug, $config; - $query = preg_replace('/``([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)``/u', '`' . $config['db']['prefix'] . '$1`', $query); + $query = preg_replace('/``('.$config['board_regex'].')``/u', '`' . $config['db']['prefix'] . '$1`', $query); sql_open(); -- cgit v1.3 From b9769d0cea205e4ddf831f374901ec8d220ecc7a Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 1 Aug 2013 01:47:15 -0400 Subject: i18n strings in inc/display.php --- inc/display.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/display.php b/inc/display.php index 94f8e8cd..c68af9d6 100644 --- a/inc/display.php +++ b/inc/display.php @@ -72,14 +72,14 @@ function error($message, $priority = true) { die(Element('page.html', array( 'config'=>$config, - 'title'=>'Error', - 'subtitle'=>'An error has occured.', + 'title'=>_('Error'), + 'subtitle'=>_('An error has occured.'), 'body'=>'
' . '

' . _($message) . '

' . (isset($board) ? "

Go back.

" : '') . + $board['dir'] . $config['file_index'] . "\">"._("Go back").".

" : '') . '
' ))); } -- cgit v1.3 From 9769e1f964eee89c2dcf1f585d665bd5e8d77357 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 1 Aug 2013 01:56:04 -0400 Subject: i18n even more strings in inc/display.php --- inc/display.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/inc/display.php b/inc/display.php index c68af9d6..5da2f302 100644 --- a/inc/display.php +++ b/inc/display.php @@ -208,7 +208,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { $body = preg_replace('/&[^;]*$/', '', $body); } - $body .= 'Post too long. Click here to view the full text.'; + $body .= ''.sprintf(_('Post too long. Click here to view the full text.'), $url).''; } return $body; @@ -331,19 +331,19 @@ class Post { // Ban if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_ban'] . ''; + $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_bandelete'] . ''; + $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Delete file (keep post) if (!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) - $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], 'Delete file', 'Are you sure you want to delete this file?', $board['uri'] . '/deletefile/' . $this->id); + $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['uri'] . '/deletefile/' . $this->id); // Edit post if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_editpost'] . ''; + $built .= ' ' . $config['mod']['link_editpost'] . ''; if (!empty($built)) $built = '' . $built . ''; @@ -420,54 +420,54 @@ class Thread { // Mod controls (on posts) // Delete if (hasPermission($config['mod']['delete'], $board['uri'], $this->mod)) - $built .= ' ' . secure_link_confirm($config['mod']['link_delete'], 'Delete', 'Are you sure you want to delete this?', $board['uri'] . '/delete/' . $this->id); + $built .= ' ' . secure_link_confirm($config['mod']['link_delete'], _('Delete'), _('Are you sure you want to delete this?'), $board['uri'] . '/delete/' . $this->id); // Delete all posts by IP if (hasPermission($config['mod']['deletebyip'], $board['uri'], $this->mod)) - $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], 'Delete all posts by IP', 'Are you sure you want to delete all posts by this IP address?', $board['uri'] . '/deletebyip/' . $this->id); + $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], _('Delete all posts by IP'), _('Are you sure you want to delete all posts by this IP address?'), $board['uri'] . '/deletebyip/' . $this->id); // Delete all posts by IP (global) if (hasPermission($config['mod']['deletebyip_global'], $board['uri'], $this->mod)) - $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], 'Delete all posts by IP across all boards', 'Are you sure you want to delete all posts by this IP address, across all boards?', $board['uri'] . '/deletebyip/' . $this->id . '/global'); + $built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], _('Delete all posts by IP across all boards'), _('Are you sure you want to delete all posts by this IP address, across all boards?'), $board['uri'] . '/deletebyip/' . $this->id . '/global'); // Ban if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_ban'] . ''; + $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_bandelete'] . ''; + $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Delete file (keep post) if (!empty($this->file) && $this->file != 'deleted' && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) - $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], 'Delete file', 'Are you sure you want to delete this file?', $board['uri'] . '/deletefile/' . $this->id); + $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['uri'] . '/deletefile/' . $this->id); // Sticky if (hasPermission($config['mod']['sticky'], $board['uri'], $this->mod)) if ($this->sticky) - $built .= ' ' . $config['mod']['link_desticky'] . ''; + $built .= ' ' . $config['mod']['link_desticky'] . ''; else - $built .= ' ' . $config['mod']['link_sticky'] . ''; + $built .= ' ' . $config['mod']['link_sticky'] . ''; if (hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod)) if ($this->bumplocked) - $built .= ' ' . $config['mod']['link_bumpunlock'] . ''; + $built .= ' ' . $config['mod']['link_bumpunlock'] . ''; else - $built .= ' ' . $config['mod']['link_bumplock'] . ''; + $built .= ' ' . $config['mod']['link_bumplock'] . ''; // Lock if (hasPermission($config['mod']['lock'], $board['uri'], $this->mod)) if ($this->locked) - $built .= ' ' . $config['mod']['link_unlock'] . ''; + $built .= ' ' . $config['mod']['link_unlock'] . ''; else - $built .= ' ' . $config['mod']['link_lock'] . ''; + $built .= ' ' . $config['mod']['link_lock'] . ''; if (hasPermission($config['mod']['move'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_move'] . ''; + $built .= ' ' . $config['mod']['link_move'] . ''; // Edit post if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod)) - $built .= ' ' . $config['mod']['link_editpost'] . ''; + $built .= ' ' . $config['mod']['link_editpost'] . ''; if (!empty($built)) $built = '' . $built . ''; -- cgit v1.3 From 6c2887ba9f3d20f23015e1a34e5170d219d5e648 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 1 Aug 2013 02:06:34 -0400 Subject: Update Polish locale --- inc/locale/pl_PL/LC_MESSAGES/javascript.po | 3 +- inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo | Bin 19840 -> 20956 bytes inc/locale/pl_PL/LC_MESSAGES/tinyboard.po | 269 +++++++++++++++++++---------- 3 files changed, 181 insertions(+), 91 deletions(-) diff --git a/inc/locale/pl_PL/LC_MESSAGES/javascript.po b/inc/locale/pl_PL/LC_MESSAGES/javascript.po index 482ec45f..ae1bb5c9 100644 --- a/inc/locale/pl_PL/LC_MESSAGES/javascript.po +++ b/inc/locale/pl_PL/LC_MESSAGES/javascript.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-27 01:54-0400\n" +"POT-Creation-Date: 2013-08-01 01:58-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,6 +42,7 @@ msgid "Click to expand" msgstr "Kliknij aby rozwinąć" #: ../../../../js/expand.js:41 ../../../../js/expand.js:45 +#: ../../../../js/expand.js:43 msgid "Hide expanded replies" msgstr "Schowaj rozwinięte odpowiedzi" diff --git a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo index bc603e67..73f434f7 100644 Binary files a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo and b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo differ diff --git a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po index 20802b7d..8a46fda9 100644 --- a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po +++ b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-27 01:54-0400\n" +"POT-Creation-Date: 2013-08-01 01:58-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -24,6 +24,7 @@ msgstr "" #: ../../../../inc/functions.php:1041 ../../../../inc/functions.php:1055 #: ../../../../inc/functions.php:1039 ../../../../inc/functions.php:1053 #: ../../../../inc/functions.php:1068 ../../../../inc/functions.php:1082 +#: ../../../../inc/functions.php:1079 ../../../../inc/functions.php:1093 msgid "Previous" msgstr "Wstecz" @@ -33,6 +34,7 @@ msgstr "Wstecz" #: ../../../../inc/functions.php:1060 ../../../../inc/functions.php:1069 #: ../../../../inc/functions.php:1058 ../../../../inc/functions.php:1067 #: ../../../../inc/functions.php:1087 ../../../../inc/functions.php:1096 +#: ../../../../inc/functions.php:1098 ../../../../inc/functions.php:1107 msgid "Next" msgstr "Dalej" @@ -57,6 +59,7 @@ msgid "all boards" msgstr "wszystkie boardy" #: /var/www/html/Tinyboard/inc/config.php:305 ../../../../inc/config.php:330 +#: ../../../../inc/config.php:334 msgid "You have been muted for unoriginal content." msgstr "Zostałeś zagłuszony za nieoryginalną treść." @@ -64,11 +67,12 @@ msgstr "Zostałeś zagłuszony za nieoryginalną treść." msgid "Anonymous" msgstr "Anonimowy" -#: /var/www/html/Tinyboard/inc/config.php:481 +#. The names on the post buttons. (On most imageboards, these are both "Post") +#: /var/www/html/Tinyboard/inc/config.php:481 ../../../../inc/config.php:552 msgid "New Topic" msgstr "Nowy wątek" -#: /var/www/html/Tinyboard/inc/config.php:482 +#: /var/www/html/Tinyboard/inc/config.php:482 ../../../../inc/config.php:553 msgid "New Reply" msgstr "Odpowiedz" @@ -84,19 +88,19 @@ msgstr "Szybka odpowiedź" #. Error messages #: /var/www/html/Tinyboard/inc/config.php:600 ../../../../inc/config.php:638 #: ../../../../inc/config.php:692 ../../../../inc/config.php:698 -#: ../../../../inc/config.php:695 +#: ../../../../inc/config.php:695 ../../../../inc/config.php:701 msgid "Lurk some more before posting." msgstr "Nie postuj pierwszego dnia." #: /var/www/html/Tinyboard/inc/config.php:601 ../../../../inc/config.php:639 #: ../../../../inc/config.php:693 ../../../../inc/config.php:699 -#: ../../../../inc/config.php:696 +#: ../../../../inc/config.php:696 ../../../../inc/config.php:702 msgid "You look like a bot." msgstr "Wyglądasz jak bot." #: /var/www/html/Tinyboard/inc/config.php:602 ../../../../inc/config.php:640 #: ../../../../inc/config.php:694 ../../../../inc/config.php:700 -#: ../../../../inc/config.php:697 +#: ../../../../inc/config.php:697 ../../../../inc/config.php:703 msgid "Your browser sent an invalid or no HTTP referer." msgstr "" "Twoja przeglądarka przesłała niepoprawny, bądź nie przesłała informacji o " @@ -104,161 +108,161 @@ msgstr "" #: /var/www/html/Tinyboard/inc/config.php:603 ../../../../inc/config.php:641 #: ../../../../inc/config.php:695 ../../../../inc/config.php:701 -#: ../../../../inc/config.php:698 +#: ../../../../inc/config.php:698 ../../../../inc/config.php:704 #, php-format msgid "The %s field was too long." msgstr "Pole %s jest za długie" #: /var/www/html/Tinyboard/inc/config.php:604 ../../../../inc/config.php:642 #: ../../../../inc/config.php:696 ../../../../inc/config.php:702 -#: ../../../../inc/config.php:699 +#: ../../../../inc/config.php:699 ../../../../inc/config.php:705 msgid "The body was too long." msgstr "Zawartość jest za długa." #: /var/www/html/Tinyboard/inc/config.php:605 ../../../../inc/config.php:643 #: ../../../../inc/config.php:697 ../../../../inc/config.php:703 -#: ../../../../inc/config.php:700 +#: ../../../../inc/config.php:700 ../../../../inc/config.php:706 msgid "The body was too short or empty." msgstr "Zawartość jest za krótka, bądź pusta." #: /var/www/html/Tinyboard/inc/config.php:606 ../../../../inc/config.php:644 #: ../../../../inc/config.php:698 ../../../../inc/config.php:704 -#: ../../../../inc/config.php:701 +#: ../../../../inc/config.php:701 ../../../../inc/config.php:707 msgid "You must upload an image." msgstr "Musisz wysłać obrazek." #: /var/www/html/Tinyboard/inc/config.php:607 ../../../../inc/config.php:645 #: ../../../../inc/config.php:699 ../../../../inc/config.php:705 -#: ../../../../inc/config.php:702 +#: ../../../../inc/config.php:702 ../../../../inc/config.php:708 msgid "The server failed to handle your upload." msgstr "Nie udało się obsłużyć twojego pliku." #: /var/www/html/Tinyboard/inc/config.php:608 ../../../../inc/config.php:646 #: ../../../../inc/config.php:700 ../../../../inc/config.php:706 -#: ../../../../inc/config.php:703 +#: ../../../../inc/config.php:703 ../../../../inc/config.php:709 msgid "Unsupported image format." msgstr "Niewspierany format obrazka." #: /var/www/html/Tinyboard/inc/config.php:609 ../../../../inc/config.php:647 #: ../../../../inc/config.php:701 ../../../../inc/config.php:707 -#: ../../../../inc/config.php:704 +#: ../../../../inc/config.php:704 ../../../../inc/config.php:710 msgid "Invalid board!" msgstr "Niepoprawny board!" #: /var/www/html/Tinyboard/inc/config.php:610 ../../../../inc/config.php:648 #: ../../../../inc/config.php:702 ../../../../inc/config.php:708 -#: ../../../../inc/config.php:705 +#: ../../../../inc/config.php:705 ../../../../inc/config.php:711 msgid "Thread specified does not exist." msgstr "Wybrany wątek nie istnieje." #: /var/www/html/Tinyboard/inc/config.php:611 ../../../../inc/config.php:649 #: ../../../../inc/config.php:703 ../../../../inc/config.php:709 -#: ../../../../inc/config.php:706 +#: ../../../../inc/config.php:706 ../../../../inc/config.php:712 msgid "Thread locked. You may not reply at this time." msgstr "Wątek jest zablokowany. Nie możesz w nim teraz postować." #: /var/www/html/Tinyboard/inc/config.php:612 ../../../../inc/config.php:650 #: ../../../../inc/config.php:706 ../../../../inc/config.php:712 -#: ../../../../inc/config.php:709 +#: ../../../../inc/config.php:709 ../../../../inc/config.php:715 msgid "You didn't make a post." msgstr "Nie zrobiłeś posta." #: /var/www/html/Tinyboard/inc/config.php:613 ../../../../inc/config.php:651 #: ../../../../inc/config.php:707 ../../../../inc/config.php:713 -#: ../../../../inc/config.php:710 +#: ../../../../inc/config.php:710 ../../../../inc/config.php:716 msgid "Flood detected; Post discarded." msgstr "Wykryto flood; Post odrzucony." #: /var/www/html/Tinyboard/inc/config.php:614 ../../../../inc/config.php:652 #: ../../../../inc/config.php:708 ../../../../inc/config.php:714 -#: ../../../../inc/config.php:711 +#: ../../../../inc/config.php:711 ../../../../inc/config.php:717 msgid "Your request looks automated; Post discarded." msgstr "Twoje żądanie wygląda na zautomatyzowane; Post odrzucony." #: /var/www/html/Tinyboard/inc/config.php:615 ../../../../inc/config.php:653 #: ../../../../inc/config.php:709 ../../../../inc/config.php:715 -#: ../../../../inc/config.php:712 +#: ../../../../inc/config.php:712 ../../../../inc/config.php:718 msgid "Unoriginal content!" msgstr "Nieoryginalna treść!" #: /var/www/html/Tinyboard/inc/config.php:616 ../../../../inc/config.php:654 #: ../../../../inc/config.php:710 ../../../../inc/config.php:716 -#: ../../../../inc/config.php:713 +#: ../../../../inc/config.php:713 ../../../../inc/config.php:719 #, php-format msgid "Unoriginal content! You have been muted for %d seconds." msgstr "Nieoryginalna treść! Zostałeś zagłuszony na %d sekund." #: /var/www/html/Tinyboard/inc/config.php:617 ../../../../inc/config.php:655 #: ../../../../inc/config.php:711 ../../../../inc/config.php:717 -#: ../../../../inc/config.php:714 +#: ../../../../inc/config.php:714 ../../../../inc/config.php:720 #, php-format msgid "You are muted! Expires in %d seconds." msgstr "Jesteś zagłuszony! Wygasa w ciągu %d sekund." #: /var/www/html/Tinyboard/inc/config.php:618 ../../../../inc/config.php:656 #: ../../../../inc/config.php:712 ../../../../inc/config.php:718 -#: ../../../../inc/config.php:715 +#: ../../../../inc/config.php:715 ../../../../inc/config.php:721 #, php-format msgid "Your IP address is listed in %s." msgstr "Twój adres IP jest na liście %s." #: /var/www/html/Tinyboard/inc/config.php:619 ../../../../inc/config.php:657 #: ../../../../inc/config.php:713 ../../../../inc/config.php:719 -#: ../../../../inc/config.php:716 +#: ../../../../inc/config.php:716 ../../../../inc/config.php:722 msgid "Too many links; flood detected." msgstr "Zbyt dużo linków; wykryto flood." #: /var/www/html/Tinyboard/inc/config.php:620 ../../../../inc/config.php:658 #: ../../../../inc/config.php:714 ../../../../inc/config.php:720 -#: ../../../../inc/config.php:717 +#: ../../../../inc/config.php:717 ../../../../inc/config.php:723 msgid "Too many cites; post discarded." msgstr "Zbyt dużo cytatów; post odrzucony." #: /var/www/html/Tinyboard/inc/config.php:621 ../../../../inc/config.php:659 #: ../../../../inc/config.php:715 ../../../../inc/config.php:721 -#: ../../../../inc/config.php:718 +#: ../../../../inc/config.php:718 ../../../../inc/config.php:724 msgid "Too many cross-board links; post discarded." msgstr "Zbyt dużo linków między boardami; post odrzucony." #: /var/www/html/Tinyboard/inc/config.php:622 ../../../../inc/config.php:660 #: ../../../../inc/config.php:716 ../../../../inc/config.php:722 -#: ../../../../inc/config.php:719 +#: ../../../../inc/config.php:719 ../../../../inc/config.php:725 msgid "You didn't select anything to delete." msgstr "Nie wybrano nic do usunięcia." #: /var/www/html/Tinyboard/inc/config.php:623 ../../../../inc/config.php:661 #: ../../../../inc/config.php:717 ../../../../inc/config.php:723 -#: ../../../../inc/config.php:720 +#: ../../../../inc/config.php:720 ../../../../inc/config.php:726 msgid "You didn't select anything to report." msgstr "Nie wybrano nic do zgłoszenia." #: /var/www/html/Tinyboard/inc/config.php:624 ../../../../inc/config.php:662 #: ../../../../inc/config.php:718 ../../../../inc/config.php:724 -#: ../../../../inc/config.php:721 +#: ../../../../inc/config.php:721 ../../../../inc/config.php:727 msgid "You can't report that many posts at once." msgstr "Nie możesz raportować tyle postów na raz." #: /var/www/html/Tinyboard/inc/config.php:625 ../../../../inc/config.php:663 #: ../../../../inc/config.php:719 ../../../../inc/config.php:725 -#: ../../../../inc/config.php:722 +#: ../../../../inc/config.php:722 ../../../../inc/config.php:728 msgid "Wrong password…" msgstr "Niepoprawne hasło" #: /var/www/html/Tinyboard/inc/config.php:626 ../../../../inc/config.php:664 #: ../../../../inc/config.php:720 ../../../../inc/config.php:726 -#: ../../../../inc/config.php:723 +#: ../../../../inc/config.php:723 ../../../../inc/config.php:729 msgid "Invalid image." msgstr "Niepoprawny obrazek." #: /var/www/html/Tinyboard/inc/config.php:627 ../../../../inc/config.php:665 #: ../../../../inc/config.php:721 ../../../../inc/config.php:727 -#: ../../../../inc/config.php:724 +#: ../../../../inc/config.php:724 ../../../../inc/config.php:730 msgid "Unknown file extension." msgstr "Nieznane rozszerzenie pliku." #: /var/www/html/Tinyboard/inc/config.php:628 ../../../../inc/config.php:666 #: ../../../../inc/config.php:722 ../../../../inc/config.php:728 -#: ../../../../inc/config.php:725 +#: ../../../../inc/config.php:725 ../../../../inc/config.php:731 msgid "Maximum file size: %maxsz% bytes
Your file's size: %filesz% bytes" msgstr "" "Maksymalny rozmiar pliku: %maxsz% bajtów
Rozmiar twojego pliku: %filesz% " @@ -266,33 +270,33 @@ msgstr "" #: /var/www/html/Tinyboard/inc/config.php:629 ../../../../inc/config.php:667 #: ../../../../inc/config.php:723 ../../../../inc/config.php:729 -#: ../../../../inc/config.php:726 +#: ../../../../inc/config.php:726 ../../../../inc/config.php:732 msgid "The file was too big." msgstr "Plik jest za duży." #: /var/www/html/Tinyboard/inc/config.php:630 ../../../../inc/config.php:668 #: ../../../../inc/config.php:724 ../../../../inc/config.php:730 -#: ../../../../inc/config.php:727 +#: ../../../../inc/config.php:727 ../../../../inc/config.php:733 msgid "Invalid archive!" msgstr "Niepoprawne archiwum!" #: /var/www/html/Tinyboard/inc/config.php:631 ../../../../inc/config.php:669 #: ../../../../inc/config.php:725 ../../../../inc/config.php:731 -#: ../../../../inc/config.php:728 +#: ../../../../inc/config.php:728 ../../../../inc/config.php:734 #, php-format msgid "That file already exists!" msgstr "Ten plik już istnieje!" #: /var/www/html/Tinyboard/inc/config.php:632 ../../../../inc/config.php:670 #: ../../../../inc/config.php:727 ../../../../inc/config.php:733 -#: ../../../../inc/config.php:730 +#: ../../../../inc/config.php:730 ../../../../inc/config.php:736 #, php-format msgid "You'll have to wait another %s before deleting that." msgstr "Musisz poczekać kolejne %s przed usunięciem tego." #: /var/www/html/Tinyboard/inc/config.php:633 ../../../../inc/config.php:671 #: ../../../../inc/config.php:728 ../../../../inc/config.php:734 -#: ../../../../inc/config.php:731 +#: ../../../../inc/config.php:731 ../../../../inc/config.php:737 msgid "MIME type detection XSS exploit (IE) detected; post discarded." msgstr "" "Wykryto próbę wykorzystania luki wykrywania typu MIME (XSS w IE); post " @@ -300,31 +304,31 @@ msgstr "" #: /var/www/html/Tinyboard/inc/config.php:634 ../../../../inc/config.php:672 #: ../../../../inc/config.php:729 ../../../../inc/config.php:735 -#: ../../../../inc/config.php:732 +#: ../../../../inc/config.php:732 ../../../../inc/config.php:738 msgid "Couldn't make sense of the URL of the video you tried to embed." msgstr "Nie można było zrozumieć URL-a wideo, którego próbowano zapostować." #: /var/www/html/Tinyboard/inc/config.php:635 ../../../../inc/config.php:673 #: ../../../../inc/config.php:730 ../../../../inc/config.php:736 -#: ../../../../inc/config.php:733 +#: ../../../../inc/config.php:733 ../../../../inc/config.php:739 msgid "You seem to have mistyped the verification." msgstr "Wygląda na to, że przepisano źle weryfikację." #: /var/www/html/Tinyboard/inc/config.php:638 ../../../../inc/config.php:676 #: ../../../../inc/config.php:734 ../../../../inc/config.php:740 -#: ../../../../inc/config.php:737 +#: ../../../../inc/config.php:737 ../../../../inc/config.php:743 msgid "Invalid username and/or password." msgstr "Błędna nazwa użytkownika, bądź hasło" #: /var/www/html/Tinyboard/inc/config.php:639 ../../../../inc/config.php:677 #: ../../../../inc/config.php:735 ../../../../inc/config.php:741 -#: ../../../../inc/config.php:738 +#: ../../../../inc/config.php:738 ../../../../inc/config.php:744 msgid "You are not a mod…" msgstr "Nie jesteś moderatorem" #: /var/www/html/Tinyboard/inc/config.php:640 ../../../../inc/config.php:678 #: ../../../../inc/config.php:736 ../../../../inc/config.php:742 -#: ../../../../inc/config.php:739 +#: ../../../../inc/config.php:739 ../../../../inc/config.php:745 msgid "" "Invalid username and/or password. Your user may have been deleted or changed." msgstr "" @@ -333,65 +337,65 @@ msgstr "" #: /var/www/html/Tinyboard/inc/config.php:641 ../../../../inc/config.php:679 #: ../../../../inc/config.php:737 ../../../../inc/config.php:743 -#: ../../../../inc/config.php:740 +#: ../../../../inc/config.php:740 ../../../../inc/config.php:746 msgid "Invalid/malformed cookies." msgstr "Niepoprawne/zmodyfikowane pliki cookie." #: /var/www/html/Tinyboard/inc/config.php:642 ../../../../inc/config.php:680 #: ../../../../inc/config.php:738 ../../../../inc/config.php:744 -#: ../../../../inc/config.php:741 +#: ../../../../inc/config.php:741 ../../../../inc/config.php:747 msgid "Your browser didn't submit an input when it should have." msgstr "Twoja przeglądarka nie wysłała pola, kiedy powinna." #: /var/www/html/Tinyboard/inc/config.php:643 ../../../../inc/config.php:681 #: ../../../../inc/config.php:739 ../../../../inc/config.php:745 -#: ../../../../inc/config.php:742 +#: ../../../../inc/config.php:742 ../../../../inc/config.php:748 #, php-format msgid "The %s field is required." msgstr "Pole %s jest wymagane." #: /var/www/html/Tinyboard/inc/config.php:644 ../../../../inc/config.php:682 #: ../../../../inc/config.php:740 ../../../../inc/config.php:746 -#: ../../../../inc/config.php:743 +#: ../../../../inc/config.php:743 ../../../../inc/config.php:749 #, php-format msgid "The %s field was invalid." msgstr "Pole %s jest niepoprawne." #: /var/www/html/Tinyboard/inc/config.php:645 ../../../../inc/config.php:683 #: ../../../../inc/config.php:741 ../../../../inc/config.php:747 -#: ../../../../inc/config.php:744 +#: ../../../../inc/config.php:744 ../../../../inc/config.php:750 #, php-format msgid "There is already a %s board." msgstr "Już istnieje board %s" #: /var/www/html/Tinyboard/inc/config.php:646 ../../../../inc/config.php:684 #: ../../../../inc/config.php:742 ../../../../inc/config.php:748 -#: ../../../../inc/config.php:745 +#: ../../../../inc/config.php:745 ../../../../inc/config.php:751 msgid "You don't have permission to do that." msgstr "Nie masz uprawnień do wykonania tej czynności." #: /var/www/html/Tinyboard/inc/config.php:647 ../../../../inc/config.php:685 #: ../../../../inc/config.php:743 ../../../../inc/config.php:749 -#: ../../../../inc/config.php:746 +#: ../../../../inc/config.php:746 ../../../../inc/config.php:752 msgid "That post doesn't exist…" msgstr "Ten post nie istnieje..." #: /var/www/html/Tinyboard/inc/config.php:648 ../../../../inc/config.php:686 #: ../../../../inc/config.php:744 ../../../../inc/config.php:750 -#: ../../../../inc/config.php:747 +#: ../../../../inc/config.php:747 ../../../../inc/config.php:753 msgid "Page not found." msgstr "Strona nie znaleziona." #: /var/www/html/Tinyboard/inc/config.php:649 ../../../../inc/config.php:687 #: ../../../../inc/config.php:745 ../../../../inc/config.php:751 -#: ../../../../inc/config.php:748 +#: ../../../../inc/config.php:748 ../../../../inc/config.php:754 #, php-format msgid "That mod already exists!" msgstr "Ten moderator już istnieje!" #: /var/www/html/Tinyboard/inc/config.php:650 ../../../../inc/config.php:688 #: ../../../../inc/config.php:746 ../../../../inc/config.php:752 -#: ../../../../inc/config.php:749 +#: ../../../../inc/config.php:749 ../../../../inc/config.php:755 msgid "That theme doesn't exist!" msgstr "Ten dodatek nie istnieje!" @@ -430,6 +434,7 @@ msgstr "[Przenieś]" #. Default public ban message. #. In public ban messages, %length% is replaced with "for x days" or "permanently" (with %LENGTH% being the uppercase equivalent). #: /var/www/html/Tinyboard/inc/config.php:801 ../../../../inc/config.php:911 +#: ../../../../inc/config.php:917 msgid "USER WAS BANNED FOR THIS POST" msgstr "UŻYTKOWNIK ZOSTAŁ ZBANOWANY ZA TEGO POSTA" @@ -438,20 +443,21 @@ msgstr "UŻYTKOWNIK ZOSTAŁ ZBANOWANY ZA TEGO POSTA" msgid "Moved to %s." msgstr "Przeniesiono do %s." -#: /var/www/html/Tinyboard/inc/display.php:80 +#: /var/www/html/Tinyboard/inc/display.php:80 ../../../../inc/display.php:75 msgid "Error" msgstr "Błąd" -#: /var/www/html/Tinyboard/inc/display.php:81 +#: /var/www/html/Tinyboard/inc/display.php:81 ../../../../inc/display.php:76 msgid "An error has occured." msgstr "Wystąpił błąd." -#: /var/www/html/Tinyboard/inc/display.php:87 +#: /var/www/html/Tinyboard/inc/display.php:87 ../../../../inc/display.php:82 msgid "Go back" msgstr "Wróć" #: /var/www/html/Tinyboard/inc/display.php:97 ../../../../inc/display.php:91 #: ../../../../inc/mod/pages.php:59 ../../../../inc/mod/pages.php:62 +#: ../../../../inc/display.php:92 msgid "Login" msgstr "Logowanie" @@ -469,31 +475,34 @@ msgstr "" #: /var/www/html/Tinyboard/templates/cache/dd/1a/77e08f0c1b4ecf707c5a3e5a70be.php:27 #: ../../../../templates/cache/a8/a6/1022091d3402e085395b12e6279a.php:27 #: ../../../../templates/cache/82/40/4c4a4b82f787181e6500ce83494d.php:27 +#: ../../../../inc/display.php:423 msgid "Delete" msgstr "Usuń" #: /var/www/html/Tinyboard/inc/display.php:272 -#: /var/www/html/Tinyboard/inc/display.php:365 +#: /var/www/html/Tinyboard/inc/display.php:365 ../../../../inc/display.php:423 msgid "Are you sure you want to delete this?" msgstr "Czy jesteś pewien, że chcesz to usunąć?" #: /var/www/html/Tinyboard/inc/display.php:276 -#: /var/www/html/Tinyboard/inc/display.php:369 +#: /var/www/html/Tinyboard/inc/display.php:369 ../../../../inc/display.php:427 msgid "Delete all posts by IP" msgstr "Usuń wszystkie posty z tego adresu IP" #: /var/www/html/Tinyboard/inc/display.php:276 -#: /var/www/html/Tinyboard/inc/display.php:369 +#: /var/www/html/Tinyboard/inc/display.php:369 ../../../../inc/display.php:427 msgid "Are you sure you want to delete all posts by this IP address?" msgstr "Czy na pewno chcesz usunąć wszystkie posty z tego adresu IP?" #: /var/www/html/Tinyboard/inc/display.php:280 -#: /var/www/html/Tinyboard/inc/display.php:373 +#: /var/www/html/Tinyboard/inc/display.php:373 ../../../../inc/display.php:334 +#: ../../../../inc/display.php:435 msgid "Ban" msgstr "Ban" #: /var/www/html/Tinyboard/inc/display.php:284 -#: /var/www/html/Tinyboard/inc/display.php:377 +#: /var/www/html/Tinyboard/inc/display.php:377 ../../../../inc/display.php:338 +#: ../../../../inc/display.php:439 msgid "Ban & Delete" msgstr "Usuń i zbanuj" @@ -506,34 +515,36 @@ msgstr "Usuń plik" #: /var/www/html/Tinyboard/inc/display.php:408 #: ../../../../inc/mod/pages.php:1080 ../../../../inc/mod/pages.php:1105 #: ../../../../inc/mod/pages.php:1239 ../../../../inc/mod/pages.php:1242 +#: ../../../../inc/display.php:346 ../../../../inc/display.php:470 +#: ../../../../inc/mod/pages.php:1314 msgid "Edit post" msgstr "Edytuj post" -#: /var/www/html/Tinyboard/inc/display.php:386 +#: /var/www/html/Tinyboard/inc/display.php:386 ../../../../inc/display.php:448 msgid "Make thread not sticky" msgstr "Odklej wątek" -#: /var/www/html/Tinyboard/inc/display.php:388 +#: /var/www/html/Tinyboard/inc/display.php:388 ../../../../inc/display.php:450 msgid "Make thread sticky" msgstr "Przyklej wątek" -#: /var/www/html/Tinyboard/inc/display.php:392 +#: /var/www/html/Tinyboard/inc/display.php:392 ../../../../inc/display.php:454 msgid "Allow thread to be bumped" msgstr "Zezwól wątkowi na bumpowanie" -#: /var/www/html/Tinyboard/inc/display.php:394 +#: /var/www/html/Tinyboard/inc/display.php:394 ../../../../inc/display.php:456 msgid "Prevent thread from being bumped" msgstr "Zabroń wątkowi na bumpowanie" -#: /var/www/html/Tinyboard/inc/display.php:399 +#: /var/www/html/Tinyboard/inc/display.php:399 ../../../../inc/display.php:461 msgid "Unlock thread" msgstr "Odblokuj wątek" -#: /var/www/html/Tinyboard/inc/display.php:401 +#: /var/www/html/Tinyboard/inc/display.php:401 ../../../../inc/display.php:463 msgid "Lock thread" msgstr "Zablokuj wątek" -#: /var/www/html/Tinyboard/inc/display.php:404 +#: /var/www/html/Tinyboard/inc/display.php:404 ../../../../inc/display.php:466 msgid "Move thread to another board" msgstr "Przenieś wątek na inny board" @@ -703,6 +714,8 @@ msgstr "Weryfikacja" #. line 72 #. line 3 #. line 72 +#. line 3 +#. line 72 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:149 #: /var/www/html/Tinyboard/templates/cache/dd/1a/77e08f0c1b4ecf707c5a3e5a70be.php:22 #: ../../../../templates/cache/d1/2d/eda9403e966240c642b13ca43eb6.php:165 @@ -787,6 +800,8 @@ msgstr "Flagi" #. line 99 #. line 98 #. line 99 +#. line 98 +#. line 99 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:188 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:191 #: ../../../../templates/cache/d1/2d/eda9403e966240c642b13ca43eb6.php:215 @@ -854,6 +869,8 @@ msgstr "Przyklejony" #. line 103 #. line 102 #. line 103 +#. line 102 +#. line 103 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:200 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:203 #: ../../../../templates/cache/d1/2d/eda9403e966240c642b13ca43eb6.php:227 @@ -921,6 +938,8 @@ msgstr "Zablokowany" #. line 107 #. line 106 #. line 107 +#. line 106 +#. line 107 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:212 #: /var/www/html/Tinyboard/templates/cache/1d/5e/91ec2bc929b77377b8b877d82db4.php:215 #: ../../../../templates/cache/d1/2d/eda9403e966240c642b13ca43eb6.php:239 @@ -1058,6 +1077,7 @@ msgstr "Tryb postowania: Odpowiedź" #: ../../../../templates/cache/aa/f6/f10fd83961bcd8c947af6ddf919d.php:172 #: ../../../../templates/cache/aa/f6/f10fd83961bcd8c947af6ddf919d.php:127 #: ../../../../templates/cache/aa/f6/f10fd83961bcd8c947af6ddf919d.php:173 +#: ../../../../templates/cache/aa/f6/f10fd83961bcd8c947af6ddf919d.php:174 msgid "Return" msgstr "Powrót" @@ -1079,6 +1099,7 @@ msgstr "Usuń post" #. line 106 #. line 8 #. line 32 +#. line 8 #: /var/www/html/Tinyboard/templates/cache/dd/1a/77e08f0c1b4ecf707c5a3e5a70be.php:32 #: /var/www/html/Tinyboard/mod.php:1801 #: ../../../../templates/cache/a8/a6/1022091d3402e085395b12e6279a.php:32 @@ -1116,6 +1137,7 @@ msgstr "Wiadomości prywatne" #: ../../../../inc/mod/pages.php:376 ../../../../inc/mod/pages.php:393 #: ../../../../inc/mod/pages.php:406 ../../../../inc/mod/pages.php:540 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:166 +#: ../../../../inc/mod/pages.php:604 msgid "News" msgstr "Aktualności" @@ -1123,7 +1145,7 @@ msgstr "Aktualności" #: ../../../../inc/mod/pages.php:1557 ../../../../inc/mod/pages.php:1657 #: ../../../../inc/mod/pages.php:1682 ../../../../inc/mod/pages.php:1816 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:207 -#: ../../../../inc/mod/pages.php:1831 +#: ../../../../inc/mod/pages.php:1831 ../../../../inc/mod/pages.php:1904 msgid "Report queue" msgstr "Kolejka zgłoszeń" @@ -1131,6 +1153,7 @@ msgstr "Kolejka zgłoszeń" #: ../../../../inc/mod/pages.php:664 ../../../../inc/mod/pages.php:705 #: ../../../../inc/mod/pages.php:721 ../../../../inc/mod/pages.php:855 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:224 +#: ../../../../inc/mod/pages.php:918 msgid "Ban list" msgstr "Lista banów" @@ -1138,7 +1161,7 @@ msgstr "Lista banów" #: ../../../../inc/mod/pages.php:1271 ../../../../inc/mod/pages.php:1369 #: ../../../../inc/mod/pages.php:1394 ../../../../inc/mod/pages.php:1528 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:232 -#: ../../../../inc/mod/pages.php:1543 +#: ../../../../inc/mod/pages.php:1543 ../../../../inc/mod/pages.php:1615 msgid "Manage users" msgstr "Zarządzaj użytkownikami" @@ -1153,6 +1176,7 @@ msgstr "Zmień swoje hasło" #: ../../../../inc/mod/pages.php:580 ../../../../inc/mod/pages.php:607 #: ../../../../templates/cache/55/dd/8ffe738533bd12359200e5745905.php:65 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:255 +#: ../../../../inc/mod/pages.php:644 ../../../../inc/mod/pages.php:671 msgid "Moderation log" msgstr "Log moderacji" @@ -1172,7 +1196,7 @@ msgstr "Pokaż konfigurację" #: ../../../../inc/mod/pages.php:1739 ../../../../inc/mod/pages.php:1805 #: ../../../../inc/mod/pages.php:1830 ../../../../inc/mod/pages.php:1964 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:247 -#: ../../../../inc/mod/pages.php:1979 +#: ../../../../inc/mod/pages.php:1979 ../../../../inc/mod/pages.php:2052 msgid "Manage themes" msgstr "Zarządzaj dodatkami" @@ -1196,7 +1220,7 @@ msgstr "Wyrażenie:" #: ../../../../templates/cache/c3/de/6ff26042c5b94cc80055e6f209d2.php:19 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:286 #: ../../../../templates/cache/4c/fb/a3bf13b0badfc09442bd42da1cce.php:19 -#: ../../../../search.php:165 +#: ../../../../search.php:165 ../../../../search.php:168 msgid "Search" msgstr "Szukaj" @@ -1276,12 +1300,14 @@ msgstr "Akcja" #: /var/www/html/Tinyboard/mod.php:528 ../../../../inc/mod/pages.php:1723 #: ../../../../inc/mod/pages.php:1789 ../../../../inc/mod/pages.php:1814 #: ../../../../inc/mod/pages.php:1948 ../../../../inc/mod/pages.php:1963 +#: ../../../../inc/mod/pages.php:2036 msgid "Themes directory doesn't exist!" msgstr "Katalog dodatków (themes) nie istnieje!" #: /var/www/html/Tinyboard/mod.php:530 ../../../../inc/mod/pages.php:1725 #: ../../../../inc/mod/pages.php:1791 ../../../../inc/mod/pages.php:1816 #: ../../../../inc/mod/pages.php:1950 ../../../../inc/mod/pages.php:1965 +#: ../../../../inc/mod/pages.php:2038 msgid "Cannot open themes directory; check permissions." msgstr "Nie można otworzyć katalogu dodatków (themes); sprawdź uprawnienia." @@ -1334,6 +1360,7 @@ msgstr "Instaluj" #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:263 #: ../../../../inc/mod/pages.php:1741 ../../../../inc/mod/pages.php:1745 #: ../../../../templates/cache/86/31/3f70fa8521e56d617b21133af4d8.php:98 +#: ../../../../inc/mod/pages.php:1814 ../../../../inc/mod/pages.php:1818 msgid "Rebuild" msgstr "Przebuduj" @@ -1361,6 +1388,7 @@ msgstr "Postuj na tablicy ogłoszeń" #: ../../../../inc/mod/pages.php:333 ../../../../inc/mod/pages.php:346 #: ../../../../inc/mod/pages.php:480 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:96 +#: ../../../../inc/mod/pages.php:543 msgid "Noticeboard" msgstr "Tablica ogłoszeń" @@ -1468,13 +1496,13 @@ msgstr "Konfiguracja" #: /var/www/html/Tinyboard/mod.php:2174 ../../../../inc/mod/pages.php:255 #: ../../../../inc/mod/pages.php:272 ../../../../inc/mod/pages.php:285 -#: ../../../../inc/mod/pages.php:419 +#: ../../../../inc/mod/pages.php:419 ../../../../inc/mod/pages.php:481 msgid "Couldn't open board after creation." msgstr "Nie można otworzyć boardu po utworzeniu." #: /var/www/html/Tinyboard/mod.php:2678 ../../../../inc/mod/pages.php:759 #: ../../../../inc/mod/pages.php:800 ../../../../inc/mod/pages.php:823 -#: ../../../../inc/mod/pages.php:957 +#: ../../../../inc/mod/pages.php:957 ../../../../inc/mod/pages.php:1020 msgid "Target and source board are the same." msgstr "Docelowy i źródłowy board są takie same." @@ -1484,6 +1512,7 @@ msgstr "Nie ma boardu na który można to przenieść; istnieje tylko jeden." #: ../../../../inc/config.php:689 ../../../../inc/config.php:747 #: ../../../../inc/config.php:753 ../../../../inc/config.php:750 +#: ../../../../inc/config.php:756 msgid "Invalid security token! Please go back and try again." msgstr "Niepoprawny token bezpieczeństwa! Proszę cofnąć i spróbować ponownie." @@ -1493,11 +1522,13 @@ msgstr "Potwierdź akcję" #: ../../../../inc/mod/pages.php:222 ../../../../inc/mod/pages.php:239 #: ../../../../inc/mod/pages.php:252 ../../../../inc/mod/pages.php:386 +#: ../../../../inc/mod/pages.php:431 msgid "Edit board" msgstr "Edytuj board" #: ../../../../inc/mod/pages.php:270 ../../../../inc/mod/pages.php:287 #: ../../../../inc/mod/pages.php:300 ../../../../inc/mod/pages.php:434 +#: ../../../../inc/mod/pages.php:496 msgid "New board" msgstr "Nowy board" @@ -1511,6 +1542,7 @@ msgstr "Nowy board" #: ../../../../inc/mod/pages.php:628 ../../../../inc/mod/pages.php:762 #: ../../../../templates/cache/24/a0/f1ddafed7a8f9625e747a5ca33f5.php:247 #: ../../../../templates/cache/18/9c/c365d711719f494c684aab98a4ae.php:65 +#: ../../../../inc/mod/pages.php:825 msgid "IP" msgstr "adres IP" @@ -1520,12 +1552,14 @@ msgstr "adres IP" #: ../../../../inc/mod/pages.php:638 ../../../../inc/mod/pages.php:1053 #: ../../../../inc/mod/pages.php:772 ../../../../inc/mod/pages.php:1187 #: ../../../../templates/cache/24/a0/f1ddafed7a8f9625e747a5ca33f5.php:398 -#: ../../../../inc/mod/pages.php:1190 +#: ../../../../inc/mod/pages.php:1190 ../../../../inc/mod/pages.php:835 +#: ../../../../inc/mod/pages.php:1255 msgid "New ban" msgstr "Nowy ban" #: ../../../../inc/mod/pages.php:919 ../../../../inc/mod/pages.php:962 #: ../../../../inc/mod/pages.php:987 ../../../../inc/mod/pages.php:1121 +#: ../../../../inc/mod/pages.php:1184 msgid "Impossible to move thread; there is only one board." msgstr "Nie można przenieść wątku; istnieje tylko jeden board." @@ -1533,6 +1567,7 @@ msgstr "Nie można przenieść wątku; istnieje tylko jeden board." #: ../../../../inc/mod/pages.php:923 ../../../../inc/mod/pages.php:966 #: ../../../../inc/mod/pages.php:991 ../../../../inc/mod/pages.php:1125 #: ../../../../templates/cache/dd/1a/7d548894242b9d7bff167de40716.php:106 +#: ../../../../inc/mod/pages.php:1188 msgid "Move thread" msgstr "Przenieś wątek" @@ -1541,6 +1576,7 @@ msgstr "Przenieś wątek" #: ../../../../inc/mod/pages.php:1332 ../../../../inc/mod/pages.php:1381 #: ../../../../inc/mod/pages.php:1466 ../../../../inc/mod/pages.php:1515 #: ../../../../inc/mod/pages.php:1477 ../../../../inc/mod/pages.php:1530 +#: ../../../../inc/mod/pages.php:1549 ../../../../inc/mod/pages.php:1602 msgid "Edit user" msgstr "Edytuj użytkownika" @@ -1550,12 +1586,13 @@ msgstr "Edytuj użytkownika" #: ../../../../inc/mod/pages.php:1456 ../../../../inc/mod/pages.php:1528 #: ../../../../inc/mod/pages.php:1590 ../../../../inc/mod/pages.php:1662 #: ../../../../inc/mod/pages.php:1605 ../../../../inc/mod/pages.php:1677 +#: ../../../../inc/mod/pages.php:1750 msgid "New PM for" msgstr "Nowe PW dla" #: ../../../../inc/mod/pages.php:1337 ../../../../inc/mod/pages.php:1435 #: ../../../../inc/mod/pages.php:1460 ../../../../inc/mod/pages.php:1594 -#: ../../../../inc/mod/pages.php:1609 +#: ../../../../inc/mod/pages.php:1609 ../../../../inc/mod/pages.php:1681 msgid "Private message" msgstr "Prywatna wiadomość" @@ -1563,39 +1600,39 @@ msgstr "Prywatna wiadomość" #: ../../../../inc/mod/pages.php:1358 ../../../../inc/mod/pages.php:1456 #: ../../../../inc/mod/pages.php:1481 ../../../../inc/mod/pages.php:1615 #: ../../../../templates/cache/3a/df/ab38a77244cb9c729b4c6f99759a.php:171 -#: ../../../../inc/mod/pages.php:1630 +#: ../../../../inc/mod/pages.php:1630 ../../../../inc/mod/pages.php:1702 msgid "PM inbox" msgstr "Odebrane PW" #: ../../../../inc/mod/pages.php:1679 ../../../../inc/mod/pages.php:1779 #: ../../../../inc/mod/pages.php:1804 ../../../../inc/mod/pages.php:1938 -#: ../../../../inc/mod/pages.php:1953 +#: ../../../../inc/mod/pages.php:1953 ../../../../inc/mod/pages.php:2026 msgid "Config editor" msgstr "Edytor konfiguracji" #: ../../../../inc/mod/pages.php:1713 ../../../../inc/mod/pages.php:1945 #: ../../../../inc/mod/pages.php:1970 ../../../../inc/mod/pages.php:2104 -#: ../../../../inc/mod/pages.php:2119 +#: ../../../../inc/mod/pages.php:2119 ../../../../inc/mod/pages.php:2192 msgid "Debug: Anti-spam" msgstr "Debug: Antyspam" #: ../../../../inc/mod/pages.php:1801 ../../../../inc/mod/pages.php:1867 #: ../../../../inc/mod/pages.php:1892 ../../../../inc/mod/pages.php:2026 -#: ../../../../inc/mod/pages.php:2041 +#: ../../../../inc/mod/pages.php:2041 ../../../../inc/mod/pages.php:2114 #, php-format msgid "Installed theme: %s" msgstr "Zainstalowano dodatek: %s" #: ../../../../inc/mod/pages.php:1811 ../../../../inc/mod/pages.php:1878 #: ../../../../inc/mod/pages.php:1903 ../../../../inc/mod/pages.php:2037 -#: ../../../../inc/mod/pages.php:2052 +#: ../../../../inc/mod/pages.php:2052 ../../../../inc/mod/pages.php:2125 #, php-format msgid "Configuring theme: %s" msgstr "Konfigurowanie dodatku: %s" #: ../../../../inc/mod/pages.php:1839 ../../../../inc/mod/pages.php:1906 #: ../../../../inc/mod/pages.php:1931 ../../../../inc/mod/pages.php:2065 -#: ../../../../inc/mod/pages.php:2080 +#: ../../../../inc/mod/pages.php:2080 ../../../../inc/mod/pages.php:2153 #, php-format msgid "Rebuilt theme: %s" msgstr "Przebudowano dodatek: %s" @@ -1607,24 +1644,24 @@ msgid "" msgstr "" #: ../../../../inc/config.php:704 ../../../../inc/config.php:710 -#: ../../../../inc/config.php:707 +#: ../../../../inc/config.php:707 ../../../../inc/config.php:713 msgid "Thread has reached its maximum reply limit." msgstr "Ten temat osiągnął swój maksymalny limit odpowiedzi." #: ../../../../inc/config.php:705 ../../../../inc/config.php:711 -#: ../../../../inc/config.php:708 +#: ../../../../inc/config.php:708 ../../../../inc/config.php:714 msgid "Thread has reached its maximum image limit." msgstr "Ten temat osiągnął swój maksymalny limit obrazków." #: ../../../../inc/config.php:726 ../../../../inc/config.php:732 -#: ../../../../inc/config.php:729 +#: ../../../../inc/config.php:729 ../../../../inc/config.php:735 #, php-format msgid "That file already exists in this thread!" msgstr "Ten plik już istnieje w tym temacie!" #. Moderator errors #: ../../../../inc/config.php:733 ../../../../inc/config.php:739 -#: ../../../../inc/config.php:736 +#: ../../../../inc/config.php:736 ../../../../inc/config.php:742 #, php-format msgid "" "You are only allowed to unban %s users at a time. You tried to unban %u " @@ -1634,11 +1671,13 @@ msgstr "" #: ../../../../inc/mod/pages.php:1969 ../../../../inc/mod/pages.php:1994 #: ../../../../inc/mod/pages.php:2128 ../../../../inc/mod/pages.php:2143 +#: ../../../../inc/mod/pages.php:2216 msgid "Debug: Recent posts" msgstr "Debug: Ostatnie posty" #: ../../../../inc/mod/pages.php:1993 ../../../../inc/mod/pages.php:2018 #: ../../../../inc/mod/pages.php:2152 ../../../../inc/mod/pages.php:2167 +#: ../../../../inc/mod/pages.php:2240 msgid "Debug: SQL" msgstr "Debug: SQL" @@ -1651,7 +1690,7 @@ msgstr[1] "%count% odpowiedzi" msgstr[2] "%count% odpowiedzi" #. $results now contains the search results -#: ../../../../inc/mod/pages.php:290 +#: ../../../../inc/mod/pages.php:290 ../../../../inc/mod/pages.php:335 msgid "Search results" msgstr "Wyniki wyszukiwania" @@ -1976,11 +2015,11 @@ msgstr "Wyszukiwanie postów jest wyłączone" msgid "Wait a while before searching again, please." msgstr "Proszę poczekać chwilę przed ponownym szukaniem." -#: ../../../../search.php:128 +#: ../../../../search.php:128 ../../../../search.php:131 msgid "Query too broad." msgstr "Zapytanie zbyt szerokie." -#: ../../../../search.php:149 +#: ../../../../search.php:149 ../../../../search.php:152 #, php-format msgid "%d result in" msgid_plural "%d results in" @@ -1988,11 +2027,11 @@ msgstr[0] "%d wynik na" msgstr[1] "%d wyniki na" msgstr[2] "%d wyników na" -#: ../../../../search.php:160 +#: ../../../../search.php:160 ../../../../search.php:163 msgid "No results." msgstr "Brak wyników." -#: ../../../../inc/functions.php:594 +#: ../../../../inc/functions.php:594 ../../../../inc/functions.php:603 msgid "Banned!" msgstr "Zbanowany!" @@ -2005,6 +2044,7 @@ msgid "You are not banned." msgstr "Nie jesteś zbanowany." #: ../../../../inc/functions.php:549 ../../../../inc/functions.php:566 +#: ../../../../inc/functions.php:558 ../../../../inc/functions.php:575 msgid "second" msgid_plural "seconds" msgstr[0] "sekunda" @@ -2012,6 +2052,7 @@ msgstr[1] "sekundy" msgstr[2] "sekund" #: ../../../../inc/functions.php:551 ../../../../inc/functions.php:568 +#: ../../../../inc/functions.php:560 ../../../../inc/functions.php:577 msgid "minute" msgid_plural "minutes" msgstr[0] "minuta" @@ -2019,6 +2060,7 @@ msgstr[1] "minuty" msgstr[2] "minut" #: ../../../../inc/functions.php:553 ../../../../inc/functions.php:570 +#: ../../../../inc/functions.php:562 ../../../../inc/functions.php:579 msgid "hour" msgid_plural "hours" msgstr[0] "godzina" @@ -2026,6 +2068,7 @@ msgstr[1] "godziny" msgstr[2] "godzin" #: ../../../../inc/functions.php:555 ../../../../inc/functions.php:572 +#: ../../../../inc/functions.php:564 ../../../../inc/functions.php:581 msgid "day" msgid_plural "days" msgstr[0] "dzień" @@ -2033,6 +2076,7 @@ msgstr[1] "dni" msgstr[2] "dni" #: ../../../../inc/functions.php:557 ../../../../inc/functions.php:574 +#: ../../../../inc/functions.php:566 ../../../../inc/functions.php:583 msgid "week" msgid_plural "weeks" msgstr[0] "tydzień" @@ -2040,6 +2084,7 @@ msgstr[1] "tygodnie" msgstr[2] "tygodni" #: ../../../../inc/functions.php:560 ../../../../inc/functions.php:577 +#: ../../../../inc/functions.php:569 ../../../../inc/functions.php:586 msgid "year" msgid_plural "years" msgstr[0] "rok" @@ -2097,3 +2142,47 @@ msgstr "Nie ma dostępnych dodatków." #: ../../../../templates/cache/d1/99/467985632043e204070d354b8290.php:91 msgid "Install theme" msgstr "Zainstaluj dodatek" + +#: ../../../../inc/display.php:211 +#, php-format +msgid "Post too long. Click here to view the full text." +msgstr "Post za długi. Kliknij tutaj, aby zobaczyć jego pełną treść." + +#: ../../../../inc/display.php:342 ../../../../inc/display.php:443 +msgid "Delete file" +msgstr "Usuń plik" + +#: ../../../../inc/display.php:342 ../../../../inc/display.php:443 +msgid "Are you sure you want to delete this file?" +msgstr "Czy jesteś pewien, że chcesz usunąć ten plik?" + +#: ../../../../inc/display.php:431 +msgid "Delete all posts by IP across all boards" +msgstr "Usuń wszystkie posty z tego IP ze wszystkich boardów" + +#: ../../../../inc/display.php:431 +msgid "" +"Are you sure you want to delete all posts by this IP address, across all " +"boards?" +msgstr "" +"Czy jesteś pewien, że chcesz usunąć wszystkie posty z tego adresu IP, ze " +"wszystkich boardów?" + +#. Page footer +#: ../../../../inc/config.php:564 +msgid "" +"All trademarks, copyrights, comments, and images on this page are owned by " +"and are the responsibility of their respective parties." +msgstr "" +"Wszystkie znaki towarowe, prawa autorskie, komentarze oraz obrazki na tej " +"stronie są własnością i odpowiedzialność za nie spoczywa na ich odpowiednich " +"właścicielach." + +#: ../../../../inc/mod/pages.php:267 +msgid "There are no boards to search!" +msgstr "Nie ma boardów do przeszukania!" + +#. Print error +#: ../../../../inc/database.php:72 +msgid "Database error: " +msgstr "Błąd bazy danych: " -- cgit v1.3 From 0a026c8f3fd62de31e3e7a0c091f0aed4fa5164c Mon Sep 17 00:00:00 2001 From: Jakub Skrzypnik Date: Thu, 1 Aug 2013 08:46:24 +0200 Subject: Correcting polish locale a bit --- inc/locale/pl_PL/LC_MESSAGES/tinyboard.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po index 8a46fda9..e8caf477 100644 --- a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po +++ b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po @@ -61,7 +61,7 @@ msgstr "wszystkie boardy" #: /var/www/html/Tinyboard/inc/config.php:305 ../../../../inc/config.php:330 #: ../../../../inc/config.php:334 msgid "You have been muted for unoriginal content." -msgstr "Zostałeś zagłuszony za nieoryginalną treść." +msgstr "Zostałeś wyciszony za nieoryginalną treść." #: /var/www/html/Tinyboard/inc/config.php:447 msgid "Anonymous" @@ -197,7 +197,7 @@ msgstr "Nieoryginalna treść! Zostałeś zagłuszony na %d sekund." #: ../../../../inc/config.php:714 ../../../../inc/config.php:720 #, php-format msgid "You are muted! Expires in %d seconds." -msgstr "Jesteś zagłuszony! Wygasa w ciągu %d sekund." +msgstr "Jesteś wyciszony! Wygasa w ciągu %d sekund." #: /var/www/html/Tinyboard/inc/config.php:618 ../../../../inc/config.php:656 #: ../../../../inc/config.php:712 ../../../../inc/config.php:718 -- cgit v1.3 From 00600f241ff0357f57abdcd3a9f4c88cbfc1f5bd Mon Sep 17 00:00:00 2001 From: Jakub Skrzypnik Date: Thu, 1 Aug 2013 08:49:14 +0200 Subject: Correcting polish locale a bit --- inc/locale/pl_PL/LC_MESSAGES/tinyboard.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po index e8caf477..a5a58616 100644 --- a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po +++ b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.po @@ -190,7 +190,7 @@ msgstr "Nieoryginalna treść!" #: ../../../../inc/config.php:713 ../../../../inc/config.php:719 #, php-format msgid "Unoriginal content! You have been muted for %d seconds." -msgstr "Nieoryginalna treść! Zostałeś zagłuszony na %d sekund." +msgstr "Nieoryginalna treść! Zostałeś wyciszony na %d sekund." #: /var/www/html/Tinyboard/inc/config.php:617 ../../../../inc/config.php:655 #: ../../../../inc/config.php:711 ../../../../inc/config.php:717 -- cgit v1.3 From 9487eb4ac74afabe08b4c6a582bf385bda224aa3 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 1 Aug 2013 02:52:35 -0400 Subject: Compile Polish locale --- inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo | Bin 20956 -> 20950 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo index 73f434f7..d2807a37 100644 Binary files a/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo and b/inc/locale/pl_PL/LC_MESSAGES/tinyboard.mo differ -- cgit v1.3 From c1912b2a90c15eb46196abe60cd4ed0c324ec634 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 03:30:45 -0400 Subject: Move stylesheets from Tinyboard-Tools here --- stylesheets/dark.css | 150 +++++++++++ stylesheets/futaba+vichan.css | 88 +++++++ stylesheets/img/fade-miku.png | Bin 0 -> 234 bytes stylesheets/img/fade-yellow.png | Bin 0 -> 47975 bytes stylesheets/img/testorange_bg.gif | Bin 0 -> 2618 bytes stylesheets/img/testorange_f_bg.gif | Bin 0 -> 143 bytes stylesheets/img/testorange_testo.png | Bin 0 -> 20588 bytes stylesheets/img/testorange_textarea_bg.gif | Bin 0 -> 292 bytes stylesheets/img/testorange_top_bg.gif | Bin 0 -> 6551 bytes stylesheets/miku.css | 87 +++++++ stylesheets/testorange.css | 208 +++++++++++++++ stylesheets/wasabi.css | 391 +++++++++++++++++++++++++++++ 12 files changed, 924 insertions(+) create mode 100644 stylesheets/dark.css create mode 100644 stylesheets/futaba+vichan.css create mode 100644 stylesheets/img/fade-miku.png create mode 100644 stylesheets/img/fade-yellow.png create mode 100644 stylesheets/img/testorange_bg.gif create mode 100644 stylesheets/img/testorange_f_bg.gif create mode 100644 stylesheets/img/testorange_testo.png create mode 100644 stylesheets/img/testorange_textarea_bg.gif create mode 100644 stylesheets/img/testorange_top_bg.gif create mode 100644 stylesheets/miku.css create mode 100644 stylesheets/testorange.css create mode 100644 stylesheets/wasabi.css diff --git a/stylesheets/dark.css b/stylesheets/dark.css new file mode 100644 index 00000000..2248c9d3 --- /dev/null +++ b/stylesheets/dark.css @@ -0,0 +1,150 @@ +/** + * dark.css + * For AwsumChan by Circlepuller + */ +body { + background: #1E1E1E; + color: #999999; + font-family: sans-serif; + font-size: 12px; +} +h1 { + font-size: 20pt; + text-align: center; + letter-spacing: 0px; +} +div.title, h1 { + color: lime; + font-family: Arial, Helvetica, sans-serif; +} +div.title p { + font-size: 10px; +} +a:link, a:visited, p.intro a.email span.name { + color: #CCCCCC; + text-decoration: underline; + font-family: sans-serif; +} +a:link:hover, a:visited:hover { + color: #FF0000; + font-family: sans-serif; + text-decoration: underline overline; +} +a.post_no { + color: #AAAAAA; + text-decoration: none; +} +a.post_no:hover { + color: maroon; + text-decoration: underline overline; +} +div.post.reply { + background: #333333; + border: #555555 1px solid; +} +div.post.reply.highlighted { + background: transparent; + border: transparent 1px solid; +} +div.post.reply div.body a:link, div.post.reply div.body a:visited { + color: #CCCCCC; +} +div.post.reply div.body a:link:hover, div.post.reply div.body a:visited:hover { + color: #FF0000; +} +p.intro span.subject { + font-size: 12px; + font-family: sans-serif; + color: #446655; + font-weight: 800; +} +p.intro span.name { + color: #00CC00; + font-weight: 800; +} +p.intro a.capcode, p.intro a.nametag { + color: magenta; + margin-left: 0; +} +p.intro a.email, p.intro a.email span.name, p.intro a.email:hover, p.intro a.email:hover span.name { + color: #00CCCC; +} +input[type="text"], textarea, select { + background: #333333; + color: #CCCCCC; + border: #666666 1px solid; + padding-left: 5px; + padding-right: -5px; + font-family: sans-serif; + font-size: 10pt; +} +input[type="password"] { + background: #333333; + color: #CCCCCC; + border: #666666 1px solid; +} +form table tr th { + background: #333333; + color: #AAAAAA; + font-weight: 800; + text-align: left; + padding: 0; +} +div.banner { + background: #00AA00; + color: #FFFFFF; + text-align: center; + width: 250px; + padding: 4px; + padding-left: 12px; + padding-right: 12px; + margin-left: auto; + margin-right: auto; + font-size: 12px; +} +input[type="submit"] { + background: #333333; + border: #888888 1px solid; + color: #CCCCCC; +} +input[type="submit"]:hover { + background: #555555; + border: #888888 1px solid; + color: #FF0000; +} +p.fileinfo a:hover { + text-decoration: underline; +} +span.trip { + color: #AAAAAA; +} +div.pages { + color: #AAAAAA; + background: #333333; + border: #666666 1px solid; + font-family: sans-serif; + font-size: 10pt; +} +div.pages a.selected { + color: #CCCCCC; +} +hr { + height: 1px; + border: #333333 1px solid; +} +div.boardlist { + color: #999999; +} +div.ban { + background-color: transparent; + border: transparent 0px solid; +} +div.ban h2 { + background: transparent; + color: lime; + font-size: 12px; +} +table.modlog tr th { + background: #333333; + color: #AAAAAA; +} diff --git a/stylesheets/futaba+vichan.css b/stylesheets/futaba+vichan.css new file mode 100644 index 00000000..be0ab672 --- /dev/null +++ b/stylesheets/futaba+vichan.css @@ -0,0 +1,88 @@ +/* +piwnichan style, based on futaba.css of Tinyboard */ + +body { + background: #ffe; + color: #800000; + font-family: sans-serif; + font-size: 13px; +} +div.title h1 { + font-size: 24px; +} +div.title p { + font-size: 10px; +} +div.pages { + font-size: 13px !important; +} +a:link, a:visited, p.intro a.email span.name { + color: #0000ff; + font-size: inherit; + text-decoration: inherit; +} +a:link:hover { + color: #d00; + text-decoration: inherit; +} +span.omitted { + color: gray; +} +a.post_no { + color: #800000; +} +div.post.reply { + border: 0px; + background: #f0e0d6; +} +div.post.reply.highlighted { + background: #f0c0b0; + border-color: #d9bfb7; +} +div.post.reply div.body a { + color: navy; +} +p.intro span.subject { + color: #d00; +} +form table tr th { + background: #EA8; +} +div.ban h2 { + background: #FCA; + color: inherit; +} +div.ban { + border-color: #800; +} +div.ban p { + color: black; +} +div.pages { + padding: 7px 5px; + color: maroon; + font-size: 12pt; + + background: none; + border-width: 1px; + border-style: inset; + +} +div.pages a.selected { + color: #800; +} +hr { + border-width: 1px; + border-style: inset; +} +div.boardlist { + color: #B86; +} +div.boardlist a { + color: #800; +} +unimportant, .unimportant * { + font-size: 13px; +} +table.modlog tr th { + background: #EA8; +} diff --git a/stylesheets/img/fade-miku.png b/stylesheets/img/fade-miku.png new file mode 100644 index 00000000..a231913f Binary files /dev/null and b/stylesheets/img/fade-miku.png differ diff --git a/stylesheets/img/fade-yellow.png b/stylesheets/img/fade-yellow.png new file mode 100644 index 00000000..bd071754 Binary files /dev/null and b/stylesheets/img/fade-yellow.png differ diff --git a/stylesheets/img/testorange_bg.gif b/stylesheets/img/testorange_bg.gif new file mode 100644 index 00000000..79ed93b9 Binary files /dev/null and b/stylesheets/img/testorange_bg.gif differ diff --git a/stylesheets/img/testorange_f_bg.gif b/stylesheets/img/testorange_f_bg.gif new file mode 100644 index 00000000..1887e7fa Binary files /dev/null and b/stylesheets/img/testorange_f_bg.gif differ diff --git a/stylesheets/img/testorange_testo.png b/stylesheets/img/testorange_testo.png new file mode 100644 index 00000000..3d91c159 Binary files /dev/null and b/stylesheets/img/testorange_testo.png differ diff --git a/stylesheets/img/testorange_textarea_bg.gif b/stylesheets/img/testorange_textarea_bg.gif new file mode 100644 index 00000000..1c7bf27b Binary files /dev/null and b/stylesheets/img/testorange_textarea_bg.gif differ diff --git a/stylesheets/img/testorange_top_bg.gif b/stylesheets/img/testorange_top_bg.gif new file mode 100644 index 00000000..c1d18282 Binary files /dev/null and b/stylesheets/img/testorange_top_bg.gif differ diff --git a/stylesheets/miku.css b/stylesheets/miku.css new file mode 100644 index 00000000..23fb1d9d --- /dev/null +++ b/stylesheets/miku.css @@ -0,0 +1,87 @@ +/** + * miku.css + * For AwsumChan by Circlepuller + */ +body { + background: #D2FFEE url('img/fade-miku.png') top repeat-x; +} + +a:link, a:visited { + text-decoration: none; + color: #0093AB; +} + +a:link:hover, a:visited:hover { + color: #DD0000; +} + +a.post_no { + color: #000033; +} + +p.intro a.email span.name { + color: #0093AB; +} + +p.intro a.email:hover span.name { + color: #DD0000; +} + +h2, div.title, h1 { + color: #800000; +} + +form table tr th { + background: #95D2D3; +} + +div.banner { + background-color: #E04000; +} + +div.post.op hr { + border-color: #B7C9D5; +} + +p.intro span.subject { + color: #117743; + font-weight: 800; +} + +p.intro span.name { + color: #117743; + font-weight: 800; +} + +div.post.reply.highlighted { + background: #9988EE; +} + +div.post.reply { + background: #B6DDDE; + border-color: #8FCCCD; +} + +div.ban { + border: 1px solid #0093AB; +} + +div.ban h2 { + background: #B6DDDE; + color: #0093AB; +} + +div.pages { + color: #8899AA; + background: #B6DDDE; + border-right: 1px solid #8FCCCD; + border-bottom: 1px solid #8FCCCD; +} + +hr { + border-color: #B7D9C5; +} + +div.boardlist { + color: #0093AB; +} diff --git a/stylesheets/testorange.css b/stylesheets/testorange.css new file mode 100644 index 00000000..7b1ce0a6 --- /dev/null +++ b/stylesheets/testorange.css @@ -0,0 +1,208 @@ +/* +piwnichan style, based on testorange.css from Karachan */ + +body { + font-family: sans-serif; + font-size: 12px; + color:#bebebe; + + background-color: #1e1e1e; + background-image: url('img/testorange_testo.png'), url('img/testorange_top_bg.gif'), url('img/testorange_bg.gif'); + background-repeat: no-repeat, repeat-x, repeat; + background-attachment: fixed, scroll, scroll; + background-position: right bottom, 0% 0%, 0% 0%; +} + +a:link, a:visited, div.post.reply div.body a { + color:#ff9100; + text-decoration: none; +} +a:link:hover, a:visited:hover, div.post.reply div.body a:hover { + color:#ffff00; +} + +a.email span.name { + color:#ff9100 !important; + +} + +input { + color: #000; + background: #fff; +} +textarea { + background: #dedede url('img/testorange_textarea_bg.gif') repeat-x; +} +input, textarea { + border: 1px #fff solid; +} + +hr { + width: 100%; + height: 1px; + border: none; + background: #707070; + overflow: hidden; +} + +.reflink a:hover{ + font-weight: bold; +} +.adminbar { + text-align:right; + clear:both; + float:right; +} +h1 { + clear:both; + text-align:center; + font-size: 2.5em; + color:#ff9100; + width:100%; +} +div.title { + color:#ff9100; +} +div.banner, .replymode, .catalogmode { + text-align:center; + margin: 5px 0 5px 0; + padding: 5px 2px 5px 2px; + color:#000; + font-weight: bold; + width:100%; +} +.postblock, form table th { + color: #000; + font-size: 11px; + font-weight: bold; + text-align: center !important; +} + +.postarea { +} +.rules { + width: 468px; + font-size: 10px; +} +.rules li { + margin-left: 1em; +} +.footer { + text-align:center; + font-size:12px; +} +.passvalid { + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; + +} +.managehead { + background-color: #1e1e1e; + color: #bebebe; + padding:0px; +} +.postlists { + background: #000; + width:100%; + padding:0px; + color: #bebebe; +} +.row1 { + background-color: #1e1e1e; + color: #bebebe; +} +.row2 { + background: #1e1e1e; + color: #bebebe; +} +.unkfunc { + background:inherit; + color:#789922; +} +.filesize { + text-decoration:none; +} +.filetitle { + background:inherit; + font-size:1.2em; + color: #bebebe; + font-weight:800; +} +span.name, .postername { + color:#fff !important; + font-weight:bold; +} +span.trip, .postertrip { + color:#707070; +} +.oldpost { + color:#CC1105; + font-weight:800; +} +.omittedposts { + color:#707070; +} +.reply { + padding: 5px; + border: 1px #707070 solid !important; + background: #282828 !important; + + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; +} +.replyhl { + background-color: #1e1e1e; + color: #bebebe; +} +.doubledash { + vertical-align:top; + clear:both; + float:left; +} +.replytitle { + font-size: 1.2em; + color:#fff; + font-weight:800; +} +.commentpostername { + color: #fff; + font-weight:800; +} +.thumbnailmsg { + font-size: small; + color: #bebebe; +} +form table th, div.banner, div.pages, .replymode, .postblock, .passvalid, .catalogmode { + background: #ff9100 url('img/testorange_f_bg.gif') repeat-x !important; +} +div.pages { + color: black; + border: 0; +} + +.abbrev { + color:#707070; +} +.highlight { + background:#000; + border: 1px dashed #ff9100; +} + +#watchedthreads { + background-color: #282828 !important; +} + +.reflinkpreview { + background-color: #282828 !important; +} + diff --git a/stylesheets/wasabi.css b/stylesheets/wasabi.css new file mode 100644 index 00000000..a080a12a --- /dev/null +++ b/stylesheets/wasabi.css @@ -0,0 +1,391 @@ +/** + * wasabi.css + * For AwsumChan by Circlepuller + */ +body { + background: #F7F9B0 url('img/fade-yellow.png') repeat-x 50% 0%; + color: black; + font-family: arial, helvetica, sans-serif; + font-size: 10pt; + margin: 0 8px; + padding-left: 5px; + padding-right: 5px; +} +table * { + margin: 0; +} +a:link, a:visited { + text-decoration: underline; + color: #400040; +} +a:link:hover, a:visited:hover { + color: limegreen; +} +a.post_no { + color: black; + text-decoration: none; + margin: 0; + padding: 0; +} +p.intro a.post_no, p.intro a.email { + margin: 0; +} +p.intro a.email span.name { + color: #34345C; +} +p.intro a.email:hover span.name { + color: #ff0000; +} +p.intro label { + display: inline; +} +h2 { + color: #AF0A0F; + font-size: 11pt; + margin: 0px; + padding: 0px; +} +h1 { + font-family: tahoma; + letter-spacing: -2px; + font-size: 20pt; + margin-bottom: 0; +} +h1.logo img { + display: inline; + float: none; + background-image: url('/static/logo_bg.gif'); + background-repeat: no-repeat; + background-position: center; +} +div.title, h1 { + color: #AF0A0F; + text-align: center; +} +div.title { + font-size: 8pt; + margin-bottom: 2em; +} +form { + margin-bottom: 4em; +} +form table { + margin: auto; +} +form table input { + height: auto; +} +input[type="text"], input[type="password"], textarea { + border: 1px solid #a9a9a9; + text-indent: 0px; + text-shadow: none; + text-transform: none; + word-spacing: normal; +} +form table tr td { + text-align: left; + margin: 0px; + padding: 0px; +} +form table tr th { + text-align: left; + padding: 4px; +} +form table tr th { + background: #D7FE85; +} +form table tr td div { + text-align: center; + float: left; + padding-left: 3px; +} +form table tr td div input { + display: block; + margin: 2px auto 0 auto; +} +form table tr td div label { + font-size: 10px; +} +.unimportant, .unimportant * { + font-size: 10px; +} +p.fileinfo { + display: block; + margin: 0px; + padding-right: 7em; +} +div.banner { + background-color: #400040; + font-size: 12pt; + font-weight: bold; + text-align: center; + margin: 1em 0; +} +div.banner, div.banner a { + color: white; +} +div.banner a:hover { + color: #EEF2FF; + text-decoration: none; +} +img.banner { + float: none; + margin: 4px auto 0 auto; +} +img { + display: block; + float: left; + margin: 10px 20px; + border: none; +} +div.post img { + padding: 5px; + margin: 5px 20px 0 0; +} +div.post img.icon { + display: inline; + float: none; + margin: 0 5px; + padding: 0; +} +div.post.op { + margin-right: 20px; + margin-bottom: 5px; +} +div.post.op hr { + border-color: #D9BFB7; +} +p.intro { + margin: 0.5em 0; + padding: 0; + padding-bottom: 0.2em; +} +input.delete { + float: left; + margin: 1px 6px 0 0; +} +p.intro span.subject { + color: #0F0C5D; + font-weight: bold; +} +p.intro span.name { + color: #117743; + font-weight: bold; +} +p.intro a.capcode, p.intro a.nametag { + color: #F00000; + margin-left: 0; +} +p.intro a { + margin-left: 8px; +} +div.delete { + float: right; +} +div.post.reply p { + margin: 0.3em 0 0 0; +} +div.post.reply div.body { + margin-left: 1.8em; + margin-top: 0.8em; + padding-right: 3em; + padding-bottom: 0.3em; +} +div.post.reply.highlighted { + background-color: #FFF; + border-color: #CCC; +} +div.post.reply div.body a { + color: #D00; +} +div.post { + max-width: 97%; +} +div.post div.body { + word-wrap: break-word; +} +div.post.reply { + background: #D7FE85; + margin: 0.2em 16px; + padding: 0.2em 0.3em 0.5em 0.6em; + border-width: 1px; + border-style: none solid solid none; + border-color: lightgreen; + display: inline-block; +} +span.trip { + color: #228854; +} +span.quote { + color: #3C6D8A; +} +span.omitted { + display: block; + margin-top: 1em; +} +br.clear { + clear: left; +} +span.controls { + float: right; + margin: 0; + padding: 0; + font-size: 80%; +} +span.controls.op { + float: none; + margin-left: 10px; +} +span.controls a { + margin: 0; +} +div#wrap { + width: 900px; + margin:0 auto; +} +div.ban { + background-color: white; + border: 1px solid #400040; + max-width: 700px; + margin: 30px auto; +} +div.ban p, div.ban h2 { + padding: 3px 7px; +} +div.ban h2 { + background: #D7FE85; + color: #400040; + font-size: 12pt; +} +div.ban p { + font-size: 12px; + margin-bottom: 12px; +} +div.ban p.reason { + font-weight: bold; +} +span.heading { + color: #AF0A0F; + font-size: 11pt; + font-weight: bold; + display: block; +} +span.spoiler { + background: black; + color: black; +} +div.post.reply div.body span.spoiler a { + color: black; +} +span.spoiler:hover, div.post.reply div.body span.spoiler:hover a { + color: white; +} +div.styles { + float: right; + padding-bottom: 20px; +} +div.styles a { + margin: 0 10px; +} +div.styles a.selected { + text-decoration: none; +} +table.test { + width: 100%; +} +table.test td, table.test th { + text-align: left; + padding: 5px; +} +table.test tr.h th { + background: #98E; +} +table.test td img { + margin: 0; +} +fieldset label { + display: block; +} +div.pages { + color: limegreen; + background: #D7FE85; + display: inline; + padding: 8px; + border-right: 1px solid limegreen; + border-bottom: 1px solid limegreen; +} +div.pages a.selected { + color: black; + font-weight: bolder; +} +div.pages a:link { + text-decoration: none; +} +div.pages form { + margin: 0; + padding: 0; + display: inline; +} +div.pages form input { + margin: 0 5px; + display: inline; +} +hr { + border: none; + border-top: 1px solid limegreen; + height: 0px; +} +div.boardlist { + color: limegreen; + font-size: 9pt; + margin-top: 3px; +} +div.boardlist.bottom { + margin-top: 20px; +} +div.boardlist a { + text-decoration: none; +} +div.report { + color: #333; +} +table.modlog { + margin: auto; + width: 100%; +} +table.modlog tr td { + text-align: left; + margin: 0px; + padding: 4px 15px 0 0; +} +table.modlog tr th { + text-align: left; + padding: 4px 15px 5px 5px; + white-space: nowrap; +} +table.modlog tr th { + background: #D7FE85; +} +td.minimal, th.minimal { + width: 1%; + white-space: nowrap; +} +div.top_notice { + text-align: center; + margin: 5px auto; +} +span.public_ban { + display: block; + color: red; + font-weight: bold; + margin-top: 15px; +} +span.toolong { + display: block; + margin-top: 15px; +} +div.blotter { + color: red; + font-weight: bold; + text-align: center; +} -- cgit v1.3 From 6df1a179ed3554faf1945a366ae87992dfe23e95 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Wed, 2 Jan 2013 07:53:00 +0100 Subject: Add szalet.css style by Kurwancka from http://lepszy.vichan.net/ --- stylesheets/img/szalet_bg.png | Bin 0 -> 54946 bytes stylesheets/img/szalet_hr.png | Bin 0 -> 1023 bytes stylesheets/szalet.css | 210 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 stylesheets/img/szalet_bg.png create mode 100644 stylesheets/img/szalet_hr.png create mode 100644 stylesheets/szalet.css diff --git a/stylesheets/img/szalet_bg.png b/stylesheets/img/szalet_bg.png new file mode 100644 index 00000000..12e4dcca Binary files /dev/null and b/stylesheets/img/szalet_bg.png differ diff --git a/stylesheets/img/szalet_hr.png b/stylesheets/img/szalet_hr.png new file mode 100644 index 00000000..97414ce5 Binary files /dev/null and b/stylesheets/img/szalet_hr.png differ diff --git a/stylesheets/szalet.css b/stylesheets/szalet.css new file mode 100644 index 00000000..1bdc212a --- /dev/null +++ b/stylesheets/szalet.css @@ -0,0 +1,210 @@ +/* nowy styl */ + +body { + font-family: sans-serif; + font-size: 12px; + color: #C4C4C4; + + background-color: #1e1e1e; + background-image: url('img/szalet_bg.png'); + background-repeat: repeat; + +} + + div.pages a.selected { +color: #FFFCFC !important;} + + +a:link, a:visited, div.post.reply p.body a { + color: #86472F; + text-decoration: none; +} +a:link:hover, a:visited:hover, div.post.reply p.body a:hover { + color: rgb(138, 138, 35); +} + +a.email span.name { + color: #ECDDCA !important; + +} + +input { + color: #8A7656; + background: none !important; +} +textarea { + background: #dedede url('img/testorange_textarea_bg.gif') repeat-x; +} +input, textarea { +} + +hr { + height: 3px; +border-width: 0px; +background: url('img/szalet_hr.png') center no-repeat; +background-size: 100% 100%; + overflow: hidden; +} + +.reflink a:hover{ + font-weight: bold; +} +.adminbar { + text-align:right; + clear:both; + float:right; +} +h1 { + clear:both; + text-align:center; + font-size: 2.5em; + color: sandybrown; + width:100%; +} +div.title { + color: #AF8C5D; +} +div.banner, .replymode, .catalogmode { + text-align:center; + margin: 5px 0 5px 0; + padding: 5px 2px 5px 2px; + color: sandybrown; + font-weight: bold; + width:100%; +} +.postblock, form table th { + color: sandybrown; + font-size: 11px; + font-weight: bold; + text-align: center !important; +} + +.postarea { +} +.rules { + width: 468px; + font-size: 10px; +} +.rules li { + margin-left: 1em; +} +.footer { + text-align:center; + font-size:12px; +} +.passvalid { + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; + +} +.managehead { + background-color: #1e1e1e; + color: #bebebe; + padding:0px; +} +.postlists { + background: #000; + width:100%; + padding:0px; + color: #bebebe; +} +.row1 { + background-color: #1e1e1e; + color: #bebebe; +} +.row2 { + background: #1e1e1e; + color: #bebebe; +} +.unkfunc { + background:inherit; + color:#789922; +} +.filesize { + text-decoration:none; +} +.filetitle { + background:inherit; + font-size:1.2em; + color: #bebebe; + font-weight:800; +} + +p.intro span.subject { +color: #D11C2A; +font-weight: bold; +} + + +span.name, .postername { + color: #DAAD66 !important; + font-weight:bold; +} +span.trip, .postertrip { + color: #B88146; +} +.oldpost { + color:#CC1105; + font-weight:800; +} +span.omitted, .omittedposts { + color: #A39E96; +} +.reply { + padding: 5px; + border: 1px sandyBrown solid !important; + background: #200000 !important; + + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; +} +.replyhl { + background-color: #1e1e1e; + color: #bebebe; +} +.doubledash { + vertical-align:top; + clear:both; + float:left; +} +.replytitle { + font-size: 1.2em; + color:#fff; + font-weight:800; +} +.commentpostername { + color: #fff; + font-weight:800; +} +.thumbnailmsg { + font-size: small; + color: #bebebe; +} +form table th, div.banner, div.pages, .replymode, .postblock, .passvalid, .catalogmode { + background: #200000!important; + border: 1px solid sandyBrown; +} +div.pages { + color: rgb(143, 139, 139); + border: 0; + background: none !important; +} + +.abbrev { + color:#707070; +} +.highlight { + background:#000; + border: 1px dashed #ff9100; +} -- cgit v1.3 From 54abc409589614a24375a5d0bde33f10954d8145 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Wed, 2 Jan 2013 07:53:50 +0100 Subject: Add luna.css style by klaczy, ported by asiekierka --- stylesheets/img/luna_bg1.png | Bin 0 -> 27337 bytes stylesheets/img/luna_bg2.png | Bin 0 -> 803 bytes stylesheets/luna.css | 447 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 447 insertions(+) create mode 100644 stylesheets/img/luna_bg1.png create mode 100644 stylesheets/img/luna_bg2.png create mode 100644 stylesheets/luna.css diff --git a/stylesheets/img/luna_bg1.png b/stylesheets/img/luna_bg1.png new file mode 100644 index 00000000..fe72c24e Binary files /dev/null and b/stylesheets/img/luna_bg1.png differ diff --git a/stylesheets/img/luna_bg2.png b/stylesheets/img/luna_bg2.png new file mode 100644 index 00000000..ea4688ad Binary files /dev/null and b/stylesheets/img/luna_bg2.png differ diff --git a/stylesheets/luna.css b/stylesheets/luna.css new file mode 100644 index 00000000..2256f8c2 --- /dev/null +++ b/stylesheets/luna.css @@ -0,0 +1,447 @@ +body { + background-color: #171C4E; + background-image: url('img/luna_bg1.png'), url('img/luna_bg2.png'); + background-repeat: no-repeat, repeat-x; + background-attachment: fixed, scroll; + background-position: right bottom, 0% 0%; + font-family: sans-serif; + font-size: 12px; + color:#ffffff; + margin: 0 8px; + padding-left: 5px; + padding-right: 5px; +} +table * { + margin: 0; +} +a, a:visited { + text-decoration: none; + color: #0091ff;; +} +a, a:selected { + text-decoration: bold; + color: #ffffff; +} +a:hover, p.intro a.post_no:hover { + color: #ffffff; +} +a.post_no { + text-decoration: none; + margin: 0; + padding: 0; +} +p.intro a.post_no { + color: inherit; +} +p.intro a.post_no, p.intro a.email { + margin: 0; +} +p.intro a.email span.name { + color: #0091ff; +} +p.intro a.email:hover span.name { + color: #ffffff; +} +p.intro label { + display: inline; +} +h2 { + color: #0091ff; + font-size: 11pt; + margin: 0; + padding: 0; +} +header { + margin: 1em 0; +} +h1 { + color: #0091ff; + letter-spacing: -2px; + font-size: 20pt; + margin: 0; +} +header div.subtitle, h1 { + color: #FFFFFF; + text-align: center; +} +header div.subtitle { + font-size: 8pt; +} +form { + margin-bottom: 4em; +} +form table { + margin: auto; +} +form table input { + height: auto; +} +input[type="text"], input[type="password"], textarea { + border: 1px solid #a9a9a9; + text-indent: 0; + text-shadow: none; + text-transform: none; + word-spacing: normal; + box-shadow: 3px 3px 3px #111; + border-radius: 10px; +} +form table tr td { + text-align: left; + margin: 0; + padding: 0; +} +form table.mod tr td { + padding: 2px; +} +form table tr th { + text-align: left; + padding: 4px; +} +form table tr th { + background: #000000; +} +form table tr td div { + text-align: center; + float: left; + padding-left: 3px; +} +form table tr td div input { + display: block; + margin: 2px auto 0 auto; + border-radius: 10px; +} +form table tr td div label { + font-size: 10px; +} +.unimportant, .unimportant * { + font-size: 10px; +} +p.fileinfo { + display: block; + margin: 0; + padding-right: 7em; + border-radius: 10px; +} +div.banner { + background-color: #000000; + font-size: 12pt; + font-weight: bold; + text-align: center; + margin: 1em 0; +} +div.banner, div.banner a { + color: #aaa; +} +div.banner a:hover { + color: #000000; + text-decoration: none; +} +img.banner { + float: none; + border: 1px solid #a9a9a9; + margin: 12px auto 0 auto; +} +img { + display: block; + float: left; + margin: 10px 20px; + border: none; +} +div.post img { + padding: 5px; + margin: 5px 20px 0 0; +} +div.post img.icon { + display: inline; + float: none; + margin: 0 5px; + padding: 0; +} +div.post.op { + margin-right: 20px; + margin-bottom: 5px; + border-radius: 10px; +} +div.post.op hr { + border-color: #040934; +} +p.intro { + margin: 0.5em 0; + padding: 0; + padding-bottom: 0.2em; +} +input.delete { + float: left; + margin: 1px 6px 0 0; +} +p.intro span.subject { + color: #CCCCEE; + font-weight: bold; +} +p.intro span.name { + color: #BBBBDD; + font-weight: bold; +} +p.intro span.capcode, p.intro a.capcode, p.intro a.nametag { + color: #CCCCEE; + margin-left: 0; +} +p.intro a { + margin-left: 8px; +} +div.delete { + float: right; +} +div.post.reply p { + margin: 0.3em 0 0 0; +} +div.post.reply div.body { + margin-left: 1.8em; + margin-top: 0.8em; + padding-right: 3em; + padding-bottom: 0.3em; +} +div.post.reply.highlighted { + background: #000000; +} +div.post.reply div.body a { + color: #0091FF; +} +div.post { + max-width: 97%; +} +div.post div.body { + word-wrap: break-word; + white-space: pre-wrap; +} +div.post.reply { + margin-right: 20px; + margin-bottom: 5px; + padding: 5px; + border: 1px #353868 solid; + background: rgba(53, 56, 104, 0.6) !important; + box-shadow: 2px 2px 2px #353868; + display: inline-block; + border-radius: 10px; +} +span.trip { + color: #DDDDDD; +} +span.quote { + color: #FFFF55; +} +span.omitted { + display: block; + margin-top: 1em; +} +br.clear { + clear: left; + display: block; +} +span.controls { + float: right; + margin: 0; + padding: 0; + font-size: 80%; +} +span.controls.op { + float: none; + margin-left: 10px; +} +span.controls a { + margin: 0; +} +div#wrap { + width: 900px; + margin:0 auto; +} +div.ban { + background: #070C3E; + border: 1px solid #00; + max-width: 700px; + margin: 30px auto; +} +div.ban p, div.ban h2 { + padding: 3px 7px; +} +div.ban h2 { + background: #000; + color: #FFF; + font-size: 12pt; +} +div.ban p { + font-size: 12px; + margin-bottom: 12px; +} +div.ban p.reason { + font-weight: bold; +} +span.heading { + color: #000; + font-size: 11pt; + font-weight: bold; +} +span.spoiler { + background: black; + color: black; + padding: 0px 1px; +} +div.post.reply div.body span.spoiler a { + color: black; +} +span.spoiler:hover, div.post.reply div.body span.spoiler:hover a { + color: white; +} +div.styles { + color: #B7C5D9; + background: #353868; + display: inline; + padding: 8px; + border-right: 1px solid #000000; + border-bottom: 1px solid #000000; + float: right; +} +div.styles a { + text-decoration: none; +} +div.styles a.selected { + color: #FFF; + font-weight: bolder; +} +div.styles form { + margin: 0; + padding: 0; + display: inline; +} +table.test { + width: 100%; +} +table.test td, table.test th { + text-align: left; + padding: 5px; +} +table.test tr.h th { + background: #000; +} +table.test td img { + margin: 0; +} +fieldset label { + display: block; +} +fieldset legend { + background: black; + color: white; + border: 1px solid #000 +} +div.pages { + color: #B7C5D9; + background: #353868; + display: inline; + padding: 8px; + border-right: 1px solid #000000; + border-bottom: 1px solid #000000; +} +div.pages a.selected { + color: #FFF; + font-weight: bolder; +} +div.pages a { + text-decoration: none; +} +div.pages form { + margin: 0; + padding: 0; + display: inline; +} +div.pages form input { + margin: 0 5px; + display: inline; +} +hr { + border: none; + border-top: 1px solid #000000; + height: 0; + clear: left; +} +div.boardlist { + color: #B7C5D9; + background: #353868; + display: inline; + padding: 8px; + border-right: 1px solid #000000; + border-bottom: 1px solid #000000; +} +div.boardlist.bottom { + margin-top: 20px; +} +div.boardlist a { + text-decoration: none; +} +div.boardlist a.selected { + color: #FFF; + font-weight: bolder; +} +div.report { + color: #333; +} +table.modlog { + margin: auto; + width: 100%; +} +table.modlog tr td { + text-align: left; + margin: 0; + padding: 4px 15px 0 0; +} +table.modlog tr th { + text-align: left; + padding: 4px 15px 5px 5px; + white-space: nowrap; +} +table.modlog tr th { + background: #000; +} +td.minimal, th.minimal { + width: 1%; + white-space: nowrap; +} +div.top_notice { + text-align: center; + margin: 5px auto; +} +span.public_ban { + display: block; + color: red; + font-weight: bold; + margin-top: 15px; +} +span.toolong { + display: block; + margin-top: 15px; +} +div.blotter { + color: red; + font-weight: bold; + text-align: center; +} +table.mod.config-editor { + font-size: 9pt; + width: 100%; +} +table.mod.config-editor td { + text-align: left; + padding: 5px; + border-bottom: 1px solid #000; +} +table.mod.config-editor input[type="text"] { + width: 98%; +} + +.desktop-style div.boardlist:nth-child(1):hover { + background-color: inherit; +} + +.desktop-style .sub { + background: none; +} -- cgit v1.3 From 5174bf23ebb3d2f7b20d1bbdca8197a1273ee9e8 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Wed, 2 Jan 2013 07:54:44 +0100 Subject: Add Terminal-2 style by spider --- stylesheets/terminal2.css | 170 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 stylesheets/terminal2.css diff --git a/stylesheets/terminal2.css b/stylesheets/terminal2.css new file mode 100644 index 00000000..f08d0b3a --- /dev/null +++ b/stylesheets/terminal2.css @@ -0,0 +1,170 @@ +body { + background: #000000; + color: #00FF00; + font-family: sans-serif; + font-size: 12px; +} +h1 { + font-size: 20pt; + text-align: center; + letter-spacing: 0px; +} +div.title, h1 { + color: lime; + font-family: sans-serif; +} +div.title p { + font-size: 10px; +} +a:link, a:visited, p.intro a.email span.name { + color: #00FF00; + text-decoration: underline; + font-family: sans-serif; +} +a:link:hover, a:visited:hover { + color: #00FF00; + font-family: sans-serif; + text-decoration: underline overline; +} +a.post_no { + color: #00FF00; + text-decoration: none; +} +a.post_no:hover { + color: #00FF00; + text-decoration: underline overline; +} +div.post.reply { + background: #000000; + border: 1px dashed; + border-color:#00FF00; +} +div.post.reply.highlighted { + background: transparent; + border: transparent 1px dashed; + border-color:#00FF00; +} +div.post.reply div.body a:link, div.post.reply div.body a:visited { + color: #00FF00; +} +div.post.reply div.body a:link:hover, div.post.reply div.body a:visited:hover { + color: #00FF00; +} +p.intro span.subject { + font-size: 12px; + font-family: sans-serif; + color: #446655; + font-weight: 800; +} +p.intro span.name { + color: #00FF00; + font-weight: 800; +} +p.intro a.capcode, p.intro a.nametag { + color: #00FF00; + margin-left: 0; +} +p.intro a.email, p.intro a.email span.name, p.intro a.email:hover, p.intro a.email:hover span.name { + color: #00FF00; +} +input[type="text"], textarea, select { + background: #000000; + color: #00FF00; + border: 1px dashed; + border-color:#00FF00; + padding-left: 5px; + padding-right: -5px; + font-family: sans-serif; + font-size: 10pt; +} +input[type="password"] { + background: #000000; + color: #00FF00; + border: 1px dashed; + border-color:#00FF00; +} + +form table tr th { + background: #000000; + color: #00FF00; + font-weight: 800; + text-align: left; + padding: 0; + border: #00FF00 1px dashed; + border-color:#00FF00; +} +div.banner { + background: #00AA00; + color: #FFFFFF; + text-align: center; + width: 250px; + padding: 4px; + padding-left: 12px; + padding-right: 12px; + margin-left: auto; + margin-right: auto; + font-size: 12px; +} +input[type="submit"] { + background: #000000; + border: 1px dashed; + border-color:#00FF00; + color: #00FF00; +} +input[type="submit"]:hover { + background: #000000; + border: 1px dashed; + border-color:#00FF00; + color: #00FF00; +} +p.fileinfo a:hover { + text-decoration: underline; +} +span.trip { + color: #00FF00; +} +div.pages { + color: #00FF00; + background: #000000; + border: 1px dashed; + border-color:#00FF00; + font-family: sans-serif; + font-size: 10pt; +} +div.pages a.selected { + color: #00FF00; +} +hr { + height: 1px; + border: 1px dashed; + border-color:#00FF00; +} +div.boardlist { + color: #00FF00; +} +div.ban { + border: transparent 0px dashed; + border-color:#00FF00; +} +div.ban h2 { + background: transparent; + color: lime; + font-size: 12px; +} +table.modlog tr th { + background: #000000; + color: #00FF00; +} + +.desktop-style div.boardlist:nth-child(1) { + background-color: black; + border-bottom: #00FF00 1px dashed; +} +.desktop-style div.boardlist:nth-child(1):hover { + background-color: black; +} + +.desktop-style .sub { + background: none; +} + -- cgit v1.3 From fc455f8d8f63b011c002647810ba0093707ee372 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Wed, 2 Jan 2013 07:55:13 +0100 Subject: Add futaba-light.css by Kurwancka --- stylesheets/futaba-light.css | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 stylesheets/futaba-light.css diff --git a/stylesheets/futaba-light.css b/stylesheets/futaba-light.css new file mode 100644 index 00000000..76a82f58 --- /dev/null +++ b/stylesheets/futaba-light.css @@ -0,0 +1,98 @@ +/* +piwnichan style, based on futaba.css of Tinyboard */ + +body { + background: #FFF0DF; + color: #800000; + font-family: sans-serif; + font-size: 13px; +} +div.title h1 { + font-size: 24px; +} +div.title p { + font-size: 10px; +} +div.pages { + font-size: 13px !important; +} +a:link, a:visited, p.intro a.email span.name { + color: #A32615; + font-size: inherit; + text-decoration: inherit; +} +a:link:hover { + color: #d00; + text-decoration: inherit; +} +span.omitted { + color: gray; +} +a.post_no { + color: #800000; +} +div.post.reply { + border: 0px; + background: #FAE8D4; + border: 1px solid #E2C5B1; +} +div.post.reply.highlighted { + background: #f0c0b0; + border-color: #d9bfb7; +} +div.post.reply div.body a { + color: rgb(190, 79, 43); +} +p.intro span.subject { + color: #AA4848; +} +form table tr th { + background: #EED1C2; +} +div.ban h2 { + background: #FCA; + color: inherit; +} +div.ban { + border-color: #800; +} +div.ban p { + color: black; +} +div.pages { + padding: 7px 5px; + color: maroon; + font-size: 12pt; + + background: none; + border-width: 1px; + border-style: inset; + +} +div.pages a.selected { + color: #800; +} +hr { + border-width: 1px; + border-style: inset; +} +div.boardlist { + color: #B86; +} +div.boardlist a { + color: #800; +} +unimportant, .unimportant * { + font-size: 13px; +} +table.modlog tr th { + background: #EA8; +} + +.desktop-style div.boardlist:nth-child(1) { + text-shadow: #fff 1px 1px 1px, #fff -1px -1px 1px; +} + + +.desktop-style div.boardlist:nth-child(1):hover { + background-color: rgba(90%, 90%, 90%, 0.55); +} -- cgit v1.3 From 32dd6cc34f49fedc3b7bc61d15f5dea28d713cc6 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Wed, 2 Jan 2013 08:08:14 +0100 Subject: Add stripes.css by klaczy --- stylesheets/img/stripes_bg.png | Bin 0 -> 19901 bytes stylesheets/img/stripes_submit.png | Bin 0 -> 163 bytes stylesheets/img/stripes_textarea.png | Bin 0 -> 2816 bytes stylesheets/stripes.css | 67 +++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 stylesheets/img/stripes_bg.png create mode 100644 stylesheets/img/stripes_submit.png create mode 100644 stylesheets/img/stripes_textarea.png create mode 100644 stylesheets/stripes.css diff --git a/stylesheets/img/stripes_bg.png b/stylesheets/img/stripes_bg.png new file mode 100644 index 00000000..17a4d6b4 Binary files /dev/null and b/stylesheets/img/stripes_bg.png differ diff --git a/stylesheets/img/stripes_submit.png b/stylesheets/img/stripes_submit.png new file mode 100644 index 00000000..31eabaf0 Binary files /dev/null and b/stylesheets/img/stripes_submit.png differ diff --git a/stylesheets/img/stripes_textarea.png b/stylesheets/img/stripes_textarea.png new file mode 100644 index 00000000..b6401acd Binary files /dev/null and b/stylesheets/img/stripes_textarea.png differ diff --git a/stylesheets/stripes.css b/stylesheets/stripes.css new file mode 100644 index 00000000..da3f2aab --- /dev/null +++ b/stylesheets/stripes.css @@ -0,0 +1,67 @@ +/** + * stripes.css + * for vichan by klaczy + */ +body { + background: url('img/stripes_bg.png'); + color: #BBB; + font-family: 'Hevletica', sans-serif; + font-size: 12px; +} +div.boardlist:nth-child(1):hover { + background: #222 !important; +} +div.reply, div.pages { + background: -moz-linear-gradient(bottom, #323232 40%, #2E2E2E 75%) !important; + border: 1px solid #2D2D2D !important; + box-shadow: 0px 0px 10px #2C2C2C; + color: #BBB !important; +} +.reply { + margin-top: 0.5em !important; +} +.body a, a:hover { + color: #FF6666; +} +table th { background: none !important } +a, a:visited { + color: #BBB; +} +hr { + border: 0 !important; + height: 1px !important; + background-color: #AAA !important; + margin: 1.5em 0 1.5em !important; +} +.name, .body a { + color: #FF6666 !important; +} +.subject, h1, .subtitle, .selected { + color: #FF6699 !important; +} +.capcode { + color: #FF66CC !important; +} +input, textarea { + background: url('img/stripes_textarea.png'); + border: 1px #CCC; + border-radius: 3px; + padding: 3px; +} +input[type="text"] { width: 200px } +textarea { + background-size: 100% 100%; + background-color: #FCFCFC; + background-repeat: repeat-x; + width: 100%; + height: 200px; +} +input[type="submit"] { + border: 1px solid rgb(204, 204, 204); + background: url('img/stripes_submit.png'); + height: 23px; + margin-left: 0.5em; +} +.delete { + margin-top: 0.5em; +} -- cgit v1.3 From cd82c167a2c8d1205296c653a3e7f01b79a62116 Mon Sep 17 00:00:00 2001 From: szalej Date: Sat, 19 Jan 2013 02:38:01 +0100 Subject: Update stylesheets/szalet.css --- stylesheets/szalet.css | 75 +++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/stylesheets/szalet.css b/stylesheets/szalet.css index 1bdc212a..e4deb8ee 100644 --- a/stylesheets/szalet.css +++ b/stylesheets/szalet.css @@ -1,14 +1,27 @@ -/* nowy styl */ +/* szalet 1.2 */ body { font-family: sans-serif; font-size: 12px; - color: #C4C4C4; + color: #99938D; background-color: #1e1e1e; background-image: url('img/szalet_bg.png'); background-repeat: repeat; - +} + +.desktop-style .bl-menu{ +background-image: url('img/szalet_bg.png'); +background-repeat: repeat; +/*background-color: #200000;*/ +} + +.boardlist .board a { +background-color: #200000; +} + +p.intro span.capcode, p.intro a.capcode, p.intro a.nametag { +color: #26899C; } div.pages a.selected { @@ -16,15 +29,15 @@ color: #FFFCFC !important;} a:link, a:visited, div.post.reply p.body a { - color: #86472F; + color: #7A422C!important; text-decoration: none; } a:link:hover, a:visited:hover, div.post.reply p.body a:hover { - color: rgb(138, 138, 35); + color: #8A8A23!important; } a.email span.name { - color: #ECDDCA !important; + color: #4B4B4B !important; } @@ -36,6 +49,8 @@ textarea { background: #dedede url('img/testorange_textarea_bg.gif') repeat-x; } input, textarea { +background: #200000; +color: #99938D; } hr { @@ -58,7 +73,7 @@ h1 { clear:both; text-align:center; font-size: 2.5em; - color: sandybrown; + color: #583E28; width:100%; } div.title { @@ -68,12 +83,12 @@ div.banner, .replymode, .catalogmode { text-align:center; margin: 5px 0 5px 0; padding: 5px 2px 5px 2px; - color: sandybrown; + color: #583E28; font-weight: bold; width:100%; } .postblock, form table th { - color: sandybrown; + color: #583E28; font-size: 11px; font-weight: bold; text-align: center !important; @@ -140,13 +155,13 @@ div.banner, .replymode, .catalogmode { } p.intro span.subject { -color: #D11C2A; +color: #771018; font-weight: bold; } span.name, .postername { - color: #DAAD66 !important; + color: #8A775B !important; font-weight:bold; } span.trip, .postertrip { @@ -159,52 +174,30 @@ span.trip, .postertrip { span.omitted, .omittedposts { color: #A39E96; } -.reply { +div.post.reply { padding: 5px; - border: 1px sandyBrown solid !important; - background: #200000 !important; + border: 1px #583E28 solid !important; + background: #200000; -webkit-border-radius: 10px; -khtml-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; } +div.post.reply.highlighted { +background: #583E28; +} + .replyhl { background-color: #1e1e1e; color: #bebebe; } -.doubledash { - vertical-align:top; - clear:both; - float:left; -} -.replytitle { - font-size: 1.2em; - color:#fff; - font-weight:800; -} -.commentpostername { - color: #fff; - font-weight:800; -} -.thumbnailmsg { - font-size: small; - color: #bebebe; -} form table th, div.banner, div.pages, .replymode, .postblock, .passvalid, .catalogmode { background: #200000!important; - border: 1px solid sandyBrown; + border: 1px solid #583E28; } div.pages { color: rgb(143, 139, 139); border: 0; background: none !important; } - -.abbrev { - color:#707070; -} -.highlight { - background:#000; - border: 1px dashed #ff9100; -} -- cgit v1.3 From d1e05f7a2f266f47aaff3d2195515b2f1234439f Mon Sep 17 00:00:00 2001 From: cccxd Date: Sat, 19 Jan 2013 21:22:40 +0100 Subject: style --- stylesheets/img/jungle_bg.png | Bin 0 -> 97254 bytes stylesheets/img/jungle_bg1.png | Bin 0 -> 100273 bytes stylesheets/img/jungle_td.png | Bin 0 -> 147347 bytes stylesheets/img/jungle_td2.png | Bin 0 -> 129711 bytes stylesheets/img/rect820.png | Bin 0 -> 38261 bytes stylesheets/img/rect821.png | Bin 0 -> 38762 bytes stylesheets/jungle.css | 135 +++++++++++++++++++++++++++ stylesheets/piwnichan.css | 206 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 341 insertions(+) create mode 100644 stylesheets/img/jungle_bg.png create mode 100644 stylesheets/img/jungle_bg1.png create mode 100644 stylesheets/img/jungle_td.png create mode 100644 stylesheets/img/jungle_td2.png create mode 100755 stylesheets/img/rect820.png create mode 100755 stylesheets/img/rect821.png create mode 100644 stylesheets/jungle.css create mode 100644 stylesheets/piwnichan.css diff --git a/stylesheets/img/jungle_bg.png b/stylesheets/img/jungle_bg.png new file mode 100644 index 00000000..649bafe7 Binary files /dev/null and b/stylesheets/img/jungle_bg.png differ diff --git a/stylesheets/img/jungle_bg1.png b/stylesheets/img/jungle_bg1.png new file mode 100644 index 00000000..4d25c184 Binary files /dev/null and b/stylesheets/img/jungle_bg1.png differ diff --git a/stylesheets/img/jungle_td.png b/stylesheets/img/jungle_td.png new file mode 100644 index 00000000..66a8d6ec Binary files /dev/null and b/stylesheets/img/jungle_td.png differ diff --git a/stylesheets/img/jungle_td2.png b/stylesheets/img/jungle_td2.png new file mode 100644 index 00000000..4c6cd1a0 Binary files /dev/null and b/stylesheets/img/jungle_td2.png differ diff --git a/stylesheets/img/rect820.png b/stylesheets/img/rect820.png new file mode 100755 index 00000000..c0a16c18 Binary files /dev/null and b/stylesheets/img/rect820.png differ diff --git a/stylesheets/img/rect821.png b/stylesheets/img/rect821.png new file mode 100755 index 00000000..a24cbf13 Binary files /dev/null and b/stylesheets/img/rect821.png differ diff --git a/stylesheets/jungle.css b/stylesheets/jungle.css new file mode 100644 index 00000000..881eb88b --- /dev/null +++ b/stylesheets/jungle.css @@ -0,0 +1,135 @@ +/* based on jungle.css from brchan.org */ + +body { + background: #ffe; + background-image: url('img/jungle_bg1.png'), url('img/jungle_bg.png'); + background-repeat: repeat-x, repeat; + +background-attachment: scroll, scroll; + color: #054500; + font-family: serif; + font-size: 16px; +} +div.title h1 { + font-size: 24px; +} +div.title p { + font-size: 10px; +} +a:link, a:visited, p.intro a.email span.name { + color: #00E; +} +a:link:hover { + color: #d00; +} +a.post_no { + color: #800000; +} + +desktop-style .bl-menu{ + background-image: url('img/jungle_bg1.png'), url('img/jungle_bg.png'); + background-repeat: repeat-x, repeat; + background-attachment: scroll, scroll; +} + +.boardlist .board a { +background: #65AB6B; +border: 1px solid #054500; +color: #054500; +font-weight: 600; +} + + +div.post.reply { + background-image: url('img/jungle_td.png'); + border: 1px solid #E5D959; +border-left: none; +border-top: none; +webkit-border-radius: 5px; +-moz-border-radius: 5px; +border-radius: 5px; +-webkit-box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.35); +-moz-box-shadow: 0px 2px 3px rgba(0,0,0,0.35); +-o-box-shadow: 0px 2px 3px rgba(0,0,0,0.35); +box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.35); +} +div.post.reply.highlighted { + background-image: url('img/jungle_td2.png'); + border: 1px solid #E5D959; +border-left: none; +border-top: none; +webkit-border-radius: 5px; +-moz-border-radius: 5px; +border-radius: 5px; +-webkit-box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.35); +-moz-box-shadow: 0px 2px 3px rgba(0,0,0,0.35); +-o-box-shadow: 0px 2px 3px rgba(0,0,0,0.35); +box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.35); +} +div.post.reply div.body a { + color: #00E; +} +p.intro span.subject { + color: #d00; +} +form table tr th { + background: #65AB6B; +border: 1px solid #054500; +font-weight: 600; +} +div.ban h2 { + background: #FCA; + color: inherit; +} +div.ban { + border-color: #800; +} +div.ban p { + color: black; +} +div.pages { + padding: 7px 5px; + color: #054500; + font-size: 12pt; + + background-image: url('img/jungle_td.png'); + border-width: 1px; + border-style: inset; + +} +div.pages a.selected { + color: #800; +} +hr { + border-width: 1px; + border-style: inset; +} +div.boardlist { + color: #B86; +} +div.boardlist a { + color: #800; +} +unimportant, .unimportant * { + font-size: 13px; +} +table.modlog tr th { + background: #EA8; +} + +p.intro span.name { +color: maroon; +font-weight: 600; +} + +header div.subtitle, h1 { +color: #054500; +} +.desktop-style div.boardlist:nth-child(1) { + text-shadow: #fff 1px 1px 1px, #fff -1px -1px 1px; +} + + +.desktop-style div.boardlist:nth-child(1):hover { + background-color: rgba(90%, 90%, 90%, 0.55); +} diff --git a/stylesheets/piwnichan.css b/stylesheets/piwnichan.css new file mode 100644 index 00000000..2c1ea49a --- /dev/null +++ b/stylesheets/piwnichan.css @@ -0,0 +1,206 @@ +/* piwnichan */ + + + +body { + font-family: sans-serif; + font-size: 12px; + color:#47506F; + background:#000006 url('img/rect820.png') fixed top right no-repeat; +} + +.desktop-style .bl-menu{ +background-color: #030511; +} + +.boardlist .board a { +background-color: #030511; +} + + +span.quote { +color: #296353; +} + + div.pages a.selected { +color: #FFFCFC !important;} + +div.post.reply div.body a { +color: #6F0A0A; +} + +a:link, a:visited, div.post.reply p.body a { + color: #355097; + text-decoration: none; +} +a:link:hover, a:visited:hover, div.post.reply p.body a:hover { + color: #5A8C99; +} + +a.email span.name { + color: #5A8C99 !important; +} + +p.intro span.capcode, p.intro a.capcode, p.intro a.nametag { +color: #6E0877; +} + +div.post.reply.highlighted { +background: #000E3A; +} + + +input, textarea { + background: url("img/rect821.png") no-repeat fixed right top #030511; + color: #47506F; + +} + +hr { + height:3px; + border-width: 0px; + background:url(img/img/hr_d_blue2.png) center no-repeat; + background-size:100% 100%; + -moz-background-size:100% 100%; +} + +.reflink a:hover{ + font-weight: bold; +} +.adminbar { + text-align:right; + clear:both; + float:right; +} +h1 { + clear:both; + text-align:center; + font-size: 2.5em; + color: #47506F; + width:100%; +} +div.title { + color: #AF8C5D; +} +div.banner, .replymode, .catalogmode { + text-align:center; + margin: 5px 0 5px 0; + padding: 5px 2px 5px 2px; + color: #47506F; + font-weight: bold; + width:100%; +} +.postblock, form table th { + color: sandybrown; + font-size: 11px; + font-weight: bold; + text-align: center !important; +} + +.postarea { +} +.rules { + width: 468px; + font-size: 10px; +} +.rules li { + margin-left: 1em; +} +.footer { + text-align:center; + font-size:12px; +} +.passvalid { + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; + +} +.managehead { + background-color: #1e1e1e; + color: #bebebe; + padding:0px; +} +.postlists { + background: #000; + width:100%; + padding:0px; + color: #bebebe; +} +.row1 { + background-color: #1e1e1e; + color: #bebebe; +} +.row2 { + background: #1e1e1e; + color: #bebebe; +} +.unkfunc { + background:inherit; + color:#789922; +} +.filesize { + text-decoration:none; +} +.filetitle { + background:inherit; + font-size:1.2em; + color: #bebebe; + font-weight:800; +} + +p.intro span.subject { +color: #4D2C80; +font-weight: bold; +} + + +span.name, .postername { + color: #06546D !important; + font-weight:bold; +} +span.trip, .postertrip { + color: #B88146; +} +.oldpost { + color:#CC1105; + font-weight:800; +} +span.omitted, .omittedposts { + color: #7C776F; +} +div.post.reply { + padding: 5px; + + background:#030511 url('img/rect821.png') fixed top right no-repeat; + color:#47506F; + border: 1px solid #000E3A!important; + + + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; +} +.replyhl { + background-color: #1e1e1e; + color: #bebebe; +} +form table th, div.banner, div.pages, .replymode, .postblock, .passvalid, .catalogmode { + background: #030511!important; + color:#47506F; + border: 1px solid #0A1E55 +} +div.pages { + color: rgb(143, 139, 139); + border: 0; + background: none !important; +} -- cgit v1.3 From 9c1984a4ea61f4361893f7991141d8b7a06e0fd8 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 15 Jun 2013 01:36:30 -0400 Subject: stylesheets: add photon.css by Turanga --- stylesheets/photon.css | 321 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 stylesheets/photon.css diff --git a/stylesheets/photon.css b/stylesheets/photon.css new file mode 100644 index 00000000..09735d5c --- /dev/null +++ b/stylesheets/photon.css @@ -0,0 +1,321 @@ +/*https://github.com/turanga/Tinyboard/blob/efe78b81c1ffca32bcf9601d0e3877bb65c70df1/stylesheets/photon.css*/ + + +.floatiframe{ +float:left; +padding:10px; +} + + +div.boardlist { + color: #8899AA; + font-size: 12pt; + margin-top: 0px; + background-color: #DDDDDD; + border: 1px solid #cccccc; + border-radius: 4px 4px 4px 4px; + margin-top: 0; + padding: 10px; + position: fixed; + top: 0; +} +div.boardlist.bottom { + margin-top: 20px; + position: inherit; + background:inherit; +} + + + +.return1 a{ +float:left; +font-size: inherit; + +} + +div.blotter { + background: none repeat scroll 0 0 #DDDDDD; + border: 1px solid #CCCCCC; + border-radius: 5px 5px 5px 5px; + clear: both; + color: #006AB9; + font-weight: bold; + margin-bottom: 0.5em; + padding: 2px; + text-align: center; +} + + + +div.title { + margin-bottom: 0em; + clear: both; + color: #FFAB3F; + font-size: 2em; + font-weight: bold; + +} + +div.ban h2 { + border-radius: 6px 6px 6px 6px; +} + +div.ban { + background: none repeat scroll 0 0 #DDDDDD; + border: 1px solid #CCCCCC; + margin: 30px auto; + max-width: 700px; + border-radius: 7px; + +} + +form { + margin-bottom: 0px; +} + + +form { + margin-bottom: 0px; +} + +span.heading { + color: #FFAB3F; + display: block; + font-size: 12pt; + font-weight: bold; +} + +textarea#body{ + height: 136px; + width: 518px; +} + + + +html, body { + background: none; + background-color: #EEEEEE; + color: #333333; + font-family: "Trebuchet MS",Trebuchet,serif; + font-size: 12pt; +} +a { + color: #FF6600; +} +a:hover { + color: #0066FF; +} +.adminbar { + clear:both; + float:right; + font-size: .8em; +} +.adminbar a { + font-weight: bold; +} +.logo { + clear:both; + text-align:left; + font-size:2em; + font-weight: bold; + color:#FF6600; + /*width:100%;*/ +} +.theader, .passvalid { + background:#DDDDDD; + text-align:center; + padding:2px; + color:#2266AA; + clear: both; + font-weight: bold; + margin-bottom: .5em; + border: solid 1px #CCCCCC; + -moz-border-radius: 5px; +} +.postarea { +} +.rules { + font-size:0.7em; +} +.postblock { + background:transparent; + color:#002244; + font-weight:bold; +} +.footer { + text-align:center; + font-size:12px; + font-family:serif; + margin: 2em 0 0 0; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; +} +.managehead { + background:#DDDDDD; + color:#002244; + padding:0px; +} +.postlists { + background:#FFFFFF; + width:100%; + padding:0px; + color:#800000; +} +.row1 { + background:#DDDDDD; + color:#002244; +} +.row2 { + background:#CCCCCC; + color:#002244; +} +.unkfunc { + background:inherit; + color:#789922; +} +.reflink { + font-size: .8em; + font-weight: bold; +} +.filesize { + text-decoration:none; + color: #666666; + font-size: .8em; +} +.filetitle { + background:inherit; + font-size:1.2em; + color:#002244; + font-weight:bold; +} +.postername { + color:#004A99; + font-weight:bold; +} +.postertrip { + color:#FF3300; +} +.oldpost { + color:#CC1105; + font-weight:bold; +} +.omittedposts { + color:#666666; +} +.reply { + background:#DDDDDD; + border: solid 1px #CCCCCC; + padding: 0; + margin: 0; + -moz-border-radius: 5px; +} +blockquote { + margin: .5em .5em .5em 1em; +} +blockquote p { + margin: 0; + padding: 0; +} +.reply blockquote { + margin: .5em; +} +.doubledash { + display: none; + vertical-align:top; + clear:both; + float:left; +} +.replytitle { + font-size: 1.2em; + color:#002244; + font-weight:bold; +} +.commentpostername { + color:#004A99; + font-weight:800; +} +.thumbnailmsg { + font-size: .8em; + color:#666666; +} +hr { + border-style: solid none none none; + border-width: 1px; + border-color: #BBBBBB; +} +table { + border-style: none; +} +table td { + border-style: none; +} +.nothumb { + background-color: #FFFFFF; + border-style: dotted; + margin: .3em .5em; +} + +.abbrev { + color:#666666; +} +.highlight { + background:#EEDACB; + color:#333333; + border: 2px dashed #EE6600; +} + + +div.banner, div.banner a { + color: inherit; +} +div.banner { + background-color: inherit; +} +form table tr th { + background: none; +} + +div.post.reply { + background: none repeat scroll 0 0 #DDDDDD; + border: 1px solid #CCCCCC; + border-radius: 5px 5px 5px 5px; +} +div.title,h1 { + color: #FF6600; + font-size: 32px; + font-weight: bold; +} +div.title p { + font-size: 26px; + margin: 0; +} + +h1 { + letter-spacing: inherit; +} + +div.banner { + background: none repeat scroll 0 0 #DDDDDD; + border: 1px solid #CCCCCC; + border-radius: 5px 5px 5px 5px; + clear: both; + color: #2266AA; + font-weight: bold; + margin-bottom: 0.5em; + padding: 2px; + text-align: center; +} + +form table tr td div { + padding-left: 0px; + +} +.recaptchatable .recaptcha_image_cell { + padding: 0px !important; +} -- cgit v1.3 From 590d46366b93a3dd27c338899dbebeb85abe0a49 Mon Sep 17 00:00:00 2001 From: lanc33 Date: Sat, 22 Jun 2013 12:16:10 -0300 Subject: Added gentoochan.css. --- stylesheets/gentoochan.css | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 stylesheets/gentoochan.css diff --git a/stylesheets/gentoochan.css b/stylesheets/gentoochan.css new file mode 100644 index 00000000..8213eb26 --- /dev/null +++ b/stylesheets/gentoochan.css @@ -0,0 +1,67 @@ +body { + background: #0E0E0E url(data:image/gif;base64,R0lGODlhGAAMAKEEAOXl5ebm5vDw8PHx8SH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAGAAMAAACRpQiY6cLa146MyY1EJQKjG81lNGRUPOIkgMJHtquBgIO7xwvpbrpduUSuXq8ntEC0bBEylYitdDAdM1ViaobkgKgZwyDLAAAOw==) repeat 0 0!important; + color: #000; +} +a:link, a:visited, p.intro a.email span.name { + -webkit-transition: all ease-in 0.3s; + -moz-transition: all ease-in 0.3s; + color: rgba(0, 0, 0, 0.6); + text-decoration:none !important; +} +a:link:hover { + -moz-transition: all ease-in 0.5s; + text-shadow: 0px 0px 2px #000; +} +a.post_no { + color: #fff; +} +.boardlist { + color: #ccc; +} +div.post.reply, input, textarea { + background: rgba(0, 0, 0, 0.1)!important; + border: 1px solid rgba(0, 0, 0, 0.2)!important; + border-radius: 2px !important; +} +div.post.reply.highlighted { + background: #f0c0b0; + border-color: #d9bfb7; +} +div.post.reply p.body a { + color: navy; +} +p.intro span.subject { + color: #000; +} +form table tr th { + background: #EA8; +} +div.ban h2 { + background: #FCA; + color: inherit; +} +div.ban { + border-color: #000; +} +div.ban p { + color: black; +} +div.pages { + background: #F0E0D6; + border-color: #D9BFB7; +} +div.pages a.selected { + color: #800; +} +hr { + border-color: rgba(0, 0, 0, 0.2); +} +div.boardlist { + color: rgba(0, 0, 0, 0.2); +} +div.boardlist a { + color: #000; +} +table.modlog tr th { + background: #EA8; +} -- cgit v1.3 From 780dd56eab1b92f9d65eb75c795ad825884f04ba Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 02:34:15 -0400 Subject: dark.css stylesheet fixes Conflicts: stylesheets/dark.css --- stylesheets/dark.css | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/stylesheets/dark.css b/stylesheets/dark.css index 2248c9d3..c4a6855c 100644 --- a/stylesheets/dark.css +++ b/stylesheets/dark.css @@ -8,13 +8,16 @@ body { font-family: sans-serif; font-size: 12px; } +span.quote { + color:#B8D962; +} h1 { font-size: 20pt; text-align: center; letter-spacing: 0px; } div.title, h1 { - color: lime; + color: #32DD72; font-family: Arial, Helvetica, sans-serif; } div.title p { @@ -22,35 +25,41 @@ div.title p { } a:link, a:visited, p.intro a.email span.name { color: #CCCCCC; - text-decoration: underline; + text-decoration: none; font-family: sans-serif; } a:link:hover, a:visited:hover { - color: #FF0000; + color: #fff; font-family: sans-serif; - text-decoration: underline overline; + text-decoration: none; + } a.post_no { color: #AAAAAA; text-decoration: none; } a.post_no:hover { - color: maroon; + color: #32DD72 !important; text-decoration: underline overline; } div.post.reply { background: #333333; border: #555555 1px solid; + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + } div.post.reply.highlighted { - background: transparent; + background: #555; border: transparent 1px solid; } div.post.reply div.body a:link, div.post.reply div.body a:visited { color: #CCCCCC; } div.post.reply div.body a:link:hover, div.post.reply div.body a:visited:hover { - color: #FF0000; + color: #32DD72; } p.intro span.subject { font-size: 12px; @@ -59,7 +68,7 @@ p.intro span.subject { font-weight: 800; } p.intro span.name { - color: #00CC00; + color: #32DD72; font-weight: 800; } p.intro a.capcode, p.intro a.nametag { @@ -67,7 +76,7 @@ p.intro a.capcode, p.intro a.nametag { margin-left: 0; } p.intro a.email, p.intro a.email span.name, p.intro a.email:hover, p.intro a.email:hover span.name { - color: #00CCCC; + color: #32ddaf; } input[type="text"], textarea, select { background: #333333; @@ -91,8 +100,8 @@ form table tr th { padding: 0; } div.banner { - background: #00AA00; - color: #FFFFFF; + background: #32DD72; + color: #000; text-align: center; width: 250px; padding: 4px; @@ -102,6 +111,9 @@ div.banner { margin-right: auto; font-size: 12px; } +div.banner a { + color:#000; +} input[type="submit"] { background: #333333; border: #888888 1px solid; @@ -110,7 +122,10 @@ input[type="submit"] { input[type="submit"]:hover { background: #555555; border: #888888 1px solid; - color: #FF0000; + color: #32DD72; +} +input[type="text"]:focus { + border:#aaa 1px solid; } p.fileinfo a:hover { text-decoration: underline; @@ -134,7 +149,9 @@ hr { } div.boardlist { color: #999999; + background-color: rgba(12%, 12%, 12%, 0.10); } + div.ban { background-color: transparent; border: transparent 0px solid; @@ -148,3 +165,12 @@ table.modlog tr th { background: #333333; color: #AAAAAA; } + +.desktop-style div.boardlist:nth-child(1) { + text-shadow: black 1px 1px 1px, black -1px -1px 1px, black -1px 1px 1px, black 1px -1px 1px; +} + + +.desktop-style div.boardlist:nth-child(1):hover { + background-color: rgba(30%, 30%, 30%, 0.65); +} \ No newline at end of file -- cgit v1.3 From 256d4e24e5d78901e94b50bc97103b0f3d3c7092 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 03:37:01 -0400 Subject: Line endings fix --- stylesheets/stripes.css | 134 ++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/stylesheets/stripes.css b/stylesheets/stripes.css index da3f2aab..61a9d326 100644 --- a/stylesheets/stripes.css +++ b/stylesheets/stripes.css @@ -1,67 +1,67 @@ -/** - * stripes.css - * for vichan by klaczy - */ -body { - background: url('img/stripes_bg.png'); - color: #BBB; - font-family: 'Hevletica', sans-serif; - font-size: 12px; -} -div.boardlist:nth-child(1):hover { - background: #222 !important; -} -div.reply, div.pages { - background: -moz-linear-gradient(bottom, #323232 40%, #2E2E2E 75%) !important; - border: 1px solid #2D2D2D !important; - box-shadow: 0px 0px 10px #2C2C2C; - color: #BBB !important; -} -.reply { - margin-top: 0.5em !important; -} -.body a, a:hover { - color: #FF6666; -} -table th { background: none !important } -a, a:visited { - color: #BBB; -} -hr { - border: 0 !important; - height: 1px !important; - background-color: #AAA !important; - margin: 1.5em 0 1.5em !important; -} -.name, .body a { - color: #FF6666 !important; -} -.subject, h1, .subtitle, .selected { - color: #FF6699 !important; -} -.capcode { - color: #FF66CC !important; -} -input, textarea { - background: url('img/stripes_textarea.png'); - border: 1px #CCC; - border-radius: 3px; - padding: 3px; -} -input[type="text"] { width: 200px } -textarea { - background-size: 100% 100%; - background-color: #FCFCFC; - background-repeat: repeat-x; - width: 100%; - height: 200px; -} -input[type="submit"] { - border: 1px solid rgb(204, 204, 204); - background: url('img/stripes_submit.png'); - height: 23px; - margin-left: 0.5em; -} -.delete { - margin-top: 0.5em; -} +/** + * stripes.css + * for vichan by klaczy + */ +body { + background: url('img/stripes_bg.png'); + color: #BBB; + font-family: 'Hevletica', sans-serif; + font-size: 12px; +} +div.boardlist:nth-child(1):hover { + background: #222 !important; +} +div.reply, div.pages { + background: -moz-linear-gradient(bottom, #323232 40%, #2E2E2E 75%) !important; + border: 1px solid #2D2D2D !important; + box-shadow: 0px 0px 10px #2C2C2C; + color: #BBB !important; +} +.reply { + margin-top: 0.5em !important; +} +.body a, a:hover { + color: #FF6666; +} +table th { background: none !important } +a, a:visited { + color: #BBB; +} +hr { + border: 0 !important; + height: 1px !important; + background-color: #AAA !important; + margin: 1.5em 0 1.5em !important; +} +.name, .body a { + color: #FF6666 !important; +} +.subject, h1, .subtitle, .selected { + color: #FF6699 !important; +} +.capcode { + color: #FF66CC !important; +} +input, textarea { + background: url('img/stripes_textarea.png'); + border: 1px #CCC; + border-radius: 3px; + padding: 3px; +} +input[type="text"] { width: 200px } +textarea { + background-size: 100% 100%; + background-color: #FCFCFC; + background-repeat: repeat-x; + width: 100%; + height: 200px; +} +input[type="submit"] { + border: 1px solid rgb(204, 204, 204); + background: url('img/stripes_submit.png'); + height: 23px; + margin-left: 0.5em; +} +.delete { + margin-top: 0.5em; +} -- cgit v1.3 From 4851d4cabeebdd72764e75fe8d51f45c0e436c32 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 03:51:50 -0400 Subject: Forgot "global $config" here --- inc/image.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/image.php b/inc/image.php index 99c10252..c39d7694 100644 --- a/inc/image.php +++ b/inc/image.php @@ -173,6 +173,7 @@ class ImageImagick extends ImageBase { } } public function to($src) { + global $config; if ($config['strip_exif']) { $this->image->stripImage(); } -- cgit v1.3 From 22f3a95e0e421de05a11633eac846df96a2a4768 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 04:24:34 -0400 Subject: convert+gifscale didn't respect $config['thumb_keep_animation_frames'] --- inc/config.php | 7 +++---- inc/image.php | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/inc/config.php b/inc/config.php index 75384d3f..cec996c1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -412,9 +412,9 @@ // Thumbnail extension, empty for inherited (png recommended) $config['thumb_ext'] = 'png'; - // EXPERIMENTAL: // Maximum amount of frames to resize (more frames means more processing power). "1" means no animated thumbnails. - // Requires $config['thumb_ext'] to be 'gif' $config['imagick'] to be enabled. + // Requires $config['thumb_ext'] to be 'gif' and $config['thumb_method'] to be 'imagick', 'convert', or 'convert+gifsicle'. + // Not respected by 'convert'; will just resize all frames if this is > 1. $config['thumb_keep_animation_frames'] = 1; // Thumbnailing method: @@ -426,8 +426,7 @@ // PHP Imagick. // - 'convert+gifsicle' Same as above, with the exception of using `gifsicle` (command line application) // instead of `convert` for resizing gifs. It's faster and resulting animated gifs - // have less artifacts than if resized with ImageMagick. - + // have less artifacts than if resized with ImageMagick. $config['thumb_method'] = 'gd'; // Strip EXIF metadata from JPEG files diff --git a/inc/image.php b/inc/image.php index c39d7694..5910cb85 100644 --- a/inc/image.php +++ b/inc/image.php @@ -282,10 +282,13 @@ class ImageConvert extends ImageBase { $quality = $config['thumb_quality'] * 10; + $config['thumb_keep_animation_frames'] = (int) $config['thumb_keep_animation_frames']; + if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { if ($this->gifsicle) { if (shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " . - escapeshellarg($this->src . '') . " > " . escapeshellarg($this->temp)) || !file_exists($this->temp)) + escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" > " . + escapeshellarg($this->temp)) || !file_exists($this->temp)) error('Failed to resize image!'); } else { if (shell_exec("convert -background transparent -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " . -- cgit v1.3 From 0fe552857468aa12097a74e08f51f5aaa983be07 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 15:20:12 -0400 Subject: Upgrade Twig library --- inc/lib/Twig/Autoloader.php | 20 +- inc/lib/Twig/Compiler.php | 82 +- inc/lib/Twig/CompilerInterface.php | 10 +- inc/lib/Twig/Environment.php | 510 ++++++++--- inc/lib/Twig/Error.php | 144 +-- inc/lib/Twig/Error/Loader.php | 15 +- inc/lib/Twig/Error/Runtime.php | 3 +- inc/lib/Twig/Error/Syntax.php | 3 +- inc/lib/Twig/ExistsLoaderInterface.php | 28 + inc/lib/Twig/ExpressionParser.php | 306 ++++++- inc/lib/Twig/Extension.php | 4 +- inc/lib/Twig/Extension/Core.php | 993 ++++++++++++++++----- inc/lib/Twig/Extension/Debug.php | 71 ++ inc/lib/Twig/Extension/Escaper.php | 44 +- inc/lib/Twig/Extension/Staging.php | 113 +++ inc/lib/Twig/Extension/StringLoader.php | 64 ++ inc/lib/Twig/ExtensionInterface.php | 25 +- inc/lib/Twig/Extensions/Extension/Tinyboard.php | 5 - inc/lib/Twig/Filter.php | 31 +- inc/lib/Twig/Filter/Function.php | 8 +- inc/lib/Twig/Filter/Method.php | 11 +- inc/lib/Twig/Filter/Node.php | 39 + inc/lib/Twig/FilterCallableInterface.php | 23 + inc/lib/Twig/FilterInterface.php | 22 +- inc/lib/Twig/Function.php | 25 +- inc/lib/Twig/Function/Function.php | 8 +- inc/lib/Twig/Function/Method.php | 11 +- inc/lib/Twig/Function/Node.php | 39 + inc/lib/Twig/FunctionCallableInterface.php | 23 + inc/lib/Twig/FunctionInterface.php | 18 +- inc/lib/Twig/Lexer.php | 226 +++-- inc/lib/Twig/LexerInterface.php | 10 +- inc/lib/Twig/Loader/Array.php | 39 +- inc/lib/Twig/Loader/Chain.php | 79 +- inc/lib/Twig/Loader/Filesystem.php | 129 ++- inc/lib/Twig/Loader/String.php | 34 +- inc/lib/Twig/LoaderInterface.php | 21 +- inc/lib/Twig/Markup.php | 14 +- inc/lib/Twig/Node.php | 11 +- inc/lib/Twig/Node/AutoEscape.php | 3 +- inc/lib/Twig/Node/Block.php | 3 +- inc/lib/Twig/Node/BlockReference.php | 3 +- inc/lib/Twig/Node/Body.php | 19 + inc/lib/Twig/Node/Do.php | 38 + inc/lib/Twig/Node/Embed.php | 38 + inc/lib/Twig/Node/Expression.php | 3 +- inc/lib/Twig/Node/Expression/Array.php | 51 +- inc/lib/Twig/Node/Expression/AssignName.php | 6 +- inc/lib/Twig/Node/Expression/Binary/FloorDiv.php | 4 +- inc/lib/Twig/Node/Expression/BlockReference.php | 3 +- inc/lib/Twig/Node/Expression/Call.php | 178 ++++ .../Twig/Node/Expression/ExtensionReference.php | 3 +- inc/lib/Twig/Node/Expression/Filter.php | 60 +- inc/lib/Twig/Node/Expression/Filter/Default.php | 43 + inc/lib/Twig/Node/Expression/Function.php | 38 +- inc/lib/Twig/Node/Expression/GetAttr.php | 56 +- inc/lib/Twig/Node/Expression/MethodCall.php | 41 + inc/lib/Twig/Node/Expression/Name.php | 71 +- inc/lib/Twig/Node/Expression/Parent.php | 24 +- inc/lib/Twig/Node/Expression/TempName.php | 26 + inc/lib/Twig/Node/Expression/Test.php | 44 +- inc/lib/Twig/Node/Expression/Test/Constant.php | 46 + inc/lib/Twig/Node/Expression/Test/Defined.php | 54 ++ inc/lib/Twig/Node/Expression/Test/Divisibleby.php | 33 + inc/lib/Twig/Node/Expression/Test/Even.php | 32 + inc/lib/Twig/Node/Expression/Test/Null.php | 31 + inc/lib/Twig/Node/Expression/Test/Odd.php | 32 + inc/lib/Twig/Node/Expression/Test/Sameas.php | 29 + inc/lib/Twig/Node/Flush.php | 36 + inc/lib/Twig/Node/For.php | 63 +- inc/lib/Twig/Node/ForLoop.php | 55 ++ inc/lib/Twig/Node/If.php | 3 +- inc/lib/Twig/Node/Import.php | 3 +- inc/lib/Twig/Node/Include.php | 45 +- inc/lib/Twig/Node/Macro.php | 59 +- inc/lib/Twig/Node/Module.php | 127 ++- inc/lib/Twig/Node/Print.php | 3 +- inc/lib/Twig/Node/Sandbox.php | 3 +- inc/lib/Twig/Node/SandboxedModule.php | 23 +- inc/lib/Twig/Node/SandboxedPrint.php | 3 +- inc/lib/Twig/Node/Set.php | 9 +- inc/lib/Twig/Node/SetTemp.php | 35 + inc/lib/Twig/Node/Spaceless.php | 3 +- inc/lib/Twig/Node/Text.php | 3 +- inc/lib/Twig/NodeInterface.php | 12 +- inc/lib/Twig/NodeOutputInterface.php | 3 +- inc/lib/Twig/NodeTraverser.php | 3 +- inc/lib/Twig/NodeVisitor/Escaper.php | 58 +- inc/lib/Twig/NodeVisitor/Optimizer.php | 68 +- inc/lib/Twig/NodeVisitor/SafeAnalysis.php | 32 +- inc/lib/Twig/NodeVisitor/Sandbox.php | 7 +- inc/lib/Twig/NodeVisitorInterface.php | 13 +- inc/lib/Twig/Parser.php | 126 ++- inc/lib/Twig/ParserInterface.php | 8 +- inc/lib/Twig/Sandbox/SecurityError.php | 3 +- inc/lib/Twig/Sandbox/SecurityPolicy.php | 3 +- inc/lib/Twig/Sandbox/SecurityPolicyInterface.php | 9 +- inc/lib/Twig/SimpleFilter.php | 94 ++ inc/lib/Twig/SimpleFunction.php | 84 ++ inc/lib/Twig/SimpleTest.php | 46 + inc/lib/Twig/Template.php | 215 +++-- inc/lib/Twig/TemplateInterface.php | 10 +- inc/lib/Twig/Test.php | 34 + inc/lib/Twig/Test/Function.php | 12 +- inc/lib/Twig/Test/IntegrationTestCase.php | 154 ++++ inc/lib/Twig/Test/Method.php | 15 +- inc/lib/Twig/Test/Node.php | 37 + inc/lib/Twig/Test/NodeTestCase.php | 58 ++ inc/lib/Twig/TestCallableInterface.php | 21 + inc/lib/Twig/TestInterface.php | 6 +- inc/lib/Twig/Token.php | 50 +- inc/lib/Twig/TokenParser.php | 6 +- inc/lib/Twig/TokenParser/AutoEscape.php | 36 +- inc/lib/Twig/TokenParser/Block.php | 10 +- inc/lib/Twig/TokenParser/Do.php | 42 + inc/lib/Twig/TokenParser/Embed.php | 66 ++ inc/lib/Twig/TokenParser/Extends.php | 8 +- inc/lib/Twig/TokenParser/Filter.php | 2 +- inc/lib/Twig/TokenParser/Flush.php | 42 + inc/lib/Twig/TokenParser/For.php | 66 +- inc/lib/Twig/TokenParser/From.php | 6 +- inc/lib/Twig/TokenParser/If.php | 15 +- inc/lib/Twig/TokenParser/Import.php | 4 +- inc/lib/Twig/TokenParser/Include.php | 29 +- inc/lib/Twig/TokenParser/Macro.php | 21 +- inc/lib/Twig/TokenParser/Sandbox.php | 15 +- inc/lib/Twig/TokenParser/Set.php | 6 +- inc/lib/Twig/TokenParser/Spaceless.php | 2 +- inc/lib/Twig/TokenParser/Use.php | 9 +- inc/lib/Twig/TokenParserBroker.php | 39 +- inc/lib/Twig/TokenParserBrokerInterface.php | 14 +- inc/lib/Twig/TokenParserInterface.php | 11 +- inc/lib/Twig/TokenStream.php | 12 +- 133 files changed, 5041 insertions(+), 1347 deletions(-) create mode 100644 inc/lib/Twig/ExistsLoaderInterface.php create mode 100644 inc/lib/Twig/Extension/Debug.php create mode 100644 inc/lib/Twig/Extension/Staging.php create mode 100644 inc/lib/Twig/Extension/StringLoader.php create mode 100644 inc/lib/Twig/Filter/Node.php create mode 100644 inc/lib/Twig/FilterCallableInterface.php create mode 100644 inc/lib/Twig/Function/Node.php create mode 100644 inc/lib/Twig/FunctionCallableInterface.php create mode 100644 inc/lib/Twig/Node/Body.php create mode 100644 inc/lib/Twig/Node/Do.php create mode 100644 inc/lib/Twig/Node/Embed.php create mode 100644 inc/lib/Twig/Node/Expression/Call.php create mode 100644 inc/lib/Twig/Node/Expression/Filter/Default.php create mode 100644 inc/lib/Twig/Node/Expression/MethodCall.php create mode 100644 inc/lib/Twig/Node/Expression/TempName.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Constant.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Defined.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Divisibleby.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Even.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Null.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Odd.php create mode 100644 inc/lib/Twig/Node/Expression/Test/Sameas.php create mode 100644 inc/lib/Twig/Node/Flush.php create mode 100644 inc/lib/Twig/Node/ForLoop.php create mode 100644 inc/lib/Twig/Node/SetTemp.php create mode 100644 inc/lib/Twig/SimpleFilter.php create mode 100644 inc/lib/Twig/SimpleFunction.php create mode 100644 inc/lib/Twig/SimpleTest.php create mode 100644 inc/lib/Twig/Test.php create mode 100644 inc/lib/Twig/Test/IntegrationTestCase.php create mode 100644 inc/lib/Twig/Test/Node.php create mode 100644 inc/lib/Twig/Test/NodeTestCase.php create mode 100644 inc/lib/Twig/TestCallableInterface.php create mode 100644 inc/lib/Twig/TokenParser/Do.php create mode 100644 inc/lib/Twig/TokenParser/Embed.php create mode 100644 inc/lib/Twig/TokenParser/Flush.php diff --git a/inc/lib/Twig/Autoloader.php b/inc/lib/Twig/Autoloader.php index a93b8caf..7007d315 100644 --- a/inc/lib/Twig/Autoloader.php +++ b/inc/lib/Twig/Autoloader.php @@ -12,28 +12,30 @@ /** * Autoloads Twig classes. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Autoloader { /** * Registers Twig_Autoloader as an SPL autoloader. + * + * @param Boolean $prepend Whether to prepend the autoloader or not. */ - static public function register() + public static function register($prepend = false) { - ini_set('unserialize_callback_func', 'spl_autoload_call'); - spl_autoload_register(array(new self, 'autoload')); + if (version_compare(phpversion(), '5.3.0', '>=')) { + spl_autoload_register(array(new self, 'autoload'), true, $prepend); + } else { + spl_autoload_register(array(new self, 'autoload')); + } } /** * Handles autoloading of classes. * - * @param string $class A class name. - * - * @return boolean Returns true if the class has been loaded + * @param string $class A class name. */ - static public function autoload($class) + public static function autoload($class) { if (0 !== strpos($class, 'Twig')) { return; diff --git a/inc/lib/Twig/Compiler.php b/inc/lib/Twig/Compiler.php index db2e8de4..99aecbcc 100644 --- a/inc/lib/Twig/Compiler.php +++ b/inc/lib/Twig/Compiler.php @@ -13,8 +13,7 @@ /** * Compiles a node to PHP code. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Compiler implements Twig_CompilerInterface { @@ -22,6 +21,10 @@ class Twig_Compiler implements Twig_CompilerInterface protected $source; protected $indentation; protected $env; + protected $debugInfo; + protected $sourceOffset; + protected $sourceLine; + protected $filename; /** * Constructor. @@ -31,6 +34,12 @@ class Twig_Compiler implements Twig_CompilerInterface public function __construct(Twig_Environment $env) { $this->env = $env; + $this->debugInfo = array(); + } + + public function getFilename() + { + return $this->filename; } /** @@ -56,8 +65,8 @@ class Twig_Compiler implements Twig_CompilerInterface /** * Compiles a node. * - * @param Twig_NodeInterface $node The node to compile - * @param integer $indent The current indentation + * @param Twig_NodeInterface $node The node to compile + * @param integer $indentation The current indentation * * @return Twig_Compiler The current compiler instance */ @@ -65,8 +74,15 @@ class Twig_Compiler implements Twig_CompilerInterface { $this->lastLine = null; $this->source = ''; + $this->sourceOffset = 0; + // source code starts at 1 (as we then increment it when we encounter new lines) + $this->sourceLine = 1; $this->indentation = $indentation; + if ($node instanceof Twig_Node_Module) { + $this->filename = $node->getAttribute('filename'); + } + $node->compile($this); return $this; @@ -86,7 +102,7 @@ class Twig_Compiler implements Twig_CompilerInterface /** * Adds a raw string to the compiled code. * - * @param string $string The string + * @param string $string The string * * @return Twig_Compiler The current compiler instance */ @@ -113,6 +129,11 @@ class Twig_Compiler implements Twig_CompilerInterface return $this; } + /** + * Appends an indentation to the current PHP code after compilation. + * + * @return Twig_Compiler The current compiler instance + */ public function addIndentation() { $this->source .= str_repeat(' ', $this->indentation * 4); @@ -123,7 +144,7 @@ class Twig_Compiler implements Twig_CompilerInterface /** * Adds a quoted string to the compiled code. * - * @param string $string The string + * @param string $value The string * * @return Twig_Compiler The current compiler instance */ @@ -137,19 +158,27 @@ class Twig_Compiler implements Twig_CompilerInterface /** * Returns a PHP representation of a given value. * - * @param mixed $value The value to convert + * @param mixed $value The value to convert * * @return Twig_Compiler The current compiler instance */ public function repr($value) { if (is_int($value) || is_float($value)) { + if (false !== $locale = setlocale(LC_NUMERIC, 0)) { + setlocale(LC_NUMERIC, 'C'); + } + $this->raw($value); - } else if (null === $value) { + + if (false !== $locale) { + setlocale(LC_NUMERIC, $locale); + } + } elseif (null === $value) { $this->raw('null'); - } else if (is_bool($value)) { + } elseif (is_bool($value)) { $this->raw($value ? 'true' : 'false'); - } else if (is_array($value)) { + } elseif (is_array($value)) { $this->raw('array('); $i = 0; foreach ($value as $key => $value) { @@ -178,17 +207,35 @@ class Twig_Compiler implements Twig_CompilerInterface public function addDebugInfo(Twig_NodeInterface $node) { if ($node->getLine() != $this->lastLine) { - $this->lastLine = $node->getLine(); $this->write("// line {$node->getLine()}\n"); + + // when mbstring.func_overload is set to 2 + // mb_substr_count() replaces substr_count() + // but they have different signatures! + if (((int) ini_get('mbstring.func_overload')) & 2) { + // this is much slower than the "right" version + $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n"); + } else { + $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset); + } + $this->sourceOffset = strlen($this->source); + $this->debugInfo[$this->sourceLine] = $node->getLine(); + + $this->lastLine = $node->getLine(); } return $this; } + public function getDebugInfo() + { + return $this->debugInfo; + } + /** * Indents the generated code. * - * @param integer $indent The number of indentation to add + * @param integer $step The number of indentation to add * * @return Twig_Compiler The current compiler instance */ @@ -202,18 +249,19 @@ class Twig_Compiler implements Twig_CompilerInterface /** * Outdents the generated code. * - * @param integer $indent The number of indentation to remove + * @param integer $step The number of indentation to remove * * @return Twig_Compiler The current compiler instance */ public function outdent($step = 1) { - $this->indentation -= $step; - - if ($this->indentation < 0) { - throw new Twig_Error('Unable to call outdent() as the indentation would become negative'); + // can't outdent by more steps than the current indentation level + if ($this->indentation < $step) { + throw new LogicException('Unable to call outdent() as the indentation would become negative'); } + $this->indentation -= $step; + return $this; } } diff --git a/inc/lib/Twig/CompilerInterface.php b/inc/lib/Twig/CompilerInterface.php index 0a13edf2..e293ec91 100644 --- a/inc/lib/Twig/CompilerInterface.php +++ b/inc/lib/Twig/CompilerInterface.php @@ -12,24 +12,24 @@ /** * Interface implemented by compiler classes. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_CompilerInterface { /** * Compiles a node. * - * @param Twig_NodeInterface $node The node to compile + * @param Twig_NodeInterface $node The node to compile * * @return Twig_CompilerInterface The current compiler instance */ - function compile(Twig_NodeInterface $node); + public function compile(Twig_NodeInterface $node); /** * Gets the current PHP code after compilation. * * @return string The PHP code */ - function getSource(); + public function getSource(); } diff --git a/inc/lib/Twig/Environment.php b/inc/lib/Twig/Environment.php index b91c80c5..3afa73d6 100644 --- a/inc/lib/Twig/Environment.php +++ b/inc/lib/Twig/Environment.php @@ -12,12 +12,11 @@ /** * Stores the Twig configuration. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Environment { - const VERSION = '1.2.0'; + const VERSION = '1.13.1'; protected $charset; protected $loader; @@ -36,6 +35,7 @@ class Twig_Environment protected $functions; protected $globals; protected $runtimeInitialized; + protected $extensionInitialized; protected $loadedTemplates; protected $strictVariables; protected $unaryOperators; @@ -43,23 +43,23 @@ class Twig_Environment protected $templateClassPrefix = '__TwigTemplate_'; protected $functionCallbacks; protected $filterCallbacks; + protected $staging; /** * Constructor. * * Available options: * - * * debug: When set to `true`, the generated templates have a __toString() - * method that you can use to display the generated nodes (default to - * false). + * * debug: When set to true, it automatically set "auto_reload" to true as + * well (default to false). * - * * charset: The charset used by the templates (default to utf-8). + * * charset: The charset used by the templates (default to UTF-8). * * * base_template_class: The base template class to use for generated * templates (default to Twig_Template). * * * cache: An absolute path where to store the compiled templates, or - * false to disable compilation cache (default) + * false to disable compilation cache (default). * * * auto_reload: Whether to reload the template is the original source changed. * If you don't provide the auto_reload option, it will be @@ -68,14 +68,18 @@ class Twig_Environment * * strict_variables: Whether to ignore invalid variables in templates * (default to false). * - * * autoescape: Whether to enable auto-escaping (default to true); + * * autoescape: Whether to enable auto-escaping (default to html): + * * false: disable auto-escaping + * * true: equivalent to html + * * html, js: set the autoescaping to one of the supported strategies + * * PHP callback: a PHP callback that returns an escaping strategy based on the template "filename" * * * optimizations: A flag that indicates which optimizations to apply * (default to -1 which means that all optimizations are enabled; - * set it to 0 to disable) + * set it to 0 to disable). * - * @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance - * @param array $options An array of options + * @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance + * @param array $options An array of options */ public function __construct(Twig_LoaderInterface $loader = null, $options = array()) { @@ -88,26 +92,27 @@ class Twig_Environment 'charset' => 'UTF-8', 'base_template_class' => 'Twig_Template', 'strict_variables' => false, - 'autoescape' => true, + 'autoescape' => 'html', 'cache' => false, 'auto_reload' => null, 'optimizations' => -1, ), $options); $this->debug = (bool) $options['debug']; - $this->charset = $options['charset']; + $this->charset = strtoupper($options['charset']); $this->baseTemplateClass = $options['base_template_class']; $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload']; - $this->extensions = array( - 'core' => new Twig_Extension_Core(), - 'escaper' => new Twig_Extension_Escaper((bool) $options['autoescape']), - 'optimizer' => new Twig_Extension_Optimizer($options['optimizations']), - ); $this->strictVariables = (bool) $options['strict_variables']; $this->runtimeInitialized = false; $this->setCache($options['cache']); $this->functionCallbacks = array(); $this->filterCallbacks = array(); + + $this->addExtension(new Twig_Extension_Core()); + $this->addExtension(new Twig_Extension_Escaper($options['autoescape'])); + $this->addExtension(new Twig_Extension_Optimizer($options['optimizations'])); + $this->extensionInitialized = false; + $this->staging = new Twig_Extension_Staging(); } /** @@ -250,13 +255,14 @@ class Twig_Environment /** * Gets the template class associated with the given string. * - * @param string $name The name for which to calculate the template class name + * @param string $name The name for which to calculate the template class name + * @param integer $index The index if it is an embedded template * * @return string The template class name */ - public function getTemplateClass($name) + public function getTemplateClass($name, $index = null) { - return $this->templateClassPrefix.md5($this->loader->getCacheKey($name)); + return $this->templateClassPrefix.md5($this->getLoader()->getCacheKey($name)).(null === $index ? '' : '_'.$index); } /** @@ -282,16 +288,28 @@ class Twig_Environment return $this->loadTemplate($name)->render($context); } + /** + * Displays a template. + * + * @param string $name The template name + * @param array $context An array of parameters to pass to the template + */ + public function display($name, array $context = array()) + { + $this->loadTemplate($name)->display($context); + } + /** * Loads a template by name. * - * @param string $name The template name + * @param string $name The template name + * @param integer $index The index if it is an embedded template * * @return Twig_TemplateInterface A template instance representing the given template name */ - public function loadTemplate($name) + public function loadTemplate($name, $index = null) { - $cls = $this->getTemplateClass($name); + $cls = $this->getTemplateClass($name, $index); if (isset($this->loadedTemplates[$cls])) { return $this->loadedTemplates[$cls]; @@ -299,10 +317,10 @@ class Twig_Environment if (!class_exists($cls, false)) { if (false === $cache = $this->getCacheFilename($name)) { - eval('?>'.$this->compileSource($this->loader->getSource($name), $name)); + eval('?>'.$this->compileSource($this->getLoader()->getSource($name), $name)); } else { - if (!is_file($cache) || ($this->isAutoReload() && !$this->loader->isFresh($name, filemtime($cache)))) { - $this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $name)); + if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) { + $this->writeCacheFile($cache, $this->compileSource($this->getLoader()->getSource($name), $name)); } require_once $cache; @@ -316,6 +334,30 @@ class Twig_Environment return $this->loadedTemplates[$cls] = new $cls($this); } + /** + * Returns true if the template is still fresh. + * + * Besides checking the loader for freshness information, + * this method also checks if the enabled extensions have + * not changed. + * + * @param string $name The template name + * @param timestamp $time The last modification time of the cached template + * + * @return Boolean true if the template is fresh, false otherwise + */ + public function isTemplateFresh($name, $time) + { + foreach ($this->extensions as $extension) { + $r = new ReflectionObject($extension); + if (filemtime($r->getFileName()) > $time) { + return false; + } + } + + return $this->getLoader()->isFresh($name, $time); + } + public function resolveTemplate($names) { if (!is_array($names)) { @@ -510,6 +552,10 @@ class Twig_Environment */ public function getLoader() { + if (null === $this->loader) { + throw new LogicException('You must set a loader first.'); + } + return $this->loader; } @@ -520,7 +566,7 @@ class Twig_Environment */ public function setCharset($charset) { - $this->charset = $charset; + $this->charset = strtoupper($charset); } /** @@ -580,16 +626,28 @@ class Twig_Environment */ public function addExtension(Twig_ExtensionInterface $extension) { + if ($this->extensionInitialized) { + throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName())); + } + $this->extensions[$extension->getName()] = $extension; } /** * Removes an extension by name. * + * This method is deprecated and you should not use it. + * * @param string $name The extension name + * + * @deprecated since 1.12 (to be removed in 2.0) */ public function removeExtension($name) { + if ($this->extensionInitialized) { + throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name)); + } + unset($this->extensions[$name]); } @@ -622,39 +680,46 @@ class Twig_Environment */ public function addTokenParser(Twig_TokenParserInterface $parser) { - if (null === $this->parsers) { - $this->getTokenParsers(); + if ($this->extensionInitialized) { + throw new LogicException('Unable to add a token parser as extensions have already been initialized.'); } - $this->parsers->addTokenParser($parser); + $this->staging->addTokenParser($parser); } /** * Gets the registered Token Parsers. * - * @return Twig_TokenParserInterface[] An array of Twig_TokenParserInterface instances + * @return Twig_TokenParserBrokerInterface A broker containing token parsers */ public function getTokenParsers() { - if (null === $this->parsers) { - $this->parsers = new Twig_TokenParserBroker; - foreach ($this->getExtensions() as $extension) { - $parsers = $extension->getTokenParsers(); - foreach($parsers as $parser) { - if ($parser instanceof Twig_TokenParserInterface) { - $this->parsers->addTokenParser($parser); - } else if ($parser instanceof Twig_TokenParserBrokerInterface) { - $this->parsers->addTokenParserBroker($parser); - } else { - throw new Twig_Error_Runtime('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances'); - } - } - } + if (!$this->extensionInitialized) { + $this->initExtensions(); } return $this->parsers; } + /** + * Gets registered tags. + * + * Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes. + * + * @return Twig_TokenParserInterface[] An array of Twig_TokenParserInterface instances + */ + public function getTags() + { + $tags = array(); + foreach ($this->getTokenParsers()->getParsers() as $parser) { + if ($parser instanceof Twig_TokenParserInterface) { + $tags[$parser->getTag()] = $parser; + } + } + + return $tags; + } + /** * Registers a Node Visitor. * @@ -662,11 +727,11 @@ class Twig_Environment */ public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) { - if (null === $this->visitors) { - $this->getNodeVisitors(); + if ($this->extensionInitialized) { + throw new LogicException('Unable to add a node visitor as extensions have already been initialized.', $extension->getName()); } - $this->visitors[] = $visitor; + $this->staging->addNodeVisitor($visitor); } /** @@ -676,11 +741,8 @@ class Twig_Environment */ public function getNodeVisitors() { - if (null === $this->visitors) { - $this->visitors = array(); - foreach ($this->getExtensions() as $extension) { - $this->visitors = array_merge($this->visitors, $extension->getNodeVisitors()); - } + if (!$this->extensionInitialized) { + $this->initExtensions(); } return $this->visitors; @@ -689,16 +751,25 @@ class Twig_Environment /** * Registers a Filter. * - * @param string $name The filter name - * @param Twig_FilterInterface $visitor A Twig_FilterInterface instance + * @param string|Twig_SimpleFilter $name The filter name or a Twig_SimpleFilter instance + * @param Twig_FilterInterface|Twig_SimpleFilter $filter A Twig_FilterInterface instance or a Twig_SimpleFilter instance */ - public function addFilter($name, Twig_FilterInterface $filter) + public function addFilter($name, $filter = null) { - if (null === $this->filters) { - $this->loadFilters(); + if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) { + throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter'); } - $this->filters[$name] = $filter; + if ($name instanceof Twig_SimpleFilter) { + $filter = $name; + $name = $filter->getName(); + } + + if ($this->extensionInitialized) { + throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name)); + } + + $this->staging->addFilter($name, $filter); } /** @@ -709,18 +780,31 @@ class Twig_Environment * * @param string $name The filter name * - * @return Twig_Filter|false A Twig_Filter instance or false if the filter does not exists + * @return Twig_Filter|false A Twig_Filter instance or false if the filter does not exist */ public function getFilter($name) { - if (null === $this->filters) { - $this->loadFilters(); + if (!$this->extensionInitialized) { + $this->initExtensions(); } if (isset($this->filters[$name])) { return $this->filters[$name]; } + foreach ($this->filters as $pattern => $filter) { + $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count); + + if ($count) { + if (preg_match('#^'.$pattern.'$#', $name, $matches)) { + array_shift($matches); + $filter->setArguments($matches); + + return $filter; + } + } + } + foreach ($this->filterCallbacks as $callback) { if (false !== $filter = call_user_func($callback, $name)) { return $filter; @@ -738,29 +822,43 @@ class Twig_Environment /** * Gets the registered Filters. * + * Be warned that this method cannot return filters defined with registerUndefinedFunctionCallback. + * * @return Twig_FilterInterface[] An array of Twig_FilterInterface instances + * + * @see registerUndefinedFilterCallback */ - protected function loadFilters() + public function getFilters() { - $this->filters = array(); - foreach ($this->getExtensions() as $extension) { - $this->filters = array_merge($this->filters, $extension->getFilters()); + if (!$this->extensionInitialized) { + $this->initExtensions(); } + + return $this->filters; } /** * Registers a Test. * - * @param string $name The test name - * @param Twig_TestInterface $visitor A Twig_TestInterface instance + * @param string|Twig_SimpleTest $name The test name or a Twig_SimpleTest instance + * @param Twig_TestInterface|Twig_SimpleTest $test A Twig_TestInterface instance or a Twig_SimpleTest instance */ - public function addTest($name, Twig_TestInterface $test) + public function addTest($name, $test = null) { - if (null === $this->tests) { - $this->getTests(); + if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) { + throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest'); } - $this->tests[$name] = $test; + if ($name instanceof Twig_SimpleTest) { + $test = $name; + $name = $test->getName(); + } + + if ($this->extensionInitialized) { + throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name)); + } + + $this->staging->addTest($name, $test); } /** @@ -770,29 +868,55 @@ class Twig_Environment */ public function getTests() { - if (null === $this->tests) { - $this->tests = array(); - foreach ($this->getExtensions() as $extension) { - $this->tests = array_merge($this->tests, $extension->getTests()); - } + if (!$this->extensionInitialized) { + $this->initExtensions(); } return $this->tests; } + /** + * Gets a test by name. + * + * @param string $name The test name + * + * @return Twig_Test|false A Twig_Test instance or false if the test does not exist + */ + public function getTest($name) + { + if (!$this->extensionInitialized) { + $this->initExtensions(); + } + + if (isset($this->tests[$name])) { + return $this->tests[$name]; + } + + return false; + } + /** * Registers a Function. * - * @param string $name The function name - * @param Twig_FunctionInterface $function A Twig_FunctionInterface instance + * @param string|Twig_SimpleFunction $name The function name or a Twig_SimpleFunction instance + * @param Twig_FunctionInterface|Twig_SimpleFunction $function A Twig_FunctionInterface instance or a Twig_SimpleFunction instance */ - public function addFunction($name, Twig_FunctionInterface $function) + public function addFunction($name, $function = null) { - if (null === $this->functions) { - $this->loadFunctions(); + if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) { + throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction'); } - $this->functions[$name] = $function; + if ($name instanceof Twig_SimpleFunction) { + $function = $name; + $name = $function->getName(); + } + + if ($this->extensionInitialized) { + throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $name)); + } + + $this->staging->addFunction($name, $function); } /** @@ -803,18 +927,31 @@ class Twig_Environment * * @param string $name function name * - * @return Twig_Function|false A Twig_Function instance or false if the function does not exists + * @return Twig_Function|false A Twig_Function instance or false if the function does not exist */ public function getFunction($name) { - if (null === $this->functions) { - $this->loadFunctions(); + if (!$this->extensionInitialized) { + $this->initExtensions(); } if (isset($this->functions[$name])) { return $this->functions[$name]; } + foreach ($this->functions as $pattern => $function) { + $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count); + + if ($count) { + if (preg_match('#^'.$pattern.'$#', $name, $matches)) { + array_shift($matches); + $function->setArguments($matches); + + return $function; + } + } + } + foreach ($this->functionCallbacks as $callback) { if (false !== $function = call_user_func($callback, $name)) { return $function; @@ -829,27 +966,53 @@ class Twig_Environment $this->functionCallbacks[] = $callable; } - protected function loadFunctions() + /** + * Gets registered functions. + * + * Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback. + * + * @return Twig_FunctionInterface[] An array of Twig_FunctionInterface instances + * + * @see registerUndefinedFunctionCallback + */ + public function getFunctions() { - $this->functions = array(); - foreach ($this->getExtensions() as $extension) { - $this->functions = array_merge($this->functions, $extension->getFunctions()); + if (!$this->extensionInitialized) { + $this->initExtensions(); } + + return $this->functions; } /** * Registers a Global. * + * New globals can be added before compiling or rendering a template; + * but after, you can only update existing globals. + * * @param string $name The global name * @param mixed $value The global value */ public function addGlobal($name, $value) { - if (null === $this->globals) { - $this->getGlobals(); + if ($this->extensionInitialized || $this->runtimeInitialized) { + if (null === $this->globals) { + $this->globals = $this->initGlobals(); + } + + /* This condition must be uncommented in Twig 2.0 + if (!array_key_exists($name, $this->globals)) { + throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); + } + */ } - $this->globals[$name] = $value; + if ($this->extensionInitialized || $this->runtimeInitialized) { + // update the value + $this->globals[$name] = $value; + } else { + $this->staging->addGlobal($name, $value); + } } /** @@ -859,16 +1022,37 @@ class Twig_Environment */ public function getGlobals() { + if (!$this->runtimeInitialized && !$this->extensionInitialized) { + return $this->initGlobals(); + } + if (null === $this->globals) { - $this->globals = array(); - foreach ($this->getExtensions() as $extension) { - $this->globals = array_merge($this->globals, $extension->getGlobals()); - } + $this->globals = $this->initGlobals(); } return $this->globals; } + /** + * Merges a context with the defined globals. + * + * @param array $context An array representing the context + * + * @return array The context merged with the globals + */ + public function mergeGlobals(array $context) + { + // we don't use array_merge as the context being generally + // bigger than globals, this code is faster. + foreach ($this->getGlobals() as $key => $value) { + if (!array_key_exists($key, $context)) { + $context[$key] = $value; + } + } + + return $context; + } + /** * Gets the registered unary Operators. * @@ -876,8 +1060,8 @@ class Twig_Environment */ public function getUnaryOperators() { - if (null === $this->unaryOperators) { - $this->initOperators(); + if (!$this->extensionInitialized) { + $this->initExtensions(); } return $this->unaryOperators; @@ -890,24 +1074,121 @@ class Twig_Environment */ public function getBinaryOperators() { - if (null === $this->binaryOperators) { - $this->initOperators(); + if (!$this->extensionInitialized) { + $this->initExtensions(); } return $this->binaryOperators; } - protected function initOperators() + public function computeAlternatives($name, $items) + { + $alternatives = array(); + foreach ($items as $item) { + $lev = levenshtein($name, $item); + if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { + $alternatives[$item] = $lev; + } + } + asort($alternatives); + + return array_keys($alternatives); + } + + protected function initGlobals() + { + $globals = array(); + foreach ($this->extensions as $extension) { + $extGlob = $extension->getGlobals(); + if (!is_array($extGlob)) { + throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension))); + } + + $globals[] = $extGlob; + } + + $globals[] = $this->staging->getGlobals(); + + return call_user_func_array('array_merge', $globals); + } + + protected function initExtensions() { + if ($this->extensionInitialized) { + return; + } + + $this->extensionInitialized = true; + $this->parsers = new Twig_TokenParserBroker(); + $this->filters = array(); + $this->functions = array(); + $this->tests = array(); + $this->visitors = array(); $this->unaryOperators = array(); $this->binaryOperators = array(); - foreach ($this->getExtensions() as $extension) { - $operators = $extension->getOperators(); - if (!$operators) { - continue; + foreach ($this->extensions as $extension) { + $this->initExtension($extension); + } + $this->initExtension($this->staging); + } + + protected function initExtension(Twig_ExtensionInterface $extension) + { + // filters + foreach ($extension->getFilters() as $name => $filter) { + if ($name instanceof Twig_SimpleFilter) { + $filter = $name; + $name = $filter->getName(); + } elseif ($filter instanceof Twig_SimpleFilter) { + $name = $filter->getName(); + } + + $this->filters[$name] = $filter; + } + + // functions + foreach ($extension->getFunctions() as $name => $function) { + if ($name instanceof Twig_SimpleFunction) { + $function = $name; + $name = $function->getName(); + } elseif ($function instanceof Twig_SimpleFunction) { + $name = $function->getName(); + } + + $this->functions[$name] = $function; + } + + // tests + foreach ($extension->getTests() as $name => $test) { + if ($name instanceof Twig_SimpleTest) { + $test = $name; + $name = $test->getName(); + } elseif ($test instanceof Twig_SimpleTest) { + $name = $test->getName(); } + $this->tests[$name] = $test; + } + + // token parsers + foreach ($extension->getTokenParsers() as $parser) { + if ($parser instanceof Twig_TokenParserInterface) { + $this->parsers->addTokenParser($parser); + } elseif ($parser instanceof Twig_TokenParserBrokerInterface) { + $this->parsers->addTokenParserBroker($parser); + } else { + throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances'); + } + } + + // node visitors + foreach ($extension->getNodeVisitors() as $visitor) { + $this->visitors[] = $visitor; + } + + // operators + if ($operators = $extension->getOperators()) { if (2 !== count($operators)) { throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension))); } @@ -919,20 +1200,25 @@ class Twig_Environment protected function writeCacheFile($file, $content) { - if (!is_dir(dirname($file))) { - mkdir(dirname($file), 0777, true); + $dir = dirname($file); + if (!is_dir($dir)) { + if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { + throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir)); + } + } elseif (!is_writable($dir)) { + throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir)); } $tmpFile = tempnam(dirname($file), basename($file)); if (false !== @file_put_contents($tmpFile, $content)) { // rename does not work on Win32 before 5.2.6 if (@rename($tmpFile, $file) || (@copy($tmpFile, $file) && unlink($tmpFile))) { - chmod($file, 0644); + @chmod($file, 0666 & ~umask()); return; } } - throw new Twig_Error_Runtime(sprintf('Failed to write cache file "%s".', $file)); + throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file)); } } diff --git a/inc/lib/Twig/Error.php b/inc/lib/Twig/Error.php index ed0836c4..72d91a98 100644 --- a/inc/lib/Twig/Error.php +++ b/inc/lib/Twig/Error.php @@ -12,8 +12,24 @@ /** * Twig base exception. * - * @package twig - * @author Fabien Potencier + * This exception class and its children must only be used when + * an error occurs during the loading of a template, when a syntax error + * is detected in a template, or when rendering a template. Other + * errors must use regular PHP exception classes (like when the template + * cache directory is not writable for instance). + * + * To help debugging template issues, this class tracks the original template + * name and line where the error occurred. + * + * Whenever possible, you must set these information (original template name + * and line number) yourself by passing them to the constructor. If some or all + * these information are not available from where you throw the exception, then + * this class will guess them automatically (when the line number is set to -1 + * and/or the filename is set to null). As this is a costly operation, this + * can be disabled by passing false for both the filename and the line number + * when creating a new instance of this class. + * + * @author Fabien Potencier */ class Twig_Error extends Exception { @@ -25,6 +41,15 @@ class Twig_Error extends Exception /** * Constructor. * + * Set both the line number and the filename to false to + * disable automatic guessing of the original template name + * and line number. + * + * Set the line number to -1 to enable its automatic guessing. + * Set the filename to null to enable its automatic guessing. + * + * By default, automatic guessing is enabled. + * * @param string $message The error message * @param integer $lineno The template line where the error occurred * @param string $filename The template file name where the error occurred @@ -32,22 +57,23 @@ class Twig_Error extends Exception */ public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) { - if (-1 === $lineno || null === $filename) { - list($lineno, $filename) = $this->findTemplateInfo(null !== $previous ? $previous : $this, $lineno, $filename); + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + $this->previous = $previous; + parent::__construct(''); + } else { + parent::__construct('', 0, $previous); } $this->lineno = $lineno; $this->filename = $filename; + + if (-1 === $this->lineno || null === $this->filename) { + $this->guessTemplateInfo(); + } + $this->rawMessage = $message; $this->updateRepr(); - - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - $this->previous = $previous; - parent::__construct($this->message); - } else { - parent::__construct($this->message, 0, $previous); - } } /** @@ -104,13 +130,21 @@ class Twig_Error extends Exception $this->updateRepr(); } + public function guess() + { + $this->guessTemplateInfo(); + $this->updateRepr(); + } + /** * For PHP < 5.3.0, provides access to the getPrevious() method. * - * @param string $method The method name - * @param array $arguments The parameters to be passed to the method + * @param string $method The method name + * @param array $arguments The parameters to be passed to the method * * @return Exception The previous exception or null + * + * @throws BadMethodCallException */ public function __call($method, $arguments) { @@ -131,11 +165,16 @@ class Twig_Error extends Exception $dot = true; } - if (null !== $this->filename) { - $this->message .= sprintf(' in %s', json_encode($this->filename)); + if ($this->filename) { + if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) { + $filename = sprintf('"%s"', $this->filename); + } else { + $filename = json_encode($this->filename); + } + $this->message .= sprintf(' in %s', $filename); } - if ($this->lineno >= 0) { + if ($this->lineno && $this->lineno >= 0) { $this->message .= sprintf(' at line %d', $this->lineno); } @@ -144,52 +183,57 @@ class Twig_Error extends Exception } } - protected function findTemplateInfo(Exception $e, $currentLine, $currentFile) + protected function guessTemplateInfo() { - if (!function_exists('token_get_all')) { - return array($currentLine, $currentFile); + $template = null; + + if (version_compare(phpversion(), '5.3.6', '>=')) { + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); + } else { + $backtrace = debug_backtrace(); } - $traces = $e->getTrace(); - foreach ($traces as $i => $trace) { - if (!isset($trace['class']) || 'Twig_Template' === $trace['class']) { - continue; + foreach ($backtrace as $trace) { + if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) { + if (null === $this->filename || $this->filename == $trace['object']->getTemplateName()) { + $template = $trace['object']; + } } + } - $r = new ReflectionClass($trace['class']); - if (!$r->implementsInterface('Twig_TemplateInterface')) { - continue; - } + // update template filename + if (null !== $template && null === $this->filename) { + $this->filename = $template->getTemplateName(); + } - if (!is_file($r->getFilename())) { - // probably an eval()'d code - return array($currentLine, $currentFile); - } + if (null === $template || $this->lineno > -1) { + return; + } - if (0 === $i) { - $line = $e->getLine(); - } else { - $line = isset($traces[$i - 1]['line']) ? $traces[$i - 1]['line'] : -log(0); - } + $r = new ReflectionObject($template); + $file = $r->getFileName(); - $tokens = token_get_all(file_get_contents($r->getFilename())); - $templateline = -1; - $template = null; - foreach ($tokens as $token) { - if (isset($token[2]) && $token[2] >= $line) { - return array($templateline, $template); + $exceptions = array($e = $this); + while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) { + $exceptions[] = $e; + } + + while ($e = array_pop($exceptions)) { + $traces = $e->getTrace(); + while ($trace = array_shift($traces)) { + if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) { + continue; } - if (T_COMMENT === $token[0] && null === $template && preg_match('#/\* +(.+) +\*/#', $token[1], $match)) { - $template = $match[1]; - } elseif (T_COMMENT === $token[0] && preg_match('#^//\s*line (\d+)\s*$#', $token[1], $match)) { - $templateline = $match[1]; + foreach ($template->getDebugInfo() as $codeLine => $templateLine) { + if ($codeLine <= $trace['line']) { + // update template line + $this->lineno = $templateLine; + + return; + } } } - - return array($currentLine, $template); } - - return array($currentLine, $currentFile); } } diff --git a/inc/lib/Twig/Error/Loader.php b/inc/lib/Twig/Error/Loader.php index 418a7760..68efb574 100644 --- a/inc/lib/Twig/Error/Loader.php +++ b/inc/lib/Twig/Error/Loader.php @@ -12,9 +12,20 @@ /** * Exception thrown when an error occurs during template loading. * - * @package twig - * @author Fabien Potencier + * Automatic template information guessing is always turned off as + * if a template cannot be loaded, there is nothing to guess. + * However, when a template is loaded from another one, then, we need + * to find the current context and this is automatically done by + * Twig_Template::displayWithErrorHandling(). + * + * This strategy makes Twig_Environment::resolveTemplate() much faster. + * + * @author Fabien Potencier */ class Twig_Error_Loader extends Twig_Error { + public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) + { + parent::__construct($message, false, false, $previous); + } } diff --git a/inc/lib/Twig/Error/Runtime.php b/inc/lib/Twig/Error/Runtime.php index 8a387fa8..8b6ceddb 100644 --- a/inc/lib/Twig/Error/Runtime.php +++ b/inc/lib/Twig/Error/Runtime.php @@ -13,8 +13,7 @@ /** * Exception thrown when an error occurs at runtime. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Error_Runtime extends Twig_Error { diff --git a/inc/lib/Twig/Error/Syntax.php b/inc/lib/Twig/Error/Syntax.php index a2650c36..0f5c5792 100644 --- a/inc/lib/Twig/Error/Syntax.php +++ b/inc/lib/Twig/Error/Syntax.php @@ -13,8 +13,7 @@ /** * Exception thrown when a syntax error occurs during lexing or parsing of a template. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Error_Syntax extends Twig_Error { diff --git a/inc/lib/Twig/ExistsLoaderInterface.php b/inc/lib/Twig/ExistsLoaderInterface.php new file mode 100644 index 00000000..ce434765 --- /dev/null +++ b/inc/lib/Twig/ExistsLoaderInterface.php @@ -0,0 +1,28 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +interface Twig_ExistsLoaderInterface +{ + /** + * Check if we have the source code of a template, given its name. + * + * @param string $name The name of the template to check if we can load + * + * @return boolean If the template source code is handled by this loader or not + */ + public function exists($name); +} diff --git a/inc/lib/Twig/ExpressionParser.php b/inc/lib/Twig/ExpressionParser.php index b4fc5d5d..9cf19344 100644 --- a/inc/lib/Twig/ExpressionParser.php +++ b/inc/lib/Twig/ExpressionParser.php @@ -18,8 +18,7 @@ * @see http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm * @see http://en.wikipedia.org/wiki/Operator-precedence_parser * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_ExpressionParser { @@ -89,9 +88,19 @@ class Twig_ExpressionParser { while ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '?')) { $this->parser->getStream()->next(); - $expr2 = $this->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'The ternary operator must have a default value'); - $expr3 = $this->parseExpression(); + if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ':')) { + $expr2 = $this->parseExpression(); + if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ':')) { + $this->parser->getStream()->next(); + $expr3 = $this->parseExpression(); + } else { + $expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine()); + } + } else { + $this->parser->getStream()->next(); + $expr2 = $expr; + $expr3 = $this->parseExpression(); + } $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine()); } @@ -143,31 +152,67 @@ class Twig_ExpressionParser break; case Twig_Token::NUMBER_TYPE: - case Twig_Token::STRING_TYPE: $this->parser->getStream()->next(); $node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); break; + case Twig_Token::STRING_TYPE: + case Twig_Token::INTERPOLATION_START_TYPE: + $node = $this->parseStringExpression(); + break; + default: if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) { $node = $this->parseArrayExpression(); } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) { $node = $this->parseHashExpression(); } else { - throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine()); + throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine(), $this->parser->getFilename()); } } return $this->parsePostfixExpression($node); } + public function parseStringExpression() + { + $stream = $this->parser->getStream(); + + $nodes = array(); + // a string cannot be followed by another string in a single expression + $nextCanBeString = true; + while (true) { + if ($stream->test(Twig_Token::STRING_TYPE) && $nextCanBeString) { + $token = $stream->next(); + $nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); + $nextCanBeString = false; + } elseif ($stream->test(Twig_Token::INTERPOLATION_START_TYPE)) { + $stream->next(); + $nodes[] = $this->parseExpression(); + $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); + $nextCanBeString = true; + } else { + break; + } + } + + $expr = array_shift($nodes); + foreach ($nodes as $node) { + $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getLine()); + } + + return $expr; + } + public function parseArrayExpression() { $stream = $this->parser->getStream(); $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected'); - $elements = array(); + + $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine()); + $first = true; while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) { - if (!empty($elements)) { + if (!$first) { $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma'); // trailing ,? @@ -175,21 +220,24 @@ class Twig_ExpressionParser break; } } + $first = false; - $elements[] = $this->parseExpression(); + $node->addElement($this->parseExpression()); } $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed'); - return new Twig_Node_Expression_Array($elements, $stream->getCurrent()->getLine()); + return $node; } public function parseHashExpression() { $stream = $this->parser->getStream(); $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected'); - $elements = array(); + + $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine()); + $first = true; while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) { - if (!empty($elements)) { + if (!$first) { $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma'); // trailing ,? @@ -197,19 +245,33 @@ class Twig_ExpressionParser break; } } - - if (!$stream->test(Twig_Token::STRING_TYPE) && !$stream->test(Twig_Token::NUMBER_TYPE)) { + $first = false; + + // a hash key can be: + // + // * a number -- 12 + // * a string -- 'a' + // * a name, which is equivalent to a string -- a + // * an expression, which must be enclosed in parentheses -- (1 + 2) + if ($stream->test(Twig_Token::STRING_TYPE) || $stream->test(Twig_Token::NAME_TYPE) || $stream->test(Twig_Token::NUMBER_TYPE)) { + $token = $stream->next(); + $key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); + } elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { + $key = $this->parseExpression(); + } else { $current = $stream->getCurrent(); - throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string or a number (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine()); + + throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine(), $this->parser->getFilename()); } - $key = $stream->next()->getValue(); $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)'); - $elements[$key] = $this->parseExpression(); + $value = $this->parseExpression(); + + $node->addElement($value, $key); } $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed'); - return new Twig_Node_Expression_Array($elements, $stream->getCurrent()->getLine()); + return $node; } public function parsePostfixExpression($node) @@ -234,43 +296,56 @@ class Twig_ExpressionParser public function getFunctionNode($name, $line) { - $args = $this->parseArguments(); switch ($name) { case 'parent': + $args = $this->parseArguments(); if (!count($this->parser->getBlockStack())) { - throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line); + throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename()); } - if (!$this->parser->getParent()) { - throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend another one is forbidden', $line); + if (!$this->parser->getParent() && !$this->parser->hasTraits()) { + throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename()); } return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line); case 'block': - return new Twig_Node_Expression_BlockReference($args->getNode(0), false, $line); + return new Twig_Node_Expression_BlockReference($this->parseArguments()->getNode(0), false, $line); case 'attribute': + $args = $this->parseArguments(); if (count($args) < 2) { - throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attribute)', $line); + throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename()); } return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : new Twig_Node_Expression_Array(array(), $line), Twig_TemplateInterface::ANY_CALL, $line); default: - if (null !== $alias = $this->parser->getImportedFunction($name)) { - return new Twig_Node_Expression_GetAttr($alias['node'], new Twig_Node_Expression_Constant($alias['name'], $line), $args, Twig_TemplateInterface::METHOD_CALL, $line); + if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) { + $arguments = new Twig_Node_Expression_Array(array(), $line); + foreach ($this->parseArguments() as $n) { + $arguments->addElement($n); + } + + $node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line); + $node->setAttribute('safe', true); + + return $node; } - return new Twig_Node_Expression_Function($name, $args, $line); + $args = $this->parseArguments(true); + $class = $this->getFunctionNodeClass($name, $line); + + return new $class($name, $args, $line); } } public function parseSubscriptExpression($node) { - $token = $this->parser->getStream()->next(); + $stream = $this->parser->getStream(); + $token = $stream->next(); $lineno = $token->getLine(); - $arguments = new Twig_Node(); + $arguments = new Twig_Node_Expression_Array(array(), $lineno); $type = Twig_TemplateInterface::ANY_CALL; if ($token->getValue() == '.') { - $token = $this->parser->getStream()->next(); + $token = $stream->next(); if ( $token->getType() == Twig_Token::NAME_TYPE || @@ -280,20 +355,60 @@ class Twig_ExpressionParser ) { $arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno); - if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) { + if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { $type = Twig_TemplateInterface::METHOD_CALL; - $arguments = $this->parseArguments(); - } else { - $arguments = new Twig_Node(); + foreach ($this->parseArguments() as $n) { + $arguments->addElement($n); + } } } else { - throw new Twig_Error_Syntax('Expected name or number', $lineno); + throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename()); + } + + if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { + if (!$arg instanceof Twig_Node_Expression_Constant) { + throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename()); + } + + $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); + $node->setAttribute('safe', true); + + return $node; } } else { $type = Twig_TemplateInterface::ARRAY_CALL; - $arg = $this->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ']'); + // slice? + $slice = false; + if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) { + $slice = true; + $arg = new Twig_Node_Expression_Constant(0, $token->getLine()); + } else { + $arg = $this->parseExpression(); + } + + if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) { + $slice = true; + $stream->next(); + } + + if ($slice) { + if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) { + $length = new Twig_Node_Expression_Constant(null, $token->getLine()); + } else { + $length = $this->parseExpression(); + } + + $class = $this->getFilterNodeClass('slice', $token->getLine()); + $arguments = new Twig_Node(array($arg, $length)); + $filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine()); + + $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); + + return $filter; + } + + $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); } return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno); @@ -315,10 +430,12 @@ class Twig_ExpressionParser if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) { $arguments = new Twig_Node(); } else { - $arguments = $this->parseArguments(); + $arguments = $this->parseArguments(true); } - $node = new Twig_Node_Expression_Filter($node, $name, $arguments, $token->getLine(), $tag); + $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine()); + + $node = new $class($node, $name, $arguments, $token->getLine(), $tag); if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) { break; @@ -330,17 +447,62 @@ class Twig_ExpressionParser return $node; } - public function parseArguments() + /** + * Parses arguments. + * + * @param Boolean $namedArguments Whether to allow named arguments or not + * @param Boolean $definition Whether we are parsing arguments for a function definition + */ + public function parseArguments($namedArguments = false, $definition = false) { $args = array(); $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must be opened by a parenthesis'); + $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis'); while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) { if (!empty($args)) { $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma'); } - $args[] = $this->parseExpression(); + + if ($definition) { + $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name'); + $value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine()); + } else { + $value = $this->parseExpression(); + } + + $name = null; + if ($namedArguments && $stream->test(Twig_Token::OPERATOR_TYPE, '=')) { + $token = $stream->next(); + if (!$value instanceof Twig_Node_Expression_Name) { + throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given', get_class($value)), $token->getLine(), $this->parser->getFilename()); + } + $name = $value->getAttribute('name'); + + if ($definition) { + $value = $this->parsePrimaryExpression(); + + if (!$this->checkConstantExpression($value)) { + throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $this->parser->getFilename()); + } + } else { + $value = $this->parseExpression(); + } + } + + if ($definition) { + if (null === $name) { + $name = $value->getAttribute('name'); + $value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine()); + } + $args[$name] = $value; + } else { + if (null === $name) { + $args[] = $value; + } else { + $args[$name] = $value; + } + } } $stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis'); @@ -353,7 +515,7 @@ class Twig_ExpressionParser while (true) { $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to'); if (in_array($token->getValue(), array('true', 'false', 'none'))) { - throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine()); + throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename()); } $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine()); @@ -379,4 +541,60 @@ class Twig_ExpressionParser return new Twig_Node($targets); } + + protected function getFunctionNodeClass($name, $line) + { + $env = $this->parser->getEnvironment(); + + if (false === $function = $env->getFunction($name)) { + $message = sprintf('The function "%s" does not exist', $name); + if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFunctions()))) { + $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); + } + + throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename()); + } + + if ($function instanceof Twig_SimpleFunction) { + return $function->getNodeClass(); + } + + return $function instanceof Twig_Function_Node ? $function->getClass() : 'Twig_Node_Expression_Function'; + } + + protected function getFilterNodeClass($name, $line) + { + $env = $this->parser->getEnvironment(); + + if (false === $filter = $env->getFilter($name)) { + $message = sprintf('The filter "%s" does not exist', $name); + if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFilters()))) { + $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); + } + + throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename()); + } + + if ($filter instanceof Twig_SimpleFilter) { + return $filter->getNodeClass(); + } + + return $filter instanceof Twig_Filter_Node ? $filter->getClass() : 'Twig_Node_Expression_Filter'; + } + + // checks that the node only contains "constant" elements + protected function checkConstantExpression(Twig_NodeInterface $node) + { + if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array)) { + return false; + } + + foreach ($node as $n) { + if (!$this->checkConstantExpression($n)) { + return false; + } + } + + return true; + } } diff --git a/inc/lib/Twig/Extension.php b/inc/lib/Twig/Extension.php index ac289cb4..931fc033 100644 --- a/inc/lib/Twig/Extension.php +++ b/inc/lib/Twig/Extension.php @@ -82,9 +82,9 @@ abstract class Twig_Extension implements Twig_ExtensionInterface } /** - * Returns a list of global functions to add to the existing list. + * Returns a list of global variables to add to the existing list. * - * @return array An array of global functions + * @return array An array of global variables */ public function getGlobals() { diff --git a/inc/lib/Twig/Extension/Core.php b/inc/lib/Twig/Extension/Core.php index a4153245..e68687b4 100644 --- a/inc/lib/Twig/Extension/Core.php +++ b/inc/lib/Twig/Extension/Core.php @@ -14,6 +14,83 @@ if (!defined('ENT_SUBSTITUTE')) { */ class Twig_Extension_Core extends Twig_Extension { + protected $dateFormats = array('F j, Y H:i', '%d days'); + protected $numberFormat = array(0, '.', ','); + protected $timezone = null; + + /** + * Sets the default format to be used by the date filter. + * + * @param string $format The default date format string + * @param string $dateIntervalFormat The default date interval format string + */ + public function setDateFormat($format = null, $dateIntervalFormat = null) + { + if (null !== $format) { + $this->dateFormats[0] = $format; + } + + if (null !== $dateIntervalFormat) { + $this->dateFormats[1] = $dateIntervalFormat; + } + } + + /** + * Gets the default format to be used by the date filter. + * + * @return array The default date format string and the default date interval format string + */ + public function getDateFormat() + { + return $this->dateFormats; + } + + /** + * Sets the default timezone to be used by the date filter. + * + * @param DateTimeZone|string $timezone The default timezone string or a DateTimeZone object + */ + public function setTimezone($timezone) + { + $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone); + } + + /** + * Gets the default timezone to be used by the date filter. + * + * @return DateTimeZone The default timezone currently in use + */ + public function getTimezone() + { + if (null === $this->timezone) { + $this->timezone = new DateTimeZone(date_default_timezone_get()); + } + + return $this->timezone; + } + + /** + * Sets the default format to be used by the number_format filter. + * + * @param integer $decimal The number of decimal places to use. + * @param string $decimalPoint The character(s) to use for the decimal point. + * @param string $thousandSep The character(s) to use for the thousands separator. + */ + public function setNumberFormat($decimal, $decimalPoint, $thousandSep) + { + $this->numberFormat = array($decimal, $decimalPoint, $thousandSep); + } + + /** + * Get the default format used by the number_format filter. + * + * @return array The arguments for number_format() + */ + public function getNumberFormat() + { + return $this->numberFormat; + } + /** * Returns the token parser instance to add to the existing list. * @@ -34,6 +111,9 @@ class Twig_Extension_Core extends Twig_Extension new Twig_TokenParser_From(), new Twig_TokenParser_Set(), new Twig_TokenParser_Spaceless(), + new Twig_TokenParser_Flush(), + new Twig_TokenParser_Do(), + new Twig_TokenParser_Embed(), ); } @@ -46,40 +126,53 @@ class Twig_Extension_Core extends Twig_Extension { $filters = array( // formatting filters - 'date' => new Twig_Filter_Function('twig_date_format_filter'), - 'format' => new Twig_Filter_Function('sprintf'), - 'replace' => new Twig_Filter_Function('twig_strtr'), + new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('format', 'sprintf'), + new Twig_SimpleFilter('replace', 'strtr'), + new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('abs', 'abs'), // encoding - 'url_encode' => new Twig_Filter_Function('twig_urlencode_filter'), - 'json_encode' => new Twig_Filter_Function('twig_jsonencode_filter'), + new Twig_SimpleFilter('url_encode', 'twig_urlencode_filter'), + new Twig_SimpleFilter('json_encode', 'twig_jsonencode_filter'), + new Twig_SimpleFilter('convert_encoding', 'twig_convert_encoding'), // string filters - 'title' => new Twig_Filter_Function('twig_title_string_filter', array('needs_environment' => true)), - 'capitalize' => new Twig_Filter_Function('twig_capitalize_string_filter', array('needs_environment' => true)), - 'upper' => new Twig_Filter_Function('strtoupper'), - 'lower' => new Twig_Filter_Function('strtolower'), - 'striptags' => new Twig_Filter_Function('strip_tags'), + new Twig_SimpleFilter('title', 'twig_title_string_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('upper', 'strtoupper'), + new Twig_SimpleFilter('lower', 'strtolower'), + new Twig_SimpleFilter('striptags', 'strip_tags'), + new Twig_SimpleFilter('trim', 'trim'), + new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))), // array helpers - 'join' => new Twig_Filter_Function('twig_join_filter'), - 'reverse' => new Twig_Filter_Function('twig_reverse_filter'), - 'length' => new Twig_Filter_Function('twig_length_filter', array('needs_environment' => true)), - 'sort' => new Twig_Filter_Function('twig_sort_filter'), - 'merge' => new Twig_Filter_Function('twig_array_merge'), + new Twig_SimpleFilter('join', 'twig_join_filter'), + new Twig_SimpleFilter('split', 'twig_split_filter'), + new Twig_SimpleFilter('sort', 'twig_sort_filter'), + new Twig_SimpleFilter('merge', 'twig_array_merge'), + new Twig_SimpleFilter('batch', 'twig_array_batch'), + + // string/array filters + new Twig_SimpleFilter('reverse', 'twig_reverse_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('length', 'twig_length_filter', array('needs_environment' => true)), + new Twig_SimpleFilter('slice', 'twig_slice', array('needs_environment' => true)), + new Twig_SimpleFilter('first', 'twig_first', array('needs_environment' => true)), + new Twig_SimpleFilter('last', 'twig_last', array('needs_environment' => true)), // iteration and runtime - 'default' => new Twig_Filter_Function('twig_default_filter'), - 'keys' => new Twig_Filter_Function('twig_get_array_keys_filter'), + new Twig_SimpleFilter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')), + new Twig_SimpleFilter('keys', 'twig_get_array_keys_filter'), // escaping - 'escape' => new Twig_Filter_Function('twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), - 'e' => new Twig_Filter_Function('twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), + new Twig_SimpleFilter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), + new Twig_SimpleFilter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), ); if (function_exists('mb_get_info')) { - $filters['upper'] = new Twig_Filter_Function('twig_upper_filter', array('needs_environment' => true)); - $filters['lower'] = new Twig_Filter_Function('twig_lower_filter', array('needs_environment' => true)); + $filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', array('needs_environment' => true)); + $filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', array('needs_environment' => true)); } return $filters; @@ -93,29 +186,33 @@ class Twig_Extension_Core extends Twig_Extension public function getFunctions() { return array( - 'range' => new Twig_Function_Function('range'), - 'constant' => new Twig_Function_Function('constant'), - 'cycle' => new Twig_Function_Function('twig_cycle'), + new Twig_SimpleFunction('range', 'range'), + new Twig_SimpleFunction('constant', 'twig_constant'), + new Twig_SimpleFunction('cycle', 'twig_cycle'), + new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)), + new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)), + new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))), ); } /** - * Returns a list of filters to add to the existing list. + * Returns a list of tests to add to the existing list. * - * @return array An array of filters + * @return array An array of tests */ public function getTests() { return array( - 'even' => new Twig_Test_Function('twig_test_even'), - 'odd' => new Twig_Test_Function('twig_test_odd'), - 'defined' => new Twig_Test_Function('twig_test_defined'), - 'sameas' => new Twig_Test_Function('twig_test_sameas'), - 'none' => new Twig_Test_Function('twig_test_none'), - 'null' => new Twig_Test_Function('twig_test_none'), - 'divisibleby' => new Twig_Test_Function('twig_test_divisibleby'), - 'constant' => new Twig_Test_Function('twig_test_constant'), - 'empty' => new Twig_Test_Function('twig_test_empty'), + new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')), + new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')), + new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')), + new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')), + new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), + new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), + new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')), + new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')), + new Twig_SimpleTest('empty', 'twig_test_empty'), + new Twig_SimpleTest('iterable', 'twig_test_iterable'), ); } @@ -129,15 +226,15 @@ class Twig_Extension_Core extends Twig_Extension return array( array( 'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - '-' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Neg'), - '+' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Pos'), + '-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'), + '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'), ), array( - 'b-and' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-xor' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-or' => array('precedence' => 5, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), @@ -146,6 +243,7 @@ class Twig_Extension_Core extends Twig_Extension '<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), @@ -155,7 +253,6 @@ class Twig_Extension_Core extends Twig_Extension '%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'is' => array('precedence' => 100, 'callable' => array($this, 'parseTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'is not' => array('precedence' => 100, 'callable' => array($this, 'parseNotTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '..' => array('precedence' => 110, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), '**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT), ), ); @@ -169,13 +266,35 @@ class Twig_Extension_Core extends Twig_Extension public function parseTestExpression(Twig_Parser $parser, $node) { $stream = $parser->getStream(); - $name = $stream->expect(Twig_Token::NAME_TYPE); + $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); $arguments = null; if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $arguments = $parser->getExpressionParser()->parseArguments(); + $arguments = $parser->getExpressionParser()->parseArguments(true); } - return new Twig_Node_Expression_Test($node, $name->getValue(), $arguments, $parser->getCurrentToken()->getLine()); + $class = $this->getTestNodeClass($parser, $name, $node->getLine()); + + return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine()); + } + + protected function getTestNodeClass(Twig_Parser $parser, $name, $line) + { + $env = $parser->getEnvironment(); + $testMap = $env->getTests(); + if (!isset($testMap[$name])) { + $message = sprintf('The test "%s" does not exist', $name); + if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) { + $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); + } + + throw new Twig_Error_Syntax($message, $line, $parser->getFilename()); + } + + if ($testMap[$name] instanceof Twig_SimpleTest) { + return $testMap[$name]->getNodeClass(); + } + + return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test'; } /** @@ -192,18 +311,77 @@ class Twig_Extension_Core extends Twig_Extension /** * Cycles over a value. * - * @param ArrayAccess|array $values An array or an ArrayAccess instance - * @param integer $i The cycle value + * @param ArrayAccess|array $values An array or an ArrayAccess instance + * @param integer $position The cycle position * * @return string The next value in the cycle */ -function twig_cycle($values, $i) +function twig_cycle($values, $position) { if (!is_array($values) && !$values instanceof ArrayAccess) { return $values; } - return $values[$i % count($values)]; + return $values[$position % count($values)]; +} + +/** + * Returns a random value depending on the supplied parameter type: + * - a random item from a Traversable or array + * - a random character from a string + * - a random integer between 0 and the integer parameter + * + * @param Twig_Environment $env A Twig_Environment instance + * @param Traversable|array|integer|string $values The values to pick a random item from + * + * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is). + * + * @return mixed A random value from the given sequence + */ +function twig_random(Twig_Environment $env, $values = null) +{ + if (null === $values) { + return mt_rand(); + } + + if (is_int($values) || is_float($values)) { + return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values); + } + + if ($values instanceof Traversable) { + $values = iterator_to_array($values); + } elseif (is_string($values)) { + if ('' === $values) { + return ''; + } + if (null !== $charset = $env->getCharset()) { + if ('UTF-8' != $charset) { + $values = twig_convert_encoding($values, 'UTF-8', $charset); + } + + // unicode version of str_split() + // split at all positions, but not after the start and not before the end + $values = preg_split('/(? $value) { + $values[$i] = twig_convert_encoding($value, $charset, 'UTF-8'); + } + } + } else { + return $values[mt_rand(0, strlen($values) - 1)]; + } + } + + if (!is_array($values)) { + return $values; + } + + if (0 === count($values)) { + throw new Twig_Error_Runtime('The random function cannot pick from an empty array.'); + } + + return $values[array_rand($values, 1)]; } /** @@ -213,44 +391,143 @@ function twig_cycle($values, $i) * {{ post.published_at|date("m/d/Y") }} * * + * @param Twig_Environment $env A Twig_Environment instance + * @param DateTime|DateInterval|string $date A date + * @param string $format A format + * @param DateTimeZone|string $timezone A timezone + * + * @return string The formatted date + */ +function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null) +{ + if (null === $format) { + $formats = $env->getExtension('core')->getDateFormat(); + $format = $date instanceof DateInterval ? $formats[1] : $formats[0]; + } + + if ($date instanceof DateInterval) { + return $date->format($format); + } + + return twig_date_converter($env, $date, $timezone)->format($format); +} + +/** + * Returns a new date object modified + * + *
+ *   {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
+ * 
+ * + * @param Twig_Environment $env A Twig_Environment instance + * @param DateTime|string $date A date + * @param string $modifier A modifier string + * + * @return DateTime A new date object + */ +function twig_date_modify_filter(Twig_Environment $env, $date, $modifier) +{ + $date = twig_date_converter($env, $date, false); + $date->modify($modifier); + + return $date; +} + +/** + * Converts an input to a DateTime instance. + * + *
+ *    {% if date(user.created_at) < date('+2days') %}
+ *      {# do something #}
+ *    {% endif %}
+ * 
+ * + * @param Twig_Environment $env A Twig_Environment instance * @param DateTime|string $date A date - * @param string $format A format * @param DateTimeZone|string $timezone A timezone * - * @return string The formatter date + * @return DateTime A DateTime instance */ -function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = null) +function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null) { - if (!$date instanceof DateTime) { - if (ctype_digit((string) $date)) { - $date = new DateTime('@'.$date); - $date->setTimezone(new DateTimeZone(date_default_timezone_get())); - } else { - $date = new DateTime($date); - } + // determine the timezone + if (!$timezone) { + $defaultTimezone = $env->getExtension('core')->getTimezone(); + } elseif (!$timezone instanceof DateTimeZone) { + $defaultTimezone = new DateTimeZone($timezone); + } else { + $defaultTimezone = $timezone; } - if (null !== $timezone) { - if (!$timezone instanceof DateTimeZone) { - $timezone = new DateTimeZone($timezone); + if ($date instanceof DateTime) { + $date = clone $date; + if (false !== $timezone) { + $date->setTimezone($defaultTimezone); } - $date->setTimezone($timezone); + return $date; + } + + $asString = (string) $date; + if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) { + $date = '@'.$date; + } + + $date = new DateTime($date, $defaultTimezone); + if (false !== $timezone) { + $date->setTimezone($defaultTimezone); + } + + return $date; +} + +/** + * Number format filter. + * + * All of the formatting options can be left null, in that case the defaults will + * be used. Supplying any of the parameters will override the defaults set in the + * environment object. + * + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $number A float/int/string of the number to format + * @param integer $decimal The number of decimal points to display. + * @param string $decimalPoint The character(s) to use for the decimal point. + * @param string $thousandSep The character(s) to use for the thousands separator. + * + * @return string The formatted number + */ +function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null) +{ + $defaults = $env->getExtension('core')->getNumberFormat(); + if (null === $decimal) { + $decimal = $defaults[0]; + } + + if (null === $decimalPoint) { + $decimalPoint = $defaults[1]; + } + + if (null === $thousandSep) { + $thousandSep = $defaults[2]; } - return $date->format($format); + return number_format((float) $number, $decimal, $decimalPoint, $thousandSep); } /** - * URL encodes a string. + * URL encodes a string as a path segment or an array as a query string. * - * @param string $url A URL - * @param bool $raw true to use rawurlencode() instead of urlencode + * @param string|array $url A URL or an array of query parameters + * @param bool $raw true to use rawurlencode() instead of urlencode * * @return string The URL encoded value */ function twig_urlencode_filter($url, $raw = false) { + if (is_array($url)) { + return http_build_query($url, '', '&'); + } + if ($raw) { return rawurlencode($url); } @@ -260,7 +537,7 @@ function twig_urlencode_filter($url, $raw = false) if (version_compare(PHP_VERSION, '5.3.0', '<')) { /** - * JSON encodes a PHP variable. + * JSON encodes a variable. * * @param mixed $value The value to encode. * @param integer $options Not used on PHP 5.2.x @@ -279,7 +556,7 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) { } } else { /** - * JSON encodes a PHP variable. + * JSON encodes a variable. * * @param mixed $value The value to encode. * @param integer $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT @@ -324,12 +601,72 @@ function _twig_markup2string(&$value) function twig_array_merge($arr1, $arr2) { if (!is_array($arr1) || !is_array($arr2)) { - throw new Twig_Error_Runtime('The merge filter only work with arrays or hashes.'); + throw new Twig_Error_Runtime('The merge filter only works with arrays or hashes.'); } return array_merge($arr1, $arr2); } +/** + * Slices a variable. + * + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $item A variable + * @param integer $start Start of the slice + * @param integer $length Size of the slice + * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array) + * + * @return mixed The sliced variable + */ +function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false) +{ + if ($item instanceof Traversable) { + $item = iterator_to_array($item, false); + } + + if (is_array($item)) { + return array_slice($item, $start, $length, $preserveKeys); + } + + $item = (string) $item; + + if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) { + return mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset); + } + + return null === $length ? substr($item, $start) : substr($item, $start, $length); +} + +/** + * Returns the first element of the item. + * + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $item A variable + * + * @return mixed The first element of the item + */ +function twig_first(Twig_Environment $env, $item) +{ + $elements = twig_slice($env, $item, 0, 1, false); + + return is_string($elements) ? $elements[0] : current($elements); +} + +/** + * Returns the last element of the item. + * + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $item A variable + * + * @return mixed The last element of the item + */ +function twig_last(Twig_Environment $env, $item) +{ + $elements = twig_slice($env, $item, -1, 1, false); + + return is_string($elements) ? $elements[0] : current($elements); +} + /** * Joins the values to a string. * @@ -350,30 +687,55 @@ function twig_array_merge($arr1, $arr2) */ function twig_join_filter($value, $glue = '') { + if ($value instanceof Traversable) { + $value = iterator_to_array($value, false); + } + return implode($glue, (array) $value); } /** - * Returns the value or the default value when it is undefined or empty. + * Splits the string into an array. * *
+ *  {{ "one,two,three"|split(',') }}
+ *  {# returns [one, two, three] #}
+ *
+ *  {{ "one,two,three,four,five"|split(',', 3) }}
+ *  {# returns [one, two, "three,four,five"] #}
  *
- *  {{ var.foo|default('foo item on var is not defined') }}
+ *  {{ "123"|split('') }}
+ *  {# returns [1, 2, 3] #}
  *
+ *  {{ "aabbcc"|split('', 2) }}
+ *  {# returns [aa, bb, cc] #}
  * 
* - * @param mixed $value A value - * @param mixed $default The default value + * @param string $value A string + * @param string $delimiter The delimiter + * @param integer $limit The limit * - * @param mixed The value or the default value; + * @return array The split string as an array */ -function twig_default_filter($value, $default = '') +function twig_split_filter($value, $delimiter, $limit = null) +{ + if (empty($delimiter)) { + return str_split($value, null === $limit ? 1 : $limit); + } + + return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit); +} + +// The '_default' filter is used internally to avoid using the ternary operator +// which costs a lot for big contexts (before PHP 5.4). So, on average, +// a function call is cheaper. +function _twig_default_filter($value, $default = '') { if (twig_test_empty($value)) { return $default; - } else { - return $value; } + + return $value; } /** @@ -405,23 +767,43 @@ function twig_get_array_keys_filter($array) } /** - * Reverses an array. + * Reverses a variable. * - * @param array|Traversable $array An array or a Traversable instance + * @param Twig_Environment $env A Twig_Environment instance + * @param array|Traversable|string $item An array, a Traversable instance, or a string + * @param Boolean $preserveKeys Whether to preserve key or not * - * return array The array reversed + * @return mixed The reversed input */ -function twig_reverse_filter($array) +function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false) { - if (is_object($array) && $array instanceof Traversable) { - return array_reverse(iterator_to_array($array)); + if (is_object($item) && $item instanceof Traversable) { + return array_reverse(iterator_to_array($item), $preserveKeys); } - if (!is_array($array)) { - return array(); + if (is_array($item)) { + return array_reverse($item, $preserveKeys); + } + + if (null !== $charset = $env->getCharset()) { + $string = (string) $item; + + if ('UTF-8' != $charset) { + $item = twig_convert_encoding($string, 'UTF-8', $charset); + } + + preg_match_all('/./us', $item, $matches); + + $string = implode('', array_reverse($matches[0])); + + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, $charset, 'UTF-8'); + } + + return $string; } - return array_reverse($array); + return strrev((string) $item); } /** @@ -440,78 +822,151 @@ function twig_sort_filter($array) function twig_in_filter($value, $compare) { if (is_array($compare)) { - return in_array($value, $compare); + return in_array($value, $compare, is_object($value)); } elseif (is_string($compare)) { + if (!strlen($value)) { + return empty($compare); + } + return false !== strpos($compare, (string) $value); - } elseif (is_object($compare) && $compare instanceof Traversable) { - return in_array($value, iterator_to_array($compare, false)); + } elseif ($compare instanceof Traversable) { + return in_array($value, iterator_to_array($compare, false), is_object($value)); } return false; } -/** - * Replaces placeholders in a string. - * - *
- *  {{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
- * 
- * - * @param string $pattern A string - * @param string $replacements The values for the placeholders - * - * @return string The string where the placeholders have been replaced - */ -function twig_strtr($pattern, $replacements) -{ - return str_replace(array_keys($replacements), array_values($replacements), $pattern); -} - /** * Escapes a string. * - * @param Twig_Environment $env A Twig_Environment instance - * @param string $string The value to be escaped - * @param string $type The escaping strategy - * @param string $charset The charset + * @param Twig_Environment $env A Twig_Environment instance + * @param string $string The value to be escaped + * @param string $strategy The escaping strategy + * @param string $charset The charset + * @param Boolean $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false) */ -function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $charset = null) +function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false) { - if (is_object($string) && $string instanceof Twig_Markup) { + if ($autoescape && $string instanceof Twig_Markup) { return $string; } - if (!is_string($string) && !(is_object($string) && method_exists($string, '__toString'))) { - return $string; + if (!is_string($string)) { + if (is_object($string) && method_exists($string, '__toString')) { + $string = (string) $string; + } else { + return $string; + } } if (null === $charset) { $charset = $env->getCharset(); } - switch ($type) { + switch ($strategy) { + case 'html': + // see http://php.net/htmlspecialchars + + // Using a static variable to avoid initializing the array + // each time the function is called. Moving the declaration on the + // top of the function slow downs other escaping strategies. + static $htmlspecialcharsCharsets = array( + 'ISO-8859-1' => true, 'ISO8859-1' => true, + 'ISO-8859-15' => true, 'ISO8859-15' => true, + 'utf-8' => true, 'UTF-8' => true, + 'CP866' => true, 'IBM866' => true, '866' => true, + 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true, + '1251' => true, + 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true, + 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true, + 'BIG5' => true, '950' => true, + 'GB2312' => true, '936' => true, + 'BIG5-HKSCS' => true, + 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true, + 'EUC-JP' => true, 'EUCJP' => true, + 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true, + ); + + if (isset($htmlspecialcharsCharsets[$charset])) { + return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); + } + + if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) { + // cache the lowercase variant for future iterations + $htmlspecialcharsCharsets[$charset] = true; + + return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); + } + + $string = twig_convert_encoding($string, 'UTF-8', $charset); + $string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); + + return twig_convert_encoding($string, $charset, 'UTF-8'); + case 'js': // escape all non-alphanumeric characters // into their \xHH or \uHHHH representations if ('UTF-8' != $charset) { - $string = _twig_convert_encoding($string, 'UTF-8', $charset); + $string = twig_convert_encoding($string, 'UTF-8', $charset); } - if (null === $string = preg_replace_callback('#[^\p{L}\p{N} ]#u', '_twig_escape_js_callback', $string)) { + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); } + $string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string); + if ('UTF-8' != $charset) { - $string = _twig_convert_encoding($string, $charset, 'UTF-8'); + $string = twig_convert_encoding($string, $charset, 'UTF-8'); } return $string; - case 'html': - return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); + case 'css': + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, 'UTF-8', $charset); + } + + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { + throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); + } + + $string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string); + + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, $charset, 'UTF-8'); + } + + return $string; + + case 'html_attr': + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, 'UTF-8', $charset); + } + + if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) { + throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.'); + } + + $string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string); + + if ('UTF-8' != $charset) { + $string = twig_convert_encoding($string, $charset, 'UTF-8'); + } + + return $string; + + case 'url': + // hackish test to avoid version_compare that is much slower, this works unless PHP releases a 5.10.* + // at that point however PHP 5.2.* support can be removed + if (PHP_VERSION < '5.3.0') { + return str_replace('%7E', '~', rawurlencode($string)); + } + + return rawurlencode($string); default: - throw new Twig_Error_Runtime(sprintf('Invalid escape type "%s".', $type)); + throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: html, js, url, css, and html_attr).', $strategy)); } } @@ -521,28 +976,26 @@ function twig_escape_filter_is_safe(Twig_Node $filterArgs) foreach ($filterArgs as $arg) { if ($arg instanceof Twig_Node_Expression_Constant) { return array($arg->getAttribute('value')); - } else { - return array(); } - break; + return array(); } return array('html'); } -if (function_exists('iconv')) { - function _twig_convert_encoding($string, $to, $from) +if (function_exists('mb_convert_encoding')) { + function twig_convert_encoding($string, $to, $from) { - return iconv($from, $to, $string); + return mb_convert_encoding($string, $to, $from); } -} elseif (function_exists('mb_convert_encoding')) { - function _twig_convert_encoding($string, $to, $from) +} elseif (function_exists('iconv')) { + function twig_convert_encoding($string, $to, $from) { - return mb_convert_encoding($string, $to, $from); + return iconv($from, $to, $string); } } else { - function _twig_convert_encoding($string, $to, $from) + function twig_convert_encoding($string, $to, $from) { throw new Twig_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).'); } @@ -554,22 +1007,98 @@ function _twig_escape_js_callback($matches) // \xHH if (!isset($char[1])) { - return '\\x'.substr('00'.bin2hex($char), -2); + return '\\x'.strtoupper(substr('00'.bin2hex($char), -2)); + } + + // \uHHHH + $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); + + return '\\u'.strtoupper(substr('0000'.bin2hex($char), -4)); +} + +function _twig_escape_css_callback($matches) +{ + $char = $matches[0]; + + // \xHH + if (!isset($char[1])) { + $hex = ltrim(strtoupper(bin2hex($char)), '0'); + if (0 === strlen($hex)) { + $hex = '0'; + } + + return '\\'.$hex.' '; } // \uHHHH - $char = _twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); + $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); - return '\\u'.substr('0000'.bin2hex($char), -4); + return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' '; +} + +/** + * This function is adapted from code coming from Zend Framework. + * + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +function _twig_escape_html_attr_callback($matches) +{ + /* + * While HTML supports far more named entities, the lowest common denominator + * has become HTML5's XML Serialisation which is restricted to the those named + * entities that XML supports. Using HTML entities would result in this error: + * XML Parsing Error: undefined entity + */ + static $entityMap = array( + 34 => 'quot', /* quotation mark */ + 38 => 'amp', /* ampersand */ + 60 => 'lt', /* less-than sign */ + 62 => 'gt', /* greater-than sign */ + ); + + $chr = $matches[0]; + $ord = ord($chr); + + /** + * The following replaces characters undefined in HTML with the + * hex entity for the Unicode replacement character. + */ + if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) { + return '�'; + } + + /** + * Check if the current character to escape has a name entity we should + * replace it with while grabbing the hex value of the character. + */ + if (strlen($chr) == 1) { + $hex = strtoupper(substr('00'.bin2hex($chr), -2)); + } else { + $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8'); + $hex = strtoupper(substr('0000'.bin2hex($chr), -4)); + } + + $int = hexdec($hex); + if (array_key_exists($int, $entityMap)) { + return sprintf('&%s;', $entityMap[$int]); + } + + /** + * Per OWASP recommendations, we'll use hex entities for any other + * characters where a named entity does not exist. + */ + + return sprintf('&#x%s;', $hex); } // add multibyte extensions if possible if (function_exists('mb_get_info')) { /** - * Returns the length of a PHP variable. + * Returns the length of a variable. * * @param Twig_Environment $env A Twig_Environment instance - * @param mixed $thing A PHP variable + * @param mixed $thing A variable * * @return integer The length of the value */ @@ -648,13 +1177,12 @@ if (function_exists('mb_get_info')) { } } // and byte fallback -else -{ +else { /** - * Returns the length of a PHP variable. + * Returns the length of a variable. * * @param Twig_Environment $env A Twig_Environment instance - * @param mixed $thing A PHP variable + * @param mixed $thing A variable * * @return integer The length of the value */ @@ -693,154 +1221,135 @@ else /* used internally */ function twig_ensure_traversable($seq) { - if (is_array($seq) || (is_object($seq) && $seq instanceof Traversable)) { + if ($seq instanceof Traversable || is_array($seq)) { return $seq; - } else { - return array(); } + + return array(); } /** - * Checks that a variable points to the same memory address than another one. + * Checks if a variable is empty. * *
- * {% if foo.attribute is sameas(false) %}
- *    the foo attribute really is the ``false`` PHP value
+ * {# evaluates to true if the foo variable is null, false, or the empty string #}
+ * {% if foo is empty %}
+ *     {# ... #}
  * {% endif %}
  * 
* - * @param mixed $value A PHP variable - * @param mixed $test The PHP variable to test against + * @param mixed $value A variable * - * @return Boolean true if the values are the same, false otherwise + * @return Boolean true if the value is empty, false otherwise */ -function twig_test_sameas($value, $test) +function twig_test_empty($value) { - return $value === $test; -} + if ($value instanceof Countable) { + return 0 == count($value); + } -/** - * Checks that a variable is null. - * - *
- *  {{ var is none }}
- * 
- * - * @param mixed $value a PHP variable. - * - * @return Boolean true if the value is null, false otherwise - */ -function twig_test_none($value) -{ - return null === $value; + return '' === $value || false === $value || null === $value || array() === $value; } /** - * Checks if a variable is divisible by a number. + * Checks if a variable is traversable. * *
- *  {% if loop.index is divisibleby(3) %}
+ * {# evaluates to true if the foo variable is an array or a traversable object #}
+ * {% if foo is traversable %}
+ *     {# ... #}
+ * {% endif %}
  * 
* - * @param integer $value A PHP value - * @param integer $num A number + * @param mixed $value A variable * - * @return Boolean true if the value is divisible by the number, false otherwise + * @return Boolean true if the value is traversable */ -function twig_test_divisibleby($value, $num) +function twig_test_iterable($value) { - return 0 == $value % $num; + return $value instanceof Traversable || is_array($value); } /** - * Checks if a number is even. - * - *
- *  {{ var is even }}
- * 
+ * Renders a template. * - * @param integer $value An integer + * @param string $template The template to render + * @param array $variables The variables to pass to the template + * @param Boolean $with_context Whether to pass the current context variables or not + * @param Boolean $ignore_missing Whether to ignore missing templates or not + * @param Boolean $sandboxed Whether to sandbox the template or not * - * @return Boolean true if the value is even, false otherwise + * @return string The rendered template */ -function twig_test_even($value) +function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) { - return $value % 2 == 0; -} + if ($withContext) { + $variables = array_merge($context, $variables); + } -/** - * Checks if a number is odd. - * - *
- *  {{ var is odd }}
- * 
- * - * @param integer $value An integer - * - * @return Boolean true if the value is odd, false otherwise - */ -function twig_test_odd($value) -{ - return $value % 2 == 1; -} + if ($isSandboxed = $sandboxed && $env->hasExtension('sandbox')) { + $sandbox = $env->getExtension('sandbox'); + if (!$alreadySandboxed = $sandbox->isSandboxed()) { + $sandbox->enableSandbox(); + } + } -/** - * Checks if a variable is the exact same value as a constant. - * - *
- *  {% if post.status is constant('Post::PUBLISHED') %}
- *    the status attribute is exactly the same as Post::PUBLISHED
- *  {% endif %}
- * 
- * - * @param mixed $value A PHP value - * @param mixed $constant The constant to test against - * - * @return Boolean true if the value is the same as the constant, false otherwise - */ -function twig_test_constant($value, $constant) -{ - return constant($constant) === $value; + try { + return $env->resolveTemplate($template)->render($variables); + } catch (Twig_Error_Loader $e) { + if (!$ignoreMissing) { + throw $e; + } + } + + if ($isSandboxed && !$alreadySandboxed) { + $sandbox->disableSandbox(); + } } /** - * Checks if a variable is defined in the current context. - * - *
- * {# defined works with variable names #}
- * {% if foo is defined %}
- *     {# ... #}
- * {% endif %}
- * 
+ * Provides the ability to get constants from instances as well as class/global constants. * - * @param mixed $name A PHP variable - * @param array $context The current context + * @param string $constant The name of the constant + * @param null|object $object The object to get the constant from * - * @return Boolean true if the value is defined, false otherwise + * @return string */ -function twig_test_defined($name, $context) +function twig_constant($constant, $object = null) { - return array_key_exists($name, $context); + if (null !== $object) { + $constant = get_class($object).'::'.$constant; + } + + return constant($constant); } /** - * Checks if a variable is empty. - * - *
- * {# evaluates to true if the foo variable is null, false, or the empty string #}
- * {% if foo is empty %}
- *     {# ... #}
- * {% endif %}
- * 
+ * Batches item. * - * @param mixed $value A PHP variable + * @param array $items An array of items + * @param integer $size The size of the batch + * @param string $fill A string to fill missing items * - * @return Boolean true if the value is empty, false otherwise + * @return array */ -function twig_test_empty($value) +function twig_array_batch($items, $size, $fill = null) { - if ($value instanceof Countable) { - return 0 == count($value); + if ($items instanceof Traversable) { + $items = iterator_to_array($items, false); } - return false === $value || (empty($value) && '0' != $value); + + $size = ceil($size); + + $result = array_chunk($items, $size, true); + + if (null !== $fill) { + $last = count($result) - 1; + $result[$last] = array_merge( + $result[$last], + array_fill(0, $size - count($result[$last]), $fill) + ); + } + + return $result; } diff --git a/inc/lib/Twig/Extension/Debug.php b/inc/lib/Twig/Extension/Debug.php new file mode 100644 index 00000000..e3a85bfe --- /dev/null +++ b/inc/lib/Twig/Extension/Debug.php @@ -0,0 +1,71 @@ + $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), + ); + } + + /** + * Returns the name of the extension. + * + * @return string The extension name + */ + public function getName() + { + return 'debug'; + } +} + +function twig_var_dump(Twig_Environment $env, $context) +{ + if (!$env->isDebug()) { + return; + } + + ob_start(); + + $count = func_num_args(); + if (2 === $count) { + $vars = array(); + foreach ($context as $key => $value) { + if (!$value instanceof Twig_Template) { + $vars[$key] = $value; + } + } + + var_dump($vars); + } else { + for ($i = 2; $i < $count; $i++) { + var_dump(func_get_arg($i)); + } + } + + return ob_get_clean(); +} diff --git a/inc/lib/Twig/Extension/Escaper.php b/inc/lib/Twig/Extension/Escaper.php index 43ae1113..c9a7f68e 100644 --- a/inc/lib/Twig/Extension/Escaper.php +++ b/inc/lib/Twig/Extension/Escaper.php @@ -10,11 +10,11 @@ */ class Twig_Extension_Escaper extends Twig_Extension { - protected $autoescape; + protected $defaultStrategy; - public function __construct($autoescape = true) + public function __construct($defaultStrategy = 'html') { - $this->autoescape = $autoescape; + $this->setDefaultStrategy($defaultStrategy); } /** @@ -45,13 +45,44 @@ class Twig_Extension_Escaper extends Twig_Extension public function getFilters() { return array( - 'raw' => new Twig_Filter_Function('twig_raw_filter', array('is_safe' => array('all'))), + new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))), ); } - public function isGlobal() + /** + * Sets the default strategy to use when not defined by the user. + * + * The strategy can be a valid PHP callback that takes the template + * "filename" as an argument and returns the strategy to use. + * + * @param mixed $defaultStrategy An escaping strategy + */ + public function setDefaultStrategy($defaultStrategy) + { + // for BC + if (true === $defaultStrategy) { + $defaultStrategy = 'html'; + } + + $this->defaultStrategy = $defaultStrategy; + } + + /** + * Gets the default strategy to use when not defined by the user. + * + * @param string $filename The template "filename" + * + * @return string The default strategy to use for the template + */ + public function getDefaultStrategy($filename) { - return $this->autoescape; + // disable string callables to avoid calling a function named html or js, + // or any other upcoming escaping strategy + if (!is_string($this->defaultStrategy) && is_callable($this->defaultStrategy)) { + return call_user_func($this->defaultStrategy, $filename); + } + + return $this->defaultStrategy; } /** @@ -74,4 +105,3 @@ function twig_raw_filter($string) { return $string; } - diff --git a/inc/lib/Twig/Extension/Staging.php b/inc/lib/Twig/Extension/Staging.php new file mode 100644 index 00000000..8ab0f459 --- /dev/null +++ b/inc/lib/Twig/Extension/Staging.php @@ -0,0 +1,113 @@ + + */ +class Twig_Extension_Staging extends Twig_Extension +{ + protected $functions = array(); + protected $filters = array(); + protected $visitors = array(); + protected $tokenParsers = array(); + protected $globals = array(); + protected $tests = array(); + + public function addFunction($name, $function) + { + $this->functions[$name] = $function; + } + + /** + * {@inheritdoc} + */ + public function getFunctions() + { + return $this->functions; + } + + public function addFilter($name, $filter) + { + $this->filters[$name] = $filter; + } + + /** + * {@inheritdoc} + */ + public function getFilters() + { + return $this->filters; + } + + public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) + { + $this->visitors[] = $visitor; + } + + /** + * {@inheritdoc} + */ + public function getNodeVisitors() + { + return $this->visitors; + } + + public function addTokenParser(Twig_TokenParserInterface $parser) + { + $this->tokenParsers[] = $parser; + } + + /** + * {@inheritdoc} + */ + public function getTokenParsers() + { + return $this->tokenParsers; + } + + public function addGlobal($name, $value) + { + $this->globals[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function getGlobals() + { + return $this->globals; + } + + public function addTest($name, $test) + { + $this->tests[$name] = $test; + } + + /** + * {@inheritdoc} + */ + public function getTests() + { + return $this->tests; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'staging'; + } +} diff --git a/inc/lib/Twig/Extension/StringLoader.php b/inc/lib/Twig/Extension/StringLoader.php new file mode 100644 index 00000000..20f3f994 --- /dev/null +++ b/inc/lib/Twig/Extension/StringLoader.php @@ -0,0 +1,64 @@ + true)), + ); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'string_loader'; + } +} + +/** + * Loads a template from a string. + * + *
+ * {{ include(template_from_string("Hello {{ name }}")) }}
+ * 
+ * + * @param Twig_Environment $env A Twig_Environment instance + * @param string $template A template as a string + * + * @return Twig_Template A Twig_Template instance + */ +function twig_template_from_string(Twig_Environment $env, $template) +{ + static $loader; + + if (null === $loader) { + $loader = new Twig_Loader_String(); + } + + $current = $env->getLoader(); + $env->setLoader($loader); + try { + $template = $env->loadTemplate($template); + } catch (Exception $e) { + $env->setLoader($current); + + throw $e; + } + $env->setLoader($current); + + return $template; +} diff --git a/inc/lib/Twig/ExtensionInterface.php b/inc/lib/Twig/ExtensionInterface.php index f8b232a5..f189e9d9 100644 --- a/inc/lib/Twig/ExtensionInterface.php +++ b/inc/lib/Twig/ExtensionInterface.php @@ -12,8 +12,7 @@ /** * Interface implemented by extension classes. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_ExtensionInterface { @@ -24,61 +23,61 @@ interface Twig_ExtensionInterface * * @param Twig_Environment $environment The current Twig_Environment instance */ - function initRuntime(Twig_Environment $environment); + public function initRuntime(Twig_Environment $environment); /** * Returns the token parser instances to add to the existing list. * * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances */ - function getTokenParsers(); + public function getTokenParsers(); /** * Returns the node visitor instances to add to the existing list. * * @return array An array of Twig_NodeVisitorInterface instances */ - function getNodeVisitors(); + public function getNodeVisitors(); /** * Returns a list of filters to add to the existing list. * * @return array An array of filters */ - function getFilters(); + public function getFilters(); /** * Returns a list of tests to add to the existing list. * * @return array An array of tests */ - function getTests(); + public function getTests(); /** * Returns a list of functions to add to the existing list. * * @return array An array of functions */ - function getFunctions(); + public function getFunctions(); /** * Returns a list of operators to add to the existing list. * * @return array An array of operators */ - function getOperators(); + public function getOperators(); /** - * Returns a list of global functions to add to the existing list. + * Returns a list of global variables to add to the existing list. * - * @return array An array of global functions + * @return array An array of global variables */ - function getGlobals(); + public function getGlobals(); /** * Returns the name of the extension. * * @return string The extension name */ - function getName(); + public function getName(); } diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 58a98c40..8c8d9456 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -23,7 +23,6 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension 'count' => new Twig_Filter_Function('count'), 'ago' => new Twig_Filter_Function('ago'), 'until' => new Twig_Filter_Function('until'), - 'split' => new Twig_Filter_Function('twig_split_filter'), 'push' => new Twig_Filter_Function('twig_push_filter'), 'bidi_cleanup' => new Twig_Filter_Function('bidi_cleanup'), 'addslashes' => new Twig_Filter_Function('addslashes') @@ -61,10 +60,6 @@ function twig_timezone_function() { return 'Z'; } -function twig_split_filter($str, $delim) { - return explode($delim, $str); -} - function twig_push_filter($array, $value) { array_push($array, $value); return $array; diff --git a/inc/lib/Twig/Filter.php b/inc/lib/Twig/Filter.php index 9595a1a8..5cfbb662 100644 --- a/inc/lib/Twig/Filter.php +++ b/inc/lib/Twig/Filter.php @@ -12,12 +12,15 @@ /** * Represents a template filter. * - * @package twig - * @author Fabien Potencier + * Use Twig_SimpleFilter instead. + * + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ -abstract class Twig_Filter implements Twig_FilterInterface +abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface { protected $options; + protected $arguments = array(); public function __construct(array $options = array()) { @@ -25,9 +28,21 @@ abstract class Twig_Filter implements Twig_FilterInterface 'needs_environment' => false, 'needs_context' => false, 'pre_escape' => null, + 'preserves_safety' => null, + 'callable' => null, ), $options); } + public function setArguments($arguments) + { + $this->arguments = $arguments; + } + + public function getArguments() + { + return $this->arguments; + } + public function needsEnvironment() { return $this->options['needs_environment']; @@ -47,12 +62,20 @@ abstract class Twig_Filter implements Twig_FilterInterface if (isset($this->options['is_safe_callback'])) { return call_user_func($this->options['is_safe_callback'], $filterArgs); } + } - return array(); + public function getPreservesSafety() + { + return $this->options['preserves_safety']; } public function getPreEscape() { return $this->options['pre_escape']; } + + public function getCallable() + { + return $this->options['callable']; + } } diff --git a/inc/lib/Twig/Filter/Function.php b/inc/lib/Twig/Filter/Function.php index 1de078b2..ad374a55 100644 --- a/inc/lib/Twig/Filter/Function.php +++ b/inc/lib/Twig/Filter/Function.php @@ -12,8 +12,10 @@ /** * Represents a function template filter. * - * @package twig - * @author Fabien Potencier + * Use Twig_SimpleFilter instead. + * + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Filter_Function extends Twig_Filter { @@ -21,6 +23,8 @@ class Twig_Filter_Function extends Twig_Filter public function __construct($function, array $options = array()) { + $options['callable'] = $function; + parent::__construct($options); $this->function = $function; diff --git a/inc/lib/Twig/Filter/Method.php b/inc/lib/Twig/Filter/Method.php index d831e0f2..63c8c3be 100644 --- a/inc/lib/Twig/Filter/Method.php +++ b/inc/lib/Twig/Filter/Method.php @@ -12,15 +12,20 @@ /** * Represents a method template filter. * - * @package twig - * @author Fabien Potencier + * Use Twig_SimpleFilter instead. + * + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Filter_Method extends Twig_Filter { - protected $extension, $method; + protected $extension; + protected $method; public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) { + $options['callable'] = array($extension, $method); + parent::__construct($options); $this->extension = $extension; diff --git a/inc/lib/Twig/Filter/Node.php b/inc/lib/Twig/Filter/Node.php new file mode 100644 index 00000000..8744c5e0 --- /dev/null +++ b/inc/lib/Twig/Filter/Node.php @@ -0,0 +1,39 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +class Twig_Filter_Node extends Twig_Filter +{ + protected $class; + + public function __construct($class, array $options = array()) + { + parent::__construct($options); + + $this->class = $class; + } + + public function getClass() + { + return $this->class; + } + + public function compile() + { + } +} diff --git a/inc/lib/Twig/FilterCallableInterface.php b/inc/lib/Twig/FilterCallableInterface.php new file mode 100644 index 00000000..145534df --- /dev/null +++ b/inc/lib/Twig/FilterCallableInterface.php @@ -0,0 +1,23 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +interface Twig_FilterCallableInterface +{ + public function getCallable(); +} diff --git a/inc/lib/Twig/FilterInterface.php b/inc/lib/Twig/FilterInterface.php index 4ac19ceb..5319ecc9 100644 --- a/inc/lib/Twig/FilterInterface.php +++ b/inc/lib/Twig/FilterInterface.php @@ -12,8 +12,10 @@ /** * Represents a template filter. * - * @package twig - * @author Fabien Potencier + * Use Twig_SimpleFilter instead. + * + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FilterInterface { @@ -22,13 +24,19 @@ interface Twig_FilterInterface * * @return string The PHP code for the filter */ - function compile(); + public function compile(); + + public function needsEnvironment(); + + public function needsContext(); + + public function getSafe(Twig_Node $filterArgs); - function needsEnvironment(); + public function getPreservesSafety(); - function needsContext(); + public function getPreEscape(); - function getSafe(Twig_Node $filterArgs); + public function setArguments($arguments); - function getPreEscape(); + public function getArguments(); } diff --git a/inc/lib/Twig/Function.php b/inc/lib/Twig/Function.php index 1197924a..b5ffb2b0 100644 --- a/inc/lib/Twig/Function.php +++ b/inc/lib/Twig/Function.php @@ -12,21 +12,35 @@ /** * Represents a template function. * - * @package twig - * @author Fabien Potencier + * Use Twig_SimpleFunction instead. + * + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ -abstract class Twig_Function implements Twig_FunctionInterface +abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface { protected $options; + protected $arguments = array(); public function __construct(array $options = array()) { $this->options = array_merge(array( 'needs_environment' => false, 'needs_context' => false, + 'callable' => null, ), $options); } + public function setArguments($arguments) + { + $this->arguments = $arguments; + } + + public function getArguments() + { + return $this->arguments; + } + public function needsEnvironment() { return $this->options['needs_environment']; @@ -49,4 +63,9 @@ abstract class Twig_Function implements Twig_FunctionInterface return array(); } + + public function getCallable() + { + return $this->options['callable']; + } } diff --git a/inc/lib/Twig/Function/Function.php b/inc/lib/Twig/Function/Function.php index 3237d8c5..d1e1b96a 100644 --- a/inc/lib/Twig/Function/Function.php +++ b/inc/lib/Twig/Function/Function.php @@ -13,8 +13,10 @@ /** * Represents a function template function. * - * @package twig - * @author Arnaud Le Blanc + * Use Twig_SimpleFunction instead. + * + * @author Arnaud Le Blanc + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Function_Function extends Twig_Function { @@ -22,6 +24,8 @@ class Twig_Function_Function extends Twig_Function public function __construct($function, array $options = array()) { + $options['callable'] = $function; + parent::__construct($options); $this->function = $function; diff --git a/inc/lib/Twig/Function/Method.php b/inc/lib/Twig/Function/Method.php index 7328566e..67039a95 100644 --- a/inc/lib/Twig/Function/Method.php +++ b/inc/lib/Twig/Function/Method.php @@ -13,15 +13,20 @@ /** * Represents a method template function. * - * @package twig - * @author Arnaud Le Blanc + * Use Twig_SimpleFunction instead. + * + * @author Arnaud Le Blanc + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Function_Method extends Twig_Function { - protected $extension, $method; + protected $extension; + protected $method; public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) { + $options['callable'] = array($extension, $method); + parent::__construct($options); $this->extension = $extension; diff --git a/inc/lib/Twig/Function/Node.php b/inc/lib/Twig/Function/Node.php new file mode 100644 index 00000000..06a0d0db --- /dev/null +++ b/inc/lib/Twig/Function/Node.php @@ -0,0 +1,39 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +class Twig_Function_Node extends Twig_Function +{ + protected $class; + + public function __construct($class, array $options = array()) + { + parent::__construct($options); + + $this->class = $class; + } + + public function getClass() + { + return $this->class; + } + + public function compile() + { + } +} diff --git a/inc/lib/Twig/FunctionCallableInterface.php b/inc/lib/Twig/FunctionCallableInterface.php new file mode 100644 index 00000000..0aab4f5e --- /dev/null +++ b/inc/lib/Twig/FunctionCallableInterface.php @@ -0,0 +1,23 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +interface Twig_FunctionCallableInterface +{ + public function getCallable(); +} diff --git a/inc/lib/Twig/FunctionInterface.php b/inc/lib/Twig/FunctionInterface.php index ccc9fd93..67f4f89c 100644 --- a/inc/lib/Twig/FunctionInterface.php +++ b/inc/lib/Twig/FunctionInterface.php @@ -13,8 +13,10 @@ /** * Represents a template function. * - * @package twig - * @author Arnaud Le Blanc + * Use Twig_SimpleFunction instead. + * + * @author Arnaud Le Blanc + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FunctionInterface { @@ -23,11 +25,15 @@ interface Twig_FunctionInterface * * @return string The PHP code for the function */ - function compile(); + public function compile(); + + public function needsEnvironment(); + + public function needsContext(); - function needsEnvironment(); + public function getSafe(Twig_Node $filterArgs); - function needsContext(); + public function setArguments($arguments); - function getSafe(Twig_Node $filterArgs); + public function getArguments(); } diff --git a/inc/lib/Twig/Lexer.php b/inc/lib/Twig/Lexer.php index 868a814e..000b038e 100644 --- a/inc/lib/Twig/Lexer.php +++ b/inc/lib/Twig/Lexer.php @@ -13,8 +13,7 @@ /** * Lexes a template string. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Lexer implements Twig_LexerInterface { @@ -24,21 +23,28 @@ class Twig_Lexer implements Twig_LexerInterface protected $lineno; protected $end; protected $state; + protected $states; protected $brackets; - protected $env; protected $filename; protected $options; - protected $operatorRegex; - - const STATE_DATA = 0; - const STATE_BLOCK = 1; - const STATE_VAR = 2; - - const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; - const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; - const REGEX_STRING = '/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; - const PUNCTUATION = '()[]{}?:.,|'; + protected $regexes; + protected $position; + protected $positions; + protected $currentVarBlockLine; + + const STATE_DATA = 0; + const STATE_BLOCK = 1; + const STATE_VAR = 2; + const STATE_STRING = 3; + const STATE_INTERPOLATION = 4; + + const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; + const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; + const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; + const REGEX_DQ_STRING_DELIM = '/"/A'; + const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; + const PUNCTUATION = '()[]{}?:.,|'; public function __construct(Twig_Environment $env, array $options = array()) { @@ -49,14 +55,28 @@ class Twig_Lexer implements Twig_LexerInterface 'tag_block' => array('{%', '%}'), 'tag_variable' => array('{{', '}}'), 'whitespace_trim' => '-', + 'interpolation' => array('#{', '}'), ), $options); + + $this->regexes = array( + 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A', + 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A', + 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s', + 'operator' => $this->getOperatorRegex(), + 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s', + 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As', + 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', + 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s', + 'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A', + 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A', + ); } /** * Tokenizes a source code. * - * @param string $code The source code - * @param string $filename A unique identifier for the source code + * @param string $code The source code + * @param string $filename A unique identifier for the source code * * @return Twig_TokenStream A token stream instance */ @@ -74,7 +94,13 @@ class Twig_Lexer implements Twig_LexerInterface $this->end = strlen($this->code); $this->tokens = array(); $this->state = self::STATE_DATA; + $this->states = array(); $this->brackets = array(); + $this->position = -1; + + // find all token starts in one go + preg_match_all($this->regexes['lex_tokens_start'], $this->code, $matches, PREG_OFFSET_CAPTURE); + $this->positions = $matches; while ($this->cursor < $this->end) { // dispatch to the lexing functions depending @@ -91,6 +117,14 @@ class Twig_Lexer implements Twig_LexerInterface case self::STATE_VAR: $this->lexVar(); break; + + case self::STATE_STRING: + $this->lexString(); + break; + + case self::STATE_INTERPOLATION: + $this->lexInterpolation(); + break; } } @@ -110,77 +144,66 @@ class Twig_Lexer implements Twig_LexerInterface protected function lexData() { - $pos = $this->end; - $append = ''; - - // Find the first token after the cursor - foreach (array('tag_comment', 'tag_variable', 'tag_block') as $type) { - $tmpPos = strpos($this->code, $this->options[$type][0], $this->cursor); - if (false !== $tmpPos && $tmpPos < $pos) { - $trimBlock = false; - $append = ''; - $pos = $tmpPos; - $token = $this->options[$type][0]; - if (strpos($this->code, $this->options['whitespace_trim'], $pos) === ($pos + strlen($token))) { - $trimBlock = true; - $append = $this->options['whitespace_trim']; - } - } - } - // if no matches are left we return the rest of the template as simple text token - if ($pos === $this->end) { + if ($this->position == count($this->positions[0]) - 1) { $this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor)); $this->cursor = $this->end; + return; } + // Find the first token after the current cursor + $position = $this->positions[0][++$this->position]; + while ($position[1] < $this->cursor) { + if ($this->position == count($this->positions[0]) - 1) { + return; + } + $position = $this->positions[0][++$this->position]; + } + // push the template text first - $text = $textContent = substr($this->code, $this->cursor, $pos - $this->cursor); - if (true === $trimBlock) { + $text = $textContent = substr($this->code, $this->cursor, $position[1] - $this->cursor); + if (isset($this->positions[2][$this->position][0])) { $text = rtrim($text); } $this->pushToken(Twig_Token::TEXT_TYPE, $text); - $this->moveCursor($textContent.$token.$append); + $this->moveCursor($textContent.$position[0]); - switch ($token) { + switch ($this->positions[1][$this->position][0]) { case $this->options['tag_comment'][0]: $this->lexComment(); break; case $this->options['tag_block'][0]: // raw data? - if (preg_match('/\s*raw\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', $this->code, $match, null, $this->cursor)) { + if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) { $this->moveCursor($match[0]); - $this->lexRawData(); - $this->state = self::STATE_DATA; + $this->lexRawData($match[1]); // {% line \d+ %} - } else if (preg_match('/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', $this->code, $match, null, $this->cursor)) { + } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) { $this->moveCursor($match[0]); $this->lineno = (int) $match[1]; - $this->state = self::STATE_DATA; } else { $this->pushToken(Twig_Token::BLOCK_START_TYPE); - $this->state = self::STATE_BLOCK; + $this->pushState(self::STATE_BLOCK); + $this->currentVarBlockLine = $this->lineno; } break; case $this->options['tag_variable'][0]: $this->pushToken(Twig_Token::VAR_START_TYPE); - $this->state = self::STATE_VAR; + $this->pushState(self::STATE_VAR); + $this->currentVarBlockLine = $this->lineno; break; } } protected function lexBlock() { - $trimTag = preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/'); - $endTag = preg_quote($this->options['tag_block'][1], '/'); - - if (empty($this->brackets) && preg_match('/\s*(?:'.$trimTag.'\s*|\s*'.$endTag.')\n?/A', $this->code, $match, null, $this->cursor)) { + if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) { $this->pushToken(Twig_Token::BLOCK_END_TYPE); $this->moveCursor($match[0]); - $this->state = self::STATE_DATA; + $this->popState(); } else { $this->lexExpression(); } @@ -188,13 +211,10 @@ class Twig_Lexer implements Twig_LexerInterface protected function lexVar() { - $trimTag = preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/'); - $endTag = preg_quote($this->options['tag_variable'][1], '/'); - - if (empty($this->brackets) && preg_match('/\s*'.$trimTag.'\s*|\s*'.$endTag.'/A', $this->code, $match, null, $this->cursor)) { + if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) { $this->pushToken(Twig_Token::VAR_END_TYPE); $this->moveCursor($match[0]); - $this->state = self::STATE_DATA; + $this->popState(); } else { $this->lexExpression(); } @@ -207,12 +227,12 @@ class Twig_Lexer implements Twig_LexerInterface $this->moveCursor($match[0]); if ($this->cursor >= $this->end) { - throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable')); + throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->filename); } } // operators - if (preg_match($this->getOperatorRegex(), $this->code, $match, null, $this->cursor)) { + if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) { $this->pushToken(Twig_Token::OPERATOR_TYPE, $match[0]); $this->moveCursor($match[0]); } @@ -223,7 +243,11 @@ class Twig_Lexer implements Twig_LexerInterface } // numbers elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::NUMBER_TYPE, ctype_digit($match[0]) ? (int) $match[0] : (float) $match[0]); + $number = (float) $match[0]; // floats + if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) { + $number = (int) $match[0]; // integers lower than the maximum + } + $this->pushToken(Twig_Token::NUMBER_TYPE, $number); $this->moveCursor($match[0]); } // punctuation @@ -252,35 +276,80 @@ class Twig_Lexer implements Twig_LexerInterface $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1))); $this->moveCursor($match[0]); } + // opening double quoted string + elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) { + $this->brackets[] = array('"', $this->lineno); + $this->pushState(self::STATE_STRING); + $this->moveCursor($match[0]); + } // unlexable else { throw new Twig_Error_Syntax(sprintf('Unexpected character "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename); } } - protected function lexRawData() + protected function lexRawData($tag) { - if (!preg_match('/'.preg_quote($this->options['tag_block'][0], '/').'\s*endraw\s*'.preg_quote($this->options['tag_block'][1], '/').'/s', $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { - throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "block"')); + if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { + throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename); } + $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor); - $this->pushToken(Twig_Token::TEXT_TYPE, $text); $this->moveCursor($text.$match[0][0]); + + if (false !== strpos($match[1][0], $this->options['whitespace_trim'])) { + $text = rtrim($text); + } + + $this->pushToken(Twig_Token::TEXT_TYPE, $text); } protected function lexComment() { - $commentEndRegex = '/(?:'.preg_quote($this->options['whitespace_trim'], '/') - .preg_quote($this->options['tag_comment'][1], '/').'\s*|' - .preg_quote($this->options['tag_comment'][1], '/').')\n?/s'; - - if (!preg_match($commentEndRegex, $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { + if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { throw new Twig_Error_Syntax('Unclosed comment', $this->lineno, $this->filename); } $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]); } + protected function lexString() + { + if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) { + $this->brackets[] = array($this->options['interpolation'][0], $this->lineno); + $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE); + $this->moveCursor($match[0]); + $this->pushState(self::STATE_INTERPOLATION); + + } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) { + $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0])); + $this->moveCursor($match[0]); + + } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) { + + list($expect, $lineno) = array_pop($this->brackets); + if ($this->code[$this->cursor] != '"') { + throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename); + } + + $this->popState(); + ++$this->cursor; + } + } + + protected function lexInterpolation() + { + $bracket = end($this->brackets); + if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) { + array_pop($this->brackets); + $this->pushToken(Twig_Token::INTERPOLATION_END_TYPE); + $this->moveCursor($match[0]); + $this->popState(); + } else { + $this->lexExpression(); + } + } + protected function pushToken($type, $value = '') { // do not push empty text tokens @@ -299,10 +368,6 @@ class Twig_Lexer implements Twig_LexerInterface protected function getOperatorRegex() { - if (null !== $this->operatorRegex) { - return $this->operatorRegex; - } - $operators = array_merge( array('='), array_keys($this->env->getUnaryOperators()), @@ -317,12 +382,27 @@ class Twig_Lexer implements Twig_LexerInterface // an operator that ends with a character must be followed by // a whitespace or a parenthesis if (ctype_alpha($operator[$length - 1])) { - $regex[] = preg_quote($operator, '/').'(?=[ ()])'; + $regex[] = preg_quote($operator, '/').'(?=[\s()])'; } else { $regex[] = preg_quote($operator, '/'); } } - return $this->operatorRegex = '/'.implode('|', $regex).'/A'; + return '/'.implode('|', $regex).'/A'; + } + + protected function pushState($state) + { + $this->states[] = $this->state; + $this->state = $state; + } + + protected function popState() + { + if (0 === count($this->states)) { + throw new Exception('Cannot pop state without a previous state'); + } + + $this->state = array_pop($this->states); } } diff --git a/inc/lib/Twig/LexerInterface.php b/inc/lib/Twig/LexerInterface.php index 02233849..4b83f81b 100644 --- a/inc/lib/Twig/LexerInterface.php +++ b/inc/lib/Twig/LexerInterface.php @@ -12,18 +12,18 @@ /** * Interface implemented by lexer classes. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_LexerInterface { /** * Tokenizes a source code. * - * @param string $code The source code - * @param string $filename A unique identifier for the source code + * @param string $code The source code + * @param string $filename A unique identifier for the source code * * @return Twig_TokenStream A token stream instance */ - function tokenize($code, $filename = null); + public function tokenize($code, $filename = null); } diff --git a/inc/lib/Twig/Loader/Array.php b/inc/lib/Twig/Loader/Array.php index e8dc1605..89087aea 100644 --- a/inc/lib/Twig/Loader/Array.php +++ b/inc/lib/Twig/Loader/Array.php @@ -17,10 +17,9 @@ * source code of the template). If you don't want to see your cache grows out of * control, you need to take care of clearing the old cache file by yourself. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Loader_Array implements Twig_LoaderInterface +class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $templates; @@ -47,18 +46,15 @@ class Twig_Loader_Array implements Twig_LoaderInterface */ public function setTemplate($name, $template) { - $this->templates[$name] = $template; + $this->templates[(string) $name] = $template; } /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { + $name = (string) $name; if (!isset($this->templates[$name])) { throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); } @@ -67,14 +63,19 @@ class Twig_Loader_Array implements Twig_LoaderInterface } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + return isset($this->templates[(string) $name]); + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { + $name = (string) $name; if (!isset($this->templates[$name])) { throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); } @@ -83,13 +84,15 @@ class Twig_Loader_Array implements Twig_LoaderInterface } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { + $name = (string) $name; + if (!isset($this->templates[$name])) { + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + } + return true; } } diff --git a/inc/lib/Twig/Loader/Chain.php b/inc/lib/Twig/Loader/Chain.php index 48dd8b84..1f1cf065 100644 --- a/inc/lib/Twig/Loader/Chain.php +++ b/inc/lib/Twig/Loader/Chain.php @@ -12,11 +12,11 @@ /** * Loads templates from other loaders. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Loader_Chain implements Twig_LoaderInterface +class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { + private $hasSourceCache = array(); protected $loaders; /** @@ -40,61 +40,100 @@ class Twig_Loader_Chain implements Twig_LoaderInterface public function addLoader(Twig_LoaderInterface $loader) { $this->loaders[] = $loader; + $this->hasSourceCache = array(); } /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->getSource($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = $e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(', ', $exceptions))); } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + $name = (string) $name; + + if (isset($this->hasSourceCache[$name])) { + return $this->hasSourceCache[$name]; + } + + foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface) { + if ($loader->exists($name)) { + return $this->hasSourceCache[$name] = true; + } + + continue; + } + + try { + $loader->getSource($name); + + return $this->hasSourceCache[$name] = true; + } catch (Twig_Error_Loader $e) { + } + } + + return $this->hasSourceCache[$name] = false; + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->getCacheKey($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { + $exceptions = array(); foreach ($this->loaders as $loader) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { + continue; + } + try { return $loader->isFresh($name, $time); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } } diff --git a/inc/lib/Twig/Loader/Filesystem.php b/inc/lib/Twig/Loader/Filesystem.php index be348aa3..f9211cbd 100644 --- a/inc/lib/Twig/Loader/Filesystem.php +++ b/inc/lib/Twig/Loader/Filesystem.php @@ -12,10 +12,9 @@ /** * Loads template from the filesystem. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Loader_Filesystem implements Twig_LoaderInterface +class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $paths; protected $cache; @@ -25,44 +24,64 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * * @param string|array $paths A path or an array of paths where to look for templates */ - public function __construct($paths) + public function __construct($paths = array()) { - $this->setPaths($paths); + if ($paths) { + $this->setPaths($paths); + } } /** * Returns the paths to the templates. * + * @param string $namespace A path namespace + * * @return array The array of paths where to look for templates */ - public function getPaths() + public function getPaths($namespace = '__main__') + { + return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array(); + } + + /** + * Returns the path namespaces. + * + * The "__main__" namespace is always defined. + * + * @return array The array of defined namespaces + */ + public function getNamespaces() { - return $this->paths; + return array_keys($this->paths); } /** * Sets the paths where templates are stored. * - * @param string|array $paths A path or an array of paths where to look for templates + * @param string|array $paths A path or an array of paths where to look for templates + * @param string $namespace A path namespace */ - public function setPaths($paths) + public function setPaths($paths, $namespace = '__main__') { if (!is_array($paths)) { $paths = array($paths); } - $this->paths = array(); + $this->paths[$namespace] = array(); foreach ($paths as $path) { - $this->addPath($path); + $this->addPath($path, $namespace); } } /** * Adds a path where templates are stored. * - * @param string $path A path where to look for templates + * @param string $path A path where to look for templates + * @param string $namespace A path name + * + * @throws Twig_Error_Loader */ - public function addPath($path) + public function addPath($path, $namespace = '__main__') { // invalidate the cache $this->cache = array(); @@ -71,15 +90,37 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); } - $this->paths[] = $path; + $this->paths[$namespace][] = rtrim($path, '/\\'); } /** - * Gets the source code of a template, given its name. + * Prepends a path where templates are stored. * - * @param string $name The name of the template to load + * @param string $path A path where to look for templates + * @param string $namespace A path name * - * @return string The template source code + * @throws Twig_Error_Loader + */ + public function prependPath($path, $namespace = '__main__') + { + // invalidate the cache + $this->cache = array(); + + if (!is_dir($path)) { + throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); + } + + $path = rtrim($path, '/\\'); + + if (!isset($this->paths[$namespace])) { + $this->paths[$namespace][] = $path; + } else { + array_unshift($this->paths[$namespace], $path); + } + } + + /** + * {@inheritdoc} */ public function getSource($name) { @@ -87,11 +128,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} */ public function getCacheKey($name) { @@ -99,18 +136,36 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} + */ + public function exists($name) + { + $name = (string) $name; + if (isset($this->cache[$name])) { + return true; + } + + try { + $this->findTemplate($name); + + return true; + } catch (Twig_Error_Loader $exception) { + return false; + } + } + + /** + * {@inheritdoc} */ public function isFresh($name, $time) { - return filemtime($this->findTemplate($name)) < $time; + return filemtime($this->findTemplate($name)) <= $time; } protected function findTemplate($name) { + $name = (string) $name; + // normalize name $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); @@ -120,13 +175,28 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface $this->validateName($name); - foreach ($this->paths as $path) { + $namespace = '__main__'; + if (isset($name[0]) && '@' == $name[0]) { + if (false === $pos = strpos($name, '/')) { + throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name)); + } + + $namespace = substr($name, 1, $pos - 1); + + $name = substr($name, $pos + 1); + } + + if (!isset($this->paths[$namespace])) { + throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); + } + + foreach ($this->paths[$namespace] as $path) { if (is_file($path.'/'.$name)) { return $this->cache[$name] = $path.'/'.$name; } } - throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths))); + throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]))); } protected function validateName($name) @@ -135,6 +205,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface throw new Twig_Error_Loader('A template name cannot contain NUL bytes.'); } + $name = ltrim($name, '/'); $parts = explode('/', $name); $level = 0; foreach ($parts as $part) { diff --git a/inc/lib/Twig/Loader/String.php b/inc/lib/Twig/Loader/String.php index 26eb0096..8ad9856c 100644 --- a/inc/lib/Twig/Loader/String.php +++ b/inc/lib/Twig/Loader/String.php @@ -12,22 +12,21 @@ /** * Loads a template from a string. * + * This loader should only be used for unit testing as it has many limitations + * (for instance, the include or extends tag does not make any sense for a string + * loader). + * * When using this loader with a cache mechanism, you should know that a new cache * key is generated each time a template content "changes" (the cache key being the * source code of the template). If you don't want to see your cache grows out of * control, you need to take care of clearing the old cache file by yourself. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Loader_String implements Twig_LoaderInterface +class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { /** - * Gets the source code of a template, given its name. - * - * @param string $name The name of the template to load - * - * @return string The template source code + * {@inheritdoc} */ public function getSource($name) { @@ -35,11 +34,15 @@ class Twig_Loader_String implements Twig_LoaderInterface } /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name The name of the template to load - * - * @return string The cache key + * {@inheritdoc} + */ + public function exists($name) + { + return true; + } + + /** + * {@inheritdoc} */ public function getCacheKey($name) { @@ -47,10 +50,7 @@ class Twig_Loader_String implements Twig_LoaderInterface } /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param timestamp $time The last modification time of the cached template + * {@inheritdoc} */ public function isFresh($name, $time) { diff --git a/inc/lib/Twig/LoaderInterface.php b/inc/lib/Twig/LoaderInterface.php index f0bd3a5b..927786d1 100644 --- a/inc/lib/Twig/LoaderInterface.php +++ b/inc/lib/Twig/LoaderInterface.php @@ -12,34 +12,41 @@ /** * Interface all loaders must implement. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_LoaderInterface { /** * Gets the source code of a template, given its name. * - * @param string $name The name of the template to load + * @param string $name The name of the template to load * * @return string The template source code + * + * @throws Twig_Error_Loader When $name is not found */ - function getSource($name); + public function getSource($name); /** * Gets the cache key to use for the cache for a given template name. * - * @param string $name The name of the template to load + * @param string $name The name of the template to load * * @return string The cache key + * + * @throws Twig_Error_Loader When $name is not found */ - function getCacheKey($name); + public function getCacheKey($name); /** * Returns true if the template is still fresh. * * @param string $name The template name * @param timestamp $time The last modification time of the cached template + * + * @return Boolean true if the template is fresh, false otherwise + * + * @throws Twig_Error_Loader When $name is not found */ - function isFresh($name, $time); + public function isFresh($name, $time); } diff --git a/inc/lib/Twig/Markup.php b/inc/lib/Twig/Markup.php index c1a1469c..69871fcb 100644 --- a/inc/lib/Twig/Markup.php +++ b/inc/lib/Twig/Markup.php @@ -12,20 +12,26 @@ /** * Marks a content as safe. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Markup +class Twig_Markup implements Countable { protected $content; + protected $charset; - public function __construct($content) + public function __construct($content, $charset) { $this->content = (string) $content; + $this->charset = $charset; } public function __toString() { return $this->content; } + + public function count() + { + return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content); + } } diff --git a/inc/lib/Twig/Node.php b/inc/lib/Twig/Node.php index 22e65d45..931b4635 100644 --- a/inc/lib/Twig/Node.php +++ b/inc/lib/Twig/Node.php @@ -13,10 +13,9 @@ /** * Represents a node in the AST. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ -class Twig_Node implements Twig_NodeInterface, Countable, IteratorAggregate +class Twig_Node implements Twig_NodeInterface { protected $nodes; protected $attributes; @@ -134,12 +133,12 @@ class Twig_Node implements Twig_NodeInterface, Countable, IteratorAggregate * * @param string The attribute name * - * @return mixed The attribute value + * @return mixed The attribute value */ public function getAttribute($name) { if (!array_key_exists($name, $this->attributes)) { - throw new Twig_Error_Runtime(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this))); + throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this))); } return $this->attributes[$name]; @@ -188,7 +187,7 @@ class Twig_Node implements Twig_NodeInterface, Countable, IteratorAggregate public function getNode($name) { if (!array_key_exists($name, $this->nodes)) { - throw new Twig_Error_Runtime(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this))); + throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this))); } return $this->nodes[$name]; diff --git a/inc/lib/Twig/Node/AutoEscape.php b/inc/lib/Twig/Node/AutoEscape.php index a0c2ee6d..8f190e0b 100644 --- a/inc/lib/Twig/Node/AutoEscape.php +++ b/inc/lib/Twig/Node/AutoEscape.php @@ -18,8 +18,7 @@ * * If autoescaping is disabled, then the value is false. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_AutoEscape extends Twig_Node { diff --git a/inc/lib/Twig/Node/Block.php b/inc/lib/Twig/Node/Block.php index 5548ad06..50eb67ed 100644 --- a/inc/lib/Twig/Node/Block.php +++ b/inc/lib/Twig/Node/Block.php @@ -13,8 +13,7 @@ /** * Represents a block node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Block extends Twig_Node { diff --git a/inc/lib/Twig/Node/BlockReference.php b/inc/lib/Twig/Node/BlockReference.php index 53f6287c..013e369e 100644 --- a/inc/lib/Twig/Node/BlockReference.php +++ b/inc/lib/Twig/Node/BlockReference.php @@ -13,8 +13,7 @@ /** * Represents a block call node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface { diff --git a/inc/lib/Twig/Node/Body.php b/inc/lib/Twig/Node/Body.php new file mode 100644 index 00000000..3ffb1342 --- /dev/null +++ b/inc/lib/Twig/Node/Body.php @@ -0,0 +1,19 @@ + + */ +class Twig_Node_Body extends Twig_Node +{ +} diff --git a/inc/lib/Twig/Node/Do.php b/inc/lib/Twig/Node/Do.php new file mode 100644 index 00000000..c528066b --- /dev/null +++ b/inc/lib/Twig/Node/Do.php @@ -0,0 +1,38 @@ + + */ +class Twig_Node_Do extends Twig_Node +{ + public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) + { + parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->addDebugInfo($this) + ->write('') + ->subcompile($this->getNode('expr')) + ->raw(";\n") + ; + } +} diff --git a/inc/lib/Twig/Node/Embed.php b/inc/lib/Twig/Node/Embed.php new file mode 100644 index 00000000..4c9456dc --- /dev/null +++ b/inc/lib/Twig/Node/Embed.php @@ -0,0 +1,38 @@ + + */ +class Twig_Node_Embed extends Twig_Node_Include +{ + // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module) + public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) + { + parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag); + + $this->setAttribute('filename', $filename); + $this->setAttribute('index', $index); + } + + protected function addGetTemplate(Twig_Compiler $compiler) + { + $compiler + ->write("\$this->env->loadTemplate(") + ->string($this->getAttribute('filename')) + ->raw(', ') + ->string($this->getAttribute('index')) + ->raw(")") + ; + } +} diff --git a/inc/lib/Twig/Node/Expression.php b/inc/lib/Twig/Node/Expression.php index 13b170e5..a7382e7d 100644 --- a/inc/lib/Twig/Node/Expression.php +++ b/inc/lib/Twig/Node/Expression.php @@ -13,8 +13,7 @@ /** * Abstract class for all nodes that represents an expression. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ abstract class Twig_Node_Expression extends Twig_Node { diff --git a/inc/lib/Twig/Node/Expression/Array.php b/inc/lib/Twig/Node/Expression/Array.php index 2d860823..1da785fe 100644 --- a/inc/lib/Twig/Node/Expression/Array.php +++ b/inc/lib/Twig/Node/Expression/Array.php @@ -10,9 +10,54 @@ */ class Twig_Node_Expression_Array extends Twig_Node_Expression { + protected $index; + public function __construct(array $elements, $lineno) { parent::__construct($elements, array(), $lineno); + + $this->index = -1; + foreach ($this->getKeyValuePairs() as $pair) { + if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { + $this->index = $pair['key']->getAttribute('value'); + } + } + } + + public function getKeyValuePairs() + { + $pairs = array(); + + foreach (array_chunk($this->nodes, 2) as $pair) { + $pairs[] = array( + 'key' => $pair[0], + 'value' => $pair[1], + ); + } + + return $pairs; + } + + public function hasElement(Twig_Node_Expression $key) + { + foreach ($this->getKeyValuePairs() as $pair) { + // we compare the string representation of the keys + // to avoid comparing the line numbers which are not relevant here. + if ((string) $key == (string) $pair['key']) { + return true; + } + } + + return false; + } + + public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) + { + if (null === $key) { + $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine()); + } + + array_push($this->nodes, $key, $value); } /** @@ -24,16 +69,16 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression { $compiler->raw('array('); $first = true; - foreach ($this->nodes as $name => $node) { + foreach ($this->getKeyValuePairs() as $pair) { if (!$first) { $compiler->raw(', '); } $first = false; $compiler - ->repr($name) + ->subcompile($pair['key']) ->raw(' => ') - ->subcompile($node) + ->subcompile($pair['value']) ; } $compiler->raw(')'); diff --git a/inc/lib/Twig/Node/Expression/AssignName.php b/inc/lib/Twig/Node/Expression/AssignName.php index 67f12509..2ddea78c 100644 --- a/inc/lib/Twig/Node/Expression/AssignName.php +++ b/inc/lib/Twig/Node/Expression/AssignName.php @@ -19,6 +19,10 @@ class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name */ public function compile(Twig_Compiler $compiler) { - $compiler->raw(sprintf('$context[\'%s\']', $this->getAttribute('name'))); + $compiler + ->raw('$context[') + ->string($this->getAttribute('name')) + ->raw(']') + ; } } diff --git a/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php b/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php index e86b1ea0..7fbd0556 100644 --- a/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php +++ b/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php @@ -17,9 +17,9 @@ class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary */ public function compile(Twig_Compiler $compiler) { - $compiler->raw('floor('); + $compiler->raw('intval(floor('); parent::compile($compiler); - $compiler->raw(')'); + $compiler->raw('))'); } public function operator(Twig_Compiler $compiler) diff --git a/inc/lib/Twig/Node/Expression/BlockReference.php b/inc/lib/Twig/Node/Expression/BlockReference.php index 174d9097..647196eb 100644 --- a/inc/lib/Twig/Node/Expression/BlockReference.php +++ b/inc/lib/Twig/Node/Expression/BlockReference.php @@ -13,8 +13,7 @@ /** * Represents a block call node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression { diff --git a/inc/lib/Twig/Node/Expression/Call.php b/inc/lib/Twig/Node/Expression/Call.php new file mode 100644 index 00000000..87b62deb --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Call.php @@ -0,0 +1,178 @@ +getAttribute('callable'); + + $closingParenthesis = false; + if ($callable) { + if (is_string($callable)) { + $compiler->raw($callable); + } elseif (is_array($callable) && $callable[0] instanceof Twig_ExtensionInterface) { + $compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', $callable[0]->getName(), $callable[1])); + } else { + $type = ucfirst($this->getAttribute('type')); + $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name'))); + $closingParenthesis = true; + } + } else { + $compiler->raw($this->getAttribute('thing')->compile()); + } + + $this->compileArguments($compiler); + + if ($closingParenthesis) { + $compiler->raw(')'); + } + } + + protected function compileArguments(Twig_Compiler $compiler) + { + $compiler->raw('('); + + $first = true; + + if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { + $compiler->raw('$this->env'); + $first = false; + } + + if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { + if (!$first) { + $compiler->raw(', '); + } + $compiler->raw('$context'); + $first = false; + } + + if ($this->hasAttribute('arguments')) { + foreach ($this->getAttribute('arguments') as $argument) { + if (!$first) { + $compiler->raw(', '); + } + $compiler->string($argument); + $first = false; + } + } + + if ($this->hasNode('node')) { + if (!$first) { + $compiler->raw(', '); + } + $compiler->subcompile($this->getNode('node')); + $first = false; + } + + if ($this->hasNode('arguments') && null !== $this->getNode('arguments')) { + $callable = $this->hasAttribute('callable') ? $this->getAttribute('callable') : null; + + $arguments = $this->getArguments($callable, $this->getNode('arguments')); + + foreach ($arguments as $node) { + if (!$first) { + $compiler->raw(', '); + } + $compiler->subcompile($node); + $first = false; + } + } + + $compiler->raw(')'); + } + + protected function getArguments($callable, $arguments) + { + $parameters = array(); + $named = false; + foreach ($arguments as $name => $node) { + if (!is_int($name)) { + $named = true; + $name = $this->normalizeName($name); + } elseif ($named) { + throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name'))); + } + + $parameters[$name] = $node; + } + + if (!$named) { + return $parameters; + } + + if (!$callable) { + throw new LogicException(sprintf('Named arguments are not supported for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name'))); + } + + // manage named arguments + if (is_array($callable)) { + $r = new ReflectionMethod($callable[0], $callable[1]); + } elseif (is_object($callable) && !$callable instanceof Closure) { + $r = new ReflectionObject($callable); + $r = $r->getMethod('__invoke'); + } else { + $r = new ReflectionFunction($callable); + } + + $definition = $r->getParameters(); + if ($this->hasNode('node')) { + array_shift($definition); + } + if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { + array_shift($definition); + } + if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { + array_shift($definition); + } + if ($this->hasAttribute('arguments') && null !== $this->getAttribute('arguments')) { + foreach ($this->getAttribute('arguments') as $argument) { + array_shift($definition); + } + } + + $arguments = array(); + $pos = 0; + foreach ($definition as $param) { + $name = $this->normalizeName($param->name); + + if (array_key_exists($name, $parameters)) { + if (array_key_exists($pos, $parameters)) { + throw new Twig_Error_Syntax(sprintf('Arguments "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); + } + + $arguments[] = $parameters[$name]; + unset($parameters[$name]); + } elseif (array_key_exists($pos, $parameters)) { + $arguments[] = $parameters[$pos]; + unset($parameters[$pos]); + ++$pos; + } elseif ($param->isDefaultValueAvailable()) { + $arguments[] = new Twig_Node_Expression_Constant($param->getDefaultValue(), -1); + } elseif ($param->isOptional()) { + break; + } else { + throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); + } + } + + foreach (array_keys($parameters) as $name) { + throw new Twig_Error_Syntax(sprintf('Unknown argument "%s" for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); + } + + return $arguments; + } + + protected function normalizeName($name) + { + return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name)); + } +} diff --git a/inc/lib/Twig/Node/Expression/ExtensionReference.php b/inc/lib/Twig/Node/Expression/ExtensionReference.php index cb4efad0..00ac6701 100644 --- a/inc/lib/Twig/Node/Expression/ExtensionReference.php +++ b/inc/lib/Twig/Node/Expression/ExtensionReference.php @@ -12,8 +12,7 @@ /** * Represents an extension call node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression { diff --git a/inc/lib/Twig/Node/Expression/Filter.php b/inc/lib/Twig/Node/Expression/Filter.php index 101e6df0..207b062a 100644 --- a/inc/lib/Twig/Node/Expression/Filter.php +++ b/inc/lib/Twig/Node/Expression/Filter.php @@ -9,7 +9,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -class Twig_Node_Expression_Filter extends Twig_Node_Expression +class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call { public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) { @@ -19,54 +19,18 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression public function compile(Twig_Compiler $compiler) { $name = $this->getNode('filter')->getAttribute('value'); - if (false === $filter = $compiler->getEnvironment()->getFilter($name)) { - throw new Twig_Error_Syntax(sprintf('The filter "%s" does not exist', $name), $this->getLine()); + $filter = $compiler->getEnvironment()->getFilter($name); + + $this->setAttribute('name', $name); + $this->setAttribute('type', 'filter'); + $this->setAttribute('thing', $filter); + $this->setAttribute('needs_environment', $filter->needsEnvironment()); + $this->setAttribute('needs_context', $filter->needsContext()); + $this->setAttribute('arguments', $filter->getArguments()); + if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { + $this->setAttribute('callable', $filter->getCallable()); } - $node = $this->getNode('node'); - - // The default filter is intercepted when the filtered value - // is a name (like obj) or an attribute (like obj.attr) - // In such a case, it's compiled to {{ obj is defined ? obj|default('bar') : 'bar' }} - if ('default' === $name && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { - $compiler - ->raw('((') - ->subcompile(new Twig_Node_Expression_Test($node, 'defined', new Twig_Node(), $this->getLine())) - ->raw(') ? (') - ; - - $this->compileFilter($compiler, $filter); - - $compiler->raw(') : ('); - - if ($this->getNode('arguments')->hasNode(0)) { - $compiler->subcompile($this->getNode('arguments')->getNode(0)); - } else { - $compiler->string(''); - } - - $compiler->raw('))'); - } else { - $this->compileFilter($compiler, $filter); - } - } - - protected function compileFilter(Twig_Compiler $compiler, Twig_FilterInterface $filter) - { - $compiler - ->raw($filter->compile().'(') - ->raw($filter->needsEnvironment() ? '$this->env, ' : '') - ->raw($filter->needsContext() ? '$context, ' : '') - ->subcompile($this->getNode('node')) - ; - - foreach ($this->getNode('arguments') as $node) { - $compiler - ->raw(', ') - ->subcompile($node) - ; - } - - $compiler->raw(')'); + $this->compileCallable($compiler); } } diff --git a/inc/lib/Twig/Node/Expression/Filter/Default.php b/inc/lib/Twig/Node/Expression/Filter/Default.php new file mode 100644 index 00000000..1827c888 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Filter/Default.php @@ -0,0 +1,43 @@ + + * {{ var.foo|default('foo item on var is not defined') }} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter +{ + public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) + { + $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine()); + + if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { + $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine()); + $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine()); + + $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine()); + } else { + $node = $default; + } + + parent::__construct($node, $filterName, $arguments, $lineno, $tag); + } + + public function compile(Twig_Compiler $compiler) + { + $compiler->subcompile($this->getNode('node')); + } +} diff --git a/inc/lib/Twig/Node/Expression/Function.php b/inc/lib/Twig/Node/Expression/Function.php index 3f457199..3e1f6b55 100644 --- a/inc/lib/Twig/Node/Expression/Function.php +++ b/inc/lib/Twig/Node/Expression/Function.php @@ -8,7 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -class Twig_Node_Expression_Function extends Twig_Node_Expression +class Twig_Node_Expression_Function extends Twig_Node_Expression_Call { public function __construct($name, Twig_NodeInterface $arguments, $lineno) { @@ -17,33 +17,19 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression public function compile(Twig_Compiler $compiler) { - $function = $compiler->getEnvironment()->getFunction($this->getAttribute('name')); - if (false === $function) { - throw new Twig_Error_Syntax(sprintf('The function "%s" does not exist', $this->getAttribute('name')), $this->getLine()); - } - - $compiler - ->raw($function->compile().'(') - ->raw($function->needsEnvironment() ? '$this->env' : '') - ; - - if ($function->needsContext()) { - $compiler->raw($function->needsEnvironment() ? ', $context' : '$context'); - } + $name = $this->getAttribute('name'); + $function = $compiler->getEnvironment()->getFunction($name); - $first = true; - foreach ($this->getNode('arguments') as $node) { - if (!$first) { - $compiler->raw(', '); - } else { - if ($function->needsEnvironment() || $function->needsContext()) { - $compiler->raw(', '); - } - $first = false; - } - $compiler->subcompile($node); + $this->setAttribute('name', $name); + $this->setAttribute('type', 'function'); + $this->setAttribute('thing', $function); + $this->setAttribute('needs_environment', $function->needsEnvironment()); + $this->setAttribute('needs_context', $function->needsContext()); + $this->setAttribute('arguments', $function->getArguments()); + if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { + $this->setAttribute('callable', $function->getCallable()); } - $compiler->raw(')'); + $this->compileCallable($compiler); } } diff --git a/inc/lib/Twig/Node/Expression/GetAttr.php b/inc/lib/Twig/Node/Expression/GetAttr.php index eb9e6050..81a9b137 100644 --- a/inc/lib/Twig/Node/Expression/GetAttr.php +++ b/inc/lib/Twig/Node/Expression/GetAttr.php @@ -11,43 +11,43 @@ */ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression { - public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_NodeInterface $arguments, $type, $lineno) + public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno) { - parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type), $lineno); + parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); } public function compile(Twig_Compiler $compiler) { - $compiler->raw('$this->getAttribute('); - - if ($this->hasAttribute('is_defined_test') && $compiler->getEnvironment()->isStrictVariables()) { - $compiler->subcompile(new Twig_Node_Expression_Filter( - $this->getNode('node'), - new Twig_Node_Expression_Constant('default', $this->getLine()), - new Twig_Node(), - $this->getLine() - )); + if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { + $compiler->raw('twig_template_get_attributes($this, '); } else { - $compiler->subcompile($this->getNode('node')); + $compiler->raw('$this->getAttribute('); } - $compiler - ->raw(', ') - ->subcompile($this->getNode('attribute')) - ->raw(', array(') - ; - - foreach ($this->getNode('arguments') as $node) { - $compiler - ->subcompile($node) - ->raw(', ') - ; + if ($this->getAttribute('ignore_strict_check')) { + $this->getNode('node')->setAttribute('ignore_strict_check', true); } - $compiler - ->raw('), ') - ->repr($this->getAttribute('type')) - ->raw($this->hasAttribute('is_defined_test') ? ', true' : ', false') - ->raw(')'); + $compiler->subcompile($this->getNode('node')); + + $compiler->raw(', ')->subcompile($this->getNode('attribute')); + + if (count($this->getNode('arguments')) || Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { + $compiler->raw(', ')->subcompile($this->getNode('arguments')); + + if (Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { + $compiler->raw(', ')->repr($this->getAttribute('type')); + } + + if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { + $compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false')); + } + + if ($this->getAttribute('ignore_strict_check')) { + $compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false')); + } + } + + $compiler->raw(')'); } } diff --git a/inc/lib/Twig/Node/Expression/MethodCall.php b/inc/lib/Twig/Node/Expression/MethodCall.php new file mode 100644 index 00000000..620b02bf --- /dev/null +++ b/inc/lib/Twig/Node/Expression/MethodCall.php @@ -0,0 +1,41 @@ + $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); + + if ($node instanceof Twig_Node_Expression_Name) { + $node->setAttribute('always_defined', true); + } + } + + public function compile(Twig_Compiler $compiler) + { + $compiler + ->subcompile($this->getNode('node')) + ->raw('->') + ->raw($this->getAttribute('method')) + ->raw('(') + ; + $first = true; + foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { + if (!$first) { + $compiler->raw(', '); + } + $first = false; + + $compiler->subcompile($pair['value']); + } + $compiler->raw(')'); + } +} diff --git a/inc/lib/Twig/Node/Expression/Name.php b/inc/lib/Twig/Node/Expression/Name.php index fceda2b7..3b8fae01 100644 --- a/inc/lib/Twig/Node/Expression/Name.php +++ b/inc/lib/Twig/Node/Expression/Name.php @@ -11,31 +11,78 @@ */ class Twig_Node_Expression_Name extends Twig_Node_Expression { + protected $specialVars = array( + '_self' => '$this', + '_context' => '$context', + '_charset' => '$this->env->getCharset()', + ); + public function __construct($name, $lineno) { - parent::__construct(array(), array('name' => $name), $lineno); + parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno); } public function compile(Twig_Compiler $compiler) { - static $specialVars = array( - '_self' => '$this', - '_context' => '$context', - '_charset' => '$this->env->getCharset()', - ); - $name = $this->getAttribute('name'); - if ($this->hasAttribute('is_defined_test')) { - if (isset($specialVars[$name])) { + if ($this->getAttribute('is_defined_test')) { + if ($this->isSpecial()) { $compiler->repr(true); } else { $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); } - } elseif (isset($specialVars[$name])) { - $compiler->raw($specialVars[$name]); + } elseif ($this->isSpecial()) { + $compiler->raw($this->specialVars[$name]); + } elseif ($this->getAttribute('always_defined')) { + $compiler + ->raw('$context[') + ->string($name) + ->raw(']') + ; } else { - $compiler->raw(sprintf('$this->getContext($context, \'%s\')', $name)); + // remove the non-PHP 5.4 version when PHP 5.3 support is dropped + // as the non-optimized version is just a workaround for slow ternary operator + // when the context has a lot of variables + if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + // PHP 5.4 ternary operator performance was optimized + $compiler + ->raw('(isset($context[') + ->string($name) + ->raw(']) ? $context[') + ->string($name) + ->raw('] : ') + ; + + if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) { + $compiler->raw('null)'); + } else { + $compiler->raw('$this->getContext($context, ')->string($name)->raw('))'); + } + } else { + $compiler + ->raw('$this->getContext($context, ') + ->string($name) + ; + + if ($this->getAttribute('ignore_strict_check')) { + $compiler->raw(', true'); + } + + $compiler + ->raw(')') + ; + } } } + + public function isSpecial() + { + return isset($this->specialVars[$this->getAttribute('name')]); + } + + public function isSimple() + { + return !$this->isSpecial() && !$this->getAttribute('is_defined_test'); + } } diff --git a/inc/lib/Twig/Node/Expression/Parent.php b/inc/lib/Twig/Node/Expression/Parent.php index 5689fe45..dcf618c0 100644 --- a/inc/lib/Twig/Node/Expression/Parent.php +++ b/inc/lib/Twig/Node/Expression/Parent.php @@ -13,14 +13,13 @@ /** * Represents a parent node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Expression_Parent extends Twig_Node_Expression { public function __construct($name, $lineno, $tag = null) { - parent::__construct(array(), array('name' => $name), $lineno, $tag); + parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); } /** @@ -30,10 +29,19 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression */ public function compile(Twig_Compiler $compiler) { - $compiler - ->raw("\$this->renderParentBlock(") - ->string($this->getAttribute('name')) - ->raw(", \$context, \$blocks)") - ; + if ($this->getAttribute('output')) { + $compiler + ->addDebugInfo($this) + ->write("\$this->displayParentBlock(") + ->string($this->getAttribute('name')) + ->raw(", \$context, \$blocks);\n") + ; + } else { + $compiler + ->raw("\$this->renderParentBlock(") + ->string($this->getAttribute('name')) + ->raw(", \$context, \$blocks)") + ; + } } } diff --git a/inc/lib/Twig/Node/Expression/TempName.php b/inc/lib/Twig/Node/Expression/TempName.php new file mode 100644 index 00000000..e6b058e8 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/TempName.php @@ -0,0 +1,26 @@ + $name), $lineno); + } + + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('$_') + ->raw($this->getAttribute('name')) + ->raw('_') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test.php b/inc/lib/Twig/Node/Expression/Test.php index ef35df6b..639f501a 100644 --- a/inc/lib/Twig/Node/Expression/Test.php +++ b/inc/lib/Twig/Node/Expression/Test.php @@ -8,7 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -class Twig_Node_Expression_Test extends Twig_Node_Expression +class Twig_Node_Expression_Test extends Twig_Node_Expression_Call { public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) { @@ -17,44 +17,16 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression public function compile(Twig_Compiler $compiler) { - $testMap = $compiler->getEnvironment()->getTests(); - if (!isset($testMap[$this->getAttribute('name')])) { - throw new Twig_Error_Syntax(sprintf('The test "%s" does not exist', $this->getAttribute('name')), $this->getLine()); - } - $name = $this->getAttribute('name'); - $node = $this->getNode('node'); - - // defined is a special case - if ('defined' === $name) { - if ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr) { - $node->setAttribute('is_defined_test', true); - $compiler->subcompile($node); - $node->removeAttribute('is_defined_test'); - } else { - throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); - } - return; - } - - $compiler - ->raw($testMap[$name]->compile().'(') - ->subcompile($node) - ; - - if (null !== $this->getNode('arguments')) { - $compiler->raw(', '); - - $max = count($this->getNode('arguments')) - 1; - foreach ($this->getNode('arguments') as $i => $arg) { - $compiler->subcompile($arg); + $test = $compiler->getEnvironment()->getTest($name); - if ($i != $max) { - $compiler->raw(', '); - } - } + $this->setAttribute('name', $name); + $this->setAttribute('type', 'test'); + $this->setAttribute('thing', $test); + if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { + $this->setAttribute('callable', $test->getCallable()); } - $compiler->raw(')'); + $this->compileCallable($compiler); } } diff --git a/inc/lib/Twig/Node/Expression/Test/Constant.php b/inc/lib/Twig/Node/Expression/Test/Constant.php new file mode 100644 index 00000000..de55f5f5 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Constant.php @@ -0,0 +1,46 @@ + + * {% if post.status is constant('Post::PUBLISHED') %} + * the status attribute is exactly the same as Post::PUBLISHED + * {% endif %} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(') + ->subcompile($this->getNode('node')) + ->raw(' === constant(') + ; + + if ($this->getNode('arguments')->hasNode(1)) { + $compiler + ->raw('get_class(') + ->subcompile($this->getNode('arguments')->getNode(1)) + ->raw(')."::".') + ; + } + + $compiler + ->subcompile($this->getNode('arguments')->getNode(0)) + ->raw('))') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Defined.php b/inc/lib/Twig/Node/Expression/Test/Defined.php new file mode 100644 index 00000000..247b2e23 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Defined.php @@ -0,0 +1,54 @@ + + * {# defined works with variable names and variable attributes #} + * {% if foo is defined %} + * {# ... #} + * {% endif %} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test +{ + public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) + { + parent::__construct($node, $name, $arguments, $lineno); + + if ($node instanceof Twig_Node_Expression_Name) { + $node->setAttribute('is_defined_test', true); + } elseif ($node instanceof Twig_Node_Expression_GetAttr) { + $node->setAttribute('is_defined_test', true); + + $this->changeIgnoreStrictCheck($node); + } else { + throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); + } + } + + protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) + { + $node->setAttribute('ignore_strict_check', true); + + if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { + $this->changeIgnoreStrictCheck($node->getNode('node')); + } + } + + public function compile(Twig_Compiler $compiler) + { + $compiler->subcompile($this->getNode('node')); + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Divisibleby.php b/inc/lib/Twig/Node/Expression/Test/Divisibleby.php new file mode 100644 index 00000000..0aceb530 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Divisibleby.php @@ -0,0 +1,33 @@ + + * {% if loop.index is divisibleby(3) %} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(0 == ') + ->subcompile($this->getNode('node')) + ->raw(' % ') + ->subcompile($this->getNode('arguments')->getNode(0)) + ->raw(')') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Even.php b/inc/lib/Twig/Node/Expression/Test/Even.php new file mode 100644 index 00000000..d7853e89 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Even.php @@ -0,0 +1,32 @@ + + * {{ var is even }} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(') + ->subcompile($this->getNode('node')) + ->raw(' % 2 == 0') + ->raw(')') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Null.php b/inc/lib/Twig/Node/Expression/Test/Null.php new file mode 100644 index 00000000..1c83825a --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Null.php @@ -0,0 +1,31 @@ + + * {{ var is none }} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(null === ') + ->subcompile($this->getNode('node')) + ->raw(')') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Odd.php b/inc/lib/Twig/Node/Expression/Test/Odd.php new file mode 100644 index 00000000..421c19e8 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Odd.php @@ -0,0 +1,32 @@ + + * {{ var is odd }} + * + * + * @author Fabien Potencier + */ +class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(') + ->subcompile($this->getNode('node')) + ->raw(' % 2 == 1') + ->raw(')') + ; + } +} diff --git a/inc/lib/Twig/Node/Expression/Test/Sameas.php b/inc/lib/Twig/Node/Expression/Test/Sameas.php new file mode 100644 index 00000000..b48905ee --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Test/Sameas.php @@ -0,0 +1,29 @@ + + */ +class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test +{ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->raw('(') + ->subcompile($this->getNode('node')) + ->raw(' === ') + ->subcompile($this->getNode('arguments')->getNode(0)) + ->raw(')') + ; + } +} diff --git a/inc/lib/Twig/Node/Flush.php b/inc/lib/Twig/Node/Flush.php new file mode 100644 index 00000000..0467ddce --- /dev/null +++ b/inc/lib/Twig/Node/Flush.php @@ -0,0 +1,36 @@ + + */ +class Twig_Node_Flush extends Twig_Node +{ + public function __construct($lineno, $tag) + { + parent::__construct(array(), array(), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler + ->addDebugInfo($this) + ->write("flush();\n") + ; + } +} diff --git a/inc/lib/Twig/Node/For.php b/inc/lib/Twig/Node/For.php index eb204e28..d1ff371d 100644 --- a/inc/lib/Twig/Node/For.php +++ b/inc/lib/Twig/Node/For.php @@ -13,14 +13,21 @@ /** * Represents a for node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_For extends Twig_Node { + protected $loop; + public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null) { - parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'ifexpr' => $ifexpr, 'body' => $body, 'else' => $else), array('with_loop' => true), $lineno, $tag); + $body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag))); + + if (null !== $ifexpr) { + $body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag); + } + + parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body, 'else' => $else), array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag); } /** @@ -53,7 +60,7 @@ class Twig_Node_For extends Twig_Node ->write(");\n") ; - if (null === $this->getNode('ifexpr')) { + if (!$this->getAttribute('ifexpr')) { $compiler ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n") ->indent() @@ -68,6 +75,10 @@ class Twig_Node_For extends Twig_Node } } + $this->loop->setAttribute('else', null !== $this->getNode('else')); + $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop')); + $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr')); + $compiler ->write("foreach (\$context['_seq'] as ") ->subcompile($this->getNode('key_target')) @@ -75,47 +86,7 @@ class Twig_Node_For extends Twig_Node ->subcompile($this->getNode('value_target')) ->raw(") {\n") ->indent() - ; - - if (null !== $this->getNode('ifexpr')) { - $compiler - ->write("if (!(") - ->subcompile($this->getNode('ifexpr')) - ->raw(")) {\n") - ->indent() - ->write("continue;\n") - ->outdent() - ->write("}\n\n") - ; - } - - $compiler->subcompile($this->getNode('body')); - - if (null !== $this->getNode('else')) { - $compiler->write("\$context['_iterated'] = true;\n"); - } - - if ($this->getAttribute('with_loop')) { - $compiler - ->write("++\$context['loop']['index0'];\n") - ->write("++\$context['loop']['index'];\n") - ->write("\$context['loop']['first'] = false;\n") - ; - - if (null === $this->getNode('ifexpr')) { - $compiler - ->write("if (isset(\$context['loop']['length'])) {\n") - ->indent() - ->write("--\$context['loop']['revindex0'];\n") - ->write("--\$context['loop']['revindex'];\n") - ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") - ->outdent() - ->write("}\n") - ; - } - } - - $compiler + ->subcompile($this->getNode('body')) ->outdent() ->write("}\n") ; @@ -136,6 +107,6 @@ class Twig_Node_For extends Twig_Node $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n"); // keep the values set in the inner context for variables defined in the outer context - $compiler->write("\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));\n"); + $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n"); } } diff --git a/inc/lib/Twig/Node/ForLoop.php b/inc/lib/Twig/Node/ForLoop.php new file mode 100644 index 00000000..b8841583 --- /dev/null +++ b/inc/lib/Twig/Node/ForLoop.php @@ -0,0 +1,55 @@ + + */ +class Twig_Node_ForLoop extends Twig_Node +{ + public function __construct($lineno, $tag = null) + { + parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + if ($this->getAttribute('else')) { + $compiler->write("\$context['_iterated'] = true;\n"); + } + + if ($this->getAttribute('with_loop')) { + $compiler + ->write("++\$context['loop']['index0'];\n") + ->write("++\$context['loop']['index'];\n") + ->write("\$context['loop']['first'] = false;\n") + ; + + if (!$this->getAttribute('ifexpr')) { + $compiler + ->write("if (isset(\$context['loop']['length'])) {\n") + ->indent() + ->write("--\$context['loop']['revindex0'];\n") + ->write("--\$context['loop']['revindex'];\n") + ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") + ->outdent() + ->write("}\n") + ; + } + } + } +} diff --git a/inc/lib/Twig/Node/If.php b/inc/lib/Twig/Node/If.php index aa12efbe..4296a8d6 100644 --- a/inc/lib/Twig/Node/If.php +++ b/inc/lib/Twig/Node/If.php @@ -13,8 +13,7 @@ /** * Represents an if node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_If extends Twig_Node { diff --git a/inc/lib/Twig/Node/Import.php b/inc/lib/Twig/Node/Import.php index a327411d..99efc091 100644 --- a/inc/lib/Twig/Node/Import.php +++ b/inc/lib/Twig/Node/Import.php @@ -12,8 +12,7 @@ /** * Represents an import node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Import extends Twig_Node { diff --git a/inc/lib/Twig/Node/Include.php b/inc/lib/Twig/Node/Include.php index 467749b5..ed4a3751 100644 --- a/inc/lib/Twig/Node/Include.php +++ b/inc/lib/Twig/Node/Include.php @@ -13,8 +13,7 @@ /** * Represents an include node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface { @@ -39,21 +38,46 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface ; } + $this->addGetTemplate($compiler); + + $compiler->raw('->display('); + + $this->addTemplateArguments($compiler); + + $compiler->raw(");\n"); + + if ($this->getAttribute('ignore_missing')) { + $compiler + ->outdent() + ->write("} catch (Twig_Error_Loader \$e) {\n") + ->indent() + ->write("// ignore missing template\n") + ->outdent() + ->write("}\n\n") + ; + } + } + + protected function addGetTemplate(Twig_Compiler $compiler) + { if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) { $compiler ->write("\$this->env->loadTemplate(") ->subcompile($this->getNode('expr')) - ->raw(")->display(") + ->raw(")") ; } else { $compiler ->write("\$template = \$this->env->resolveTemplate(") ->subcompile($this->getNode('expr')) ->raw(");\n") - ->write('$template->display(') + ->write('$template') ; } + } + protected function addTemplateArguments(Twig_Compiler $compiler) + { if (false === $this->getAttribute('only')) { if (null === $this->getNode('variables')) { $compiler->raw('$context'); @@ -71,18 +95,5 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface $compiler->subcompile($this->getNode('variables')); } } - - $compiler->raw(");\n"); - - if ($this->getAttribute('ignore_missing')) { - $compiler - ->outdent() - ->write("} catch (Twig_Error_Loader \$e) {\n") - ->indent() - ->write("// ignore missing template\n") - ->outdent() - ->write("}\n\n") - ; - } } } diff --git a/inc/lib/Twig/Node/Macro.php b/inc/lib/Twig/Node/Macro.php index 9f95570f..89910618 100644 --- a/inc/lib/Twig/Node/Macro.php +++ b/inc/lib/Twig/Node/Macro.php @@ -12,8 +12,7 @@ /** * Represents a macro node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Macro extends Twig_Node { @@ -29,43 +28,67 @@ class Twig_Node_Macro extends Twig_Node */ public function compile(Twig_Compiler $compiler) { - $arguments = array(); - foreach ($this->getNode('arguments') as $argument) { - $arguments[] = '$'.$argument->getAttribute('name').' = null'; + $compiler + ->addDebugInfo($this) + ->write(sprintf("public function get%s(", $this->getAttribute('name'))) + ; + + $count = count($this->getNode('arguments')); + $pos = 0; + foreach ($this->getNode('arguments') as $name => $default) { + $compiler + ->raw('$_'.$name.' = ') + ->subcompile($default) + ; + + if (++$pos < $count) { + $compiler->raw(', '); + } } $compiler - ->addDebugInfo($this) - ->write(sprintf("public function get%s(%s)\n", $this->getAttribute('name'), implode(', ', $arguments)), "{\n") - ->indent() - ->write("\$context = array_merge(\$this->env->getGlobals(), array(\n") + ->raw(")\n") + ->write("{\n") ->indent() ; - foreach ($this->getNode('arguments') as $argument) { + if (!count($this->getNode('arguments'))) { + $compiler->write("\$context = \$this->env->getGlobals();\n\n"); + } else { $compiler - ->write('') - ->string($argument->getAttribute('name')) - ->raw(' => $'.$argument->getAttribute('name')) - ->raw(",\n") + ->write("\$context = \$this->env->mergeGlobals(array(\n") + ->indent() + ; + + foreach ($this->getNode('arguments') as $name => $default) { + $compiler + ->write('') + ->string($name) + ->raw(' => $_'.$name) + ->raw(",\n") + ; + } + + $compiler + ->outdent() + ->write("));\n\n") ; } $compiler - ->outdent() - ->write("));\n\n") + ->write("\$blocks = array();\n\n") ->write("ob_start();\n") ->write("try {\n") ->indent() ->subcompile($this->getNode('body')) ->outdent() - ->write("} catch(Exception \$e) {\n") + ->write("} catch (Exception \$e) {\n") ->indent() ->write("ob_end_clean();\n\n") ->write("throw \$e;\n") ->outdent() ->write("}\n\n") - ->write("return ob_get_clean();\n") + ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n") ->outdent() ->write("}\n\n") ; diff --git a/inc/lib/Twig/Node/Module.php b/inc/lib/Twig/Node/Module.php index 9b8c55e3..585048b8 100644 --- a/inc/lib/Twig/Node/Module.php +++ b/inc/lib/Twig/Node/Module.php @@ -13,14 +13,19 @@ /** * Represents a module node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Module extends Twig_Node { - public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $filename) + public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $filename) { - parent::__construct(array('parent' => $parent, 'body' => $body, 'blocks' => $blocks, 'macros' => $macros, 'traits' => $traits), array('filename' => $filename), 1); + // embedded templates are set as attributes so that they are only visited once by the visitors + parent::__construct(array('parent' => $parent, 'body' => $body, 'blocks' => $blocks, 'macros' => $macros, 'traits' => $traits), array('filename' => $filename, 'index' => null, 'embedded_templates' => $embeddedTemplates), 1); + } + + public function setIndex($index) + { + $this->setAttribute('index', $index); } /** @@ -31,13 +36,21 @@ class Twig_Node_Module extends Twig_Node public function compile(Twig_Compiler $compiler) { $this->compileTemplate($compiler); + + foreach ($this->getAttribute('embedded_templates') as $template) { + $compiler->subcompile($template); + } } protected function compileTemplate(Twig_Compiler $compiler) { + if (!$this->getAttribute('index')) { + $compiler->write('compileClassHeader($compiler); - if (count($this->getNode('blocks')) || count($this->getNode('traits'))) { + if (count($this->getNode('blocks')) || count($this->getNode('traits')) || null === $this->getNode('parent') || $this->getNode('parent') instanceof Twig_Node_Expression_Constant) { $this->compileConstructor($compiler); } @@ -57,29 +70,31 @@ class Twig_Node_Module extends Twig_Node $this->compileIsTraitable($compiler); + $this->compileDebugInfo($compiler); + $this->compileClassFooter($compiler); } protected function compileGetParent(Twig_Compiler $compiler) { + if (null === $this->getNode('parent')) { + return; + } + $compiler ->write("protected function doGetParent(array \$context)\n", "{\n") ->indent() ->write("return ") ; - if (null === $this->getNode('parent')) { - $compiler->raw("false"); + if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) { + $compiler->subcompile($this->getNode('parent')); } else { - if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) { - $compiler->subcompile($this->getNode('parent')); - } else { - $compiler - ->raw("\$this->env->resolveTemplate(") - ->subcompile($this->getNode('parent')) - ->raw(")") - ; - } + $compiler + ->raw("\$this->env->resolveTemplate(") + ->subcompile($this->getNode('parent')) + ->raw(")") + ; } $compiler @@ -91,21 +106,25 @@ class Twig_Node_Module extends Twig_Node protected function compileDisplayBody(Twig_Compiler $compiler) { - $compiler->write("\$context = array_merge(\$this->env->getGlobals(), \$context);\n\n"); $compiler->subcompile($this->getNode('body')); if (null !== $this->getNode('parent')) { - $compiler->write("\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));\n"); + if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) { + $compiler->write("\$this->parent"); + } else { + $compiler->write("\$this->getParent(\$context)"); + } + $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n"); } } protected function compileClassHeader(Twig_Compiler $compiler) { $compiler - ->write("write("\n\n") // if the filename contains */, add a blank to avoid a PHP parse error ->write("/* ".str_replace('*/', '* /', $this->getAttribute('filename'))." */\n") - ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->getAttribute('filename'))) + ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->getAttribute('filename'), $this->getAttribute('index'))) ->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass())) ->write("{\n") ->indent() @@ -120,6 +139,17 @@ class Twig_Node_Module extends Twig_Node ->write("parent::__construct(\$env);\n\n") ; + // parent + if (null === $this->getNode('parent')) { + $compiler->write("\$this->parent = false;\n\n"); + } elseif ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) { + $compiler + ->write("\$this->parent = \$this->env->loadTemplate(") + ->subcompile($this->getNode('parent')) + ->raw(");\n\n") + ; + } + $countTraits = count($this->getNode('traits')); if ($countTraits) { // traits @@ -151,18 +181,32 @@ class Twig_Node_Module extends Twig_Node } } - $compiler - ->write("\$this->blocks = array_merge(\n") - ->indent() - ; + if ($countTraits > 1) { + $compiler + ->write("\$this->traits = array_merge(\n") + ->indent() + ; + + for ($i = 0; $i < $countTraits; $i++) { + $compiler + ->write(sprintf("\$_trait_%s_blocks".($i == $countTraits - 1 ? '' : ',')."\n", $i)) + ; + } - for ($i = 0; $i < $countTraits; $i++) { $compiler - ->write(sprintf("\$_trait_%s_blocks,\n", $i)) + ->outdent() + ->write(");\n\n") + ; + } else { + $compiler + ->write("\$this->traits = \$_trait_0_blocks;\n\n") ; } $compiler + ->write("\$this->blocks = array_merge(\n") + ->indent() + ->write("\$this->traits,\n") ->write("array(\n") ; } else { @@ -250,11 +294,21 @@ class Twig_Node_Module extends Twig_Node // only contains blocks and use statements. $traitable = null === $this->getNode('parent') && 0 === count($this->getNode('macros')); if ($traitable) { - if (!count($nodes = $this->getNode('body'))) { - $nodes = new Twig_Node(array($this->getNode('body'))); + if ($this->getNode('body') instanceof Twig_Node_Body) { + $nodes = $this->getNode('body')->getNode(0); + } else { + $nodes = $this->getNode('body'); + } + + if (!count($nodes)) { + $nodes = new Twig_Node(array($nodes)); } foreach ($nodes as $node) { + if (!count($node)) { + continue; + } + if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { continue; } @@ -268,16 +322,31 @@ class Twig_Node_Module extends Twig_Node } } + if ($traitable) { + return; + } + $compiler ->write("public function isTraitable()\n", "{\n") ->indent() ->write(sprintf("return %s;\n", $traitable ? 'true' : 'false')) ->outdent() + ->write("}\n\n") + ; + } + + protected function compileDebugInfo(Twig_Compiler $compiler) + { + $compiler + ->write("public function getDebugInfo()\n", "{\n") + ->indent() + ->write(sprintf("return %s;\n", str_replace("\n", '', var_export(array_reverse($compiler->getDebugInfo(), true), true)))) + ->outdent() ->write("}\n") ; } - public function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) + protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) { if ($node instanceof Twig_Node_Expression_Constant) { $compiler diff --git a/inc/lib/Twig/Node/Print.php b/inc/lib/Twig/Node/Print.php index 766725ff..b0c41d1d 100644 --- a/inc/lib/Twig/Node/Print.php +++ b/inc/lib/Twig/Node/Print.php @@ -13,8 +13,7 @@ /** * Represents a node that outputs an expression. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface { diff --git a/inc/lib/Twig/Node/Sandbox.php b/inc/lib/Twig/Node/Sandbox.php index cbfcb411..8cf3ed44 100644 --- a/inc/lib/Twig/Node/Sandbox.php +++ b/inc/lib/Twig/Node/Sandbox.php @@ -12,8 +12,7 @@ /** * Represents a sandbox node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Sandbox extends Twig_Node { diff --git a/inc/lib/Twig/Node/SandboxedModule.php b/inc/lib/Twig/Node/SandboxedModule.php index 36d9f198..be1f5daa 100644 --- a/inc/lib/Twig/Node/SandboxedModule.php +++ b/inc/lib/Twig/Node/SandboxedModule.php @@ -13,8 +13,7 @@ /** * Represents a module node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_SandboxedModule extends Twig_Node_Module { @@ -24,7 +23,9 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions) { - parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag()); + parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag()); + + $this->setAttribute('index', $node->getAttribute('index')); $this->usedFilters = $usedFilters; $this->usedTags = $usedTags; @@ -33,9 +34,7 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module protected function compileDisplayBody(Twig_Compiler $compiler) { - if (null === $this->getNode('parent')) { - $compiler->write("\$this->checkSecurity();\n"); - } + $compiler->write("\$this->checkSecurity();\n"); parent::compileDisplayBody($compiler); } @@ -45,7 +44,7 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module parent::compileDisplayFooter($compiler); $compiler - ->write("protected function checkSecurity() {\n") + ->write("protected function checkSecurity()\n", "{\n") ->indent() ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") ->indent() @@ -54,16 +53,6 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module ->write(!$this->usedFunctions ? "array()\n" : "array('".implode('\', \'', $this->usedFunctions)."')\n") ->outdent() ->write(");\n") - ; - - if (null !== $this->getNode('parent')) { - $compiler - ->raw("\n") - ->write("\$this->parent->checkSecurity();\n") - ; - } - - $compiler ->outdent() ->write("}\n\n") ; diff --git a/inc/lib/Twig/Node/SandboxedPrint.php b/inc/lib/Twig/Node/SandboxedPrint.php index 77730d8c..73dfaa96 100644 --- a/inc/lib/Twig/Node/SandboxedPrint.php +++ b/inc/lib/Twig/Node/SandboxedPrint.php @@ -17,8 +17,7 @@ * and if the sandbox is enabled, we need to check that the __toString() * method is allowed if 'article' is an object. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_SandboxedPrint extends Twig_Node_Print { diff --git a/inc/lib/Twig/Node/Set.php b/inc/lib/Twig/Node/Set.php index 9913664f..4c9c16ce 100644 --- a/inc/lib/Twig/Node/Set.php +++ b/inc/lib/Twig/Node/Set.php @@ -12,8 +12,7 @@ /** * Represents a set node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Set extends Twig_Node { @@ -67,7 +66,7 @@ class Twig_Node_Set extends Twig_Node $compiler->subcompile($this->getNode('names'), false); if ($this->getAttribute('capture')) { - $compiler->raw(" = new Twig_Markup(ob_get_clean())"); + $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())"); } } @@ -87,9 +86,9 @@ class Twig_Node_Set extends Twig_Node } else { if ($this->getAttribute('safe')) { $compiler - ->raw("new Twig_Markup(") + ->raw("('' === \$tmp = ") ->subcompile($this->getNode('values')) - ->raw(")") + ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())") ; } else { $compiler->subcompile($this->getNode('values')); diff --git a/inc/lib/Twig/Node/SetTemp.php b/inc/lib/Twig/Node/SetTemp.php new file mode 100644 index 00000000..3bdd1cb7 --- /dev/null +++ b/inc/lib/Twig/Node/SetTemp.php @@ -0,0 +1,35 @@ + $name), $lineno); + } + + public function compile(Twig_Compiler $compiler) + { + $name = $this->getAttribute('name'); + $compiler + ->addDebugInfo($this) + ->write('if (isset($context[') + ->string($name) + ->raw('])) { $_') + ->raw($name) + ->raw('_ = $context[') + ->repr($name) + ->raw(']; } else { $_') + ->raw($name) + ->raw("_ = null; }\n") + ; + } +} diff --git a/inc/lib/Twig/Node/Spaceless.php b/inc/lib/Twig/Node/Spaceless.php index 46013466..7555fa0f 100644 --- a/inc/lib/Twig/Node/Spaceless.php +++ b/inc/lib/Twig/Node/Spaceless.php @@ -14,8 +14,7 @@ * * It removes spaces between HTML tags. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Spaceless extends Twig_Node { diff --git a/inc/lib/Twig/Node/Text.php b/inc/lib/Twig/Node/Text.php index 0c1c0928..21bdcea1 100644 --- a/inc/lib/Twig/Node/Text.php +++ b/inc/lib/Twig/Node/Text.php @@ -13,8 +13,7 @@ /** * Represents a text node. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface { diff --git a/inc/lib/Twig/NodeInterface.php b/inc/lib/Twig/NodeInterface.php index 165aed4d..f0ef7258 100644 --- a/inc/lib/Twig/NodeInterface.php +++ b/inc/lib/Twig/NodeInterface.php @@ -12,19 +12,19 @@ /** * Represents a node in the AST. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ -interface Twig_NodeInterface +interface Twig_NodeInterface extends Countable, IteratorAggregate { /** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ - function compile(Twig_Compiler $compiler); + public function compile(Twig_Compiler $compiler); - function getLine(); + public function getLine(); - function getNodeTag(); + public function getNodeTag(); } diff --git a/inc/lib/Twig/NodeOutputInterface.php b/inc/lib/Twig/NodeOutputInterface.php index 71839569..22172c09 100644 --- a/inc/lib/Twig/NodeOutputInterface.php +++ b/inc/lib/Twig/NodeOutputInterface.php @@ -12,8 +12,7 @@ /** * Represents a displayable node in the AST. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_NodeOutputInterface { diff --git a/inc/lib/Twig/NodeTraverser.php b/inc/lib/Twig/NodeTraverser.php index 1e82b032..28cba1ad 100644 --- a/inc/lib/Twig/NodeTraverser.php +++ b/inc/lib/Twig/NodeTraverser.php @@ -14,8 +14,7 @@ * * It visits all nodes and their children and call the given visitor for each. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_NodeTraverser { diff --git a/inc/lib/Twig/NodeVisitor/Escaper.php b/inc/lib/Twig/NodeVisitor/Escaper.php index 049ce96a..cc4b3d71 100644 --- a/inc/lib/Twig/NodeVisitor/Escaper.php +++ b/inc/lib/Twig/NodeVisitor/Escaper.php @@ -12,18 +12,18 @@ /** * Twig_NodeVisitor_Escaper implements output escaping. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface { protected $statusStack = array(); protected $blocks = array(); - protected $safeAnalysis; protected $traverser; + protected $defaultStrategy = false; + protected $safeVars = array(); - function __construct() + public function __construct() { $this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis(); } @@ -34,14 +34,21 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface The modified node */ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) { - if ($node instanceof Twig_Node_AutoEscape) { + if ($node instanceof Twig_Node_Module) { + if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) { + $this->defaultStrategy = $defaultStrategy; + } + $this->safeVars = array(); + } elseif ($node instanceof Twig_Node_AutoEscape) { $this->statusStack[] = $node->getAttribute('value'); } elseif ($node instanceof Twig_Node_Block) { $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env); + } elseif ($node instanceof Twig_Node_Import) { + $this->safeVars[] = $node->getNode('var')->getAttribute('name'); } return $node; @@ -53,11 +60,14 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface The modified node */ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) { - if ($node instanceof Twig_Node_Expression_Filter) { + if ($node instanceof Twig_Node_Module) { + $this->defaultStrategy = false; + $this->safeVars = array(); + } elseif ($node instanceof Twig_Node_Expression_Filter) { return $this->preEscapeFilterNode($node, $env); } elseif ($node instanceof Twig_Node_Print) { return $this->escapePrintNode($node, $env, $this->needEscaping($env)); @@ -96,22 +106,18 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface { $name = $filter->getNode('filter')->getAttribute('value'); - if (false !== $f = $env->getFilter($name)) { - $type = $f->getPreEscape(); - if (null === $type) { - return $filter; - } - - $node = $filter->getNode('node'); - if ($this->isSafeFor($type, $node, $env)) { - return $filter; - } - - $filter->setNode('node', $this->getEscaperFilter($type, $node)); + $type = $env->getFilter($name)->getPreEscape(); + if (null === $type) { + return $filter; + } + $node = $filter->getNode('node'); + if ($this->isSafeFor($type, $node, $env)) { return $filter; } + $filter->setNode('node', $this->getEscaperFilter($type, $node)); + return $filter; } @@ -123,6 +129,9 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface if (null === $this->traverser) { $this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis)); } + + $this->safeAnalysis->setSafeVars($this->safeVars); + $this->traverser->traverse($expression); $safe = $this->safeAnalysis->getSafe($expression); } @@ -136,18 +145,15 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface return $this->statusStack[count($this->statusStack) - 1]; } - if ($env->hasExtension('escaper') && $env->getExtension('escaper')->isGlobal()) { - return 'html'; - } - - return false; + return $this->defaultStrategy ? $this->defaultStrategy : false; } protected function getEscaperFilter($type, Twig_NodeInterface $node) { $line = $node->getLine(); $name = new Twig_Node_Expression_Constant('escape', $line); - $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line))); + $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line))); + return new Twig_Node_Expression_Filter($node, $name, $args, $line); } diff --git a/inc/lib/Twig/NodeVisitor/Optimizer.php b/inc/lib/Twig/NodeVisitor/Optimizer.php index 3679746e..a254def7 100644 --- a/inc/lib/Twig/NodeVisitor/Optimizer.php +++ b/inc/lib/Twig/NodeVisitor/Optimizer.php @@ -17,8 +17,7 @@ * You can configure which optimizations you want to activate via the * optimizer mode. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface { @@ -26,9 +25,12 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface const OPTIMIZE_NONE = 0; const OPTIMIZE_FOR = 2; const OPTIMIZE_RAW_FILTER = 4; + const OPTIMIZE_VAR_ACCESS = 8; protected $loops = array(); protected $optimizers; + protected $prependedNodes = array(); + protected $inABody = false; /** * Constructor. @@ -53,6 +55,20 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface $this->enterOptimizeFor($node, $env); } + if (!version_compare(phpversion(), '5.4.0RC1', '>=') && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) { + if ($this->inABody) { + if (!$node instanceof Twig_Node_Expression) { + if (get_class($node) !== 'Twig_Node') { + array_unshift($this->prependedNodes, array()); + } + } else { + $node = $this->optimizeVariables($node, $env); + } + } elseif ($node instanceof Twig_Node_Body) { + $this->inABody = true; + } + } + return $node; } @@ -61,6 +77,8 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface */ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) { + $expression = $node instanceof Twig_Node_Expression; + if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) { $this->leaveOptimizeFor($node, $env); } @@ -69,20 +87,58 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface $node = $this->optimizeRawFilter($node, $env); } - $node = $this->optimizeRenderBlock($node, $env); + $node = $this->optimizePrintNode($node, $env); + + if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) { + if ($node instanceof Twig_Node_Body) { + $this->inABody = false; + } elseif ($this->inABody) { + if (!$expression && get_class($node) !== 'Twig_Node' && $prependedNodes = array_shift($this->prependedNodes)) { + $nodes = array(); + foreach (array_unique($prependedNodes) as $name) { + $nodes[] = new Twig_Node_SetTemp($name, $node->getLine()); + } + + $nodes[] = $node; + $node = new Twig_Node($nodes); + } + } + } + + return $node; + } + + protected function optimizeVariables($node, $env) + { + if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) { + $this->prependedNodes[0][] = $node->getAttribute('name'); + + return new Twig_Node_Expression_TempName($node->getAttribute('name'), $node->getLine()); + } return $node; } /** - * Replaces "echo $this->renderBlock()" with "$this->displayBlock()". + * Optimizes print nodes. + * + * It replaces: + * + * * "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()" * * @param Twig_NodeInterface $node A Node * @param Twig_Environment $env The current Twig environment */ - protected function optimizeRenderBlock($node, $env) + protected function optimizePrintNode($node, $env) { - if ($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_BlockReference) { + if (!$node instanceof Twig_Node_Print) { + return $node; + } + + if ( + $node->getNode('expr') instanceof Twig_Node_Expression_BlockReference || + $node->getNode('expr') instanceof Twig_Node_Expression_Parent + ) { $node->getNode('expr')->setAttribute('output', true); return $node->getNode('expr'); diff --git a/inc/lib/Twig/NodeVisitor/SafeAnalysis.php b/inc/lib/Twig/NodeVisitor/SafeAnalysis.php index 5961ba29..c4bbd812 100644 --- a/inc/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/inc/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -3,27 +3,33 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface { protected $data = array(); + protected $safeVars = array(); + + public function setSafeVars($safeVars) + { + $this->safeVars = $safeVars; + } public function getSafe(Twig_NodeInterface $node) { $hash = spl_object_hash($node); if (isset($this->data[$hash])) { - foreach($this->data[$hash] as $bucket) { + foreach ($this->data[$hash] as $bucket) { if ($bucket['key'] === $node) { return $bucket['value']; } } } - return null; } protected function setSafe(Twig_NodeInterface $node, array $safe) { $hash = spl_object_hash($node); if (isset($this->data[$hash])) { - foreach($this->data[$hash] as &$bucket) { + foreach ($this->data[$hash] as &$bucket) { if ($bucket['key'] === $node) { $bucket['value'] = $safe; + return; } } @@ -59,7 +65,11 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface $name = $node->getNode('filter')->getAttribute('value'); $args = $node->getNode('arguments'); if (false !== $filter = $env->getFilter($name)) { - $this->setSafe($node, $filter->getSafe($args)); + $safe = $filter->getSafe($args); + if (null === $safe) { + $safe = $this->intersectSafe($this->getSafe($node->getNode('node')), $filter->getPreservesSafety()); + } + $this->setSafe($node, $safe); } else { $this->setSafe($node, array()); } @@ -73,6 +83,20 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface } else { $this->setSafe($node, array()); } + } elseif ($node instanceof Twig_Node_Expression_MethodCall) { + if ($node->getAttribute('safe')) { + $this->setSafe($node, array('all')); + } else { + $this->setSafe($node, array()); + } + } elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) { + $name = $node->getNode('node')->getAttribute('name'); + // attributes on template instances are safe + if ('_self' == $name || in_array($name, $this->safeVars)) { + $this->setSafe($node, array('all')); + } else { + $this->setSafe($node, array()); + } } else { $this->setSafe($node, array()); } diff --git a/inc/lib/Twig/NodeVisitor/Sandbox.php b/inc/lib/Twig/NodeVisitor/Sandbox.php index 356b661f..fb27045b 100644 --- a/inc/lib/Twig/NodeVisitor/Sandbox.php +++ b/inc/lib/Twig/NodeVisitor/Sandbox.php @@ -12,8 +12,7 @@ /** * Twig_NodeVisitor_Sandbox implements sandboxing. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface { @@ -28,7 +27,7 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface The modified node */ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) { @@ -70,7 +69,7 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface The modified node */ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) { diff --git a/inc/lib/Twig/NodeVisitorInterface.php b/inc/lib/Twig/NodeVisitorInterface.php index d44e510c..f33c13fc 100644 --- a/inc/lib/Twig/NodeVisitorInterface.php +++ b/inc/lib/Twig/NodeVisitorInterface.php @@ -12,8 +12,7 @@ /** * Twig_NodeVisitorInterface is the interface the all node visitor classes must implement. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_NodeVisitorInterface { @@ -23,9 +22,9 @@ interface Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface The modified node */ - function enterNode(Twig_NodeInterface $node, Twig_Environment $env); + public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Called after child nodes are visited. @@ -33,9 +32,9 @@ interface Twig_NodeVisitorInterface * @param Twig_NodeInterface $node The node to visit * @param Twig_Environment $env The Twig environment instance * - * @param Twig_NodeInterface The modified node + * @return Twig_NodeInterface|false The modified node or false if the node must be removed */ - function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); + public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); /** * Returns the priority for this visitor. @@ -44,5 +43,5 @@ interface Twig_NodeVisitorInterface * * @return integer The priority level */ - function getPriority(); + public function getPriority(); } diff --git a/inc/lib/Twig/Parser.php b/inc/lib/Twig/Parser.php index 8c982887..958e46b3 100644 --- a/inc/lib/Twig/Parser.php +++ b/inc/lib/Twig/Parser.php @@ -13,11 +13,11 @@ /** * Default parser implementation. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Parser implements Twig_ParserInterface { + protected $stack = array(); protected $stream; protected $parent; protected $handlers; @@ -28,9 +28,9 @@ class Twig_Parser implements Twig_ParserInterface protected $macros; protected $env; protected $reservedMacroNames; - protected $importedFunctions; - protected $tmpVarCount; + protected $importedSymbols; protected $traits; + protected $embeddedTemplates = array(); /** * Constructor. @@ -42,28 +42,45 @@ class Twig_Parser implements Twig_ParserInterface $this->env = $env; } + public function getEnvironment() + { + return $this->env; + } + public function getVarName() { - return sprintf('__internal_%s_%d', substr($this->env->getTemplateClass($this->stream->getFilename()), strlen($this->env->getTemplateClassPrefix())), ++$this->tmpVarCount); + return sprintf('__internal_%s', hash('sha1', uniqid(mt_rand(), true), false)); + } + + public function getFilename() + { + return $this->stream->getFilename(); } /** * Converts a token stream to a node tree. * - * @param Twig_TokenStream $stream A token stream instance + * @param Twig_TokenStream $stream A token stream instance * * @return Twig_Node_Module A node tree */ - public function parse(Twig_TokenStream $stream) + public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false) { - $this->tmpVarCount = 0; + // push all variables into the stack to keep the current state of the parser + $vars = get_object_vars($this); + unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser']); + $this->stack[] = $vars; // tag handlers - $this->handlers = $this->env->getTokenParsers(); - $this->handlers->setParser($this); + if (null === $this->handlers) { + $this->handlers = $this->env->getTokenParsers(); + $this->handlers->setParser($this); + } // node visitors - $this->visitors = $this->env->getNodeVisitors(); + if (null === $this->visitors) { + $this->visitors = $this->env->getNodeVisitors(); + } if (null === $this->expressionParser) { $this->expressionParser = new Twig_ExpressionParser($this, $this->env->getUnaryOperators(), $this->env->getBinaryOperators()); @@ -75,10 +92,11 @@ class Twig_Parser implements Twig_ParserInterface $this->macros = array(); $this->traits = array(); $this->blockStack = array(); - $this->importedFunctions = array(array()); + $this->importedSymbols = array(array()); + $this->embeddedTemplates = array(); try { - $body = $this->subparse(null); + $body = $this->subparse($test, $dropNeedle); if (null !== $this->parent) { if (null === $body = $this->filterBodyNodes($body)) { @@ -86,18 +104,29 @@ class Twig_Parser implements Twig_ParserInterface } } } catch (Twig_Error_Syntax $e) { - if (null === $e->getTemplateFile()) { - $e->setTemplateFile($this->stream->getFilename()); + if (!$e->getTemplateFile()) { + $e->setTemplateFile($this->getFilename()); + } + + if (!$e->getTemplateLine()) { + $e->setTemplateLine($this->stream->getCurrent()->getLine()); } throw $e; } - $node = new Twig_Node_Module($body, $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->stream->getFilename()); + $node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $this->getFilename()); $traverser = new Twig_NodeTraverser($this->env, $this->visitors); - return $traverser->traverse($node); + $node = $traverser->traverse($node); + + // restore previous stack so previous parse() call can resume working + foreach (array_pop($this->stack) as $key => $val) { + $this->$key = $val; + } + + return $node; } public function subparse($test, $dropNeedle = false) @@ -123,7 +152,7 @@ class Twig_Parser implements Twig_ParserInterface $token = $this->getCurrentToken(); if ($token->getType() !== Twig_Token::NAME_TYPE) { - throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->stream->getFilename()); + throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->getFilename()); } if (null !== $test && call_user_func($test, $token)) { @@ -141,10 +170,20 @@ class Twig_Parser implements Twig_ParserInterface $subparser = $this->handlers->getTokenParser($token->getValue()); if (null === $subparser) { if (null !== $test) { - throw new Twig_Error_Syntax(sprintf('Unexpected tag name "%s" (expecting closing tag for the "%s" tag defined near line %s)', $token->getValue(), $test[0]->getTag(), $lineno), $token->getLine(), $this->stream->getFilename()); + $error = sprintf('Unexpected tag name "%s"', $token->getValue()); + if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) { + $error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno); + } + + throw new Twig_Error_Syntax($error, $token->getLine(), $this->getFilename()); } - throw new Twig_Error_Syntax(sprintf('Unknown tag name "%s"', $token->getValue()), $token->getLine(), $this->stream->getFilename()); + $message = sprintf('Unknown tag name "%s"', $token->getValue()); + if ($alternatives = $this->env->computeAlternatives($token->getValue(), array_keys($this->env->getTags()))) { + $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); + } + + throw new Twig_Error_Syntax($message, $token->getLine(), $this->getFilename()); } $this->stream->next(); @@ -156,7 +195,7 @@ class Twig_Parser implements Twig_ParserInterface break; default: - throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', -1, $this->stream->getFilename()); + throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', 0, $this->getFilename()); } } @@ -202,9 +241,14 @@ class Twig_Parser implements Twig_ParserInterface return isset($this->blocks[$name]); } + public function getBlock($name) + { + return $this->blocks[$name]; + } + public function setBlock($name, $value) { - $this->blocks[$name] = $value; + $this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getLine()); } public function hasMacro($name) @@ -223,7 +267,7 @@ class Twig_Parser implements Twig_ParserInterface } if (in_array($name, $this->reservedMacroNames)) { - throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine()); + throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename()); } $this->macros[$name] = $node; @@ -234,33 +278,45 @@ class Twig_Parser implements Twig_ParserInterface $this->traits[] = $trait; } - public function addImportedFunction($alias, $name, Twig_Node_Expression $node) + public function hasTraits() + { + return count($this->traits) > 0; + } + + public function embedTemplate(Twig_Node_Module $template) { - $this->importedFunctions[0][$alias] = array('name' => $name, 'node' => $node); + $template->setIndex(mt_rand()); + + $this->embeddedTemplates[] = $template; } - public function getImportedFunction($alias) + public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null) { - foreach ($this->importedFunctions as $functions) { - if (isset($functions[$alias])) { - return $functions[$alias]; + $this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node); + } + + public function getImportedSymbol($type, $alias) + { + foreach ($this->importedSymbols as $functions) { + if (isset($functions[$type][$alias])) { + return $functions[$type][$alias]; } } } public function isMainScope() { - return 1 === count($this->importedFunctions); + return 1 === count($this->importedSymbols); } public function pushLocalScope() { - array_unshift($this->importedFunctions, array()); + array_unshift($this->importedSymbols, array()); } public function popLocalScope() { - array_shift($this->importedFunctions); + array_shift($this->importedSymbols); } /** @@ -311,7 +367,11 @@ class Twig_Parser implements Twig_ParserInterface || (!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface) ) { - throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->stream->getFilename()); + if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) { + throw new Twig_Error_Syntax('A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->getFilename()); + } + + throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->getFilename()); } // bypass "set" nodes as they "capture" the output diff --git a/inc/lib/Twig/ParserInterface.php b/inc/lib/Twig/ParserInterface.php index c7a34418..f0d79009 100644 --- a/inc/lib/Twig/ParserInterface.php +++ b/inc/lib/Twig/ParserInterface.php @@ -12,17 +12,17 @@ /** * Interface implemented by parser classes. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_ParserInterface { /** * Converts a token stream to a node tree. * - * @param Twig_TokenStream $stream A token stream instance + * @param Twig_TokenStream $stream A token stream instance * * @return Twig_Node_Module A node tree */ - function parse(Twig_TokenStream $code); + public function parse(Twig_TokenStream $stream); } diff --git a/inc/lib/Twig/Sandbox/SecurityError.php b/inc/lib/Twig/Sandbox/SecurityError.php index debabb79..015bfaea 100644 --- a/inc/lib/Twig/Sandbox/SecurityError.php +++ b/inc/lib/Twig/Sandbox/SecurityError.php @@ -12,8 +12,7 @@ /** * Exception thrown when a security error occurs at runtime. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Sandbox_SecurityError extends Twig_Error { diff --git a/inc/lib/Twig/Sandbox/SecurityPolicy.php b/inc/lib/Twig/Sandbox/SecurityPolicy.php index ba912ef4..66ee2332 100644 --- a/inc/lib/Twig/Sandbox/SecurityPolicy.php +++ b/inc/lib/Twig/Sandbox/SecurityPolicy.php @@ -12,8 +12,7 @@ /** * Represents a security policy which need to be enforced when sandbox mode is enabled. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface { diff --git a/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php b/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php index d5015aff..6ab48e3c 100644 --- a/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php +++ b/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php @@ -12,14 +12,13 @@ /** * Interfaces that all security policy classes must implements. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_Sandbox_SecurityPolicyInterface { - function checkSecurity($tags, $filters, $functions); + public function checkSecurity($tags, $filters, $functions); - function checkMethodAllowed($obj, $method); + public function checkMethodAllowed($obj, $method); - function checkPropertyAllowed($obj, $method); + public function checkPropertyAllowed($obj, $method); } diff --git a/inc/lib/Twig/SimpleFilter.php b/inc/lib/Twig/SimpleFilter.php new file mode 100644 index 00000000..d35c5633 --- /dev/null +++ b/inc/lib/Twig/SimpleFilter.php @@ -0,0 +1,94 @@ + + */ +class Twig_SimpleFilter +{ + protected $name; + protected $callable; + protected $options; + protected $arguments = array(); + + public function __construct($name, $callable, array $options = array()) + { + $this->name = $name; + $this->callable = $callable; + $this->options = array_merge(array( + 'needs_environment' => false, + 'needs_context' => false, + 'is_safe' => null, + 'is_safe_callback' => null, + 'pre_escape' => null, + 'preserves_safety' => null, + 'node_class' => 'Twig_Node_Expression_Filter', + ), $options); + } + + public function getName() + { + return $this->name; + } + + public function getCallable() + { + return $this->callable; + } + + public function getNodeClass() + { + return $this->options['node_class']; + } + + public function setArguments($arguments) + { + $this->arguments = $arguments; + } + + public function getArguments() + { + return $this->arguments; + } + + public function needsEnvironment() + { + return $this->options['needs_environment']; + } + + public function needsContext() + { + return $this->options['needs_context']; + } + + public function getSafe(Twig_Node $filterArgs) + { + if (null !== $this->options['is_safe']) { + return $this->options['is_safe']; + } + + if (null !== $this->options['is_safe_callback']) { + return call_user_func($this->options['is_safe_callback'], $filterArgs); + } + } + + public function getPreservesSafety() + { + return $this->options['preserves_safety']; + } + + public function getPreEscape() + { + return $this->options['pre_escape']; + } +} diff --git a/inc/lib/Twig/SimpleFunction.php b/inc/lib/Twig/SimpleFunction.php new file mode 100644 index 00000000..8ef6aca2 --- /dev/null +++ b/inc/lib/Twig/SimpleFunction.php @@ -0,0 +1,84 @@ + + */ +class Twig_SimpleFunction +{ + protected $name; + protected $callable; + protected $options; + protected $arguments = array(); + + public function __construct($name, $callable, array $options = array()) + { + $this->name = $name; + $this->callable = $callable; + $this->options = array_merge(array( + 'needs_environment' => false, + 'needs_context' => false, + 'is_safe' => null, + 'is_safe_callback' => null, + 'node_class' => 'Twig_Node_Expression_Function', + ), $options); + } + + public function getName() + { + return $this->name; + } + + public function getCallable() + { + return $this->callable; + } + + public function getNodeClass() + { + return $this->options['node_class']; + } + + public function setArguments($arguments) + { + $this->arguments = $arguments; + } + + public function getArguments() + { + return $this->arguments; + } + + public function needsEnvironment() + { + return $this->options['needs_environment']; + } + + public function needsContext() + { + return $this->options['needs_context']; + } + + public function getSafe(Twig_Node $functionArgs) + { + if (null !== $this->options['is_safe']) { + return $this->options['is_safe']; + } + + if (null !== $this->options['is_safe_callback']) { + return call_user_func($this->options['is_safe_callback'], $functionArgs); + } + + return array(); + } +} diff --git a/inc/lib/Twig/SimpleTest.php b/inc/lib/Twig/SimpleTest.php new file mode 100644 index 00000000..225459c9 --- /dev/null +++ b/inc/lib/Twig/SimpleTest.php @@ -0,0 +1,46 @@ + + */ +class Twig_SimpleTest +{ + protected $name; + protected $callable; + protected $options; + + public function __construct($name, $callable, array $options = array()) + { + $this->name = $name; + $this->callable = $callable; + $this->options = array_merge(array( + 'node_class' => 'Twig_Node_Expression_Test', + ), $options); + } + + public function getName() + { + return $this->name; + } + + public function getCallable() + { + return $this->callable; + } + + public function getNodeClass() + { + return $this->options['node_class']; + } +} diff --git a/inc/lib/Twig/Template.php b/inc/lib/Twig/Template.php index a129fd73..a001ca03 100644 --- a/inc/lib/Twig/Template.php +++ b/inc/lib/Twig/Template.php @@ -13,16 +13,17 @@ /** * Default base class for compiled templates. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ abstract class Twig_Template implements Twig_TemplateInterface { - static protected $cache = array(); + protected static $cache = array(); + protected $parent; protected $parents; protected $env; protected $blocks; + protected $traits; /** * Constructor. @@ -33,6 +34,7 @@ abstract class Twig_Template implements Twig_TemplateInterface { $this->env = $env; $this->blocks = array(); + $this->traits = array(); } /** @@ -43,9 +45,7 @@ abstract class Twig_Template implements Twig_TemplateInterface abstract public function getTemplateName(); /** - * Returns the Twig environment. - * - * @return Twig_Environment The Twig environment + * {@inheritdoc} */ public function getEnvironment() { @@ -55,10 +55,17 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Returns the parent template. * + * This method is for internal use only and should never be called + * directly. + * * @return Twig_TemplateInterface|false The parent template or false if there is no parent */ public function getParent(array $context) { + if (null !== $this->parent) { + return $this->parent; + } + $parent = $this->doGetParent($context); if (false === $parent) { return false; @@ -73,33 +80,53 @@ abstract class Twig_Template implements Twig_TemplateInterface return $this->parents[$parent]; } - abstract protected function doGetParent(array $context); + protected function doGetParent(array $context) + { + return false; + } + + public function isTraitable() + { + return true; + } /** * Displays a parent block. * + * This method is for internal use only and should never be called + * directly. + * * @param string $name The block name to display from the parent * @param array $context The context * @param array $blocks The current set of blocks */ public function displayParentBlock($name, array $context, array $blocks = array()) { - if (false !== $parent = $this->getParent($context)) { + $name = (string) $name; + + if (isset($this->traits[$name])) { + $this->traits[$name][0]->displayBlock($name, $context, $blocks); + } elseif (false !== $parent = $this->getParent($context)) { $parent->displayBlock($name, $context, $blocks); } else { - throw new Twig_Error_Runtime('This template has no parent', -1, $this->getTemplateName()); + throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block', $name), -1, $this->getTemplateName()); } } /** * Displays a block. * + * This method is for internal use only and should never be called + * directly. + * * @param string $name The block name to display * @param array $context The context * @param array $blocks The current set of blocks */ public function displayBlock($name, array $context, array $blocks = array()) { + $name = (string) $name; + if (isset($blocks[$name])) { $b = $blocks; unset($b[$name]); @@ -114,6 +141,9 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Renders a parent block. * + * This method is for internal use only and should never be called + * directly. + * * @param string $name The block name to render from the parent * @param array $context The context * @param array $blocks The current set of blocks @@ -131,6 +161,9 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Renders a block. * + * This method is for internal use only and should never be called + * directly. + * * @param string $name The block name to render * @param array $context The context * @param array $blocks The current set of blocks @@ -148,19 +181,34 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Returns whether a block exists or not. * + * This method is for internal use only and should never be called + * directly. + * + * This method does only return blocks defined in the current template + * or defined in "used" traits. + * + * It does not return blocks from parent templates as the parent + * template name can be dynamic, which is only known based on the + * current context. + * * @param string $name The block name * * @return Boolean true if the block exists, false otherwise */ public function hasBlock($name) { - return isset($this->blocks[$name]); + return isset($this->blocks[(string) $name]); } /** * Returns all block names. * + * This method is for internal use only and should never be called + * directly. + * * @return array An array of block names + * + * @see hasBlock */ public function getBlockNames() { @@ -170,7 +218,12 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Returns all blocks. * + * This method is for internal use only and should never be called + * directly. + * * @return array An array of blocks + * + * @see hasBlock */ public function getBlocks() { @@ -178,28 +231,15 @@ abstract class Twig_Template implements Twig_TemplateInterface } /** - * Displays the template with the given context. - * - * @param array $context An array of parameters to pass to the template - * @param array $blocks An array of blocks to pass to the template + * {@inheritdoc} */ public function display(array $context, array $blocks = array()) { - try { - $this->doDisplay($context, $blocks); - } catch (Twig_Error $e) { - throw $e; - } catch (Exception $e) { - throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, null, $e); - } + $this->displayWithErrorHandling($this->env->mergeGlobals($context), $blocks); } /** - * Renders the template with the given context and returns it as string. - * - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered template + * {@inheritdoc} */ public function render(array $context) { @@ -218,6 +258,28 @@ abstract class Twig_Template implements Twig_TemplateInterface return ob_get_clean(); } + protected function displayWithErrorHandling(array $context, array $blocks = array()) + { + try { + $this->doDisplay($context, $blocks); + } catch (Twig_Error $e) { + if (!$e->getTemplateFile()) { + $e->setTemplateFile($this->getTemplateName()); + } + + // this is mostly useful for Twig_Error_Loader exceptions + // see Twig_Error_Loader + if (false === $e->getTemplateLine()) { + $e->setTemplateLine(-1); + $e->guess(); + } + + throw $e; + } catch (Exception $e) { + throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, null, $e); + } + } + /** * Auto-generated method to display the template with the given context. * @@ -229,21 +291,30 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Returns a variable from the context. * - * @param array $context The context - * @param string $item The variable to return from the context + * This method is for internal use only and should never be called + * directly. + * + * This method should not be overridden in a sub-class as this is an + * implementation detail that has been introduced to optimize variable + * access for versions of PHP before 5.4. This is not a way to override + * the way to get a variable value. + * + * @param array $context The context + * @param string $item The variable to return from the context + * @param Boolean $ignoreStrictCheck Whether to ignore the strict variable check or not * * @return The content of the context variable * * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode */ - protected function getContext($context, $item) + final protected function getContext($context, $item, $ignoreStrictCheck = false) { if (!array_key_exists($item, $context)) { - if (!$this->env->isStrictVariables()) { + if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { return null; } - throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item)); + throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this->getTemplateName()); } return $context[$item]; @@ -252,40 +323,50 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Returns the attribute value for a given array/object. * - * @param mixed $object The object or array from where to get the item - * @param mixed $item The item to get from the array or object - * @param array $arguments An array of arguments to pass if the item is an object method - * @param string $type The type of attribute (@see Twig_TemplateInterface) - * @param Boolean $isDefinedTest Whether this is only a defined check + * @param mixed $object The object or array from where to get the item + * @param mixed $item The item to get from the array or object + * @param array $arguments An array of arguments to pass if the item is an object method + * @param string $type The type of attribute (@see Twig_TemplateInterface) + * @param Boolean $isDefinedTest Whether this is only a defined check + * @param Boolean $ignoreStrictCheck Whether to ignore the strict attribute check or not + * + * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true + * + * @throws Twig_Error_Runtime if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false */ - protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false) + protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) { // array if (Twig_TemplateInterface::METHOD_CALL !== $type) { - if ((is_array($object) && array_key_exists($item, $object)) - || ($object instanceof ArrayAccess && isset($object[$item])) + $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; + + if ((is_array($object) && array_key_exists($arrayItem, $object)) + || ($object instanceof ArrayAccess && isset($object[$arrayItem])) ) { if ($isDefinedTest) { return true; } - return $object[$item]; + return $object[$arrayItem]; } - if (Twig_TemplateInterface::ARRAY_CALL === $type) { + if (Twig_TemplateInterface::ARRAY_CALL === $type || !is_object($object)) { if ($isDefinedTest) { return false; } - if (!$this->env->isStrictVariables()) { + if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { return null; } if (is_object($object)) { - throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object))); - // array + throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $arrayItem, get_class($object)), -1, $this->getTemplateName()); + } elseif (is_array($object)) { + throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object))), -1, $this->getTemplateName()); + } elseif (Twig_TemplateInterface::ARRAY_CALL === $type) { + throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName()); } else { - throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object)))); + throw new Twig_Error_Runtime(sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName()); } } } @@ -295,32 +376,18 @@ abstract class Twig_Template implements Twig_TemplateInterface return false; } - if (!$this->env->isStrictVariables()) { + if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { return null; } - throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, $object)); + throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName()); } - // get some information about the object $class = get_class($object); - if (!isset(self::$cache[$class])) { - $r = new ReflectionClass($class); - self::$cache[$class] = array('methods' => array(), 'properties' => array()); - foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { - self::$cache[$class]['methods'][strtolower($method->getName())] = true; - } - - foreach ($r->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { - self::$cache[$class]['properties'][$property->getName()] = true; - } - } // object property if (Twig_TemplateInterface::METHOD_CALL !== $type) { - if (isset(self::$cache[$class]['properties'][$item]) - || isset($object->$item) || array_key_exists($item, $object) - ) { + if (isset($object->$item) || array_key_exists((string) $item, $object)) { if ($isDefinedTest) { return true; } @@ -334,25 +401,29 @@ abstract class Twig_Template implements Twig_TemplateInterface } // object method + if (!isset(self::$cache[$class]['methods'])) { + self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); + } + $lcItem = strtolower($item); if (isset(self::$cache[$class]['methods'][$lcItem])) { - $method = $item; + $method = (string) $item; } elseif (isset(self::$cache[$class]['methods']['get'.$lcItem])) { $method = 'get'.$item; } elseif (isset(self::$cache[$class]['methods']['is'.$lcItem])) { $method = 'is'.$item; } elseif (isset(self::$cache[$class]['methods']['__call'])) { - $method = $item; + $method = (string) $item; } else { if ($isDefinedTest) { return false; } - if (!$this->env->isStrictVariables()) { + if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { return null; } - throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object))); + throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName()); } if ($isDefinedTest) { @@ -365,10 +436,20 @@ abstract class Twig_Template implements Twig_TemplateInterface $ret = call_user_func_array(array($object, $method), $arguments); + // useful when calling a template method from a template + // this is not supported but unfortunately heavily used in the Symfony profiler if ($object instanceof Twig_TemplateInterface) { - return new Twig_Markup($ret); + return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); } return $ret; } + + /** + * This method is only useful when testing Twig. Do not use it. + */ + public static function clearCache() + { + self::$cache = array(); + } } diff --git a/inc/lib/Twig/TemplateInterface.php b/inc/lib/Twig/TemplateInterface.php index 08da1163..879f503e 100644 --- a/inc/lib/Twig/TemplateInterface.php +++ b/inc/lib/Twig/TemplateInterface.php @@ -12,8 +12,8 @@ /** * Interface implemented by all compiled templates. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TemplateInterface { @@ -28,7 +28,7 @@ interface Twig_TemplateInterface * * @return string The rendered template */ - function render(array $context); + public function render(array $context); /** * Displays the template with the given context. @@ -36,12 +36,12 @@ interface Twig_TemplateInterface * @param array $context An array of parameters to pass to the template * @param array $blocks An array of blocks to pass to the template */ - function display(array $context, array $blocks = array()); + public function display(array $context, array $blocks = array()); /** * Returns the bound environment for this template. * * @return Twig_Environment The current environment */ - function getEnvironment(); + public function getEnvironment(); } diff --git a/inc/lib/Twig/Test.php b/inc/lib/Twig/Test.php new file mode 100644 index 00000000..3baff885 --- /dev/null +++ b/inc/lib/Twig/Test.php @@ -0,0 +1,34 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface +{ + protected $options; + protected $arguments = array(); + + public function __construct(array $options = array()) + { + $this->options = array_merge(array( + 'callable' => null, + ), $options); + } + + public function getCallable() + { + return $this->options['callable']; + } +} diff --git a/inc/lib/Twig/Test/Function.php b/inc/lib/Twig/Test/Function.php index 1240a0f1..4be6b9b9 100644 --- a/inc/lib/Twig/Test/Function.php +++ b/inc/lib/Twig/Test/Function.php @@ -12,15 +12,19 @@ /** * Represents a function template test. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ -class Twig_Test_Function implements Twig_TestInterface +class Twig_Test_Function extends Twig_Test { protected $function; - public function __construct($function) + public function __construct($function, array $options = array()) { + $options['callable'] = $function; + + parent::__construct($options); + $this->function = $function; } diff --git a/inc/lib/Twig/Test/IntegrationTestCase.php b/inc/lib/Twig/Test/IntegrationTestCase.php new file mode 100644 index 00000000..724f0941 --- /dev/null +++ b/inc/lib/Twig/Test/IntegrationTestCase.php @@ -0,0 +1,154 @@ + + * @author Karma Dordrak + */ +abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase +{ + abstract protected function getExtensions(); + abstract protected function getFixturesDir(); + + /** + * @dataProvider getTests + */ + public function testIntegration($file, $message, $condition, $templates, $exception, $outputs) + { + $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs); + } + + public function getTests() + { + $fixturesDir = realpath($this->getFixturesDir()); + $tests = array(); + + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + if (!preg_match('/\.test$/', $file)) { + continue; + } + + $test = file_get_contents($file->getRealpath()); + + if (preg_match('/ + --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { + $message = $match[1]; + $condition = $match[2]; + $templates = $this->parseTemplates($match[3]); + $exception = $match[5]; + $outputs = array(array(null, $match[4], null, '')); + } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) { + $message = $match[1]; + $condition = $match[2]; + $templates = $this->parseTemplates($match[3]); + $exception = false; + preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER); + } else { + throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file))); + } + + $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs); + } + + return $tests; + } + + protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs) + { + if ($condition) { + eval('$ret = '.$condition.';'); + if (!$ret) { + $this->markTestSkipped($condition); + } + } + + $loader = new Twig_Loader_Array($templates); + + foreach ($outputs as $match) { + $config = array_merge(array( + 'cache' => false, + 'strict_variables' => true, + ), $match[2] ? eval($match[2].';') : array()); + $twig = new Twig_Environment($loader, $config); + $twig->addGlobal('global', 'global'); + foreach ($this->getExtensions() as $extension) { + $twig->addExtension($extension); + } + + try { + $template = $twig->loadTemplate('index.twig'); + } catch (Exception $e) { + if (false !== $exception) { + $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); + + return; + } + + if ($e instanceof Twig_Error_Syntax) { + $e->setTemplateFile($file); + + throw $e; + } + + throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); + } + + try { + $output = trim($template->render(eval($match[1].';')), "\n "); + } catch (Exception $e) { + if (false !== $exception) { + $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); + + return; + } + + if ($e instanceof Twig_Error_Syntax) { + $e->setTemplateFile($file); + } else { + $e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e); + } + + $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage())); + } + + if (false !== $exception) { + list($class, ) = explode(':', $exception); + $this->assertThat(NULL, new PHPUnit_Framework_Constraint_Exception($class)); + } + + $expected = trim($match[3], "\n "); + + if ($expected != $output) { + echo 'Compiled template that failed:'; + + foreach (array_keys($templates) as $name) { + echo "Template: $name\n"; + $source = $loader->getSource($name); + echo $twig->compile($twig->parse($twig->tokenize($source, $name))); + } + } + $this->assertEquals($expected, $output, $message.' (in '.$file.')'); + } + } + + protected static function parseTemplates($test) + { + $templates = array(); + preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $templates[($match[1] ? $match[1] : 'index.twig')] = $match[2]; + } + + return $templates; + } +} diff --git a/inc/lib/Twig/Test/Method.php b/inc/lib/Twig/Test/Method.php index a3b39483..17c6c041 100644 --- a/inc/lib/Twig/Test/Method.php +++ b/inc/lib/Twig/Test/Method.php @@ -12,15 +12,20 @@ /** * Represents a method template test. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ -class Twig_Test_Method implements Twig_TestInterface +class Twig_Test_Method extends Twig_Test { - protected $extension, $method; + protected $extension; + protected $method; - public function __construct(Twig_ExtensionInterface $extension, $method) + public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) { + $options['callable'] = array($extension, $method); + + parent::__construct($options); + $this->extension = $extension; $this->method = $method; } diff --git a/inc/lib/Twig/Test/Node.php b/inc/lib/Twig/Test/Node.php new file mode 100644 index 00000000..c832a57b --- /dev/null +++ b/inc/lib/Twig/Test/Node.php @@ -0,0 +1,37 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +class Twig_Test_Node extends Twig_Test +{ + protected $class; + + public function __construct($class, array $options = array()) + { + parent::__construct($options); + + $this->class = $class; + } + + public function getClass() + { + return $this->class; + } + + public function compile() + { + } +} diff --git a/inc/lib/Twig/Test/NodeTestCase.php b/inc/lib/Twig/Test/NodeTestCase.php new file mode 100644 index 00000000..b15c85ff --- /dev/null +++ b/inc/lib/Twig/Test/NodeTestCase.php @@ -0,0 +1,58 @@ +assertNodeCompilation($source, $node, $environment); + } + + public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null) + { + $compiler = $this->getCompiler($environment); + $compiler->compile($node); + + $this->assertEquals($source, trim($compiler->getSource())); + } + + protected function getCompiler(Twig_Environment $environment = null) + { + return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment); + } + + protected function getEnvironment() + { + return new Twig_Environment(); + } + + protected function getVariableGetter($name) + { + if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); + } + + return sprintf('$this->getContext($context, "%s")', $name); + } + + protected function getAttributeGetter() + { + if (function_exists('twig_template_get_attributes')) { + return 'twig_template_get_attributes($this, '; + } + + return '$this->getAttribute('; + } +} diff --git a/inc/lib/Twig/TestCallableInterface.php b/inc/lib/Twig/TestCallableInterface.php new file mode 100644 index 00000000..0db43682 --- /dev/null +++ b/inc/lib/Twig/TestCallableInterface.php @@ -0,0 +1,21 @@ + + * @deprecated since 1.12 (to be removed in 2.0) + */ +interface Twig_TestCallableInterface +{ + public function getCallable(); +} diff --git a/inc/lib/Twig/TestInterface.php b/inc/lib/Twig/TestInterface.php index c2ff7258..30d8a2c4 100644 --- a/inc/lib/Twig/TestInterface.php +++ b/inc/lib/Twig/TestInterface.php @@ -12,8 +12,8 @@ /** * Represents a template test. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TestInterface { @@ -22,5 +22,5 @@ interface Twig_TestInterface * * @return string The PHP code for the test */ - function compile(); + public function compile(); } diff --git a/inc/lib/Twig/Token.php b/inc/lib/Twig/Token.php index 79a10030..bbca90db 100644 --- a/inc/lib/Twig/Token.php +++ b/inc/lib/Twig/Token.php @@ -13,8 +13,7 @@ /** * Represents a Token. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_Token { @@ -22,17 +21,19 @@ class Twig_Token protected $type; protected $lineno; - const EOF_TYPE = -1; - const TEXT_TYPE = 0; - const BLOCK_START_TYPE = 1; - const VAR_START_TYPE = 2; - const BLOCK_END_TYPE = 3; - const VAR_END_TYPE = 4; - const NAME_TYPE = 5; - const NUMBER_TYPE = 6; - const STRING_TYPE = 7; - const OPERATOR_TYPE = 8; - const PUNCTUATION_TYPE = 9; + const EOF_TYPE = -1; + const TEXT_TYPE = 0; + const BLOCK_START_TYPE = 1; + const VAR_START_TYPE = 2; + const BLOCK_END_TYPE = 3; + const VAR_END_TYPE = 4; + const NAME_TYPE = 5; + const NUMBER_TYPE = 6; + const STRING_TYPE = 7; + const OPERATOR_TYPE = 8; + const PUNCTUATION_TYPE = 9; + const INTERPOLATION_START_TYPE = 10; + const INTERPOLATION_END_TYPE = 11; /** * Constructor. @@ -120,10 +121,11 @@ class Twig_Token * * @param integer $type The type as an integer * @param Boolean $short Whether to return a short representation or not + * @param integer $line The code line * * @return string The string representation */ - static public function typeToString($type, $short = false, $line = -1) + public static function typeToString($type, $short = false, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -159,8 +161,14 @@ class Twig_Token case self::PUNCTUATION_TYPE: $name = 'PUNCTUATION_TYPE'; break; + case self::INTERPOLATION_START_TYPE: + $name = 'INTERPOLATION_START_TYPE'; + break; + case self::INTERPOLATION_END_TYPE: + $name = 'INTERPOLATION_END_TYPE'; + break; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } return $short ? $name : 'Twig_Token::'.$name; @@ -169,12 +177,12 @@ class Twig_Token /** * Returns the english representation of a given type. * - * @param integer $type The type as an integer - * @param Boolean $short Whether to return a short representation or not + * @param integer $type The type as an integer + * @param integer $line The code line * * @return string The string representation */ - static public function typeToEnglish($type, $line = -1) + public static function typeToEnglish($type, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -199,8 +207,12 @@ class Twig_Token return 'operator'; case self::PUNCTUATION_TYPE: return 'punctuation'; + case self::INTERPOLATION_START_TYPE: + return 'begin of string interpolation'; + case self::INTERPOLATION_END_TYPE: + return 'end of string interpolation'; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } } } diff --git a/inc/lib/Twig/TokenParser.php b/inc/lib/Twig/TokenParser.php index 6c9e6935..decebd5e 100644 --- a/inc/lib/Twig/TokenParser.php +++ b/inc/lib/Twig/TokenParser.php @@ -12,11 +12,13 @@ /** * Base class for all token parsers. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ abstract class Twig_TokenParser implements Twig_TokenParserInterface { + /** + * @var Twig_Parser + */ protected $parser; /** diff --git a/inc/lib/Twig/TokenParser/AutoEscape.php b/inc/lib/Twig/TokenParser/AutoEscape.php index 3b4b96e3..27560288 100644 --- a/inc/lib/Twig/TokenParser/AutoEscape.php +++ b/inc/lib/Twig/TokenParser/AutoEscape.php @@ -39,23 +39,35 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser public function parse(Twig_Token $token) { $lineno = $token->getLine(); - $value = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); - if (!in_array($value, array('true', 'false'))) { - throw new Twig_Error_Syntax("Autoescape value must be 'true' or 'false'", $lineno); - } - $value = 'true' === $value ? 'html' : false; + $stream = $this->parser->getStream(); + + if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { + $value = 'html'; + } else { + $expr = $this->parser->getExpressionParser()->parseExpression(); + if (!$expr instanceof Twig_Node_Expression_Constant) { + throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename()); + } + $value = $expr->getAttribute('value'); - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { - if (false === $value) { - throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $lineno); + $compat = true === $value || false === $value; + + if (true === $value) { + $value = 'html'; } - $value = $this->parser->getStream()->next()->getValue(); + if ($compat && $stream->test(Twig_Token::NAME_TYPE)) { + if (false === $value) { + throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename()); + } + + $value = $stream->next()->getValue(); + } } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag()); } @@ -68,7 +80,7 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Block.php b/inc/lib/Twig/TokenParser/Block.php index b31f7ed6..a2e017f3 100644 --- a/inc/lib/Twig/TokenParser/Block.php +++ b/inc/lib/Twig/TokenParser/Block.php @@ -35,8 +35,9 @@ class Twig_TokenParser_Block extends Twig_TokenParser $stream = $this->parser->getStream(); $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); if ($this->parser->hasBlock($name)) { - throw new Twig_Error_Syntax("The block '$name' has already been defined", $lineno); + throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename()); } + $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno)); $this->parser->pushLocalScope(); $this->parser->pushBlockStack($name); @@ -48,7 +49,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser $value = $stream->next()->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $lineno); + throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } } else { @@ -58,8 +59,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser } $stream->expect(Twig_Token::BLOCK_END_TYPE); - $block = new Twig_Node_Block($name, $body, $lineno); - $this->parser->setBlock($name, $block); + $block->setNode('body', $body); $this->parser->popBlockStack(); $this->parser->popLocalScope(); @@ -74,7 +74,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Do.php b/inc/lib/Twig/TokenParser/Do.php new file mode 100644 index 00000000..f50939dd --- /dev/null +++ b/inc/lib/Twig/TokenParser/Do.php @@ -0,0 +1,42 @@ +parser->getExpressionParser()->parseExpression(); + + $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + + return new Twig_Node_Do($expr, $token->getLine(), $this->getTag()); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'do'; + } +} diff --git a/inc/lib/Twig/TokenParser/Embed.php b/inc/lib/Twig/TokenParser/Embed.php new file mode 100644 index 00000000..69cb5f35 --- /dev/null +++ b/inc/lib/Twig/TokenParser/Embed.php @@ -0,0 +1,66 @@ +parser->getStream(); + + $parent = $this->parser->getExpressionParser()->parseExpression(); + + list($variables, $only, $ignoreMissing) = $this->parseArguments(); + + // inject a fake parent to make the parent() function work + $stream->injectTokens(array( + new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()), + new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()), + new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()), + new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()), + )); + + $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true); + + // override the parent with the correct one + $module->setNode('parent', $parent); + + $this->parser->embedTemplate($module); + + $stream->expect(Twig_Token::BLOCK_END_TYPE); + + return new Twig_Node_Embed($module->getAttribute('filename'), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + + public function decideBlockEnd(Twig_Token $token) + { + return $token->test('endembed'); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'embed'; + } +} diff --git a/inc/lib/Twig/TokenParser/Extends.php b/inc/lib/Twig/TokenParser/Extends.php index 67eacda0..f5ecee21 100644 --- a/inc/lib/Twig/TokenParser/Extends.php +++ b/inc/lib/Twig/TokenParser/Extends.php @@ -29,23 +29,21 @@ class Twig_TokenParser_Extends extends Twig_TokenParser public function parse(Twig_Token $token) { if (!$this->parser->isMainScope()) { - throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine()); + throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename()); } if (null !== $this->parser->getParent()) { - throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine()); + throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename()); } $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return null; } /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Filter.php b/inc/lib/Twig/TokenParser/Filter.php index 0969ab1e..2b97475a 100644 --- a/inc/lib/Twig/TokenParser/Filter.php +++ b/inc/lib/Twig/TokenParser/Filter.php @@ -52,7 +52,7 @@ class Twig_TokenParser_Filter extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Flush.php b/inc/lib/Twig/TokenParser/Flush.php new file mode 100644 index 00000000..4e15e785 --- /dev/null +++ b/inc/lib/Twig/TokenParser/Flush.php @@ -0,0 +1,42 @@ +parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + + return new Twig_Node_Flush($token->getLine(), $this->getTag()); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'flush'; + } +} diff --git a/inc/lib/Twig/TokenParser/For.php b/inc/lib/Twig/TokenParser/For.php index 5ce82979..98a6d079 100644 --- a/inc/lib/Twig/TokenParser/For.php +++ b/inc/lib/Twig/TokenParser/For.php @@ -33,32 +33,41 @@ class Twig_TokenParser_For extends Twig_TokenParser public function parse(Twig_Token $token) { $lineno = $token->getLine(); + $stream = $this->parser->getStream(); $targets = $this->parser->getExpressionParser()->parseAssignmentExpression(); - $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, 'in'); + $stream->expect(Twig_Token::OPERATOR_TYPE, 'in'); $seq = $this->parser->getExpressionParser()->parseExpression(); $ifexpr = null; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'if')) { - $this->parser->getStream()->next(); + if ($stream->test(Twig_Token::NAME_TYPE, 'if')) { + $stream->next(); $ifexpr = $this->parser->getExpressionParser()->parseExpression(); } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideForFork')); - if ($this->parser->getStream()->next()->getValue() == 'else') { - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + if ($stream->next()->getValue() == 'else') { + $stream->expect(Twig_Token::BLOCK_END_TYPE); $else = $this->parser->subparse(array($this, 'decideForEnd'), true); } else { $else = null; } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); if (count($targets) > 1) { $keyTarget = $targets->getNode(0); + $keyTarget = new Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getLine()); $valueTarget = $targets->getNode(1); + $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine()); } else { $keyTarget = new Twig_Node_Expression_AssignName('_key', $lineno); $valueTarget = $targets->getNode(0); + $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine()); + } + + if ($ifexpr) { + $this->checkLoopUsageCondition($stream, $ifexpr); + $this->checkLoopUsageBody($stream, $body); } return new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag()); @@ -74,10 +83,51 @@ class Twig_TokenParser_For extends Twig_TokenParser return $token->test('endfor'); } + // the loop variable cannot be used in the condition + protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node) + { + if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) { + throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition', $node->getLine(), $stream->getFilename()); + } + + foreach ($node as $n) { + if (!$n) { + continue; + } + + $this->checkLoopUsageCondition($stream, $n); + } + } + + // check usage of non-defined loop-items + // it does not catch all problems (for instance when a for is included into another or when the variable is used in an include) + protected function checkLoopUsageBody(Twig_TokenStream $stream, Twig_NodeInterface $node) + { + if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) { + $attribute = $node->getNode('attribute'); + if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) { + throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition', $attribute->getAttribute('value')), $node->getLine(), $stream->getFilename()); + } + } + + // should check for parent.loop.XXX usage + if ($node instanceof Twig_Node_For) { + return; + } + + foreach ($node as $n) { + if (!$n) { + continue; + } + + $this->checkLoopUsageBody($stream, $n); + } + } + /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/From.php b/inc/lib/Twig/TokenParser/From.php index 87aceb4d..a54054db 100644 --- a/inc/lib/Twig/TokenParser/From.php +++ b/inc/lib/Twig/TokenParser/From.php @@ -55,8 +55,8 @@ class Twig_TokenParser_From extends Twig_TokenParser $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); - foreach($targets as $name => $alias) { - $this->parser->addImportedFunction($alias, $name, $node->getNode('var')); + foreach ($targets as $name => $alias) { + $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); } return $node; @@ -65,7 +65,7 @@ class Twig_TokenParser_From extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/If.php b/inc/lib/Twig/TokenParser/If.php index 65a1a8b2..3d7d1f51 100644 --- a/inc/lib/Twig/TokenParser/If.php +++ b/inc/lib/Twig/TokenParser/If.php @@ -36,22 +36,23 @@ class Twig_TokenParser_If extends Twig_TokenParser { $lineno = $token->getLine(); $expr = $this->parser->getExpressionParser()->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideIfFork')); $tests = array($expr, $body); $else = null; $end = false; while (!$end) { - switch ($this->parser->getStream()->next()->getValue()) { + switch ($stream->next()->getValue()) { case 'else': - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $else = $this->parser->subparse(array($this, 'decideIfEnd')); break; case 'elseif': $expr = $this->parser->getExpressionParser()->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideIfFork')); $tests[] = $expr; $tests[] = $body; @@ -62,11 +63,11 @@ class Twig_TokenParser_If extends Twig_TokenParser break; default: - throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), -1); + throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); } } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); } @@ -84,7 +85,7 @@ class Twig_TokenParser_If extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Import.php b/inc/lib/Twig/TokenParser/Import.php index d0a88cde..e7050c70 100644 --- a/inc/lib/Twig/TokenParser/Import.php +++ b/inc/lib/Twig/TokenParser/Import.php @@ -32,13 +32,15 @@ class Twig_TokenParser_Import extends Twig_TokenParser $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine()); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $this->parser->addImportedSymbol('template', $var->getAttribute('name')); + return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag()); } /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Include.php b/inc/lib/Twig/TokenParser/Include.php index 54154559..4a317868 100644 --- a/inc/lib/Twig/TokenParser/Include.php +++ b/inc/lib/Twig/TokenParser/Include.php @@ -32,37 +32,46 @@ class Twig_TokenParser_Include extends Twig_TokenParser { $expr = $this->parser->getExpressionParser()->parseExpression(); + list($variables, $only, $ignoreMissing) = $this->parseArguments(); + + return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + + protected function parseArguments() + { + $stream = $this->parser->getStream(); + $ignoreMissing = false; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'ignore')) { - $this->parser->getStream()->next(); - $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, 'missing'); + if ($stream->test(Twig_Token::NAME_TYPE, 'ignore')) { + $stream->next(); + $stream->expect(Twig_Token::NAME_TYPE, 'missing'); $ignoreMissing = true; } $variables = null; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'with')) { - $this->parser->getStream()->next(); + if ($stream->test(Twig_Token::NAME_TYPE, 'with')) { + $stream->next(); $variables = $this->parser->getExpressionParser()->parseExpression(); } $only = false; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'only')) { - $this->parser->getStream()->next(); + if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { + $stream->next(); $only = true; } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + return array($variables, $only, $ignoreMissing); } /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Macro.php b/inc/lib/Twig/TokenParser/Macro.php index da1ac55c..82b4fa6d 100644 --- a/inc/lib/Twig/TokenParser/Macro.php +++ b/inc/lib/Twig/TokenParser/Macro.php @@ -30,26 +30,25 @@ class Twig_TokenParser_Macro extends Twig_TokenParser public function parse(Twig_Token $token) { $lineno = $token->getLine(); - $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); + $stream = $this->parser->getStream(); + $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - $arguments = $this->parser->getExpressionParser()->parseArguments(); + $arguments = $this->parser->getExpressionParser()->parseArguments(true, true); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $this->parser->pushLocalScope(); $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { - $value = $this->parser->getStream()->next()->getValue(); + if ($stream->test(Twig_Token::NAME_TYPE)) { + $value = $stream->next()->getValue(); if ($value != $name) { - throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $lineno); + throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename()); } } $this->parser->popLocalScope(); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - $this->parser->setMacro($name, new Twig_Node_Macro($name, $body, $arguments, $lineno, $this->getTag())); - - return null; + $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag())); } public function decideBlockEnd(Twig_Token $token) @@ -60,7 +59,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Sandbox.php b/inc/lib/Twig/TokenParser/Sandbox.php index 62e7f8f7..9457325a 100644 --- a/inc/lib/Twig/TokenParser/Sandbox.php +++ b/inc/lib/Twig/TokenParser/Sandbox.php @@ -35,6 +35,19 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + // in a sandbox tag, only include tags are allowed + if (!$body instanceof Twig_Node_Include) { + foreach ($body as $node) { + if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { + continue; + } + + if (!$node instanceof Twig_Node_Include) { + throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename()); + } + } + } + return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); } @@ -46,7 +59,7 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Set.php b/inc/lib/Twig/TokenParser/Set.php index 489e1d30..70e0b41b 100644 --- a/inc/lib/Twig/TokenParser/Set.php +++ b/inc/lib/Twig/TokenParser/Set.php @@ -49,13 +49,13 @@ class Twig_TokenParser_Set extends Twig_TokenParser $stream->expect(Twig_Token::BLOCK_END_TYPE); if (count($names) !== count($values)) { - throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignements.", $lineno); + throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignments.", $stream->getCurrent()->getLine(), $stream->getFilename()); } } else { $capture = true; if (count($names) > 1) { - throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $lineno); + throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $stream->getCurrent()->getLine(), $stream->getFilename()); } $stream->expect(Twig_Token::BLOCK_END_TYPE); @@ -75,7 +75,7 @@ class Twig_TokenParser_Set extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Spaceless.php b/inc/lib/Twig/TokenParser/Spaceless.php index aa7ffbc4..1e3fa8f3 100644 --- a/inc/lib/Twig/TokenParser/Spaceless.php +++ b/inc/lib/Twig/TokenParser/Spaceless.php @@ -50,7 +50,7 @@ class Twig_TokenParser_Spaceless extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParser/Use.php b/inc/lib/Twig/TokenParser/Use.php index 16c47e3e..bc0e09ef 100644 --- a/inc/lib/Twig/TokenParser/Use.php +++ b/inc/lib/Twig/TokenParser/Use.php @@ -35,13 +35,12 @@ class Twig_TokenParser_Use extends Twig_TokenParser public function parse(Twig_Token $token) { $template = $this->parser->getExpressionParser()->parseExpression(); + $stream = $this->parser->getStream(); if (!$template instanceof Twig_Node_Expression_Constant) { - throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $token->getLine()); + throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename()); } - $stream = $this->parser->getStream(); - $targets = array(); if ($stream->test('with')) { $stream->next(); @@ -69,14 +68,12 @@ class Twig_TokenParser_Use extends Twig_TokenParser $stream->expect(Twig_Token::BLOCK_END_TYPE); $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets)))); - - return null; } /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { diff --git a/inc/lib/Twig/TokenParserBroker.php b/inc/lib/Twig/TokenParserBroker.php index 34fcdfbf..ec3fba67 100644 --- a/inc/lib/Twig/TokenParserBroker.php +++ b/inc/lib/Twig/TokenParserBroker.php @@ -13,8 +13,8 @@ /** * Default implementation of a token parser broker. * - * @package twig - * @author Arnaud Le Blanc + * @author Arnaud Le Blanc + * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface { @@ -32,13 +32,13 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface { foreach ($parsers as $parser) { if (!$parser instanceof Twig_TokenParserInterface) { - throw new Twig_Error('$parsers must a an array of Twig_TokenParserInterface'); + throw new LogicException('$parsers must a an array of Twig_TokenParserInterface'); } $this->parsers[$parser->getTag()] = $parser; } foreach ($brokers as $broker) { if (!$broker instanceof Twig_TokenParserBrokerInterface) { - throw new Twig_Error('$brokers must a an array of Twig_TokenParserBrokerInterface'); + throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface'); } $this->brokers[] = $broker; } @@ -54,6 +54,19 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface $this->parsers[$parser->getTag()] = $parser; } + /** + * Removes a TokenParser. + * + * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance + */ + public function removeTokenParser(Twig_TokenParserInterface $parser) + { + $name = $parser->getTag(); + if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) { + unset($this->parsers[$name]); + } + } + /** * Adds a TokenParserBroker. * @@ -64,6 +77,18 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface $this->brokers[] = $broker; } + /** + * Removes a TokenParserBroker. + * + * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance + */ + public function removeTokenParserBroker(Twig_TokenParserBroker $broker) + { + if (false !== $pos = array_search($broker, $this->brokers)) { + unset($this->brokers[$pos]); + } + } + /** * Gets a suitable TokenParser for a tag. * @@ -86,7 +111,11 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } $broker = prev($this->brokers); } - return null; + } + + public function getParsers() + { + return $this->parsers; } public function getParser() diff --git a/inc/lib/Twig/TokenParserBrokerInterface.php b/inc/lib/Twig/TokenParserBrokerInterface.php index 3ce8ca26..3f006e33 100644 --- a/inc/lib/Twig/TokenParserBrokerInterface.php +++ b/inc/lib/Twig/TokenParserBrokerInterface.php @@ -15,31 +15,31 @@ * * Token parser brokers allows to implement custom logic in the process of resolving a token parser for a given tag name. * - * @package twig - * @author Arnaud Le Blanc + * @author Arnaud Le Blanc + * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TokenParserBrokerInterface { /** * Gets a TokenParser suitable for a tag. * - * @param string $tag A tag name + * @param string $tag A tag name * * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found */ - function getTokenParser($tag); + public function getTokenParser($tag); /** * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. * * @param Twig_ParserInterface $parser A Twig_ParserInterface interface */ - function setParser(Twig_ParserInterface $parser); + public function setParser(Twig_ParserInterface $parser); /** * Gets the Twig_ParserInterface. * - * @return null|Twig_ParserInterface A Twig_ParserInterface instance of null + * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null */ - function getParser(); + public function getParser(); } diff --git a/inc/lib/Twig/TokenParserInterface.php b/inc/lib/Twig/TokenParserInterface.php index 114a939e..bbde7714 100644 --- a/inc/lib/Twig/TokenParserInterface.php +++ b/inc/lib/Twig/TokenParserInterface.php @@ -12,8 +12,7 @@ /** * Interface implemented by token parsers. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ interface Twig_TokenParserInterface { @@ -22,7 +21,7 @@ interface Twig_TokenParserInterface * * @param $parser A Twig_Parser instance */ - function setParser(Twig_Parser $parser); + public function setParser(Twig_Parser $parser); /** * Parses a token and returns a node. @@ -31,12 +30,12 @@ interface Twig_TokenParserInterface * * @return Twig_NodeInterface A Twig_NodeInterface instance */ - function parse(Twig_Token $token); + public function parse(Twig_Token $token); /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ - function getTag(); + public function getTag(); } diff --git a/inc/lib/Twig/TokenStream.php b/inc/lib/Twig/TokenStream.php index a2002b42..a78189f6 100644 --- a/inc/lib/Twig/TokenStream.php +++ b/inc/lib/Twig/TokenStream.php @@ -13,8 +13,7 @@ /** * Represents a token stream. * - * @package twig - * @author Fabien Potencier + * @author Fabien Potencier */ class Twig_TokenStream { @@ -45,6 +44,11 @@ class Twig_TokenStream return implode("\n", $this->tokens); } + public function injectTokens(array $tokens) + { + $this->tokens = array_merge(array_slice($this->tokens, 0, $this->current), $tokens, array_slice($this->tokens, $this->current)); + } + /** * Sets the pointer to the next token and returns the old one. * @@ -53,7 +57,7 @@ class Twig_TokenStream public function next() { if (!isset($this->tokens[++$this->current])) { - throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); + throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current - 1]->getLine(), $this->filename); } return $this->tokens[$this->current - 1]; @@ -92,7 +96,7 @@ class Twig_TokenStream public function look($number = 1) { if (!isset($this->tokens[$this->current + $number])) { - throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); + throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current + $number - 1]->getLine(), $this->filename); } return $this->tokens[$this->current + $number]; -- cgit v1.3 From 6b6f32949df7be58c7a9125711aeab2c34cd1d54 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 15:20:25 -0400 Subject: Web config editor: Use a + {% elseif var.type == 'integer' and var.name.0 == 'mod' and (var.default in ['JANITOR', 'MOD', 'ADMIN', 'DISABLED'] or var.default|slice(0, 14) == "$config['mod']") and var.value <= constant('DISABLED') %} + {% elseif var.type == 'integer' %} {% elseif var.type == 'boolean' %} -- cgit v1.3 From 157dcf9fb13f83d3d7ec8e2ab6cd566e92efea97 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 15:55:28 -0400 Subject: Continue upgrading Twig --- inc/lib/Twig/Extensions/Extension/I18n.php | 2 +- inc/lib/Twig/Extensions/Extension/Tinyboard.php | 46 ++++++++++++------------- inc/lib/Twig/Extensions/Node/Trans.php | 11 +++--- inc/lib/Twig/Extensions/TokenParser/Trans.php | 6 ++-- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/inc/lib/Twig/Extensions/Extension/I18n.php b/inc/lib/Twig/Extensions/Extension/I18n.php index 1f795490..bc6a05bd 100644 --- a/inc/lib/Twig/Extensions/Extension/I18n.php +++ b/inc/lib/Twig/Extensions/Extension/I18n.php @@ -28,7 +28,7 @@ class Twig_Extensions_Extension_I18n extends Twig_Extension public function getFilters() { return array( - 'trans' => new Twig_Filter_Function('gettext'), + new Twig_SimpleFilter('trans', 'gettext'), ); } diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 8c8d9456..727d5d2c 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -9,23 +9,23 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension */ public function getFilters() { - return Array( - 'filesize' => new Twig_Filter_Function('format_bytes'), - 'truncate' => new Twig_Filter_Function('twig_truncate_filter'), - 'truncate_body' => new Twig_Filter_Function('truncate'), - 'extension' => new Twig_Filter_Function('twig_extension_filter'), - 'sprintf' => new Twig_Filter_Function('sprintf'), - 'capcode' => new Twig_Filter_Function('capcode'), - 'hasPermission' => new Twig_Filter_Function('twig_hasPermission_filter'), - 'date' => new Twig_Filter_Function('twig_date_filter'), - 'poster_id' => new Twig_Filter_Function('poster_id'), - 'remove_whitespace' => new Twig_Filter_Function('twig_remove_whitespace_filter'), - 'count' => new Twig_Filter_Function('count'), - 'ago' => new Twig_Filter_Function('ago'), - 'until' => new Twig_Filter_Function('until'), - 'push' => new Twig_Filter_Function('twig_push_filter'), - 'bidi_cleanup' => new Twig_Filter_Function('bidi_cleanup'), - 'addslashes' => new Twig_Filter_Function('addslashes') + return array( + new Twig_SimpleFilter('filesize', 'format_bytes'), + new Twig_SimpleFilter('truncate', 'twig_truncate_filter'), + new Twig_SimpleFilter('truncate_body', 'truncate'), + new Twig_SimpleFilter('extension', 'twig_extension_filter'), + new Twig_SimpleFilter('sprintf', 'sprintf'), + new Twig_SimpleFilter('capcode', 'capcode'), + new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'), + new Twig_SimpleFilter('date', 'twig_date_filter'), + new Twig_SimpleFilter('poster_id', 'poster_id'), + new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'), + new Twig_SimpleFilter('count', 'count'), + new Twig_SimpleFilter('ago', 'ago'), + new Twig_SimpleFilter('until', 'until'), + new Twig_SimpleFilter('push', 'twig_push_filter'), + new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'), + new Twig_SimpleFilter('addslashes', 'addslashes') ); } @@ -36,12 +36,12 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension */ public function getFunctions() { - return Array( - 'time' => new Twig_Filter_Function('time'), - 'floor' => new Twig_Filter_Function('floor'), - 'timezone' => new Twig_Filter_Function('twig_timezone_function'), - 'hiddenInputs' => new Twig_Filter_Function('hiddenInputs'), - 'hiddenInputsHash' => new Twig_Filter_Function('hiddenInputsHash'), + return array( + new Twig_SimpleFunction('time', 'time'), + new Twig_SimpleFunction('floor', 'floor'), + new Twig_SimpleFunction('timezone', 'twig_timezone_function'), + new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'), + new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'), ); } diff --git a/inc/lib/Twig/Extensions/Node/Trans.php b/inc/lib/Twig/Extensions/Node/Trans.php index 18087e77..e7dc1ca8 100644 --- a/inc/lib/Twig/Extensions/Node/Trans.php +++ b/inc/lib/Twig/Extensions/Node/Trans.php @@ -94,22 +94,25 @@ class Twig_Extensions_Node_Trans extends Twig_Node ; } - $compiler->raw(');'); + $compiler->raw(");\n"); } } protected function compileString(Twig_NodeInterface $body) { - if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant) { + if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) { return array($body, array()); } $vars = array(); - if (count($body)) { $msg = ''; foreach ($body as $node) { + if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof Twig_Node_SetTemp) { + $node = $node->getNode(1); + } + if ($node instanceof Twig_Node_Print) { $n = $node->getNode('expr'); while ($n instanceof Twig_Node_Expression_Filter) { @@ -127,4 +130,4 @@ class Twig_Extensions_Node_Trans extends Twig_Node return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars); } -} +} \ No newline at end of file diff --git a/inc/lib/Twig/Extensions/TokenParser/Trans.php b/inc/lib/Twig/Extensions/TokenParser/Trans.php index 5b2d93b6..4a0fad41 100644 --- a/inc/lib/Twig/Extensions/TokenParser/Trans.php +++ b/inc/lib/Twig/Extensions/TokenParser/Trans.php @@ -43,12 +43,12 @@ class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag()); } - public function decideForFork($token) + public function decideForFork(Twig_Token $token) { return $token->test(array('plural', 'endtrans')); } - public function decideForEnd($token) + public function decideForEnd(Twig_Token $token) { return $token->test('endtrans'); } @@ -77,4 +77,4 @@ class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser throw new Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno); } } -} +} \ No newline at end of file -- cgit v1.3 From 5a44c50811ba9a927add4d54604307692492df8a Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 17:18:10 -0400 Subject: Simple file editor replacement for ?/config (optional). Issue #127 --- inc/config.php | 7 +++--- inc/mod/pages.php | 29 ++++++++++++++++++----- templates/mod/config-editor-php.html | 45 ++++++++++++++++++++++++++++++++++++ templates/mod/dashboard.html | 2 +- templates/mod/edit_post_form.html | 2 +- 5 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 templates/mod/config-editor-php.html diff --git a/inc/config.php b/inc/config.php index d82ebfc6..bddb9e4c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -929,6 +929,9 @@ // Automatically dismiss all reports regarding a thread when it is locked $config['mod']['dismiss_reports_on_lock'] = true; + // Replace ?/config with a simple text editor for editing inc/instance-config.php + $config['mod']['config_editor_php'] = false; + // Probably best not to change these: if (!defined('JANITOR')) { define('JANITOR', 0, true); @@ -999,7 +1002,7 @@ // Bypass flood check $config['mod']['flood'] = ADMIN; // Raw HTML posting - $config['mod']['rawhtml'] = DISABLED; + $config['mod']['rawhtml'] = ADMIN; /* Administration */ // View the report queue @@ -1077,8 +1080,6 @@ // Delete news entries $config['mod']['news_delete'] = ADMIN; - // View the current configuration - $config['mod']['show_config'] = ADMIN; // Edit the current configuration (via web interface) $config['mod']['edit_config'] = ADMIN; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 1e0dc7c9..615e85c7 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1304,13 +1304,12 @@ function mod_edit_post($board, $edit_raw_html, $postID) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']); } else { if ($config['minify_html']) { - // $post['body_nomarkup'] = str_replace("\n", ' ', $post['body_nomarkup']); - // $post['body'] = str_replace("\n", ' ', $post['body']); + $post['body_nomarkup'] = str_replace("\n", ' ', utf8tohtml($post['body_nomarkup'])); + $post['body'] = str_replace("\n", ' ', utf8tohtml($post['body'])); + $post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']); + $post['body'] = str_replace("\r", '', $post['body']); } - - // Minifying this page causes an issue with newlines in the textarea. This is a temporary solution. - $config['minify_html'] = false; - + mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); } } @@ -1948,6 +1947,24 @@ function mod_config() { if (!hasPermission($config['mod']['edit_config'])) error($config['error']['noaccess']); + if ($config['mod']['config_editor_php']) { + $readonly = !is_writable('inc/instance-config.php'); + + if (!$readonly && isset($_POST['code'])) { + $code = $_POST['code']; + file_put_contents('inc/instance-config.php', $code); + header('Location: ?/config', true, $config['redirect_http']); + return; + } + + $instance_config = file_get_contents('inc/instance-config.php'); + $instance_config = str_replace("\n", ' ', utf8tohtml($instance_config)); + + mod_page(_('Config editor'), 'mod/config-editor-php.html', array('php' => $instance_config, 'readonly' => $readonly)); + return; + } + + require_once 'inc/mod/config-editor.php'; $conf = config_vars(); diff --git a/templates/mod/config-editor-php.html b/templates/mod/config-editor-php.html new file mode 100644 index 00000000..54c398e4 --- /dev/null +++ b/templates/mod/config-editor-php.html @@ -0,0 +1,45 @@ +{% if readonly %} +

Tinyboard does not have the required permissions to edit inc/instance-config.php. To make changes, you will need to change the file's permissions first or manually edit the code.

+{% endif %} + + +{% if not readonly %}
{% endif %} + + +
    +
  • +
+{% if not readonly %}
{% endif %} + + \ No newline at end of file diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 5f6585fc..e9fb7c9c 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -94,7 +94,7 @@ {% if mod|hasPermission(config.mod.rebuild) %}
  • {% trans 'Rebuild' %}
  • {% endif %} - {% if mod|hasPermission(config.mod.show_config) %} + {% if mod|hasPermission(config.mod.edit_config) %}
  • {% trans 'Configuration' %}
  • {% endif %} diff --git a/templates/mod/edit_post_form.html b/templates/mod/edit_post_form.html index b9359c68..a2980d35 100644 --- a/templates/mod/edit_post_form.html +++ b/templates/mod/edit_post_form.html @@ -32,7 +32,7 @@ {% trans %}Comment{% endtrans %} - + -- cgit v1.3 From cf0a20a5645e1e82a48ad00f9381813af3b4e658 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 19:21:15 -0400 Subject: js/style-select.js: Changes the stylesheet chooser links to a + * + * Released under the MIT license + * Copyright (c) 2013 Michael Save + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/style-select.js'; + * + */ + +onready(function(){ + var stylesDiv = $('div.styles'); + var stylesSelect = $(''); + + var i = 1; + stylesDiv.children().each(function() { + stylesSelect.append( + $('') + .text(this.innerText.replace(/(^\[|\]$)/g, '')) + .val(i) + ); + $(this).attr('id', 'style-select-' + i); + i++; + }); + + stylesSelect.change(function() { + $('#style-select-' + $(this).val()).click(); + }); + + stylesDiv.hide(); + + stylesDiv.after( + $('
    ') + .text(_('Style: ')) + .append(stylesSelect) + ); +}); + -- cgit v1.3 From 2fd60c6d2599d991c8d05ad101844ea840bc1528 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 19:26:09 -0400 Subject: Select chosen stylesheet on load --- js/style-select.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/style-select.js b/js/style-select.js index ac17c7ce..33c1308b 100644 --- a/js/style-select.js +++ b/js/style-select.js @@ -19,11 +19,12 @@ onready(function(){ var i = 1; stylesDiv.children().each(function() { - stylesSelect.append( - $('') - .text(this.innerText.replace(/(^\[|\]$)/g, '')) - .val(i) - ); + var opt = $('') + .text(this.innerText.replace(/(^\[|\]$)/g, '')) + .val(i); + if ($(this).hasClass('selected')) + opt.attr('selected', true); + stylesSelect.append(opt); $(this).attr('id', 'style-select-' + i); i++; }); -- cgit v1.3 From 6c4103737797f1573070c7b00af3dfcbb5b96367 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 19:44:22 -0400 Subject: Add two stylesheets --- stylesheets/ferus.css | 155 +++++++++++++++++++++++++++++ stylesheets/ricechan.css | 249 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 404 insertions(+) create mode 100644 stylesheets/ferus.css create mode 100644 stylesheets/ricechan.css diff --git a/stylesheets/ferus.css b/stylesheets/ferus.css new file mode 100644 index 00000000..6a1dfb59 --- /dev/null +++ b/stylesheets/ferus.css @@ -0,0 +1,155 @@ +@font-face { + font-family: Matrix; + src: url(data:application/x-font-tff;base64,AAEAAAAOAIAAAwBgRkZUTTHZQ8IAALw8AAAAHE9TLzKQGR/2AAABaAAAAFZjbWFw5AjWjgAACJAAAAMaY3Z0IA0AJ3gAABNsAAABoGZwZ23UiPsUAAALrAAABRhnbHlm1ZlQ+QAAGJgAAJbMaGVhZOxJsogAAADsAAAANmhoZWEN1gd9AAABJAAAACRobXR4Go/MGQAAAcAAAAbQbG9jYflSH7IAABUMAAADjG1heHADwQX3AAABSAAAACBuYW1lMsi/8gAAr2QAAAKLcG9zdHFsGbAAALHwAAAKSXByZXA+daKoAAAQxAAAAqUAAQAAAAEAAIHcJmpfDzz1AB8IAAAAAADDEDQMAAAAAMMQNAz/9v6WBwAG3QAAAAgAAgAAAAAAAAABAAAG3f6WAAAIAP/2/0MHAAABAAAAAAAAAAAAAAAAAAABowABAAABxQBTAAQAWgAEAAIAEAAvADgAAAGoBRgAAwABAAEETAGQAAUACAWaBTMAAACyBZoFMwAAAeMAfQISCA8CAQUJAgECAQMDgAAArxAAIEgAAAAAAAAAAE1PTk8AQAAA8AMFMf6YAfYG3QFqoAAAk43UAAAAAAgAAQAAAAAABNUAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAfQETADLBEwAzwRMAM0ETADLBEwA0QRMAc8ETAHNBEwBgwRMAOcETADLBEwBdwRMAM8ETAHJBEwA4wRMAMsETADJBEwAxwRMAMkETAD6BEwA4QRMAM8ETADLBEwAyQRMANEETAHNBEwBcQRMAM8ETADLBEwA5QRMAOUETADPBEwAzwRMAMsETADTBEwAywRMAM8ETADPBEwAywRMAMsETADNBEwBIQRMAM0ETADPBEwAywRMAM8ETADNBEwAzwRMAM0ETADRBEwAzQRMAM0ETADNBEwA0QRMAM0ETADbBEwA0QRMAM0ETADPBEwA5QRMAM0ETADfBEz/9gRMAYcETADLBEwA0wRMANAETADJBEwAzQRMAPoETADNBEwAzQRMASEETAEfBEwAzwRMASMETAC6BEwAzwRMAM0ETADPBEwAzwRMAM8ETADNBEwAzQRMANIETADNBEwAuARMANsETADNBEwAzwRMANEETAIXBEwA0QRMAPYETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwB9ARMANAETADHBEwAyQRMAMsETAIXBEwAzQRMAMsETACqBEwAywRMAM8ETADBBEwAzwRMAKoETP/2BEwA9gRMAMEETAGLBEwB3wRMAYcETADRBEwAugRMAckETAF3BEwB3QRMAM0ETADZBEwAFARMABQETAAUBEwAuARMAM8ETADPBEwAzwRMAM8ETADLBEwAzwRMANUETADTBEwAzwRMAM8ETADPBEwAywRMAM0ETADNBEwAzQRMAMsETADLBEwAzwRMAM0ETADNBEwAzQRMAM0ETADLBEwBEARMAN8ETADNBEwAzQRMAM0ETADLBEwA0QRMAM8ETADNBEwAywRMAMsETADLBEwAywRMAMsETADLBEwATARMANAETADNBEwAzQRMAM0ETADLBEwBDARMASEETACRBEwAZARMAM0ETADPBEwAzQRMAM0ETADNBEwAzQRMAMsETADBBEwAzQRMANIETADSBEwA0gRMAMsETADNBEwAzwRMAMsETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwBIQRMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMABkETAEjBEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAzQRMAEwETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETADNBEwAzQRMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAARMAAAETAAABEwAAAR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phY3V0ZQZ6YWN1dGUKWmRvdGFjY2VudAp6ZG90YWNjZW50BWxvbmdzB3VuaTAxODAHdW5pMDE4MQd1bmkwMTgyB3VuaTAxODMHdW5pMDE4NAd1bmkwMTg1B3VuaTAxODYHdW5pMDE4Nwd1bmkwMTg4B3VuaTAxODkHdW5pMDE4QQd1bmkwMThCB3VuaTAxOEMHdW5pMDE4RAd1bmkwMThFB3VuaTAxOEYHdW5pMDE5MAd1bmkwMTkxB3VuaTAxOTMHdW5pMDE5NAxmb3Vyc3VwZXJpb3IAAAAAAAABAAAAAML+SiAAAAAAq8rFpAAAAADDEDP9); +} + +body { + background: #050505; + color: #00FF00; + font-family: Matrix; + font-size: 13.3px; +} +h1 { + font-size: 20pt; + text-align: center; + letter-spacing: 0px; +} +div.title, h1 { + color: #00FF00; + font-family: Arial, Helvetica, sans-serif; +} +div.title p { + font-size: 13px; +} +a:link, a:visited, p.intro a.email span.name { + color: #16C816; + text-decoration: underline; + font-family: Matrix; +} +a:link:hover, a:visited:hover { + color: #003C00; + font-family: Matrix;; + text-decoration: underline overline; +} +a.post_no { + color: #464646; + text-decoration: none; +} +a.post_no:hover { + color: maroon; + text-decoration: underline overline; +} +div.post.reply { + background: #0E0E0E; + border: #414141 2px solid; +} +.de-pview { + background: rgba(14, 14, 14, 0.84) !important; +} +div.post.reply.highlighted { + background: transparent; + border: #414141 2px solid; +} +div.post.reply div.body a:link, div.post.reply div.body a:visited { + color: #646464; +} +div.post.reply div.body a:link:hover, div.post.reply div.body a:visited:hover { + color: #00FF00; +} +p.intro span.subject { + font-size: 12px; + font-family: Matrix; + color: #446655; + font-weight: 800; +} +p.intro span.name { + color: #008200; + font-weight: 900; +} +p.intro a.capcode, p.intro a.nametag { + color: magenta; + margin-left: 0; +} +p.intro a.email, p.intro a.email span.name, p.intro a.email:hover, p.intro a.email:hover span.name { + color: #00CC64; + font-family: Matrix; +} +input[type="text"], textarea, select { + background: #333333; + color: #CCCCCC; + border: #666666 1px solid; + padding-left: 5px; + padding-right: -5px; + font-family: Matrix; + font-size: 10pt; +} +input[type="password"] { + background: #333333; + color: #8B8B8B; + border: #666666 1px solid; +} +form table tr th { + background: #333333; + color: #828282; + font-weight: 800; + text-align: left; + padding: 0; +} +div.banner { + background: #00AA00; + color: #646464; + text-align: center; + width: 250px; + padding: 4px; + padding-left: 12px; + padding-right: 12px; + margin-left: auto; + margin-right: auto; + font-size: 12px; +} +input[type="submit"] { + background: #333333; + border: #888888 1px solid; + color: #A0A0A0; +} +input[type="submit"]:hover { + background: #555555; + border: #888888 1px solid; + color: #00FF00; +} +p.fileinfo a:hover { + text-decoration: underline; +} +span.trip { + color: #AAAAAA; +} +div.pages { + color: #AAAAAA; + background: #333333; + border: #666666 1px solid; + font-family: sans-serif; + font-size: 10pt; +} +div.pages a.selected { + color: #8C8C8C; +} +hr { + height: 1px; + border: #333333 1px solid; +} +div.boardlist { + color: #999999; +} +div.ban { + background-color: transparent; + border: transparent 0px solid; +} +div.ban h2 { + background: transparent; + color: lime; + font-size: 12px; +} +table.modlog tr th { + background: #00FF00; + color: #AAAAAA; +} \ No newline at end of file diff --git a/stylesheets/ricechan.css b/stylesheets/ricechan.css new file mode 100644 index 00000000..b8549726 --- /dev/null +++ b/stylesheets/ricechan.css @@ -0,0 +1,249 @@ +/* http://userstyles.org/styles/37014/4chan-ricechan-alpha */ + +.rules, +.logo+hr, +.logo+hr+div, +.logo+hr+div+hr, +hr+script+center>a, +hr+script+center+hr, +#recaptcha_logo, +#recaptcha_tagline, +table+br+hr+center>a, +table+br+hr+center+hr, +.postarea>form>div[style]>a[target], +.doubledash {display:none !important} + +* { + border: none !important; + background: none !important; + color: inherit !important; +} +html { + color: #555 !important; + background: #222 !important; +} +#navtop { + position: absolute; + top:0;left:0;right:0; + color: #666 !important; + background: #111 !important; + border-bottom: 1px solid #282828 !important; + text-align: center; + margin: -4px; + padding: 3px; +} +#navtop a { + color: #9f0 !important; +} +hr { + border-bottom: 1px solid rgba(0,0,0,0.5) !important; + border-top: 1px solid rgba(255,255,255,0.1) !important; +} +h1 { + color: #AF2020 !important; +} +a>img { + box-shadow: 0 0 6px #000; + -moz-box-shadow: 0 0 6px #000; + -webkit-box-shadow: 0 0 6px #000; +} +.logo b { + color: #fff !important; +} +div.boardlist a { + text-decoration: none; + color: #615A5A !important; +} +div.boardlist a:hover { + color: #C08E8E !important; +} +.postarea { + color: #fff !important; + position: fixed; + top:0; right:0; +} +.postblock { + color: #999 !important; +} +.postarea form { + padding-left: 12px; + opacity: .1; + width: 0; +} +.postarea form:hover { + width: auto; + opacity: 1; + background: rgba(0,0,0,0.8) !important; + border-radius: 0 0 0 32px; + -moz-border-radius: 0 0 0 32px; + -webkit-border-radius: 0 0 0 32px; + box-shadow: 0 0 32px #000; + -moz-box-shadow: 0 0 32px #000; + -webkit-box-shadow: 0 0 32px #000; +} +tr>th>font { /*POSTINGMODE*/ + position: fixed; + top:-2px; right:0; + font-size: 0; +} +tr>th>font:after { + color: #f00 !important; + content: 'REPLY'; + font-size: 48px; +} +form table tr th { + background: #7E3737 !important; + color: #B99B9B !important; +} +input[type="text"], input[type="password"], textarea { + border: 2px solid rgba(94, 50, 50, 0.56) !important; + background: #7C7373 !important; + color: #311313 !important; +} +a:hover { + color: #8E748F !important; +} +a { + color: #7C7E7C !important; +} +form>table { + padding: 4px !important; +} +.reply, .replyhl { + background: rgba(0,0,0,0.25) !important; + border: 1px solid #161616 !important; + margin: 8px !important; + border-radius: 12px; + -moz-border-radius: 12px; + -webkit-border-radius: 12px; + box-shadow: 0 0 6px rgba(0,0,0,0.5); + -moz-box-shadow: 0 0 6px rgba(0,0,0,0.5); + -webkit-box-shadow: 0 0 6px rgba(0,0,0,0.5); +} +h1 { + color: #962B22 !important; + letter-spacing: 1px; +} +.replyhl { + border: 1px solid #9f0 !important; + border-width: 4px 0 !important; +} +.post.reply.highlighted { + background: rgba(18, 21, 22, 0.6) !important; +} +.omitted { + font-style: italic; +} +#de-menu { + rgba(0, 0, 0, 0.85) !important; +} +#de-alert { + rgba(0, 0, 0, 0.85) !important; +} +.de-pview { + background: rgba(0,0,0,0.86) !important; + border: 1px solid #161616 !important; + margin: 8px !important; + border-radius: 12px; + -moz-border-radius: 12px; + -webkit-border-radius: 12px; + box-shadow: 0 0 6px rgba(0,0,0,0.5); + -moz-box-shadow: 0 0 6px rgba(0,0,0,0.5); + -webkit-box-shadow: 0 0 6px rgba(0,0,0,0.5); +} +.name,.commentpostername { + color: #999 !important; +} +.trip { + color: #644 !important; +} +.capcode { + color: #BB1212!important; +} +.de-ppanel-cnt:after { + color: #3A5252 !important; +} +.public_ban { + color: #E62C2C !important; +} +blockquote { + color: #fff !important; +} +.quotejs { + color: #999 !important; +} +.quotelink { + color: #9f0 !important; +} +.unkfunc { + color: #6c6 !important; +} +.de-refmap:before { + color: #707A86 !important; +} +.de-refmap { + color: #4C505E !important; +} +p.intro a.email span.name { + text-decoration: underline; +} +.quote { + color: #82A259 !important; +} +.delete { + color: #857979 !important; +} + +.commentpostername>span[style] { + color: #f0c !important; + font-size: 1.1em; +} +a[href="mailto:sage"] { + text-decoration: none !important; +} +a[href="mailto:sage"]:before { + color: #f90; + content: '「SAGE」'; + text-shadow: 0 -1px 1px #f00; +} +.heading { + color: #B41818 !important; + font-size: 13pt !important; + text-shadow: 0 0 0.55em #522121 !important +} +strong { + color: #706E6E !important; +} +.subject { + color: #819173 !important; +} +.spoiler { + background: #D3CABC !important; + color: #D3CABC !important; +} +.spoiler:hover { + color: #3F3535 !important; +} +.filesize span { + font-size: .01em; + letter-spacing: -5em; +} +.filesize span:before { + font-size: 100em; + letter-spacing: 0; + content: attr(title); +} + +.spoiler { + color: #161515 !important; + background: #141313 !important; +} +span.spoiler:hover { + color: #858585 !important; + background: #2C2929 !important; +} +br+br+b[style] { + color: #f00 !important; +} + +} \ No newline at end of file -- cgit v1.3 From 40ab2e0c1728fab613bc16a19ab8fcb3fa78c1d4 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 21:28:16 -0400 Subject: Don't redraw image again after correcting image orientation; Correct image orientation with convert+gifsicle too --- inc/image.php | 4 ++-- post.php | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/inc/image.php b/inc/image.php index 5910cb85..51db2f83 100644 --- a/inc/image.php +++ b/inc/image.php @@ -251,9 +251,9 @@ class ImageConvert extends ImageBase { if (!$this->temp) { if ($config['strip_exif']) { - shell_exec('convert ' . escapeshellarg($this->src) . ' -strip ' . escapeshellarg($src)); + shell_exec('convert ' . escapeshellarg($this->src) . ' -auto-orient -strip ' . escapeshellarg($src)); } else { - shell_exec('convert ' . escapeshellarg($this->src) . ' ' . escapeshellarg($src)); + shell_exec('convert ' . escapeshellarg($this->src) . ' -auto-orient ' . escapeshellarg($src)); } } else { rename($this->temp, $src); diff --git a/post.php b/post.php index 22782ca7..5031830f 100644 --- a/post.php +++ b/post.php @@ -450,10 +450,12 @@ if (isset($_POST['delete'])) { if ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') { // The following code corrects the image orientation. // Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered. - if ($config['thumb_method'] == 'convert') { - $exif = exif_read_data($upload); - if (isset($exif['Orientation']) && $exif['Orientation'] != 1) { - shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)); + if (!($config['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) { + if ($config['thumb_method'] == 'convert' || $config['thumb_method'] == 'convert+gifsicle') { + $exif = exif_read_data($upload); + if (isset($exif['Orientation']) && $exif['Orientation'] != 1) { + shell_exec('convert ' . escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)); + } } } } -- cgit v1.3