public function listTypes() { static $result; if (is_array($result)) { return $result; } $extensions = ExtensionManager::listInstalledHandles(); if (!is_array($extensions) || empty($extensions)) { return array(); } $result = array(); foreach ($extensions as $e) { $path = EXTENSIONS . "/{$e}/template"; if (!is_dir($path)) { continue; } $structure = General::listStructure($path, '/^formatter.[\\w-]+.tpl$/', false, 'ASC', $path); if (is_array($structure['filelist']) && !empty($structure['filelist'])) { foreach ($structure['filelist'] as $t) { $type = preg_replace(array('/^formatter./i', '/.tpl$/i'), '', $t); $result[$type] = array('path' => $path); } } } return $result; }
private function __indexPage() { // Create the XML for the page: $xml = new XMLElement('data'); $sectionsNode = new XMLElement('sections'); $sm = new SectionManager($this); $sections = $sm->fetch(); foreach ($sections as $section) { $sectionsNode->appendChild(new XMLElement('section', $section->get('name'), array('id' => $section->get('id')))); } $xml->appendChild($sectionsNode); // Check if the multilingual-field extension is installed: if (in_array('multilingual_field', ExtensionManager::listInstalledHandles())) { $xml->setAttribute('multilanguage', 'yes'); // Get all the multilanguage fields: $fm = new FieldManager($this); $fields = $fm->fetch(null, null, 'ASC', 'sortorder', 'multilingual'); $multilanguage = new XMLElement('multilanguage'); foreach ($fields as $field) { $sectionID = $field->get('parent_section'); $section = $sm->fetch($sectionID); $id = $field->get('id'); $label = $section->get('name') . ' : ' . $field->get('label'); $multilanguage->appendChild(new XMLElement('field', $label, array('id' => $id))); } $xml->appendChild($multilanguage); } // Generate the HTML: $xslt = new XSLTPage(); $xslt->setXML($xml->generate()); $xslt->setXSL(EXTENSIONS . '/importcsv/content/index.xsl', true); $this->Form->setValue($xslt->generate()); $this->Form->setAttribute('enctype', 'multipart/form-data'); }
function listAll() { $result = array(); $people = array(); $structure = General::listStructure(TEXTFORMATTERS, '/formatter.[\\w-]+.php/', false, 'ASC', TEXTFORMATTERS); if (is_array($structure['filelist']) && !empty($structure['filelist'])) { foreach ($structure['filelist'] as $f) { $f = str_replace(array('formatter.', '.php'), '', $f); $result[$f] = $this->about($f); } } $extensionManager = new ExtensionManager($this->_Parent); $extensions = $extensionManager->listInstalledHandles(); if (is_array($extensions) && !empty($extensions)) { foreach ($extensions as $e) { if (!is_dir(EXTENSIONS . "/{$e}/text-formatters")) { continue; } $tmp = General::listStructure(EXTENSIONS . "/{$e}/text-formatters", '/formatter.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/text-formatters"); if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) { foreach ($tmp['filelist'] as $f) { $f = preg_replace(array('/^formatter./i', '/.php$/i'), '', $f); $result[$f] = $this->about($f); } } } } ksort($result); return $result; }
function listAll() { $result = array(); $people = array(); $structure = General::listStructure(EVENTS, '/event.[\\w-]+.php/', false, 'ASC', EVENTS); if (is_array($structure['filelist']) && !empty($structure['filelist'])) { foreach ($structure['filelist'] as $f) { $f = self::__getHandleFromFilename($f); //preg_replace(array('/^event./i', '/.php$/i'), '', $f); if ($about = $this->about($f)) { $classname = $this->__getClassName($f); $path = $this->__getDriverPath($f); $can_parse = false; $type = NULL; if (is_callable(array($classname, 'allowEditorToParse'))) { $can_parse = @call_user_func(array(&$classname, 'allowEditorToParse')); } if (is_callable(array($classname, 'getType'))) { $type = @call_user_func(array(&$classname, 'getType')); } $about['can_parse'] = $can_parse; $about['type'] = $type; $result[$f] = $about; } } } //$structure = General::listStructure(EXTENSIONS, array(), false, 'ASC', EXTENSIONS); //$extensions = $structure['dirlist']; $extensionManager = new ExtensionManager($this->_Parent); $extensions = $extensionManager->listInstalledHandles(); if (is_array($extensions) && !empty($extensions)) { foreach ($extensions as $e) { if (!is_dir(EXTENSIONS . "/{$e}/events")) { continue; } $tmp = General::listStructure(EXTENSIONS . "/{$e}/events", '/event.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/events"); if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) { foreach ($tmp['filelist'] as $f) { $f = $f = self::__getHandleFromFilename($f); if ($about = $this->about($f)) { $classname = $this->__getClassName($f); $can_parse = false; $type = NULL; $about['can_parse'] = $can_parse; $about['type'] = $type; $result[$f] = $about; } } } } } ksort($result); return $result; }
function __find($type) { if (@is_file(TOOLKIT . "/fields/field.{$type}.php")) { return TOOLKIT . '/fields'; } else { $extensionManager = new ExtensionManager($this->_Parent); $extensions = $extensionManager->listInstalledHandles(); if (is_array($extensions) && !empty($extensions)) { foreach ($extensions as $e) { if (@is_file(EXTENSIONS . "/{$e}/fields/field.{$type}.php")) { return EXTENSIONS . "/{$e}/fields"; } } } } return false; }
private static function __install() { $fields = $_POST['fields']; $start = time(); Symphony::Log()->writeToLog(PHP_EOL . '============================================', true); Symphony::Log()->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true); Symphony::Log()->writeToLog('============================================', true); // MySQL: Establishing connection Symphony::Log()->pushToLog('MYSQL: Establishing Connection', E_NOTICE, true, true); try { Symphony::Database()->connect($fields['database']['host'], $fields['database']['user'], $fields['database']['password'], $fields['database']['port'], $fields['database']['db']); } catch (DatabaseException $e) { self::__abort('There was a problem while trying to establish a connection to the MySQL server. Please check your settings.', $start); } // MySQL: Setting prefix & character encoding Symphony::Database()->setPrefix($fields['database']['tbl_prefix']); Symphony::Database()->setCharacterEncoding(); Symphony::Database()->setCharacterSet(); // MySQL: Importing schema Symphony::Log()->pushToLog('MYSQL: Importing Table Schema', E_NOTICE, true, true); try { Symphony::Database()->import(file_get_contents(INSTALL . '/includes/install.sql'), true); } catch (DatabaseException $e) { self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start); } // MySQL: Creating default author Symphony::Log()->pushToLog('MYSQL: Creating Default Author', E_NOTICE, true, true); try { Symphony::Database()->insert(array('id' => 1, 'username' => Symphony::Database()->cleanValue($fields['user']['username']), 'password' => Cryptography::hash(Symphony::Database()->cleanValue($fields['user']['password'])), 'first_name' => Symphony::Database()->cleanValue($fields['user']['firstname']), 'last_name' => Symphony::Database()->cleanValue($fields['user']['lastname']), 'email' => Symphony::Database()->cleanValue($fields['user']['email']), 'last_seen' => NULL, 'user_type' => 'developer', 'primary' => 'yes', 'default_area' => NULL, 'auth_token_active' => 'no'), 'tbl_authors'); } catch (DatabaseException $e) { self::__abort('There was an error while trying create the default author. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start); } // Configuration: Populating array $conf = Symphony::Configuration()->get(); foreach ($conf as $group => $settings) { foreach ($settings as $key => $value) { if (isset($fields[$group]) && isset($fields[$group][$key])) { $conf[$group][$key] = $fields[$group][$key]; } } } // Create manifest folder structure Symphony::Log()->pushToLog('WRITING: Creating ‘manifest’ folder (/manifest)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/manifest', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘manifest’ directory. Check permission on the root folder.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘logs’ folder (/manifest/logs)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/manifest/logs', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘logs’ directory. Check permission on /manifest.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘cache’ folder (/manifest/cache)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/manifest/cache', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘cache’ directory. Check permission on /manifest.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘tmp’ folder (/manifest/tmp)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/manifest/tmp', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘tmp’ directory. Check permission on /manifest.', $start); } // Writing configuration file Symphony::Log()->pushToLog('WRITING: Configuration File', E_NOTICE, true, true); Symphony::Configuration()->setArray($conf); if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) { self::__abort('Could not create config file ‘' . CONFIG . '’. Check permission on /manifest.', $start); } // Writing htaccess file Symphony::Log()->pushToLog('CONFIGURING: Frontend', E_NOTICE, true, true); $rewrite_base = ltrim(preg_replace('/\\/install$/i', NULL, dirname($_SERVER['PHP_SELF'])), '/'); $htaccess = str_replace('<!-- REWRITE_BASE -->', $rewrite_base, file_get_contents(INSTALL . '/includes/htaccess.txt')); if (!General::writeFile(DOCROOT . "/.htaccess", $htaccess, $conf['file']['write_mode'], 'a')) { self::__abort('Could not write ‘.htaccess’ file. Check permission on ' . DOCROOT, $start); } // Writing /workspace folder if (!is_dir(DOCROOT . '/workspace')) { // Create workspace folder structure Symphony::Log()->pushToLog('WRITING: Creating ‘workspace’ folder (/workspace)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/workspace', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘workspace’ directory. Check permission on the root folder.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘data-sources’ folder (/workspace/data-sources)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/workspace/data-sources', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘workspace/data-sources’ directory. Check permission on the root folder.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘events’ folder (/workspace/events)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/workspace/events', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘workspace/events’ directory. Check permission on the root folder.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘pages’ folder (/workspace/pages)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/workspace/pages', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘workspace/pages’ directory. Check permission on the root folder.', $start); } Symphony::Log()->pushToLog('WRITING: Creating ‘utilities’ folder (/workspace/utilities)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/workspace/utilities', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘workspace/utilities’ directory. Check permission on the root folder.', $start); } } else { Symphony::Log()->pushToLog('An existing ‘workspace’ directory was found at this location. Symphony will use this workspace.', E_NOTICE, true, true); // MySQL: Importing workspace data Symphony::Log()->pushToLog('MYSQL: Importing Workspace Data...', E_NOTICE, true, true); if (is_file(DOCROOT . '/workspace/install.sql')) { try { Symphony::Database()->import(file_get_contents(DOCROOT . '/workspace/install.sql'), $fields['database']['use-server-encoding'] != 'yes' ? true : false, true); } catch (DatabaseException $e) { self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start); } } } // Write extensions folder if (!is_dir(DOCROOT . '/extensions')) { // Create extensions folder Symphony::Log()->pushToLog('WRITING: Creating ‘extensions’ folder (/extensions)', E_NOTICE, true, true); if (!General::realiseDirectory(DOCROOT . '/extensions', $conf['directory']['write_mode'])) { self::__abort('Could not create ‘extension’ directory. Check permission on the root folder.', $start); } } // Install existing extensions Symphony::Log()->pushToLog('CONFIGURING: Installing existing extensions', E_NOTICE, true, true); $disabled_extensions = array(); foreach (new DirectoryIterator(EXTENSIONS) as $e) { if ($e->isDot() || $e->isFile() || !is_file($e->getRealPath() . '/extension.driver.php')) { continue; } $handle = $e->getBasename(); try { if (!ExtensionManager::enable($handle)) { $disabled_extensions[] = $handle; Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’.', E_NOTICE, true, true); } } catch (Exception $ex) { $disabled_extensions[] = $handle; Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’. ' . $ex->getMessage(), E_NOTICE, true, true); } } // Loading default language if (isset($_REQUEST['lang']) && $_REQUEST['lang'] != 'en') { Symphony::Log()->pushToLog('CONFIGURING: Default language', E_NOTICE, true, true); $language = Lang::Languages(); $language = $language[$_REQUEST['lang']]; // Is the language extension enabled? if (in_array('lang_' . $language['handle'], ExtensionManager::listInstalledHandles())) { Symphony::Configuration()->set('lang', $_REQUEST['lang'], 'symphony'); if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) { Symphony::Log()->pushToLog('Could not write default language ‘' . $language['name'] . '’ to config file.', E_NOTICE, true, true); } } else { Symphony::Log()->pushToLog('Could not enable the desired language ‘' . $language['name'] . '’.', E_NOTICE, true, true); } } // Installation completed. Woo-hoo! Symphony::Log()->writeToLog('============================================', true); Symphony::Log()->writeToLog(sprintf('INSTALLATION COMPLETED: Execution Time - %d sec (%s)', max(1, time() - $start), date('d.m.y H:i:s')), true); Symphony::Log()->writeToLog('============================================' . PHP_EOL . PHP_EOL . PHP_EOL, true); return $disabled_extensions; }