Subversion Repositories bysoftdeveloper

[/] [modules/] [bysoftdeveloper/] [template.php] - Blame information for rev 31

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1 cavin.deng
<?php
2
 
3
//
4
// @author cavin.deng
5
//
6
include_once( "kernel/common/template.php" );
7
 
8
// disable all debug
9
$ini = eZINI::instance();
10
//$ini->setVariable('TemplateSettings', 'Bug', 'disabled');
11
//$ini->setVariable('TemplateSettings', 'TemplateCache', 'enabled');
12
//$ini->setVariable('TemplateSettings', 'TemplateCompile', 'enabled');
13
//$ini->setVariable('TemplateSettings', 'ShowUsedTemplates', 'disabled');
14
 
15
 
16
// turn off debug for this page
17
$settings = array(
18
        'debug-enabled' =>  FALSE,
19
    'debug-by-ip' => FALSE,
20
);
21
 
22
eZDebug::updateSettings($settings);
23
 
24
$tpl = templateInit();
25
 
26 23 cavin.deng
function findClassPathByName($className)
27
{
28
    static $ezpClasses = null;
29
 
30
    if ($ezpClasses === null) {
31
        $ezRoot = '';
32
        $ezpKernelClasses = require $ezRoot . 'autoload/ezp_kernel.php';
33
        $ezpExtensionClasses = false;
34
 
35
        if (file_exists($ezRoot . 'var/autoload/ezp_extension.php')) {
36
            $ezpExtensionClasses = require $ezRoot . 'var/autoload/ezp_extension.php';
37
        }
38
 
39
        if ($ezpExtensionClasses) {
40
            $ezpClasses = array_merge($ezpKernelClasses, $ezpExtensionClasses);
41
        }
42
 
43
        if (defined('EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE') and EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE) {
44
            if ($ezpKernelOverrideClasses = include $ezRoot . 'var/autoload/ezp_override.php') {
45
                $ezpClasses = array_merge($ezpClasses, $ezpKernelOverrideClasses);
46
            }
47
        }
48
    }
49
 
50
    if (isset($ezpClasses[$className])) {
51
        return $ezpClasses[$className];
52
    }
53
}
54
 
55 1 cavin.deng
function adjustPath($path) {
56
    // cavin.deng add these two variables
57
    $isWin = (substr(PHP_OS, 0, 3) == 'WIN') ? 1 : 0;
58
    $siteDir = eZSys::siteDir();
59
 
60
    $path = str_replace('\\', '/', $siteDir . $path );
61
    $path = str_replace('//', '/', $path);
62
    if ($isWin) {
63
        $path = str_replace('/', '\\\\', $path);
64
    }
65
    return $path;
66
}
67
 
68
function cmpStrlen($a, $b){
69
    $lenA = strlen($a);
70
    $lenB = strlen($b);
71
    if ($lenA == $lenB) {
72
        return strcasecmp($a, $b);
73
    }
74
    return ($lenA - $lenB);
75
}
76
 
77
$templateFuncAttrs = $tpl->FunctionAttributes;
78
 
79
///// operator
80
$templateOperators = array();
81
 
82
$operatorClassToNameMaps = array(
83
    'eZTemplateArrayOperator' => 'Arrays',
84
    'eZTemplateExecuteOperator' => 'Data and information extraction',
85
    'eZTemplateLocaleOperator' => 'Formatting and internationalization',
86
    'eZTemplateAttributeOperator' => 'Miscellaneous',
87
    'eZTemplateNl2BrOperator' => 'Strings',
88
    'eZTemplateTextOperator' => 'Strings',
89
    'eZTemplateUnitOperator' => 'Formatting and internationalization',
90
    'eZTemplateLogicOperator' => 'Logical operations',
91
    'eZTemplateTypeOperator' => 'Variable and type handling',
92
    'eZTemplateControlOperator' => 'Logical operations',
93
    'eZTemplateArithmeticOperator' => 'Mathematics',
94
    'eZTemplateImageOperator' => 'Images',
95
    'eZTemplateStringOperator' => 'Strings',
96
    'eZTemplateDigestOperator' => 'Strings',
97
    'eZURLOperator' => 'URLs',
98
    'eZI18nOperator' => 'Formatting and internationalization',
99
    'eZAlphabetOperator' => 'Strings',
100
    'eZDateOperatorCollection' => 'Miscellaneous',
101
    'eZAutoLinkOperator' => 'Strings',
102
    'eZSimpleTagsOperator' => 'Strings',
103
    'eZTreeMenuOperator' => 'Miscellaneous',
104
    'eZContentStructureTreeOperator' => 'Miscellaneous',
105
    'eZWordToImageOperator' => 'Miscellaneous',
106
    'eZKernelOperator' => 'Data and information extraction',
107
    'eZPHPOperatorInit' => 'Miscellaneous',
108
    'eZModuleParamsOperator' => 'Data and information extraction',
109
    'eZTopMenuOperator' => 'Miscellaneous',
110
    'eZPackageOperator' => 'Miscellaneous',
111
    'eZTOCOperator' => 'Miscellaneous',
112
    'eZModuleOperator' => 'Miscellaneous',
113
    'eZPDF' => 'Miscellaneous',
114
    'ezpLanguageSwitcherOperator' => 'Miscellaneous',
115
);
116
 
