PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_jfusion/views/extensions/tmpl/default.php

http://jfusion.googlecode.com/
PHP | 432 lines | 340 code | 60 blank | 32 comment | 38 complexity | f2a9ab720f0023b5fe7cdeefd2c8b4cd MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /**
  3. * @package JFusion
  4. * @subpackage Views
  5. * @author JFusion development team
  6. * @copyright Copyright (C) 2008 JFusion. All rights reserved.
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  8. */
  9. // no direct access
  10. defined('_JEXEC') or die('Restricted access');
  11. // load debug library
  12. require_once(JPATH_ADMINISTRATOR .DS.'components'.DS.'com_jfusion'.DS.'models'.DS.'model.debug.php');
  13. /**
  14. * This function allows the version number to be retrieved for JFusion plugins
  15. */
  16. function getVersionNumber($plugin_type, $plugin, &$row_count){
  17. //append path
  18. $localfile = JPATH_SITE . $plugin->localfile[0]->data();
  19. $installed = false;
  20. if($plugin_type=='jfusion') {
  21. static $installed_plugins;
  22. if(!is_array($installed_plugins)) {
  23. $db = & JFactory::getDBO();
  24. $query = 'SELECT name from #__jfusion WHERE name != "joomla_int"';
  25. $db->setQuery($query);
  26. $installed_plugins = $db->loadObjectList('name');
  27. }
  28. if(array_key_exists($plugin->name(), $installed_plugins)) {
  29. $installed = true;
  30. }
  31. } elseif($plugin_type=='joomla') {
  32. $db =& JFactory::getDBO();
  33. if($plugin->type[0]->data()=='plugin') {
  34. $query = "SELECT id FROM #__plugins WHERE element = '{$plugin->element[0]->data()}' AND folder = '{$plugin->folder[0]->data()}'";
  35. $db->setQuery($query);
  36. $result = $db->loadResult();
  37. if(!empty($result)) {
  38. $installed = true;
  39. }
  40. } else {
  41. $query = "SELECT id FROM #__modules WHERE module = '{$plugin->element[0]->data()}' LIMIT 0,1";
  42. $db->setQuery($query);
  43. $result = $db->loadResult();
  44. if(!empty($result)) {
  45. $installed = true;
  46. }
  47. }
  48. } elseif($plugin_type=='language') {
  49. //if $localfile exists, then language is installed
  50. if(file_exists($localfile)) {
  51. $installed = true;
  52. }
  53. }
  54. if (file_exists($localfile) && is_readable($localfile) && $installed) {
  55. //get the version number
  56. $parser = JFactory::getXMLParser('Simple');
  57. $parser->loadFile($localfile);
  58. if (version_compare($parser->document->version[0]->data(), $plugin->version[0]->data(), '>=')){
  59. $status = 'up2date';
  60. echo '<tr class = "good'.$row_count.' row">';
  61. $version = $parser->document->version[0]->data();
  62. } else {
  63. echo '<tr class = "bad'.$row_count.' row">';
  64. $status = 'outdated';
  65. $version = $parser->document->version[0]->data();
  66. }
  67. } else {
  68. $status = 'not_installed';
  69. echo '<tr class="row">';
  70. $version = JText::_('NOT') .' ' . JText::_('INSTALLED');
  71. }
  72. //output the standard info
  73. echo '<td>' . JText::_('JFUSION') . ' ' .$plugin->name[0]->data(). ' </td>';
  74. echo '<td>' . $version . '</td>';
  75. echo '<td>' . $plugin->version[0]->data() . '</td><td>';
  76. //create the URL
  77. $url = 'index.php?option=com_jfusion&mode=' . $plugin_type .'&name=' . $plugin->name();
  78. if(!empty($plugin->type[0])){
  79. $url .= '&type=' . $plugin->type[0]->data();
  80. }
  81. if(!empty($plugin->element[0])){
  82. $url .= '&element=' . $plugin->element[0]->data();
  83. }
  84. if(!empty($plugin->folder[0])){
  85. $url .= '&folder=' . $plugin->folder[0]->data();
  86. }
  87. if($status == 'outdated') {
  88. //provide upgrade option
  89. echo '<a href="' . $url . '&task=install">'.JText::_('UPGRADE').'</a>';
  90. //provide uninstall option
  91. echo '&nbsp;/&nbsp;<a href="javascript:void(0);" onclick="if(confirm(\''.JText::sprintf('CONFIRM_UNINSTALL',$plugin->name[0]->data()).'\')) { window.location=\''.$url.'&task=uninstall\'; }">'.JText::_('UNINSTALL').'</a>';
  92. } elseif ($status == 'up2date') {
  93. //provide uninstall option
  94. echo '<a href="javascript:void(0);" onclick="if(confirm(\''.JText::sprintf('CONFIRM_UNINSTALL',$plugin->name[0]->data()).'\')) { window.location=\''.$url.'&task=uninstall\'; }">'.JText::_('UNINSTALL').'</a>';
  95. } else {
  96. //provide install option
  97. echo '<a href="'.$url.'&task=install"">'.JText::_('INSTALL').'</a>';
  98. }
  99. echo '&nbsp;/&nbsp;<a href="' . $plugin->remotefile[0]->data() . '">'.JText::_('DOWNLOAD').'</a>';
  100. //close the table
  101. echo '</td></tr>';
  102. //cleanup for the next function call
  103. unset($parser);
  104. if ($row_count == 1){
  105. $row_count = 0;
  106. } else {
  107. $row_count = 1;
  108. }
  109. }
  110. /**
  111. * Sort the results by name
  112. */
  113. function sortByName($a, $b) {
  114. return (strcasecmp ($a->name[0]->data(),$b->name[0]->data()));
  115. }
  116. //check the jFusion component version
  117. ?>
  118. <table class="adminform" style="border-spacing:1px;">
  119. <thead>
  120. <tr>
  121. <th class="title" align="left"><?php echo JText::_('STATUS'); ?></th>
  122. <th class="title" align="center"><?php echo JText::_('YOUR_VERSION'); ?></th>
  123. <th class="title" align="center"><?php echo JText::_('CURRENT_VERSION'); ?></th>
  124. <th class="title" align="center"></th>
  125. </tr>
  126. </thead>
  127. <tbody>
  128. <?php
  129. if(version_compare($this->VersionCurrent, $this->VersionLatest , '>=')){
  130. //output the good news
  131. ?>
  132. <tr class="good0">
  133. <td><img src="components/com_jfusion/images/check_good.png"
  134. height="30px" width="30px"></td>
  135. <td><?php echo $this->VersionCurrent . ' (Rev ' . $this->RevisionCurrent . ')';?></td>
  136. <td><?php echo $this->VersionLatest;?></td>
  137. <td>
  138. <h2><?php echo JText::_('JFUSION_UP2DATE'); ?></h2>
  139. </td>
  140. </tr>
  141. <?php } else { //output the bad news and automatic upgrade option ?>
  142. <tr class="bad0">
  143. <td><img src="components/com_jfusion/images/check_bad.png"
  144. height="30px" width="30px"></td>
  145. <td><?php echo $this->VersionCurrent;?></td>
  146. <td><?php echo $this->VersionLatest;?></td>
  147. <td>
  148. <h2><?php echo JText::_('JFUSION_OUTDATED'); ?></h2>
  149. <a
  150. href="index.php?option=com_jfusion&task=install&file=<?php base64_encode($this->VersionData->latest[0]->remotefile[0]->data());?>"><?JText::_('UPGRADE');?></a>
  151. </td>
  152. </tr>
  153. <?php }
  154. ?></table><?php
  155. //check to see if we have version data
  156. if(empty($this->VersionData)){
  157. echo '<h2>' . JText::_('NO_VERSION_DATA') . '</h2>';
  158. return;
  159. }
  160. //do a server compatibility check
  161. ?>
  162. <table class="adminform" style="border-spacing:1px;">
  163. <thead>
  164. <tr>
  165. <th class="title" align="left"><?php echo JText::_('SERVER_SOFTWARE'); ?></th>
  166. <th class="title" align="center"><?php echo JText::_('YOUR_VERSION'); ?></th>
  167. <th class="title" align="center"><?php echo JText::_('MINIMUM_VERSION'); ?></th>
  168. </tr>
  169. </thead>
  170. <tbody>
  171. <?php
  172. $server_compatible = true;
  173. if (version_compare(phpversion(), $this->VersionData->requirements[0]->php[0]->data()) == -1){
  174. ?><tr class = "bad0"><?php
  175. $server_compatible = false;
  176. } else {
  177. ?><tr class = "good0"><?php
  178. }
  179. ?>
  180. <td>PHP</td>
  181. <td><?php echo phpversion();?></td>
  182. <td><?php echo $this->VersionData->requirements[0]->php[0]->data();?></td>
  183. </tr>
  184. <?php
  185. $version =& new JVersion;
  186. $joomla_version = $version->getShortVersion();
  187. //remove any letters from the version
  188. $joomla_versionclean = preg_replace("[A-Za-z !]","", $joomla_version);
  189. if (version_compare($joomla_versionclean, $this->VersionData->requirements[0]->joomla[0]->data()) == -1){
  190. ?><tr class = "bad1"><?php
  191. $server_compatible = false;
  192. } else {
  193. ?><tr class = "good1"><?php
  194. }
  195. ?>
  196. <td>Joomla</td>
  197. <td><?php echo $joomla_version;?></td>
  198. <td><?php echo $this->VersionData->requirements[0]->joomla[0]->data();?></td>
  199. </tr>
  200. <?php
  201. $db = & JFactory::getDBO();
  202. $mysql_version = $db->getVersion();
  203. if (version_compare($mysql_version, $this->VersionData->requirements[0]->mysql[0]->data()) == -1){
  204. ?><tr class = "bad0"><?php
  205. $server_compatible = false;
  206. } else {
  207. ?><tr class = "good0"><?php
  208. }
  209. ?>
  210. <td>MySQL</td>
  211. <td><?php echo $mysql_version;?></td>
  212. <td><?php echo $this->VersionData->requirements[0]->mysql[0]->data();?></td>
  213. </tr>
  214. <?php
  215. if($server_compatible){
  216. //output the good news
  217. ?>
  218. <tr class="good1">
  219. <td><img src="components/com_jfusion/images/check_good.png"
  220. height="30px" width="30px">
  221. <td colspan="2">
  222. <h2><?php echo JText::_('SERVER_UP2DATE'); ?></h2>
  223. </td>
  224. </tr>
  225. <?php } else { //output the bad news and automatic upgrade option ?>
  226. <tr class="bad1">
  227. <td><img src="components/com_jfusion/images/check_bad.png"
  228. height="30px" width="30px">
  229. <td colspan="2">
  230. <h2><?php echo JText::_('SERVER_OUTDATED'); ?></h2>
  231. </td>
  232. </tr>
  233. <?php } ?>
  234. </table>
  235. <br />
  236. <table class="adminform" style="border-spacing:1px;">
  237. <thead>
  238. <tr>
  239. <th class="title" align="left"><?php echo JText::_('JOOMLA') . ' ' . JText::_('EXTENSIONS'); ?></th>
  240. <th class="title" width="120px" align="center"><?php echo JText::_('YOUR_VERSION'); ?></th>
  241. <th class="title" width="120px" align="center"><?php echo JText::_('CURRENT_VERSION'); ?></th>
  242. <th class="title" width="200px" align="center"><?php echo JText::_('OPTIONS'); ?></th>
  243. </tr>
  244. </thead>
  245. <tbody>
  246. <?php
  247. $row_count = 0;
  248. $joomla_extensions = $this->VersionData->joomla[0]->children();
  249. usort($joomla_extensions, "sortByName");
  250. foreach ($joomla_extensions as $plugin){
  251. getVersionNumber('joomla', $plugin, $row_count);
  252. }
  253. ?>
  254. </table>
  255. <br />
  256. <table class="adminform" style="border-spacing:1px;">
  257. <thead>
  258. <tr>
  259. <th class="title" align="left"><?php echo JText::_('JFUSION') . ' ' . JText::_('PLUGINS'); ?></th>
  260. <th class="title" width="120px" align="center"><?php echo JText::_('YOUR_VERSION'); ?></th>
  261. <th class="title" width="120px" align="center"><?php echo JText::_('CURRENT_VERSION'); ?></th>
  262. <th class="title" width="200px" align="center"><?php echo JText::_('OPTIONS'); ?></th>
  263. </tr>
  264. </thead>
  265. <tbody>
  266. <?php
  267. $row_count = 0;
  268. $jfusion_plugins = $this->VersionData->jfusion[0]->children();
  269. usort($jfusion_plugins, "sortByName");
  270. foreach ($jfusion_plugins as $plugin){
  271. getVersionNumber('jfusion', $plugin, $row_count);
  272. }
  273. ?>
  274. </table>
  275. <br />
  276. <table class="adminform" style="border-spacing:1px;">
  277. <thead>
  278. <tr>
  279. <th class="title" align="left"><?php echo JText::_('JFUSION') . ' ' . JText::_('LANGUAGES'); ?></th>
  280. <th class="title" width="120px" align="center"><?php echo JText::_('YOUR_VERSION'); ?></th>
  281. <th class="title" width="120px" align="center"><?php echo JText::_('CURRENT_VERSION'); ?></th>
  282. <th class="title" width="200px" align="center"><?php echo JText::_('OPTIONS'); ?></th>
  283. </tr>
  284. </thead>
  285. <tbody>
  286. <?php
  287. $row_count = 0;
  288. $jfusion_languages = $this->VersionData->language[0]->children();
  289. usort($jfusion_languages, "sortByName");
  290. foreach ($jfusion_languages as $plugin){
  291. getVersionNumber('language', $plugin, $row_count);
  292. }
  293. ?>
  294. </table>
  295. <br />
  296. <form method="post" action="index2.php" name="adminForm"
  297. enctype="multipart/form-data"><input type="hidden" name="option"
  298. value="com_jfusion" /> <input type="hidden" name="task"
  299. value="install_plugin" /> <input type="hidden" name="new_jname"
  300. value="" />
  301. <table class="adminform">
  302. <tr>
  303. <td width="50px"><img src="templates/khepri/images/header/icon-48-install.png"
  304. height="48px" width="48px"></td>
  305. <td>
  306. <h1><font color=0b55c4><?php echo JText::_('PLUGIN_INSTALL'); ?></font></h1>
  307. </td>
  308. </tr>
  309. </table>
  310. <?php echo JText::_('PLUGIN_INSTALL_INSTR'); ?><br /><br />
  311. <table class="adminform">
  312. <tr>
  313. <td>
  314. <table>
  315. <tr>
  316. <th colspan="2"><?php echo JText::_( 'UPLOAD_PACKAGE' ); ?></th>
  317. </tr>
  318. <tr>
  319. <td width="120"><label for="install_package"> <?php echo JText::_( 'PACKAGE_FILE' ); ?>
  320. :</label></td>
  321. <td><input class="input_box" id="install_package"
  322. name="install_package" type="file" size="57" /> <input
  323. class="button" type="button"
  324. value="<?php echo JText::_( 'UPLOAD_FILE' ); ?> &amp; <?php echo JText::_( 'INSTALL' ); ?>"
  325. onclick="submitbutton()" /></td>
  326. </tr>
  327. </table>
  328. </td>
  329. </tr>
  330. </table>
  331. <table class="adminform">
  332. <tr>
  333. <td>
  334. <table>
  335. <tr>
  336. <th colspan="2"><?php echo JText::_( 'INSTALL_FROM_DIRECTORY' ); ?>
  337. </th>
  338. </tr>
  339. <tr>
  340. <td width="120"><label for="install_directory"> <?php echo JText::_( 'INSTALL_DIRECTORY' ); ?>
  341. :</label></td>
  342. <td><input type="text" id="install_directory"
  343. name="install_directory" class="input_box" size="70" value="" /> <input
  344. type="button" class="button"
  345. value="<?php echo JText::_( 'INSTALL' ); ?>"
  346. onclick="submitbutton3()" /></td>
  347. </tr>
  348. </table>
  349. </td>
  350. </tr>
  351. </table>
  352. <table class="adminform">
  353. <tr>
  354. <td>
  355. <table>
  356. <tr>
  357. <th colspan="2"><?php echo JText::_( 'INSTALL_FROM_URL' ); ?></th>
  358. </tr>
  359. <tr>
  360. <td width="120"><label for="install_url"> <?php echo JText::_( 'INSTALL_URL' ); ?>
  361. :</label></td>
  362. <td><input type="text" id="install_url" name="install_url"
  363. class="input_box" size="70" value="http://" /> <input type="button"
  364. class="button" value="<?php echo JText::_( 'INSTALL' ); ?>"
  365. onclick="submitbutton4()" /></td>
  366. </tr>
  367. </table>
  368. </td>
  369. </tr>
  370. </table>
  371. <input type="hidden" name="type" value="" /> <input type="hidden"
  372. name="installtype" value="upload" /></form>