1 | <?php |
||
10 | abstract class ExtensionsAbstract |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Load functions that will be used in the templates |
||
15 | */ |
||
16 | 9 | protected function loadFunctions() |
|
27 | |||
28 | /** |
||
29 | * Load extensions of templating engines |
||
30 | */ |
||
31 | protected function loadExtensions() { } |
||
32 | |||
33 | /** |
||
34 | * Extend for function _t that translates using defined global lang variable |
||
35 | * $lang = ['name' => 'Selami'] |
||
36 | * {{ _t('Hello @name',lang) }} produces Hello Selami |
||
37 | */ |
||
38 | protected function extendForTranslation() { } |
||
39 | |||
40 | /** |
||
41 | * Extend for function getUrl that returns url path for an alias. |
||
42 | * |
||
43 | * Let's say $aliases = ['home' => '/', 'about' => '/about-us'] |
||
44 | * and $baseUrl = 'http://127.0.0.1'; |
||
45 | * {{ getUrl('about') }} produces http://127.0.0.1/about-us |
||
46 | * |
||
47 | * If returned alias value has parametric strings, you can pass the values of these parameters. |
||
48 | * Let's say $aliases = ['home' => '/', 'about' => '/{lang}/about-us'] |
||
49 | * and $baseUrl = 'http://127.0.0.1' and $page_lang = 'en_US' |
||
50 | * {{ getUrl('about', {'lang': page_lang}) }} produces http://127.0.0.1/en_US/about-us |
||
51 | */ |
||
52 | protected function extendForGetUrl(){ } |
||
53 | |||
54 | /** |
||
55 | * Extend for wildcard Widget functions. Widget function determines the class and method that will be called. |
||
56 | * For example {{Widget_menu_top({'param':2})}} acts like this anonymous function: |
||
57 | * (function(){ |
||
58 | * $Widget = new Widget\Menu(); |
||
59 | * $WidgetContent = $Widget->top(['param' => 2]); |
||
60 | * } |
||
61 | * )(); |
||
62 | */ |
||
63 | protected function extendForWidget() { } |
||
64 | |||
65 | /** |
||
66 | * Extend for queryParams function that returns http_build_query result using passed parameters. |
||
67 | * $prefix = '?'; |
||
68 | * {{ queryParams({'param1':1,'param2':2}, $prefix) }} returns ?param1=1¶m2=2 |
||
69 | * |
||
70 | */ |
||
71 | protected function extendForQueryParams() { } |
||
72 | |||
73 | /** |
||
74 | * Extend for function siteUrl that returns defined baseUrl of the site |
||
75 | * Let's say $baseUrl = 'http://127.0.0.1'; |
||
76 | * {{ siteUrl('/home') }} produces http://127.0.0.1/home |
||
77 | */ |
||
78 | protected function extendForSiteUrl() { } |
||
79 | |||
80 | /** |
||
81 | * Extend for function varDump. Just outputs var_dump of passed parameter. |
||
82 | * |
||
83 | * Use it for debugging purposes. |
||
84 | * |
||
85 | */ |
||
86 | protected function extendForVarDump() { } |
||
87 | |||
88 | /** |
||
89 | * Extend for function Pagination. This function builds pagination html. |
||
90 | * Example: |
||
91 | * $total_number_of_pages = 20; // Mandatory |
||
92 | * $current_page = 2; // Mandatory. Starts from 1; |
||
93 | * $link_template = '/list?page_num=(page_id)'; // Mandatory. Use "(page_id)" string to replace page number. |
||
94 | * $parentTemplate = '<ul class="pagination">(items)</ul>'; // Optional. This is also default value. |
||
95 | * Use '(item)' string to place generated item htmls. |
||
96 | * $itemTemplate = '<li class="(item_class)">(link)</li>'; // Optional. This is also default value. |
||
97 | * Use '(item_class)' string where "active" class will be placed when the page is current page. |
||
98 | * Use '(link)' string to place generated link html. |
||
99 | * $linkItemTemplate = '<a href="(href)" class="(link_class)">(text)</a>'; // Optional. This is also default value. |
||
100 | * '(href)' string is mandatory. generated link uri will be placed. |
||
101 | * '(link_class)' string is optional. "active" class will be placed when it is current page. |
||
102 | * '(text)' string is mandatory. Page number will be placed. |
||
103 | * $ellipsesTemplate = '<li><a>...</a></li>'; // Optional. This is also default value. |
||
104 | * |
||
105 | * {{ Pagination($total_number_of_pages, $current_page, $link_template, $parentTemplate, $linkItemTemplate, |
||
106 | * $ellipsesTemplate) }} |
||
107 | * or you can use with default values: |
||
108 | * {{ Pagination($total_number_of_pages, $current_page, $link_template) }} |
||
109 | * This returns following html. |
||
110 | * <ul class="pagination"> |
||
111 | * <li class=""><a href="/list?page_num=1" class="">1</a></li> |
||
112 | * <li class="active"><a href="/list?page_num=2" class="active">2</a></li> |
||
113 | * <li><a href="/list?page_num=3" class="">3</a></li> |
||
114 | * <li><a href="/list?page_num=4" class="">4</a></li> |
||
115 | * <li><a href="/list?page_num=5" class="">5</a></li> |
||
116 | * <li><a>...</a></li> |
||
117 | * <li><a href="/list?page_num=18" class="">3</a></li> |
||
118 | * <li><a href="/list?page_num=19" class="">3</a></li> |
||
119 | * <li><a href="/list?page_num=20" class="">3</a></li> |
||
120 | * </ul> |
||
121 | */ |
||
122 | protected function extendForPagination() { } |
||
123 | } |
||
124 |