function autol_moduleContent($name) { $settings = Graphene::getInstance()->getSettings(); $modPath = $settings['modulesUrl']; $name = str_replace('\\', '/', $name); $filename = $modPath . "/" . $name . ".php"; if (is_readable(G_path($filename))) { G_Require($filename); } }
function G_Require($path) { $absolute = G_path($path); if (is_readable($absolute)) { Log::debug('COMPLETED Require of: ' . $absolute); /** @noinspection PhpIncludeInspection */ require_once $absolute; } else { Log::err('FAILED Require of: ' . $absolute); } }
public static function path($path = null) { return G_path($path); }
private function resolveImports($actions) { $retActions = array(); foreach ($actions as $ak => $action) { if (!array_key_exists('imported', $action)) { $actions[$ak]['imported'] = 'false'; } if (str_starts_with($action['name'], '$')) { $injectionPath = strtoupper(substr($action['name'], 1)); if (!str_contains($injectionPath, '/')) { $injectionPath = G_path('imports/' . $injectionPath); } Log::debug('resolving import: ' . $injectionPath); $stdActions = array(); /* * * Loading and converting from files to stdAction syntax * * */ //XML CASE if (file_exists($injectionPath . '/manifest.xml')) { $impXml = json_decode(json_encode(simplexml_load_file($injectionPath . '/manifest.xml')), true); if (array_key_exists('action', $impXml)) { foreach ($impXml['action'] as $k => $xmlAction) { $stdActions[] = $impXml['action'][$k]['@attributes']; } } } elseif (file_exists($injectionPath . '/manifest.json')) { $jsonStr = file_get_contents($injectionPath . '/manifest.json'); $impJson = json_decode($jsonStr, true); if (array_key_exists('actions', $impJson)) { $stdActions = $impJson['actions']; } } else { Log::err('manifest file not found in: ' . $injectionPath); } //Finalizing import foreach ($stdActions as $k => $v) { if (!str_starts_with($v['name'], '$')) { $expl = explode('@', $v['handler']); $stdActions[$k]['handler'] = $expl[0] . '@' . $injectionPath . '/' . $expl[1]; $stdActions[$k]['imported'] = 'true'; if (array_key_exists('pars', $action)) { $stdActions[$k]['pars'] = $action['pars']; } if (array_key_exists('query-prefix', $action)) { $stdActions[$k]['query-prefix'] = $action['query-prefix']; } if (array_key_exists('name-prefix', $action)) { $stdActions[$k]['name-prefix'] = $action['name-prefix']; } } } $retActions = array_merge($retActions, $this->resolveImports($stdActions)); } else { $retActions[] = $actions[$ak]; } } return $retActions; }