CMS  Version 3.9
CodeFileSelectFieldRenderer Class Reference

Inherits SelectFieldRenderer.

Public Member Functions

 CodeFileSelectFieldRenderer (&$form, $field, $label, $directory, $onChange="")
 
 readFiles ($home, $dir, $prefix=null)
 
 getFilesInPath (&$options, $home, $dir, $prefix)
 

Detailed Description

Definition at line 42 of file code_file_select_field_renderer.inc.

Member Function Documentation

◆ CodeFileSelectFieldRenderer()

CodeFileSelectFieldRenderer::CodeFileSelectFieldRenderer ( $form,
  $field,
  $label,
  $directory,
  $onChange = "" 
)

Definition at line 44 of file code_file_select_field_renderer.inc.

45  {
46  trace("Scanning Modules", 3);
47 
48  global $config;
49  $path = $config["homedir"]."/".$directory;
50 
51  $options = array("" => array("" => ""));
52  $options = array_merge($options, array("General Code Files" => $this->readFiles($config["homedir"], $directory)));
53 
55  trace(count($components)." components", 3);
56  foreach($components as $name => $component)
57  {
58  trace("Scanning $name", 3);
59  $modules = $this->readFiles($component->component_path, $directory, $name);
60  if (count($modules) > 0)
61  {
62  $options = array_merge($options, array(prettify($name)." Modules" => $modules));
63  }
64  }
65 
66  $this->SelectFieldRenderer($form, $field, $label, $options, $onChange, true);
67  $this->allowBlank();
68  }
$form
$component
Definition: help.inc:38
if(! $page) $path
Definition: page.inc:57
$components
Definition: tree.inc:41
$name
Definition: upload.inc:54
static getComponents()
Retrieve an array of all the currently enabled components, indexed by component name.
Definition: core.inc:206
global $config
Definition: import.inc:4

◆ getFilesInPath()

CodeFileSelectFieldRenderer::getFilesInPath ( $options,
  $home,
  $dir,
  $prefix 
)

Definition at line 87 of file code_file_select_field_renderer.inc.

88  {
89  $path = $home . DIRECTORY_SEPARATOR . $dir;
90 
91  trace("Reading $path", 3);
92 
93  if (!file_exists($path))
94  {
95  return $options;
96  }
97 
98  $handle = opendir($path);
99  $folders = array();
100 
101  while(false !== ($file = readdir($handle)))
102  {
103  trace($file, 4);
104 
105  if ($file != "." &&
106  $file != ".." &&
107  $file != ".svn" &&
108  $file != "CVS")
109  {
110  $f = "$path/$file";
111  $l = "$dir/$file";
112  trace("f is $f and l is $l", 3);
113 
114  if (is_dir($f) AND $file != "include")
115  {
116  array_push($folders, $l);
117  }
118  else if (preg_match('/.inc$/i', $file))
119  {
120  if ($prefix)
121  {
122  $options["$prefix,$l"] = $l;
123  }
124  else
125  {
126  $options[$l] = $l;
127  }
128  }
129  }
130  }
131  closedir($handle);
132  return $folders;
133  }
$dir
Definition: delete.inc:44
$file
Definition: delete.inc:47
$f
Definition: download.inc:46
if(php_sapi_name() !="cli") $home
Definition: run.php:39

◆ readFiles()

CodeFileSelectFieldRenderer::readFiles (   $home,
  $dir,
  $prefix = null 
)

Definition at line 70 of file code_file_select_field_renderer.inc.

71  {
72  $options = array();
73 
74  $folders = $this->getFilesInPath($options, $home, $dir, $prefix);
75  if(count($folders) > 0)
76  {
77  foreach($folders as $folder)
78  {
79  trace("calling getFilesInPath for folder $folder", 3);
80  $this->getFilesInPath($options, $home, $folder, $prefix);
81  }
82  }
83  return $options;
84 
85  }
$folder
Definition: templates.inc:41
getFilesInPath(&$options, $home, $dir, $prefix)

The documentation for this class was generated from the following file: