Version Notes
- Fixed all the issues related to the Easy Template Path Hints
- Used event-observer method to turn on/off template path hints
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Easy_Template_Path_Hints |
| Version | 0.2.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.1.0 to 0.2.0
- app/code/local/Mage/Core/Block/Template.php +0 -367
- app/code/local/MagePsycho/Easypathhints/Block/Easypathhints.php +8 -1
- app/code/local/MagePsycho/Easypathhints/Block/System/Config/Info.php +3 -3
- app/code/local/MagePsycho/Easypathhints/Helper/Data.php +9 -5
- app/code/local/MagePsycho/Easypathhints/Model/Observer.php +54 -0
- app/code/local/MagePsycho/Easypathhints/controllers/IndexController.php +2 -16
- app/code/local/MagePsycho/Easypathhints/etc/adminhtml.xml +2 -2
- app/code/local/MagePsycho/Easypathhints/etc/config.xml +19 -14
- package.xml +6 -7
app/code/local/Mage/Core/Block/Template.php
DELETED
|
@@ -1,367 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
-
* If you did not receive a copy of the license and are unable to
|
| 12 |
-
* obtain it through the world-wide-web, please send an email
|
| 13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
-
*
|
| 15 |
-
* DISCLAIMER
|
| 16 |
-
*
|
| 17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
-
* versions in the future. If you wish to customize Magento for your
|
| 19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
-
*
|
| 21 |
-
* @category Mage
|
| 22 |
-
* @package Mage_Core
|
| 23 |
-
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
-
*/
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Base html block
|
| 30 |
-
*
|
| 31 |
-
* @category Mage
|
| 32 |
-
* @package Mage_Core
|
| 33 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
| 34 |
-
*/
|
| 35 |
-
class Mage_Core_Block_Template extends Mage_Core_Block_Abstract
|
| 36 |
-
{
|
| 37 |
-
const XML_PATH_DEBUG_TEMPLATE_HINTS = 'dev/debug/template_hints';
|
| 38 |
-
const XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS = 'dev/debug/template_hints_blocks';
|
| 39 |
-
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink';
|
| 40 |
-
|
| 41 |
-
/**
|
| 42 |
-
* View scripts directory
|
| 43 |
-
*
|
| 44 |
-
* @var string
|
| 45 |
-
*/
|
| 46 |
-
protected $_viewDir = '';
|
| 47 |
-
|
| 48 |
-
/**
|
| 49 |
-
* Assigned variables for view
|
| 50 |
-
*
|
| 51 |
-
* @var array
|
| 52 |
-
*/
|
| 53 |
-
protected $_viewVars = array();
|
| 54 |
-
|
| 55 |
-
protected $_baseUrl;
|
| 56 |
-
|
| 57 |
-
protected $_jsUrl;
|
| 58 |
-
|
| 59 |
-
/**
|
| 60 |
-
* Is allowed symlinks flag
|
| 61 |
-
*
|
| 62 |
-
* @var bool
|
| 63 |
-
*/
|
| 64 |
-
protected $_allowSymlinks = null;
|
| 65 |
-
|
| 66 |
-
protected static $_showTemplateHints;
|
| 67 |
-
protected static $_showTemplateHintsBlocks;
|
| 68 |
-
|
| 69 |
-
/**
|
| 70 |
-
* Path to template file in theme.
|
| 71 |
-
*
|
| 72 |
-
* @var string
|
| 73 |
-
*/
|
| 74 |
-
protected $_template;
|
| 75 |
-
|
| 76 |
-
/**
|
| 77 |
-
* Internal constructor, that is called from real constructor
|
| 78 |
-
*
|
| 79 |
-
*/
|
| 80 |
-
protected function _construct()
|
| 81 |
-
{
|
| 82 |
-
parent::_construct();
|
| 83 |
-
|
| 84 |
-
/*
|
| 85 |
-
* In case template was passed through constructor
|
| 86 |
-
* we assign it to block's property _template
|
| 87 |
-
* Mainly for those cases when block created
|
| 88 |
-
* not via Mage_Core_Model_Layout::addBlock()
|
| 89 |
-
*/
|
| 90 |
-
if ($this->hasData('template')) {
|
| 91 |
-
$this->setTemplate($this->getData('template'));
|
| 92 |
-
}
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
/**
|
| 96 |
-
* Get relevant path to template
|
| 97 |
-
*
|
| 98 |
-
* @return string
|
| 99 |
-
*/
|
| 100 |
-
public function getTemplate()
|
| 101 |
-
{
|
| 102 |
-
return $this->_template;
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
/**
|
| 106 |
-
* Set path to template used for generating block's output.
|
| 107 |
-
*
|
| 108 |
-
* @param string $template
|
| 109 |
-
* @return Mage_Core_Block_Template
|
| 110 |
-
*/
|
| 111 |
-
public function setTemplate($template)
|
| 112 |
-
{
|
| 113 |
-
$this->_template = $template;
|
| 114 |
-
return $this;
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
/**
|
| 118 |
-
* Get absolute path to template
|
| 119 |
-
*
|
| 120 |
-
* @return string
|
| 121 |
-
*/
|
| 122 |
-
public function getTemplateFile()
|
| 123 |
-
{
|
| 124 |
-
$params = array('_relative'=>true);
|
| 125 |
-
$area = $this->getArea();
|
| 126 |
-
if ($area) {
|
| 127 |
-
$params['_area'] = $area;
|
| 128 |
-
}
|
| 129 |
-
$templateName = Mage::getDesign()->getTemplateFilename($this->getTemplate(), $params);
|
| 130 |
-
return $templateName;
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
/**
|
| 134 |
-
* Get design area
|
| 135 |
-
* @return string
|
| 136 |
-
*/
|
| 137 |
-
public function getArea()
|
| 138 |
-
{
|
| 139 |
-
return $this->_getData('area');
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
/**
|
| 143 |
-
* Assign variable
|
| 144 |
-
*
|
| 145 |
-
* @param string|array $key
|
| 146 |
-
* @param mixed $value
|
| 147 |
-
* @return Mage_Core_Block_Template
|
| 148 |
-
*/
|
| 149 |
-
public function assign($key, $value=null)
|
| 150 |
-
{
|
| 151 |
-
if (is_array($key)) {
|
| 152 |
-
foreach ($key as $k=>$v) {
|
| 153 |
-
$this->assign($k, $v);
|
| 154 |
-
}
|
| 155 |
-
}
|
| 156 |
-
else {
|
| 157 |
-
$this->_viewVars[$key] = $value;
|
| 158 |
-
}
|
| 159 |
-
return $this;
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
/**
|
| 163 |
-
* Set template location dire
|
| 164 |
-
*
|
| 165 |
-
* @param string $dir
|
| 166 |
-
* @return Mage_Core_Block_Template
|
| 167 |
-
*/
|
| 168 |
-
public function setScriptPath($dir)
|
| 169 |
-
{
|
| 170 |
-
$this->_viewDir = $dir;
|
| 171 |
-
return $this;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/**
|
| 175 |
-
* Check if dirrect output is allowed for block
|
| 176 |
-
* @return bool
|
| 177 |
-
*/
|
| 178 |
-
public function getDirectOutput()
|
| 179 |
-
{
|
| 180 |
-
if ($this->getLayout()) {
|
| 181 |
-
return $this->getLayout()->getDirectOutput();
|
| 182 |
-
}
|
| 183 |
-
return false;
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
public function getShowTemplateHints()
|
| 187 |
-
{
|
| 188 |
-
if (is_null(self::$_showTemplateHints)) {
|
| 189 |
-
$helper = Mage::helper('easypathhints');
|
| 190 |
-
$isActive = $helper->getConfig('active');
|
| 191 |
-
$tp = Mage::app()->getRequest()->getParam('tp');
|
| 192 |
-
$accessCode = Mage::app()->getRequest()->getParam('code');
|
| 193 |
-
$dbAccessCode = $helper->getConfig('code');
|
| 194 |
-
if(!empty($dbAccessCode)){
|
| 195 |
-
$checkAccessCode = ($dbAccessCode == $accessCode) ? true : false;
|
| 196 |
-
}else{
|
| 197 |
-
$checkAccessCode = true;
|
| 198 |
-
}
|
| 199 |
-
if($tp && $isActive && $checkAccessCode){
|
| 200 |
-
self::$_showTemplateHints = true;
|
| 201 |
-
self::$_showTemplateHintsBlocks = true;
|
| 202 |
-
}else{
|
| 203 |
-
self::$_showTemplateHints = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS)
|
| 204 |
-
&& Mage::helper('core')->isDevAllowed();
|
| 205 |
-
self::$_showTemplateHintsBlocks = Mage::getStoreConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS)
|
| 206 |
-
&& Mage::helper('core')->isDevAllowed();
|
| 207 |
-
}
|
| 208 |
-
}
|
| 209 |
-
return self::$_showTemplateHints;
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
/**
|
| 213 |
-
* Retrieve block view from file (template)
|
| 214 |
-
*
|
| 215 |
-
* @param string $fileName
|
| 216 |
-
* @return string
|
| 217 |
-
*/
|
| 218 |
-
public function fetchView($fileName)
|
| 219 |
-
{
|
| 220 |
-
Varien_Profiler::start($fileName);
|
| 221 |
-
|
| 222 |
-
// EXTR_SKIP protects from overriding
|
| 223 |
-
// already defined variables
|
| 224 |
-
extract ($this->_viewVars, EXTR_SKIP);
|
| 225 |
-
$do = $this->getDirectOutput();
|
| 226 |
-
|
| 227 |
-
if (!$do) {
|
| 228 |
-
ob_start();
|
| 229 |
-
}
|
| 230 |
-
if ($this->getShowTemplateHints()) {
|
| 231 |
-
echo <<<HTML
|
| 232 |
-
<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;">
|
| 233 |
-
<div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial;
|
| 234 |
-
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex='999'"
|
| 235 |
-
onmouseout="this.style.zIndex='998'" title="{$fileName}">{$fileName}</div>
|
| 236 |
-
HTML;
|
| 237 |
-
if (self::$_showTemplateHintsBlocks) {
|
| 238 |
-
$thisClass = get_class($this);
|
| 239 |
-
echo <<<HTML
|
| 240 |
-
<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial;
|
| 241 |
-
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex='999'" onmouseout="this.style.zIndex='998'"
|
| 242 |
-
title="{$thisClass}">{$thisClass}</div>
|
| 243 |
-
HTML;
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
|
| 247 |
-
try {
|
| 248 |
-
$includeFilePath = realpath($this->_viewDir . DS . $fileName);
|
| 249 |
-
if (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks()) {
|
| 250 |
-
include $includeFilePath;
|
| 251 |
-
} else {
|
| 252 |
-
Mage::log('Not valid template file:'.$fileName, Zend_Log::CRIT, null, null, true);
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
} catch (Exception $e) {
|
| 256 |
-
ob_get_clean();
|
| 257 |
-
throw $e;
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
if ($this->getShowTemplateHints()) {
|
| 261 |
-
echo '</div>';
|
| 262 |
-
}
|
| 263 |
-
|
| 264 |
-
if (!$do) {
|
| 265 |
-
$html = ob_get_clean();
|
| 266 |
-
} else {
|
| 267 |
-
$html = '';
|
| 268 |
-
}
|
| 269 |
-
Varien_Profiler::stop($fileName);
|
| 270 |
-
return $html;
|
| 271 |
-
}
|
| 272 |
-
|
| 273 |
-
/**
|
| 274 |
-
* Render block
|
| 275 |
-
*
|
| 276 |
-
* @return string
|
| 277 |
-
*/
|
| 278 |
-
public function renderView()
|
| 279 |
-
{
|
| 280 |
-
$this->setScriptPath(Mage::getBaseDir('design'));
|
| 281 |
-
$html = $this->fetchView($this->getTemplateFile());
|
| 282 |
-
return $html;
|
| 283 |
-
}
|
| 284 |
-
|
| 285 |
-
/**
|
| 286 |
-
* Render block HTML
|
| 287 |
-
*
|
| 288 |
-
* @return string
|
| 289 |
-
*/
|
| 290 |
-
protected function _toHtml()
|
| 291 |
-
{
|
| 292 |
-
if (!$this->getTemplate()) {
|
| 293 |
-
return '';
|
| 294 |
-
}
|
| 295 |
-
$html = $this->renderView();
|
| 296 |
-
return $html;
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
/**
|
| 300 |
-
* Get base url of the application
|
| 301 |
-
*
|
| 302 |
-
* @return string
|
| 303 |
-
*/
|
| 304 |
-
public function getBaseUrl()
|
| 305 |
-
{
|
| 306 |
-
if (!$this->_baseUrl) {
|
| 307 |
-
$this->_baseUrl = Mage::getBaseUrl();
|
| 308 |
-
}
|
| 309 |
-
return $this->_baseUrl;
|
| 310 |
-
}
|
| 311 |
-
|
| 312 |
-
/**
|
| 313 |
-
* Get url of base javascript file
|
| 314 |
-
*
|
| 315 |
-
* To get url of skin javascript file use getSkinUrl()
|
| 316 |
-
*
|
| 317 |
-
* @param string $fileName
|
| 318 |
-
* @return string
|
| 319 |
-
*/
|
| 320 |
-
public function getJsUrl($fileName='')
|
| 321 |
-
{
|
| 322 |
-
if (!$this->_jsUrl) {
|
| 323 |
-
$this->_jsUrl = Mage::getBaseUrl('js');
|
| 324 |
-
}
|
| 325 |
-
return $this->_jsUrl.$fileName;
|
| 326 |
-
}
|
| 327 |
-
|
| 328 |
-
/**
|
| 329 |
-
* Get data from specified object
|
| 330 |
-
*
|
| 331 |
-
* @param Varien_Object $object
|
| 332 |
-
* @param string $key
|
| 333 |
-
* @return mixed
|
| 334 |
-
*/
|
| 335 |
-
public function getObjectData(Varien_Object $object, $key)
|
| 336 |
-
{
|
| 337 |
-
return $object->getDataUsingMethod((string)$key);
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
/**
|
| 341 |
-
* Get cache key informative items
|
| 342 |
-
*
|
| 343 |
-
* @return array
|
| 344 |
-
*/
|
| 345 |
-
public function getCacheKeyInfo()
|
| 346 |
-
{
|
| 347 |
-
return array(
|
| 348 |
-
'BLOCK_TPL',
|
| 349 |
-
Mage::app()->getStore()->getCode(),
|
| 350 |
-
$this->getTemplateFile(),
|
| 351 |
-
'template' => $this->getTemplate()
|
| 352 |
-
);
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
/**
|
| 356 |
-
* Get is allowed symliks flag
|
| 357 |
-
*
|
| 358 |
-
* @return bool
|
| 359 |
-
*/
|
| 360 |
-
protected function _getAllowSymlinks()
|
| 361 |
-
{
|
| 362 |
-
if (is_null($this->_allowSymlinks)) {
|
| 363 |
-
$this->_allowSymlinks = Mage::getStoreConfigFlag(self::XML_PATH_TEMPLATE_ALLOW_SYMLINK);
|
| 364 |
-
}
|
| 365 |
-
return $this->_allowSymlinks;
|
| 366 |
-
}
|
| 367 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/MagePsycho/Easypathhints/Block/Easypathhints.php
CHANGED
|
@@ -1,5 +1,12 @@
|
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
class MagePsycho_Easypathhints_Block_Easypathhints extends Mage_Core_Block_Template
|
| 3 |
{
|
| 4 |
-
|
| 5 |
}
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @category MagePsycho
|
| 4 |
+
* @package MagePsycho_Easypathhints
|
| 5 |
+
* @author magepsycho@gmail.com
|
| 6 |
+
* @website http://www.magepsycho.com
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
class MagePsycho_Easypathhints_Block_Easypathhints extends Mage_Core_Block_Template
|
| 10 |
{
|
| 11 |
+
|
| 12 |
}
|
app/code/local/MagePsycho/Easypathhints/Block/System/Config/Info.php
CHANGED
|
@@ -3,14 +3,14 @@
|
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
-
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_Block_System_Config_Info
|
| 10 |
extends Mage_Adminhtml_Block_Abstract
|
| 11 |
implements Varien_Data_Form_Element_Renderer_Interface
|
| 12 |
{
|
| 13 |
-
|
| 14 |
/**
|
| 15 |
* Render fieldset html
|
| 16 |
*
|
|
@@ -26,7 +26,7 @@ class MagePsycho_Easypathhints_Block_System_Config_Info
|
|
| 26 |
<a href="http://www.magepsycho.com/contacts" target="_blank">Request a Quote / Contact Us</a><br />
|
| 27 |
Skype me @ magentopycho<br />
|
| 28 |
Email me @ <a href="mailto:info@magepsycho.com">info@magepsycho.com</a><br />
|
| 29 |
-
Follow me on <a href="http://twitter.com/magepsycho" target="_blank"
|
| 30 |
Visit my website: <a href="http://www.magepsycho.com" target="_blank">www.magespycho.com</a></p>
|
| 31 |
</div>';
|
| 32 |
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
+
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_Block_System_Config_Info
|
| 10 |
extends Mage_Adminhtml_Block_Abstract
|
| 11 |
implements Varien_Data_Form_Element_Renderer_Interface
|
| 12 |
{
|
| 13 |
+
|
| 14 |
/**
|
| 15 |
* Render fieldset html
|
| 16 |
*
|
| 26 |
<a href="http://www.magepsycho.com/contacts" target="_blank">Request a Quote / Contact Us</a><br />
|
| 27 |
Skype me @ magentopycho<br />
|
| 28 |
Email me @ <a href="mailto:info@magepsycho.com">info@magepsycho.com</a><br />
|
| 29 |
+
Follow me on Twitter <a href="http://twitter.com/magepsycho" target="_blank">@magepsycho</a><br />
|
| 30 |
Visit my website: <a href="http://www.magepsycho.com" target="_blank">www.magespycho.com</a></p>
|
| 31 |
</div>';
|
| 32 |
|
app/code/local/MagePsycho/Easypathhints/Helper/Data.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
-
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_Helper_Data extends Mage_Core_Helper_Abstract
|
|
@@ -11,16 +11,20 @@ class MagePsycho_Easypathhints_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 11 |
public function getConfig($field, $default = null){
|
| 12 |
$value = Mage::getStoreConfig('easypathhints/option/'.$field);
|
| 13 |
if(!isset($value) or trim($value) == ''){
|
| 14 |
-
return $default;
|
| 15 |
}else{
|
| 16 |
return $value;
|
| 17 |
-
}
|
| 18 |
}
|
| 19 |
-
|
| 20 |
public function log($data){
|
| 21 |
if(is_array($data) || is_object($data)){
|
| 22 |
$data = print_r($data, true);
|
| 23 |
}
|
| 24 |
-
Mage::log($data, null, 'easypathhints.log');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
}
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
+
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_Helper_Data extends Mage_Core_Helper_Abstract
|
| 11 |
public function getConfig($field, $default = null){
|
| 12 |
$value = Mage::getStoreConfig('easypathhints/option/'.$field);
|
| 13 |
if(!isset($value) or trim($value) == ''){
|
| 14 |
+
return $default;
|
| 15 |
}else{
|
| 16 |
return $value;
|
| 17 |
+
}
|
| 18 |
}
|
| 19 |
+
|
| 20 |
public function log($data){
|
| 21 |
if(is_array($data) || is_object($data)){
|
| 22 |
$data = print_r($data, true);
|
| 23 |
}
|
| 24 |
+
Mage::log($data, null, 'easypathhints.log');
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public function isActive(){
|
| 28 |
+
return $this->getConfig('active');
|
| 29 |
}
|
| 30 |
}
|
app/code/local/MagePsycho/Easypathhints/Model/Observer.php
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @category MagePsycho
|
| 4 |
+
* @package MagePsycho_Easypathhints
|
| 5 |
+
* @author magepsycho@gmail.com
|
| 6 |
+
* @website http://www.magepsycho.com
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
class MagePsycho_Easypathhints_Model_Observer {
|
| 10 |
+
|
| 11 |
+
public function setTemplatePathHints(Varien_Event_Observer $observer) {
|
| 12 |
+
$helper = Mage::helper('easypathhints');
|
| 13 |
+
$isActive = $helper->isActive();
|
| 14 |
+
$tp = Mage::app()->getRequest()->getParam('tp');
|
| 15 |
+
$accessCode = Mage::app()->getRequest()->getParam('code');
|
| 16 |
+
$dbAccessCode = $helper->getConfig('code');
|
| 17 |
+
|
| 18 |
+
if(!empty($dbAccessCode)){
|
| 19 |
+
$checkAccessCode = ($dbAccessCode == $accessCode) ? true : false;
|
| 20 |
+
}else{
|
| 21 |
+
$checkAccessCode = true;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
if ($tp && $isActive && $checkAccessCode):
|
| 25 |
+
|
| 26 |
+
/* @var $block Mage_Core_Block_Abstract */
|
| 27 |
+
$block = $observer->getBlock();
|
| 28 |
+
$transport = $observer->getTransport();
|
| 29 |
+
|
| 30 |
+
$fileName = $block->getTemplateFile();
|
| 31 |
+
$thisClass = get_class($block);
|
| 32 |
+
if($fileName){
|
| 33 |
+
$preHtml = '<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;">
|
| 34 |
+
<div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial;
|
| 35 |
+
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'"
|
| 36 |
+
onmouseout="this.style.zIndex=\'998\'" title="'.$fileName.'">'.$fileName.'</div>';
|
| 37 |
+
$preHtml .= '<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial;
|
| 38 |
+
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex=\'999\'" onmouseout="this.style.zIndex=\'998\'"
|
| 39 |
+
title="'.$thisClass.'">'.$thisClass.'</div>';
|
| 40 |
+
|
| 41 |
+
$postHtml = '</div>';
|
| 42 |
+
}else{
|
| 43 |
+
$preHtml = null;
|
| 44 |
+
$postHtml = null;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
$html = $transport->getHtml();
|
| 49 |
+
$html = $preHtml . $html . $postHtml;
|
| 50 |
+
$transport->setHtml($html);
|
| 51 |
+
|
| 52 |
+
endif;
|
| 53 |
+
}
|
| 54 |
+
}
|
app/code/local/MagePsycho/Easypathhints/controllers/IndexController.php
CHANGED
|
@@ -3,27 +3,13 @@
|
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
-
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_IndexController extends Mage_Core_Controller_Front_Action
|
| 10 |
{
|
| 11 |
public function indexAction()
|
| 12 |
{
|
| 13 |
-
|
| 14 |
-
$groups_value = array();
|
| 15 |
-
$groups_value['debug']['fields']['template_hints']['value'] = 1;
|
| 16 |
-
$groups_value['debug']['fields']['template_hints_blocks']['value'] = 1;
|
| 17 |
-
|
| 18 |
-
$website = $this->getRequest()->getParam('website');
|
| 19 |
-
$store = $this->getRequest()->getParam('store');
|
| 20 |
-
Mage::getModel('adminhtml/config_data')
|
| 21 |
-
->setSection('dev')
|
| 22 |
-
->setWebsite($website)
|
| 23 |
-
->setStore($store)
|
| 24 |
-
->setGroups($groups_value)
|
| 25 |
-
->save();
|
| 26 |
-
Mage::getConfig()->reinit();
|
| 27 |
-
Mage::app()->reinitStores();
|
| 28 |
}
|
| 29 |
}
|
| 3 |
* @category MagePsycho
|
| 4 |
* @package MagePsycho_Easypathhints
|
| 5 |
* @author magepsycho@gmail.com
|
| 6 |
+
* @website http://www.magepsycho.com
|
| 7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
*/
|
| 9 |
class MagePsycho_Easypathhints_IndexController extends Mage_Core_Controller_Front_Action
|
| 10 |
{
|
| 11 |
public function indexAction()
|
| 12 |
{
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
}
|
app/code/local/MagePsycho/Easypathhints/etc/adminhtml.xml
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
<!--
|
| 3 |
/**
|
| 4 |
* @category MagePsycho
|
| 5 |
-
* @package
|
| 6 |
-
* @author
|
| 7 |
* @website http://www.magepsycho.com
|
| 8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
*/
|
| 2 |
<!--
|
| 3 |
/**
|
| 4 |
* @category MagePsycho
|
| 5 |
+
* @package MagePsycho_Easypathhints
|
| 6 |
+
* @author magepsycho@gmail.com
|
| 7 |
* @website http://www.magepsycho.com
|
| 8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
*/
|
app/code/local/MagePsycho/Easypathhints/etc/config.xml
CHANGED
|
@@ -1,40 +1,45 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
-
<!--
|
| 3 |
/**
|
| 4 |
* @category MagePsycho
|
| 5 |
* @package MagePsycho_Easypathhints
|
| 6 |
* @author info@magepsycho.com
|
| 7 |
-
* @website http://www.magepsycho.com
|
| 8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
*/
|
| 10 |
-->
|
| 11 |
<config>
|
| 12 |
<modules>
|
| 13 |
<MagePsycho_Easypathhints>
|
| 14 |
-
<version>0.
|
| 15 |
</MagePsycho_Easypathhints>
|
| 16 |
</modules>
|
| 17 |
<global>
|
| 18 |
<models>
|
| 19 |
<easypathhints>
|
| 20 |
<class>MagePsycho_Easypathhints_Model</class>
|
| 21 |
-
</easypathhints>
|
| 22 |
-
</models>
|
| 23 |
<blocks>
|
| 24 |
<easypathhints>
|
| 25 |
<class>MagePsycho_Easypathhints_Block</class>
|
| 26 |
</easypathhints>
|
| 27 |
-
<core>
|
| 28 |
-
<rewrite>
|
| 29 |
-
<template>MagePsycho_Easypathhints_Block_Template</template>
|
| 30 |
-
</rewrite>
|
| 31 |
-
</core>
|
| 32 |
</blocks>
|
| 33 |
<helpers>
|
| 34 |
<easypathhints>
|
| 35 |
<class>MagePsycho_Easypathhints_Helper</class>
|
| 36 |
</easypathhints>
|
| 37 |
</helpers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
</global>
|
| 39 |
<frontend>
|
| 40 |
<routers>
|
|
@@ -46,7 +51,7 @@
|
|
| 46 |
</args>
|
| 47 |
</easypathhints>
|
| 48 |
</routers>
|
| 49 |
-
</frontend>
|
| 50 |
<adminhtml>
|
| 51 |
<acl>
|
| 52 |
<resources>
|
|
@@ -70,13 +75,13 @@
|
|
| 70 |
</admin>
|
| 71 |
</resources>
|
| 72 |
</acl>
|
| 73 |
-
</adminhtml>
|
| 74 |
<default>
|
| 75 |
<easypathhints>
|
| 76 |
<option>
|
| 77 |
-
<active>1</active>
|
| 78 |
<code>magento</code>
|
| 79 |
</option>
|
| 80 |
</easypathhints>
|
| 81 |
-
</default>
|
| 82 |
</config>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
/**
|
| 4 |
* @category MagePsycho
|
| 5 |
* @package MagePsycho_Easypathhints
|
| 6 |
* @author info@magepsycho.com
|
| 7 |
+
* @website http://www.magepsycho.com
|
| 8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
*/
|
| 10 |
-->
|
| 11 |
<config>
|
| 12 |
<modules>
|
| 13 |
<MagePsycho_Easypathhints>
|
| 14 |
+
<version>0.2.0</version>
|
| 15 |
</MagePsycho_Easypathhints>
|
| 16 |
</modules>
|
| 17 |
<global>
|
| 18 |
<models>
|
| 19 |
<easypathhints>
|
| 20 |
<class>MagePsycho_Easypathhints_Model</class>
|
| 21 |
+
</easypathhints>
|
| 22 |
+
</models>
|
| 23 |
<blocks>
|
| 24 |
<easypathhints>
|
| 25 |
<class>MagePsycho_Easypathhints_Block</class>
|
| 26 |
</easypathhints>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</blocks>
|
| 28 |
<helpers>
|
| 29 |
<easypathhints>
|
| 30 |
<class>MagePsycho_Easypathhints_Helper</class>
|
| 31 |
</easypathhints>
|
| 32 |
</helpers>
|
| 33 |
+
<events>
|
| 34 |
+
<core_block_abstract_to_html_after>
|
| 35 |
+
<observers>
|
| 36 |
+
<easypathhints_core_block_abstract_to_html_after>
|
| 37 |
+
<class>easypathhints/observer</class>
|
| 38 |
+
<method>setTemplatePathHints</method>
|
| 39 |
+
</easypathhints_core_block_abstract_to_html_after>
|
| 40 |
+
</observers>
|
| 41 |
+
</core_block_abstract_to_html_after>
|
| 42 |
+
</events>
|
| 43 |
</global>
|
| 44 |
<frontend>
|
| 45 |
<routers>
|
| 51 |
</args>
|
| 52 |
</easypathhints>
|
| 53 |
</routers>
|
| 54 |
+
</frontend>
|
| 55 |
<adminhtml>
|
| 56 |
<acl>
|
| 57 |
<resources>
|
| 75 |
</admin>
|
| 76 |
</resources>
|
| 77 |
</acl>
|
| 78 |
+
</adminhtml>
|
| 79 |
<default>
|
| 80 |
<easypathhints>
|
| 81 |
<option>
|
| 82 |
+
<active>1</active>
|
| 83 |
<code>magento</code>
|
| 84 |
</option>
|
| 85 |
</easypathhints>
|
| 86 |
+
</default>
|
| 87 |
</config>
|
package.xml
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Easy_Template_Path_Hints</name>
|
| 4 |
-
<version>0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easy Template Path Hints extension is used to turn on the template path hints for frontend</summary>
|
| 10 |
<description>Easy Template Path Hints extension is used to turn on the template path hints for frontend</description>
|
| 11 |
-
<notes>-
|
| 12 |
-
-
|
| 13 |
-
- Easy to install</notes>
|
| 14 |
<authors><author><name>MagePsycho</name><user>auto-converted</user><email>rajen_k_bhtt@hotmail.com</email></author></authors>
|
| 15 |
-
<date>
|
| 16 |
-
<time>
|
| 17 |
-
<contents><target name="magelocal"><dir name="MagePsycho"><dir name="Easypathhints"><dir name="Block"><dir name="System"><dir name="Config"><file name="Info.php" hash="
|
| 18 |
<compatible/>
|
| 19 |
<dependencies/>
|
| 20 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Easy_Template_Path_Hints</name>
|
| 4 |
+
<version>0.2.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easy Template Path Hints extension is used to turn on the template path hints for frontend</summary>
|
| 10 |
<description>Easy Template Path Hints extension is used to turn on the template path hints for frontend</description>
|
| 11 |
+
<notes>- Fixed all the issues related to the Easy Template Path Hints
|
| 12 |
+
- Used event-observer method to turn on/off template path hints</notes>
|
|
|
|
| 13 |
<authors><author><name>MagePsycho</name><user>auto-converted</user><email>rajen_k_bhtt@hotmail.com</email></author></authors>
|
| 14 |
+
<date>2012-03-03</date>
|
| 15 |
+
<time>17:21:36</time>
|
| 16 |
+
<contents><target name="magelocal"><dir name="MagePsycho"><dir name="Easypathhints"><dir name="Block"><dir name="System"><dir name="Config"><file name="Info.php" hash="09e62815ab54bf2f73ae70c94ffe9f02"/></dir></dir><file name="Easypathhints.php" hash="4f3f5b2fadef393abddd4fd1587150b0"/></dir><dir name="Helper"><file name="Data.php" hash="16b72955af5218ccac9b7f944078577e"/></dir><dir name="Model"><file name="Easypathhints.php" hash="c4dfd676133eb413d6191f43c17e008f"/><file name="Observer.php" hash="3b76f5dc2708637ab4db318cc301234f"/></dir><dir name="controllers"><file name="IndexController.php" hash="f555e0d45eca2fb1d13d3f3c181fdc8f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4539abd237cb1105c3664ada132ed546"/><file name="config.xml" hash="07b1d98c5adaa269be592bfc0f2fe973"/><file name="system.xml" hash="6477a7d85c3ae053e8c8670f087e6930"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MagePsycho_Easypathhints.xml" hash="f758539550c2ed5c83e195eaa7c244a2"/></dir></target></contents>
|
| 17 |
<compatible/>
|
| 18 |
<dependencies/>
|
| 19 |
</package>
|
