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

/administrator/components/com_nonumbermanager/views/default/tmpl/default.php

https://bitbucket.org/organicdevelopment/joomla-2.5
PHP | 363 lines | 326 code | 24 blank | 13 comment | 45 complexity | 902f1c0588a18333321664c4dc78ce4e MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, MIT, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * @package NoNumber Extension Manager
  4. * @version 3.3.0
  5. *
  6. * @author Peter van Westen <peter@nonumber.nl>
  7. * @link http://www.nonumber.nl
  8. * @copyright Copyright © 2012 NoNumber All Rights Reserved
  9. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
  10. */
  11. // No direct access
  12. defined('_JEXEC') or die;
  13. JHtml::_('behavior.modal');
  14. JHtml::_('behavior.tooltip');
  15. $ids = array();
  16. foreach ($this->items as $item) {
  17. $ids[] = $item->id;
  18. }
  19. $config = JComponentHelper::getParams('com_nonumbermanager');
  20. $check_data = $config->get('check_data', 1);
  21. $hide_notinstalled = $config->get('hide_notinstalled', 0);
  22. $has_not_installed = 0;
  23. foreach ($this->items as $item) {
  24. if (!$item->installed) {
  25. $has_not_installed = 1;
  26. break;
  27. }
  28. }
  29. if (version_compare(PHP_VERSION, '5.3.0', 'l')) {
  30. $app = JFactory::getApplication();
  31. $app->enqueueMessage(JText::sprintf('NNEM_NOT_COMPATIBLE_PHP', PHP_VERSION, '5.3'), 'notice');
  32. }
  33. $document = JFactory::getDocument();
  34. require_once JPATH_PLUGINS.'/system/nnframework/helpers/versions.php';
  35. $versions = NNVersions::getInstance();
  36. $version = $versions->getXMLVersion(null, null, null, 1);
  37. $document->addStyleSheet(JURI::root(true).'/plugins/system/nnframework/css/style.css'.$version);
  38. $document->addScript(JURI::root(true).'/plugins/system/nnframework/js/script.js'.$version);
  39. $key = trim($config->get('key'));
  40. if ($key) {
  41. $key = strtolower(substr($key, 0, 8).md5(substr($key, 8)));
  42. }
  43. $script = "
  44. /* NoNumber Extension Manager variable */
  45. var NNEM_IDS = [ '".implode("', '", $ids)."' ];
  46. var NNEM_NOINSTALL = '".addslashes(JText::_('NNEM_ALERT_NO_ITEMS_TO_INSTALL'))."';
  47. var NNEM_NOUPDATE = '".addslashes(JText::_('NNEM_ALERT_NO_ITEMS_TO_UPDATE'))."';
  48. var NNEM_NONESELECTED = '".addslashes(JText::_('NNEM_ALERT_NO_ITEMS_SELECTED'))."';
  49. var NNEM_FAIL = '".addslashes(JText::_('NNEM_ALERT_FAIL'))."';
  50. var NNEM_CHANGELOG = '".addslashes(JText::_('NNEM_CHANGELOG'))."';
  51. var NNEM_TIMEOUT = ".(int) $config->get('timeout', 5).";
  52. var NNEM_TOKEN = '".JUtility::getToken()."';
  53. var NNEM_KEY = '".$key."';
  54. ";
  55. $document->addScriptDeclaration($script);
  56. $version = $versions->getXMLVersion('nonumbermanager', 'component', null, 1);
  57. $document->addStyleSheet(JURI::root(true).'/administrator/components/com_nonumbermanager/css/style.css'.$version);
  58. $document->addScript(JURI::root(true).'/administrator/components/com_nonumbermanager/js/script.js'.$version);
  59. $onload = array();
  60. if ($check_data) {
  61. $onload[] = 'nnManager.refreshData();';
  62. }
  63. if (!empty($onload)) {
  64. $script = "
  65. window.addEvent( 'domready', function() {
  66. ".implode("\n\t\t", $onload)."
  67. });
  68. ";
  69. $document->addScriptDeclaration($script);
  70. }
  71. // Version check
  72. $version = $versions->getXMLVersion('nonumbermanager', 'component');
  73. echo $versions->getMessage('nonumberextensionmanager', '', $version);
  74. ?>
  75. <a id="nnem_modal" href=""></a>
  76. <div id="nnem">
  77. <form action="" name="adminForm" id="adminForm">
  78. <div class="nnem_main_buttons">
  79. <?php
  80. echo makeElement('', 'data', 'refresh', JText::_('NNEM_CHECK_DATA'), JText::_('NNEM_REFRESH_DESC'), 0, $check_data);
  81. echo makeElement('', 'refresh', 'refresh', JText::_('NNEM_REFRESH'), JText::_('NNEM_REFRESH_DESC'), 0, !$check_data);
  82. if ($has_not_installed) {
  83. echo makeElement('hide', '', 'toggle', JText::_('NNEM_HIDE_NOTINSTALLED'), 0, 0, $hide_notinstalled);
  84. echo makeElement('show', '', 'toggle', JText::_('NNEM_SHOW_NOTINSTALLED'), 0, 0, !$hide_notinstalled);
  85. }
  86. ?>
  87. <div class="clr"></div>
  88. <?php
  89. echo makeElement('', 'all_ghosted', 'installselected', 0, JText::_('NNEM_INSTALL_SELECTED'), 'none');
  90. echo makeElement('', 'all', 'installselected', JText::_('NNEM_INSTALL_SELECTED'), JText::_('NNEM_INSTALL_SELECTED_DESC'), 0, 1);
  91. echo makeElement('', 'all_ghosted', 'installall', 0, JText::_('NNEM_INSTALL_ALL'), 'none');
  92. echo makeElement('', 'all', 'installall', JText::_('NNEM_INSTALL_ALL'), JText::_('NNEM_INSTALL_ALL_DESC'), 0, 1);
  93. echo makeElement('', 'all_ghosted', 'updateall', 0, JText::_('NNEM_UPDATE_ALL'), 'none');
  94. echo makeElement('', 'all', 'updateall', JText::_('NNEM_UPDATE_ALL'), JText::_('NNEM_UPDATE_ALL_DESC'), 0, 1);
  95. ?>
  96. </div>
  97. <table class="adminlist<?php echo $hide_notinstalled ? ' hide_not_installed' : ''; ?>">
  98. <thead>
  99. <tr>
  100. <th width="1%">
  101. <input type="checkbox" name="checkall-toggle" value="" onclick="checkAll(this)" />
  102. </th>
  103. <th width="5%" class="left" nowrap="nowrap">
  104. <?php echo JText::_('NNEM_EXTENSION'); ?>
  105. </th>
  106. <th width="1%">&nbsp;</th>
  107. <th width="2%" class="left" nowrap="nowrap">
  108. <?php echo JText::_('NNEM_TYPE'); ?>
  109. </th>
  110. <th width="5%" class="left" nowrap="nowrap">
  111. <?php echo JText::_('NNEM_INSTALLED'); ?>
  112. </th>
  113. <th width="5%" class="left" nowrap="nowrap">
  114. <?php echo JText::_('NNEM_AVAILABLE'); ?>
  115. </th>
  116. <th width="1%">&nbsp;</th>
  117. <th width="5%" class="left buttons" nowrap="nowrap">
  118. <?php echo JText::_('NNEM_INSTALL_UPDATE'); ?>
  119. </th>
  120. <th width="1%">&nbsp;</th>
  121. <th class="left" nowrap="nowrap">
  122. <?php echo JText::_('NNEM_COMMENT'); ?>
  123. </th>
  124. <th width="5%" class="left">&nbsp;</th>
  125. </tr>
  126. </thead>
  127. <tbody>
  128. <?php foreach ($this->items as $i => $item) : ?>
  129. <tr id="row_<?php echo $item->id; ?>" class="<?php
  130. if ($item->installed) {
  131. echo 'installed'
  132. .($item->old ? ' old' : ($item->pro ? ' pro_installed' : ' free_installed'))
  133. .(empty($item->missing) ? '' : ' has_missing');
  134. } else {
  135. echo 'not_installed';
  136. }
  137. ?>">
  138. <td class="center checkbox">
  139. <div class="checkbox_container">
  140. <span class="group_data select" style="display:none;">
  141. <?php echo JHtml::_('grid.id', $i, $item->id); ?>
  142. </span>
  143. </div>
  144. </td>
  145. <td nowrap="nowrap" class="ext_name">
  146. <input type="hidden" id="url_<?php echo $item->id; ?>" value="" />
  147. <span class="hasTip"
  148. title="<?php echo JText::_('JGLOBAL_DESCRIPTION').'::'.JText::_($item->name.'_DESC'); ?>">
  149. <img src="<?php echo JURI::base(); ?>components/com_nonumbermanager/images/icons/<?php echo $item->alias; ?>.png"
  150. alt="" width="16" height="16" /> <?php echo JText::_($item->name); ?>
  151. </span>
  152. </td>
  153. <td class="ext_website">
  154. <a href="http://www.nonumber.nl/<?php echo $item->id; ?>" target="_blank">
  155. <span class="hasTip"
  156. title="<?php echo JText::_('NNEM_WEBSITE'); ?>::http://www.nonumber.nl/<?php echo $item->alias; ?>">
  157. <img src="<?php echo JURI::base(); ?>components/com_nonumbermanager/images/link.png"
  158. alt=""
  159. width="16" height="16" />
  160. </span>
  161. </a>
  162. </td>
  163. <td nowrap="nowrap" class="ext_types">
  164. <span class="not_installed">
  165. <?php
  166. foreach ($item->types as $type) {
  167. $tip = JText::_('NN_'.strtoupper($type->type)).':: ';
  168. $icon = '<img src="'.JURI::base().'components/com_nonumbermanager/images/ext_'.$type->type.'.png" alt="'.$tip.'" style="margin:0 1px;" width="16" height="16" />';
  169. echo '<label class="hasTip" title="'.$tip.'">'.$icon.'</label>';
  170. }
  171. ?>
  172. </span>
  173. <span class="installed">
  174. <?php
  175. foreach ($item->types as $type) {
  176. $tip = JText::_('NN_'.strtoupper($type->type)).'::'.JText::_('NNEM_GO_TO_EXTENSION');
  177. $icon = '<img src="'.JURI::base().'components/com_nonumbermanager/images/ext_'.$type->type.'.png" alt="'.$tip.'" style="margin:0 1px;" width="16" height="16" />';
  178. $icon = '<a href="index.php?'.$type->link.'" target="_blank">'.$icon.'</a>';
  179. echo '<label class="hasTip" title="'.$tip.'">'.$icon.'</label>';
  180. }
  181. ?>
  182. </span>
  183. </td>
  184. <td nowrap="nowrap" class="">
  185. <?php
  186. echo makeElement($item->id, 'version_loading data', 'loading', 0, 0, 0, 1);
  187. ?>
  188. <span class="installed">
  189. <?php
  190. echo makeElement($item->id, '', 'current_version', 0, $item->version, 0, 0);
  191. echo makeElement($item->id, '', 'free_installed', 0, 'FREE', 0, 1);
  192. echo makeElement($item->id, '', 'pro_installed', 0, 'PRO', 0, 1);
  193. ?>
  194. <div class="clr"></div>
  195. </span>
  196. </td>
  197. <td nowrap="nowrap" class="">
  198. <?php
  199. echo makeElement('', 'data', 'refresh', JText::_('NNEM_CHECK_DATA'), JText::_('NNEM_REFRESH_DESC'), 0, $check_data);
  200. echo makeElement($item->id, 'data', 'loading', 0, 0, 0, 1);
  201. ?>
  202. <span class="hide_uptodate">
  203. <?php
  204. echo makeElement($item->id, 'data', 'new_version', 0, '&nbsp;', 0, 1);
  205. echo makeElement($item->id, 'data', 'pro_no_access', 0, 'FREE', 0, 1);
  206. echo makeElement($item->id, 'data', 'pro_access', 0, 'PRO', 0, 1);
  207. ?>
  208. </span>
  209. </td>
  210. <td class="center ext_changelog">
  211. <?php
  212. echo makeElement($item->id, 'data', 'changelog', 0, JText::_('NNEM_CHANGELOG'), 'http://www.nonumber.nl/'.$item->id.'#changelog', 1);
  213. ?>
  214. </td>
  215. <td nowrap="nowrap" class="buttons">
  216. <?php
  217. echo makeElement($item->id, 'data', 'update', JText::_('NNEM_TITLE_UPDATE'), 0, 0, 1);
  218. echo makeElement($item->id, 'data', 'install', JText::_('NNEM_TITLE_INSTALL'), 0, 0, 1);
  219. echo makeElement($item->id, 'data', 'reinstall', JText::_('NNEM_TITLE_REINSTALL'), 0, 0, 1);
  220. echo makeElement($item->id, 'data', 'downgrade', JText::_('NNEM_TITLE_DOWNGRADE'), 0, 0, 1);
  221. ?>
  222. </td>
  223. <td nowrap="nowrap" class="buttons">
  224. <span class="pro_not_installed"><span class="pro_available"><span class="pro_no_access">
  225. <?php
  226. echo makeElement($item->id, '', 'buy', JText::_('NNEM_BUY_PRO_VERSION'), 0, 'http://www.nonumber.nl/subscribe?ext='.$item->id);
  227. ?>
  228. </span></span></span>
  229. <span class="pro_installed"><span class="pro_no_access">
  230. <?php
  231. echo makeElement($item->id, '', 'nopro', JText::_('NNEM_RENEW_SUBSCRIPTION'), 0, 'http://www.nonumber.nl/subsciptions?ext='.$item->id);
  232. ?>
  233. </span>
  234. </td>
  235. <td class="comments">
  236. <?php
  237. echo makeElement($item->id, 'comment', 'uptodate', 0, JText::_('NNEM_COMMENT_UPTODATE'), 0, 1);
  238. echo makeElement($item->id, 'comment', 'update', 0, JText::_('NNEM_COMMENT_UPDATE'), 0, 1);
  239. echo makeElement($item->id, 'comment', 'downgrade', 0, JText::_('NNEM_COMMENT_DOWNGRADE'), 0, 1);
  240. echo makeElement($item->id, 'comment', 'pro_no_access', 0, JText::_('NNEM_COMMENT_NO_PRO'), 0, 1);
  241. echo makeElement($item->id, 'comment', 'old', 0, JText::sprintf('NNEM_COMMENT_OLD', JText::_($item->name)), 0, 1);
  242. $missing = '';
  243. if ($item->installed && !empty($item->missing)) {
  244. $missing = array();
  245. foreach ($item->missing as $m) {
  246. $missing[] = JText::_('NN_'.strtoupper($m));
  247. }
  248. $missing = JText::sprintf('NNEM_MISSING_EXTENSIONS', implode(',', $missing));
  249. }
  250. echo makeElement($item->id, 'comment', 'missing', 0, $missing, 0, (!$missing));
  251. ?>
  252. </td>
  253. <td nowrap="nowrap" class="ext_uninstall buttons">
  254. <?php if ($item->id != 'nonumberextensionmanager') : ?>
  255. <span class="installed">
  256. <?php echo makeElement($item->id, 'none', 'uninstall', JText::_('NNEM_TITLE_UNINSTALL')); ?>
  257. </span>
  258. <?php endif; ?>
  259. </td>
  260. </tr>
  261. <?php endforeach; ?>
  262. </tbody>
  263. </table>
  264. <input type="hidden" name="task" value="" />
  265. <input type="hidden" name="boxchecked" value="0" />
  266. </form>
  267. </div>
  268. <?php
  269. // Copyright
  270. echo $versions->getCopyright(JText::_('NONUMBER_EXTENSION_MANAGER'), $version);
  271. function makeElement($alias, $group, $type, $button = 0, $tip = 0, $link = 0, $hide = 0)
  272. {
  273. $class = array();
  274. $id = '';
  275. if ($alias) {
  276. $id = $alias.'_'.$type;
  277. }
  278. if ($group != 'comment') {
  279. $class[] = $type;
  280. }
  281. if ($group) {
  282. if ($alias) {
  283. $id = $alias.'_'.$group.'_'.$type;
  284. }
  285. $class[] = 'group_'.$group;
  286. $class[] = $group.'_'.$type;
  287. }
  288. $txt = $tip;
  289. if ($button) {
  290. $txt = $button;
  291. } else {
  292. $tip = 0;
  293. }
  294. if ($tip) {
  295. $class[] = 'hasTip';
  296. } else {
  297. $tip = 0;
  298. }
  299. if ($group == 'comment') {
  300. $split = explode('<br />', $txt, 2);
  301. $txt = $split['0'];
  302. if (isset($split['1'])) {
  303. $txt .= ' <span class="readmore">'.JText::_('NN_MORE_INFO').'</span><span class="readmore_text"><br />'.$split['1'].'</span>';
  304. }
  305. }
  306. $img = '';
  307. if ($type == 'loading') {
  308. $txt = '<progress class="loading">'.JText::sprintf('NNEM_PROCESS_LOADING', '...').'</progress>';
  309. $id = '';
  310. } else if ($type == 'changelog') {
  311. $img = 'changelog.png';
  312. }
  313. $html = array();
  314. $html[] = '<span'.($id ? ' id="'.str_replace(' ', '_', $id).'"' : '').' class="'.implode(' ', $class).'"'.($tip ? ' title="'.$tip.':: "' : '').($hide ? ' style="display:none;"' : '').'>';
  315. if ($link === 'none') {
  316. $html[] = '<a class="nolink">';
  317. } else if ($button && $link) {
  318. $html[] = '<a href="'.$link.'" target="_blank">';
  319. } else if ($button) {
  320. $html[] = '<a href="javascript://" onclick="nnem_function(\''.$type.'\', \''.$alias.'\');" class="nnem_link">';
  321. } else if ($link) {
  322. $html[] = '<a href="'.$link.'" target="_blank">';
  323. }
  324. $class = array();
  325. if ($type == 'loading') {
  326. $html[] = $txt;
  327. } else if ($img) {
  328. $html[] = '<img src="'.JURI::base().'components/com_nonumbermanager/images/'.$img.'" alt="'.JText::_('NNEM_'.strtoupper($type)).'" width="16" height="16" />';
  329. } else if ($txt !== 0) {
  330. $html[] = '<span class="nnem_button">';
  331. $html[] = $txt;
  332. $html[] = '</span>';
  333. }
  334. if ($link || $button) {
  335. $html[] = '</a>';
  336. }
  337. $html[] = '</span>';
  338. return implode('', $html);
  339. }