Example #1
0
 /**
  * Display the main page
  */
 public function index()
 {
     $filters = $this->getFilters();
     $this->addKeysToJavaScript("language.confirm-delete-lang", "language.confirm-delete-key");
     $this->addJavaScript(Plugin::current()->getJsUrl('languages.js'));
     return LeftSidebarTab::make(array('icon' => 'flag', 'title' => Lang::get('language.lang-page-name'), 'page' => array('content' => $this->editKeys()), 'sidebar' => array('widgets' => array(LanguageFilterWidget::getInstance($filters), NewLanguageKeyWidget::getInstance())), 'tabId' => 'language-manage-page'));
 }
Example #2
0
 /**
  * Search themes on the remote platform
  */
 public function search()
 {
     $api = new HawkApi();
     $search = App::request()->getParams('search');
     // Search themes on the API
     try {
         $themes = $api->searchThemes($search);
     } catch (\Hawk\HawkApiException $e) {
         $themes = array();
     }
     // Remove the plugins already downloaded on the application
     foreach ($themes as &$theme) {
         $installed = Theme::get($theme['name']);
         $theme['installed'] = $installed !== null;
         if ($installed) {
             $theme['currentVersion'] = $installed->getDefinition('version');
         }
     }
     $list = new ItemList(array('id' => 'search-themes-list', 'data' => $themes, 'resultTpl' => Plugin::current()->getView('theme-search-list.tpl'), 'fields' => array()));
     if ($list->isRefreshing()) {
         return $list->display();
     } else {
         $this->addCss(Plugin::current()->getCssUrl('themes.less'));
         $this->addJavaScript(Plugin::current()->getJsUrl('themes.js'));
         return LeftSidebarTab::make(array('page' => array('content' => $list->display()), 'sidebar' => array('widgets' => array(new SearchThemeWidget())), 'icon' => 'picture-o', 'title' => Lang::get($this->_plugin . '.search-theme-result-title', array('search' => $search))));
     }
 }
Example #3
0
 /**
  * Display the details page of the plugin
  */
 public function details()
 {
     $plugin = Plugin::get($this->plugin);
     if (is_file($plugin->getReadmeFile())) {
         $mdParser = new Parsedown();
         $md = View::make($plugin->getReadmeFile());
         // Replace img sources
         $md = preg_replace_callback("#\\!\\[(.*?)\\]\\((.+?)( .+)?\\)#", function ($matches) use($plugin) {
             $alt = $matches[1];
             $src = $matches[2];
             $attributes = empty($matches[3]) ? '' : $matches[3];
             if (substr($src, 0, 4) !== 'http' && substr($src, 0, 2) !== '//') {
                 $src = $plugin->getImgUrl('readme/' . $src);
             }
             return '![' . $alt . '](' . $src . $attributes . ')';
         }, $md);
         $plugin->readme = $mdParser->text($md);
         // $plugin->readme = View::makeFromString($plugin->readme);
     } else {
         $plugin->readme = '';
     }
     $pageContent = View::make($this->getPlugin()->getView('plugin-details-page.tpl'), array('plugin' => $plugin));
     $this->addJavaScript($this->getPlugin()->getJsUrl('plugins.js'));
     $this->addCss($this->getPlugin()->getCssUrl('plugins.less'));
     return LeftSidebarTab::make(array('tabId' => 'plugin-details-page', 'icon' => $plugin->getFaviconUrl() ? $plugin->getFaviconUrl() : 'plug', 'title' => $plugin->getDefinition('title'), 'sidebar' => array('widgets' => array(PluginActionsWidget::getInstance(array('plugin' => $plugin)))), 'page' => array('content' => $pageContent)));
 }