-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation nip tuck, fixed ExtensionManager accessor for S2.3
- Loading branch information
Showing
8 changed files
with
80 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
Class extension_hello_world extends Extension{ | ||
|
||
public function getSubscribedDelegates(){ | ||
return array( | ||
// 1. Subscribe to the EXSLT Function Manager's "ManageEXSLFunctions" delegate | ||
array( | ||
'page' => '/frontend/', | ||
'delegate' => 'ManageEXSLFunctions', | ||
'callback' => 'loadhelloworld' | ||
) | ||
); | ||
} | ||
|
||
// 2. The delegate callback method. Register your XSLT functions here | ||
public function loadhelloworld($context){ | ||
|
||
$context['manager']->addFunction( | ||
'extension_hello_world::helloworld', // callback class and static method name | ||
'http://example.com', // namespace of your choosing | ||
'hello' // the function name you'll use in XSLT | ||
); | ||
|
||
$context['manager']->addFunction( | ||
'extension_hello_world::hellonode', | ||
'http://example.com', | ||
'hellonode' | ||
); | ||
} | ||
|
||
// 3. The functions! | ||
public static function helloworld($name) { | ||
return 'Hello, ' . $name; | ||
} | ||
|
||
public static function hellonode( array $name) { | ||
// By type hinting an array, this function is passed a DomDocument wrapped in array. | ||
return $name[0]; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<extension id="hello_world" status="experimental" xmlns="http://symphony-cms.com/schemas/extension/1.0"> | ||
<name>Hello World</name> | ||
<description>An example use of the EXSLT Function Manager extension.</description> | ||
<releases> | ||
<release version="0.1" date="2012-06-06" min="2.3.0" /> | ||
</releases> | ||
</extension> |
16 changes: 10 additions & 6 deletions
16
examples/helloworld/helloworld.xsl → examples/hello_world/helloworld.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
|
||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:function="http://example.com" > | ||
<!-- Note the function declaration above. While the URI is from the function extension, I've made up the prefix 'function' just for use in this doc.--> | ||
xmlns:my_function="http://example.com"> | ||
<!-- | ||
Note the function declaration above. | ||
While the namespace URI is from the function's extension, I've made up the prefix 'my_function' just for use in this doc. | ||
--> | ||
|
||
<xsl:output method="xml" | ||
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" | ||
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" | ||
omit-xml-declaration="yes" | ||
encoding="UTF-8" | ||
indent="yes" /> | ||
|
||
<!-- include the stream, this does all sorts of awesome --> | ||
<xsl:include href='efm://functions' /> | ||
|
||
<xsl:template match="/"> | ||
|
||
<xsl:variable name='name' select="'I am a boring string.'" /> | ||
<xsl:value-of select='function:hello($name)' /><br /><br /> | ||
<p><xsl:value-of select='my_function:hello($name)' /></p> | ||
|
||
|
||
<xsl:variable name='testnode'> | ||
<node>Hello, I'm a node. I've been to PHP and back. Wild stuff.</node> | ||
</xsl:variable> | ||
<xsl:copy-of select='function:hellonode($testnode)' /> | ||
<xsl:copy-of select='my_function:hellonode($testnode)' /> | ||
|
||
</xsl:template> | ||
</xsl:stylesheet> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
<?php | ||
|
||
require_once('lib/class.functionmanager.php'); | ||
require_once('lib/class.functionstream.php'); | ||
|
||
Class extension_EXSL_Function_Manager extends Extension{ | ||
public function about(){ | ||
return array('name' => 'EXSL Function Manager', | ||
'version' => '0.5', | ||
'release-date' => '', | ||
'author' => array('name' => 'Andrew Shooner', | ||
'website' => 'http://andrewshooner.com', | ||
'email' => 'ashooner@gmail.com') | ||
); | ||
} | ||
|
||
public function getSubscribedDelegates(){ | ||
return array( | ||
array( | ||
'page' => '/frontend/', | ||
'delegate' => 'FrontendOutputPreGenerate', | ||
'callback' => 'initFunctionManager' | ||
), | ||
|
||
); | ||
array( | ||
'page' => '/frontend/', | ||
'delegate' => 'FrontendOutputPreGenerate', | ||
'callback' => 'initFunctionManager' | ||
) | ||
); | ||
} | ||
|
||
public function initFunctionManager($context) { | ||
|
||
public function initFunctionManager($context){ | ||
$Manager = new FunctionManager(&$context); | ||
$Manager->createDelegate(); | ||
$Manager->createStream(); | ||
} | ||
$Manager->createDelegate(); | ||
$Manager->createStream(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters