Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core...

47
Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most popular web programming language gets even better with an easy to use framework for developing the next generation of web applications.

Transcript of Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core...

Page 1: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Copyright © 2007, Zend Technologies Inc.

Zend Framework

Thomas Weidner

I18N Team Leader and Core Developer,

for the Zend Framework

Now, the world's most popular web programming language gets even better with an easy to use framework for developing the next generation of web applications.

Page 2: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Nội dung

1. Giới thiệu

2. Phân tích và thiết kế

3. Hiện thực các module

4. Tổng kết

01/2010Visual Idea | Page 2

Page 3: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 3

Giới thiệu

• Giới thiệu framework: Visual Idea (VI)

• Vị trí của VI trong quy trình phát triển web

• Lợi ích VI mang lại khi hiện thực website

Page 4: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Giới thiệu framework: Visual Idea(VI)

• Khái niệm framework[5]: Framework là khung sườn đã xây dựng sẵn nhiều công cụ lập trình và các thư viện cũng như tiện ích để phát triển ứng dụng một cách tốt nhất.

• Framework Visual Idea(viết tắt là VI): là một framework được xây dựng với mục đích giúp phát triển nhanh và trực quan ứng dụng web dựa trên những ý tưởng mới và công nghệ web mới nhất.

2007-06-02Zend Framework | Page 4

Page 5: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

VI Framework

Vị trí của VI trong quy trình phát triển web[6]

2007-06-02Zend Framework | Page 5

Thiết kế mỹ thuật và thiết kế giao diện cho website.

Liện hệ và phân tích yêu cầu từ khách hàng và tư vấn các chức năng của website.

Hiện thực các chức năng của website theo yêu cầu.

Bước 1 Bước 2 Bước 3

Kiểm tra, triển khai và bảo trì ứng dụng web.

Bước 4

Page 6: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Lợi ích VI mang lại khi hiện thực website

2007-06-02Zend Framework | Page 6

• Các đối tượng tham gia website

Page 7: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Các lợi ích VI mang lại khi thiết kế website

• Tận dụng được lại tất cả những gì đã viết trước đó

• Dễ dàng viết module mới với hỗ trợ trực quan

• Tận dụng mô hình MVC trong lập trình

• Tổ chức giao diện nhanh chóng và tiện lợi

• Thay đổi giao diện trực quan bằng cách kéo thả

• Giao diện quản lý trực quan gần với ứng dụng desktop

• Đa ngôn ngữ tự động

• Phân quyền mềm dẽo không hạn chế các quyền trên tác vụ.

2007-06-02Zend Framework | Page 7

Page 8: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Nội dung

1. Giới thiệu

2. Phân tích và thiết kế

3. Hiện thực các module

4. Tổng kết

01/2010Visual Idea | Page 8

Page 9: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 9

Phân tích thiết kế hệ thống

• Bài toán thiết kế framework

• Thiết kế các thành phần framework

Page 10: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Bài toán thiết kế framework

Thiết kế framework là bài toán cho đến nay chưa có lời giải tối

2007-06-02Zend Framework | Page 10

Page 11: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 11

What’s in the Zend Framework?

MVC web app framework(model-view-controller)

Database access Lucene-compatible Search engine Input filtering and validation Authentication Access control Session handling I18N, translation PDF file reading and writing

HTTP client XmlRpc REST web services RSS and Atom feeds Google Gdata client Logging Mail reading and sending Caching Configuration file handling Command-line option parsing

• Simple, convenient object-oriented solutions to common web application development tasks:

Page 12: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 12

API Overview

Page 13: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 13

Component Overview 1/4

• MVC Layer Zend_Controller – Controller Pattern Zend_View – View Pattern

• DATA Layer Zend_Db – Database Handling Zend_Pdf – PDF Creation and Handling Zend_Search – Lucene Search

• I18N Layer Zend_Date – Localized Date handling Zend_Locale – I18N Base class, Localisation Zend_Measure – Measurements, conversions Zend_Translate – Translations

Page 14: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 14

Component Overview 2/4

• WEB Services Layer Zend_Feed – RSS und ATOM Feeds Zend_GData – Google Data Client Zend_Http – HTTP Client and Server Zend_Json – JSON Access Zend_Rest – Rest Client and Server Zend_XmlRpc – XMLRPC Client and Server Zend_Service – Access for different web services including

• Askimet• Amazon• Audioscrobbler• Delicious• Flickr• Simpy• Yahoo• and more are already in the incubator or proposed

Page 15: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 15

Component Overview 3/4

