Ejemplo n.º 1
0
 /**
  * Flags a theme as being uninstalled.
  * @param string $name Theme code
  */
 public function setUninstalled($code)
 {
     $history = Parameters::get('system::theme.history', []);
     if (array_key_exists($code, $history)) {
         unset($history[$code]);
     }
     Parameters::set('system::theme.history', $history);
 }
Ejemplo n.º 2
0
 /**
  * Internal helper, attaches a build code to an asset path
  * @param  array $asset Stored asset array
  * @return string
  */
 protected function getAssetEntryBuildPath($asset)
 {
     $path = $asset['path'];
     if (isset($asset['attributes']['build'])) {
         $build = $asset['attributes']['build'];
         if ($build == 'core') {
             $build = 'v' . Parameters::get('system::core.build', 1);
         } elseif ($pluginVersion = PluginVersion::getVersion($build)) {
             $build = 'v' . $pluginVersion;
         }
         $path .= '?' . $build;
     }
     return $path;
 }
Ejemplo n.º 3
0
 public function onDetachProject()
 {
     Parameters::set(['system::project.id' => null, 'system::project.name' => null, 'system::project.owner' => null]);
     Flash::success(Lang::get('system::lang.project.unbind_success'));
     return Redirect::to(Backend::url('system/updates'));
 }
Ejemplo n.º 4
0
 /**
  * Sets the active theme.
  * The active theme code is stored in the database and overrides the configuration cms.activeTheme parameter. 
  * @param string $code Specifies the  active theme code.
  */
 public static function setActiveTheme($code)
 {
     $paramKey = 'cms::theme.active';
     Parameters::set($paramKey, $code);
     Cache::forget($paramKey);
 }
Ejemplo n.º 5
0
 /**
  * Sets the active theme.
  * The active theme code is stored in the database and overrides the configuration cms.activeTheme parameter. 
  * @param string $code Specifies the  active theme code.
  */
 public static function setActiveTheme($code)
 {
     self::resetCache();
     Parameters::set(self::ACTIVE_KEY, $code);
 }
Ejemplo n.º 6
0
 /**
  * Downloads a file from the update server.
  * @param  string $uri          Gateway API URI
  * @param  string $fileCode     A unique code for saving the file.
  * @param  string $expectedHash The expected file hash of the file.
  * @param  array  $postData     Extra post data
  * @return void
  */
 public function requestServerFile($uri, $fileCode, $expectedHash, $postData = [])
 {
     $filePath = $this->getFilePath($fileCode);
     if ($projectId = Parameters::get('system::project.id')) {
         $postData['project'] = $projectId;
     }
     $result = Http::post($this->createServerUrl($uri), function ($http) use($postData, $filePath) {
         $this->applyHttpAttributes($http, $postData);
         $http->toFile($filePath);
     });
     if ($result->code != 200) {
         throw new ApplicationException(File::get($filePath));
     }
     if (md5_file($filePath) != $expectedHash) {
         @unlink($filePath);
         throw new ApplicationException(Lang::get('system::lang.server.file_corrupt'));
     }
 }
Ejemplo n.º 7
0
 protected function getInstalledThemes()
 {
     $history = Parameters::get('system::theme.history', []);
     $manager = UpdateManager::instance();
     $installed = $manager->requestProductDetails(array_keys($history), 'theme');
     /*
      * Splice in the directory names
      */
     foreach ($installed as $key => $data) {
         $code = array_get($data, 'code');
         $installed[$key]['dirName'] = array_get($history, $code, $code);
     }
     return $installed;
 }
 /**
  * @see RainLab\Blog\Components\Posts::defineProperties()
  * @return array
  */
 public function defineProperties()
 {
     // check build to add fallback to not supported inspector types if needed
     $hasNewInspector = Parameters::get('system::core.build') >= 306;
     return ['searchTerm' => ['title' => 'Search Term', 'description' => 'The value to determine what the user is searching for.', 'type' => 'string', 'default' => '{{ :search }}'], 'pageNumber' => ['title' => 'rainlab.blog::lang.settings.posts_pagination', 'description' => 'rainlab.blog::lang.settings.posts_pagination_description', 'type' => 'string', 'default' => '{{ :page }}'], 'hightlight' => ['title' => 'Hightlight Matches', 'type' => 'checkbox', 'default' => false, 'showExternalParam' => false], 'postsPerPage' => ['title' => 'rainlab.blog::lang.settings.posts_per_page', 'type' => 'string', 'validationPattern' => '^[0-9]+$', 'validationMessage' => 'rainlab.blog::lang.settings.posts_per_page_validation', 'default' => '10'], 'noPostsMessage' => ['title' => 'rainlab.blog::lang.settings.posts_no_posts', 'description' => 'rainlab.blog::lang.settings.posts_no_posts_description', 'type' => 'string', 'default' => 'No posts found', 'showExternalParam' => false], 'sortOrder' => ['title' => 'rainlab.blog::lang.settings.posts_order', 'description' => 'rainlab.blog::lang.settings.posts_order_description', 'type' => 'dropdown', 'default' => 'published_at desc'], 'excludeCategories' => ['title' => 'Exclude Categories', 'description' => 'Posts with selected categories are excluded from the search result', 'type' => $hasNewInspector ? 'set' : 'dropdown'], 'categoryPage' => ['title' => 'rainlab.blog::lang.settings.posts_category', 'description' => 'rainlab.blog::lang.settings.posts_category_description', 'type' => 'dropdown', 'default' => 'blog/category', 'group' => 'Links'], 'postPage' => ['title' => 'rainlab.blog::lang.settings.posts_post', 'description' => 'rainlab.blog::lang.settings.posts_post_description', 'type' => 'dropdown', 'default' => 'blog/post', 'group' => 'Links']];
 }
Ejemplo n.º 9
0
 /**
  * Sets the active theme.
  * The active theme code is stored in the database and overrides the configuration cms.activeTheme parameter. 
  * @param string $code Specifies the  active theme code.
  */
 public static function setActiveTheme($code)
 {
     self::$activeThemeCache = false;
     self::$editThemeCache = false;
     $paramKey = 'cms::theme.active';
     Parameters::set($paramKey, $code);
     Cache::forget($paramKey);
 }
 /**
  * Returns the active theme.
  * By default the active theme is loaded from the cms.activeTheme parameter,
  * but this behavior can be overridden by the cms.activeTheme event listeners.
  * @return \Cms\Classes\Theme Returns the loaded theme object.
  * If the theme doesn't exist, returns null.
  */
 public static function getActiveTheme()
 {
     if (self::$activeThemeCache !== false) {
         return self::$activeThemeCache;
     }
     $activeTheme = Config::get('cms.activeTheme');
     if (DbDongle::hasDatabase()) {
         $dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function () {
             return Parameters::applyKey(self::ACTIVE_KEY)->pluck('value');
         });
         if ($dbResult !== null && static::exists($dbResult)) {
             $activeTheme = $dbResult;
         }
     }
     $apiResult = Event::fire('cms.activeTheme', [], true);
     if ($apiResult !== null) {
         $activeTheme = $apiResult;
     }
     if (!strlen($activeTheme)) {
         throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));
     }
     $theme = static::load($activeTheme);
     if (!File::isDirectory($theme->getPath())) {
         return self::$activeThemeCache = null;
     }
     return self::$activeThemeCache = $theme;
 }
Ejemplo n.º 11
0
 protected function loadBuildNum()
 {
     $this->build = Parameters::get('system::core.build');
 }
 /**
  * Extracts the core after it has been downloaded.
  * @param string $hash
  * @param string $build
  * @return void
  */
 public function extractCore($hash, $build)
 {
     $filePath = $this->getFilePath('core');
     if (!Zip::extract($filePath, $this->baseDirectory)) {
         throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
     }
     @unlink($filePath);
     // Database may fall asleep after this long process
     Db::reconnect();
     Parameters::set(['system::core.hash' => $hash, 'system::core.build' => $build]);
 }