implement module inclusion
This commit is contained in:
@@ -35,13 +35,14 @@ abstract class BaseModuleGenerate extends ContainerAwareCommand
|
|||||||
protected $moduleDirectory;
|
protected $moduleDirectory;
|
||||||
|
|
||||||
protected $reservedKeyWords = array(
|
protected $reservedKeyWords = array(
|
||||||
"thelia"
|
'thelia'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $neededDirectories = array(
|
protected $neededDirectories = array(
|
||||||
"Config",
|
'Config',
|
||||||
"Model",
|
'Model',
|
||||||
"Loop"
|
'Loop',
|
||||||
|
'AdminModule'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected function verifyExistingModule()
|
protected function verifyExistingModule()
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace Thelia\Core\Template\Smarty\Plugins;
|
|||||||
|
|
||||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||||
|
use Thelia\Model\ModuleQuery;
|
||||||
|
|
||||||
class Module extends AbstractSmartyPlugin
|
class Module extends AbstractSmartyPlugin
|
||||||
{
|
{
|
||||||
@@ -32,13 +33,27 @@ class Module extends AbstractSmartyPlugin
|
|||||||
* Process theliaModule template inclusion function
|
* Process theliaModule template inclusion function
|
||||||
*
|
*
|
||||||
* @param unknown $params
|
* @param unknown $params
|
||||||
* @param unknown $smarty
|
* @param \Smarty_Internal_Template $template
|
||||||
|
* @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function theliaModule($params, &$smarty)
|
public function theliaModule($params, \Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
// TODO
|
$content = null;
|
||||||
return "";
|
if (array_key_exists('location', $params)) {
|
||||||
|
$location = $params['location'];
|
||||||
|
$modules = ModuleQuery::getActivated();
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
|
||||||
|
$file = THELIA_MODULE_DIR . "/". ucfirst($module->getCode()) . "/ModuleAdmin/".$location.".html";
|
||||||
|
if(file_exists($file)) {
|
||||||
|
$content .= file_get_contents($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $template->fetch(sprintf("string:%s", $content));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
|
use Propel\Runtime\Connection\ConnectionInterface;
|
||||||
use Thelia\Model\Base\Module as BaseModule;
|
use Thelia\Model\Base\Module as BaseModule;
|
||||||
|
|
||||||
class Module extends BaseModule {
|
class Module extends BaseModule {
|
||||||
|
|
||||||
|
public function postSave(ConnectionInterface $con = null)
|
||||||
|
{
|
||||||
|
ModuleQuery::resetActivated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,26 @@ use Thelia\Model\Base\ModuleQuery as BaseModuleQuery;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ModuleQuery extends BaseModuleQuery {
|
class ModuleQuery extends BaseModuleQuery {
|
||||||
|
|
||||||
|
protected static $activated = null;
|
||||||
/**
|
/**
|
||||||
* @return array|mixed|\PropelObjectCollection
|
* @return array|mixed|\PropelObjectCollection
|
||||||
*/
|
*/
|
||||||
public static function getActivated()
|
public static function getActivated()
|
||||||
{
|
{
|
||||||
return self::create()
|
if(null === self::$activated) {
|
||||||
->filterByActivate(1)
|
self::$activated = self::create()
|
||||||
->find();
|
->filterByActivate(1)
|
||||||
|
->find();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function resetActivated()
|
||||||
|
{
|
||||||
|
self::$activated = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // ModuleQuery
|
} // ModuleQuery
|
||||||
|
|||||||
Reference in New Issue
Block a user