Last active
May 11, 2016 17:01
-
-
Save sergant210/6975e37ad02605a95cee684c77d6cf7e to your computer and use it in GitHub Desktop.
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
<?php | |
require_once '_fenom.php'; | |
class FenomPlus extends FenomX | |
{ | |
/** | |
* @inheritdoc | |
*/ | |
protected function _addDefaultModifiers() | |
{ | |
parent::_addDefaultModifiers(); | |
$modx = $this->modx; | |
/** @var pdoToolsPlus $pdo */ | |
$pdo = $this->pdoTools; | |
$fenom = $this; | |
// Get chunk from file | |
$this->_modifiers['chunk'] = function ($input, $options = array()) use ($modx, $pdo) { | |
$input = str_replace(array('../','./'),'',$input); | |
$pdo->config['tplPath'] = isset($options['tplPath']) ? $options['tplPath'] : MODX_CORE_PATH . 'elements/chunks'; | |
if (!preg_match('/(.html|.tpl)$/i', $input)) { | |
$input .= '.tpl'; | |
} | |
$content = $pdo->parseChunk('@FILE '. $input, $options); | |
unset($pdo->config['tplPath']); | |
return $content ? $content : $input; | |
}; | |
// Get snippet from file | |
$this->_modifiers['snippet'] = function ($input, $options = array()) use ($modx, $pdo) { | |
$input = str_replace(array('../','./'),'',$input); | |
$pdo->config['tplPath'] = isset($options['tplPath']) ? $options['tplPath'] : NULL; | |
$output = $pdo->includeSnippet($input, $options); | |
unset($pdo->config['tplPath']); | |
return $output ? $output : $input; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment