Sunday, June 24, 2007

Ubuntu 7.10 Features Overview

Announced at the middle of April 2007, the next version of Ubuntu Linux distribution (7.10, codename Gutsy Gibbon) has already started to stir up a lot of interest among the Ubuntu fans around the world. The Ubuntu team announced today the features that Ubuntu 7.10 will bring in late October this year. Here’s a quick overview of the features you will find in Ubuntu 7.10:

Desktop

Ubuntu 7.10 will ship with the latest version of the GNOME desktop (2.20), which will be released a few weeks before the final version of Gutsy Gibbon. On the other hand, Kubuntu will ship with the latest version of the KDE desktop (3.5.7). Moreover, Kubuntu users will have the possibility of installing KDE 4.0 RC2 packages.

Ubuntu 7.10 will be the first distribution to include the newly merged Beryl and Compiz projects, which will be the default window manager on systems that will support it.

Hardware Support

The Linux kernel 2.6.22 with the usual selection of updated and additional drivers will be part of the Ubuntu 7.10 release.

Ubuntu 7.10 will include the most awaited release of Xorg, version 7.3, which brings bleeding-edge features such as:
  • better graphics hardware support;
  • hotplug monitors and input devices;
  • easier configuration;
  • hotplugging-supported drivers (no xorg.conf).
You should also expect improvements to the Restricted Driver Manager, and the "winmodem" chips will be supported out of the box (where drivers are available).

Mobile

Ubuntu 7.10 will be the first release available for hand-held devices and other
mobile/embedded form factors, through the Mobile and Embedded edition.

Server

Ubuntu 7.10 Server Edition aims to attract more and more server administrators and it will bring attractive features for small businesses and organizations. Novel's AppArmor security framework will also be available for those that want it.

Stability and Performance

Last but not least, Ubuntu 7.10 is promised to be more stable and powerful than the previous releases were. The system should work much better when the filesystem is full, allowing the user to make room and continue his work without interruption.

Moreover, Upstart 0.5 will be on board of Ubuntu 7.10 to provide flexible and reliable service supervision. Also, the boot process will "suffer" improvements and reduce start-up time.

The release schedule for Gutsy Gibbon was also made public. The development process started as expected, on June 7th, with the first Alpha release, and it will end somewhere around October 18th with the final release:
  • June 7th - Tribe CD 1 (first alpha release)
  • June 28st - Tribe CD 2 (second alpha release)
  • July 26th - Tribe CD 3 (third alpha release)
  • August 9th - Tribe CD 4 (fourth alpha release)
  • August 23rd - Tribe CD 5 (fifth alpha release)
  • September 6th - Tribe CD 6 (sixth alpha release)
  • September 27th - Beta Release
  • October 11th - Release Candidate
  • October 18th - Final Release
To know the downloading details : Ubuntu, Xubuntu, Kubuntu, Edubuntu 7.10 (Gutsy Gibbon) Tribe 1 - Free

Lập trình PHP bằng công nghệ template

PHP là một ngôn ngữ lập trình hướng template. Thật tế thì ta đã có thể lập trình tách biệt giao diện và phần xử lý của PHP rất tốt rồi, tuy nhiên các nhà lập trình PHP vẫn chưa dừng lại, họ muốn một sự tách biệt thật rõ ràng và thế là các lớp xử lý template và nhất là smarty đã ra đời để đáp ứng nhu cầu đó.
Hôm nay tôi muốn giới thiệu đến các bạn cách sử dụng một lớp dùng để lập trình template trong PHP: xtemplate. Ngoài ra, tôi cũng demo và giải thích cho các bạn các ví dụ trong phần docs của gói nầy.
Bạn vào trang http://sourceforge.net/projects/xtpl/ download gói xtemplate về.
Đầu tiên bạn tạo một thư mục web là test. Sau đó bạn giải nén gói xtemplate và chép file xtemplate.class.php vào thư mục test.
Bây giờ bắt đầu ví dụ thui ;) ok ?
ví dụ 1:
Bạn chép file ex1.xtpl và file ex2.php vào thư mục test. Sau đó mở trình duyệt và mở file ex1.php
Trang web sẽ xuất ra như sau:

This is a simple replace test. the text in bold should contain "TEST": TEST
now a dynamic block test:
this is block 1.

id 38
name cocomp
age 33


