本文整理汇总了PHP中HookRegistry::getHooks方法的典型用法代码示例。如果您正苦于以下问题:PHP HookRegistry::getHooks方法的具体用法?PHP HookRegistry::getHooks怎么用?PHP HookRegistry::getHooks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HookRegistry
的用法示例。
在下文中一共展示了HookRegistry::getHooks方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
/**
* Call each callback registered against $hookName in sequence.
* The first callback that returns a value that evaluates to true
* will interrupt processing and this function will return its return
* value; otherwise, all callbacks will be called in sequence and the
* return value of this call will be the value returned by the last
* callback.
* @param $hookName string The name of the hook to register against
* @param $args string Hooks are called with this as the second param
* @return mixed
*/
function call($hookName, $args = null)
{
$hooks =& HookRegistry::getHooks();
if (!isset($hooks[$hookName])) {
return false;
}
foreach ($hooks[$hookName] as $hook) {
if ($result = call_user_func($hook, $hookName, $args)) {
break;
}
}
return $result;
}
示例2: call
/**
* Call each callback registered against $hookName in sequence.
* The first callback that returns a value that evaluates to true
* will interrupt processing and this function will return its return
* value; otherwise, all callbacks will be called in sequence and the
* return value of this call will be the value returned by the last
* callback.
* @param $hookName string The name of the hook to register against
* @param $args string Hooks are called with this as the second param
* @return mixed
*/
function call($hookName, $args = null)
{
// For testing only.
// The implementation is a bit quirky as this has to work when
// executed statically.
if (self::rememberCalledHooks(true)) {
// Remember the called hooks for testing.
$calledHooks =& HookRegistry::getCalledHooks();
$calledHooks[] = array($hookName, $args);
}
$hooks =& HookRegistry::getHooks();
if (!isset($hooks[$hookName])) {
return false;
}
foreach ($hooks[$hookName] as $hook) {
if ($result = call_user_func($hook, $hookName, $args)) {
break;
}
}
return $result;
}
示例3: testExportUnregisteredDois
/**
* SCENARIO OUTLINE: see FunctionalDoiExportTest::testExportUnregisteredDois().
*
* EXAMPLES:
* export plug-in |objects |XML files
* =================|======================================|==============================================================================
* MedraExportPlugin|issue 1; article 1; galleys 1, 2 and 3|serial-article-as-{work,manifestation}-2.xml,serial-issue-as-manifestation.xml
*/
public function testExportUnregisteredDois()
{
$this->removeRegisteredDois('MedraExportPlugin');
$this->configurePlugin(array('exportIssuesAs' => O4DOI_ISSUE_AS_MANIFESTATION));
// Test whether exporting updates changes correctly
// sets the notification type.
$pluginInstance = $this->instantiatePlugin('MedraExportPlugin');
$hookName = 'articledao::getAdditionalFieldNames';
HookRegistry::register($hookName, array($pluginInstance, 'getAdditionalFieldNames'));
$articleDao = DAORegistry::getDAO('ArticleDAO');
$testObject = $articleDao->getArticle(1);
$testObject->setData('medra::' . DOI_EXPORT_REGDOI, '1749/t.v1i1.1');
$articleDao->updateArticle($testObject);
// Remove the hook.
$hooks = HookRegistry::getHooks();
foreach ($hooks[$hookName] as $index => $hook) {
if (is_a($hook[0], 'MedraExportPlugin')) {
unset($hooks[$hookName][$index]);
break;
}
}
$objects = array('issue' => 1, 'article' => 1, 'galley' => array(1, 2, 3));
$xmlFiles = array('serial-article-as-work-2.xml', 'serial-article-as-manifestation-2.xml', 'serial-issue-as-manifestation.xml');
parent::testExportUnregisteredDois('MedraExportPlugin', $objects, $xmlFiles);
}
示例4: getUsageEvent
/**
* Get usage event and pass it to the registered plugins, if any.
*/
function getUsageEvent($hookName, $args)
{
// Check if we have a registration to receive the usage event.
$hooks = HookRegistry::getHooks();
if (array_key_exists('UsageEventPlugin::getUsageEvent', $hooks)) {
$usageEvent = $this->_buildUsageEvent($hookName, $args);
HookRegistry::call('UsageEventPlugin::getUsageEvent', array_merge(array($hookName, $usageEvent), $args));
}
return false;
}
示例5: initialize
//.........这里部分代码省略.........
if ($dispatcher = $this->_request->getDispatcher()) {
$this->addStyleSheet('pkpLib', $dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
}
// Add reading language flag based on locale
$this->assign('currentLocaleLangDir', AppLocale::getLocaleDirection($locale));
// If there's a locale-specific stylesheet, add it.
if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
$this->addStyleSheet('pkpLibLocale', $this->_request->getBaseUrl() . '/' . $localeStyleSheet, array('contexts' => array('frontend', 'backend')));
}
// Register colour picker assets on the appearance page
$this->addJavaScript('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.js', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
$this->addStyleSheet('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.css', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
// Register recaptcha on relevant pages
if (Config::getVar('captcha', 'recaptcha') && Config::getVar('captcha', 'captcha_on_register')) {
$this->addJavaScript('recaptcha', 'https://www.google.com/recaptcha/api.js', array('contexts' => array('frontend-user-register', 'frontend-user-registerUser')));
}
// Register meta tags
if (Config::getVar('general', 'installed')) {
if (($this->_request->getRequestedPage() == '' || $this->_request->getRequestedPage() == 'index') && $currentContext && $currentContext->getLocalizedSetting('searchDescription')) {
$this->addHeader('searchDescription', '<meta name="description" content="' . $currentContext->getLocalizedSetting('searchDescription') . '">');
}
$this->addHeader('generator', '<meta name="generator" content="' . __($application->getNameKey()) . ' ' . $application->getCurrentVersion()->getVersionString(false) . '">', array('contexts' => array('frontend', 'backend')));
if ($currentContext) {
$customHeaders = $currentContext->getLocalizedSetting('customHeaders');
if (!empty($customHeaders)) {
$this->addHeader('customHeaders', $customHeaders);
}
}
}
if ($currentContext && !$currentContext->getEnabled()) {
$this->addHeader('noindex', '<meta name="robots" content="noindex,nofollow">', array('contexts' => array('frontend', 'backend')));
}
}
// Register custom functions
$this->register_modifier('translate', array('AppLocale', 'translate'));
$this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml'));
$this->register_modifier('String_substr', array('PKPString', 'substr'));
$this->register_modifier('dateformatPHP2JQueryDatepicker', array('PKPString', 'dateformatPHP2JQueryDatepicker'));
$this->register_modifier('to_array', array($this, 'smartyToArray'));
$this->register_modifier('compare', array($this, 'smartyCompare'));
$this->register_modifier('concat', array($this, 'smartyConcat'));
$this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
$this->register_modifier('explode', array($this, 'smartyExplode'));
$this->register_modifier('assign', array($this, 'smartyAssign'));
$this->register_function('csrf', array($this, 'smartyCSRF'));
$this->register_function('translate', array($this, 'smartyTranslate'));
$this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
$this->register_function('help', array($this, 'smartyHelp'));
$this->register_function('flush', array($this, 'smartyFlush'));
$this->register_function('call_hook', array($this, 'smartyCallHook'));
$this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
$this->register_block('iterate', array($this, 'smartyIterate'));
$this->register_function('page_links', array($this, 'smartyPageLinks'));
$this->register_function('page_info', array($this, 'smartyPageInfo'));
$this->register_function('pluck_files', array($this, 'smartyPluckFiles'));
// Modified vocabulary for creating forms
$fbv = $this->getFBV();
$this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
$this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
$this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
$this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
$this->assign('fbvStyles', $fbv->getStyles());
$this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
// register the resource name "core"
$coreResource = new PKPTemplateResource($this->core_template_dir);
$this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
$appResource = new PKPTemplateResource($this->app_template_dir);
$this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
$this->register_function('url', array($this, 'smartyUrl'));
// ajax load into a div or any element
$this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
$this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
// load stylesheets/scripts/headers from a given context
$this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
$this->register_function('load_script', array($this, 'smartyLoadScript'));
$this->register_function('load_header', array($this, 'smartyLoadHeader'));
/**
* Kludge to make sure no code that tries to connect to the
* database is executed (e.g., when loading installer pages).
*/
if (!defined('SESSION_DISABLE_INIT')) {
$application = PKPApplication::getApplication();
$this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
$user = $this->_request->getUser();
$hasSystemNotifications = false;
if ($user) {
$notificationDao = DAORegistry::getDAO('NotificationDAO');
$notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
if ($notifications->getCount() > 0) {
$this->assign('hasSystemNotifications', true);
}
// Assign the user name to be used in the sitenav
$this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
}
}
// Load enabled block plugins and setup active sidebar variables
PluginRegistry::loadCategory('blocks', true);
$sidebarHooks = HookRegistry::getHooks('Templates::Common::Sidebar');
$this->assign(array('hasSidebar' => !empty($sidebarHooks)));
}
示例6: removeRegisteredDois
/**
* Remove registered DOIs for all out test objects.
* @param $pluginName string
*/
protected function removeRegisteredDois($pluginName)
{
// Mark all our test objects as "unregistered".
$configurations = array('Issue' => array('IssueDAO', 'updateObject', 'getById', 1), 'Article' => array('ArticleDAO', 'updateObject', 'getArticle', 1), 'ArticleGalley' => array('ArticleGalleyDAO', 'updateGalley', 'getGalley', array(1, 2, 3)), 'SuppFile' => array('SuppFileDAO', 'updateSuppFile', 'getSuppFile', 1));
$pluginInstance = $this->instantiatePlugin($pluginName);
foreach ($configurations as $objectType => $configuration) {
list($daoName, $updateMethod, $getMethod, $testIds) = $configuration;
$dao = DAORegistry::getDAO($daoName);
if (is_scalar($testIds)) {
$testIds = array($testIds);
}
$hookName = strtolower_codesafe($daoName) . '::getAdditionalFieldNames';
HookRegistry::register($hookName, array($pluginInstance, 'getAdditionalFieldNames'));
foreach ($testIds as $testId) {
// Retrieve the test object.
$testObject = $dao->{$getMethod}($testId);
// Remove the registered DOI.
$testObject->setData($this->pluginId . '::' . DOI_EXPORT_REGDOI, '');
$dao->{$updateMethod}($testObject);
}
$hooks = HookRegistry::getHooks();
foreach ($hooks[$hookName] as $index => $hook) {
if (is_a($hook[0], $pluginName)) {
unset($hooks[$hookName][$index]);
break;
}
}
}
}
示例7: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $mediaType string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
{
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
return $result;
}
$postDownloadHookList = array('FileManager::downloadFileFinished', 'UsageEventPlugin::getUsageEvent');
if (is_readable($filePath)) {
if ($mediaType === null) {
// If the media type wasn't specified, try to detect.
$mediaType = String::mime_content_type($filePath);
if (empty($mediaType)) {
$mediaType = 'application/octet-stream';
}
}
if ($fileName === null) {
// If the filename wasn't specified, use the server-side.
$fileName = basename($filePath);
}
$postDownloadHooks = null;
$hooks = HookRegistry::getHooks();
foreach ($postDownloadHookList as $hookName) {
if (isset($hooks[$hookName])) {
$postDownloadHooks[$hookName] = $hooks[$hookName];
}
}
unset($hooks);
Registry::clear();
// Stream the file to the end user.
header("Content-Type: {$mediaType}");
header('Content-Length: ' . filesize($filePath));
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
header('Cache-Control: private');
// Workarounds for IE weirdness
header('Pragma: public');
// Beware of converting to instance call
// https://github.com/pkp/pkp-lib/commit/82f4a36db406ecac3eb88875541a74123e455713#commitcomment-1459396
FileManager::readFile($filePath, true);
if ($postDownloadHooks) {
foreach ($postDownloadHooks as $hookName => $hooks) {
HookRegistry::setHooks($hookName, $hooks);
}
}
$returner = true;
} else {
$returner = false;
}
HookRegistry::call('FileManager::downloadFileFinished', array(&$returner));
return $returner;
}
示例8: initialize
/**
* Initialize the template manager.
*/
function initialize()
{
$locale = AppLocale::getLocale();
$application = PKPApplication::getApplication();
$router = $this->_request->getRouter();
assert(is_a($router, 'PKPRouter'));
$this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'allowCDN' => Config::getVar('general', 'enable_cdn'), 'useMinifiedJavaScript' => Config::getVar('general', 'enable_minified'), 'toggleHelpOnText' => __('help.toggleInlineHelpOn'), 'toggleHelpOffText' => __('help.toggleInlineHelpOff'), 'currentContext' => $this->_request->getContext(), 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey()), 'exposedConstants' => $application->getExposedConstants(), 'jsLocaleKeys' => $application->getJSLocaleKeys()));
if (is_a($router, 'PKPPageRouter')) {
$this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request)));
}
if ($dispatcher = $this->_request->getDispatcher()) {
$this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE, 'backend');
}
// If there's a locale-specific stylesheet, add it.
if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
$this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet, 'backend');
}
// Register custom functions
$this->register_modifier('translate', array('AppLocale', 'translate'));
$this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml'));
$this->register_modifier('String_substr', array('String', 'substr'));
$this->register_modifier('to_array', array($this, 'smartyToArray'));
$this->register_modifier('compare', array($this, 'smartyCompare'));
$this->register_modifier('concat', array($this, 'smartyConcat'));
$this->register_modifier('escape', array($this, 'smartyEscape'));
$this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
$this->register_modifier('explode', array($this, 'smartyExplode'));
$this->register_modifier('assign', array($this, 'smartyAssign'));
$this->register_function('translate', array($this, 'smartyTranslate'));
$this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
$this->register_function('flush', array($this, 'smartyFlush'));
$this->register_function('call_hook', array($this, 'smartyCallHook'));
$this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
$this->register_block('iterate', array($this, 'smartyIterate'));
$this->register_function('page_links', array($this, 'smartyPageLinks'));
$this->register_function('page_info', array($this, 'smartyPageInfo'));
$this->register_function('icon', array($this, 'smartyIcon'));
$this->register_modifier('truncate', array($this, 'smartyTruncate'));
// Modified vocabulary for creating forms
$fbv = $this->getFBV();
$this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
$this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
$this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
$this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
$this->assign('fbvStyles', $fbv->getStyles());
$this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
// register the resource name "core"
$coreResource = new PKPTemplateResource($this->core_template_dir);
$this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
$appResource = new PKPTemplateResource($this->app_template_dir);
$this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
$this->register_function('url', array($this, 'smartyUrl'));
// ajax load into a div or any element
$this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
$this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
// load stylesheets from a given context
$this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
/**
* Kludge to make sure no code that tries to connect to the
* database is executed (e.g., when loading installer pages).
*/
if (!defined('SESSION_DISABLE_INIT')) {
$application = PKPApplication::getApplication();
$currentVersion = $application->getCurrentVersion();
$this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'currentVersionString' => $currentVersion->getVersionString(false), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
$user = $this->_request->getUser();
$hasSystemNotifications = false;
if ($user) {
$notificationDao = DAORegistry::getDAO('NotificationDAO');
$notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
if ($notifications->getCount() > 0) {
$this->assign('hasSystemNotifications', true);
}
// Assign the user name to be used in the sitenav
$this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
}
}
// Load enabled block plugins and setup active sidebar variables
PluginRegistry::loadCategory('blocks', true);
$leftSidebarHooks = HookRegistry::getHooks('Templates::Common::LeftSidebar');
$rightSidebarHooks = HookRegistry::getHooks('Templates::Common::RightSidebar');
$this->assign(array('hasLeftSidebar' => !empty($leftSidebarHooks), 'hasRightSidebar' => !empty($rightSidebarHooks)));
}
示例9: css
/**
* Get the compiled CSS
* @param $args array
* @param $request PKPRequest
*/
function css($args, $request)
{
header('Content-Type: text/css');
$templateManager = TemplateManager::getManager($request);
$name = $request->getUserVar('name');
if (empty($name)) {
$name = 'pkp-lib';
}
switch ($name) {
// The core app stylesheet
case 'pkp-lib':
$cachedFile = $templateManager->getCachedLessFilePath($name);
if (!file_exists($cachedFile)) {
$styles = $templateManager->compileLess($name, 'styles/index.less');
if (!$templateManager->cacheLess($cachedFile, $styles)) {
echo $styles;
die;
}
}
default:
// Backwards compatibility. This hook is deprecated.
if (HookRegistry::getHooks('PageHandler::displayCss')) {
$result = '';
$lastModified = null;
HookRegistry::call('PageHandler::displayCss', array($request, &$name, &$result, &$lastModified));
if ($lastModified) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
}
header('Content-Length: ' . strlen($result));
echo $result;
die;
} else {
$cachedFile = $templateManager->getCachedLessFilePath($name);
if (!file_exists($cachedFile)) {
// Process styles registered with the current theme
$styles = '';
$themes = PluginRegistry::loadCategory('themes', true);
foreach ($themes as $theme) {
if ($theme->isActive()) {
$style = $theme->getStyle($name);
if (!empty($style)) {
// Compile and cache the stylesheet
$styles = $templateManager->compileLess($name, $style['style'], array('baseUrl' => isset($style['baseUrl']) ? $style['baseUrl'] : null, 'addLess' => isset($style['addLess']) ? $style['addLess'] : null, 'addLessVariables' => isset($style['addLessVariables']) ? $style['addLessVariables'] : null));
}
break;
}
}
// If we still haven't found styles, fire off a hook
// which allows other types of plugins to handle
// requests
if (!$styles) {
HookRegistry::call('PageHandler::getCompiledLess', array('request' => $request, 'name' => &$name, 'styles' => &$styles));
}
// Give up if there are still no styles
if (!$styles) {
die;
}
// Try to save the styles to a cached file. If we can't,
// just print them out
if (!$templateManager->cacheLess($cachedFile, $styles)) {
echo $styles;
die;
}
}
}
}
// Deliver the cached file
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($cachedFile)) . ' GMT');
header('Content-Length: ' . filesize($cachedFile));
readfile($cachedFile);
die;
}
示例10: callbackManage
/**
* Syncronize crontab with lazy load plugins management.
* @param $hookName string
* @param $args array
* @return boolean
* @see PluginHandler::plugin() for the hook call.
*/
function callbackManage($hookName, $args)
{
$verb = $args[0];
$plugin = $args[4];
/* @var $plugin LazyLoadPlugin */
// Only interested in plugins that can be enabled/disabled.
if (!is_a($plugin, 'LazyLoadPlugin')) {
return false;
}
// Only interested in enable/disable actions.
if ($verb !== 'enable' && $verb !== 'disable') {
return false;
}
// Check if the plugin wants to add its own
// scheduled task into the cron tab.
$hooks = HookRegistry::getHooks();
$hookName = 'AcronPlugin::parseCronTab';
if (!isset($hooks[$hookName])) {
return false;
}
foreach ($hooks[$hookName] as $callback) {
if ($callback[0] == $plugin) {
$this->_parseCrontab();
break;
}
}
return false;
}
示例11: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $mediaType string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
{
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
return $result;
}
$postDownloadHookList = array('FileManager::downloadFileFinished', 'UsageEventPlugin::getUsageEvent');
if (is_readable($filePath)) {
if ($mediaType === null) {
// If the media type wasn't specified, try to detect.
$mediaType = PKPString::mime_content_type($filePath);
if (empty($mediaType)) {
$mediaType = 'application/octet-stream';
}
}
if ($fileName === null) {
// If the filename wasn't specified, use the server-side.
$fileName = basename($filePath);
}
// Free some memory
$postDownloadHooks = null;
$hooks = HookRegistry::getHooks();
foreach ($postDownloadHookList as $hookName) {
if (isset($hooks[$hookName])) {
$postDownloadHooks[$hookName] = $hooks[$hookName];
}
}
unset($hooks);
Registry::clear();
// Stream the file to the end user.
header("Content-Type: {$mediaType}");
header('Content-Length: ' . filesize($filePath));
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
header('Cache-Control: private');
// Workarounds for IE weirdness
header('Pragma: public');
$this->readFileFromPath($filePath, true);
if ($postDownloadHooks) {
foreach ($postDownloadHooks as $hookName => $hooks) {
HookRegistry::setHooks($hookName, $hooks);
}
}
$returner = true;
} else {
$returner = false;
}
HookRegistry::call('FileManager::downloadFileFinished', array(&$returner));
return $returner;
}