Skip to content
This repository
Browse code

No commit message

  • Loading branch information...
commit 662798d8a5a4d6e73dfb5c491a9279f10a951eb3 1 parent f94b8d2
qiang.xue authored

Showing 834 changed files with 43,434 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  CHANGELOG
  2. +31 0 COPYRIGHT
  3. +31 0 LICENSE
  4. +61 0 README
  5. +14 0 UPGRADE
  6. +21 0 build/build
  7. +23 0 build/build.bat
  8. +157 0 build/build.xml
  9. +290 0 build/commands/ApiCommand.php
  10. +79 0 build/commands/AutoloadCommand.php
  11. +325 0 build/commands/CldrCommand.php
  12. +221 0 build/commands/LiteCommand.php
  13. +643 0 build/commands/api/ApiModel.php
  14. +80 0 build/commands/api/assets/css/api.css
  15. +32 0 build/commands/api/assets/css/style.css
  16. +3,549 0 build/commands/api/assets/js/jquery.js
  17. +44 0 build/commands/api/layouts/main.php
  18. +35 0 build/commands/api/views/chmContents.php
  19. +42 0 build/commands/api/views/chmIndex.php
  20. +22 0 build/commands/api/views/chmProject.php
  21. +29 0 build/commands/api/views/class.php
  22. +38 0 build/commands/api/views/classSummary.php
  23. +26 0 build/commands/api/views/eventDetails.php
  24. +20 0 build/commands/api/views/eventSummary.php
  25. +18 0 build/commands/api/views/index.php
  26. +47 0 build/commands/api/views/methodDetails.php
  27. +22 0 build/commands/api/views/methodSummary.php
  28. +27 0 build/commands/api/views/propertyDetails.php
  29. +23 0 build/commands/api/views/propertySummary.php
  30. +9 0 build/commands/api/views/seeAlso.php
  31. +107 0 build/commands/lite/css/form.css
  32. +112 0 build/commands/lite/css/main.css
  33. +4 0 build/commands/lite/index.php
  34. +1 0  build/commands/lite/protected/.htaccess
  35. +25 0 build/commands/lite/protected/components/WebUser.php
  36. +26 0 build/commands/lite/protected/config/main.php
  37. +15 0 build/commands/lite/protected/controllers/HomeController.php
  38. +168 0 build/commands/lite/protected/controllers/PostController.php
  39. +71 0 build/commands/lite/protected/controllers/UserController.php
  40. BIN  build/commands/lite/protected/data/source.db
  41. +60 0 build/commands/lite/protected/models/Post.php
  42. +44 0 build/commands/lite/protected/views/home/index.php
  43. +39 0 build/commands/lite/protected/views/layouts/main.php
  44. +34 0 build/commands/lite/protected/views/post/create.php
  45. +29 0 build/commands/lite/protected/views/post/list.php
  46. +40 0 build/commands/lite/protected/views/post/show.php
  47. +35 0 build/commands/lite/protected/views/post/update.php
  48. +27 0 build/commands/lite/protected/views/user/login.php
  49. +76 0 build/tasks/YiiInitTask.php
  50. +1 0  framework/.htaccess
  51. +532 0 framework/YiiBase.php
  52. +100 0 framework/caching/CApcCache.php
  53. +259 0 framework/caching/CCache.php
  54. +227 0 framework/caching/CDbCache.php
  55. +252 0 framework/caching/CMemCache.php
  56. +62 0 framework/caching/dependencies/CCacheDependency.php
  57. +68 0 framework/caching/dependencies/CChainedCacheDependency.php
  58. +86 0 framework/caching/dependencies/CDbCacheDependency.php
  59. +134 0 framework/caching/dependencies/CDirectoryCacheDependency.php
  60. +53 0 framework/caching/dependencies/CFileCacheDependency.php
  61. +54 0 framework/caching/dependencies/CGlobalStateCacheDependency.php
  62. +193 0 framework/cli/commands/MessageCommand.php
  63. +112 0 framework/cli/commands/ShellCommand.php
  64. +73 0 framework/cli/commands/WebAppCommand.php
  65. +111 0 framework/cli/commands/shell/ControllerCommand.php
  66. +139 0 framework/cli/commands/shell/CrudCommand.php
  67. +64 0 framework/cli/commands/shell/HelpCommand.php
  68. +126 0 framework/cli/commands/shell/ModelCommand.php
  69. 0  framework/cli/runtime/.yii
  70. +43 0 framework/cli/views/shell/controller/controller.php
  71. +2 0  framework/cli/views/shell/controller/view.php
  72. +168 0 framework/cli/views/shell/crud/controller.php
  73. +24 0 framework/cli/views/shell/crud/create.php
  74. +29 0 framework/cli/views/shell/crud/list.php
  75. +18 0 framework/cli/views/shell/crud/show.php
  76. +25 0 framework/cli/views/shell/crud/update.php
  77. +57 0 framework/cli/views/shell/model/model.php
  78. 0  framework/cli/views/webapp/assets/.yii
  79. +107 0 framework/cli/views/webapp/css/form.css
  80. +112 0 framework/cli/views/webapp/css/main.css
  81. 0  framework/cli/views/webapp/images/.yii
  82. +11 0 framework/cli/views/webapp/index.php
  83. +1 0  framework/cli/views/webapp/protected/.htaccess
  84. 0  framework/cli/views/webapp/protected/commands/.yii
  85. +25 0 framework/cli/views/webapp/protected/components/WebUser.php
  86. +7 0 framework/cli/views/webapp/protected/config/console.php
  87. +19 0 framework/cli/views/webapp/protected/config/main.php
  88. +15 0 framework/cli/views/webapp/protected/controllers/HomeController.php
  89. +71 0 framework/cli/views/webapp/protected/controllers/UserController.php
  90. 0  framework/cli/views/webapp/protected/extensions/.yii
  91. 0  framework/cli/views/webapp/protected/messages/.yii
  92. 0  framework/cli/views/webapp/protected/models/.yii
  93. 0  framework/cli/views/webapp/protected/runtime/.yii
  94. +44 0 framework/cli/views/webapp/protected/views/home/index.php
  95. +39 0 framework/cli/views/webapp/protected/views/layouts/main.php
  96. 0  framework/cli/views/webapp/protected/views/system/.yii
  97. +27 0 framework/cli/views/webapp/protected/views/user/login.php
  98. +16 0 framework/cli/views/webapp/protected/yiic
  99. +16 0 framework/cli/views/webapp/protected/yiic.bat
  100. 0  framework/cli/views/webapp/themes/.yii
  101. +159 0 framework/collections/CAttributeCollection.php
  102. +149 0 framework/collections/CConfiguration.php
  103. +426 0 framework/collections/CList.php
  104. +403 0 framework/collections/CMap.php
  105. +253 0 framework/collections/CQueue.php
  106. +254 0 framework/collections/CStack.php
  107. +52 0 framework/collections/CTypedList.php
  108. +156 0 framework/console/CConsoleApplication.php
  109. +224 0 framework/console/CConsoleCommand.php
  110. +141 0 framework/console/CConsoleCommandRunner.php
  111. +70 0 framework/console/CHelpCommand.php
  112. +946 0 framework/core/CApplication.php
  113. +47 0 framework/core/CApplicationComponent.php
  114. +542 0 framework/core/CComponent.php
  115. +302 0 framework/core/CErrorHandler.php
  116. +22 0 framework/core/CException.php
  117. +40 0 framework/core/CHttpException.php
  118. +210 0 framework/core/CModel.php
  119. +245 0 framework/core/CSecurityManager.php
  120. +105 0 framework/core/CStatePersister.php
  121. +52 0 framework/core/functions.php
  122. +207 0 framework/core/interfaces.php
  123. +171 0 framework/core/log/CDbLogRoute.php
  124. +122 0 framework/core/log/CEmailLogRoute.php
  125. +162 0 framework/core/log/CFileLogRoute.php
  126. +88 0 framework/core/log/CLogRoute.php
  127. +109 0 framework/core/log/CLogRouter.php
  128. +167 0 framework/core/log/CLogger.php
  129. +183 0 framework/core/log/CProfileLogRoute.php
  130. +57 0 framework/core/log/CWebLogRoute.php
  131. +288 0 framework/db/CDbCommand.php
  132. +551 0 framework/db/CDbConnection.php
  133. +221 0 framework/db/CDbDataReader.php
  134. +21 0 framework/db/CDbException.php
  135. +106 0 framework/db/CDbTransaction.php
  136. +800 0 framework/db/ar/CActiveFinder.php
  137. +1,586 0 framework/db/ar/CActiveRecord.php
  138. +143 0 framework/db/schema/CDbColumnSchema.php
  139. +527 0 framework/db/schema/CDbCommandBuilder.php
  140. +69 0 framework/db/schema/CDbCriteria.php
  141. +126 0 framework/db/schema/CDbSchema.php
  142. +76 0 framework/db/schema/CDbTableSchema.php
  143. +44 0 framework/db/schema/mysql/CMysqlColumnSchema.php
  144. +210 0 framework/db/schema/mysql/CMysqlSchema.php
  145. +26 0 framework/db/schema/mysql/CMysqlTableSchema.php
  146. +56 0 framework/db/schema/pgsql/CPgsqlColumnSchema.php
  147. +255 0 framework/db/schema/pgsql/CPgsqlSchema.php
  148. +25 0 framework/db/schema/pgsql/CPgsqlTableSchema.php
  149. +40 0 framework/db/schema/sqlite/CSqliteCommandBuilder.php
  150. +117 0 framework/db/schema/sqlite/CSqliteSchema.php
  151. +502 0 framework/i18n/CDateFormatter.php
  152. +114 0 framework/i18n/CDbMessageSource.php
  153. +243 0 framework/i18n/CLocale.php
  154. +88 0 framework/i18n/CMessageSource.php
  155. +254 0 framework/i18n/CNumberFormatter.php
  156. +96 0 framework/i18n/CPhpMessageSource.php
  157. +667 0 framework/i18n/CTimestamp.php
  158. +10 0 framework/i18n/data/README.txt
  159. +159 0 framework/i18n/data/aa.php
  160. +150 0 framework/i18n/data/aa_dj.php
  161. +159 0 framework/i18n/data/aa_er.php
  162. +159 0 framework/i18n/data/aa_er_saaho.php
  163. +159 0 framework/i18n/data/aa_et.php
  164. +157 0 framework/i18n/data/af.php
  165. +157 0 framework/i18n/data/af_na.php
  166. +157 0 framework/i18n/data/af_za.php
  167. +157 0 framework/i18n/data/ak.php
  168. +157 0 framework/i18n/data/ak_gh.php
  169. +158 0 framework/i18n/data/am.php
  170. +158 0 framework/i18n/data/am_et.php
  171. +180 0 framework/i18n/data/ar.php
  172. +180 0 framework/i18n/data/ar_ae.php
  173. +180 0 framework/i18n/data/ar_bh.php
  174. +180 0 framework/i18n/data/ar_dz.php
  175. +180 0 framework/i18n/data/ar_eg.php
  176. +180 0 framework/i18n/data/ar_iq.php
  177. +180 0 framework/i18n/data/ar_jo.php
  178. +180 0 framework/i18n/data/ar_kw.php
  179. +180 0 framework/i18n/data/ar_lb.php
  180. +180 0 framework/i18n/data/ar_ly.php
  181. +180 0 framework/i18n/data/ar_ma.php
  182. +180 0 framework/i18n/data/ar_om.php
  183. +180 0 framework/i18n/data/ar_qa.php
  184. +180 0 framework/i18n/data/ar_sa.php
  185. +180 0 framework/i18n/data/ar_sd.php
  186. +180 0 framework/i18n/data/ar_sy.php
  187. +180 0 framework/i18n/data/ar_tn.php
  188. +180 0 framework/i18n/data/ar_ye.php
  189. +156 0 framework/i18n/data/as.php
  190. +156 0 framework/i18n/data/as_in.php
  191. +164 0 framework/i18n/data/az.php
  192. +164 0 framework/i18n/data/az_az.php
  193. +164 0 framework/i18n/data/az_cyrl.php
  194. +164 0 framework/i18n/data/az_cyrl_az.php
  195. +164 0 framework/i18n/data/az_latn.php
  196. +164 0 framework/i18n/data/az_latn_az.php
  197. +159 0 framework/i18n/data/be.php
  198. +159 0 framework/i18n/data/be_by.php
  199. +254 0 framework/i18n/data/bg.php
  200. +254 0 framework/i18n/data/bg_bg.php
  201. +158 0 framework/i18n/data/bn.php
  202. +158 0 framework/i18n/data/bn_bd.php
  203. +158 0 framework/i18n/data/bn_in.php
  204. +158 0 framework/i18n/data/bs.php
  205. +158 0 framework/i18n/data/bs_ba.php
  206. +158 0 framework/i18n/data/byn.php
  207. +158 0 framework/i18n/data/byn_er.php
  208. +159 0 framework/i18n/data/ca.php
  209. +159 0 framework/i18n/data/ca_es.php
  210. +157 0 framework/i18n/data/cch.php
  211. +157 0 framework/i18n/data/cch_ng.php
  212. +156 0 framework/i18n/data/cop.php
  213. +253 0 framework/i18n/data/cs.php
  214. +253 0 framework/i18n/data/cs_cz.php
  215. +156 0 framework/i18n/data/cy.php
  216. +156 0 framework/i18n/data/cy_gb.php
  217. +251 0 framework/i18n/data/da.php
  218. +251 0 framework/i18n/data/da_dk.php
  219. +255 0 framework/i18n/data/de.php
  220. +234 0 framework/i18n/data/de_at.php
  221. +244 0 framework/i18n/data/de_be.php
  222. +255 0 framework/i18n/data/de_ch.php
  223. +255 0 framework/i18n/data/de_de.php
  224. +255 0 framework/i18n/data/de_li.php
  225. +256 0 framework/i18n/data/de_lu.php
  226. +157 0 framework/i18n/data/dv.php
  227. +157 0 framework/i18n/data/dv_mv.php
  228. +157 0 framework/i18n/data/dz.php
  229. +157 0 framework/i18n/data/dz_bt.php
  230. +158 0 framework/i18n/data/ee.php
  231. +158 0 framework/i18n/data/ee_gh.php
  232. +158 0 framework/i18n/data/ee_tg.php
  233. +246 0 framework/i18n/data/el.php
  234. +246 0 framework/i18n/data/el_cy.php
  235. +246 0 framework/i18n/data/el_gr.php
  236. +234 0 framework/i18n/data/el_polyton.php
  237. +271 0 framework/i18n/data/en.php
  238. +271 0 framework/i18n/data/en_as.php
  239. +271 0 framework/i18n/data/en_au.php
  240. +271 0 framework/i18n/data/en_be.php
  241. +272 0 framework/i18n/data/en_bw.php
  242. +271 0 framework/i18n/data/en_bz.php
  243. +271 0 framework/i18n/data/en_ca.php
  244. +271 0 framework/i18n/data/en_dsrt.php
  245. +271 0 framework/i18n/data/en_dsrt_us.php
  246. +271 0 framework/i18n/data/en_gb.php
  247. +271 0 framework/i18n/data/en_gu.php
  248. +271 0 framework/i18n/data/en_hk.php
  249. +271 0 framework/i18n/data/en_ie.php
  250. +271 0 framework/i18n/data/en_in.php
  251. +271 0 framework/i18n/data/en_jm.php
  252. +271 0 framework/i18n/data/en_mh.php
  253. +271 0 framework/i18n/data/en_mp.php
  254. +271 0 framework/i18n/data/en_mt.php
  255. +271 0 framework/i18n/data/en_na.php
  256. +271 0 framework/i18n/data/en_nz.php
