From 8ec4cd6ea3271be0a90c553c4564a5845d3bddaa Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sun, 25 May 2014 00:55:53 +1000 Subject: [PATCH] Add method for looking up other page component properties (getOtherPageComponent) --- modules/cms/classes/Controller.php | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index 557739b7a..c20de34b2 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -1,6 +1,7 @@ getTheme(); + $manager = ComponentManager::instance(); + $componentObj = new $class; + + if (($page = Page::loadCached($theme, $page)) && isset($page->settings['components'])) { + foreach ($page->settings['components'] as $component => $properties) { + list($name, $alias) = strpos($component, ' ') ? explode(' ', $component) : array($component, $component); + if ($manager->resolve($name) == $class) { + $componentObj->setProperties($properties); + $componentObj->alias = $alias; + return $componentObj; + } + } + + if (!isset($page->settings['layout'])) + return null; + + $layout = $page->settings['layout']; + if (($layout = Layout::loadCached($theme, $layout)) && isset($layout->settings['components'])) { + foreach ($layout->settings['components'] as $component => $properties) { + list($name, $alias) = strpos($component, ' ') ? explode(' ', $component) : array($component, $component); + if ($manager->resolve($name) == $class) { + $componentObj->setProperties($properties); + $componentObj->alias = $alias; + return $componentObj; + } + } + } + } + + return null; + } + /** * Executes the page, layout, component and plugin AJAX handlers. * @return mixed Returns the AJAX Response object or null. @@ -710,7 +753,6 @@ class Controller extends BaseController return null; } - /** * Searches the layout and page components by a partial file * @return ComponentBase The component object, if found