• Core Layer Zend_Acl – Access Controll List, Limiting ressources, roles, users Zend_Auth – Authentication Zend_Cache – Caching Zend_Config – Configuration Handling Zend_Console – Console Options Handling Zend_Filter – Filtering Input data Zend_Log – Log file Handling (log4j based) Zend_Mail – Mail sending and receiving Zend_Memory – Memory Access when memory is limited Zend_Registry – Storing data within an application registry Zend_Session – Session Handling Zend_Validate – Validating

Page 16: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 16

Component Overview 4/4

• Incubator Components… after 1.0 release, already partitial useable Zend_Currency – Localized currency handling (I18N) Zend_Environment – (Core) Zend_Form – Form handling (MVC) Zend_Soap – Soap Client and Server (Services) Zend_Timesync – Timeserver access (NTP, SNTP) (I18N)

• Future Components Several additional components proposed including… LDAP, Calendar, PayPal, YouTube, Yaml…

• Proposals http://framework.zend.com/wiki/display/ZFPROP/Home

Page 17: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 17

Directory layout

/Zend

/Zend/Locale.php

/Zend/Locale

/Zend/Locale/Format.php

A component is always a base class and all subclasses in it’s same named directory. ..

This way single components can be used without installing the complete framework…

Page 18: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 18

Minimum requirements

• Some Minimum requirements

PHP 5.1.4 Webserver Standard installation commonly no additional extensions needed

• That’s all…

Page 19: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 19

A simple example 1/4

• A simple example – Localisation:

<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); print $locale->toString();

Page 20: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 20

A simple example 2/4

• Each class can be used alone:

<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); print $locale->toString();

Requiring the file is enough…

Each component knows which other components it has to load

Page 21: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 21

A simple example 3/4

• Location of the ZF components:

<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); print $locale->toString();

All components are in the same directory.

Page 22: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 22

A simple example 4/4

• The result: our users language

<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); print $locale->toString();

The visiting users language…

Page 23: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 23

Localisation

• Possibilities of Zend_Locale

Get the client users languages Get localized data Base localisation class for ZF Locale aware formating of numbers, dates and times

• Example1

• Example2

Page 24: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 24

Localized data

• Localized and translated data:

Translation for all languages Translation for all scripts Translation for countries and territories Calendar formats Month- and Day names Standard formats for Date and Time Currency name, signs and formats Characters used in this language Yes and no strings …

Page 25: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 25

Locale aware formating rules

• Zend_Locale_Format Converting from one script to another Normalizing of numbers (12,345.45 -> 12345.45) Localizing of numbers (12345.45 -> 12,345.45) Checking if a localized number is valid Normalizing date & time inputs Checking if a localized date or time input is valid

Page 26: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 26

Script conversion

• From european digits to arabic digits and visa versa

<?phprequire_once ‘Zend/Locale.php’;

$number = “12345”;

$converted = Zend_Locale_Format::convertNumerals($number, ‘Latn’, ‘Arab’);

$european = Zend_Locale_Format::convertNumerals($converted, ‘Arab’, ‘Latn’);

• Example3

Page 27: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 27

Number normalization

• Normalizing numbers

<?phprequire_once ‘Zend/Locale.php’;

$number = “12.345,67”;

$normal = Zend_Locale_Format::getNumber($number);

• Example4

Page 28: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 28

Number localization

• Localizing numbers

<?phprequire_once ‘Zend/Locale.php’;

$number = 12345.67;

$normal = Zend_Locale_Format::toNumber($number);

• Example5

• Example8

Page 29: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 29

Multilingual applications

• Making applications running worldwide

Translating output Format of date and time Format of numbers Format of currencies Knowing allowed characters of a language

Page 30: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 30

Translation

• Gettext… the old way

• <?phpbindtextdomain(‘domain’, ‘path’);textdomain(‘domain’);

print gettext(‘my translation’);

• Fixed directory layout /path/LC_ALL/locale/

• Needs an extension to work

• Complicated for people unfamiliar to GNUs gettext

Page 31: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 31

Zend_Translate

• Gettext… with Zend_Translate

• <?phprequire_once ‘Zend/Translate.php’; // within bootstrap file

$tr = new Zend_Translate(AN_ARRAY, ‘Path/to/myfile.mo’, ‘de’);print $tr->_(‘my translation’);

• No fixed directory layout

• No extension needed

• Same API for all sources

Page 32: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 32

Zend_Translate sources

• Zend_Translate sources One API for all sources Supported sources are:

• Array

• Csv

