CMS  Version 3.9
ComponentManager Class Reference

ComponentManager provides the core functionality for building the component map describing the application configuration. More...

Public Member Functions

 ComponentManager ()
 Creates a new ComponentManager object. More...
 
 scanComponents ($root, $subdir)
 Scan the specified root and sub-directory for components. More...
 
 scanAdminPages ($component)
 Builds the administration page map for the specified component. More...
 
 scanComponentPages ($component)
 Scan and build the compoment page map for the specified component. More...
 
 scan ($verbosity=0)
 Scans the application home directory and PHP include path and builds the component and administration page map that describe the configuration of the application. More...
 
 getComponent ($component)
 Retrieve the component definition record for the specified component. More...
 
 dispatchAction ($process=null)
 Dispatch an incoming user action to the appropriate component handler script. More...
 
 dispatchLocalAction ($action, $process=null)
 

Static Public Member Functions

static scanTrace ($message, $level)
 
static findComponentPath ($name)
 Locate the component path for the named component using the standard precedence rules. More...
 
static getEventHandlers ()
 Retrieve the event handler map. More...
 
static compareByPriority ($item1, $item2)
 Priority comparison callback - not for external use. More...
 
static fireEvent ($event, $parameter=null, $mustBeConsumed=false)
 Fire an event to all subscribers as detailed in their manifests. More...
 
static fireEventTo ($event, $component, $parameter=null)
 Fire an event to the specificed component. More...
 
static displayPage ($identifier, &$continue)
 
static enumerateComponentPages ($items)
 
static deleteRole ($del_role)
 
static setComponentVersion ($component_name)
 
static upgradeComponent ($version)
 
static componentListTabs ()
 
static componentPageTabs ($key)
 
static componentFormTabs ($key)
 
static setDefaults ()
 
static getComponentSignature ()
 Retrieves a unique signature for the application's enabled components, based on their installed version numbers. More...
 

Public Attributes

 $found = array()
 

Static Public Attributes

static $verbosityLevel = 0
 Verbosity level for component scan (same as trace level) More...
 
static $plainOutput = false
 Set to true for plain text output during component scan. More...
 

Detailed Description

ComponentManager provides the core functionality for building the component map describing the application configuration.

It also scans components to build the administration section page map, and provides an event dispatching mechanism allowing PHP or client-side scripts to pass events or perform actions on a component without directly instantiating any classes related to the component.

Author
andy

Definition at line 49 of file component_manager.inc.

Member Function Documentation

◆ compareByPriority()

static ComponentManager::compareByPriority (   $item1,
  $item2 
)
static

Priority comparison callback - not for external use.

Parameters
array$item1
array$item2
Returns
integer comparison value

Definition at line 430 of file component_manager.inc.

431  {
432  return $item1["priority"] - $item2["priority"];
433  }

◆ componentFormTabs()

static ComponentManager::componentFormTabs (   $key)
static

Definition at line 795 of file component_manager.inc.

796  {
797  $tabs = array( "Definition" => "/admin/component_form",
798  "Component Pages" => "/admin/component_pages",
799  "Version History" => "/admin/component_versions"
800  );
801 
802  $qs = ($key) ? "component_id=$key" : "";
803  $bar = new TabBar("tabs", $tabs, $qs);
804 
805  return $bar;
806  }
$tabs

◆ componentListTabs()

static ComponentManager::componentListTabs ( )
static

Definition at line 772 of file component_manager.inc.

773  {
774  $tabs = array( "Components" => "/admin/components",
775  "Component Pages" => "/admin/component_pages"
776  );
777 
778  $bar = new TabBar("tabs", $tabs, "");
779  $bar->useQueryString = false;
780 
781  return $bar;
782  }

◆ ComponentManager()

ComponentManager::ComponentManager ( )

Creates a new ComponentManager object.

Definition at line 80 of file component_manager.inc.

81  {
82  }

◆ componentPageTabs()

static ComponentManager::componentPageTabs (   $key)
static

Definition at line 784 of file component_manager.inc.

