Drupal as a web framework
- 3. “A web application framework is a software
framework that is designed to support the
development of dynamic websites, Web
applications and Web services. The
framework aims to alleviate the overhead
associated with common activities
performed in Web development.”
- Wikipedia
- 10. $query = db_select('search_index',
'i', array('target' => 'slave'))-
>extend('SearchQuery')-
>extend('PagerDefault');
$query->join('node', 'n', 'n.nid =
i.sid');
$query
->condition('n.status', 1)
->addTag('node_access')
->searchExpression($keys, 'node');
- 11. $databases['default']['default'] = array(
'driver' => 'mysql',
'database' => 'databasename',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'prefix' => 'main_',
'collation' => 'utf8_general_ci',
);
$databases['default']['default'] = array (
'database' => 'sites/default/files/.ht.sqlite',
'driver' => 'sqlite',
'prefix' => '',
);
- 12. function audioblogger_schema() {
$schema = array();
$schema['audioblogger'] = array(
'fields' => array(
'uid' => array('type' => 'int',
'unsigned' => TRUE, 'not null' => TRUE,
'default' => 0, 'disp-width' => '10'),
'bloguser' => array('type' =>
'varchar', 'length' => '255', 'not null'
=> TRUE),
- 13. $form['audioblogger']['phone'] = array(
'#type' => 'textfield',
'#title' => t('Phone'),
'#default_value' =>
empty($edit['phone']) ? '' :
$edit['phone'],
'#description' => t('The phone number
you usually will call in from.'));
- 14. function audioblogger_menu() {
$items = array();
$items['audioblogger/answer'] =
array(
'page callback' =>
'audioblogger_answer',
'access arguments' => array('access
content'),
'type' => MENU_NORMAL_ITEM,
);
- 16. <?php if (isset($primary_links)) : ?>
<?php print theme('links',
$primary_links, array('class' => 'links
primary-links')) ?>
<?php endif; ?>
<?php if (isset($secondary_links)) : ?>
<?php print theme('links',
$secondary_links, array('class' =>
'links secondary-links')) ?>
<?php endif; ?>
- 19. /**
* Default implementation of
DrupalEntityControllerInterface.
*
* This class can be used as-is by most
simple entity types. Entity types
* requiring special handling can
extend the class.
*/
class DrupalDefaultEntityController
implements
DrupalEntityControllerInterface {
- 20. <?php if (isset($primary_links)) : ?>
<?php print theme('links',
$primary_links, array('class' =>
'links primary-links')) ?>
<?php endif; ?>
<?php if
(isset($secondary_links)) : ?>
<?php print theme('links',
$secondary_links, array('class' =>
'links secondary-links')) ?>
<?php endif; ?>
- 21. function audioblogger_menu() {
$items = array();
$items['audioblogger/answer'] =
array(
'page callback' =>
'audioblogger_answer',
'access arguments' =>
array('access content'),
'type' => MENU_NORMAL_ITEM,
);
- 27. function frameworkdemo_menu() {
$items = array();
$items['demo/answer'] = array(
'page callback' => 'demo_answer',
'access arguments' => array('access
content'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
- 28. function frameworkdemo_answer() {
include_once 'tropo.class.php';
$tropo = new Tropo();
$session = new Session();
$caller = $session->getFrom();
$number = $caller['id'];
$tropo->say('Thanks for coming!');
$_SESSION['caller'] = $number;
$tropo->on(array('event' =>
'continue', 'next'=> url('demo/
thanks/')));
frameworkdemo_save($number);
print $tropo;
}
- 32. Free developer accounts: http://Tropo.com
Demo module source:
https://github.com/akalsey/drupal-framework-demo
Slides: http://slideshare.com/akalsey/drupal-as-a-web-
framework
Follow us on Twitter: @Tropo
Me: Adam Kalsey | adam@tropo.com | @akalsey