117
foreach ($tpl->Operators as $operator => $info) {
118
    $info['path'] = adjustPath($info['script']);
119
    $info['name'] = $operator;
120
    if (substr($operator , 0, 2) != '__') {
121 23 cavin.deng
        if (isset($info['class'])) {
122
            $info['path'] = adjustPath(findClassPathByName($info['class']));
123
        } else {
124
 
125
        }
126 1 cavin.deng
        // cateogrized
127
        if (array_key_exists($info['class'],$operatorClassToNameMaps)) {
128
            $templateOperators[$operatorClassToNameMaps[$info['class']]][$operator] = $info;
129
        } else {
130
            if ('extension' == substr($info['script'], 0, 9)) {
131
                // extension operators
132
                $templateOperators['XExtension Operator'][$operator] = $info;
133
            } else {
134
                $templateOperators['Miscellaneous'][$operator] = $info;
135
            }
136
        }
137
    }
138
}
139
 
140
// used by developer only
141
$tpl->Operators['array_intel'] = array(
142
    'script' => 'extension/bysoftdeveloper/kernel/eztemplatesstatisticsreporter.php',
143
    'class' => 'eZTemplatesStatisticsReporter',
144
    'operator_names' => array('array_intel','variables')
145
);
146
 
147
///// functions
148
$templateFunctions = array();
149
$functionClassToNameMaps = array(
150
        'eZTemplateSectionFunction' => 'Miscellaneous',
151
    'eZTemplateDelimitFunction' => 'Miscellaneous',
152
    'eZTemplateIncludeFunction' => 'Miscellaneous',
153
    'eZTemplateSwitchFunction' => 'Miscellaneous',
154
    'eZTemplateSequenceFunction' => 'Variables',
155
    'eZTemplateSetFunction' => 'Variables',
156
    'eZTemplateBlockFunction' => 'Variables',
157
    'eZTemplateDebugFunction' => 'Debugging',
158
    'eZTemplateCacheFunction' => 'Miscellaneous',
159
    'eZTemplateToolbarFunction' => 'Visualization',
160
    'eZTemplateMenuFunction' => 'Miscellaneous',
161
    'eZTemplateIfFunction' => 'Miscellaneous',
162
    'eZTemplateWhileFunction' => 'Miscellaneous',
163
    'eZTemplateForFunction' => 'Miscellaneous',
164
    'eZTemplateForeachFunction' => 'Miscellaneous',
165
    'eZTemplateDoFunction' => 'Miscellaneous',
166
    'eZTemplateDefFunction' => 'Miscellaneous',
167
    'eZObjectForwardInit' => 'Miscellaneous',
168
);
169
$functionFuncNameToNameMaps = array(
170
    'eZObjectForwardInit' => 'Visualization',
171
    'eZSurveyForwardInit' => 'Visualization'
172
);
173
foreach ($tpl->Functions as $fun => $info) {
174
    if (!isset($info['script'])) {
175
        if ($info['function'] == 'eZObjectForwardInit') {
176 23 cavin.deng
            $info['script'] = adjustPath('kernel/common/eztemplateautoload.php');
177 1 cavin.deng
        }
178
        if ($info['function'] == 'eZSurveyForwardInit') {
179 23 cavin.deng
            $info['script'] = adjustPath('extension/ezsurvey/autoloads/eztemplateautoload.php');
180 1 cavin.deng
        }
181
    }
182 23 cavin.deng
    if (isset($info['class'])) {
183
        $info['path'] =  adjustPath(findClassPathByName($info['class']));
184
    } else {
185
        $info['path'] = '';
186
    }
187 1 cavin.deng
    $info['name'] = $fun;
188
    if (array_key_exists($info['class'], $functionClassToNameMaps)) {
189
        $templateFunctions[$functionClassToNameMaps[$info['class']]][$fun] = $info;
190
    } else {
191
        if (array_key_exists($info['function'], $functionFuncNameToNameMaps)) {
192
            $templateFunctions[$functionFuncNameToNameMaps[$info['function']]][$fun] = $info;
193
        } else {
194
            if ('extension' == substr($info['script'], 0, 9)) {
195
                $templateFunctions['XExtension Functions'][$fun] = $info;
196
            } else {
197
                $templateFunctions['Miscellaneous'][$fun] = $info;
198
            }
199
        }
200
    }
201
}
202
 
203
///// function attributes
204
$templateFuncAttrs = array();
205
foreach ($tpl->FunctionAttributes as $attr => $info){
206 23 cavin.deng
    if (isset($info['class'])) {
207
        $info['path'] =  adjustPath(findClassPathByName($info['class']));
208
    } else {
209
        $info['path'] = '';
210
    }
211 1 cavin.deng
    $info['name'] = $attr;
212
    $templateFuncAttrs[$attr] = $info;
213
}
214
 
215
 
216
// sort operators.
217
foreach ($templateOperators as $category => &$ops) {
218
    uksort($ops, 'cmpStrlen');
219
}
220
 
221
// sort functions
222
foreach ($templateFunctions as $category => &$func) {
223
    uksort($func, 'cmpStrlen');
224
}
225
 
226
 
227
$tpl->setVariable('template_operators', $templateOperators);
228
$tpl->setVariable('template_functions', $templateFunctions);
229
$tpl->setVariable('template_funcattrs', $templateFuncAttrs);
230
 
231
$Result = array();
232
$Result['content'] = $tpl->fetch( 'design:bysoftdeveloper/template.tpl' );
233
 
234
$Result['path'] = array(    array('url' => false,
235 31 alvawu
                                              'text' => 'Import'),
236 1 cavin.deng
                                        array('url' => false,
237 31 alvawu
                                              'text' => 'CSV' )
238 1 cavin.deng
                                               );
239
 
240
$Result['pagelayout'] = '';                                            
241 23 cavin.deng
?>