Sorry, we could not display the entire diff because too many files (834) changed.
3  CHANGELOG
... ... @@ -0,0 +1,3 @@
  1 +Version 1.0a October 1, 2008
  2 +=============================
  3 +Initial release
31 COPYRIGHT
... ... @@ -0,0 +1,31 @@
31 LICENSE
... ... @@ -0,0 +1,31 @@
  1 +The Yii framework is free software. It is released under the terms of
  2 +the following BSD License.
  3 +
  4 +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
  5 +All rights reserved.
  6 +
  7 +Redistribution and use in source and binary forms, with or without
  8 +modification, are permitted provided that the following conditions
  9 +are met:
  10 + * Redistributions of source code must retain the above copyright
  11 + notice, this list of conditions and the following disclaimer.
  12 + * Redistributions in binary form must reproduce the above copyright
  13 + notice, this list of conditions and the following disclaimer in
  14 + the documentation and/or other materials provided with the
  15 + distribution.
  16 + * Neither the name of Yii Software LLC nor the names of its
  17 + contributors may be used to endorse or promote products derived
  18 + from this software without specific prior written permission.
  19 +
  20 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23 +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24 +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25 +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26 +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28 +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29 +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30 +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31 +POSSIBILITY OF SUCH DAMAGE.
61 README
... ... @@ -0,0 +1,61 @@
  1 +
  2 + Yii Web Programming Framework
  3 + =============================
  4 +
  5 +Thank you for choosing Yii - a high-performance programming framework
  6 +for developing Web applications in PHP 5.
  7 +
  8 +
  9 +INSTALLATION
  10 +------------
  11 +Please make sure the release file is unpacked under a Web-accessible
  12 +directory. You shall see the following files and directories:
  13 +
  14 + framework/ containing the Yii framework source files
  15 + requirements/ containing the Yii requirement checker
  16 + CHANGELOG describing changes in every Yii release
  17 + LICENSE license of Yii
  18 + README this file
  19 + UPGRADE upgrading instructions
  20 +
  21 +
  22 +REQUIREMENTS
  23 +------------
  24 +The minimum requirement by Yii is that your Web server supports
  25 +PHP 5.2.1 or above. Yii has been tested with Apache HTTP server
  26 +on Windows and Linux operating systems.
  27 +
  28 +Please access the following URL to check if your Web server reaches
  29 +the requirements by Yii, assuming "YiiPath" is where Yii is installed:
  30 +
  31 + http://hostname/YiiPath/requirements/index.php
  32 +
  33 +
  34 +QUICK START
  35 +-----------
  36 +Yii comes with a command line tool called "yiic" that can create
  37 +a skeleton Yii application for you to start with.
  38 +
  39 +On command line, type in the following commands:
  40 +
  41 + $ cd YiiPath/framework (Linux)
  42 + cd YiiPath\framework (Windows)
  43 +
  44 + $ ./yiic webapp ../testdrive (Linux)
  45 + yiic webapp ..\testdrive (Windows)
  46 +
  47 +The new Yii application will be created at "YiiPath/testdrive".
  48 +You can access it with the following URL:
  49 +
  50 + http://hostname/YiiPath/testdrive/index.php
  51 +
  52 +
  53 +WHAT's NEXT
  54 +-----------
  55 +Please visit the project website for tutorials, class reference
  56 +and join discussions with other Yii users.
  57 +
  58 +
  59 +
  60 +The Yii Team
  61 +http://www.yiiframework.com
