PageRenderTime 32ms CodeModel.GetById 23ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 13// Check to ensure this file is included in Joomla!
 14defined('_JEXEC') or die('Restricted access');
 15 
 16jimport('joomla.form.formfield');
 17 
 18defined('JPATH_BASE') or die();
 19
 20class JFormFieldTemplatelist extends JFormField
 21{
 22	protected $type = 'Templatelist';
 23	
 24	function getInput()
 25	{
 26		jimport( 'joomla.filesystem.folder' );
 27		
 28		// path to images directory
 29		$path		= JPATH_ROOT.DS.$this->element['directory'];
 30		$filter		= $this->element['filter'];
 31		$exclude	= $this->element['exclude'];
 32		$folders	= JFolder::folders($path, $filter);
 33		
 34		$options = array ();
 35		foreach ($folders as $folder)
 36		{
 37			if ($exclude)
 38			{
 39				if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder )) {
 40					continue;
 41				}
 42			}
 43			$options[] = JHtml::_('select.option', $folder, $folder);
 44		}
 45		
 46		$lang = JFactory::getLanguage();
 47		$lang->load("com_joomleague", JPATH_ADMINISTRATOR);
 48		if (!$this->element['hide_none'])
 49		{
 50			array_unshift($options, JHtml::_('select.option', '-1', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_DO_NOT_USE')));
 51		}
 52		
 53		if (!$this->element['hide_default'])
 54		{
 55			array_unshift($options, JHtml::_('select.option', '', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_USE_DEFAULT')));
 56		}
 57		
 58		$doc = JFactory::getDocument();
 59		$doc->addScriptDeclaration('
 60			function getPosition(element)
 61			{
 62				var pos = { y: 0, x: 0 };
 63		
 64				if(element)
 65				{
 66					var elem=element;
 67					while(elem && elem.tagName.toUpperCase() != \'BODY\')
 68					{
 69						pos.y += elem.offsetTop;
 70						pos.x += elem.offsetLeft;
 71						elem = elem.offsetParent;
 72					}
 73				}
 74				return pos;
 75			}
 76		
 77			function scrollToPosition(elementId)
 78			{
 79				var a,element,dynPos;
 80				element = $(elementId);
 81				a = getPosition(element);
 82				dynPos = a.y;
 83				window.scroll(a.x,dynPos);
 84		
 85			}
 86			');
 87		
 88		$mainframe = JFactory::getApplication();
 89
 90		$select = '<table>'
 91				. '<tr>'
 92				. '<td>'
 93				. JHtml::_('select.genericlist',  $options, $this->name,
 94						   'class="inputbox" onchange="$(\'TemplateImage\').src=\''
 95				           .$mainframe->getCfg('live_site')
 96						   .'/modules/mod_joomleague_matches/tmpl/\'+this.options[this.selectedIndex].value+\'/template.png\';"', 
 97						   'value', 'text', $this->value, $this->id)
 98				. '<br /><br />'
 99				. JText::_($this->element['details'])
100				. '</td>'
101				. '</tr>'
102				. '<tr>'
103				. '<td style="text-align:right;background-color:grey;padding:4px;margin:20px;width:200px;height:150px;">'
104				. JHtml::_('image','modules/mod_joomleague_matches/tmpl/'.$this->value.'/template.png', 
105						   'TemplateImage', 'id="TemplateImage" width="200"')
106			    . '</td>'
107			    . '</tr>'
108		        . '</table>';
109
110		return $select;
111	}
112}
113