Skip to content

Commit

Permalink
Refactored for module naming standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Drak committed Apr 21, 2012
1 parent 6e8df89 commit 450fdb2
Show file tree
Hide file tree
Showing 42 changed files with 144 additions and 273 deletions.
14 changes: 7 additions & 7 deletions src/Zikula/Bundle/CoreBundle/EventListener/InitListener.php
Expand Up @@ -22,7 +22,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Users\Constants as UsersConstant;
use UsersModule\Constants as UsersConstant;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
Expand Down Expand Up @@ -156,12 +156,12 @@ public function onInit(GetResponseEvent $event) //$stage = self::STAGE_ALL)
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
\ModUtil::initCoreVars();
\ModUtil::dbInfoLoad('Settings', 'Settings');
\ModUtil::dbInfoLoad('Theme', 'Theme');
\ModUtil::dbInfoLoad('Users', 'Users');
\ModUtil::dbInfoLoad('Groups', 'Groups');
\ModUtil::dbInfoLoad('Permissions', 'Permissions');
\ModUtil::dbInfoLoad('Categories', 'Categories');
\ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
\ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
\ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
\ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
\ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
\ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');

if (!\System::isInstalling()) {
\ModUtil::registerAutoloaders();
Expand Down
160 changes: 1 addition & 159 deletions src/Zikula/Core/Core.php
Expand Up @@ -21,7 +21,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Users\Constants as UsersConstant;
use UsersModule\Constants as UsersConstant;


// Defines for access levels
Expand Down Expand Up @@ -360,162 +360,4 @@ public function getStage()
{
return $this->stage;
}

/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL)
{
$coreInitEvent = new GenericEvent($this);

// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;

if (($stage & self::STAGE_PRE) && ($this->stage & ~self::STAGE_PRE)) {
\ModUtil::flushCache();
\System::flushCache();
$this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
}

// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
// error reporting
if (!\System::isInstalling()) {
// this is here because it depends on the config.php loading.
$event = new GenericEvent(null, array('stage' => $stage));
$this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
}

// initialise custom event listeners from config.php settings
$coreInitEvent->setArg('stage', self::STAGE_CONFIG);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}


// Check that Zikula is installed before continuing
if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
$response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
$response->send();
\System::shutdown();
}

if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
} catch (\PDOException $e) {
if (!\System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
\System::shutDown();
} else {
return false;
}
}
}

if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
\ModUtil::initCoreVars();
\ModUtil::dbInfoLoad('Settings', 'Settings');
\ModUtil::dbInfoLoad('Theme', 'Theme');
\ModUtil::dbInfoLoad('Users', 'Users');
\ModUtil::dbInfoLoad('Groups', 'Groups');
\ModUtil::dbInfoLoad('Permissions', 'Permissions');
\ModUtil::dbInfoLoad('Categories', 'Categories');

if (!\System::isInstalling()) {
\ModUtil::registerAutoloaders();
}

$coreInitEvent->setArg('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}

if ($stage & self::STAGE_SESSIONS) {
\SessionUtil::requireSession();
$coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}

// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = \ZLanguage::getInstance();
}

if ($stage & self::STAGE_DECODEURLS) {
\System::queryStringDecode();
$coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}