14 UPGRADE
... ... @@ -0,0 +1,14 @@
  1 +
  2 + Upgrading Instructions for Yii Framework v1.0a
  3 + ==============================================
  4 +
  5 +!!!IMPORTANT!!!
  6 +
  7 +The following upgrading instructions are cumulative. That is,
  8 +if you want to upgrade from version A to version C and there is
  9 +version B between A and C, you need to following the instructions
  10 +for both A and B.
  11 +
  12 +
  13 +Upgrading from v1.0a
  14 +--------------------
21 build/build
... ... @@ -0,0 +1,21 @@
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * build script file.
  5 + *
  6 + * This is a command line script that provides various commands
  7 + * for building an Yii release.
  8 + *
  9 + * @author Qiang Xue <qiang.xue@gmail.com>
  10 + * @link http://www.yiiframework.com/
  11 + * @copyright Copyright &copy; 2008 Yii Software LLC
  12 + * @license http://www.yiiframework.com/license/
  13 + * @version $Id$
  14 + */
  15 +
  16 +defined('YII_DEBUG') or define('YII_DEBUG',true);
  17 +
  18 +$root=dirname(__FILE__);
  19 +require_once($root.'/../framework/yii.php');
  20 +$config=array('basePath'=>$root);
  21 +Yii::createConsoleApplication($config)->run();