785  {
786  $tabs = array( "Definition" => "/admin/component_page_form",
787  "Modules" => "/admin/component_page_modules");
788 
789  $qs = ($key) ? "component_page_id=$key" : "";
790  $bar = new TabBar("tabs", $tabs, $qs);
791 
792  return $bar;
793  }

◆ deleteRole()

static ComponentManager::deleteRole (   $del_role)
static

Definition at line 730 of file component_manager.inc.

731  {
732  $constraint = "WHERE role like '%$del_role%'";
733  $componentPages = Query::create(ComponentPage, $constraint)->execute();
734 
735  RoleManager::deleteRoleFromString($componentPages, $del_role);
736 
737  return $del_role;
738 
739  }
$constraint
static deleteRoleFromString(&$items, $del_role, $field="")

◆ dispatchAction()

ComponentManager::dispatchAction (   $process = null)

Dispatch an incoming user action to the appropriate component handler script.

Parameters
string$process(optional) process identifier if running as a background process

Definition at line 545 of file component_manager.inc.

546  {
547  global $script;
548  global $isAction;
549  $isAction = true;
550 
551  $component = $this->getComponent($_REQUEST["component"]);
552  $action = $_REQUEST["action"];
553 
554  if (!preg_match("/^[\\w\\d_\\.]+$/", $action))
555  {
556  throw new FakoliException("Invalid action");
557  }
558 
559  $this->fireEventTo("PreAction", $component->name, $action);
560 
561  ob_start();
562 
563  $this->dispatchActionInternal($process);
564 
565  $out = ob_get_contents();
566  ob_end_clean();
567 
568  echo $script;
569  echo $out;
570 
571  $this->fireEventTo("PostAction", $component->name, $action);
572 
573  ComponentManager::fireEvent("RequestComplete");
574  }
$component
Definition: help.inc:38
$out
Definition: page.inc:66
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
getComponent($component)
Retrieve the component definition record for the specified component.
static fireEventTo($event, $component, $parameter=null)
Fire an event to the specificed component.
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
if($config["default_content_type"]) $isAction
Definition: core.inc:1584
$process
Definition: run.php:54
$action
Definition: run.php:41

◆ dispatchLocalAction()

ComponentManager::dispatchLocalAction (   $action,
  $process = null 
)

Definition at line 625 of file component_manager.inc.

626  {
627  global $method;
628 
629  trace($action, 3);
630 
631  list($uri, $queryString) = explode("?", $action);
632 
633  trace("URI: $uri, Query String: $queryString", 3);
634 
635  list($empty, $prefix, $component, $action) = explode("/", $uri);
636 
637  trace("Prefix: $prefix, Component: $component, Action: $action", 3);
638 
639  if ($prefix != "action")
640  {
641  throw new FakoliException("Malformed action handler");
642  }
643 
644  $context = array(
645  "_GET" => $_GET,
646  "_REQUEST" => $_REQUEST,
647  "_SERVER" => $_SERVER,
648  "method" => $method
649  );
650 
651  parse_str($queryString, $_GET);
652 
653  //trace("\$_GET: " . json_encode($_GET), 3);
654 
655  $_SERVER["REQUEST_URI"] = $uri;
656 
657  $_GET["component"] = $component;
658  $_GET["action"] = $action;
659 
660  $_REQUEST["component"] = $component;
661  $_REQUEST["action"] = $action;
662 
663  ob_start();
664 
665  try
666  {
667  $this->dispatchActionInternal($process);
668  }
669  catch(Exception $e)
670  {
671  trace($e->getMessage(), 3);
672  echo $e->getMessage();
673  }
674 
675  $output = ob_get_contents();
676  ob_end_clean();
677 
678  //trace(print_r($context, true), 3);
679 
680  foreach($context as $name => $value)
681  {
682  $$name = $value;
683  }
684 
685  return $output;
686  }
$name
Definition: upload.inc:54
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$output
Definition: generate.inc:9
$uri
Definition: tearoff.inc:4

◆ displayPage()

static ComponentManager::displayPage (   $identifier,
$continue 
)
static

