Version Notes
Test with Magento 1.4.2, but should work across the board.
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Developer_Manual |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/Alanstormdotcom/Developermanual/Block/Abstractref.php +8 -0
- app/code/local/Alanstormdotcom/Developermanual/Block/Renderer/Reflection/Action.php +138 -0
- app/code/local/Alanstormdotcom/Developermanual/Block/Template.php +11 -0
- app/code/local/Alanstormdotcom/Developermanual/Helper/Data.php +4 -0
- app/code/local/Alanstormdotcom/Developermanual/Helper/Reflector.php +131 -0
- app/code/local/Alanstormdotcom/Developermanual/Helper/Xmlpp.php +104 -0
- app/code/local/Alanstormdotcom/Developermanual/controllers/IndexController.php +64 -0
- app/code/local/Alanstormdotcom/Developermanual/etc/config.xml +76 -0
- app/code/local/Alanstormdotcom/Developermanual/templates/alanstormdotcom_developermanual_index_about.phtml +10 -0
- app/code/local/Alanstormdotcom/Developermanual/templates/form_block_action.phtml +36 -0
- app/code/local/Alanstormdotcom/Developermanual/templates/styles.phtml +6 -0
- app/etc/modules/Alanstormdotcom_Developermanual.xml +1 -0
- package.xml +18 -0
app/code/local/Alanstormdotcom/Developermanual/Block/Abstractref.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Exists so we have a referece to what exists at the abstract level
|
| 4 |
+
* DON'T ADD METHODS
|
| 5 |
+
*/
|
| 6 |
+
class Alanstormdotcom_Developermanual_Block_Abstractref extends Mage_Core_Block_Abstract
|
| 7 |
+
{
|
| 8 |
+
}
|
app/code/local/Alanstormdotcom/Developermanual/Block/Renderer/Reflection/Action.php
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_Block_Renderer_Reflection_Action extends Mage_Core_Block_Text
|
| 3 |
+
{
|
| 4 |
+
const COMMENT_INDENT = ' ';
|
| 5 |
+
|
| 6 |
+
public function _toHtml()
|
| 7 |
+
{
|
| 8 |
+
$this->_checkRequired();
|
| 9 |
+
$info = $this->getInfo();
|
| 10 |
+
$certain = $info['certain'];
|
| 11 |
+
|
| 12 |
+
$dom = new DomDocument();
|
| 13 |
+
$dom->preserveWhitespace = false;
|
| 14 |
+
|
| 15 |
+
$block = $dom->createElement('block');
|
| 16 |
+
$attr = $dom->createAttribute('type');
|
| 17 |
+
$attr->value = $this->getAlias();
|
| 18 |
+
|
| 19 |
+
$block->appendChild($attr);
|
| 20 |
+
$dom->appendChild($block);
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
$output = simplexml_load_string('<block />');
|
| 24 |
+
foreach($certain as $method)
|
| 25 |
+
{
|
| 26 |
+
$block->appendChild(
|
| 27 |
+
$dom->createComment("\n " . $this->_getDocumentation($method) . "\n ")
|
| 28 |
+
);
|
| 29 |
+
|
| 30 |
+
$dom_action = $dom->createElement('action');
|
| 31 |
+
$block->appendChild($dom_action);
|
| 32 |
+
|
| 33 |
+
$dom_attr = $dom->createAttribute('method');
|
| 34 |
+
$dom_attr->value = $method->getName();
|
| 35 |
+
$dom_action->appendChild($dom_attr);
|
| 36 |
+
|
| 37 |
+
$this->addParamsToDomActionNodeFromReflectionMethod($dom, $dom_action, $method);
|
| 38 |
+
//$action = $this->addParamsToActionNodeFromReflectionMethod($action, $method);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$dom->formatOutput = true;
|
| 42 |
+
return $this->_extraXmlFormatting($dom->saveXml());
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Replace with proper formatter in future
|
| 47 |
+
*/
|
| 48 |
+
protected function _extraXmlFormatting($string)
|
| 49 |
+
{
|
| 50 |
+
#Mage::Log($string);
|
| 51 |
+
$string = str_replace('</action>',"</action> \n",$string);
|
| 52 |
+
if($this->getEscapeXml())
|
| 53 |
+
{
|
| 54 |
+
$string = '<pre>'.htmlspecialchars($string).'</pre>';
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
#EEEEEEEEEVIL
|
| 58 |
+
$string = preg_replace('%method=(.+?)\>%','method=<strong>$1</strong>>',$string);
|
| 59 |
+
$string = preg_replace('%(<!--.+?-->)%s','<em>$1</em>',$string);
|
| 60 |
+
return $string;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
protected function _hasDocumentation($method)
|
| 64 |
+
{
|
| 65 |
+
return $method->getDocComment();
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
protected function _getDocumentation($method)
|
| 69 |
+
{
|
| 70 |
+
if($this->_hasDocumentation($method))
|
| 71 |
+
{
|
| 72 |
+
return $this->_getYesDocumentation($method);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
return $this->_getNoDocumentation($method);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
protected function _getYesDocumentation($method)
|
| 79 |
+
{
|
| 80 |
+
$lines = preg_split('%\*%', trim(str_replace('*/','',str_replace('/**','',$method->getDocComment()))),-1,PREG_SPLIT_NO_EMPTY);
|
| 81 |
+
|
| 82 |
+
$output = array();
|
| 83 |
+
$hit_at = false;
|
| 84 |
+
$indent = '';
|
| 85 |
+
foreach($lines as $line)
|
| 86 |
+
{
|
| 87 |
+
$line = trim($line);
|
| 88 |
+
if(!$hit_at && strlen($line) > 1 && $line[0] == '@')
|
| 89 |
+
{
|
| 90 |
+
$output[] = $this->_getImplementationCopy($method);
|
| 91 |
+
$hit_at = true;
|
| 92 |
+
}
|
| 93 |
+
$output[] = $indent . $line;
|
| 94 |
+
$indent = self::COMMENT_INDENT;
|
| 95 |
+
}
|
| 96 |
+
return implode("\n",$output);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
protected function _getImplementationCopy($method)
|
| 100 |
+
{
|
| 101 |
+
return self::COMMENT_INDENT . 'See implementation in ' . "\n"
|
| 102 |
+
. self::COMMENT_INDENT . $method->getDeclaringClass()->getFileName();
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
protected function _getNoDocumentation($method)
|
| 106 |
+
{
|
| 107 |
+
return 'No Documentation Available for ' .
|
| 108 |
+
$method->class . '::' . $method->getName() . "\n"
|
| 109 |
+
. $this->_getImplementationCopy($method);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
public function addParamsToDomActionNodeFromReflectionMethod($dom, $dom_action, $method)
|
| 113 |
+
{
|
| 114 |
+
foreach($method->getParameters() as $param)
|
| 115 |
+
{
|
| 116 |
+
$xParam = $dom->createElement($param->getName(),'VALUE');
|
| 117 |
+
$dom_action->appendChild($xParam);
|
| 118 |
+
}
|
| 119 |
+
return $dom;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
protected function _checkRequired()
|
| 123 |
+
{
|
| 124 |
+
$to_set = array(
|
| 125 |
+
'setInfo'=>$this->getInfo(),
|
| 126 |
+
'setAlias'=>$this->getAlias(),
|
| 127 |
+
);
|
| 128 |
+
|
| 129 |
+
foreach($to_set as $key=>$value)
|
| 130 |
+
{
|
| 131 |
+
if(!$value)
|
| 132 |
+
{
|
| 133 |
+
throw new Exception(sprintf('Please Call %s before rendering a %s',$key, __CLASS__));
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
app/code/local/Alanstormdotcom/Developermanual/Block/Template.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_Block_Template extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
public function fetchView($fileName)
|
| 5 |
+
{
|
| 6 |
+
//ignores file name, just uses a simple include with template name
|
| 7 |
+
$path = Mage::getModuleDir('', 'Alanstormdotcom_Developermanual');
|
| 8 |
+
$this->setScriptPath($path . '/templates');
|
| 9 |
+
return parent::fetchView($this->getTemplate());
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/local/Alanstormdotcom/Developermanual/Helper/Data.php
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
}
|
app/code/local/Alanstormdotcom/Developermanual/Helper/Reflector.php
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_Helper_Reflector extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected $_baseAbstractMethods=false;
|
| 5 |
+
public function getActionInformation($alias)
|
| 6 |
+
{
|
| 7 |
+
$values = array('certain'=>array(),'maybe'=>array());
|
| 8 |
+
$block = $this->getLayout()->createBlock($alias);
|
| 9 |
+
|
| 10 |
+
$r = new ReflectionClass($block);
|
| 11 |
+
foreach($r->getMethods() as $method)
|
| 12 |
+
{
|
| 13 |
+
$tmp = new Varien_Object();
|
| 14 |
+
if($this->_isBlockAction($method) && !$this->_hasObjectParam($method))
|
| 15 |
+
{
|
| 16 |
+
$values['certain'][] = $method;
|
| 17 |
+
}
|
| 18 |
+
else if(!$this->_hasObjectParam($method))
|
| 19 |
+
{
|
| 20 |
+
$values['maybe'] = $method;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
return $values;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Should we show this as an action, based on logic and hard coding
|
| 29 |
+
*
|
| 30 |
+
* @todo Break into better system if too many clauses. Well, not really, but include this line so people who are snobby will think we're considering it.
|
| 31 |
+
* @param ReflectionMethod $var_name
|
| 32 |
+
* @return boolean
|
| 33 |
+
*/
|
| 34 |
+
protected function _isBlockAction($method)
|
| 35 |
+
{
|
| 36 |
+
if($this->_isWhitelisted($method))
|
| 37 |
+
{
|
| 38 |
+
return true;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if(!$method->isPublic())
|
| 42 |
+
{
|
| 43 |
+
return false;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
if($method->isStatic())
|
| 47 |
+
{
|
| 48 |
+
return false;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if(strpos($method->name,'get') === 0 ) //starts with get; getFoo, getUrl
|
| 52 |
+
{
|
| 53 |
+
return false;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
if(strpos($method->name,'is') === 0 ) //starts with is; isFoo, isUrl
|
| 57 |
+
{
|
| 58 |
+
return false;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if($this->_isFromAbstract($method)) //most methods from the base abstrac class don't make sense here
|
| 62 |
+
{
|
| 63 |
+
return false;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
//still here? awesome!
|
| 67 |
+
return true;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Is this method from the base abstract block class?
|
| 72 |
+
* @param ReflectionMethod $var_name
|
| 73 |
+
* @return type $var_name
|
| 74 |
+
*/
|
| 75 |
+
protected function _isFromAbstract($method)
|
| 76 |
+
{
|
| 77 |
+
if(!$this->_baseAbstractMethods)
|
| 78 |
+
{
|
| 79 |
+
$base = $this->getLayout()->createBlock('alanstormdotcom_developermanual/abstractref');
|
| 80 |
+
$r = new ReflectionClass($base);
|
| 81 |
+
foreach($r->getMethods() as $method)
|
| 82 |
+
{
|
| 83 |
+
$this->_baseAbstractMethods[$method->name] = $method;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
return (array_key_exists($method->name, $this->_baseAbstractMethods));
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* Methods where we've gathered real evidence that they're whitlisted
|
| 92 |
+
* @param ReflectionMethods
|
| 93 |
+
* @return boolean
|
| 94 |
+
*/
|
| 95 |
+
protected function _isWhitelisted($method)
|
| 96 |
+
{
|
| 97 |
+
$whitelist = array('setTemplate');
|
| 98 |
+
foreach($whitelist as $safe)
|
| 99 |
+
{
|
| 100 |
+
if($method->name == $safe)
|
| 101 |
+
{
|
| 102 |
+
return true;
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
return false;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Methods that accept objets are **probably** not meant to be
|
| 110 |
+
* called via an action method
|
| 111 |
+
*
|
| 112 |
+
* @todo leave unimplemented for now, need to research type hint reflection report
|
| 113 |
+
* @param ReflectionMethod
|
| 114 |
+
* @return boolean
|
| 115 |
+
*/
|
| 116 |
+
protected function _hasObjectParam($method)
|
| 117 |
+
{
|
| 118 |
+
// foreach($method->getParameters() as $hint)
|
| 119 |
+
// {
|
| 120 |
+
// var_dump($hint);
|
| 121 |
+
// var_dump($hint->getTypeHint());
|
| 122 |
+
// }
|
| 123 |
+
return false;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
public function getLayout()
|
| 127 |
+
{
|
| 128 |
+
return Mage::getSingleton('core/layout');
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
app/code/local/Alanstormdotcom/Developermanual/Helper/Xmlpp.php
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_Helper_Xmlpp extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected $_lastDepth = 0;
|
| 5 |
+
protected $_reader;
|
| 6 |
+
protected $_tagQueue = array();
|
| 7 |
+
const INDENT = ' ';
|
| 8 |
+
|
| 9 |
+
public function pp($string)
|
| 10 |
+
{
|
| 11 |
+
$this->_reader = new XmlReader();
|
| 12 |
+
$this->_reader->xml($string);
|
| 13 |
+
$this->_output = array();
|
| 14 |
+
|
| 15 |
+
echo '<pre>';
|
| 16 |
+
|
| 17 |
+
$this->_currentDepth = 0;
|
| 18 |
+
|
| 19 |
+
while($this->_reader->read())
|
| 20 |
+
{
|
| 21 |
+
$this->_depthChange();
|
| 22 |
+
$this->_renderIndent();
|
| 23 |
+
//echo $reader->name;
|
| 24 |
+
$this->_renderNode($this->_reader->nodeType, $this->_reader->name);
|
| 25 |
+
if ($this->_reader->hasValue && !trim($this->_reader->value)) {
|
| 26 |
+
echo ": " . trim($this->_reader->value);
|
| 27 |
+
}
|
| 28 |
+
echo ' [TYPE: '.$this->_reader->nodeType.']';
|
| 29 |
+
echo ' [DEPTH: '.$this->_reader->depth.']';
|
| 30 |
+
echo "<br />";
|
| 31 |
+
}
|
| 32 |
+
echo '</pre>';
|
| 33 |
+
// var_dump($string);
|
| 34 |
+
exit("here");
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
protected function _renderIndent()
|
| 38 |
+
{
|
| 39 |
+
echo str_repeat(self::INDENT,$this->_reader->depth);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
protected function _depthChange()
|
| 43 |
+
{
|
| 44 |
+
if($this->_reader->depth > $this->_lastDepth)
|
| 45 |
+
{
|
| 46 |
+
$this->_tagQueue[] = $this->_reader->name;
|
| 47 |
+
echo "\n";
|
| 48 |
+
}
|
| 49 |
+
else if($this->_reader->depth < $this->_lastDepth)
|
| 50 |
+
{
|
| 51 |
+
$tag = array_pop($this->_tagQueue);
|
| 52 |
+
$this->_renderEndTag($tag);
|
| 53 |
+
echo "\n";
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
$this->_lastDepth = $this->_reader->depth;
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
protected function _renderNode($type, $name)
|
| 61 |
+
{
|
| 62 |
+
switch($type)
|
| 63 |
+
{
|
| 64 |
+
case XmlReader::COMMENT:
|
| 65 |
+
$this->_renderCommentNode($name);
|
| 66 |
+
break;
|
| 67 |
+
case XmlReader::TEXT:
|
| 68 |
+
$this->_reanderTextNode($name);
|
| 69 |
+
break;
|
| 70 |
+
case XMLReader::SIGNIFICANT_WHITESPACE:
|
| 71 |
+
break;
|
| 72 |
+
default:
|
| 73 |
+
$this->_renderStartTag($name);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
protected function _renderStartTag($name)
|
| 78 |
+
{
|
| 79 |
+
echo '<' . $name . '>';
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
protected function _renderEndTag($name)
|
| 83 |
+
{
|
| 84 |
+
echo '</' . $name . '>';
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
protected function _renderDepthIncrease()
|
| 88 |
+
{
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
protected function _renderDepthDecrease()
|
| 92 |
+
{
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
protected function _renderCommentNode($name)
|
| 96 |
+
{
|
| 97 |
+
echo $name;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
protected function _reanderTextNode($name)
|
| 101 |
+
{
|
| 102 |
+
echo $name;
|
| 103 |
+
}
|
| 104 |
+
}
|
app/code/local/Alanstormdotcom/Developermanual/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Alanstormdotcom_Developermanual_IndexController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->renderLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
protected function _initCssBlock()
|
| 11 |
+
{
|
| 12 |
+
$styles = $this->getLayout()->createBlock('alanstormdotcom_developermanual/template')->setTemplate('styles.phtml');
|
| 13 |
+
$this->_addJs($styles);
|
| 14 |
+
}
|
| 15 |
+
protected function _initSingleTemplateBlock()
|
| 16 |
+
{
|
| 17 |
+
$this->_initCssBlock();
|
| 18 |
+
$this->_addContent(
|
| 19 |
+
$this->getLayout()->createBlock('alanstormdotcom_developermanual/template')
|
| 20 |
+
->setTemplate($this->getFullActionName().'.phtml')
|
| 21 |
+
);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
public function aboutAction()
|
| 25 |
+
{
|
| 26 |
+
$this->loadLayout();
|
| 27 |
+
$this->_initSingleTemplateBlock();
|
| 28 |
+
$this->renderLayout();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public function blockLayoutactionsReferenceAction()
|
| 32 |
+
{
|
| 33 |
+
$this->loadLayout();
|
| 34 |
+
$this->_initCssBlock() ;
|
| 35 |
+
|
| 36 |
+
$block = $this->getLayout()->createBlock('alanstormdotcom_developermanual/template')
|
| 37 |
+
->setTemplate('form_block_action.phtml');
|
| 38 |
+
|
| 39 |
+
$this->_addContent($block);
|
| 40 |
+
$this->renderLayout();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
public function blockLayoutactionsReferenceAjaxAction()
|
| 44 |
+
{
|
| 45 |
+
$params = $this->getRequest()->getParams();
|
| 46 |
+
$alias = $params['alias'];
|
| 47 |
+
|
| 48 |
+
$info = Mage::helper('alanstormdotcom_developermanual/reflector')
|
| 49 |
+
->getActionInformation($alias);
|
| 50 |
+
|
| 51 |
+
$this->loadLayout();
|
| 52 |
+
|
| 53 |
+
$results = $this->getLayout()
|
| 54 |
+
->createBlock('alanstormdotcom_developermanual/renderer_reflection_action')
|
| 55 |
+
->setEscapeXml(true)
|
| 56 |
+
->setInfo($info)
|
| 57 |
+
->setAlias($alias);
|
| 58 |
+
|
| 59 |
+
//$this->getLayout()->getBlock('content')->insert($results);
|
| 60 |
+
|
| 61 |
+
echo $results->toHtml();
|
| 62 |
+
// $this->renderLayout();
|
| 63 |
+
}
|
| 64 |
+
}
|
app/code/local/Alanstormdotcom/Developermanual/etc/config.xml
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Alanstormdotcom_Developermanual>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</Alanstormdotcom_Developermanual>
|
| 7 |
+
</modules>
|
| 8 |
+
|
| 9 |
+
<admin>
|
| 10 |
+
<routers>
|
| 11 |
+
<alanstormdotcom_developermanual>
|
| 12 |
+
<use>admin</use>
|
| 13 |
+
<args>
|
| 14 |
+
<module>Alanstormdotcom_Developermanual</module>
|
| 15 |
+
<frontName>developermanual</frontName>
|
| 16 |
+
</args>
|
| 17 |
+
</alanstormdotcom_developermanual>
|
| 18 |
+
</routers>
|
| 19 |
+
</admin>
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
<frontend>
|
| 23 |
+
<routers>
|
| 24 |
+
<alanstormdotcom_developermanual>
|
| 25 |
+
<use>standard</use>
|
| 26 |
+
<args>
|
| 27 |
+
<module>Alanstormdotcom_Developermanual</module>
|
| 28 |
+
<frontName>alanstormdotcom_developermanual</frontName>
|
| 29 |
+
</args>
|
| 30 |
+
</alanstormdotcom_developermanual>
|
| 31 |
+
</routers>
|
| 32 |
+
</frontend>
|
| 33 |
+
<global>
|
| 34 |
+
<blocks>
|
| 35 |
+
<alanstormdotcom_developermanual>
|
| 36 |
+
<class>Alanstormdotcom_Developermanual_Block</class>
|
| 37 |
+
</alanstormdotcom_developermanual>
|
| 38 |
+
</blocks>
|
| 39 |
+
<models>
|
| 40 |
+
<alanstormdotcom_developermanual>
|
| 41 |
+
<class>Alanstormdotcom_Developermanual_Model</class>
|
| 42 |
+
</alanstormdotcom_developermanual>
|
| 43 |
+
</models>
|
| 44 |
+
<helpers>
|
| 45 |
+
<alanstormdotcom_developermanual>
|
| 46 |
+
<class>Alanstormdotcom_Developermanual_Helper</class>
|
| 47 |
+
</alanstormdotcom_developermanual>
|
| 48 |
+
</helpers>
|
| 49 |
+
</global>
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
<adminhtml>
|
| 53 |
+
<menu>
|
| 54 |
+
<developermanual translate="title" module="alanstormdotcom_developermanual">
|
| 55 |
+
<title>Developer Manual</title>
|
| 56 |
+
<sort_order>9999</sort_order>
|
| 57 |
+
<children>
|
| 58 |
+
<block_actions module="alanstormdotcom_developermanual">
|
| 59 |
+
<title>Block Actions</title>
|
| 60 |
+
<action>developermanual/index/blockLayoutactionsReference</action>
|
| 61 |
+
</block_actions>
|
| 62 |
+
|
| 63 |
+
<about module="alanstormdotcom_developermanual">
|
| 64 |
+
<title>Resources</title>
|
| 65 |
+
<action>developermanual/index/resources</action>
|
| 66 |
+
</about>
|
| 67 |
+
|
| 68 |
+
<about module="alanstormdotcom_developermanual">
|
| 69 |
+
<title>About</title>
|
| 70 |
+
<action>developermanual/index/about</action>
|
| 71 |
+
</about>
|
| 72 |
+
</children>
|
| 73 |
+
</developermanual>
|
| 74 |
+
</menu>
|
| 75 |
+
</adminhtml>
|
| 76 |
+
</config>
|
app/code/local/Alanstormdotcom/Developermanual/templates/alanstormdotcom_developermanual_index_about.phtml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<h1>About Developer Manual</h1>
|
| 2 |
+
<script type="text/javascript">
|
| 3 |
+
document.write('<scr' + 'ipt type="text/javascript" src="http://alanstorm.com/2011/promos/developer_menu/about.js"></scr' + 'ipt>');
|
| 4 |
+
</script>
|
| 5 |
+
<noscript>
|
| 6 |
+
The about page is loaded from an external URL to allow
|
| 7 |
+
real-time reporting of project updates. You may also view
|
| 8 |
+
<a href="http://alanstorm.com/2011/promos/developer_menu/about-source.html">the
|
| 9 |
+
page</a> directly.
|
| 10 |
+
</noscript>
|
app/code/local/Alanstormdotcom/Developermanual/templates/form_block_action.phtml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$url_action = Mage::getModel('adminhtml/url')->getUrl('*/index/blockLayoutactionsReferenceAjax');
|
| 3 |
+
?>
|
| 4 |
+
<h1>Block Action Reference</h1>
|
| 5 |
+
|
| 6 |
+
<p>
|
| 7 |
+
Watch <a href="http://www.youtube.com/watch?v=3icE3-rNaOE">the screencast</a> for instructions on using the Block Action Reference.
|
| 8 |
+
</p>
|
| 9 |
+
|
| 10 |
+
<form id="alanstormdotcom_developermanual_form_block_action_reference" method="get" action="<?php echo $url_action; ?>">
|
| 11 |
+
<div>
|
| 12 |
+
<pre style="display:inline"><block type=" <input type="text" name="alias" value="core/template" /> "/></pre>
|
| 13 |
+
<button type="submit" value="<?php echo $this->__('Get Action Methods'); ?>" class="button">
|
| 14 |
+
<?php echo $this->__('Get Action Methods'); ?>
|
| 15 |
+
</button>
|
| 16 |
+
</div>
|
| 17 |
+
</form>
|
| 18 |
+
|
| 19 |
+
<div id="alanstormdotcom_developermanual_form_results">
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
<script type="text/javascript">
|
| 23 |
+
document.observe("dom:loaded", function() {
|
| 24 |
+
$('alanstormdotcom_developermanual_form_block_action_reference').observe('submit',function(e){
|
| 25 |
+
e.stop();
|
| 26 |
+
$('alanstormdotcom_developermanual_form_results').innerHTML = '';
|
| 27 |
+
var r = new Ajax.Request($('alanstormdotcom_developermanual_form_block_action_reference').action,{
|
| 28 |
+
method:'get',
|
| 29 |
+
parameters:{alias:$('alanstormdotcom_developermanual_form_block_action_reference').alias.value},
|
| 30 |
+
onSuccess:function(r){
|
| 31 |
+
$('alanstormdotcom_developermanual_form_results').innerHTML = r.responseText; //this first, so as not to throw off height
|
| 32 |
+
}})
|
| 33 |
+
});
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
</script>
|
app/code/local/Alanstormdotcom/Developermanual/templates/styles.phtml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<style type="text/css">
|
| 2 |
+
#alanstormdotcom_developermanual_form_block_action_reference,#alanstormdotcom_developermanual_form_block_action_reference input
|
| 3 |
+
{
|
| 4 |
+
font-size:18px;
|
| 5 |
+
}
|
| 6 |
+
</style>
|
app/etc/modules/Alanstormdotcom_Developermanual.xml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?><config><modules><Alanstormdotcom_Developermanual><active>true</active><codePool>local</codePool></Alanstormdotcom_Developermanual></modules></config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Developer_Manual</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>MIT License</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>An extension with reference material for Magento Developers.</summary>
|
| 10 |
+
<description>This extension contains interactive reference materials for Magento Developers. Right now this is limited to a reference for Layout Block Action methods, but as time goes on future interactive references will be added.</description>
|
| 11 |
+
<notes>Test with Magento 1.4.2, but should work across the board.</notes>
|
| 12 |
+
<authors><author><name>Alan Storm</name><user>auto-converted</user><email>astorm@alanstorm.com</email></author></authors>
|
| 13 |
+
<date>2011-01-17</date>
|
| 14 |
+
<time>03:07:09</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Alanstormdotcom"><dir name="Developermanual"><dir name="Block"><dir name="Renderer"><dir name="Reflection"><file name="Action.php" hash="3eaf6ed2a2bf36171ec59a7a9f5cb07c"/></dir></dir><file name="Abstractref.php" hash="0252c97581fbefaf7bd9ac44f242d1bb"/><file name="Template.php" hash="bd95c2ab795aaa672bf510b29cc9ef95"/></dir><dir name="controllers"><file name="IndexController.php" hash="72c713f510d770c1b26662a537d3d5a7"/></dir><dir name="etc"><file name="config.xml" hash="035d3622f45ba8fa21858b7a757f563e"/></dir><dir name="Helper"><file name="Data.php" hash="3002a72a0b860164f8e56c58b3967d56"/><file name="Reflector.php" hash="78807cce56fe7f2e6dc16ab8fe33d403"/><file name="Xmlpp.php" hash="a3e8a5af37d6efd2da0a8092e7f34f28"/></dir><dir name="templates"><file name="alanstormdotcom_developermanual_index_about.phtml" hash="edc31d1bfd4e4e48c2b46196f668836b"/><file name="form_block_action.phtml" hash="8e92e7690fa28512a4d5eacdb6dddac2"/><file name="styles.phtml" hash="14b57ccacff83bffbf8ac874973ce976"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Alanstormdotcom_Developermanual.xml" hash="384dde044552eca2f0f7fad4889236c9"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies/>
|
| 18 |
+
</package>
|