23 build/build.bat
... ... @@ -0,0 +1,23 @@
  1 +@echo off
  2 +
  3 +rem -------------------------------------------------------------
  4 +rem build script for Windows.
  5 +rem
  6 +rem This is the bootstrap script for running build on Windows.
  7 +rem
  8 +rem @author Qiang Xue <qiang.xue@gmail.com>
  9 +rem @link http://www.yiiframework.com/
  10 +rem @copyright Copyright &copy; 2008 Yii Software LLC
  11 +rem @license http://www.yiiframework.com/license/
  12 +rem @version $Id$
  13 +rem -------------------------------------------------------------
  14 +
  15 +@setlocal
  16 +
  17 +set BUILD_PATH=%~dp0
  18 +
  19 +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
  20 +
  21 +%PHP_COMMAND% "%BUILD_PATH%build" %*
  22 +
  23 +@endlocal
157 build/build.xml
... ... @@ -0,0 +1,157 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!--
  3 +/**
  4 + * Phing build file for Yii.
  5 + *
  6 + * @author Qiang Xue <qiang.xue@gmail.com>
  7 + * @link http://www.yiiframework.com/
  8 + * @copyright Copyright &copy; 2008 Yii Software LLC
  9 + * @license http://www.yiiframework.com/license/
  10 + * @version $Id$
  11 + */
  12 +-->
  13 +<project name="yii" basedir="." default="help">
  14 + <!-- task definitions -->
  15 + <taskdef name="yii-init-build" classname="YiiInitTask" classpath="tasks" />
  16 +
  17 + <!-- init yii.version, yii.revision and yii.winbuild -->
  18 + <yii-init-build />
  19 +
  20 + <!-- these are required external commands -->
  21 + <property name="php" value="php" /> <!-- PHP parser -->
  22 + <property name="hhc" value="hhc" /> <!-- compile phpdoc into CHM -->
  23 + <property name="pdflatex" value="pdflatex" /> <!-- generates PDF from LaTex -->
  24 + <property name="zip" value="zip" /> <!-- zip compression -->
  25 +
  26 + <property name="pkgname" value="${phing.project.name}-${yii.version}.r${yii.revision}"/>
  27 + <property name="docname" value="${phing.project.name}-docs-${yii.version}.r${yii.revision}"/>
  28 +
  29 + <!-- directory definitions -->
  30 + <property name="build.base.dir" value="release"/>
  31 + <property name="build.dist.dir" value="${build.base.dir}/dist"/>
  32 + <property name="build.src.dir" value="${build.base.dir}/${pkgname}"/>
  33 + <property name="build.doc.dir" value="${build.base.dir}/${docname}"/>
  34 + <property name="build.web.dir" value="${build.base.dir}/web"/>
  35 +
  36 + <!-- source files in the framework -->
  37 + <fileset dir=".." id="framework">
  38 + <exclude name="**/.svn"/>
  39 + <exclude name="**/*.bak"/>
  40 + <exclude name="**/*~"/>
  41 + <include name="framework/**/*"/>
  42 + <include name="requirements/*"/>
  43 + <include name="COPYRIGHT"/>
  44 + <include name="CHANGELOG"/>
  45 + <include name="UPGRADE"/>
  46 + <include name="LICENSE"/>
  47 + <include name="README"/>
  48 + </fileset>
  49 +
  50 + <target name="build" depends="prebuild">
  51 + <echo>Building package ${pkgname}...</echo>
  52 + <echo>Copying files to build directory...</echo>
  53 + <copy todir="${build.src.dir}">
  54 + <fileset refid="framework"/>
  55 + </copy>
  56 + </target>
  57 +
  58 + <target name="docs" depends="prebuild">
  59 + <echo>Building documentation...</echo>
  60 +
  61 + <echo>Building API...</echo>
  62 + <mkdir dir="${build.doc.dir}" />
  63 + <exec command="build api ${build.doc.dir}" dir="." passthru="true" />
  64 +
  65 + <echo>Building API CHM...</echo>
  66 + <exec command="${hhc} ${build.doc.dir}/api/manual.hhp" />
  67 + <move file="${build.doc.dir}/api/manual.chm" tofile="${build.doc.dir}/yii-api-${yii.version}.chm" />
  68 + <delete>
  69 + <fileset dir="${build.doc.dir}/api">
  70 + <include name="manual.*" />
  71 + </fileset>
  72 + </delete>
  73 + </target>
  74 +
  75 + <target name="web" depends="prebuild">
  76 + <echo>Building online API...</echo>
  77 + <mkdir dir="${build.web.dir}/views/doc" />
  78 + <mkdir dir="${build.web.dir}/controllers/doc" />
  79 + <exec command="build api ${build.web.dir}/views/doc online" dir="." passthru="true" />
  80 + <move file="${build.web.dir}/views/doc/apiKeywords.txt" tofile="${build.web.dir}/controllers/doc/apiKeywords.txt" />
  81 + </target>
  82 +
  83 + <target name="prebuild">
  84 + <echo>Preparing build ${pkgname}...</echo>
  85 +
  86 + <echo>Building autoload map...</echo>
  87 + <exec command="build autoload" dir="." passthru="true"/>
  88 +
  89 + <echo>Building yiilite.php...</echo>
  90 + <exec command="build lite" dir="." passthru="true"/>
  91 + </target>
  92 +
  93 + <target name="rebuild" depends="clean,build">
  94 + </target>
  95 +
  96 + <target name="dist" depends="clean,build,docs,web">
  97 + <echo>Generating release distributions...</echo>
  98 + <mkdir dir="${build.dist.dir}" />
  99 + <tar destfile="${build.dist.dir}/${pkgname}.tar.gz" compression="gzip">
  100 + <fileset dir="${build.base.dir}">
  101 + <include name="${pkgname}/**/*"/>
  102 + </fileset>
  103 + </tar>
  104 + <tar destfile="${build.dist.dir}/web.tar.gz" compression="gzip">
  105 + <fileset dir="${build.base.dir}">
  106 + <include name="web/**/*"/>
  107 + </fileset>
  108 + </tar>
  109 + <tar destfile="${build.dist.dir}/${docname}.tar.gz" compression="gzip">
  110 + <fileset dir="${build.base.dir}">
  111 + <include name="${docname}/**/*"/>
  112 + </fileset>
  113 + </tar>
  114 + <zip destfile="${build.dist.dir}/${pkgname}.zip">
  115 + <fileset dir="${build.base.dir}">
  116 + <include name="${pkgname}/**/*"/>
  117 + </fileset>
  118 + </zip>
  119 + <zip destfile="${build.dist.dir}/web.zip">
  120 + <fileset dir="${build.base.dir}">
  121 + <include name="web/**/*"/>
  122 + </fileset>
  123 + </zip>
  124 + <zip destfile="${build.dist.dir}/${docname}.zip">
  125 + <fileset dir="${build.base.dir}">
  126 + <include name="${docname}/**/*"/>
  127 + </fileset>
  128 + </zip>
  129 + </target>
  130 +
  131 + <target name="clean">
  132 + <echo>Cleaning up the build...</echo>
  133 + <delete dir="${build.base.dir}"/>
  134 + </target>
  135 +
  136 + <target name="help">
  137 + <echo>
  138 +
  139 + Welcome to use Yii build script!
  140 + --------------------------------
  141 + You may use the following command format to build a target:
  142 +
  143 + phing &lt;target name&gt;
  144 +
  145 + where &lt;target name&gt; can be one of the following:
  146 +
  147 + - dist : create a release;
  148 + - build : prepare a directory for distribution;
  149 + - clean : clean up the build directory;
  150 + - rebuild : clean first and then build;
  151 + - docs : generate documentation;
  152 + - pear : generate PEAR packages;
  153 + - snapshot : generate nightly snapshot;
  154 +
  155 + </echo>
  156 + </target>
  157 +</project>
290 build/commands/ApiCommand.php
... ... @@ -0,0 +1,290 @@
  1 +<?php
  2 +/**
  3 + * ApiCommand class file.
  4 + *
  5 + * @author Qiang Xue <qiang.xue@gmail.com>
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright &copy; 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + */
  10 +
  11 +Yii::import('application.commands.api.ApiModel');
  12 +
  13 +/**
  14 + * MessageCommand extracts messages to be translated from source files.
  15 + * The extracted messages are saved as PHP message source files
  16 + * under the specified directory.
  17 + *
  18 + * @author Qiang Xue <qiang.xue@gmail.com>
  19 + * @version $Id$
  20 + * @package system.build
  21 + * @since 1.0
  22 + */
  23 +class ApiCommand extends CConsoleCommand
  24 +{
  25 + const URL_PATTERN='/\{\{(.*?)\|(.*?)\}\}/s';
  26 + public $classes;
  27 + public $packages;
  28 + public $pageTitle;
  29 + public $themePath;
  30 + public $currentClass;
  31 +
  32 + public function getHelp()
  33 + {
  34 + return <<<EOD
  35 +USAGE
  36 + build api <output-path> [mode]
  37 +
  38 +DESCRIPTION
  39 + This command generates offline API documentation for the Yii framework.
  40 +
  41 +PARAMETERS
  42 + * output-path: required, the directory where the generated documentation
  43 + would be saved.
  44 + * mode: optional, either 'online' or 'offline' (default). This indicates
  45 + whether the generated documentation are for online or offline use.
  46 +
  47 +EOD;
  48 + }
  49 +
  50 + /**
  51 + * Execute the action.
  52 + * @param array command line parameters specific for this command
  53 + */
  54 + public function run($args)
  55 + {
  56 + if(!isset($args[0]))
  57 + $this->usageError('the output directory is not specified.');
  58 + if(!is_dir($docPath=$args[0]))
  59 + $this->usageError("the output directory {$docPath} does not exist.");
  60 +
  61 + $offline=true;
  62 + if(isset($args[1]) && $args[1]==='online')
  63 + $offline=false;
  64 +
  65 + $options=array(
  66 + 'fileTypes'=>array('php'),
  67 + 'exclude'=>array(
  68 + '.svn',
  69 + 'yiilite.php',
  70 + '/cli',
  71 + '/i18n/data',
  72 + '/messages',
  73 + '/vendors',
  74 + '/views',
  75 + '/web/js',
  76 + ),
  77 + );
  78 + $this->pageTitle='Yii Framework Class Reference';
  79 + $themePath=dirname(__FILE__).'/api';
  80 +
  81 + $model=$this->buildModel(YII_PATH,$options);
  82 +
  83 + $this->classes=$model->classes;
  84 + $this->packages=$model->packages;
  85 +
  86 + if($offline)
  87 + $this->buildOfflinePages($docPath.DIRECTORY_SEPARATOR.'api',$themePath);
  88 + else
  89 + {
  90 + $this->buildOnlinePages($docPath.DIRECTORY_SEPARATOR.'api',$themePath);
  91 + $this->buildKeywords($docPath);
  92 + }
  93 + }
  94 +
  95 + protected function buildKeywords($docPath)
  96 + {
  97 + $keywords=array();
  98 + foreach($this->classes as $class)
  99 + $keywords[]=$class->name;
  100 + foreach($this->classes as $class)
  101 + {
  102 + $name=$class->name;
  103 + foreach($class->properties as $property)
  104 + {
  105 + if(!$property->isInherited)
  106 + $keywords[]=$name.'.'.$property->name;
  107 + }
  108 + foreach($class->methods as $method)
  109 + {
  110 + if(!$method->isInherited)
  111 + $keywords[]=$name.'.'.$method->name.'()';
  112 + }
  113 + }
  114 + file_put_contents($docPath.'/apiKeywords.txt',implode(',',$keywords));
  115 + }
  116 +
  117 + public function render($view,$data=null,$return=false,$layout='main')
  118 + {
  119 + $viewFile=$this->themePath."/views/{$view}.php";
  120 + $layoutFile=$this->themePath."/layouts/{$layout}.php";
  121 + $content=$this->renderFile($viewFile,$data,true);
  122 + return $this->renderFile($layoutFile,array('content'=>$content),$return);
  123 + }
  124 +
  125 + public function renderPartial($view,$data=null,$return=false)
  126 + {
  127 + $viewFile=$this->themePath."/views/{$view}.php";
  128 + return $this->renderFile($viewFile,$data,$return);
  129 + }
  130 +
  131 + protected function buildOfflinePages($docPath,$themePath)
  132 + {
  133 + $this->themePath=$themePath;
  134 + @mkdir($docPath);
  135 + $content=$this->render('index',null,true);
  136 + $content=preg_replace_callback(self::URL_PATTERN,array($this,'fixOfflineLink'),$content);
  137 + file_put_contents($docPath.'/index.html',$content);
  138 +
  139 + foreach($this->classes as $name=>$class)
  140 + {
  141 + $this->currentClass=$name;
  142 + $this->pageTitle=$name;
  143 + $content=$this->render('class',array('class'=>$class),true);
  144 + $content=preg_replace_callback(self::URL_PATTERN,array($this,'fixOfflineLink'),$content);
  145 + file_put_contents($docPath.'/'.$name.'.html',$content);
  146 + }
  147 +
  148 + CFileHelper::copyDirectory($this->themePath.'/assets',$docPath,array('exclude'=>array('.svn')));
  149 +
  150 + $content=$this->renderPartial('chmProject',null,true);
  151 + file_put_contents($docPath.'/manual.hhp',$content);
  152 +
  153 + $content=$this->renderPartial('chmIndex',null,true);
  154 + file_put_contents($docPath.'/manual.hhk',$content);
  155 +
  156 + $content=$this->renderPartial('chmContents',null,true);
  157 + file_put_contents($docPath.'/manual.hhc',$content);
  158 + }
  159 +
  160 + protected function buildOnlinePages($docPath,$themePath)
  161 + {
  162 + $this->themePath=$themePath;
  163 + @mkdir($docPath);
  164 + $content=$this->renderPartial('index',null,true);
  165 + $content=preg_replace_callback(self::URL_PATTERN,array($this,'fixOnlineLink'),$content);
  166 + file_put_contents($docPath.'/index.php',$content);
  167 +
  168 + foreach($this->classes as $name=>$class)
  169 + {
  170 + $this->currentClass=$name;
  171 + $this->pageTitle=$name;
  172 + $content=$this->renderPartial('class',array('class'=>$class),true);
  173 + $content=preg_replace_callback(self::URL_PATTERN,array($this,'fixOnlineLink'),$content);
  174 + file_put_contents($docPath.'/'.$name.'.php',$content);
  175 + }
  176 + }
  177 +
  178 + protected function buildModel($sourcePath,$options)
  179 + {
  180 + $files=CFileHelper::findFiles($sourcePath,$options);
  181 + $model=new ApiModel;
  182 + $model->build($files);
  183 + return $model;
  184 + }
  185 +
  186 + public function renderInheritance($class)
  187 + {
  188 + $parents=array($class->signature);
  189 + foreach($class->parentClasses as $parent)
  190 + {
  191 + if(isset($this->classes[$parent]))
  192 + $parents[]='{{'.$parent.'|'.$parent.'}}';
  193 + else
  194 + $parents[]=$parent;
  195 + }
  196 + return implode(" &raquo;\n",$parents);
  197 + }
  198 +
  199 + public function renderImplements($class)
  200 + {
  201 + $interfaces=array();
  202 + foreach($class->interfaces as $interface)
  203 + {
  204 + if(isset($this->classes[$interface]))
  205 + $interfaces[]='{{'.$interface.'|'.$interface.'}}';
  206 + else
  207 + $interfaces[]=$interface;
  208 + }
  209 + return implode(', ',$interfaces);
  210 + }
  211 +
  212 + public function renderSubclasses($class)
  213 + {
  214 + $subclasses=array();
  215 + foreach($class->subclasses as $subclass)
  216 + {
  217 + if(isset($this->classes[$subclass]))
  218 + $subclasses[]='{{'.$subclass.'|'.$subclass.'}}';
  219 + else
  220 + $subclasses[]=$subclass;
  221 + }
  222 + return implode(', ',$subclasses);
  223 + }
  224 +
  225 + public function renderTypeUrl($type)
  226 + {
  227 + if(isset($this->classes[$type]) && $type!==$this->currentClass)
  228 + return '{{'.$type.'|'.$type.'}}';
  229 + else
  230 + return $type;
  231 + }
  232 +
  233 + public function renderSubjectUrl($type,$subject,$text=null)
  234 + {
  235 + if($text===null)
  236 + $text=$subject;
  237 + if(isset($this->classes[$type]))
  238 + return '{{'.$type.'::'.$subject.'|'.$text.'}}';
  239 + else
  240 + return $text;
  241 + }
  242 +
  243 + public function renderPropertySignature($property)
  244 + {
  245 + if(!empty($property->signature))
  246 + return $property->signature;
  247 + $sig='';
  248 + if(!empty($property->getter))
  249 + $sig=$property->getter->signature;
  250 + if(!empty($property->setter))
  251 + {
  252 + if($sig!=='')
  253 + $sig.='<br/>';
  254 + $sig.=$property->setter->signature;
  255 + }
  256 + return $sig;
  257 + }
  258 +
  259 + protected function fixOfflineLink($matches)
  260 + {
  261 + if(($pos=strpos($matches[1],'::'))!==false)
  262 + {
  263 + $className=substr($matches[1],0,$pos);
  264 + $method=substr($matches[1],$pos+2);
  265 + return "<a href=\"{$className}.html#{$method}\">{$matches[2]}</a>";
  266 + }
  267 + else
  268 + return "<a href=\"{$matches[1]}.html\">{$matches[2]}</a>";
  269 + }
  270 +
  271 + protected function fixOnlineLink($matches)
  272 + {
  273 + if(($pos=strpos($matches[1],'::'))!==false)
  274 + {
  275 + $className=substr($matches[1],0,$pos);
  276 + $method=substr($matches[1],$pos+2);
  277 + if($className==='index')
  278 + return "<a href=\"/doc/api/#{$method}\">{$matches[2]}</a>";
  279 + else
  280 + return "<a href=\"/doc/api/{$className}#{$method}\">{$matches[2]}</a>";
  281 + }
  282 + else
  283 + {
  284 + if($matches[1]==='index')
  285 + return "<a href=\"/doc/api/\">{$matches[2]}</a>";
  286 + else
  287 + return "<a href=\"/doc/api/{$matches[1]}\">{$matches[2]}</a>";
  288 + }
  289 + }
  290 +}
