/administrator/modules/mod_mypanel/tmpl/default.php

https://github.com/rietn/minima · PHP · 154 lines · 81 code · 38 blank · 35 comment · 16 complexity · 5f1e6f2fe3bba2cb4cda6283bf459788 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Minima
  4. * @subpackage mod_mypanel
  5. * @author Marco Barbosa
  6. * @copyright Copyright (C) 2010 Marco Barbosa. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. // No direct access.
  10. defined('_JEXEC') or die;
  11. $items = ModMypanelHelper::getItems();
  12. $invisible = false;
  13. $nPages = ceil( count($items) / 9);
  14. // hide arrows and pagination if items lower or equal 9
  15. if (count($items) <= 9) {
  16. $invisible = true;
  17. }
  18. ?>
  19. <div id="panel">
  20. <!-- search field -->
  21. <!--<input type="text" id="search-term" placeholder="What are you looking for?" />-->
  22. <!-- dots pagination -->
  23. <ul id="panel-pagination" <?php if ($invisible) echo "class=\"hide\""; ?>>
  24. <?php for($i=0; $i < $nPages; $i++) : ?>
  25. <li <?php if($i == 0) echo "class=\"current\"" ?> id="panel-pagination-<?php echo $i;?>"></li>
  26. <?php endfor; ?>
  27. </ul>
  28. <!-- prev button -->
  29. <a href="#" id="prev" <?php if ($invisible) echo "class=\"invisible\""; ?>><span class="arrow"></span></a>
  30. <nav id="panel-list">
  31. <?php
  32. // number of extensions
  33. $count = 0;
  34. // standard components that we have the icons ready
  35. $jComponents = array("com_banners", "com_contact", "com_messages", "com_newsfeeds", "com_redirect", "com_search", "com_weblinks");
  36. foreach ($items as $item) {
  37. // reset local vars
  38. $isIconFound = false;
  39. $class = "";
  40. // get the description from the language file (100 chars)
  41. $description = strip_tags( substr(JText::_(''.strtoupper($item->title).'_XML_DESCRIPTION'), 0, 100) );
  42. // get the title of the component
  43. $title = JText::_(''.strtoupper($item->title));
  44. // do we have a description?
  45. // show the "no description available" message if not
  46. if (strpos($description, '_XML_DESCRIPTION') !== false) {
  47. $description = JText::_('TPL_MINIMA_NODESCRIPTION');
  48. }
  49. // if it's a standard extension, add the class to use the sprites
  50. if (in_array(strtolower($item->element), $jComponents)) {
  51. // getting the component image class
  52. $arrClass = explode(":", $item->img);
  53. // concatenate with icon-48
  54. $class = "icon-48-".$arrClass[1];
  55. } else {
  56. // component dev already specifies image path
  57. $img = str_replace('16', '48', $item->img);
  58. // get image dimensions, maybe we still got the 16px one
  59. // $imageIsTooSmall....
  60. $imageIsTooSmall = false; // temporary
  61. // does the supplied image exist?
  62. if (!file_exists($img) || $imageIsTooSmall) {
  63. // start checking for alternative paths
  64. // look for the img in the header path
  65. //if (file_exists()) {
  66. // look for the img in the media path
  67. //} else if () {
  68. //}
  69. } else {
  70. $isIconFound = true;
  71. }
  72. // last fallback if img still not found
  73. if (!$isIconFound) {
  74. $class = "icon-48-generic";
  75. }
  76. }
  77. // new list for first of every 10th item
  78. if ($count % 9 === 0) {
  79. echo "<ul>";
  80. }
  81. // standard extension
  82. if (!empty($class)) {
  83. ?>
  84. <li>
  85. <a href="<?php echo $item->link; ?>" class="<?php echo $class; ?>"><?php echo $title; ?>
  86. <span class="ext-desc"><?php echo $description; ?></span>
  87. </a>
  88. </li>
  89. <?php
  90. // not standard, add an image instead of a class
  91. } else {
  92. ?>
  93. <li class="ext">
  94. <a href="<?php echo $item->link; ?>" class="<?php echo $class; ?>">
  95. <figure>
  96. <img src="<?php echo $img; ?>" alt="<?php echo $title; ?>" />
  97. </figure>
  98. <?php echo $title; ?>
  99. <span class="ext-desc"><?php echo $description; ?></span>
  100. </a>
  101. </li>
  102. <?php
  103. } // end of if !empty($class)
  104. // close list for first of every 10th item
  105. if ($count % 9 === 8) {
  106. echo "</ul>";
  107. }
  108. // one more extension
  109. $count++;
  110. }; //end of loop
  111. ?>
  112. </nav>
  113. <!-- next button -->
  114. <a href="#" id="next" <?php if ($invisible) echo "class=\"invisible\""; ?>><span class="arrow"></span></a>
  115. </div>
  116. <div class="clr"></div>