1 <?xml version="1.0" encoding="UTF-8"?>
3 <!-- ============================================ -->
4 <!-- Build Definition for Tine 2.0 -->
6 <!-- http://www.tine20.org -->
7 <!-- http://www.phing.info -->
8 <!-- ============================================ -->
9 <project name="tine20" description="Tine 2.0 build file" default="build">
11 <property name="builddir" value="${project.basedir}/build" override="true" />
12 <property name="userdatadir" value="${project.basedir}/userdata" override="true" />
13 <property name="localedir" value="Tinebase/js/Locale" override="true" />
14 <property name="configdir" value="${project.basedir}" override="true" />
15 <property name="testconfigdir" value="${project.basedir}/../tests/tine20" override="true" />
17 <!-- ============================================ -->
18 <!-- Target: prepare -->
19 <!-- ============================================ -->
20 <target name="prepare">
21 <echo msg="basedir: ${project.basedir}" />
24 <php expression="Tinebase_Helper::getDevelopmentRevision();" returnProperty="buildRevision" />
25 <echo msg="$buildRevision: ${buildRevision}" />
27 <php expression="date_create('now')->format('Y-m-d H:i:s');" returnProperty="buildDate" />
28 <echo msg="$buildDate: ${buildDate}" />
30 <echo msg="Making build directory" />
31 <mkdir dir="${builddir}" />
32 <mkdir dir="${builddir}/${localedir}/build" />
33 <mkdir dir="${builddir}/${localedir}/static" />
36 <!-- ============================================ -->
37 <!-- Target: build -->
38 <!-- ============================================ -->
39 <target name="build" depends="prepare">
40 <foreach param="name" absparam="path" target="prepared-build-module">
45 <exclude name="*.*" />
46 <exclude name=".tx" />
47 <exclude name="build" />
48 <exclude name="docs" />
49 <exclude name="fonts" />
50 <exclude name="images" />
51 <exclude name="library" />
52 <exclude name="styles" />
53 <exclude name="themes" />
54 <exclude name="vendor" />
55 <exclude name="userdata" />
56 <exclude name="Tool" />
57 <exclude name="Zend" />
62 <!-- ============================================ -->
63 <!-- Target: phpdoc -->
64 <!-- ============================================ -->
65 <target name="phpdoc">
66 <echo msg="Building Tine 2.0 PHP API Documentation..." />
68 <includepath classpath="${project.basedir}/vendor/phpdocumentor" />
70 <mkdir dir="${builddir}/apidocs" />
72 <phpdoc2 title="Tine 2.0 PHP API Documentation" destdir="${builddir}/apidocs" template="responsive-twig">
74 <include name="**/*.php" />
75 <exclude name="Zend/**.php" />
76 <exclude name="library/**.php" />
77 <exclude name="vendor/**.php" />
82 <!-- ============================================ -->
83 <!-- Target: phpunit -->
85 <!-- you can define the includes like this (runs all Tinebase tests): -->
86 <!-- $ vendor/bin/phing phpunit -Dtestinclude=Tinebase/**/*Test.php -->
87 <!-- ============================================ -->
88 <target name="phpunit">
89 <!-- TODO we still have some test files that are named *Tests.php, rename them or adjust the include property -->
90 <property name="testinclude" value="**/*Test.php" override="true" />
92 <echo msg="Starting Tests..." />
93 <echo msg="Using config file ${testconfigdir}/phpunit.xml" />
95 <!-- do we need this? -->
96 <!--includepath classpath = "${testconfigdir}" /-->
98 <delete dir="${builddir}/reports" />
99 <mkdir dir="${builddir}/reports" />
100 <mkdir dir="${builddir}/reports/tests" />
102 <phpunit configuration="${testconfigdir}/phpunit.xml" haltonfailure="true" printsummary="true">
103 <formatter type="plain" usefile="false" />
104 <formatter type="xml" todir="${builddir}/reports" />
106 <fileset dir="${project.basedir}/../tests/tine20">
107 <include name="${testinclude}" />
108 <exclude name="Tinebase/AccountTest.php" />
113 <phpunitreport infile="${builddir}/reports/testsuites.xml" format="frames" todir="${builddir}/reports/tests" />
116 <!-- ============================================ -->
117 <!-- Target: phpunit-prepare -->
118 <!-- ============================================ -->
119 <target name="phpunit-prepare">
120 <echo msg="Preparing for phpunit" />
122 <echo msg="Making report directories" />
123 <mkdir dir="${builddir}/reports" />
125 <echo msg="Making userdata directories" />
126 <mkdir dir="${userdatadir}/cache"/>
127 <mkdir dir="${userdatadir}/sessions"/>
128 <mkdir dir="${userdatadir}/tmp"/>
129 <mkdir dir="${userdatadir}/files"/>
130 <mkdir dir="${userdatadir}/log"/>
133 <!-- ============================================ -->
134 <!-- Target: phpunit-exec -->
136 <!-- this runs phpunit in an exec task. we do this -->
137 <!-- to overcome some drawbacks (for example we can't -->
138 <!-- use the LogListener) of the phing phpunit task. -->
139 <!-- ============================================ -->
140 <target name="phpunit-exec" depends="clean, phpunit-prepare">
141 <property name="testinclude" value="AllTests.php" override="true" />
142 <property name="includepath" value=".:/usr/share/php/:${configdir}:${project.basedir}:${project.basedir}/library:${project.basedir}/vendor/zendframework/zendframework1/library" override="true" />
143 <property name="testadditionalparams" value="" override="true" />
144 <property name="testsuite" value="tine20" override="true" />
146 <echo msg="Starting Tests..." />
147 <echo msg="Using config file ${testconfigdir}/phpunit.xml" />
148 <echo msg="Setting include_path to ${includepath}" />
150 <exec executable="${project.basedir}/vendor/bin/phpunit" dir="${project.basedir}/../tests/${testsuite}" passthru="true">
151 <arg line="-d max_execution_time=0
152 -d include_path=${includepath}
153 --configuration ${testconfigdir}/phpunit.xml
154 --log-junit ${builddir}/reports/junit.xml
155 ${testadditionalparams}
160 <!-- ============================================ -->
161 <!-- Target: phpunit-serv -->
163 <!-- this runs phpunit in an exec task. we do this -->
164 <!-- to overcome some drawbacks (for example we can't -->
165 <!-- use the LogListener) of the phing phpunit task. -->
166 <!-- ============================================ -->
167 <target name="phpunit-serv" depends="clean, phpunit-prepare">
168 <property name="testinclude" value="AllServerTests.php" override="true" />
169 <property name="includepath" value=".:/usr/share/php/:${configdir}:${project.basedir}:${project.basedir}/library/:${project.basedir}/vendor/zendframework/zendframework1/library" override="true" />
170 <property name="testadditionalparams" value="" override="true" />
172 <echo msg="Starting Server Tests..." />
173 <echo msg="Using config file ${testconfigdir}/phpunit.xml" />
174 <echo msg="Setting include_path to ${includepath}" />
176 <exec executable="${project.basedir}/vendor/bin/phpunit" dir="${project.basedir}/../tests/tine20" passthru="true">
177 <arg line="-d max_execution_time=0
178 -d include_path=${includepath}
179 --configuration ${testconfigdir}/phpunit.xml
180 --log-junit ${builddir}/reports/junit.xml
181 ${testadditionalparams}
186 <!-- ============================================ -->
187 <!-- Target: report -->
188 <!-- TODO remove code duplication (phpunit target) OR remove this -->
189 <!-- ============================================ -->
190 <target name="report">
191 <echo msg="Starting Tests..." />
193 <delete dir="${builddir}/reports"/>
194 <mkdir dir="${builddir}/reports/tests"/>
195 <mkdir dir="${builddir}/reports/coverage"/>
196 <coverage-setup database="${builddir}/reports/coverage.db">
198 <include name="**/*.php" />
199 <exclude name="Zend/**.php" />
200 <exclude name="library/**.php" />
201 <exclude name="vendor/**.php" />
204 <phpunit configuration="../tests/tine20/phpunit.xml" haltonfailure="true" haltonerror="true" printsummary="true" codecoverage="true">
205 <formatter type="xml" todir="${builddir}/reports"/>
207 <fileset dir="../tests/tine20">
208 <include name="**/*Test.php"/>
209 <exclude name="Tinebase/AccountTest.php"/>
213 <phpunitreport infile="${builddir}/reports/testsuites.xml" format="frames" todir="${builddir}/reports/tests"/>
214 <coverage-report outfile="${builddir}/reports/coverage.xml">
215 <report todir="${builddir}/reports/coverage" title="Tine 2.0"/>
219 <!-- ============================================ -->
220 <!-- Target: build-module -->
221 <!-- ============================================ -->
222 <target name="build-module" description="build single module" depends="prepare">
223 <phingcall target="prepared-build-module">
224 <property name="name" value="${name}" />
227 <target name="prepared-build-module" description="build single module">
228 <echo msg="Building ${name}" />
232 <available file="${project.basedir}/${name}/js/package.json"/>
234 <echo message="Starting npm..." />
235 <exec command="npm install" dir="${project.basedir}/${name}/js" passthru="true" />
239 <!-- do webpack build -->
241 <available file="${project.basedir}/${name}/js/webpack.config.js"/>
243 <echo message="Starting webpack..." />
244 <exec command="webpack --output-path ${builddir}/${name}/js" dir="${project.basedir}/${name}/js" passthru="true" />
247 <available file="${builddir}/${name}/js/webpack.config.js" property="webpack" value="Yes"/>
250 <!-- do jsb2tk build -->
251 <jsb2tk-build appName="${name}" />
253 <!-- replace buildstuff -->
257 <regexp pattern="Tine\.clientVersion\.buildType\s*=[^=]{1}[^;]*" replace='Tine.clientVersion.buildType="RELEASE"' modifiers="i" />
258 <regexp pattern="Tine\.clientVersion\.buildDate\s*=[^=]{1}[^;]*" replace='Tine.clientVersion.buildDate="${buildDate}"' modifiers="i"/>
259 <regexp pattern="Tine\.clientVersion\.buildRevision\s*=[^=]{1}[^;]*" replace='Tine.clientVersion.codeName="${buildRevision}"' modifiers="i"/>
263 <fileset dir="${builddir}">
264 <include name="${name}/js/*-FAT*" />
268 <!-- debug mode for debug files -->
272 <regexp pattern="Tine\.clientVersion\.buildType\s*=[^=]{1}[^;]*" replace="Tine.clientVersion.buildType = 'DEBUG'"/>
276 <fileset dir="${builddir}">
277 <include name="${name}/js/*-FAT-debug*" />
281 <!-- original jsb2 builds -->
282 <!-- NOTE as jsb2tk has no path adoption yet we need to do it here -->
283 <copy toDir="${project.basedir}">
284 <fileset dir="${builddir}">
285 <include name="${name}/*/*" />
290 <regexp pattern="(\.\.\/){2,}images" replace="../../images" modifiers="i"/>
291 <regexp pattern="(\.\.\/){2,}library" replace="../../library" modifiers="i"/>
297 <!-- adopt path for getJS/getCSS -->
298 <!-- TODO add deploymode GETTER and move this to jsb2tk -->
299 <copy toDir="${project.basedir}">
300 <mapper type="regexp" from="^(.*\.(js|css))" to="\1.inc"/>
304 <regexp pattern="(\.\.\/)+images" replace="images" modifiers="i"/>
305 <regexp pattern="(\.\.\/)+library" replace="library" modifiers="i"/>
309 <fileset dir="${builddir}">
310 <include name="${name}/*/*" />
315 <!-- translations -->
316 <translation-build appName="${name}" />
317 <jsMin targetDir="${builddir}/${name}/js" failOnError="false">
318 <fileset dir="${builddir}/${name}/js">
319 <include name="*-lang-*-debug.js"/>
323 <copy toDir="${project.basedir}/${name}/js">
324 <fileset dir="${builddir}/${name}/js">
325 <include name="*-lang-*-debug.js" />
329 <copy toDir="${project.basedir}/${name}/js">
330 <fileset dir="${builddir}/${name}/js">
331 <include name="*-lang-*-debug-min.js" />
334 <mapper type="regexp" from="^(.*)-debug-min.js" to="\1.js"/>
339 <!-- ============================================ -->
340 <!-- Target: clean -->
341 <!-- ============================================ -->
342 <target name="clean">
343 <delete dir="${builddir}" includeemptydirs="true" verbose="false" failonerror="false" />
344 <delete dir="${userdatadir}" includeemptydirs="true" verbose="false" failonerror="false" />
347 <include name="*/*/*-FAT*" />
348 <include name="*/js/*-lang-*" />
349 <include name="${project.basedir}/${localedir}/build/*" />
354 <!-- ============================================ -->
355 <!-- Target: mimetypes -->
356 <!-- ============================================ -->
357 <target name="mimetypes">
358 <build-mimetypes appName="${name}" />
361 <!-- ============================================ -->
362 <!-- Target: tx-pull -->
363 <!-- ============================================ -->
364 <target name="tx-pull">
365 <echo msg="pull translations from transifex" />
366 <exec command="tx pull -a -f --skip" passthru="true" />
367 <echo msg="Commit updated strings now:" />
368 <echo msg="$ git add */translations" />
369 <echo msg="$ git commit -m '#7086: update translation files'" />
370 <echo msg="$ git push gerrit HEAD:refs/heads/master" />
371 <echo msg="You might run the target translation-test now:" />
372 <echo msg="$ ./vendor/bin/phing translation-test" />
375 <!-- ============================================ -->
376 <!-- Target: tx-push -->
377 <!-- ============================================ -->
378 <target name="tx-push">
379 <echo msg="updating templates" />
380 <exec command="./langHelper.php --pot" passthru="true" />
381 <echo msg="push translations to transifex" />
382 <exec command="tx push -s" passthru="true" />
383 <echo msg="commit updated strings now:" />
384 <echo msg="git commit -a -m 'update lang templates'" />
385 <echo msg="git push gerrit HEAD:refs/heads/master" />
388 <!-- ============================================ -->
389 <!-- Target: translation-test -->
390 <!-- ============================================ -->
391 <target name="translation-test">
392 <echo msg="find duplicates or syntax errors" />
393 <exec command="for i in `ls ./*/translations/*.po`; do msgfmt -o - --strict $i 1>/dev/null; done" passthru="true"/>
396 <!-- ============================================ -->
397 <!-- Target: tine-install -->
398 <!-- ============================================ -->
399 <target name="tine-install">
400 <property file="${configdir}/install.properties" />
401 <echo msg="Installing Tine 2.0 with initial admin '${adminLoginName}'" />
402 <exec command="php -d include_path=.:${configdir} setup.php \
404 adminLoginName=${adminLoginName} \
405 adminPassword=${adminPassword} \
406 adminEmailAddress=${adminEmailAddress} \
407 acceptedTermsVersion=1000 \
410 authentication=${authentication} \
411 accounts=${accounts} \
413 " passthru="true" returnProperty="return"/>
415 <equals arg1="${return}" arg2="0" />
417 <echo message="Installation successful" />
420 <fail message="Installation failed" />
425 <!-- ============================================ -->
426 <!-- Target: tine-uninstall -->
427 <!-- ============================================ -->
428 <target name="tine-uninstall">
429 <echo msg="Uninstalling Tine 2.0" />
430 <exec command="php -d include_path=.:${configdir} setup.php \
431 --uninstall" passthru="true"/>
434 <!-- ============================================ -->
436 <!-- ============================================ -->
437 <adhoc-task name="init"><![CDATA[
438 class initTask extends Task {
440 passthru('composer install --prefer-source --no-interaction');
441 require_once 'vendor/autoload.php';
446 <!-- ============================================ -->
447 <!-- Task: jsb2tk-build -->
448 <!-- ============================================ -->
449 <adhoc-task name="jsb2tk-build"><![CDATA[
450 class jsb2tkTask extends Task {
453 function setAppName($appName) {
454 $this->appName = $appName;
458 $jsb2 = "${project.basedir}/{$this->appName}/{$this->appName}.jsb2";
459 if (file_exists($jsb2)) {
460 $this->log("In jsb2tkTask: " . $this->appName);
462 require_once('${project.basedir}/library/jsb2tk/jsb2tk.php');
464 $tk = new jsb2tk(array(
465 'homeDir' => '${builddir}'
468 $tk->register($jsb2);
475 <!-- ============================================ -->
476 <!-- Task: translation-build -->
477 <!-- ============================================ -->
478 <adhoc-task name="translation-build"><![CDATA[
479 class translationTask extends Task {
482 function setAppName($appName) {
483 $this->appName = $appName;
487 if (! file_exists('${builddir}/' . "{$this->appName}/js")) return;
488 $availableTranslations = Tinebase_Translation::getAvailableTranslations();
490 foreach ($availableTranslations as $translation) {
491 $localeString = $translation['locale'];
492 $locale = new Zend_Locale($localeString);
494 $jsTranslation = Tinebase_Translation::getJsTranslations($locale, $this->appName);
496 if ($this->appName == 'Tinebase' && file_exists('${project.basedir}/langstatistics.json')) {
497 $langstatistics = json_decode(file_get_contents('${project.basedir}/langstatistics.json'), TRUE);
498 $localeStats = array_values(array_filter($langstatistics['langStats'], function($stats) use ($localeString) {return $stats['locale'] == $localeString;}));
499 $jsTranslation .= ("Locale.translationStats=" . json_encode($localeStats[0]) . ";\n");
502 file_put_contents('${builddir}/' . "{$this->appName}/js/{$this->appName}-lang-{$locale}-debug.js", $jsTranslation);
505 foreach (Tinebase_Translation::getTranslationDirs() as $appName => $translationPath) {
506 foreach (scandir($translationPath) as $poFile) {
507 if (substr($poFile, -3) == '.po') {
508 $langName = substr($poFile, 0, -3);
509 `cd "$translationPath"
510 msgfmt -o $langName.mo $poFile`;
518 <!-- ============================================ -->
519 <!-- Task: build-mimetypes -->
520 <!-- ============================================ -->
521 <adhoc-task name="build-mimetypes"><![CDATA[
522 class mimetypeTask extends Task {
525 function setAppName($appName) {
526 $this->appName = $appName;
529 function buildMimeTypesStyleFile($resolution, &$styleSheet) {
531 $relatedImgPath = '/images/oxygen/'.$resolution.'/mimetypes/';
532 $imgPath = '${project.basedir}'.$relatedImgPath;
533 if (! file_exists($imgPath) || ! is_dir($imgPath)) {
534 echo 'Mimetype images no found!';
538 // öffnen des Verzeichnisses
539 if ( $handle = opendir($imgPath) ) {
541 fwrite($styleSheet, ".standardFileClass_".$resolution." .x-grid3-cell-inner {\n");
542 fwrite($styleSheet, " background-image: url(../..".$relatedImgPath."application-octet-stream.png);\n");
543 fwrite($styleSheet, " background-repeat: no-repeat;\n");
544 fwrite($styleSheet, " padding-left: 19px;\n");
545 fwrite($styleSheet, "}\n\n");
547 // einlesen der Verzeichnisses
548 while (($file = readdir($handle)) !== false)
550 $fileName = basename($file, '.png');
552 $addToStyle = strcmp($fileName, "..") + strcmp($fileName, "..");
553 if($addToStyle > 0) {
555 fwrite($styleSheet, ".".$fileName."_".$resolution." .x-grid3-cell-inner {\n");
556 fwrite($styleSheet, " background-image: url(../..".$relatedImgPath.$file.") !important;\n");
557 fwrite($styleSheet, " background-repeat: no-repeat;\n");
558 fwrite($styleSheet, " padding-left: 19px;\n");
559 fwrite($styleSheet, "}\n\n");
568 $styleSheet = fopen('Tinebase/css/mimetypes.css', 'w+');
569 $this->buildMimeTypesStyleFile('16x16', $styleSheet);
570 $this->buildMimeTypesStyleFile('22x22', $styleSheet);
571 $this->buildMimeTypesStyleFile('32x32', $styleSheet);
578 <!-- ============================================ -->
579 <!-- Task: manifest-build -->
580 <!-- TODO make it working (just a codestore) -->
581 <!-- ============================================ -->
582 <adhoc-task name="manifest-build"><![CDATA[
583 class manifestBuildTask extends Task {
586 function setAppName($appName) {
587 $this->appName = $appName;
591 $defaultFiles = "CACHE MANIFEST\n# Build by $build\nCACHE:\n";
593 $manifest = fopen('${project.basedir}/tine20.manifest', 'w+');
594 fwrite($manifest, $defaultFiles . "\n");
597 'Tinebase/css/tine-all.css',
598 'Tinebase/js/tine-all.js',
600 'library/ExtJS/ext-all.js',
601 'library/ExtJS/adapter/ext/ext-base.js',
602 'library/ExtJS/resources/css/ext-all.css',
603 'images/oxygen/16x16/actions/knewstuff.png' // ???
606 // no subdirs! => solaris does not know find -maxdeps 1
607 exec("cd \"$tine20path\"; ls images/* | grep images/ | egrep '\.png|\.gif|\.jpg'", $baseImages);
608 $files = array_merge($files, $baseImages);
610 $tineCSS = file_get_contents($tine20path . '/Tinebase/css/tine-all-debug.css');
611 preg_match_all('/url\(..\/..\/(images.*)\)/U', $tineCSS, $matches);
612 $files = array_merge($files, $matches[1]);
614 $tineCSS = file_get_contents($tine20path . '/Tinebase/css/tine-all-debug.css');
615 preg_match_all('/url\(..\/..\/(library.*)\)/U', $tineCSS, $matches);
616 $files = array_merge($files, $matches[1]);
618 $tineJs = file_get_contents($tine20path . '/Tinebase/js/tine-all-debug.js');
619 preg_match_all('/labelIcon: [\'|"](.*png)/U', $tineJs, $matches);
620 $files = array_merge($files, $matches[1]);
622 $tineJs = file_get_contents($tine20path . '/Tinebase/js/tine-all-debug.js');
623 preg_match_all('/labelIcon: [\'|"](.*gif)/U', $tineJs, $matches);
624 $files = array_merge($files, $matches[1]);
626 $tineJs = file_get_contents($tine20path . '/Tinebase/js/tine-all-debug.js');
627 preg_match_all('/src=[\'|"](.*png)/U', $tineJs, $matches);
628 $files = array_merge($files, $matches[1]);
630 $tineJs = file_get_contents($tine20path . '/Tinebase/js/tine-all-debug.js');
631 preg_match_all('/src=[\'|"](.*gif)/U', $tineJs, $matches);
632 $files = array_merge($files, $matches[1]);
634 exec("cd \"$tine20path\"; find library/ExtJS/resources/images -type f -name *.gif", $extImages);
635 $files = array_merge($files, $extImages);
636 exec("cd \"$tine20path\"; find library/ExtJS/resources/images -type f -name *.png", $extImages);
637 $files = array_merge($files, $extImages);
639 exec("cd \"$tine20path\"; find styles -type f", $tine20Styles);
640 $files = array_merge($files, $tine20Styles);
642 $files = array_unique($files);
644 foreach($files as $file) {
645 if (! is_file("$tine20path/$file")) {
646 echo "WARNING $file not found, removing it from manifest.\n";
647 } else if (substr(basename($file), 0, 1) == '.' || ! preg_match('/(js|css|gif|png|jpg)$/', $file)) {
648 echo "INFO $file is unwanted, removing it from manifest.\n";
650 fwrite($manifest, $file . "\n");
659 <!-- ============================================ -->
660 <!-- Task: zend-translation-build -->
661 <!-- TODO make a target for this -->
662 <!-- ============================================ -->
663 <adhoc-task name="zend-translation-build"><![CDATA[
664 class zendTranslationTask extends Task {
666 // dump one langfile for every locale
667 $localelist = Zend_Locale::getLocaleList();
668 foreach ($localelist as $locale => $something) {
670 $js = $this->createJsTranslationLists($locale);
671 file_put_contents('${builddir}/${localedir}/static/' . "generic-$locale-debug.js", $js);
672 } catch (Exception $e) {
673 echo "WARNING: could not create translation file for '$locale': '{$e->getMessage()}'\n";
679 * creates translation lists js files for locale with js object
681 * @param string $_locale
682 * @return string the file contents
684 function createJsTranslationLists($_locale) {
685 $jsContent = "Locale.prototype.TranslationLists = {\n";
688 'Date' => array('path' => 'Date'),
689 'Time' => array('path' => 'Time'),
690 'DateTime' => array('path' => 'DateTime'),
691 'Month' => array('path' => 'Month'),
692 'Day' => array('path' => 'Day'),
693 'Symbols' => array('path' => 'Symbols'),
694 'Question' => array('path' => 'Question'),
695 'Language' => array('path' => 'Language'),
696 'CountryList' => array('path' => 'Territory', 'value' => 2),
697 'Territory' => array('path' => 'Territory', 'value' => 1),
698 'CityToTimezone' => array('path' => 'CityToTimezone'),
701 $zendLocale = new Zend_Locale($_locale);
703 foreach ( $types as $name => $path) {
704 $list = $zendLocale->getTranslationList($path['path'], $_locale, array_key_exists('value', $path) ? $path['value'] : false);
707 if ( is_array($list) ) {
708 $jsContent .= "\n\t$name: {";
710 foreach ( $list as $key => $value ) {
711 // convert ISO -> PHP for date formats
712 if ( in_array($name, array('Date', 'Time', 'DateTime')) ) {
713 $value = $this->convertIsoToPhpFormat($value);
715 $value = preg_replace("/\"/", '\"', $value);
716 $jsContent .= "\n\t\t'$key': \"$value\",";
719 $jsContent = chop($jsContent, ",");
721 $jsContent .= "\n\t},";
724 $jsContent = chop($jsContent, ",");
726 $jsContent .= "\n};\n";
731 * Converts a format string from ISO to PHP format
732 * reverse the functionality of Zend's convertPhpToIsoFormat()
734 * @param string $format Format string in PHP's date format
735 * @return string Format string in ISO format
737 function convertIsoToPhpFormat($format) {
739 'c' => '/yyyy-MM-ddTHH:mm:ssZZZZ/',
740 '$1j$2' => '/([^d])d([^d])/',
741 'j$1' => '/^d([^d])/',
742 '$1j' => '/([^d])d$/',
752 '$1n$2' => '/([^M])M([^M])/',
753 'n$1' => '/^M([^M])/',
754 '$1n' => '/([^M])M$/',
767 '$1G$2' => '/([^H])H([^H])/',
768 'G$1' => '/^H([^H])/',
769 '$1G' => '/([^H])H$/',
783 //echo "pre:".$format."\n";
785 $patterns = array_values($convert);
786 $replacements = array_keys($convert);
787 $format = preg_replace($patterns, $replacements, $format);
789 //echo "post:".$format."\n";