From 16daf2f3fa209bd31e9f545a2ee86e2a316891ef Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Fri, 15 Mar 2019 01:58:34 +0100 Subject: [PATCH] migrate admin to Twig --- composer.json | 4 +- composer.lock | 258 +++++++++--------- ipf/admin/app.php | 3 +- ipf/admin/component.php | 8 +- ipf/admin/controllers/base.php | 2 +- ipf/admin/controllers/dashboard.php | 4 +- ipf/admin/controllers/file_browser.php | 2 +- ipf/admin/controllers/user.php | 4 +- ipf/admin/templates/admin/base.html | 72 ----- ipf/admin/templates/admin/base.html.twig | 71 +++++ ipf/admin/templates/admin/change.html | 64 ----- ipf/admin/templates/admin/change.html.twig | 63 +++++ ipf/admin/templates/admin/delete.html | 23 -- ipf/admin/templates/admin/delete.html.twig | 22 ++ ...filebrowser.html => filebrowser.html.twig} | 79 +++--- ipf/admin/templates/admin/index.html | 48 ---- ipf/admin/templates/admin/index.html.twig | 47 ++++ ipf/admin/templates/admin/items.html | 90 ------ ipf/admin/templates/admin/items.html.twig | 89 ++++++ ipf/admin/templates/admin/log.html | 60 ---- ipf/admin/templates/admin/log.html.twig | 59 ++++ .../admin/{login.html => login.html.twig} | 13 +- ipf/admin/templates/admin/logout.html | 14 - ipf/admin/templates/admin/logout.html.twig | 13 + ipf/project_template.php | 1 - ipf/twig.php | 46 ++++ 26 files changed, 598 insertions(+), 561 deletions(-) delete mode 100644 ipf/admin/templates/admin/base.html create mode 100644 ipf/admin/templates/admin/base.html.twig delete mode 100644 ipf/admin/templates/admin/change.html create mode 100644 ipf/admin/templates/admin/change.html.twig delete mode 100644 ipf/admin/templates/admin/delete.html create mode 100644 ipf/admin/templates/admin/delete.html.twig rename ipf/admin/templates/admin/{filebrowser.html => filebrowser.html.twig} (54%) delete mode 100644 ipf/admin/templates/admin/index.html create mode 100644 ipf/admin/templates/admin/index.html.twig delete mode 100644 ipf/admin/templates/admin/items.html create mode 100644 ipf/admin/templates/admin/items.html.twig delete mode 100644 ipf/admin/templates/admin/log.html create mode 100644 ipf/admin/templates/admin/log.html.twig rename ipf/admin/templates/admin/{login.html => login.html.twig} (54%) delete mode 100644 ipf/admin/templates/admin/logout.html create mode 100644 ipf/admin/templates/admin/logout.html.twig create mode 100644 ipf/twig.php diff --git a/composer.json b/composer.json index 01a35ac..301c27e 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "andy128k/migrations": "dev-master", "andy128k/pegp": "0.1.*@dev", "andy128k/routeexpression": "dev-master", - "andy128k/ipf-legacy-template": "dev-master", - "pimple/pimple": "~3.0" + "pimple/pimple": "~3.0", + "twig/twig": "~1" }, "require-dev": { "phpunit/phpunit": "5" diff --git a/composer.lock b/composer.lock index 6c907b7..eef0152 100644 --- a/composer.lock +++ b/composer.lock @@ -4,69 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6efa15ba9b218a571e0da69898cfc2d1", + "content-hash": "f67dddca5aa2e90df76556d1f8daa79b", "packages": [ - { - "name": "andy128k/ipf-legacy-template", - "version": "dev-master", - "source": { - "type": "git", - "url": "git://git.andy128k.net/ipf-legacy-template.git", - "reference": "3a3db428fb525f3612feda7ee1bc4bdf3aef412a" - }, - "require": { - "andy128k/ipf-template": "0.2.*@dev" - }, - "suggest": { - "andy128k/ipf": "Web Framework" - }, - "type": "library", - "autoload": { - "classmap": [ - "src" - ] - }, - "authors": [ - { - "name": "Andrey Kutejko", - "email": "andy128k@gmail.com" - } - ], - "time": "2016-02-28T17:52:16+00:00" - }, - { - "name": "andy128k/ipf-template", - "version": "0.2.x-dev", - "source": { - "type": "git", - "url": "git://git.andy128k.net/ipf-template.git", - "reference": "44dff45da6bd050ee59802d17460c2344ada9d11" - }, - "require-dev": { - "phpunit/phpunit": "4.4.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "lib" - ] - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Litovchenko", - "email": "alex.litovchenko@gmail.com" - }, - { - "name": "Andrey Kutejko", - "email": "andy128k@gmail.com" - } - ], - "description": "Template Engine extracted from IPF Web Framework", - "time": "2016-02-28T14:48:53+00:00" - }, { "name": "andy128k/migrations", "version": "dev-master", @@ -822,16 +761,16 @@ }, { "name": "pear/pear-core-minimal", - "version": "v1.10.7", + "version": "v1.10.9", "source": { "type": "git", "url": "https://github.com/pear/pear-core-minimal.git", - "reference": "19a3e0fcd50492c4357372f623f55f1b144346da" + "reference": "742be8dd68c746a01e4b0a422258e9c9cae1c37f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/19a3e0fcd50492c4357372f623f55f1b144346da", - "reference": "19a3e0fcd50492c4357372f623f55f1b144346da", + "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/742be8dd68c746a01e4b0a422258e9c9cae1c37f", + "reference": "742be8dd68c746a01e4b0a422258e9c9cae1c37f", "shasum": "" }, "require": { @@ -862,7 +801,7 @@ } ], "description": "Minimal set of PEAR core files to be used as composer dependency", - "time": "2018-12-05T20:03:52+00:00" + "time": "2019-03-13T18:15:44+00:00" }, { "name": "pear/pear_exception", @@ -1017,6 +956,130 @@ "psr" ], "time": "2018-12-29T15:36:03+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "twig/twig", + "version": "1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "a482da9fd0a0c00f7d8d6eb810538f9a02f1d08a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a482da9fd0a0c00f7d8d6eb810538f9a02f1d08a", + "reference": "a482da9fd0a0c00f7d8d6eb810538f9a02f1d08a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/debug": "^2.7", + "symfony/phpunit-bridge": "^3.4.19|^4.1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.38-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + }, + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://twig.symfony.com/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "time": "2019-03-14T13:57:20+00:00" } ], "packages-dev": [ @@ -2167,64 +2230,6 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-06-21T13:59:46+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "backendtea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-02-06T07:57:58+00:00" - }, { "name": "symfony/yaml", "version": "3.4.x-dev", @@ -2343,8 +2348,7 @@ "andy128k/missing-tools": 20, "andy128k/migrations": 20, "andy128k/pegp": 20, - "andy128k/routeexpression": 20, - "andy128k/ipf-legacy-template": 20 + "andy128k/routeexpression": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/ipf/admin/app.php b/ipf/admin/app.php index ab04895..50ac73b 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -1,7 +1,6 @@ IPF::version(), 'admin_title' => IPF::get('admin_title'), - 'app_list' => F::bind(array($this, 'appList'), $request), + 'app_list' => $this->appList($request), ); } diff --git a/ipf/admin/component.php b/ipf/admin/component.php index 272ee74..73677a4 100644 --- a/ipf/admin/component.php +++ b/ipf/admin/component.php @@ -127,22 +127,22 @@ abstract class IPF_Admin_Component public function listTemplate() { - return 'admin/items.html'; + return 'admin/items.html.twig'; } public function addTemplate() { - return 'admin/change.html'; + return 'admin/change.html.twig'; } public function editTemplate() { - return 'admin/change.html'; + return 'admin/change.html.twig'; } public function deleteTemplate() { - return 'admin/delete.html'; + return 'admin/delete.html.twig'; } protected function extraMedia($form) diff --git a/ipf/admin/controllers/base.php b/ipf/admin/controllers/base.php index 796109b..77efb17 100644 --- a/ipf/admin/controllers/base.php +++ b/ipf/admin/controllers/base.php @@ -13,7 +13,7 @@ abstract class IPF_Admin_Base_Controller extends IPF_Controller protected function render($template, $params) { - return IPF_Shortcuts::RenderToResponse($template, $params, $this->request); + return new IPF_HTTP_Response(IPF_Twig::render($template, $params, $this->request)); } /** diff --git a/ipf/admin/controllers/dashboard.php b/ipf/admin/controllers/dashboard.php index 35d514b..89462f2 100644 --- a/ipf/admin/controllers/dashboard.php +++ b/ipf/admin/controllers/dashboard.php @@ -18,7 +18,7 @@ class IPF_Admin_Dashboard_Controller extends IPF_Admin_Base_Controller 'page_title' => __('Site Administration'), 'admin_log' => $this->adminLog()->recent(), ); - return $this->render('admin/index.html', $context); + return $this->render('admin/index.html.twig', $context); } function log() @@ -40,6 +40,6 @@ class IPF_Admin_Dashboard_Controller extends IPF_Admin_Base_Controller 'current_page' => $currentPage, 'pages' => $pages, ); - return $this->render('admin/log.html', $context); + return $this->render('admin/log.html.twig', $context); } } diff --git a/ipf/admin/controllers/file_browser.php b/ipf/admin/controllers/file_browser.php index 5fad612..342509d 100644 --- a/ipf/admin/controllers/file_browser.php +++ b/ipf/admin/controllers/file_browser.php @@ -131,7 +131,7 @@ class IPF_Admin_FileBrowser_Controller extends IPF_Admin_Base_Controller 'curr_dir' => $this->relative, 'parent_dir' => $parent_dir, ); - return $this->render('admin/filebrowser.html', $context); + return $this->render('admin/filebrowser.html.twig', $context); } protected function backToIndex() diff --git a/ipf/admin/controllers/user.php b/ipf/admin/controllers/user.php index 8a56139..4f3e8f9 100644 --- a/ipf/admin/controllers/user.php +++ b/ipf/admin/controllers/user.php @@ -36,7 +36,7 @@ class IPF_Admin_User_Controller extends IPF_Admin_Base_Controller 'page_title' => IPF::get('admin_title'), 'form' => $form, ); - return $this->render('admin/login.html', $context); + return $this->render('admin/login.html.twig', $context); } function logout() @@ -45,7 +45,7 @@ class IPF_Admin_User_Controller extends IPF_Admin_Base_Controller $context = array( 'page_title' => IPF::get('admin_title'), ); - return $this->render('admin/logout.html', $context); + return $this->render('admin/logout.html.twig', $context); } function impersonate() diff --git a/ipf/admin/templates/admin/base.html b/ipf/admin/templates/admin/base.html deleted file mode 100644 index d4dee94..0000000 --- a/ipf/admin/templates/admin/base.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - {block css} - - - {/block} - {$page_title} - - - - -
-
- {block sidebar_toggle} - - - {/block} - - - {block usertools} -
- {trans 'Welcome'}, {$user}. {trans 'Log out'}
- Version: {$IPF_VER} -
- {/block} -
- {block navigation} - - {/block} - {block content}{/block} - -
- -{block commonjs} - -{/block} -{block scripts}{/block} - - - diff --git a/ipf/admin/templates/admin/base.html.twig b/ipf/admin/templates/admin/base.html.twig new file mode 100644 index 0000000..ce523eb --- /dev/null +++ b/ipf/admin/templates/admin/base.html.twig @@ -0,0 +1,71 @@ + + + + + {% block css %} + + + {% endblock %} + {{ page_title }} + + + + +
+
+ {% block sidebar_toggle %} + + + {% endblock %} + + + {% block usertools %} +
+ {{ trans('Welcome') }}, {{ user }}. {{ trans('Log out') }}
+ Version: {{ IPF_VER }} +
+ {% endblock %} +
+ {% block navigation %} + + {% endblock %} + {% block content %}{% endblock %} + +
+ +{% block commonjs %} + +{% endblock %} +{% block scripts %}{% endblock %} + + diff --git a/ipf/admin/templates/admin/change.html b/ipf/admin/templates/admin/change.html deleted file mode 100644 index 2126e49..0000000 --- a/ipf/admin/templates/admin/change.html +++ /dev/null @@ -1,64 +0,0 @@ -{extends "admin/base.html"} - -{block css} -{superblock} -{foreach $extra_css as $css} -{$css|safe} -{/foreach} -{/block} - -{block breadcrumbs} - -{/block} - -{block content} -
-

{$page_title}

-
- -
- -
- {if $errors} -

Please correct the error below.

- {/if} -
- {block form} - {$form_html|safe} - {/block} -
-
- {if ($mode=='change') && $can_delete}

{trans 'Delete'}

{/if} - {if ($mode=='change') && $can_change}{/if} - {if ($mode=='add') && $can_add}{/if} - -
-
-
-
-
-
-{/block} - -{block scripts} -{foreach $extra_js as $js} -{$js|safe} -{/foreach} -{/block} - diff --git a/ipf/admin/templates/admin/change.html.twig b/ipf/admin/templates/admin/change.html.twig new file mode 100644 index 0000000..a8ddc2e --- /dev/null +++ b/ipf/admin/templates/admin/change.html.twig @@ -0,0 +1,63 @@ +{% extends "admin/base.html.twig" %} + +{% block css %} +{{ parent() }} +{% for css in extra_css %} +{{ css|raw }} +{% endfor %} +{% endblock %} + +{% block breadcrumbs %} + +{% endblock %} + +{% block content %} +
+

{{ page_title }}

+
+
    + {% block objecttools %} + {% for ot_index, ot_action in objecttools %} +
  • + {% if ot_action.method == 'POST' %} +
    {{ ot_action.title }}
    + {% else %} + {{ ot_action.title }} + {% endif %} +
  • + {% endfor %} + {% endblock %} +
+
+ +
+ {% if errors %} +

Please correct the error below.

+ {% endif %} +
+ {% block form %} + {{ form_html|raw }} + {% endblock %} +
+
+ {% if mode == 'change' and can_delete %}

{{ trans('Delete') }}

{% endif %} + {% if mode == 'change' and can_change %}{% endif %} + {% if mode == 'add' and can_add %}{% endif %} + +
+
+
+
+
+
+{% endblock %} + +{% block scripts %} +{% for js in extra_js %} +{{ js|raw }} +{% endfor %} +{% endblock %} diff --git a/ipf/admin/templates/admin/delete.html b/ipf/admin/templates/admin/delete.html deleted file mode 100644 index d73ae97..0000000 --- a/ipf/admin/templates/admin/delete.html +++ /dev/null @@ -1,23 +0,0 @@ -{extends "admin/base.html"} - -{block breadcrumbs} - -{/block} - -{block content} -
-

{$page_title}

-
- -

Are you sure you want to delete {$object}?

- - -
-
-{/block} - diff --git a/ipf/admin/templates/admin/delete.html.twig b/ipf/admin/templates/admin/delete.html.twig new file mode 100644 index 0000000..3181caf --- /dev/null +++ b/ipf/admin/templates/admin/delete.html.twig @@ -0,0 +1,22 @@ +{% extends "admin/base.html.twig" %} + +{% block breadcrumbs %} + +{% endblock %} + +{% block content %} +
+

{{ page_title }}

+
+ +

Are you sure you want to delete {{ object }}?

+ + +
+
+{% endblock %} diff --git a/ipf/admin/templates/admin/filebrowser.html b/ipf/admin/templates/admin/filebrowser.html.twig similarity index 54% rename from ipf/admin/templates/admin/filebrowser.html rename to ipf/admin/templates/admin/filebrowser.html.twig index a50f5c0..905a2ad 100644 --- a/ipf/admin/templates/admin/filebrowser.html +++ b/ipf/admin/templates/admin/filebrowser.html.twig @@ -3,10 +3,9 @@ - - + + - {$page_title} - IPF Administration + {{ page_title }} - IPF Administration - {assign $zero_gif = "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="} + {% set zero_gif = "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" %}
@@ -87,10 +85,10 @@
@@ -104,47 +102,47 @@ - {if $curr_dir} + {% if curr_dir %} - .. + .. UP-DIR - {/if} - {foreach $dirs as $dir} + {% endif %} + {% for dir in dirs %} - {$dir['name']} + {{ dir.name }} SUB-DIR -
- - + + +
- {/foreach} - {foreach $files as $file} - - {$file['name']} - {$file['info']} - {$file['size']} + {% endfor %} + {% for file in files %} + + {{ file.name }} + {{ file.info }} + {{ file.size }} -
- - + + +
- {/foreach} + {% endfor %}
-
+
@@ -153,7 +151,6 @@
- + - diff --git a/ipf/admin/templates/admin/index.html b/ipf/admin/templates/admin/index.html deleted file mode 100644 index 88f673b..0000000 --- a/ipf/admin/templates/admin/index.html +++ /dev/null @@ -1,48 +0,0 @@ -{extends "admin/base.html"} - -{block sidebar_toggle}{/block} -{block navigation}{/block} - -{block content} -
-

{$page_title}

-
- {foreach $app_list() as $app} -
- - - - {foreach $app.components as $component} - - - - - - {/foreach} - -
{$app.name|escxml}
{$component->name}{if $component->can_add}{trans 'Add'}{/if}{trans 'Change'}
-
- {/foreach} -
- -
-
-{/block} - diff --git a/ipf/admin/templates/admin/index.html.twig b/ipf/admin/templates/admin/index.html.twig new file mode 100644 index 0000000..bfc9f59 --- /dev/null +++ b/ipf/admin/templates/admin/index.html.twig @@ -0,0 +1,47 @@ +{% extends "admin/base.html.twig" %} + +{% block sidebar_toggle %}{% endblock %} +{% block navigation %}{% endblock %} + +{% block content %} +
+

{{ page_title }}

+
+ {% for app in app_list %} +
+ + + + {% for component in app.components %} + + + + + + {% endfor %} + +
{{ app.name }}
{{ component.name }}{% if component.can_add %}{{ trans('Add') }}{% endif %}{{ trans('Change') }}
+
+ {% endfor %} +
+ +
+
+{% endblock %} diff --git a/ipf/admin/templates/admin/items.html b/ipf/admin/templates/admin/items.html deleted file mode 100644 index 6b48a6d..0000000 --- a/ipf/admin/templates/admin/items.html +++ /dev/null @@ -1,90 +0,0 @@ -{extends "admin/base.html"} - -{block breadcrumbs}{/block} - -{block content} -
-

{$page_title}

-
- -
- {if $is_search} -
- -
- {/if} - - {if $filters} -
-

Filter

- {foreach $filters as $f} -

{$f->title()}

- {$component->renderFilter($f)|safe} - {/foreach} -
- {/if} - -
- {block table} - - - - {foreach $header as $h} - - {/foreach} - - - - {foreach $rows as $row} - - {foreach $row['cells'] as $cell} - - {/foreach} - - {/foreach} - -
{$h['title']}
{$cell|safe}
- {/block} -

- {foreach $pages as $p} - {if $p} - {if $p == $current_page} - {$p} - {else} - {$p} - {/if} - {else} - … - {/if} - {/foreach} - {$count} record(s) of {$classname} -

-
- -
-
-
-
-{/block} - diff --git a/ipf/admin/templates/admin/items.html.twig b/ipf/admin/templates/admin/items.html.twig new file mode 100644 index 0000000..233cccf --- /dev/null +++ b/ipf/admin/templates/admin/items.html.twig @@ -0,0 +1,89 @@ +{% extends "admin/base.html.twig" %} + +{% block breadcrumbs %}{% endblock %} + +{% block content %} +
+

{{ page_title }}

+
+ +
+ {% if is_search %} +
+ +
+ {% endif %} + + {% if filters %} +
+

Filter

+ {% for f in filters %} +

{{ f.title }}

+ {{ component.renderFilter(f)|raw }} + {% endfor %} +
+ {% endif %} + +
+ {% block table %} + + + + {% for h in header %} + + {% endfor %} + + + + {% for row in rows %} + + {% for cell in row.cells %} + + {% endfor %} + + {% endfor %} + +
{{ h.title }}
{{ cell|raw }}
+ {% endblock %} +

+ {% for p in pages %} + {% if p %} + {% if p == current_page %} + {{ p }} + {% else %} + {{ p }} + {% endif %} + {% else %} + … + {% endif %} + {% endfor %} + {{ count }} record(s) of {{ classname }} +

+
+ +
+
+
+
+{% endblock %} diff --git a/ipf/admin/templates/admin/log.html b/ipf/admin/templates/admin/log.html deleted file mode 100644 index 74f7413..0000000 --- a/ipf/admin/templates/admin/log.html +++ /dev/null @@ -1,60 +0,0 @@ -{extends "admin/base.html"} - -{block breadcrumbs}{/block} - -{block content} -
-

{$page_title}

-
-
- -
- - - - - - - - - - - {foreach $admin_log as $log} - - - - - - - {/foreach} - -
{trans 'Action'}{trans 'Type'}{trans 'When'}{trans 'Who'}
{$log.object_class}{$log.created_at|datetime:'%b %e, %Y %H:%M:%S'}{$log.username}
- -

- {foreach $pages as $p} - {if $p} - {if $p == $current_page} - {$p} - {else} - {$p} - {/if} - {else} - … - {/if} - {/foreach} - {$count} log records -

-
- -
-
-
-
-{/block} - diff --git a/ipf/admin/templates/admin/log.html.twig b/ipf/admin/templates/admin/log.html.twig new file mode 100644 index 0000000..59e05fd --- /dev/null +++ b/ipf/admin/templates/admin/log.html.twig @@ -0,0 +1,59 @@ +{% extends "admin/base.html.twig" %} + +{% block breadcrumbs %}{% endblock %} + +{% block content %} +
+

{{ page_title }}

+
+
+ +
+ + + + + + + + + + + {% for log in admin_log %} + + + + + + + {% endfor %} + +
{{ trans('Action') }}{{ trans('Type') }}{{ trans('When') }}{{ trans('Who') }}
{{ log.object_class }}{{ log.created_at|date('M j, Y H:i:s') }}{{ log.username }}
+ +

+ {% for p in pages %} + {% if p %} + {% if p == current_page %} + {{ p }} + {% else %} + {{ p }} + {% endif %} + {% else %} + … + {% endif %} + {% endfor %} + {{ count }} log records +

+
+ +
+
+
+
+{% endblock %} diff --git a/ipf/admin/templates/admin/login.html b/ipf/admin/templates/admin/login.html.twig similarity index 54% rename from ipf/admin/templates/admin/login.html rename to ipf/admin/templates/admin/login.html.twig index 674eea0..7069466 100644 --- a/ipf/admin/templates/admin/login.html +++ b/ipf/admin/templates/admin/login.html.twig @@ -2,20 +2,20 @@ - {block css} - - {/block} - {$page_title} + {% block css %} + + {% endblock %} + {{ page_title }}
-

{$admin_title}

+

{{ admin_title }}

- {$form->render()|safe} + {{ form.render()|raw }}
@@ -24,4 +24,3 @@ - diff --git a/ipf/admin/templates/admin/logout.html b/ipf/admin/templates/admin/logout.html deleted file mode 100644 index bb2eda2..0000000 --- a/ipf/admin/templates/admin/logout.html +++ /dev/null @@ -1,14 +0,0 @@ -{extends 'admin/base.html'} - -{block sidebar_toggle}{/block} -{block navigation}{/block} - -{block content} -
-

Logged out

-

Thanks for spending some quality time with the Web site today.

-

Log in again.

-
-
-{/block} - diff --git a/ipf/admin/templates/admin/logout.html.twig b/ipf/admin/templates/admin/logout.html.twig new file mode 100644 index 0000000..263a137 --- /dev/null +++ b/ipf/admin/templates/admin/logout.html.twig @@ -0,0 +1,13 @@ +{% extends 'admin/base.html.twig' %} + +{% block sidebar_toggle %}{% endblock %} +{% block navigation %}{% endblock %} + +{% block content %} +
+

Logged out

+

Thanks for spending some quality time with the Web site today.

+

Log in again.

+
+
+{% endblock %} diff --git a/ipf/project_template.php b/ipf/project_template.php index 1d406bd..3cbb43d 100644 --- a/ipf/project_template.php +++ b/ipf/project_template.php @@ -94,4 +94,3 @@ final class IPF_Project_Template return IPF_HTTP_URL::generateParams($params); } } - diff --git a/ipf/twig.php b/ipf/twig.php new file mode 100644 index 0000000..e68b6a2 --- /dev/null +++ b/ipf/twig.php @@ -0,0 +1,46 @@ +loadTemplate($tplfile); + return $template->render($context); + } + + private static function createEnvironment() + { + $options = array( + 'cache' => IPF::get('tmp'), + ); + if (IPF::get('debug')) { + $options['debug'] = true; + $options['auto_reload'] = true; + } + + $twig = new Twig_Environment(self::createLoader(), $options); + + $twig->addFunction(new Twig_SimpleFunction('url', function() { + return IPF_Project_Template::urlTag(func_get_args()); + })); + $twig->addFunction(new Twig_SimpleFunction('params', function() { + return IPF_Project_Template::paramsTag(func_get_args()); + })); + $twig->addFunction(new Twig_SimpleFunction('trans', function($str) { + return __($str); + })); + + return $twig; + } + + private static function createLoader() + { + $loader = new Twig_Loader_Filesystem(array()); + foreach (IPF_Project_Template::templateDirs() as $dir) { + $loader->addPath($dir); + } + return $loader; + } +} -- 2.49.0