PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/applications/noviusos_appmanager/views/admin/app_manager.view.php

https://github.com/jay3/core
PHP | 273 lines | 241 code | 23 blank | 9 comment | 22 complexity | 0620a5c8501e9604357062a370b01a86 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * NOVIUS OS - Web OS for digital communication
  4. *
  5. * @copyright 2011 Novius
  6. * @license GNU Affero General Public License v3 or (at your option) any later version
  7. * http://www.gnu.org/licenses/agpl-3.0.html
  8. * @link http://www.novius-os.org
  9. */
  10. Nos\I18n::current_dictionary('noviusos_appmanager::common');
  11. ?>
  12. <div class="page line ui-widget app_manager" id="<?= $uniqid = uniqid('id_'); ?>">
  13. <style type="text/css">
  14. .app_manager p {
  15. margin: 0.5em 0 0;
  16. }
  17. .app_manager .line {
  18. margin: 1em 0 2em;
  19. }
  20. .app_manager h1 {
  21. margin-bottom: 0.5em;
  22. }
  23. .app_manager .app_list_available {
  24. width : 600px;
  25. }
  26. .app_manager label.tooltip {
  27. font-weight: bold;
  28. }
  29. .app_manager tr {
  30. height: 32px;
  31. }
  32. </style>
  33. <div class="col c1"></div>
  34. <div class="col c10" style="position:relative;">
  35. <div class="line native_apps">
  36. <h1 class="title"><?= __('Native applications'); ?></h1>
  37. <p>
  38. <?php
  39. if (\Nos\Application::areNativeApplicationsDirty()) {
  40. echo __('It appears you’ve made some recent changes.').' <a href="#" data-app="'.htmlspecialchars(\Format::forge(array('name' => 'nos', 'action' => 'add'))->to_json()).'" onclick="return false;"><button data-icon="wrench">'.__('Apply changes').'</button></a>';
  41. } else {
  42. echo __('All applications up-to-date.');
  43. }
  44. ?>
  45. </p>
  46. </div>
  47. <div class="line app_list_installed">
  48. <h1 class="title"><?= __('Installed applications'); ?></h1>
  49. <table>
  50. <tbody>
  51. <?php
  52. foreach ($installed as $app) {
  53. $metadata = $app->metadata;
  54. ?>
  55. <tr>
  56. <td>&nbsp;<img src="<?= isset($metadata['icons'][16]) ? $metadata['icons'][16] : 'static/novius-os/admin/novius-os/img/16/application.png' ?>" style="vertical-align:top;" alt="" title="" /> <?= e(Nos\Config_Data::get('app_installed.'.$app->folder.'.name', $app->name)); ?></td>
  57. <td>
  58. <?php
  59. if ($app->is_dirty()) {
  60. ?>
  61. <?= __('Some recent changes') ?>
  62. <a href="#" data-app="<?= htmlspecialchars(\Format::forge(array('name' => $app->folder, 'action' => 'add'))->to_json()) ?>" onclick="return false;"><button data-icon="wrench"><?= __('Apply changes') ?></button></a>
  63. <?php
  64. } else {
  65. echo __('Up-to-date');
  66. }
  67. ?>
  68. </td>
  69. <td>
  70. <?php
  71. if ($app->canUninstall()) {
  72. ?>
  73. <a href="#" data-app="<?= htmlspecialchars(\Format::forge(array('name' => $app->folder, 'action' => 'remove'))->to_json()) ?>" onclick="return false;"><button data-icon="arrowthick-1-s"><?= __('Uninstall') ?></button></a>
  74. <?php
  75. } else {
  76. $dependents = $app->installedDependentApplications();
  77. foreach ($dependents as &$dependent) {
  78. $dependent = \Nos\Application::forge($dependent)->get_name();
  79. }
  80. unset($dependent);
  81. if (count($dependents) == 1) {
  82. echo strtr(__('Cannot be uninstalled. Uninstall ‘{{application}}’ first.'), array('{{application}}' => $dependents[0]));
  83. } else {
  84. echo preg_replace('`<a>(.*)</a>`',
  85. render('noviusos_appmanager::admin/applications_tooltip', array('app_folder' => $app->folder, 'applications' => $dependents), true),
  86. __('Cannot be uninstalled. Uninstall <a>these applications</a> first.')
  87. );
  88. }
  89. }
  90. ?>
  91. </td>
  92. </tr>
  93. <?php
  94. }
  95. ?>
  96. </tbody>
  97. </table>
  98. <?php
  99. if (empty($installed)) {
  100. ?>
  101. <em><?php echo __('No applications found.') ?>.</em>
  102. <?php
  103. }
  104. ?>
  105. </div>
  106. <div class="line app_list_available">
  107. <h1 class="title"><?= __('Available applications'); ?></h1>
  108. <table>
  109. <tbody>
  110. <?php
  111. foreach ($others as $app) {
  112. $metadata = $app->getRealMetadata();
  113. $can_install = $app->canInstall();
  114. ?>
  115. <tr>
  116. <td><?= e($app->get_name_translated()) ?> </td>
  117. <td>
  118. <?php
  119. if (empty($metadata)) {
  120. ?>
  121. <em><?php echo __('No metadata found') ?>.</em>
  122. <?php
  123. } else if ($can_install) {
  124. ?>
  125. <a href="#" data-app="<?= htmlspecialchars(\Format::forge(array('name' => $app->folder, 'action' => 'add'))->to_json()) ?>" onclick="return false;"><button data-icon="arrowthick-1-n"><?= __('Install') ?></button></a></td>
  126. <?php
  127. } else {
  128. // @note: we can't get application names here since they don't exist therefore there aren't any metadata
  129. $unavailable_applications = $app->applicationsRequiredAndUnavailable();
  130. if (count($unavailable_applications) == 1) {
  131. echo strtr(__('Cannot be installed. Install ‘{{application}}’ first.'), array('{{application}}' => $unavailable_applications[0]));
  132. } else {
  133. echo preg_replace('`<a>(.*)</a>`',
  134. render('noviusos_appmanager::admin/applications_tooltip', array('app_folder' => $app->folder, 'applications' => $unavailable_applications), true),
  135. __('Cannot be installed. Install <a>these applications</a> first.')
  136. );
  137. }
  138. }
  139. ?>
  140. </tr>
  141. <?php
  142. }
  143. ?>
  144. </tbody>
  145. </table>
  146. <?php
  147. if (empty($others)) {
  148. ?>
  149. <em><?= __('No applications found.') ?></em>
  150. <?php
  151. }
  152. ?>
  153. </div>
  154. <div class="line" style="overflow:visible;">
  155. <h1 class="title"><?= __('Website configuration'); ?></h1>
  156. <p>
  157. <?php
  158. if ($local->is_dirty()) {
  159. echo __('It appears you’ve made some recent changes.').' <a href="#" data-app="'.htmlspecialchars(\Format::forge(array('name' => 'local', 'action' => 'add'))->to_json()).'" onclick="return false;"><button data-icon="wrench">'.__('Apply changes').'</button></a>';
  160. } else {
  161. echo __('The website’s configuration is up-to-date.');
  162. }
  163. ?>
  164. </p>
  165. </div>
  166. </div>
  167. <div class="col c1"></div>
  168. <script type="text/javascript">
  169. require(
  170. ['jquery-nos', 'wijmo.wijgrid'],
  171. function ($) {
  172. $(function() {
  173. var $container = $('#<?= $uniqid ?>');
  174. $container.nosFormUI();
  175. $container.nosTabs('update', {
  176. label: <?= \Format::forge(__('Applications manager'))->to_json() ?>,
  177. url: 'admin/noviusos_appmanager/appmanager',
  178. iconUrl: 'static/apps/noviusos_appmanager/img/32/app-manager.png',
  179. app: true,
  180. iconSize: 32,
  181. labelDisplay: false
  182. });
  183. <?php
  184. if (\Session::user()->user_expert) {
  185. ?>
  186. var $a = $('<a href="#" data-icon="wrench"><?= htmlspecialchars(__('Refresh all metadata')); ?></a>')
  187. .on('click', function(e) {
  188. e.preventDefault();
  189. $container.nosAjax({
  190. url: 'admin/noviusos_appmanager/appmanager/refresh_metadata',
  191. complete: function() {
  192. $container.load('admin/noviusos_appmanager/appmanager', function() {
  193. $container.find(':first').unwrap();
  194. });
  195. }
  196. })
  197. });
  198. $container.nosToolbar($a);
  199. <?php
  200. }
  201. ?>
  202. $(".app_list_available table, .app_list_installed table").wijgrid({
  203. rendered: function(args) {
  204. $(args.target).closest('.wijmo-wijgrid').find('thead').hide();
  205. var $tooltip = $(args.target).find('.tooltip');
  206. $tooltip.wijtooltip({
  207. showCallout: false,
  208. calloutFilled : true,
  209. closeBehavior: 'sticky',
  210. position : {
  211. my : 'center top',
  212. at : 'center bottom',
  213. offset : '0 0'
  214. },
  215. triggers : 'click',
  216. content : $tooltip.find('div.content').html()
  217. });
  218. },
  219. selectionMode: 'none',
  220. highlightCurrentCell: false
  221. });
  222. $container.find('a').click(function(e) {
  223. e.preventDefault();
  224. var data = $(this).data('app');
  225. $container.nosAjax({
  226. url: 'admin/noviusos_appmanager/appmanager/' + data.action + '/' + data.name,
  227. complete: function() {
  228. $container.load('admin/noviusos_appmanager/appmanager', function() {
  229. $container.find(':first').unwrap();
  230. });
  231. $.nosDispatchEvent({
  232. name : 'Nos\\Application',
  233. action : data.action,
  234. id : data.name
  235. });
  236. }
  237. });
  238. })
  239. <?php
  240. $flash = \Session::get_flash('notification.plugins');
  241. if (!empty($flash)) {
  242. ?>
  243. $.nosNotify(<?= \Format::forge()->to_json($flash); ?>);
  244. <?php
  245. }
  246. ?>
  247. });
  248. });
  249. </script>
  250. </div>