• Gettext

• Qt

• Tmx

• Xliff

More to come (SQL, XmlTm, …)

Page 33: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 33

Switching sources

• Changing sources ? No problem…

• <?phprequire_once ‘Zend/Translate.php’; // within bootstrap file

$tr = new Zend_Translate(AN_CSV, ‘Path/to/myfile.csv’, ‘de’);print $tr->_(‘my translation’);

• <?phprequire_once ‘Zend/Translate.php’; // within bootstrap file

$tr = new Zend_Translate(AN_GETTEXT, ‘Path/to/myfile.mo’, ‘de’);print $tr->_(‘my translation’);

• Just one small change, same API

Page 34: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 34

Conditional translating

• Is a string translateable ?

• <?phprequire_once ‘Zend/Translate.php’; // within bootstrap file

$tr = new Zend_Translate(AN_CSV, ‘Path/to/myfile.csv’, ‘de’);if ($tr->isTranslated(‘my translation’)) {

// do something} else {

// no translation, do something else}

• Not possible with php

Page 35: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 35

Allowed characters

• Verifying input… but localized ?

• <?phprequire_once ‘Zend/Locale.php’; // within bootstrap file

$tr = new Zend_Locale();$de = $tr->getTranslationList(‘characters’, ‘de’);$fr = $tr->getTranslationList(‘characters’, ‘fr’);

• For more than 128 languages

• Example6

Page 36: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 36

Language selectbox

• Creating a localized selectbox for languages ?

• <?phprequire_once ‘Zend/Locale.php’; // within bootstrap file

$tr = new Zend_Locale();$de = $tr->getTranslationList(‘language’);foreach ($de as $key => $value) {

$fr = $tr->getTranslationList(‘language’, $key);print $fr[$key];

}

• Example7

Page 37: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 37

Yes or No

• How to realize a yes-no for every language ?

• <?phprequire_once ‘Zend/Locale.php’; // within bootstrap file

$tr = new Zend_Locale();$de = $tr->getQuestion();

• Example9

Page 38: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 38

Normalizing dates

• Monthnames / Daynames

• <?phprequire_once ‘Zend/Locale.php’; // within bootstrap file

$date = “12.März.2007 20:15:00”;$tr = new Zend_Locale_Format::getDate($date, ‘de’);print_r($tr);

• Example10

Page 39: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 39

Working with dates

• Zend_Date

One class Handles all meanings (date, time, parts, sun…) Simple API Easy handling ISO Standard also PHP’s GNU supported Knows more than 50 standard represenations Unlimited (more than 64bit) dates supported

Page 40: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 40

Working with dates 2

• Capabilities

Computing dates Get sunset / sunrise for cities Easy changing with ISO ( dd.MM.yyyy HH:mm:ss a ) Supports different standards

( ISO, GNU, RFC2822 (mail), W3C, RSS, Cookies…)

Page 41: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 41

Date maths

• Computing dates

Normalized Localized Added / Substracted Checked (earlier, later, equal Splitted Converted …

Page 42: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 42

Date example

• Example11

$date = new Zend_Date(‘20070414T122050’, Zend_Date::ISO_8601);

$date->addMonth(2);$date->subYear(6);

If ($date->isLeapYear()) { // LeapYear} else { // NO LeapYear}

Page 43: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 43

Checking dates

• Check if a date is a date

If ( Zend_Date::isDate(’14. April. 2007 10:20:55’))

• Example12

• Compare parts

If ( $date->compareWeekday(2))

• Example13

Page 44: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 44

Stay up

• Calculating sunset / sunrise

With php… complicated With Zend_Date… just know your city

$city = Zend_Date_Cities::City(‘Amsterdam’);$date = new Zend_Date();$uptime = $date->getSunrise($city)

Page 45: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 45

At the end

• Simple solution

• Easy handling

• Easy extending – 80% use case

• High quality

• Growing fast

Page 46: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

2007-06-02Zend Framework | Page 46

Tài liệu tham khảo

1. Adfadf

2. Adfadf

3. Adfa

4. sdfdfasdf

5. http://www.codeproject.com/KB/architecture/WhatIsAFramework.aspx

6. http://vmtgroup.net/index.php?page=dichvu&id=381&idsub=389&idtin=741

Page 47: Copyright © 2007, Zend Technologies Inc. Zend Framework Thomas Weidner I18N Team Leader and Core Developer, for the Zend Framework Now, the world's most.

Copyright © 2007, Zend Technologies Inc.

Thankshttp://framework.zend.com/