/** * @see Form::fetch() * @param $request PKPRequest * @param $params array */ function fetch($request, $params = null) { $site = $request->getSite(); $publicFileManager = new PublicFileManager(); $contextDao = Application::getContextDAO(); $contexts = $contextDao->getNames(); $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); $cssSettingName = 'siteStyleSheet'; $imageSettingName = 'pageHeaderTitleImage'; // Get link actions. $uploadCssLinkAction = $this->_getFileUploadLinkAction($cssSettingName, 'css', $request); $uploadImageLinkAction = $this->_getFileUploadLinkAction($imageSettingName, 'image', $request); // Get the files view. $cssView = $this->renderFileView($cssSettingName, $request); $imageView = $this->renderFileView($imageSettingName, $request); $application = Application::getApplication(); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign(array('locale' => AppLocale::getLocale(), 'siteStyleFileExists' => file_exists($siteStyleFilename), 'uploadCssLinkAction' => $uploadCssLinkAction, 'uploadImageLinkAction' => $uploadImageLinkAction, 'cssView' => $cssView, 'imageView' => $imageView, 'redirectOptions' => $contexts, 'pageHeaderTitleImage' => $site->getSetting($imageSettingName), 'availableMetricTypes' => $application->getMetricTypes(true))); $themePlugins = PluginRegistry::getPlugins('themes'); $enabledThemes = array(); $activeThemeOptions = array(); foreach ($themePlugins as $themePlugin) { $enabledThemes[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName(); if ($themePlugin->isActive()) { $activeThemeOptions = $themePlugin->getOptionsConfig(); $activeThemeOptionsValues = $themePlugin->getOptionValues(); foreach ($activeThemeOptions as $name => $option) { $activeThemeOptions[$name]['value'] = isset($activeThemeOptionsValues[$name]) ? $activeThemeOptionsValues[$name] : ''; } } } $templateMgr->assign(array('enabledThemes' => $enabledThemes, 'activeThemeOptions' => $activeThemeOptions)); return parent::fetch($request); }
/** * Display the tabs index page. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function fetch($args, $request) { parent::fetch($args, $request); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('selectedFormatId', $this->getSelectedFormatId()); $submission = $this->getSubmission(); // load in any publication formats assigned to this published monograph $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO'); $formats = $publicationFormatDao->getBySubmissionId($submission->getId()); $publicationFormats = array(); while ($publicationFormat = $formats->next()) { $publicationFormats[] = $publicationFormat; } $templateMgr->assign_by_ref('publicationFormats', $publicationFormats); $application = Application::getApplication(); $request = $application->getRequest(); $router = $request->getRouter(); $dispatcher = $router->getDispatcher(); // These two URLs are catalog/monograph specific. $tabsUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'modals.submissionMetadata.CatalogEntryHandler', 'fetchFormatInfo', null, array('submissionId' => $submission->getId(), 'stageId' => $this->getStageId())); $templateMgr->assign('tabsUrl', $tabsUrl); $tabContentUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'tab.catalogEntry.CatalogEntryTabHandler', 'publicationMetadata', null, array('submissionId' => $submission->getId(), 'stageId' => $this->getStageId())); $templateMgr->assign('tabContentUrl', $tabContentUrl); return $templateMgr->fetchJson('controllers/modals/submissionMetadata/catalogEntryTabs.tpl'); }
/** * @see Form::fetch() * @param $request PKPRequest * @param $params array */ function fetch($request, $params = null) { $site = $request->getSite(); $publicFileManager = new PublicFileManager(); $contextDao = Application::getContextDAO(); $contexts = $contextDao->getNames(); $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); $cssSettingName = 'siteStyleSheet'; $imageSettingName = 'pageHeaderTitleImage'; // Get link actions. $uploadCssLinkAction = $this->_getFileUploadLinkAction($cssSettingName, 'css', $request); $uploadImageLinkAction = $this->_getFileUploadLinkAction($imageSettingName, 'image', $request); // Get the files view. $cssView = $this->renderFileView($cssSettingName, $request); $imageView = $this->renderFileView($imageSettingName, $request); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('locale', AppLocale::getLocale()); $templateMgr->assign('siteStyleFileExists', file_exists($siteStyleFilename)); $templateMgr->assign('uploadCssLinkAction', $uploadCssLinkAction); $templateMgr->assign('uploadImageLinkAction', $uploadImageLinkAction); $templateMgr->assign('cssView', $cssView); $templateMgr->assign('imageView', $imageView); $templateMgr->assign('redirectOptions', $contexts); $templateMgr->assign('pageHeaderTitleImage', $site->getSetting($imageSettingName)); $application = Application::getApplication(); $templateMgr->assign('availableMetricTypes', $application->getMetricTypes(true)); $themePlugins = PluginRegistry::loadCategory('themes'); $themePluginOptions = array(); foreach ($themePlugins as $themePlugin) { $themePluginOptions[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName(); } $templateMgr->assign('themePluginOptions', $themePluginOptions); return parent::fetch($request); }
/** * @see LazyLoadPlugin::register() */ function register($category, $path) { $success = parent::register($category, $path); HookRegistry::register('AcronPlugin::parseCronTab', array($this, 'callbackParseCronTab')); if ($this->getEnabled() && $success) { // Register callbacks. HookRegistry::register('PluginRegistry::loadCategory', array($this, 'callbackLoadCategory')); HookRegistry::register('LoadHandler', array($this, 'callbackLoadHandler')); // If the plugin will provide the access logs, // register to the usage event hook provider. if ($this->getSetting(CONTEXT_ID_NONE, 'createLogFiles')) { HookRegistry::register('UsageEventPlugin::getUsageEvent', array(&$this, 'logUsageEvent')); } $this->_dataPrivacyOn = $this->getSetting(CONTEXT_ID_NONE, 'dataPrivacyOption'); $this->_saltpath = $this->getSetting(CONTEXT_ID_NONE, 'saltFilepath'); // Check config for backward compatibility. if (!$this->_saltpath) { $this->_saltpath = Config::getVar('usageStats', 'salt_filepath'); } $application = Application::getApplication(); $request = $application->getRequest(); $this->_optedOut = $request->getCookieVar('usageStats-opt-out'); if ($this->_optedOut) { // Renew the Opt-Out cookie if present. $request->setCookieVar('usageStats-opt-out', true, time() + 60 * 60 * 24 * 365); } } return $success; }
/** * Verification de l'accès d'un utilisateur à l'administration d'une application * @param object PDO */ public static function ifAdministrateurAccesApplication($bdd) { $utilisateur = $_SESSION['utilisateur']['id']; if (!in_array($utilisateur, explode(',', Application::getApplication($bdd)->applicationAdministrateur))) { Tool::setFlash('Vous n\'avez pas accès à l\'administration cette application', 'erreur'); header('location:' . BASEFRONT . 'dashboard/dashboard.php'); die; } }
/** * Return information about the latest available version. * @return array */ function &getLatestVersion() { $application =& Application::getApplication(); $includeId = Config::getVar('general', 'installed') && !defined('RUNNING_UPGRADE') && Config::getVar('general', 'enable_beacon', true); if ($includeId) { $pluginSettingsDao =& DAORegistry::getDAO('PluginSettingsDAO'); $uniqueSiteId = $pluginSettingsDao->getSetting(CONTEXT_SITE, 'UsageEventPlugin', 'uniqueSiteId'); } else { $uniqueSiteId = null; } $request =& $application->getRequest(); $returner =& VersionCheck::parseVersionXML($application->getVersionDescriptorUrl() . ($includeId ? '?id=' . urlencode($uniqueSiteId) . '&oai=' . urlencode($request->url('index', 'oai')) : '')); return $returner; }
/** * @see LazyLoadPlugin::register() */ function register($category, $path) { $success = parent::register($category, $path); if (!Config::getVar('general', 'installed')) { return false; } $application =& Application::getApplication(); $request =& $application->getRequest(); $router =& $request->getRouter(); $context = $router->getContext($request); if ($success && $context) { $this->_apiKey = $this->getSetting($context->getId(), 'apiKey'); HookRegistry::register('TemplateManager::display', array(&$this, 'templateManagerCallback')); HookRegistry::register('Templates::Article::MoreInfo', array(&$this, 'articleMoreInfoCallback')); HookRegistry::register('AcronPlugin::parseCronTab', array(&$this, 'callbackParseCronTab')); } return $success; }
/** * Replace various variables in the code template with data * relevant to the assigned article. * @param PublishedArticle $publishedArticle */ function replaceCodeVars($publishedArticle = null) { $application = Application::getApplication(); $request = $application->getRequest(); $router = $request->getRouter(); $context = $request->getContext(); $code = $this->getCode(); $codeVariables = array('journalUrl' => $router->url($request, null, 'index'), 'journalName' => $context->getLocalizedName()); if (isset($publishedArticle)) { $codeVariables = array_merge($codeVariables, array('articleUrl' => $router->url($request, null, 'article', 'view', $publishedArticle->getId()), 'articleTitle' => $publishedArticle->getLocalizedTitle())); } // Replace variables in message with values foreach ($codeVariables as $key => $value) { if (!is_object($value)) { $code = str_replace('{$' . $key . '}', $value, $code); } } $this->setCode($code); }
/** * Display the tabs index page. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function fetch($args, $request) { parent::fetch($args, $request); $templateMgr = TemplateManager::getManager($request); $submission = $this->getSubmission(); // load in any galley formats assigned to this published article $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); $articleGalleys = $galleyDao->getBySubmissionId($submission->getId()); $templateMgr->assign('galleys', $articleGalleys->toArray()); $application = Application::getApplication(); $request = $application->getRequest(); $router = $request->getRouter(); $dispatcher = $router->getDispatcher(); $tabsUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'modals.submissionMetadata.IssueEntryHandler', 'fetchFormatInfo', null, array('submissionId' => $submission->getId(), 'stageId' => $this->getStageId())); $templateMgr->assign('tabsUrl', $tabsUrl); $tabContentUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'tab.issueEntry.IssueEntryTabHandler', 'galleyMetadata', null, array('submissionId' => $submission->getId(), 'stageId' => $this->getStageId())); $templateMgr->assign('tabContentUrl', $tabContentUrl); return $templateMgr->fetchJson('controllers/modals/submissionMetadata/issueEntryTabs.tpl'); }
/** * Replace various variables in the code template with data * relevant to the assigned monograph. * @param PublishedMonograph $publishedMonograph */ function replaceCodeVars($publishedMonograph = null) { $application = Application::getApplication(); $request = $application->getRequest(); $router = $request->getRouter(); $context = $request->getContext(); $code = $this->getCode(); $codeVariables = array('contextUrl' => $router->url($request, null, 'index'), 'pressName' => $context->getLocalizedName()); if (isset($publishedMonograph)) { $codeVariables = array_merge($codeVariables, array('bookCatalogUrl' => $router->url($request, null, 'catalog', 'book', $publishedMonograph->getId()), 'bookTitle' => $publishedMonograph->getLocalizedTitle())); } // Replace variables in message with values foreach ($codeVariables as $key => $value) { if (!is_object($value)) { $code = str_replace('{$' . $key . '}', $value, $code); } } $this->setCode($code); }
/** * Build an usage event. * @param $hookName string * @param $args array * @return array */ protected function buildUsageEvent($hookName, $args) { // Finished downloading a file? if ($hookName == 'FileManager::downloadFileFinished') { // The usage event for this request is already build and // passed to any other registered hook. return null; } $application = Application::getApplication(); $request = $application->getRequest(); $router = $request->getRouter(); /* @var $router PageRouter */ $templateMgr = $args[0]; /* @var $templateMgr TemplateManager */ // We are just interested in page requests. if (!is_a($router, 'PageRouter')) { return false; } // Check whether we are in journal context. $context = $router->getContext($request); if (!$context) { return false; } // Prepare request information. list($pubObject, $downloadSuccess, $assocType, $idParams, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams) = $this->getUsageEventData($hookName, $args, $request, $router, $templateMgr, $context); if (!$pubObject) { return false; } // Timestamp. $time = Core::getCurrentDate(); // Actual document size, MIME type. $htmlPageAssocTypes = $this->getHtmlPageAssocTypes(); if (in_array($assocType, $htmlPageAssocTypes)) { // HTML pages with no file downloads. $docSize = 0; $mimeType = 'text/html'; } else { // Files. $docSize = (int) $pubObject->getFileSize(); $mimeType = $pubObject->getFileType(); } $canonicalUrl = $router->url($request, null, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams); // Public identifiers. // 1) A unique system internal ID that will help us to easily attribute // statistics to a specific publication object. array_unshift($idParams, 'c' . $context->getId()); $siteId = $this->getUniqueSiteId(); if (empty($siteId)) { // Create a globally unique, persistent site ID // so that we can uniquely identify publication // objects from this site, even if the URL or any // other externally influenced information changes. $siteId = uniqid(); $this->updateSetting(0, 'uniqueSiteId', $siteId); } array_unshift($idParams, $siteId); $applicationName = $application->getName(); $applicationId = $applicationName . ':' . implode('-', $idParams); $idKey = 'other::' . $applicationName; $identifiers = array($idKey => $applicationId); // 2) Standardized public identifiers, e.g. DOI, URN, etc. if ($this->isPubIdObjectType($pubObject)) { $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $context->getId()); if (is_array($pubIdPlugins)) { foreach ($pubIdPlugins as $pubIdPlugin) { if (!$pubIdPlugin->getEnabled()) { continue; } $pubId = $pubIdPlugin->getPubId($pubObject); if ($pubId) { $identifiers[$pubIdPlugin->getPubIdType()] = $pubId; } } } } // Service URI. $serviceUri = $router->url($request, $context->getPath()); // IP and Host. $ip = $request->getRemoteAddr(); $host = null; if (isset($_SERVER['REMOTE_HOST'])) { // We do NOT actively look up the remote host to // avoid the performance penalty. We only set the remote // host if we get it "for free". $host = $_SERVER['REMOTE_HOST']; } // HTTP user agent. $userAgent = $request->getUserAgent(); // HTTP referrer. $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; // User and roles. $user = $request->getUser(); $roles = array(); if ($user) { $roleDao = DAORegistry::getDAO('RoleDAO'); /* @var $roleDao PKPRoleDAO */ $rolesByContext = $roleDao->getByUserIdGroupedByContext($user->getId()); foreach (array(CONTEXT_SITE, $context->getId()) as $workingContext) { if (isset($rolesByContext[$workingContext])) { foreach ($rolesByContext[$workingContext] as $roleId => $role) { $roles[] = $roleId; } } } } // Try a simple classification of the request. $classification = null; if (!empty($roles)) { // Access by editors, authors, etc. $internalRoles = array_diff($roles, array(ROLE_ID_READER)); if (!empty($internalRoles)) { $classification = USAGE_EVENT_PLUGIN_CLASSIFICATION_ADMIN; } } if ($request->isBot()) { // The bot classification overwrites other classifications. $classification = USAGE_EVENT_PLUGIN_CLASSIFICATION_BOT; } // TODO: Classify LOCKSS or similar as 'internal' access. /* * Comparison of our event log format with Apache log parameters... * * 1) default parameters: * %h: remote hostname or IP => $ip, $host * %l: remote logname (identd) => not supported, see $user, $roles instead * %u: remote user => not supported, see $user, $roles instead * %t: request time => $time * %r: query => derived objects: $pubObject, $assocType, $canonicalUrl, $identifiers, $serviceUri, $classification * %s: status => not supported (always 200 in our case) * %b: response size => $docSize * * 2) other common parameters * %O: bytes sent => not supported (cannot be reliably determined from within PHP) * %X: connection status => $downloadSuccess (not reliable!) * %{ContentType}o: => $mimeType * %{User-agent}i: => $userAgent * %{Referer}i: => $referrer * * Several items, e.g. time etc., may differ from what Apache * would actually log. But the differences do not matter for our use * cases. */ // Collect all information into an array. $usageEvent = compact('time', 'pubObject', 'assocType', 'canonicalUrl', 'mimeType', 'identifiers', 'docSize', 'downloadSuccess', 'serviceUri', 'ip', 'host', 'user', 'roles', 'userAgent', 'referrer', 'classification'); return $usageEvent; }
<?php /* * AWS stuff. */ $application = Application::getApplication(null, null, false, true); return array('includes' => array('_aws'), 'services' => array('default_settings' => array('params' => array('key' => @$application->setting->filter(function ($model) { return $model->name === 's3 access key'; })->first()->value, 'secret' => @$application->setting->filter(function ($model) { return $model->name === 's3 secret'; })->first()->value, 'region' => @$application->setting->filter(function ($model) { return $model->name === 's3 region'; })->first()->value))));
/** * Display the statistics area. * @param $args array * @param $request PKPRequest */ function statistics($args, $request) { $this->setupTemplate($request); $context = $request->getContext(); $templateMgr = TemplateManager::getManager($request); $application = Application::getApplication(); $templateMgr->assign('appSettings', $this->hasAppStatsSettings()); $templateMgr->assign('contextObjectName', __($application->getNameKey())); $reportPlugins = PluginRegistry::loadCategory('reports'); $templateMgr->assign_by_ref('reportPlugins', $reportPlugins); $templateMgr->assign('defaultMetricType', $context->getSetting('defaultMetricType')); $availableMetricTypes = $context->getMetricTypes(true); $templateMgr->assign('availableMetricTypes', $availableMetricTypes); if (count($availableMetricTypes) > 1) { $templateMgr->assign('showMetricTypeSelector', true); } $templateMgr->display('management/tools/statistics.tpl'); }
/** * @copydoc ListbuilderHandler::insertEntry() */ function insertEntry($request, $newRowId) { $userDao = DAORegistry::getDAO('UserDAO'); $application = Application::getApplication(); $request = $application->getRequest(); // need to do this because the method version is null. $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->getById($this->_submissionId); $this->setData('userIds', array_merge($this->getData('userIds'), $newRowId)); }
/** * @copydoc ListbuilderHandler::insertEntry() */ function insertEntry($request, $newRowId) { $userDao = DAORegistry::getDAO('UserDAO'); $application = Application::getApplication(); $request = $application->getRequest(); // need to do this because the method version is null. $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->getById($this->_submissionId); foreach ($newRowId as $id) { $this->sendMessage($id, $submission, $request); } }
public static function loadDefaultValues($input = '') { $parent = Content::find($input['parent_id']); if (!@$input['template_id']) { $parentTemplate = Template::find($parent->template_id); // dd($parent->template_id); if ($parentTemplate) { //since we occasionally want to process a looped back tree (which makes the whole tree //invalid, we can't use baum's built in functions to get the first child. if ($parentTemplate->loopback) { $parentTemplateChild = Template::find($parentTemplate->loopback); } else { $parentTemplateChild = @$parentTemplate->getImmediateDescendants()->first(); } $input['template_id'] = @$parentTemplateChild->id; } if (!@$input['template_id']) { //if it's still nothing we can safely set this to 0; $input['template_id'] = null; } } $template = Template::find($input['template_id']); //dd($template->name); //TODO: replace with something like this: dd($this->default_fields()->first()->id); //$contentDefaultFields = Contentdefaultfield::where('content_type_id', '=', $this->content_type_id)->get(); //plug in the fields we wanted.. if (!@$input['template_id']) { $input['template_id'] = @$template->id; } if (!@$input['name']) { $input['name'] = @$template->name; } if (!@$input['view']) { $input['view'] = @$template->view; } if (!@$input['identifier']) { $input['identifier'] = @$template->identifier; } if (!@$input['package']) { $input['package'] = @$template->package; } if (!@$input['edit_view']) { $input['edit_view'] = @$template->edit_view; } if (!@$input['edit_package']) { $input['edit_package'] = @$template->edit_package; } if (!@$input['edit_action']) { $input['edit_action'] = @$template->edit_action; } //work out the slug if not manually set if (!@$input['slug']) { $input['slug'] = Content::createSlug($input, $parent); } //and the user_id (author) $input['user_id'] = Auth::user()->id; //and the application: if (!@$input['application_id']) { $application = Application::getApplication(); $input['application_id'] = $application->id; } //set language if (!@$input['language']) { $input['language'] = App::getLocale(); } //and the package if not set if (!@$input['package']) { //set it as parent one.. $input['package'] = @$parent->package; //still nothing - set from application $application = Application::getApplication(); if ($application->package) { $input['package'] = $application->package; } //still nothing - we have to set it to default. if (!$input['package']) { //last ditch attempt to put something sensible in here $input['package'] = Content::PACKAGE; } } if (!@$input['edit_package']) { //set it as parent one.. $input['edit_package'] = @$parent->edit_package; //still nothing - we have to set it to default. if (!$input['edit_package']) { //last ditch attempt to put something sensible in here $input['edit_package'] = Content::PACKAGE; } } if (!@$input['edit_view']) { //set it as parent one.. $input['edit_view'] = @$parent->edit_view; //still nothing - we have to set it to default. if (!$input['edit_view']) { //last ditch attempt to put something sensible in here $input['edit_view'] = Content::EDIT_VIEW; } } if (!@$input['view']) { $input['view'] = Content::VIEW; } return $input; }
/** * Return instance of a class for reading the specified URL. * @param $source mixed; URL, filename, or resources * @return FileWrapper */ function &wrapper($source) { if (ini_get('allow_url_fopen') && Config::getVar('general', 'allow_url_fopen') && is_string($source)) { $info = parse_url($source); $wrapper = new FileWrapper($source, $info); } elseif (is_resource($source)) { // $source is an already-opened file descriptor. import('lib.pkp.classes.file.wrappers.ResourceWrapper'); $wrapper = new ResourceWrapper($source); } else { // $source should be a URL. $info = parse_url($source); if (isset($info['scheme'])) { $scheme = $info['scheme']; } else { $scheme = null; } $application =& Application::getApplication(); if (!Config::getVar('general', 'installed') || defined('RUNNING_UPGRADE') || defined('PHPUNIT_CURRENT_MOCK_ENV')) { $userAgent = $application->getName() . '/?'; } else { $currentVersion =& $application->getCurrentVersion(); $userAgent = $application->getName() . '/' . $currentVersion->getVersionString(); } switch ($scheme) { case 'http': import('lib.pkp.classes.file.wrappers.HTTPFileWrapper'); $wrapper = new HTTPFileWrapper($source, $info); $wrapper->addHeader('User-Agent', $userAgent); break; case 'https': import('lib.pkp.classes.file.wrappers.HTTPSFileWrapper'); $wrapper = new HTTPSFileWrapper($source, $info); $wrapper->addHeader('User-Agent', $userAgent); break; case 'ftp': import('lib.pkp.classes.file.wrappers.FTPFileWrapper'); $wrapper = new FTPFileWrapper($source, $info); break; default: $wrapper = new FileWrapper($source, $info); } } return $wrapper; }
public function scopeInApplication($q) { return $q->whereHas('applications', function ($sq) { $sq->where('application_id', \Application::getApplication()->application_id); }); }
@foreach($menuItems as $menuItem) @if(Permission::getPermission($menuItem['location'],'')->result) <li class="{{Request::is(config('bootlegcms.cms_route').$menuItem['activePattern'])?'active':''}}"> <a href="{{action($menuItem['location'])}}"> <i class="menu-icon glyphicon {{$menuItem['icon']}}"></i> <span class="mm-text">{{$menuItem['title']}}</span> </a> </li> @endif @endforeach @if(Permission::getPermission('\Bootleg\Cms\ApplicationController@anySettings','')->result) <li class="{{Request::is(config('bootlegcms.cms_route').'application/settings*')?'active':''}}"> <a href="{{action('\Bootleg\Cms\ApplicationController@anySettings', array())}}"> <i class="menu-icon glyphicon glyphicon-cog"></i> <span class="mm-text">Settings</span> </a> </li> @endif <li class="text-center menu-additional"> <?php $application = Application::getApplication(); ?> <h2>{{@$application->name}}</h2> <div class="btn-group"> <a title='Logout' href="{{action('\Bootleg\Cms\UsersController@anyLogout', array())}}" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-log-out"></span></a> <a title='Dashboard' href="{{action('\Bootleg\Cms\UsersController@anySettings', array())}}" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-home"></span></a> <a title='My Settings' href="{{action('\Bootleg\Cms\UsersController@anySettings', array())}}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-user"></span></a> </div> </li> </ul> </div>
/** * Get url components (page, operation and args) * based on the passed offset. * @param $urlInfo string * @param $isPathInfo string * @param $offset int * @param $varName string * @param $userVars array (optional) GET variables * (only for testing). * @return mixed array|string|null */ function _getUrlComponents($urlInfo, $isPathInfo, $offset, $varName = '', $userVars = array()) { $component = null; $isArrayComponent = false; if ($varName == 'path') { $isArrayComponent = true; } if ($isPathInfo) { $application = Application::getApplication(); $contextDepth = $application->getContextDepth(); $vars = explode('/', trim($urlInfo, '/')); if (count($vars) > $contextDepth + $offset) { if ($isArrayComponent) { $component = array_slice($vars, $contextDepth + $offset); for ($i = 0, $count = count($component); $i < $count; $i++) { $component[$i] = Core::cleanVar(get_magic_quotes_gpc() ? stripslashes($component[$i]) : $component[$i]); } } else { $component = $vars[$contextDepth + $offset]; } } } else { $component = Core::_getUserVar($urlInfo, $varName, $userVars); } if ($isArrayComponent) { if (empty($component)) { $component = array(); } elseif (!is_array($component)) { $component = array($component); } } return $component; }
/** * Log the usage event into a file. * @param $hookName string * @param $args array * @return boolean */ function logUsageEvent($hookName, $args) { $hookName = $args[0]; $usageEvent = $args[1]; // Check (and renew) the statistics opt-out. $application = Application::getApplication(); $request = $application->getRequest(); $optedOut = $request->getCookieVar('usageStats-opt-out'); if ($optedOut) { // Renew the Opt-Out cookie if present. $request->setCookieVar('usageStats-opt-out', true, time() + 60 * 60 * 24 * 365); return false; } if ($hookName == 'FileManager::downloadFileFinished' && !$usageEvent && $this->_currentUsageEvent) { // File download is finished, try to log the current usage event. $downloadSuccess = $args[2]; if ($downloadSuccess && !connection_aborted()) { $this->_currentUsageEvent['downloadSuccess'] = true; $usageEvent = $this->_currentUsageEvent; } } if ($usageEvent && !$usageEvent['downloadSuccess']) { // Don't log until we get the download finished hook call. $this->_currentUsageEvent = $usageEvent; return false; } if ($usageEvent) { $this->_writeUsageEventInLogFile($usageEvent); } return false; }
/** * Get the context object based on the context path * array that's returned by Core::getContextPaths() * @param $contextPaths array * @return mixed null|Context * @see Core::getContextPaths() */ protected function getContextByPath($contextPaths) { $application = Application::getApplication(); $deepestContextDepthIndex = $application->getContextDepth() - 1; $contextPath = $contextPaths[$deepestContextDepthIndex]; $context = null; if (isset($this->_contextsByPath[$contextPath])) { $context = $this->_contextsByPath[$contextPath]; } return $context; }
/** * Get execution log email message. * @param $executionLogFile string * @return string */ function getMessage($executionLogFile) { if (!$executionLogFile) { return __('admin.scheduledTask.noLog'); } $application =& Application::getApplication(); $request =& $application->getRequest(); $router =& $request->getRouter(); $downloadLogUrl = $router->url($request, 'index', 'admin', 'downloadScheduledTaskLogFile', null, array('file' => basename($executionLogFile))); return __('admin.scheduledTask.downloadLog', array('url' => $downloadLogUrl)); }
/** * Download scheduled task execution log file. */ function downloadScheduledTaskLogFile() { $this->validate(); $application =& Application::getApplication(); $request =& $application->getRequest(); $file = basename($request->getUserVar('file')); import('lib.pkp.classes.scheduledTask.ScheduledTaskHelper'); ScheduledTaskHelper::downloadExecutionLog($file); }
/** * Get the specified plugin. * @param $request PKPRequest * @return GalleryPlugin */ function _getSpecifiedPlugin($request) { // Get all plugins. $pluginGalleryDao = DAORegistry::getDAO('PluginGalleryDAO'); $plugins = $pluginGalleryDao->getNewestCompatible(Application::getApplication()); // Get specified plugin. Indexes into $plugins are 0-based // but row IDs are 1-based; compensate. $rowId = (int) $request->getUserVar('rowId') - 1; if (!isset($plugins[$rowId])) { fatalError('Invalid row ID!'); } return $plugins[$rowId]; }
public function superSave($input) { $input['application_id'] = Application::getApplication()->id; $parent = Template::find($input['parent_id']); unset($input['parent_id']); //SAVE CONTENT ITEM $saved = $parent->children()->create($input); return $saved; }
/** * Get views of the published monograph. * @return int */ function getViews() { $application = Application::getApplication(); return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_MONOGRAPH, $this->getId()); }
/** * Get submission file number of public downloads. * @return int */ function getViews() { $application = Application::getApplication(); return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $this->getFileId()); }
/** * Get context main page views. * @return int */ function getViews() { $application = Application::getApplication(); return $application->getPrimaryMetricByAssoc(Application::getContextAssocType(), $this->getId()); }
/** * Hook callback: register plugin settings fields with TinyMCE * @see TinyMCEPlugin::getEnableFields() */ function getTinyMCEEnabledFields($hookName, $args) { $fields =& $args[1]; $application =& Application::getApplication(); $request =& $application->getRequest(); $router =& $request->getRouter(); // TinyMCEPlugin::getEnableFields hook is only invoked on page requests. $page = $router->getRequestedPage($request); $op = $router->getRequestedOp($request); $requestArgs = $router->getRequestedArgs($request); if ($page == 'manager' && $op == 'plugin' && in_array('dataverseplugin', $requestArgs)) { $fields = array('dataAvailability', 'termsOfUse'); } return false; }