global variables can be parsed directly into the html without assigns:
$_SERVER['HTTP_HOST']=localhost
$_SERVER['PHP_SELF']=/test/ex1.php
$_SERVER['HTTP_USER_AGENT']=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20061201 Firefox/2.0.0.4 (Ubuntu-feisty)
etc..
(note that these variables are scanned in the constructor when creating the XTemplate object! so if you need some variables which you have set after creating the template object, you need to call $xtpl->scan_globals() before parsing the actual block!

Bạn hãy xem nội dung file template : ex1.xtpl
<!-- BEGIN: main -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>example 1</title>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="Co-Comp Ltd" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<!-- $HeadURL: https://xtpl.svn.source...root/xtpl/trunk/ex1.xtpl $
$Id: ex1.xtpl 16 2007-01-11 03:02:49Z cocomp $ -->
<body>
<p>This is a simple replace test. the text in bold should contain "TEST": <b>{VARIABLE}</b><br />
now a dynamic block test:<br />
<!-- BEGIN: block1 -->
this is block 1.<br />
<!-- END: block1 -->
<!-- BEGIN: block2 -->
this is block 2.<br />
<!-- END: block2 -->
</p>
<!-- BEGIN: block3#You can comment a block like this -->
<table border="1">
<tr>
<td>id</td>
<td>{DATA.ID}</td>
</tr>
<tr>
<td>name</td>
<td>{DATA.NAME#You can comment tags like this}</td>
</tr>
<tr>
<td>age</td>
<td>{DATA.AGE}</td>
</tr>
</table>
<!-- END: block3#Or comment it here too -->
<p><br />
global variables can be parsed directly into the html without assigns:<br />
$_SERVER['HTTP_HOST']={PHP._SERVER.HTTP_HOST}<br />
$_SERVER['PHP_SELF']={PHP._SERVER.PHP_SELF}<br />
$_SERVER['HTTP_USER_AGENT']={PHP._SERVER.HTTP_USER_AGENT}<br />
etc..<br />
(<span >note</span> that these variables are scanned in the constructor when creating the XTemplate object!
so if you need some variables which you have set after creating the template object, you need to call <b>$xtpl->scan_globals()</b>
before parsing the actual block!</p>
</body>
</html>
<!-- END: main -->
Đầu tiên là block main (begin và end của nó bao trùm hết cả template, bạn hãy nhìn vào đầu và cuối file template nầy), nhân viên thiết kế giao diện phải làm theo đúng định dạng nầy. Để comment cho nhân viên lập trình biết block đó để làm gì và sẽ gán biến gì vào đó nhân viên thiết kế có thể comment bằng cách thêm dấu # và nội dung comment ngay sau đó.
Trong block main sẽ có thể có các block con, ở đây là block1, block2 và block3. Ngoài ra nó còn có các biến sẽ hiển thị và phần gán giá trị cho các biến nầy sẽ được file ex1.php lo ;)
Bạn hãy xem nội dung file source: ex1.php
//đầu tiên là phải include lớp xử lý template vào.
include_once('./xtemplate.class.php');
//tạo một đối tượng template
$xtpl = new XTemplate('ex1.xtpl');
// ta muốn gán biến VARIABLE trong block mail là TEST. Như các bạn đã thấy trên phần kết
//quả kết xuất trên trình duyệt
$xtpl->assign('VARIABLE', 'TEST');
// Bây giờ parse block1. block1 đơn giản chỉ là một chuỗi html: this is the block1
$xtpl->parse('main.block1');
// bạn bỏ dấu // ở dòng tiếp theo để parse block2 kết quả y chang khi parse block1
//$xtpl->parse('main.block2');
/**
* Bạn có thể xuất một mảng trong template bằng cách sau:
* {DATA.ID} hay {DATA.NAME} hay {DATA.AGE}
* Chúng ta có thể truy cập cơ sở dữ liệu để có các giá trị nầy: ID, NAME, AGE
*/
$row = array('ID'=>'38',
'NAME'=>'cocomp',
'AGE'=>'33'
);
//gán giá trị cho biến DATA sẽ được thể hiện trong block3
$xtpl->assign('DATA',$row);
// parse block3
$xtpl->parse('main.block3');
//cuối cùng parse block main
$xtpl->parse('main');
$xtpl->out('main');

Chú ý rằng ta sẽ parse các block theo thứ tự từ trong ra ngoài, nếu ta parse block ngoài mà chưa parse block trong thì sẽ không thể hiện block trong được.

Thế là xong ví dụ 1.
Hi vọng bạn có thể hiểu và áp dụng cho trang web của mình. Phần sau mình sẽ ví dụ cho phần hiển thị một bảng (table). Về phần áp dụng rất đơn giản. Trong trang web của bạn, có một phần , giả dụ là form login nhé ! ở phần hiển thị form login nầy bạn đơn giản chèn đoạn code xử lý template mong muốn vào, thế là xong. Tất nhiên file template (file giao diện) đã được bạn thiết kế.
source code ví dụ : comming soon