/** * Create locale cache files * * @return void */ private function createLocaleFiles() { // all available languages $languages = array_unique(array_merge(SpoonSession::get('languages'), SpoonSession::get('interface_languages'))); // loop all the languages foreach ($languages as $language) { // get applications $applications = $this->db->getColumn('SELECT DISTINCT application FROM locale WHERE language = ?', array((string) $language)); // loop applications foreach ((array) $applications as $application) { // build application locale cache $this->buildCache($this->db, $language, $application); } } }
/** * Installs the required and optional modules */ private function installModules() { // The default extras to add to every page after installation of all modules and to add to the default templates. $defaultExtras = array(); // init var $warnings = array(); /** * First we need to install the core. All the linked modules, settings and sql tables are * being installed. */ require_once PATH_WWW . '/backend/core/installer/installer.php'; // create the core installer $installer = new CoreInstaller($this->db, SpoonSession::get('languages'), SpoonSession::get('interface_languages'), SpoonSession::get('example_data'), array('default_language' => SpoonSession::get('default_language'), 'default_interface_language' => SpoonSession::get('default_interface_language'), 'spoon_debug_email' => SpoonSession::get('email'), 'api_email' => SpoonSession::get('email'), 'site_domain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'fork.local', 'site_title' => 'Fork CMS', 'smtp_server' => '', 'smtp_port' => '', 'smtp_username' => '', 'smtp_password' => '')); // install the core $installer->install(); // add the warnings $moduleWarnings = $installer->getWarnings(); if (!empty($moduleWarnings)) { $warnings[] = array('module' => 'core', 'warnings' => $moduleWarnings); } // add the default extras $moduleDefaultExtras = $installer->getDefaultExtras(); if (!empty($moduleDefaultExtras)) { array_merge($defaultExtras, $moduleDefaultExtras); } // variables passed to module installers $variables = array(); $variables['email'] = SpoonSession::get('email'); $variables['default_interface_language'] = SpoonSession::get('default_interface_language'); // modules to install (required + selected) $modules = array_unique(array_merge($this->modules['required'], SpoonSession::get('modules'))); // loop required modules foreach ($modules as $module) { // install exists if (SpoonFile::exists(PATH_WWW . '/backend/modules/' . $module . '/installer/installer.php')) { // users module needs custom variables if ($module == 'users') { $variables['password'] = SpoonSession::get('password'); } // load installer file require_once PATH_WWW . '/backend/modules/' . $module . '/installer/installer.php'; // build installer class name $class = SpoonFilter::toCamelCase($module) . 'Installer'; // create installer $installer = new $class($this->db, SpoonSession::get('languages'), SpoonSession::get('interface_languages'), SpoonSession::get('example_data'), $variables); // install the module $installer->install(); // add the warnings $moduleWarnings = $installer->getWarnings(); if (!empty($moduleWarnings)) { $warnings[] = array('module' => $module, 'warnings' => $moduleWarnings); } // add the default extras $moduleDefaultExtras = $installer->getDefaultExtras(); if (!empty($moduleDefaultExtras)) { $defaultExtras = array_merge($defaultExtras, $moduleDefaultExtras); } } } // loop default extras foreach ($defaultExtras as $extra) { // get pages without this extra $revisionIds = $this->db->getColumn('SELECT i.revision_id FROM pages AS i WHERE i.revision_id NOT IN ( SELECT DISTINCT b.revision_id FROM pages_blocks AS b WHERE b.extra_id = ? GROUP BY b.revision_id )', array($extra['id'])); // build insert array for this extra $insertExtras = array(); foreach ($revisionIds as $revisionId) { $insertExtras[] = array('revision_id' => $revisionId, 'position' => $extra['position'], 'extra_id' => $extra['id'], 'created_on' => gmdate('Y-m-d H:i:s'), 'edited_on' => gmdate('Y-m-d H:i:s'), 'visible' => 'Y'); } // insert block $this->db->insert('pages_blocks', $insertExtras); } // parse the warnings $this->tpl->assign('warnings', $warnings); }