View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_View_Helper_Dojo
{zone-data}

{zone-data:proposer-list}
[~matthew]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 27 May 2008: Initial Draft.
{zone-data}

{zone-data:overview}
Using dojo requires a number of view integration points; these include requiring the dojo.js file itself, dojo.require calls, loading appropriate stylesheets, etc. ZF should make including these as easy as possible.
{zone-data}

{zone-data:references}
* [Dojo Toolkit Manual|http://dojotoolkit.org/book/dojo-book-1-0]
{zone-data}

{zone-data:requirements}
* MUST be a single view helper with multiple methods
* MUST be able to render as string
* MUST have methods for setting dojo include metadata
** MUST support using via CDN, using specified version
*** SHOULD allow specifying either AOL or Google as CDN
** MUST support using local install, via path
** MUST allow specifying djConfig key/value pairs
** SHOULD default to CDN if no path specified
* MUST have method for requiring components
** MUST have method for specifying module paths
* MUST emit default dojo.js stylesheet
** SHOULD default to CDN location if no path specified
** MUST allow specifying CDN version
** MUST allow specifying dojo install location by local path
** MUST allow specifying dijit themes by module
{zone-data}

{zone-data:dependencies}
* Zend_View_Exception
* Zend_View_Helper_Placeholder
{zone-data}

{zone-data:operation}
This component provides a fluent, PHP5 interface for programmatically setting up your Dojo environment within your view scripts. You may specify whether Dojo loads from a local path or the AOL CDN, paths to any custom modules, stylesheet modules to use, and more. Within your layout script, you will then echo the placeholder to setup the appropriate style and script tags based on the settings provided.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Prepare API
* Milestone 2: Publish this proposal
* Milestone 3: Complete first working code and tests
* Milestone 4: Write documentation
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_Dojo
{zone-data}

{zone-data:use-cases}
||UC-01||
h3. require a dojo component:
{code:php}
$this->dojo()->requireModule('dojo.QueryReadStore')
{code}

||UC-02||
h3. register a module path
{code:php}
$this->dojo()->registerModulePath('custom', '../custom')
{code}

||UC-03||
h3. tell dojo to use the CDN, version 1.0
{code:php}
$this->dojo()->setCdnVersion('1.0')
{code}

||UC-03a||
h3. tell dojo to use the Google CDN
{code:php}
$this->dojo()->setCdn('google')
->setCdnVersion('1.1.1');
{code}

||UC-04||
h3. tell dojo to use local install
{code:php}
$this->dojo()->setLocalPath('/js/dojo/dojo.js')
{code}

||UC-05||
h3. tell dojo to parse on load
{code:php}
$this->dojo()->setDjConfig('parseOnLoad', 'true');
{code}

||UC-06||
h3. specify a stylesheet by module notation
{code:php}
$this->dojo()->addStyleSheetModule('dijit.themes.tundra')
{code}

||UC-07||
h3. require a custom stylesheet
{code:php}
$this->dojo()->addStyleSheet('/css/custom.css')
{code}

||UC-08||
h3. specify a function to run onLoad
{code:php}
$this->dojo()->addOnLoad('foo')
{code}

||UC-09||
h3. specify an object method to run onLoad
{code:php}
$this->dojo()->addOnLoad('foo', 'bar'); // foo.bar()
{code}

||UC-10||
h3. capture JS to use as a named callback to run onLoad
{code:php}
<? $this->dojo()->onLoadCaptureStart('foo') ?>
bar();
baz();
<? $this-.dojo()->onLoadCaptureStop('foo') ?>
{code}

||UC-11||
h3. enable dojo (minimally, loads dojo.js and dojo.css)
{code:php}
$this->dojo()->enableDojo()
{code}

||UC-12||
h3. disable dojo (will not enable any functionality when rendered)
{code:php}
$this->dojo()->disableDojo()
{code}

||UC-13||
h3. test if dojo is enabled
{code:php}
if ($this->dojo()->isEnabled()) {
}
{code}

||UC-14||
h3. echo the dojo requirements
{code:php}
<?= $this->dojo() ?>
{code}
{zone-data}

{zone-data:skeletons}
{code:php}
class Zend_View_Helper_Dojo extends Zend_View_Helper_Placeholder_Container_Standalone
{
const CDN_AOL_BASE = 'http://o.aolcdn.com/dojo/';

const CDN_GOOGLE_BASE = 'http://ajax.googleapis.com/ajax/libs/dojo/';

const CDN_DOJO_PATH = '/dojo/dojo.xd.js';

public $view;

public function setView(Zend_View_Interface $view);

public function enableDojo();

public function disableDojo();

public function isEnabled();

public function requireModule($module);

public function getModules();

public function registerModulePath($path);

public function getModulePaths();

public function setCdnVersion($version = null);

public function getCdnVersion();

public function setCdn($cdn = 'aol');

public function getCdn();

public function setLocalPath($path);

public function getLocalPath();

public function useLocalPath();

public function setDjConfig($option, $value);

public function getDjConfig($option = null);

public function addStyleSheetModule($module);

public function getStyleSheetModules();

public function addStyleSheet($path);

public function getStyleSheets();

public function addOnLoad($script);

public function getOnLoadActions();

public function onLoadCaptureStart($action);

public function onLoadCaptureStop($action);

public function dojo();

public function __toString();
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>