$needed) { // Check for circular references if (isset ($chain[$ref])) showError (tra ('error.internal_hook_circular', array ('source' => $id, 'target' => $ref))); // Check for required hook availability and dependencies if (isset ($gl_hooks[$ref])) hookRequire ($ref, $chain + array ($ref => 0), $result); else if ($needed) showError (tra ('error.internal_hook_needed', array ('source' => $id, 'target' => $ref))); } // Check if hook has already been registered foreach ($result as $i => $item) { if ($item['id'] == $id) return; } // Insert hook regarding its weights and already included dependencies if (is_file ($hook['path'])) { $min = -1; foreach ($hook['ref'] as $ref => $null) foreach ($result as $i => $item) if ($item['id'] == $ref) $min = max ($min, $i); for ($index = count ($result); $index > $min + 1 && $result[$index - 1]['weight'] > $hook['weight']; ) --$index; array_splice ($result, $index, 0, array (array ( 'access' => $hook['access'], 'id' => $id, 'module' => $hook['module'], 'path' => $hook['path'], 'weight' => $hook['weight'] ))); } else showError (tra ('error.internal_hook_file', array ('file' => $hook['file'], 'module' => tra ($hook['module'], array (), false)))); } ?>