PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/contentmanager/code/trunk/administrator/components/com_contentmanager/libraries/jxtended/form/fields/files.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 61 lines | 38 code | 7 blank | 16 comment | 4 complexity | 9aa1fd72c24e53378206b4f6341af24d MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: files.php 160 2009-07-09 00:06:09Z eddieajau $
  4. * @package JXtended.Libraries
  5. * @subpackage Form
  6. * @copyright Copyright (C) 2008 - 2009 JXtended, LLC. All rights reserved.
  7. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  8. * @link http://jxtended.com
  9. */
  10. defined('JPATH_BASE') or die;
  11. jimport('joomla.html.html');
  12. jximport2('jxtended.form.field');
  13. jximport2('jxtended.form.fields.list');
  14. /**
  15. * JXtended Form Field Type Class for a list of files.
  16. *
  17. * @package JXtended.Libraries
  18. * @subpackage Form
  19. * @version 1.0
  20. */
  21. class JXFieldTypeFiles extends JXFieldTypeList
  22. {
  23. function _getOptions(&$node)
  24. {
  25. jximport2('joomla.filesystem.folder');
  26. jximport2('joomla.filesystem.file');
  27. // path to images directory
  28. $path = JPATH_ROOT.DS.$node->attributes('directory');
  29. $filter = $node->attributes('filter');
  30. $exclude = $node->attributes('exclude');
  31. $stripExt = $node->attributes('stripext');
  32. $files = JFolder::files($path, $filter);
  33. $options = array ();
  34. if (is_array($files))
  35. {
  36. foreach ($files as $file)
  37. {
  38. if ($exclude)
  39. {
  40. if (preg_match(chr(1) . $exclude . chr(1), $file))
  41. {
  42. continue;
  43. }
  44. }
  45. if ($stripExt)
  46. {
  47. $file = JFile::stripExt($file);
  48. }
  49. $options[] = JHTML::_('select.option', $file, $file);
  50. }
  51. }
  52. return $options;
  53. }
  54. }