Пример #1
0
 /**
  * Provides the full id of the resource, this id will be full path of the requesting layer components
  * separated by ':'.
  *
  * @return string
  *		The full id of the resource.
  */
 public function getFullId()
 {
     if ($this->parent != NULL) {
         return $this->parent->getFullId() . ':' . $this->id;
     }
     return $this->id;
 }
Пример #2
0
 /**
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $resourceId = new \Newscoop\Service\Resource\ResourceId(__CLASS__);
     $themeService = $resourceId->getService(IThemeManagementService::NAME_1);
     $publicationService = $this->getContainer()->getService('content.publication');
     $publications = $publicationService->findAll();
     $themeToSet = (string) $input->getArgument('theme');
     if ($themeToSet != null) {
         foreach ($themeService->getUnassignedThemes() as $theme) {
             if (strpos($theme->getPath(), $themeToSet) !== false) {
                 foreach ($publications as $publication) {
                     $themeService->assignTheme($theme, $publication, true);
                 }
             }
         }
     } else {
         foreach ($themeService->getUnassignedThemes() as $theme) {
             foreach ($publications as $publication) {
                 $themeService->assignTheme($theme, $publication, true);
             }
         }
     }
 }
Пример #3
0
 /**
  *
  */
 private function loadDemoSite()
 {
     global $g_db;
     $session = CampSession::singleton();
     $template_name = $session->getData('config.demo', 'installation');
     $isWritable = true;
     $directories = array();
     $templatesDir = CS_PATH_TEMPLATES;
     $cssDir = $templatesDir . DIR_SEP . 'css';
     $imagesDir = $templatesDir . DIR_SEP . 'img';
     if (!is_dir($templatesDir) || !is_writable($templatesDir)) {
         $directories[] = $templatesDir;
         $isWritable = false;
     }
     if (!is_dir($cssDir) && !mkdir($cssDir) || !is_writable($cssDir)) {
         $directories[] = $cssDir;
         $isWritable = false;
     }
     if (!is_dir($imagesDir) && !mkdir($imagesDir) || !is_writable($imagesDir)) {
         $directories[] = $imagesDir;
         $isWritable = false;
     }
     if (!$isWritable) {
         $dirList = implode('<br />', $directories);
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Templates directories' . '<div class="nonwritable"><em>' . $dirList . '</font></em></div>' . 'are not writable, please set the appropiate ' . 'permissions in order to install the demo site files.';
         return false;
     }
     require_once $GLOBALS['g_campsiteDir'] . '/bin/cli_script_lib.php';
     if (is_dir(CS_PATH_TEMPLATES . DIR_SEP . ThemeManagementServiceLocal::FOLDER_UNASSIGNED)) {
         CampInstallationBaseHelper::CopyFiles(CS_PATH_TEMPLATES . DIR_SEP . ThemeManagementServiceLocal::FOLDER_UNASSIGNED, CS_INSTALL_DIR . DIR_SEP . 'temp');
     }
     camp_remove_dir(CS_PATH_TEMPLATES . DIR_SEP . '*', null, array('system_templates'));
     // copies template files to corresponding directory
     $source = CS_INSTALL_DIR . DIR_SEP . 'sample_templates' . DIR_SEP . $template_name['loaddemo'] . DIR_SEP . 'templates';
     $target = CS_PATH_TEMPLATES . DIR_SEP . ThemeManagementServiceLocal::FOLDER_UNASSIGNED;
     if (CampInstallationBaseHelper::CopyFiles($source, $target) == false) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Copying sample site files';
         return false;
     }
     // copies template data files to corresponding directories.
     // data files are article images and article attachments
     $source = CS_INSTALL_DIR . DIR_SEP . 'sample_data';
     $target = CS_PATH_SITE;
     if (CampInstallationBaseHelper::CopyFiles($source, $target) == false) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Copying sample site data files';
         die('failed');
         return false;
     }
     if (CampInstallationBaseHelper::ConnectDB() == false) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Database parameters invalid. Could not ' . 'connect to database server.';
         return false;
     }
     $sqlFile = CS_INSTALL_DIR . DIR_SEP . 'sql' . DIR_SEP . 'campsite_demo_tables.sql';
     $errors = CampInstallationBaseHelper::ImportDB($sqlFile, $errorQueries);
     if ($errors > 0) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Importing Database: demo tables';
         foreach ($errorQueries as $query) {
             $this->m_message .= "<br>{$query}";
         }
         return false;
     }
     $sqlFile = CS_INSTALL_DIR . DIR_SEP . 'sql' . DIR_SEP . 'campsite_demo_prepare.sql';
     $errors = CampInstallationBaseHelper::ImportDB($sqlFile, $errorQueries);
     if ($errors > 0) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Importing Database: demo prepare file';
         foreach ($errorQueries as $query) {
             $this->m_message .= "<br>{$query}";
         }
         return false;
     }
     $sqlFile = CS_INSTALL_DIR . DIR_SEP . 'sql' . DIR_SEP . 'campsite_demo_data.sql';
     $errors = CampInstallationBaseHelper::ImportDB($sqlFile, $errorQueries);
     if ($errors > 0) {
         $this->m_step = 'loaddemo';
         $this->m_message = 'Error: Importing Database: demo data';
         foreach ($errorQueries as $query) {
             $this->m_message .= "<br>{$query}";
         }
         return false;
     }
     // add session db settings into global Campsite
     $keyMap = array('DATABASE_SERVER_ADDRESS' => 'hostname', 'DATABASE_NAME' => 'database', 'DATABASE_USER' => 'username', 'DATABASE_PASSWORD' => 'userpass');
     if (!isset($GLOBALS['Campsite'])) {
         $GLOBALS['Campsite'] = array();
     }
     foreach ($keyMap as $globalKey => $sessionKey) {
         $GLOBALS['Campsite'][$globalKey] = $_SESSION['installation']['config.db'][$sessionKey];
     }
     // bootstrap doctrine
     $GLOBALS['application']->bootstrap('container');
     $resourceId = new Newscoop\Service\Resource\ResourceId(__CLASS__);
     $themeService = $resourceId->getService(IThemeManagementService::NAME_1);
     $publicationService = $resourceId->getService(IPublicationService::NAME);
     foreach ($themeService->getUnassignedThemes() as $theme) {
         foreach ($publicationService->getEntities() as $publication) {
             $themeService->assignTheme($theme, $publication);
         }
     }
     if (is_dir(CS_INSTALL_DIR . DIR_SEP . 'temp')) {
         CampInstallationBaseHelper::CopyFiles(CS_INSTALL_DIR . DIR_SEP . 'temp', CS_PATH_TEMPLATES . DIR_SEP . ThemeManagementServiceLocal::FOLDER_UNASSIGNED);
         camp_remove_dir(CS_INSTALL_DIR . DIR_SEP . 'temp');
     }
     return true;
 }