if ($stage & self::STAGE_LANGS) {
$lang->setup();
$coreInitEvent->setArg('stage', self::STAGE_LANGS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
// end block

if ($stage & self::STAGE_MODS) {
// Set compression on if desired
if (\System::getVar('UseCompression') == 1) {
//ob_start("ob_gzhandler");
}

\ModUtil::load('SecurityCenter');

$coreInitEvent->setArg('stage', self::STAGE_MODS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}

if ($stage & self::STAGE_THEME) {
// register default page vars
\PageUtil::registerVar('title');
\PageUtil::setVar('title', \System::getVar('defaultpagetitle'));
\PageUtil::registerVar('keywords', true);
\PageUtil::registerVar('stylesheet', true);
\PageUtil::registerVar('javascript', true);
\PageUtil::registerVar('jsgettext', true);
\PageUtil::registerVar('body', true);
\PageUtil::registerVar('header', true);
\PageUtil::registerVar('footer', true);

$theme = \Zikula_View_Theme::getInstance();

// set some defaults
// Metadata for SEO
$this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription');
$this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords');

$coreInitEvent->setArg('stage', self::STAGE_THEME);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}

// check the users status, if not 1 then log him out
if (\UserUtil::isLoggedIn()) {
$userstatus = \UserUtil::getVar('activated');
if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) {
\UserUtil::logout();
// TODO - When getting logged out this way, the existing session is destroyed and
// then a new one is created on the reentry into index.php. The message
// set by the registerStatus call below gets lost.
\LogUtil::registerStatus(__('You have been logged out.'));
$response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login'));
$response->send();
exit;
}
}

if (($stage & self::STAGE_POST) && ($this->stage & ~self::STAGE_POST)) {
$this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage)));
}
}
}
8 changes: 5 additions & 3 deletions src/legacy/Zikula/View.php
Expand Up @@ -13,7 +13,7 @@
*/

use Zikula\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispacter;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Zikula\Common\I18n\TranslatableInterface;
use Zikula\Core\Event\GenericEvent;

Expand Down Expand Up @@ -120,7 +120,7 @@ class Zikula_View extends Smarty implements TranslatableInterface
/**
* The event manager instance.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcher
* @var EventDispatcher
*/
protected $dispatcher;

Expand Down Expand Up @@ -240,7 +240,7 @@ public function __construct(ContainerBuilder $container, $moduleName = '', $cach
// include system/Admin/templates/plugins to the plugins_dir array
if ($type === 'admin') {
if (!$this instanceof Zikula_View_Theme) {
$this->addPluginDir('system/Admin/Resources/view/plugins');
$this->addPluginDir('system/AdminModule/Resources/view/plugins');
} else {
$this->load_filter('output', 'admintitle');
}
Expand Down Expand Up @@ -352,6 +352,8 @@ public static function getInstance($module = null, $caching = null, $cache_id =
$module = ModUtil::getName();
}

$module = preg_match('/\w+Module$/', $module) ? $module : $module.'Module';

$container = ServiceUtil::getManager();
$serviceId = strtolower(sprintf('zikula.view.%s', $module));
if (!$container->has($serviceId)) {
Expand Down
4 changes: 3 additions & 1 deletion src/legacy/Zikula/View/Theme.php
Expand Up @@ -272,6 +272,8 @@ public static function getInstance($themeName = '', $caching = null, $cache_id =
$themeName = UserUtil::getTheme();
}

$themeName = preg_match('/\w+Theme$/', $themeName) ? $themeName : $themeName.'Theme';

$serviceId = 'zikula.theme';
$container = ServiceUtil::getManager();

Expand Down Expand Up @@ -637,7 +639,7 @@ public function load_config()
{
if (!$this->themeconfig) {
// load the page configurations
$pageconfigurations = ModUtil::apiFunc('Theme', 'user', 'getpageconfigurations', array('theme' => $this->name));
$pageconfigurations = ModUtil::apiFunc('ThemeModule', 'user', 'getpageconfigurations', array('theme' => $this->name));

// identify and load the correct module configuration

Expand Down
7 changes: 1 addition & 6 deletions src/util/DBUtil.php
Expand Up @@ -2922,14 +2922,9 @@ public static function getTableConstraints($table)
throw new Exception(__f('%s does not point to a valid table definition', $table));
}

//try {
// return Doctrine_Manager::getInstance()->getCurrentConnection()->import->listTableConstraints($tableName);
//} catch (Exception $e) {
// return LogUtil::registerError(__('Error! Table constraints determination failed.') . ' ' . $e->getMessage());
//}

$tablecol = $table . '_column';
$tableopt = $table . '_constraints';
$constraints = '';
$tables = self::getTables();
if (array_key_exists($tableopt, $tables) && is_array($tables[$tableopt])) {
foreach ($tables[$tableopt] as $fk_column => $fk_reference) {
Expand Down

0 comments on commit 450fdb2

Please sign in to comment.