Thursday, March 5, 2009

Integrate Smarty with Zend_Layout

If you can endure adding {include file="header.tpl"} and {include file="footer.tpl"} in all of your template files, then you don't have to worry about this issue. And you are lucky! (You are even more lucky if you don't use smarty at all!)

Unfortunately, I cannot accept this kind of coding, so I have to face the pain and find out how to integrate smarty with zend_layout.

I can only find one article from internet regarding this issue. The article is here: http://anders.tyckr.com/2008/03/12/implementing-zend-layout-and-smarty-using-zend-framework-mvc/

It gives us a detailed solution to implement smary with zend layout, and it DOES WORK! Thank God...

CLI/Console program with Zend Framework

You can google this tutorial "PHP frameworks, Part 5: Integrating external tasks" for dealing with working outside the frameworks.

Even for a web application, we may need to run scripts in command line in some cases. For example, a cron job. And we want to use our models and Zend framework components. The most important thing is to setup include path to include your Zend library and your models. For example, if Zend is placed in 'library' folder, we can
set_include_path('.' . PATH_SEPARATOR . ROOT_DIR . '/library/'
. PATH_SEPARATOR . ROOT_DIR . '/application/models/'
. PATH_SEPARATOR . get_include_path());

require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();

That is it. Now you can use your models and Zend components as you use them in your web application. For example,

$config = new Zend_Config_Ini(ROOT_DIR . '/config/config.ini', 'cli');
Zend_Registry::set('config', $config);
//set up default time zone
date_default_timezone_set($config->date_default_timezone);

// configure database and store to the registery
$db = Zend_Db::factory($config->database);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db', $db);

//do sth
$user = new User();
$user->save();

$logFile = Zend_Registry::get('config')->logFile;
$log = new Zend_Log(new Zend_Log_Writer_Stream($logFile));
$log->info('a new user is saved');

Zend_Log limitation

I researched Zend_Log for a while today. My case is I want to user one logger and log messages to different files based on the message type. The message type is not Zend_Log's message priority. It is more event/action based. For example, i want to log login information to login.log and pay information to pay.log.

Although we can add multiple writters to a logger, we can't specify which writter we want to use. Well, i should say, I didn't find out how to specify a writter for Zend_Log.

Sure i know where there is an issue, there is a solution. But I wish next Zend framework release could bring us a better Zend_Log

smarty $compile_id for different $template_dirs

We might have different template dirs storing template files with an identified name. For example, we could have /Auth/index.tpl, /Buy/index.tpl. However, Smarty uses only one compile dir, and Smarty is not that smart. To display the two index.tpl correctly, we must specify $compile_id. If you set a distinct $compile_id for each template_dir, then Smarty can tell the compiled templates apart by their $compile_id.

Wednesday, March 4, 2009

2011年全球手机成人内容市场价值33亿美元

2011年全球手机成人内容市场价值33亿美元

发表日期:2006年11月29日 出处:CNET New
-----------------------------------------------------------------------------------------------

  就如同当年的互联网媒体产业,如今的移动内容市场也走上了迅速繁荣的老路:色情内容服务。

  据CNET News.com报道,据市场调查机构Juniper分析家预测,到2011年的时候,全球移动成人内容服务市场总价值将达到33亿美元,实际上,该数字在今年已经达到了14亿美元。

  据悉,欧洲是最大的移动色情内容服务市场,在色情内容的提供和需求方面,均走在全球的第一位。与此同时,亚太地区则在色情服务产业内排名第二。

  据Jupiter分析家透露,移动成人内容服务的崛起,与手机技术的迅速发展不无关系,可以说是技术的飞跃带动了一次又一次服务的创新。据统计,目前绝大多数手机色情服务还属于文字形式,而随着未来3G手机网络的逐渐普及,更多的多媒体形式服务将登陆移动市场,例如图片、音频和视频等,届时更为丰富的色情内容将出现在世面,而色情服务基础,也将从呆板的文字过渡向更为刺激的图像世界。据一份手机产业报告,到2011年的时候,移动市场70%的营收将来自于媒体服务,而不再是简单的硬件销售。

  “手机色情服务是一块巨大的市场,实际上,成人内容服务总是可以拉拢某一媒体平台的迅速发展。”Jupiter分析家表示。据悉,目前的手机成人内容服务还处于起步阶段,大多数用户发送含有成人内容的文字信息,只是为了取悦自己的伴侣而已。

Mobile content revenues to grow exponentially to 2009

From: http://www.wiliam.com.au/wiliam-blog/mobile-phone-and-mobile-content-to-grow-exponentially-to-2009

According to an article (Mobile revenue to top $1bn by 2009, AAP) in The Sydney Morning Herald, revenues from mobile content (mobile phones) in Australia are set to explode, exceeding a fantastic $1 billion on 2009.

Revenues from Australian mobile content were $129 million in 2004, with personalisation services such as mobile phone wallpapers and ring tones accounting for 69%.

Based on study by Frost & Sullivan, the key areas of mobile content growth will be entertainment, enterprise applications and productivity services; adult services are considered entertainment in the study, and are predicted to be one of the biggest movers (122% growth).

Also mentioned is the growth of high-bandwidth applications and mobile content (3G (and 4G?) such as mobile video, predicted to account for 13% of US revenues by 2009.

There are a variety of obvious factors behind the growth including bandwidth (3G) and increasing demand from ever-savvier consumers.

The article concludes by predicted the challenge for the industry being establishing sustainable and successful business models; 1999, here we come again!

At Wiliam, we have followed the emergence and growth of the mobile content industry, and have developed a number of mobile applications with Vodafone Australia in the past year; only a few weeks back, we completed a project with client Mogenic, where we integrated our Content Management System sitedock with the Vodafone MMS gateway to allow participants to submit their MMS photos (mobile phone photos) directly to the Mogenic website.

In fact, several of our current websites in production are being built in xHTML, allowing for easier portability of content to mobile phones.

I suspect that within six months, all of our content will be mobile-ready, and that within twelve months, clients will place emphasis on mobile optimisation of their content.

Start coding on project officially

I officially start coding on my new project now. Since i decided to use Zend Framework, which is pretty new to me, in the first several days i just try to set up the framework and the file structure. I also implement Authentication and ACL, integrated Smarty with Zend.

I personally don't like smarty. But many other php developers like it, so at this point i compromise a little bit.