getName()); } return $results; } public function allowedThemeNames() { $results = []; $directoryIterator = new \FilesystemIterator(dirname(dirname(__DIR__)) . '/resources/views/themes', \FilesystemIterator::SKIP_DOTS); /** @var \SplFileInfo $fileInfo */ foreach ($directoryIterator as $fileInfo) { if (!$fileInfo->isDir() || strtolower($fileInfo->getFilename()) == 'base') { continue; } $themeName = strtolower($fileInfo->getFilename()); $themeDisplayName = $themeName; $themeInfoFilename = sprintf('%s/theme.json', $fileInfo->getPathname()); if (file_exists($themeInfoFilename)) { $themeInfo = json_decode(file_get_contents($themeInfoFilename)); if ($themeInfo !== false && isset($themeInfo->name)) { $themeDisplayName = $themeInfo->name; } } $results[$themeName] = $themeDisplayName; } return $results; } public function defaults() { $currentAppName = $this->get('app_name', false); return array( 'albums_menu_parents_only' => false, 'albums_menu_number_items' => 10, 'allow_photo_comments' => false, 'allow_photo_comments_anonymous' => true, 'allow_self_registration' => true, 'analysis_queue_storage_location' => Storage::where('is_default', true)->first()->id, 'analytics_code' => '', 'app_name' => trans('global.app_name'), 'date_format' => $this->allowedDateFormats()[0], 'default_album_view' => $this->allowedAlbumViews()[0], 'enable_visitor_hits' => false, 'facebook_external_service_id' => 0, 'google_external_service_id' => 0, 'hotlink_protection' => false, 'items_per_page' => 12, 'items_per_page_admin' => 10, 'moderate_anonymous_users' => true, 'moderate_known_users' => true, 'photo_comments_allowed_html' => 'p,div,span,a,b,i,u', 'photo_comments_thread_depth' => 3, 'public_statistics' => true, 'queue_emails' => false, 'rabbitmq_enabled' => false, 'rabbitmq_server' => 'localhost', 'rabbitmq_password' => encrypt('guest'), 'rabbitmq_port' => 5672, 'rabbitmq_queue' => 'blue_twilight', 'rabbitmq_username' => 'guest', 'rabbitmq_vhost' => '/', 'recaptcha_enabled_registration' => false, 'recaptcha_secret_key' => '', 'recaptcha_site_key' => '', 'remove_copyright' => false, 'require_email_verification' => true, 'restrict_original_download' => true, 'sender_address' => sprintf('hostmaster@%s', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost')), 'sender_name' => (is_null($currentAppName) ? trans('global.app_name') : $currentAppName), 'smtp_server' => 'localhost', 'smtp_password' => '', 'smtp_port' => 25, 'smtp_username' => '', 'social_facebook_login' => false, 'social_google_login' => false, 'social_twitter_login' => false, 'social_user_feeds' => false, 'social_user_profiles' => false, 'theme' => 'default', 'twitter_external_service_id' => 0 ); } public function get($key, $defaultIfUnset = true) { if (is_null($this->cache)) { $this->loadCache(); } $config = isset($this->cache[$key]) ? $this->cache[$key] : null; if (is_null($config)) { if ($defaultIfUnset) { $defaults = $this->defaults(); return (isset($defaults[$key]) ? $defaults[$key] : null); } return null; } return $config->value; } public function getAll() { $results = array(); /** @var Configuration $config */ foreach (Configuration::all() as $config) { $results[$config->key] = $config->value; } return $results; } public function getOrCreateModel($key) { $config = isset($this->cache[$key]) ? $this->cache[$key] : null; if (is_null($config) || $config === false) { $config = new Configuration(); $config->key = $key; $config->value = ''; $config->save(); $this->loadCache(); } return $config; } public function isImageProcessingQueueEnabled() { return $this->get('rabbitmq_enabled') && !empty($this->get('rabbitmq_server')) && !empty($this->get('rabbitmq_port')) && !empty($this->get('rabbitmq_username')) && !empty($this->get('rabbitmq_password')) && !empty($this->get('rabbitmq_queue')) && !empty($this->get('rabbitmq_vhost')); } public function isLoginWithFacebookEnabled() { return boolval($this->get('social_facebook_login')) && intval($this->get('facebook_external_service_id')) > 0; } public function isLoginWithGoogleEnabled() { return boolval($this->get('social_google_login')) && intval($this->get('google_external_service_id')) > 0; } public function isLoginWithTwitterEnabled() { return boolval($this->get('social_twitter_login')) && intval($this->get('twitter_external_service_id')) > 0; } public function isSocialMediaLoginEnabled() { return $this->isLoginWithFacebookEnabled() || $this->isLoginWithGoogleEnabled() || $this->isLoginWithTwitterEnabled(); } private function loadCache() { $this->cache = null; /** @var Configuration $config */ foreach (Configuration::all() as $config) { $this->cache[$config->key] = $config; } } }