Sourcing dojo from AOL's CDN under Zend Framework
This implementation uses a default layout. To set the path and name of the layout (default.phtml), the application.ini file was configured like so:
configs/application.ini
resources.layout[] =
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "default"
Bootstrap.php adds dojo to thel helper path for the view in _initView. The locale is set up as well as the translation.
Bootstrap.php
protected function _initView()
{
Zend_Session::start();
$session=new Zend_Session_Namespace('global');
$options=$this->getOptions();
$locale = new Zend_Locale(Zend_Locale::BROWSER,TRUE);
$session->strLocale=$locale->toString();
Zend_Registry::set('Zend_Locale', $locale);
$language_path=$options['resources']['locale']['translation']['path'];
$translate = new Zend_Translate(array('adapter'=>'gettext',
'content'=>$language_path,
'scan' => Zend_Translate::LOCALE_DIRECTORY,
'locale'=>$locale->toString()));
Zend_Registry::set('Zend_Translate', $translate);
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headLink()->appendStylesheet('/css/base.css')
->appendStylesheet('/css/color.css');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
$view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
$view->strLocale=$session->strLocale;
return $view;
}
In the controller for the form, dojo is enabled. This way, the layout only includes dojo if the form or page requires it.
$this->view->form = $form;
$this->view->dojo()->enable();
if ($this->getRequest()->isPost())
In the layout, the final dojo configuration is done, if dojo is enabled.
application/layouts/scripts/default.phtml
<?php
// application/layouts/scripts/default.phtml
echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo $this->headTitle() ?>
<?php echo $this->headMeta() ?>
<?php echo $this->headLink() ?>
<?php echo $this->headStyle() ?>
<?php if ($this->dojo()->isEnabled()){
$this->dojo()
->setCdnBase(Zend_Dojo::CDN_BASE_AOL)
->setCdnVersion('1.5')
->setCdnDojoPath(Zend_Dojo::CDN_DOJO_PATH_AOL);
$this->dojo()
->setDjConfigOption('parseOnLoad', true)
->setDjConfigOption('locale',$this->strLocale)
->setDjConfigOption('cdnbase',Zend_Dojo::CDN_BASE_AOL)
->setDjConfigOption('cdnversion','1.5')
->setDjConfigOption('cdndojopath',Zend_Dojo::CDN_DOJO_PATH_AOL)
->addStyleSheetModule('dijit.themes.tundra')
->requireModule('dijit.form.Form')
->requireModule('dijit.form.ValidationTextBox')
->requireModule('dijit.form.TextBox');
echo $this->dojo();
}
?>
Print article | This entry was posted by elvis on 09/29/10 at 05:29:12 pm . Follow any responses to this post through RSS 2.0. |