Definition at line 688 of file component_manager.inc.

689  {
690  global $page_role;
691 
692  try
693  {
694  checkIdentifier($identifier);
695 
696  $page = ComponentPage::findByIdentifier($identifier, "WHERE enabled=1");
697 
698  // JDG 11/2011 - are templates ever stored with tpl at the end??
699  $page_template = (preg_match("/tpl$/", $page->template)) ? $page->template : "{$page->template}.tpl";
700  $pageView = new ComponentPageView($page, $page_template);
701 
702  $page_role = $page->role;
703 
704  if (!checkRole($page->role))
705  {
707  redirect("/login");
708  }
709 
710  echo $pageView->drawView();
711 
712  $continue = false;
713  }
714  catch(DataNotFoundException $e)
715  {
716 
717  }
718 
719  return $identifier;
720  }
$page
Definition: help.inc:39
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
$identifier
Definition: rss.inc:37

◆ enumerateComponentPages()

static ComponentManager::enumerateComponentPages (   $items)
static

Definition at line 722 of file component_manager.inc.

723  {
724  $pages = Query::create(ComponentPage, "ORDER BY identifier")->execute();
725 
726  $items["Component Pages"] = $pages;
727  return $items;
728  }
$pages
Definition: export.inc:38

◆ findComponentPath()

static ComponentManager::findComponentPath (   $name)
static

Locate the component path for the named component using the standard precedence rules.

Parameters
string$name

Definition at line 333 of file component_manager.inc.

334  {
335  global $config;
336 
337  $path .= $config['homedir'] . PATH_SEPARATOR . ini_get("include_path");
338 
339  if (isset($config["extra_includes"])) $path .= PATH_SEPARATOR . $config["extra_includes"];
340 
341  $roots = explode(PATH_SEPARATOR, $path);
342 
343  foreach($roots as $root)
344  {
345  if ($root == ".") continue;
346 
347  $path = $root . DIRECTORY_SEPARATOR . "cms" . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . $name;
348 
349  if (file_exists($path))
350  {
351  if (!file_exists($path.DIRECTORY_SEPARATOR."DEPRECATED")) return $path;
352  }
353 
354  $path = $root . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . $name;
355 
356  if (file_exists($path))
357  {
358  if (!file_exists($path.DIRECTORY_SEPARATOR."DEPRECATED")) return $path;
359  }
360  }
361 
362  return null;
363  }
if(! $page) $path
Definition: page.inc:57
$root
global $config
Definition: import.inc:4

◆ fireEvent()

static ComponentManager::fireEvent (   $event,
  $parameter = null,
  $mustBeConsumed = false 
)
static

Fire an event to all subscribers as detailed in their manifests.

Parameters
string$eventthe name of the event
array$parameterany parameters being passed to the event
boolean$mustBeConsumedif set to true, throws FakoliEventNotConsumed if no event handler has indicated consumption of the event by setting $continue to false

Definition at line 442 of file component_manager.inc.

443  {
444  trace("** Firing event '$event'", 4);
445 
447 
448  if (!array_key_exists($event, $eventMap))
449  {
450  trace("No handlers subscribed to '$event'", 4);
451  return $parameter;
452  }
453 
454  $continue = true;
455 
456  foreach($eventMap[$event] as $subscription)
457  {
458  Fakoli::using($subscription["component"]);
459 
460  if (is_array($subscription["handler"]))
461  {
462  trace("Handling $event with {$subscription["handler"][0]}::{$subscription["handler"][1]}", 4);
463  }
464  else
465  {
466  trace("Handling $event with {$subscription["handler"]}", 4);
467  }
468 
469  if (!is_callable($subscription["handler"]))
470  {
471  if (is_array($subscription["handler"]))
472  {
473  trace("Subscription handler {$subscription["handler"][0]}::{$subscription["handler"][1]} for $event is invalid", 2);
474  }
475  else
476  {
477  trace("Subscription handler $event with {$subscription["handler"]} for $event is invalid", 2);
478  }
479 
480  trace(printIncludes(false, true), 3);
481  }
482  else
483  {
484  $parameter = call_user_func_array($subscription["handler"], array($parameter, &$continue));
485  }
486  if (!$continue) break;
487  }
488 
489  if ($mustBeConsumed && $continue)
490  {
491  throw new FakoliEventNotConsumed("'$event' not handled by any subscriber");
492  }
493 
494  return $parameter;
495  }
$event
Definition: event_form.inc:46
static getEventHandlers()
Retrieve the event handler map.
FakoliEventNotConsumed is thrown when no subscriber has handled an event that was fired with $mustBeC...
Definition: core.inc:69
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
$eventMap
Definition: event_map.inc:9

◆ fireEventTo()

static ComponentManager::fireEventTo (   $event,
  $component,
  $parameter = null 
)
static

Fire an event to the specificed component.

If the component is not subscribed the event is ignored.

Parameters
string$eventthe name of the event
string$componentThe name of the target component
array$parameterany parameters being passed to the event

Definition at line 504 of file component_manager.inc.

505  {
506  trace("** Firing event '$event' to $component", 4);
507 
509 
510  if (!array_key_exists($event, $eventMap))
511  {
512  trace("No handlers subscribed to '$event'", 4);
513  return $parameter;
514  }
515 
516  foreach($eventMap[$event] as $subscription)
517  {
518  if ($component == $subscription["component"])
519  {
520 
521  Fakoli::using($subscription["component"]);
522 
523  if (is_array($subscription["handler"]))
524  {
525  trace("Handling $event with {$subscription["handler"][0]}::{$subscription["handler"][1]}", 4);
526  }
527  else
528  {
529  trace("Handling $event with {$subscription["handler"]}", 4);
530  }
531 
532  $parameter = call_user_func_array($subscription["handler"], array($parameter, &$continue));
533  break;
534  }
535  }
536 
537  return $parameter;
538  }

◆ getComponent()

ComponentManager::getComponent (   $component)

Retrieve the component definition record for the specified component.

Parameters
$componentthe name of the component
Returns
Component the record for the specified component

Definition at line 370 of file component_manager.inc.

371  {
373 
374  if (!array_key_exists($component, $components))
375  {
376  throw new FakoliException("Unrecognized or disabled component '$component'");
377  }
378  return $components[$component];
379  }
$components
Definition: tree.inc:41
static getComponents()
Retrieve an array of all the currently enabled components, indexed by component name.
Definition: core.inc:206

◆ getComponentSignature()

static ComponentManager::getComponentSignature ( )
static

Retrieves a unique signature for the application's enabled components, based on their installed version numbers.

This enables the administrator to determine at a glance if the configuration of two Fakoli servers is the same.

Definition at line 827 of file component_manager.inc.

828  {
829  $str = "";
830 
832  foreach($components as $component)
833  {
835  $str .= $component->name.":".$version."|";
836  }
837 
838  return sha1($str);
839  }
static getLatestVersion($component)

◆ getEventHandlers()

static ComponentManager::getEventHandlers ( )
static

Retrieve the event handler map.

The map is generated on the first request and cached for future reference.

Returns
array the event handler map

Definition at line 386 of file component_manager.inc.

387  {
388  $eventMap = Cache::get("fakoli_event_map");
389  if ($eventMap) return $eventMap;
390 
391  ComponentManager::scanTrace("Mapping Event Handlers", 3);
392  $components = Query::create(Component, "WHERE enabled=1 ORDER BY priority")->execute();
393 
394  $eventMap = array();
395 
396  foreach($components as $component)
397  {
398  $manifest = $component->loadManifest();
399 
400  if (!$manifest || !method_exists($manifest, subscribeToEvents)) continue;
401 
402  $subscriptions = $manifest->subscribeToEvents();
403 
404  foreach($subscriptions as $event => $handler)
405  {
406  $handlerRecord = array("component" => $component->name, "priority" => $component->priority, "handler" => $handler);
407 
408  ComponentManager::scanTrace(" $component->name is subscribing to $event", 3);
409  if (array_key_exists($event, $eventMap))
410  {
411  $eventMap[$event][] = $handlerRecord;
412  }
413  else
414  {
415  $eventMap[$event] = array($handlerRecord);
416  }
417  }
418  }
419 
420  Cache::put("fakoli_event_map", $eventMap);
421  return $eventMap;
422  }
$handler
Definition: event_form.inc:62
static scanTrace($message, $level)