79 build/commands/AutoloadCommand.php
... ... @@ -0,0 +1,79 @@
  1 +<?php
  2 +/**
  3 + * AutoloadCommand class file.
  4 + *
  5 + * @author Qiang Xue <qiang.xue@gmail.com>
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright &copy; 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + * @version $Id$
  10 + */
  11 +
  12 +/**
  13 + * AutoloadCommand generates the class map for {@link YiiBase}.
  14 + * The class file YiiBase.php will be modified with updated class map.
  15 + *
  16 + * @author Qiang Xue <qiang.xue@gmail.com>
  17 + * @version $Id$
  18 + * @package system.build
  19 + * @since 1.0
  20 + */
  21 +class AutoloadCommand extends CConsoleCommand
  22 +{
  23 + public function getHelp()
  24 + {
  25 + return <<<EOD
  26 +USAGE
  27 + build autoload
  28 +
  29 +DESCRIPTION
  30 + This command updates YiiBase.php with the latest class map.
  31 + The class map is used by Yii::autoload() to quickly include a class on demand.
  32 +
  33 + Do not run this command unless you change or add core framework classes.
  34 +
  35 +EOD;
  36 + }
  37 +
  38 + /**
  39 + * Execute the action.
  40 + * @param array command line parameters specific for this command
  41 + */
  42 + public function run($args)
  43 + {
  44 + $options=array(
  45 + 'fileTypes'=>array('php'),
  46 + 'exclude'=>array(
  47 + '.svn',
  48 + '/messages',
  49 + '/views',
  50 + '/cli',
  51 + '/yii.php',
  52 + '/web/js',
  53 + '/vendors',
  54 + '/i18n/data',
  55 + ),
  56 + );
  57 + $files=CFileHelper::findFiles(YII_PATH,$options);
  58 + $map='';
  59 + foreach($files as $file)
  60 + {
  61 + if(($pos=strpos($file,YII_PATH))!==0)
  62 + die("Invalid file '$file' found.");
  63 + $path=str_replace('\\','/',substr($file,strlen(YII_PATH)));
  64 + $className=substr(basename($path),0,-4);
  65 + if($className[0]==='C')
  66 + $map.="\t\t'$className' => '$path',\n";
  67 + }
  68 +
  69 + $yiiBase=file_get_contents(YII_PATH.'/YiiBase.php');
  70 + $newYiiBase=preg_replace('/private static \$_classes=array\([^\)]*\);/',"private static \$_classes=array(\n{$map}\t);",$yiiBase);
  71 + if($yiiBase!==$newYiiBase)
  72 + echo "Nothing changed.\n";
  73 + else
  74 + {
  75 + file_put_contents(YII_PATH.'/YiiBase.php',$newYiiBase);
  76 + echo "YiiBase.php is updated successfully.\n";
  77 + }
  78 + }
  79 +}
