/** * @param string $name * * @return mixed|string */ public function getSource($name) { $name = $this->getName($name); $content = ''; if ($pos = strpos($name, '@')) { $propertySet = substr($name, $pos + 1); $name = substr($name, 0, $pos); } $c = (is_numeric($name) and $name > 0) ? $name : array('templatename' => $name); /** @var modChunk $chunk */ if ($element = $this->modx->getObject('modTemplate', $c)) { $content = $element->getContent(); if (!empty($propertySet) and $tmp = $element->getPropertySet($propertySet)) { $properties = $tmp; } else { $properties = $element->getProperties(); } if (!empty($content) and !empty($properties)) { $content = $this->twiggy->parseChunk('@INLINE ' . $content, $properties); } } return $content; }
/** * @param string $action * @param array $properties * * @return array */ public static function runProcessor($action = '', array $properties = array()) { $options = array(); $namespace = self::$modx->getOption('ns', $properties, null, true); if ($namespace) { $corePath = self::$modx->getOption("{$namespace}.core_path", null); if (!$corePath and $ns = self::$modx->getObject('modNamespace', $namespace)) { $corePath = $ns->getCorePath(); } self::$modx->addPackage($namespace, $corePath . "model/"); $options['processors_path'] = $corePath . 'processors/'; } if (!empty($properties['location'])) { $options['location'] = $properties['location']; } self::$modx->error->reset(); $response = self::$modx->runProcessor($action, $properties, $options); if ($response instanceof modProcessorResponse) { $output = array('success' => !$response->isError(), 'message' => $response->getMessage(), 'response' => self::$modx->fromJSON($response->getResponse()), 'errors' => $response->getFieldErrors()); } else { $output = array('success' => false, 'message' => $response, 'response' => array(), 'errors' => array()); } return $output; }