• Like
  • Save
Quality Use Of Plugin
Upcoming SlideShare
Loading in...5
×
 

Quality Use Of Plugin

on

  • 1,349 views

Cakematsuri

Cakematsuri

Statistics

Views

Total Views
1,349
Views on SlideShare
1,349
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Quality Use Of Plugin Quality Use Of Plugin Presentation Transcript

  • プラグイン活用法 quality use of Plugin slywalker
  • About me原田 康生 Yasuo Harada 大阪のこっそりPHPer Sly PHPer in OsakaBlog 「忍び歩く男 - SLYWALKER」 http://d.hatena.ne.jp/slywalker/Twitter, Wassr, Hatena, GitHub ID slywalker
  • 一瞬だけコミッターになれました I became a committer just a moment.
  • 第4回CakePHP勉強会にて 「プラグイン3段活用」 LTで発表しました I made a presentation about Plugin at 4th CakePHP Workshop.http://d.hatena.ne.jp/slywalker/20090523/1243059244
  • 簡単お手軽にプラグインを扱う方法を紹介しました I demonstrated how easily handle Plugin.
  • 1. 整 理 整 頓 smarten up 機能ごとにプラグイン化する Create a Plugin for each feature2. 道 具 箱 tool box 汎用的なプラグインをアプリケーションで共有 To share a generic plug-in application3. プラグイン Plugin 開発しながら修復。完成度を高めていく Repair and development. Gradually increase the degree of completion
  • エンタープライズ Rails「企業ユーザのためのWebアプリケーション設計術」2章 プラグインによる構成
  • プラグインといえばDebugKit http://thechaw.com/debug_kit
  • 通常ならばapp/plugins/debug_kit
  • アプリケーションが 複数あるときは?
  • 共有ならばROOT/plugins/debug_kit
  • Each appapp/config/bootstrap.php$pluginPaths = array(ROOT.DS.plugins.DS);
  • Call Pluginapp/app_controller.phpclass AppController extends Controller {� var $components = array(DebugKit.Toolbar);}
  • Plugin Tips・ config・ multilingualization i18n(.pot .po)・ template(.ctp) using in app・ /css/images(.jpg .png .gif) in plugin s /vendors
  • Account Manager Pluginhttp://github.com/slywalker/account_manager
  • smtp.php.defaultCopy app/config/smtp.php/** * SMTP_CONFIG **/class SMTP_CONFIG { � static $default = array(� � host => tls://smtp.gmail.com,� � port => 465,� � from => username@gmail.com,� � user => username,� � pass => password,� � protocol => SMTP_AUTH,� );}
  • users_controller.php/** * _send * * @param string $to * @param string $subject * @param string $template * @param string $config * @return boolean * @author Yasuo Harada */protected function _send(..., $config = default) { if (config(smtp)) { $params = SMTP_CONFIG::$$config; $this->Qdmail->smtp(true); $this->Qdmail->smtpServer($params); } ....}
  • Multilingualization i18n in Plugin __(Hello World); __d(account_manager, Hello World);account_manager/locale/jpn/LC_MESSAGES/account_manager.po
  • $ cd /your_plugins_path/account_manager $ cake i18nWelcome to CakePHP v1.2.4.8284 Console---------------------------------------------------------------App : account_managerPath: /your_plugins_path/account_manager---------------------------------------------------------------I18n Shell---------------------------------------------------------------[E]xtract POT file from sources[I]nitialize i18n database table[H]elp[Q]uitWhat would you like to do? (E/I/H/Q)>e
  • What is the full path you would like to extract?Example: /your_plugins_path/myapp[Q]uit[/your_plugins_path/account_manager] > (enter)What is the full path you would like to output?Example: /your_plugins_path/account_manager/locale[Q]uit[/your_plugins_path/account_manager/locale] > (enter)Extracting...---------------------------------------------------------------Path: /your_plugins_path/account_managerOutput Directory: /your_plugins_path/account_manager/locale/---------------------------------------------------------------Would you like to merge all translations into one file? (y/n)[y] > (enter)What should we name this file?[default] > account_manager
  • If you want use your template.
  • Template using in app use Themed� app_controller.php� class AppController extends Controller {� � function beforeFilter() {� � � if (isset($this->params[plugin])) {� � � � $this->view = Theme;� � � � $this->theme = $this->params[plugin];� � � }� � }� }
  • Template using in app Copy account_manager/views/usersapp/views/themed/account_manager/users
  • View search order1. themed2. plugin3. app4. core
  • Jquery Pluginhttp://github.com/slywalker/jquery
  • Using JqueryUI http://jqueryui.com/
  • Default DispatcherRequest images/bg.png in cssapp/webroot/css/images/bg.png <- Get!!app/vendors/css/images/bg.png <- Get!!app/plugins/vendors/css/images/bg.png <- Ooops!!vendors/css/images/bg.png <- Get!!plugins/vendors/css/images/bg.png <- Ooops!!
  • Custom Dispatcherjquery/dispatcher.phpclass Dispatcher extends Object {� function cached($url) {� � ...� � � foreach ($assets as $type => $contentType) {� � � � if ($type === $ext) {� � � � � if ($type === css || $type === js) {� � � � � � $pos = strpos($url, $type . /);� � � � � } else {� � � � � � $pos = strpos($url, img/);� � � � � � // add by slywalker start� � � � � � if ($pos === false) {� � � � � � � $pos = strpos($url, js/);� � � � � � }� � � � � � if ($pos === false) {� � � � � � � $pos = strpos($url, css/);� � � � � � }� � � � � � // add by slywalker end� � � � � }� � � � � $isAsset = true;� � � � � break;� � � � }� � � }� � ...� }}
  • Custom DispatcherRequest images/bg.png in cssapp/webroot/css/images/bg.png <- Get!!app/vendors/css/images/bg.png <- Get!!app/plugins/vendors/css/images/bg.png <- Get!!vendors/css/images/bg.png <- Get!!plugins/vendors/css/images/bg.png <- Get!!
  • Using Custom Dispatcherapp/config/bootstrap.phpApp::import(Core, Dispatcher,array(� file => ROOT.DS.jquery.DS.dispatcher.php));
  • In closing,I would like to thank you allfor listening so attentively.