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

/contentmanager/code/trunk/administrator/components/com_contentmanager/helpers/elements/list/layout.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 78 lines | 50 code | 12 blank | 16 comment | 7 complexity | f28950ad81c16bc04f981d294b558988 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: layout.php 80 2009-06-01 07:22:16Z eddieajau $
  4. * @copyright Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
  5. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  6. * @link http://www.theartofjoomla.com
  7. */
  8. // no direct access
  9. defined('_JEXEC') or die;
  10. /**
  11. * @package TAOJ.ContentManager
  12. * @subpackage com_contentmanager
  13. */
  14. class JElementList_Layout extends JElement
  15. {
  16. /**
  17. * @access protected
  18. * @var string
  19. */
  20. var $_name = 'List_Layout';
  21. function _getOptions(&$node)
  22. {
  23. global $mainframe;
  24. $options = array();
  25. $path1 = null;
  26. $path2 = null;
  27. // Load template entries for each menuid
  28. $db =& JFactory::getDBO();
  29. $query = 'SELECT template'
  30. . ' FROM #__templates_menu'
  31. . ' WHERE client_id = 0 AND menuid = 0';
  32. $db->setQuery($query);
  33. $template = $db->loadResult();
  34. if ($module = $node->attributes('module')) {
  35. $module = preg_replace('#\W#', '', $module);
  36. $path1 = JPATH_SITE.DS.'modules'.DS.$module.DS.'tmpl';
  37. $path2 = JPATH_SITE.DS.'templates'.DS.$template.DS.'html'.DS.$module;
  38. }
  39. else if ($view = $node->attributes('view')) {
  40. $view = preg_replace('#\W#', '', $view);
  41. $path1 = JPATH_SITE.DS.'components'.DS.'com_contentmanager'.DS.'views'.DS.$view.DS.'tmpl';
  42. $path2 = JPATH_SITE.DS.'templates'.DS.$template.DS.'html'.DS.'com_contentmanager'.DS.$view;
  43. }
  44. if ($path1 && $path2) {
  45. $options = JFolder::files($path1, '^[^_]*\.php$');
  46. array_unshift($options, '');
  47. if (is_dir($path2) && $temp = JFolder::files($path2, '^[^_]*\.php$')) {
  48. $options[] = '<em>'.JText::_('From Default Template').'</em>';
  49. $options = array_merge($options, $temp);
  50. array_unique($options);
  51. }
  52. }
  53. foreach ($options as $i => $option) {
  54. $options[$i] = JHtml::_('select.option', JFile::stripExt($option));
  55. }
  56. return $options;
  57. }
  58. function fetchElement($name, $value, &$node, $controlName)
  59. {
  60. jimport('joomla.filesystem.file');
  61. $size = ($node->attributes('size') ? 'size="'.$node->attributes('size').'"' : '');
  62. $class = ($node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="inputbox"');
  63. $options = $this->_getOptions($node);
  64. return JHtml::_('select.genericlist', $options, ''.$controlName.'['.$name.']', $class, 'value', 'text', $value, $controlName.$name);
  65. }
  66. }