2007 Fsoss Drupal Under The Hood
-
Upload
james-walker -
Category
Business
-
view
109 -
download
2
description
Transcript of 2007 Fsoss Drupal Under The Hood
![Page 1: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/1.jpg)
Drupal:Under the Hood
![Page 2: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/2.jpg)
What is Drupal?
1. Content Management System
2. Content Management Framework
3. Community
![Page 3: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/3.jpg)
Content Management System
![Page 4: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/4.jpg)
file uploads
revisions menus
security user profiles
blocks performance modules search engine-friendly urls user manage-
ment administration panels localization error
reporting rss taxonomy blogging comments
forums multi-site installations event
logging community authoring ajax search
free tagging feed aggregation contact
form help system roles and per-missions statistics
tracking polls
![Page 5: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/5.jpg)
1200+ Contributed Modules
![Page 6: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/6.jpg)
Community
![Page 7: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/7.jpg)
Doubles in size each release
source: http://acko.net/blog/drupal-org-explosion-and-trends source: http://buytaert.net/drupal-site-statistics
![Page 8: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/8.jpg)
Statistics
• 840+ code contributors
• 160+ local user groups
• 430+ attendees at Drupalcon Barcelona
• 200,000+ users on drupal.org
• 3 million+ lines of code (core+contrib)
• 52 SoC mentors for 20 students
• 100,000+ downloads/month
![Page 9: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/9.jpg)
Content Management Framework
![Page 10: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/10.jpg)
xml-rpc
file api jquery database abstraction layer form
api file api session management node system url routing theme system string
handling filter system content versioning
installation profiles access control trans-latable output user system caching
date/time handling unicode support mail handling image manipulation installation
system hook system menu system module system user authentication
themable output
![Page 11: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/11.jpg)
What’s under the hood?
![Page 12: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/12.jpg)
Core
• Lightweight framework
• Library of common functions
• Allows Drupal to bootstrap and serve a request
• What you get when you download Drupal
Content Management
User Management
Forms API
Install Profiles
Theming Layer
Localization
Drupal Core
Library of Common Functions
![Page 13: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/13.jpg)
Modules
• How Drupal is extended
• Lean and mean and versatile
• Inversion of control design pattern
• Drupal exposes hooks for modules
Content Management
User Management
Forms API
Install Profiles
Theming Layer
Localization
Drupal Core
Library of Common Functions
Actions/Workflows
EcommerceContent
Creation Kit
ViewsOrganic Groups
Modules
Custom Module
![Page 14: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/14.jpg)
index.php
install.php
INSTALL.txt
sites
update.php
xmlrpc.php
themes
modules
includes
![Page 15: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/15.jpg)
drupal_bootstrap()• DRUPAL_BOOTSTRAP_CONFIGURATION
• DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE
• DRUPAL_BOOTSTRAP_DATABASE
• DRUPAL_BOOTSTRAP_ACCESS
• DRUPAL_BOOTSTRAP_SESSION
• DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE
• DRUPAL_BOOTSTRAP_PATH
• DRUPAL_BOOTSTRAP_FULL
![Page 16: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/16.jpg)
menu system
![Page 17: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/17.jpg)
Is site offline?
Get menu array
Return MENU_SITE_OFFLINE
Parse $path from $_GET['q']
Is callback defined for
$path?
Trim last '/' from $path
Does callback function exist?
Return MENU_NOT_FOUND
No
No
User allowed to access this
item?
Return MENU_ACCESS_DENIED
No
Marshall parameters from URL and item's callback arguments
Call callback
No
Yes
![Page 18: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/18.jpg)
Hooks
![Page 19: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/19.jpg)
Hooks are PHP functions with Drupal-specific names
![Page 20: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/20.jpg)
How Drupal Finds Hooks
/** * Determine whether a module implements a hook. * * @param $module * The name of the module (without the .module extension). * @param $hook * The name of the hook (e.g. "help" or "menu"). */function module_hook($module, $hook) { return function_exists($module .'_'. $hook);}
![Page 21: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/21.jpg)
Module Hook Function name
pants user pants_user()
pants menu pants_menu()
pants perm pants_perm()
Naming Hooks
![Page 22: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/22.jpg)
Hook Overview
hook_user()
comment_user() locale_user() node_user() mymodule_user()
comment.module locale.module node.module mymodule.module
![Page 23: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/23.jpg)
FormAPI
![Page 24: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/24.jpg)
FormAPI
• Form elements are PHP arrays so you can programmatically manipulate any form
• Chain validator and submitter routines
• Theme overrides - down to the element!
• Built-in security
![Page 25: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/25.jpg)
Form Example$form['user_name'] = array( '#title' => t('Your Name'), '#type' => 'textfield', '#description' => t('Please enter your name.'), );
$form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') );
![Page 26: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/26.jpg)
Security
• Verifies that $_POST values have corresponding $form elements
• Form rendering sanitized for potential XSS
• $form[‘token’] used to prevent CSRF
![Page 27: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/27.jpg)
hook_form_alter
![Page 28: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/28.jpg)
drupal_execute()
![Page 29: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/29.jpg)
Theme System
![Page 30: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/30.jpg)
Theme System
![Page 31: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/31.jpg)
PHPTemplate Files
• page.tpl.php
• node.tpl.php
• block.tpl.php
• comment.tpl.php
• box.tpl.php
![Page 32: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/32.jpg)
theme-name_breadcrumb()
theme-engine_breadcrumb()
theme_breadcrumb()
theme('breadcrumb')
The first function found
gets called.
![Page 33: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/33.jpg)
garland_page()
phptemplate_page()
theme_page()
theme('page')
The first function found
gets called.
![Page 34: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/34.jpg)
Creating New Template Files
function mytheme_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { return '<span class="breadcrumb">'. implode(' * ', $breadcrumb) .'</span>'; }}
template.php
function mytheme_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { $variables = array('breadcrumb' => implode(' * ', $breadcrumb)); return _phptemplate_callback('breadcrumb', $variables); }}
new template.php
<span class="breadcrumb"><?php print $breadcrumb ?></span>breadcrumb.tpl.php
![Page 35: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/35.jpg)
ultimate control
![Page 44: 2007 Fsoss Drupal Under The Hood](https://reader035.fdocuments.in/reader035/viewer/2022062511/54c83cc14a795964538b45a8/html5/thumbnails/44.jpg)
Thanks... Questions?
James Walker http://walkah.net/