325 build/commands/CldrCommand.php
... ... @@ -0,0 +1,325 @@
  1 +<?php
  2 +/**
  3 + * CldrCommand class file.
  4 + *
  5 + * @author Qiang Xue <qiang.xue@gmail.com>
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright &copy; 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + * @version $Id$
  10 + */
  11 +
  12 +/**
  13 + * CldrCommand converts the locale data from the {@link http://www.unicode.org/cldr/ CLDR project}
  14 + * to PHP scripts so that they can be more easily used in PHP programming.
  15 + *
  16 + * The script respects locale inheritance so that the PHP data for a child locale
  17 + * will contain all its parents' locale data if they are not specified in the child locale.
  18 + * Therefore, to import the data for a locale, only the PHP script for that particular locale
  19 + * needs to be included.
  20 + *
  21 + * Note, only the data relevant to number and date formatting are extracted.
  22 + * Each PHP script file is named as the corresponding locale ID in lower case.
  23 + *
  24 + * @author Qiang Xue <qiang.xue@gmail.com>
  25 + * @version $Id$
  26 + * @package system.build
  27 + * @since 1.0
  28 + */
  29 +class CldrCommand extends CConsoleCommand
  30 +{
  31 + public function getHelp()
  32 + {
  33 + return <<<EOD
  34 +USAGE
  35 + build cldr <data-path>
  36 +
  37 +DESCRIPTION
  38 + This command converts the locale data from the CLDR project
  39 + to PHP scripts so that they can be more easily used in PHP programming.
  40 +
  41 + The script respects locale inheritance so that the PHP data for
  42 + a child locale will contain all its parent locale data if they are
  43 + not specified in the child locale. Therefore, to import the data
  44 + for a locale, only the PHP script for that particular locale needs
  45 + to be included.
  46 +
  47 + Note, only the data relevant to number and date formatting are extracted.
  48 + Each PHP script file is named as the corresponding locale ID in lower case.
  49 +
  50 + The resulting PHP scripts are created under the same directory that
  51 + contains the original CLDR data.
  52 +
  53 +PARAMETERS
  54 + * data-path: required, the original CLDR data directory. This
  55 + directory should contain hundreds of XML files.
  56 +
  57 +EOD;
  58 + }
  59 +
  60 + /**
  61 + * Execute the action.
  62 + * @param array command line parameters specific for this command
  63 + */
  64 + public function run($args)
  65 + {
  66 + if(!isset($args[0]))
  67 + $this->usageError('the CLDR data directory is not specified.');
  68 + if(!is_dir($path=$args[0]))
  69 + $this->usageError("directory '$path' does not exist.");
  70 +
  71 + // collect XML files to be processed
  72 + $options=array(
  73 + 'exclude'=>array('.svn'),
  74 + 'fileTypes'=>array('xml'),
  75 + 'level'=>0,
  76 + );
  77 + $files=CFileHelper::findFiles(realpath($path),$options);
  78 + $sourceFiles=array();
  79 + foreach($files as $file)
  80 + $sourceFiles[basename($file)]=$file;
  81 +
  82 + // sort by file name so that inheritances can be processed properly
  83 + ksort($sourceFiles);
  84 +
  85 + // process root first because it is inherited by all
  86 + if(isset($sourceFiles['root.xml']))
  87 + {
  88 + $this->process($sourceFiles['root.xml']);
  89 + unset($sourceFiles['root.xml']);
  90 +
  91 + foreach($sourceFiles as $sourceFile)
  92 + $this->process($sourceFile);
  93 + }
  94 + else
  95 + die('Unable to find the required root.xml under CLDR data directory.');
  96 + }
  97 +
  98 + protected function process($path)
  99 + {
  100 + $source=basename($path);
  101 + echo "processing $source...";
  102 +
  103 + $dir=dirname($path);
  104 + $locale=substr($source,0,-4);
  105 + $target=$locale.'.php';
  106 +
  107 + // retrieve parent data first
  108 + if(($pos=strrpos($locale,'_'))!==false)
  109 + $data=require($dir.DIRECTORY_SEPARATOR.substr($locale,0,$pos).'.php');
  110 + else if($locale!=='root')
  111 + $data=require($dir.DIRECTORY_SEPARATOR.'root.php');
  112 + else
  113 + $data=array();
  114 +
  115 + $xml=simplexml_load_file($path);
  116 +
  117 + $this->parseVersion($xml,$data);
  118 +
  119 + $this->parseNumberSymbols($xml,$data);
  120 + $this->parseNumberFormats($xml,$data);
  121 + $this->parseCurrencySymbols($xml,$data);
  122 +
  123 + $this->parseMonthNames($xml,$data);
  124 + $this->parseWeekDayNames($xml,$data);
  125 + $this->parseEraNames($xml,$data);
  126 +
  127 + $this->parseDateFormats($xml,$data);
  128 + $this->parseTimeFormats($xml,$data);
  129 + $this->parseDateTimeFormat($xml,$data);
  130 + $this->parsePeriodNames($xml,$data);
  131 +
  132 + $data=var_export($data,true);
  133 + $locale=substr(basename($path),0,-4);
  134 + $content=<<<EOD
  135 +/**
  136 + * Locale data for '$locale'.
  137 + *
  138 + * This file is automatically generated by yiic cldr command.
  139 + *
  140 + * Copyright © 1991-2007 Unicode, Inc. All rights reserved.
  141 + * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
  142 + *
  143 + * Copyright © 2008 Yii Software LLC (http://www.yiiframework.com/license/)
  144 + */
  145 +return $data;
  146 +EOD;
  147 +
  148 + file_put_contents($dir.DIRECTORY_SEPARATOR.strtolower($locale).'.php',"<?php\n".$content."\n?>");
  149 +
  150 + echo "done.\n";
  151 + }
  152 +
  153 + protected function parseVersion($xml,&$data)
  154 + {
  155 + preg_match('/[\d\.]+/',(string)$xml->identity->version['number'],$matches);
  156 + $data['version']=$matches[0];
  157 + }
  158 +
  159 + protected function parseNumberSymbols($xml,&$data)
  160 + {
  161 + foreach($xml->xpath('/ldml/numbers/symbols/*') as $symbol)
  162 + $data['numberSymbols'][$symbol->getName()]=(string)$symbol;
  163 + }
  164 +
  165 + protected function parseNumberFormats($xml,&$data)
  166 + {
  167 + $pattern=$xml->xpath('/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern');
  168 + if(isset($pattern[0]))
  169 + $data['decimalFormat']=(string)$pattern[0];
  170 + $pattern=$xml->xpath('/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern');
  171 + if(isset($pattern[0]))
  172 + $data['scientificFormat']=(string)$pattern[0];
  173 + $pattern=$xml->xpath('/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern');
  174 + if(isset($pattern[0]))
  175 + $data['percentFormat']=(string)$pattern[0];
  176 + $pattern=$xml->xpath('/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern');
  177 + if(isset($pattern[0]))
  178 + $data['currencyFormat']=(string)$pattern[0];
  179 + }
  180 +
  181 + protected function parseCurrencySymbols($xml,&$data)
  182 + {
  183 + $currencies=$xml->xpath('/ldml/numbers/currencies/currency');
  184 + foreach($currencies as $currency)
  185 + {
  186 + if((string)$currency->symbol!='')
  187 + $data['currencySymbols'][(string)$currency['type']]=(string)$currency->symbol;
  188 + }
  189 + }
  190 +
  191 + protected function parseMonthNames($xml,&$data)
  192 + {
  193 + $monthTypes=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/months/monthContext[@type=\'format\']/monthWidth');
  194 + if(is_array($monthTypes))
  195 + {
  196 + foreach($monthTypes as $monthType)
  197 + {
  198 + $names=array();
  199 + foreach($monthType->xpath('month') as $month)
  200 + $names[(string)$month['type']]=(string)$month;
  201 + if($names!==array())
  202 + $data['monthNames'][(string)$monthType['type']]=$names;
  203 + }
  204 + }
  205 +
  206 + if(!isset($data['monthNames']['abbreviated']))
  207 + $data['monthNames']['abbreviated']=$data['monthNames']['wide'];
  208 +
  209 + $monthTypes=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']');
  210 + if(is_array($monthTypes) && isset($monthTypes[0]))
  211 + {
  212 + foreach($monthTypes[0]->xpath('month') as $month)
  213 + $data['monthNames']['narrow'][(string)$month['type']]=(string)$month;
  214 + }
  215 + }
  216 +
  217 + protected function parseWeekDayNames($xml,&$data)
  218 + {
  219 + static $mapping=array(
  220 + 'sun'=>0,
  221 + 'mon'=>1,
  222 + 'tue'=>2,
  223 + 'wed'=>3,
  224 + 'thu'=>4,
  225 + 'fri'=>5,
  226 + 'sat'=>6,
  227 + );
  228 + $dayTypes=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/days/dayContext[@type=\'format\']/dayWidth');
  229 + if(is_array($dayTypes))
  230 + {
  231 + foreach($dayTypes as $dayType)
  232 + {
  233 + $names=array();
  234 + foreach($dayType->xpath('day') as $day)
  235 + $names[$mapping[(string)$day['type']]]=(string)$day;
  236 + if($names!==array())
  237 + $data['weekDayNames'][(string)$dayType['type']]=$names;
  238 + }
  239 + }
  240 +
  241 + if(!isset($data['weekDayNames']['abbreviated']))
  242 + $data['weekDayNames']['abbreviated']=$data['weekDayNames']['wide'];
  243 +
  244 + $dayTypes=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']');
  245 + if(is_array($dayTypes) && isset($dayTypes[0]))
  246 + {
  247 + foreach($dayTypes[0]->xpath('day') as $day)
  248 + $data['weekDayNames']['narrow'][(string)$day['type']]=(string)$day;
  249 + }
  250 + }
  251 +
  252 + protected function parsePeriodNames($xml,&$data)
  253 + {
  254 + $am=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/am');
  255 + if(is_array($am) && isset($am[0]))
  256 + $data['amName']=(string)$am[0];
  257 + $pm=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/pm');
  258 + if(is_array($pm) && isset($pm[0]))
  259 + $data['pmName']=(string)$pm[0];
  260 + }
  261 +
  262 + protected function parseEraNames($xml,&$data)
  263 + {
  264 + $era=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/eras/eraAbbr');
  265 + if(is_array($era) && isset($era[0]))
  266 + {
  267 + foreach($era[0]->xpath('era') as $e)
  268 + $data['eraNames']['abbreviated'][(string)$e['type']]=(string)$e;
  269 + }
  270 +
  271 + $era=$xml->xpath('/ldml/dates/calendars/calendar[@type=\'gregorian\']/eras/eraNames');
  272 + if(is_array($era) && isset($era[0]))
  273 + {
  274 + foreach($era[0]->xpath('era') as $e)
  275 + $data['eraNames']['wide'][(string)$e['type']]=(string)$e;
  276 + }
  277 + else if(!isset($data['eraNames']['wide']))
  278 + $data['eraNames']['wide']=$data['eraNames']['abbreviated'];
  279 +