◆ scan()

ComponentManager::scan (   $verbosity = 0)

Scans the application home directory and PHP include path and builds the component and administration page map that describe the configuration of the application.

Definition at line 246 of file component_manager.inc.

247  {
248  global $config;
249 
250  Fakoli::$scanning = true;
252 
253  $this->tx = new DataTransaction();
254 
255  try
256  {
257 
258  $c = new Component();
259  $c->joinTransaction($this->tx);
260  $c->deleteAll();
261 
262 
263  $p = new AdminPage();
264  $p->joinTransaction($this->tx);
265  $p->deleteAll();
266 
267  $cp = new ComponentPage();
268  $cp->joinTransaction($this->tx);
269  $cp->updateExplicit("SET scanned=0");
270 
271  $path .= $config['homedir'] . PATH_SEPARATOR . ini_get("include_path");
272 
273  if (isset($config["extra_includes"])) $path .= PATH_SEPARATOR . $config["extra_includes"];
274 
275  $roots = explode(PATH_SEPARATOR, $path);
276 
277  foreach($roots as $root)
278  {
279  if ($root == ".") continue;
280 
281  ComponentManager::scanTrace("Scanning $root for components", 2);
282  $this->scanComponents($root, "cms/components");
283  $this->scanComponents($root, "components");
284  }
285 
286  Cache::invalidate("fakoli_components");
287  Cache::invalidate("fakoli_admin_menu");
288  Cache::invalidate("fakoli_admin_icons");
289  Cache::invalidate("fakoli_scripts");
290  Cache::invalidate("fakoli_styles");
291  Cache::invalidate("fakoli_event_map");
292 
293  $cp->delete("WHERE scanned=0");
294 
295 
296  $this->tx->commit();
297  unset($this->tx);
298 
299  $components = indexedQuery(Component, "WHERE enabled=1", "name");
300  Cache::put("fakoli_components", $components);
301 
302  ComponentManager::fireEvent("upgradeComponent");
303 
304  ComponentManager::fireEvent("ComponentScanComplete");
305 
306  Fakoli::$scanning = false;
307  }
308  catch(Exception $e)
309  {
310  // JDG 6/1/2011 - if fails on ComponentScanComplete
311  if(isset($this->tx))
312  $this->tx->rollback();
313  unset($this->tx);
314 
315  Fakoli::$scanning = false;
316 
318  {
319  echo $e->__toString();
320  }
321  else
322  {
323  throw $e;
324  }
325  }
326  }
static $verbosityLevel
Verbosity level for component scan (same as trace level)
scanComponents($root, $subdir)
Scan the specified root and sub-directory for components.
static $scanning
Semaphore indicating that a component scan is in progress.
Definition: core.inc:82
if(!checkRole("admin") && $_SERVER["REMOTE_ADDR"] !=$_SERVER["SERVER_ADDR"] && $_SERVER["REMOTE_ADDR"] !=gethostbyname($config['http_host']) && $_SERVER["REMOTE_ADDR"] !="127.0.0.1") if($_SERVER["REMOTE_ADDR"]=="127.0.0.1" &&array_key_exists("clear", $_GET)) $verbosity
Definition: scan.inc:49
if(!checkRole("admin")) $c

◆ scanAdminPages()

ComponentManager::scanAdminPages (   $component)

Builds the administration page map for the specified component.

Parameters
$componentthe component being scanned

Definition at line 166 of file component_manager.inc.

167  {
168  if (!$component->enabled) return;
169 
170  $admin = $component->component_path . DIRECTORY_SEPARATOR . "admin";
171 
172  if (!is_dir($admin)) return;
173 
174  ComponentManager::scanTrace("== Scanning $admin", 3);
175 
176  $handle = opendir($admin);
177 
178  while(false !== ($file = readdir($handle)))
179  {
180  if (endsWith($file, ".inc"))
181  {
182  $page = new AdminPage();
183  $page->identifier = preg_replace("/\\.inc$/", "", $file);
184  $page->server_path = $admin . DIRECTORY_SEPARATOR . $file;
185  $page->component_id = $component->component_id;
186  $page->joinTransaction($this->tx);
187  $page->save();
188  Cache::invalidate("fakoli_admin_pages_{$page->identifier}");
189  }
190  }
191 
192  }
$file
Definition: delete.inc:47

◆ scanComponentPages()

ComponentManager::scanComponentPages (   $component)

Scan and build the compoment page map for the specified component.

Parameters
$componentthe component to be scanned.

Definition at line 198 of file component_manager.inc.

199  {
200  $pages = $component->component_path . DIRECTORY_SEPARATOR . "pages";
201 
202  if (!is_dir($pages)) return;
203  ComponentManager::scanTrace("== Scanning $pages", 3);
204 
205  $handle = opendir($pages);
206 
207  while(false !== ($file = readdir($handle)))
208  {
209  if (endsWith($file, ".inc"))
210  {
211  $identifier = preg_replace("/\\.inc$/", "", $file);
212 
213  try
214  {
215  $page = Query::create(ComponentPage, "WHERE component=:c AND identifier=:i")
216  ->bind(":c", $component->name, ":i", $identifier)
217  ->executeSingle();
218 
219  $page->scanned = true;
220  $page->server_path = $pages . DIRECTORY_SEPARATOR . $file;
221  $page->filter = new InclusionFilter("component_page_id", "server_path", "scanned");
222  $page->save();
223  }
224  catch(DataNotFoundException $e)
225  {
226  $page = new ComponentPage();
227  $page->page_title = prettify($identifier);
228  $page->identifier = $identifier;
229  $page->component = $component->name;
230  $page->server_path = $pages . DIRECTORY_SEPARATOR . $file;
231  $page->role = "";
232  $page->enabled = true;
233  $page->scanned = true;
234  $page->save();
235  }
236  }
237  }
238 
239  }

◆ scanComponents()

ComponentManager::scanComponents (   $root,
  $subdir 
)

Scan the specified root and sub-directory for components.

Parameters
$root
$subdir

Definition at line 90 of file component_manager.inc.

91  {
92  if (!$root || $root == ".") return;
93 
94  $path = $root . DIRECTORY_SEPARATOR . str_replace("/", DIRECTORY_SEPARATOR, $subdir);
95 
96  ComponentManager::scanTrace("Scanning $path", 2);
97 
98  if (is_dir($path))
99  {
100  $handle = opendir($path);
101  while(false !== ($file = readdir($handle)))
102  {
103  $f = $path . DIRECTORY_SEPARATOR . $file;
104  $m = $f . DIRECTORY_SEPARATOR . "manifest.inc";
105  $d = $f . DIRECTORY_SEPARATOR . "DEPRECATED";
106 
107  if (is_dir($f))
108  {
109  ComponentManager::scanTrace("== Found component '$file'", 3);
110  if (is_file($d))
111  {
112  ComponentManager::scanTrace("**** Deprecated component - ignoring", 3);
113  Cache::invalidate("fakoli_includes_$file");
114  continue;
115  }
116 
117  if ($this->found[$file])
118  {
119  ComponentManager::scanTrace("---- already defined - skipping", 3);
120  continue;
121  }
122 
123  if (!is_file($m))
124  {
125  ComponentManager::scanTrace("== No manifest found. Skipping...", 3);
126  continue;
127  }
128 
129  require_once $m;
130 
131  $cl = Fakoli::getComponentClassRoot($file) . "Manifest";
132 
133  try
134  {
135  ComponentManager::scanTrace("== Instantiating $cl", 3);
136 
137  $manifest = new $cl;
138  $component = $manifest->getComponentDefinition();
139  $component->component_path = sanitizePath($f);
140  $component->joinTransaction($this->tx);
141  $component->save();
142 
143  $this->found[$file] = $component;
144 
145  $this->scanAdminPages($component);
147 
148  }
149  catch(Exception $e)
150  {
151  ComponentManager::scanTrace("-- Failed to instantiate manifest class. Skipping...", 3);
152  }
153 
154  Cache::invalidate("fakoli_includes_$file");
155  }
156  }
157 
158  closedir($handle);
159  }
160  }
$f
Definition: download.inc:46
scanAdminPages($component)
Builds the administration page map for the specified component.
scanComponentPages($component)
Scan and build the compoment page map for the specified component.
static getComponentClassRoot($name)
Retrieves the capitalized camlCase name for the specified component.
Definition: core.inc:752
if(!checkRole($library->allow_access) &&! $library->allowAccess()) if(!checkRole($document->allow_access)) $d
Definition: download.inc:66

