ktai Library for ktai(mobile phone in Japanese) web site

  1. Documentation
  2. Change Log

This library provides emoji filter, ktai controller, mobile auth filter and so on. It may help your ktai web site.

Documentation

Requirements
  • Yii 1.1 or above
  • net_IPv4
  • html_css
Installation
  • pear install HTML_CSS
  • pear install Net_IPv4
  • Extract the release file under protected/
  • Copy or symlink image files under /images/emoji
  • I recommend copying net_IPv4 and html_css under venders/ directory.
Usage
  • .htaccess ~~~ php_value mb_language "Japanese" php_value mbstring.detect_order "auto" php_value mbstring.http_input "pass" php_value mbstring.http_output "pass" php_value mbstring.internal_encoding "UTF-8" php_value mbstring.script_encoding "UTF-8" php_value mb_regex_encoding "UTF-8" ~~~

  • controller

All filters depend on CHybridController, so you have to extends from CHybridController.

<?php
class MobileController extends CHybridController 
{
  public function filters()  {
    return array(
      array(
        'application.filters.ktai.AuthFilter',
        'docomoOfficial'=>true, // if your site is KOSHIKI SAITO
        'nonSupportBrowser'=>array(
          '/^DoCoMo\/1\.0(.*)$/',
          '/^J\-PHONE\/(.*)$/',
          '/^UP\.Browser\/(.*)$/',
          ),  
        'redirectForNonSupport'=>array('mobile/nonsupport'),
        'denyPcBrowser'=>true,
        'denyUnknownIP'=>true,
        'redirectForPcBrowser'=>array('pc/index'),
      ),  
      ),  
      'accessControl',
      array(
        'application.filters.ktai.CssFilter',
        'baseDir'=>Yii::app()->getBasePath().'/../',
        ),
      array(
        'application.filters.ktai.EmojiFilter',
      ),  
    );  
  }
  • Directory Tree

HybridController overwites the render function to alternate view files for each carrier. ~~~ css/ mobile/

docomo.css // for CssFilter

protected/ controllers/

NormalController.php
MobileController.php

views/

mobile/
  index.php // default view file
  docomo/index.php // view file for docomo if it exists
  au/index.php
  softbank/index.php
normal/
  index.php
email/
  hoge.php
    mobile/
      hoge.php // mobile mail template if it exists

* view file

if you want to show emoji in your view file, see EX below.

[i:20] // docomo emoji [s:20] // softbank emoji [e:20] // au emoji [*:tel] // DENWA icon for all carrier [*:fine] // HARE icon for all carrier ~~~ if you see your site in different carrier, [i:20] will be converted into img tag

  • css compatible

This library uses HTML_CSS_Mobile, so you don't need to worry about class attribute for docomo template.

See detail: http://coderepos.org/share/browser/lang/php/HTML_CSS_Mobile/

docomo.css ~~~ .hoge { font-size:x-small; } ~~~ hoge.php(view file) ~~~ <div class="hoge">fuga</div> ~~~ CssFilter automatically convert your css into style attribute. As a rsult, view file will be like this. ~~~ <div class="hoge" style="font-size:x-small">fuga</div> ~~~ When you see your site with other browser, CssFilter doesn't work.

  • mail

Use the mail library if you want to send mail for both pc and mobile.

config/main.php

:
:
    'mailer' => array(
      'class'=>'application.extensions.mailer.EMailer',
      'pathViews'=>'application.views.email',
      'pathLayouts'=>'application.views.email.layouts',
      'lang'=>'japanese',
      'internalEnc'=>'UTF-8',
      'CharSet'=>'iso-2022-jp',
      'Encoding'=>'7bit',
      'FromName'=>'',
    ), 
:
:
   'params'=>array(
      'mobileDomain'=>array(
         1=>'docomo.ne.jp',
            'ezweb.ne.jp',
            'softbank.ne.jp',
            'disney.ne.jp',
            't.vodafone.ne.jp',
            'd.vodafone.ne.jp',
            'h.vodafone.ne.jp',
            'c.vodafone.ne.jp',
            'k.vodafone.ne.jp',
            'r.vodafone.ne.jp',
            'n.vodafone.ne.jp',
            's.vodafone.ne.jp',
            'q.vodafone.ne.jp',
      ),
    ),  
  • Send email
Yii::app()->mailer->From=xxxxxx@softbank.ne.jp; 
Yii::app()->mailer->AddAddress(xxxxx@softbank.ne.jp);
Yii::app()->mailer->Subject='日本語OK'; 
Yii::app()->mailer->getView('hoge'))
Yii::app()->mailer->Send();

In this case, if the email address contains a domain which is listed in the main.php, this mailer will use mobile template (views/email/mobile/hoge.php). If it doesn't exist, view/email/hoge.php will be used instead.

  • input tag for mobile

input tag is chaotic because each carrier has their own format, but CMhtml class may help you.

echo CMhtml::activeTextField($model, "user", array('size'=>'20','class'=>'sfont'),'alphabet');

// It is almost same as CHtml. I just add one more argument.
// 4th argument should be
//  * hiragana
//  * hankakukana
//  * alphabet
//  * numeric

Change Log

February 15, 2012
  • Re-factoring the entire structure
    November 23, 2010
  • Use UTF-8 for softbank
    February 22, 2010
  • HTML helper for mobile input fields
    February 20, 2010 (2nd)
  • add mailer.
  • good-bye useragent_mobile.
  • bug fix.
    February 20, 2010
  • css filter support for docomo template
  • add useful emoji function
    February 17, 2010
  • Output filter for docomo, supporting both uid=NULLGWDOCOMO and guid=on.
    February 16, 2010
  • ktai controller and Auth filter are added.
    February 2, 2009
  • Initial release.
4 0
4 followers
1 658 downloads
Yii Version: 1.1
License: LGPL-3.0
Category: Others
Tags:
Developed by: junamai2000
Created on: Feb 3, 2009
Last updated: 12 years ago

Downloads

show all