PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_flexicontent/elements/types.php

http://flexicontent.googlecode.com/
PHP | 91 lines | 53 code | 9 blank | 29 comment | 11 complexity | f9e2ca710fb0edf0428ef7fb42c90f5e MD5 | raw file
Possible License(s): MIT, GPL-2.0, Apache-2.0
  1. <?php
  2. /**
  3. * @version 1.5 stable $Id: types.php 1800 2013-11-01 04:30:57Z ggppdk $
  4. * @package Joomla
  5. * @subpackage FLEXIcontent
  6. * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
  7. * @license GNU/GPL v2
  8. *
  9. * FLEXIcontent is a derivative work of the excellent QuickFAQ component
  10. * @copyright (C) 2008 Christoph Lukes
  11. * see www.schlu.net for more information
  12. *
  13. * FLEXIcontent is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. // Check to ensure this file is included in Joomla!
  19. defined('_JEXEC') or die('Restricted access');
  20. if (FLEXI_J16GE) {
  21. jimport('joomla.html.html');
  22. jimport('joomla.form.formfield');
  23. }
  24. /**
  25. * Renders a types element
  26. *
  27. * @package Joomla
  28. * @subpackage FLEXIcontent
  29. * @since 1.5
  30. */
  31. class JElementTypes extends JElement
  32. {
  33. /**
  34. * Element name
  35. * @access protected
  36. * @var string
  37. */
  38. var $_name = 'Types';
  39. function fetchElement($name, $value, &$node, $control_name)
  40. {
  41. $doc = JFactory::getDocument();
  42. $db = JFactory::getDBO();
  43. if (FLEXI_J16GE) {
  44. $node = & $this->element;
  45. $attributes = get_object_vars($node->attributes());
  46. $attributes = $attributes['@attributes'];
  47. } else {
  48. $attributes = & $node->_attributes;
  49. }
  50. $query = 'SELECT id AS value, name AS text'
  51. . ' FROM #__flexicontent_types'
  52. . ' WHERE published = 1'
  53. . ' ORDER BY name ASC, id ASC'
  54. ;
  55. $db->setQuery($query);
  56. $types = $db->loadObjectList();
  57. $values = FLEXI_J16GE ? $this->value : $value;
  58. if ( empty($values) ) $values = array();
  59. else if ( ! is_array($values) ) $values = !FLEXI_J16GE ? array($values) : explode("|", $values);
  60. $fieldname = FLEXI_J16GE ? $this->name : $control_name.'['.$name.']';
  61. $element_id = FLEXI_J16GE ? $this->id : $control_name.$name;
  62. $attribs = 'style="float:left;"';
  63. if (@$attributes['multiple']=='multiple' || @$attributes['multiple']=='true' ) {
  64. $attribs .= ' multiple="true" ';
  65. $attribs .= (@$attributes['size']) ? ' size="'.$attributes['size'].'" ' : ' size="6" ';
  66. $fieldname .= !FLEXI_J16GE ? "[]" : ""; // NOTE: this added automatically in J2.5
  67. $maximize_link = "<a style='display:inline-block;".(FLEXI_J16GE ? 'float:left; margin: 6px 0px 0px 18px;':'margin:0px 0px 6px 12px')."' href='javascript:;' onclick='$element_id = document.getElementById(\"$element_id\"); if ($element_id.size<16) { ${element_id}_oldsize=$element_id.size; $element_id.size=16;} else { $element_id.size=${element_id}_oldsize; } ' >Maximize/Minimize</a>";
  68. } else {
  69. if ( @ $attributes['user_selection'] )
  70. array_unshift($types, JHTML::_('select.option', '', JText::_('FLEXI_MENU_ALLOW_CONTENT_TYPE_SELECTION')));
  71. else
  72. array_unshift($types, JHTML::_('select.option', '', JText::_('FLEXI_PLEASE_SELECT')));
  73. $attribs .= 'class="inputbox"';
  74. $maximize_link = '';
  75. }
  76. if ($onchange = @$attributes['onchange']) {
  77. $attribs .= ' onchange="'.$onchange.'"';
  78. }
  79. $html = JHTML::_('select.genericlist', $types, $fieldname, $attribs, 'value', 'text', $values, $element_id);
  80. return $html.$maximize_link;
  81. }
  82. }