◆ scanTrace()

static ComponentManager::scanTrace (   $message,
  $level 
)
static

Definition at line 57 of file component_manager.inc.

58  {
59  global $config;
60 
62  {
63  if (!ComponentManager::$scanLog)
64  {
65  ComponentManager::$scanLog = $config['uploadbase'].DIRECTORY_SEPARATOR."component_scan_".date("Ymd-His").".log";
66  }
67 
68  error_log($message."\n", 3, ComponentManager::$scanLog);
69 
70  echo $message;
71  echo (ComponentManager::$plainOutput) ? "\n" : "<br/>";
72  }
73 
74  trace($message, $level);
75  }
static $plainOutput
Set to true for plain text output during component scan.
$message
Definition: mail_to.inc:49

◆ setComponentVersion()

static ComponentManager::setComponentVersion (   $component_name)
static

Definition at line 741 of file component_manager.inc.

742  {
743  $components = Query::create(Component, "WHERE name=:component_name")
744  ->bind(":component_name", $component_name)
745  ->execute();
746 
747  if(count($components) == 0)
748  return;
749 
750  $component = $components[0];
751 
752  $latest_version = ComponentUpdateLog::getLatestVersion($component_name);
753 
754  // To do - set inital values in table for existing components to start
755 
756  if($latest_version && $latest_version != $component->version)
757  {
758  $component->version = $latest_version;
759  $component->filter = new InclusionFilter("version");
760  $component->save();
761  }
762 
763  }

◆ setDefaults()

static ComponentManager::setDefaults ( )
static

Definition at line 808 of file component_manager.inc.

809  {
810  trace("ComponentManager::setDefaults", 3);
811  global $config;
812 
813  $defaultPath = $config['uploadbase'] . DIRECTORY_SEPARATOR . "upgrade_output_path";
814  if (!file_exists($defaultPath)) mkdir($defaultPath);
815 
816  Settings::setDefaultValue("component", "upgrade_output_path", $defaultPath, "String");
817  Settings::setDefaultValue("settings", "enable_inline_editing", false, "Boolean", "Turns on or off inline editing capabilities (for those components that support this option)", "General");
818  Settings::setDefaultPermission("settings", "editor_roles", "Roles for whom inline editing controls are to be shown", "admin");
819  }
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
static setDefaultPermission($component, $name, $annotation, $value, $weight=0)
Set a default Permission value indicating which SiteRoles have the given permission.
Definition: settings.inc:230

◆ upgradeComponent()

static ComponentManager::upgradeComponent (   $version)
static

Definition at line 765 of file component_manager.inc.

766  {
768  $mgr->upgrade($version);
769  }

Member Data Documentation

◆ $found

ComponentManager::$found = array()

Definition at line 51 of file component_manager.inc.

◆ $plainOutput

ComponentManager::$plainOutput = false
static

Set to true for plain text output during component scan.

Definition at line 54 of file component_manager.inc.

◆ $verbosityLevel

ComponentManager::$verbosityLevel = 0
static

Verbosity level for component scan (same as trace level)

Definition at line 53 of file component_manager.inc.


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