/com_joomleague/components/com_joomleague/modules/mod_joomleague_matches/fields/templatelist.php

https://gitlab.com/volleyuisp/joomleague · PHP · 113 lines · 87 code · 14 blank · 12 comment · 4 complexity · fddfd0e867d41f45abedf85c291b5e7d MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: templatelist.php 470 2010-01-31 19:38:29Z And_One $
  4. * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  5. * @license GNU/GPL, see LICENSE.php
  6. * Joomla! is free software. This version may have been modified pursuant
  7. * to the GNU General Public License, and as distributed it includes or
  8. * is derivative of works licensed under the GNU General Public License or
  9. * other free or open source software licenses.
  10. * See COPYRIGHT.php for copyright notices and details.
  11. */
  12. // Check to ensure this file is included in Joomla!
  13. defined('_JEXEC') or die('Restricted access');
  14. jimport('joomla.form.formfield');
  15. defined('JPATH_BASE') or die();
  16. class JFormFieldTemplatelist extends JFormField
  17. {
  18. protected $type = 'Templatelist';
  19. function getInput()
  20. {
  21. jimport( 'joomla.filesystem.folder' );
  22. // path to images directory
  23. $path = JPATH_ROOT.DS.$this->element['directory'];
  24. $filter = $this->element['filter'];
  25. $exclude = $this->element['exclude'];
  26. $folders = JFolder::folders($path, $filter);
  27. $options = array ();
  28. foreach ($folders as $folder)
  29. {
  30. if ($exclude)
  31. {
  32. if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder )) {
  33. continue;
  34. }
  35. }
  36. $options[] = JHtml::_('select.option', $folder, $folder);
  37. }
  38. $lang = JFactory::getLanguage();
  39. $lang->load("com_joomleague", JPATH_ADMINISTRATOR);
  40. if (!$this->element['hide_none'])
  41. {
  42. array_unshift($options, JHtml::_('select.option', '-1', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_DO_NOT_USE')));
  43. }
  44. if (!$this->element['hide_default'])
  45. {
  46. array_unshift($options, JHtml::_('select.option', '', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_USE_DEFAULT')));
  47. }
  48. $doc = JFactory::getDocument();
  49. $doc->addScriptDeclaration('
  50. function getPosition(element)
  51. {
  52. var pos = { y: 0, x: 0 };
  53. if(element)
  54. {
  55. var elem=element;
  56. while(elem && elem.tagName.toUpperCase() != \'BODY\')
  57. {
  58. pos.y += elem.offsetTop;
  59. pos.x += elem.offsetLeft;
  60. elem = elem.offsetParent;
  61. }
  62. }
  63. return pos;
  64. }
  65. function scrollToPosition(elementId)
  66. {
  67. var a,element,dynPos;
  68. element = $(elementId);
  69. a = getPosition(element);
  70. dynPos = a.y;
  71. window.scroll(a.x,dynPos);
  72. }
  73. ');
  74. $mainframe = JFactory::getApplication();
  75. $select = '<table>'
  76. . '<tr>'
  77. . '<td>'
  78. . JHtml::_('select.genericlist', $options, $this->name,
  79. 'class="inputbox" onchange="$(\'TemplateImage\').src=\''
  80. .$mainframe->getCfg('live_site')
  81. .'/modules/mod_joomleague_matches/tmpl/\'+this.options[this.selectedIndex].value+\'/template.png\';"',
  82. 'value', 'text', $this->value, $this->id)
  83. . '<br /><br />'
  84. . JText::_($this->element['details'])
  85. . '</td>'
  86. . '</tr>'
  87. . '<tr>'
  88. . '<td style="text-align:right;background-color:grey;padding:4px;margin:20px;width:200px;height:150px;">'
  89. . JHtml::_('image','modules/mod_joomleague_matches/tmpl/'.$this->value.'/template.png',
  90. 'TemplateImage', 'id="TemplateImage" width="200"')
  91. . '</td>'
  92. . '</tr>'
  93. . '</table>';
  94. return $select;
  95. }
  96. }