Open Journal Systems  3.3.0
functions.inc.php File Reference

Go to the source code of this file.

Functions

 arrayClean ($array)
 
 checkPhpVersion ($version)
 
 customAutoload ($rootPath, $prefix, $class)
 
if(!function_exists('import')) fatalError ($reason)
 
instantiate ($fullyQualifiedClassName, $expectedTypes=null, $expectedPackages=null, $expectedMethods=null, $constructorArg=null)
 
 lcfirst_codesafe ($str)
 
 stripAssocArray ($values)
 
 strtolower_codesafe ($str)
 
 strtoupper_codesafe ($str)
 
 ucfirst_codesafe ($str)
 

Detailed Description

Contains definitions for common functions used system-wide. Any frequently-used functions that cannot be put into an appropriate class should be added here.

Copyright (c) 2014-2020 Simon Fraser University Copyright (c) 2000-2020 John Willinsky Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.

Definition in file functions.inc.php.

Function Documentation

◆ arrayClean()

arrayClean (   $array)

Remove empty elements from an array

Parameters
$arrayarray
Returns
array

Definition at line 250 of file functions.inc.php.

◆ checkPhpVersion()

checkPhpVersion (   $version)

Check to see if the server meets a minimum version requirement for PHP.

Parameters
$versionName of version (see version_compare documentation)
Returns
boolean

Definition at line 132 of file functions.inc.php.

Referenced by RuntimeEnvironment\isCompatible().

◆ customAutoload()

customAutoload (   $rootPath,
  $prefix,
  $class 
)

Helper function to define custom autoloader

Parameters
string$rootPath
string$prefix
string$class
Returns
void

Definition at line 322 of file functions.inc.php.

References Core\cleanFileVar(), and strtolower_codesafe().

Referenced by PKPApplication\__construct().

◆ fatalError()

if (!function_exists( 'import')) fatalError (   $reason)

Emulate a Java-style import statement. Simply includes the associated PHP file (using require_once so multiple calls to include the same file have no effect).

Parameters
$classstring the complete name of the class to be imported (e.g. 'lib.pkp.classes.core.Core') Wrapper around die() to pretty-print an error message with an optional stack trace.

Definition at line 32 of file functions.inc.php.

References $application, Registry\get(), and Config\getVar().

Referenced by PromoteForm\__construct(), SendReviewsForm\__construct(), XSLTransformationFilter\__construct(), EditLibraryFileForm\__construct(), PKPSubmissionFilesUploadBaseForm\__construct(), TypeDescription\__construct(), PKPApplication\__construct(), UserGroupForm\_assignStagesToUserGroup(), TextureHandler\_buildManifestXMLFromDocument(), FilterDAO\_fromRow(), ReportGeneratorHandler\_getReportGeneratorForm(), PluginGalleryGridHandler\_getSpecifiedPlugin(), Dispatcher\_instantiateRouter(), SubmissionFileManager\_instantiateSubmissionFile(), FilterDAO\_newDataObject(), PKPAcronPlugin\_parseCrontab(), MarkupConversionHelper\_processHtmlMediaFiles(), CompositeFilter\_resolveCompositeSettingName(), ScheduledTask\addExecutionLogEntry(), PKP\components\forms\FormComponent\addGroup(), PKP\components\forms\FormComponent\addPage(), PersistableFilter\addSetting(), SubmissionFileDAO\assignRevisionToReviewRound(), PKPUserHandler\authorizationDenied(), UserGroupGridHandler\authorize(), PKP\Services\PKPSchemaService\coerce(), PKPPublicationDAO\deleteAllPubIds(), ListbuilderHandler\deleteEntry(), InformationCenterHandler\deleteNote(), Dispatcher\dispatch(), PubObjectsExportPlugin\display(), ImportExportPlugin\displayXMLValidationErrors(), FileApiHandler\downloadAllFiles(), SubmissionFileManager\downloadById(), FileApiHandler\downloadFile(), TextureHandler\editor(), SubmissionFilesUploadConfirmationForm\execute(), PromoteForm\execute(), SendReviewsForm\execute(), ReviewFormElementForm\execute(), PKPAuthorForm\execute(), ReviewerForm\execute(), Filter\execute(), QuickSubmitPlugin\executeCLI(), ScheduledTaskTool\executeTask(), PKPUserImportExportPlugin\exportUsers(), MarkupBatchGatewayPlugin\fetch(), MarkupGatewayPlugin\fetch(), PKPSubmissionFilesUploadBaseForm\fetch(), GridHandler\fetchCell(), AuthorDashboardReviewRoundTabHandler\fetchReviewRoundInfo(), OJSPaymentManager\fulfillQueuedPayment(), PKPCatalogHandler\fullSize(), PKP\Services\PKPSchemaService\get(), PKP\components\forms\Field\getConfig(), VersionDAO\getCurrentVersion(), DAORegistry\getDAO(), GridHandler\getDataElementFromRequest(), PKPSubmissionFilesUploadBaseForm\getSubmissionFiles(), Dispatcher\handle404(), UserXmlPKPUserFilter\handleChildElement(), NativeXmlUserGroupFilter\handleElement(), FileInformationCenterHandler\initialize(), PKPFileUploadWizardHandler\initialize(), ListbuilderHandler\insertEntry(), VersionDAO\insertVersion(), instantiate(), TextureHandler\json(), QueryNoteFilesGridDataProvider\loadData(), MarkupHandler\media(), TextureHandler\media(), FileManager\mkdirtree(), FileLoader\moveFile(), UserXmlPKPUserFilter\parseUser(), NavigationMenuItemHandler\preview(), Config\reloadData(), PKPLocale\requireComponents(), PKPReviewerHandler\saveDeclineReview(), PKPReviewerHandler\saveStep(), XmlWebService\setReturnType(), PKPReviewerHandler\step(), PKPCatalogHandler\thumbnail(), ReviewFormElementsGridHandler\updateReviewFormElement(), UserApiHandler\updateUserMessageState(), QuickSubmitPlugin\usage(), StaticPagesHandler\view(), and ArticleHandler\view().

◆ instantiate()

& instantiate (   $fullyQualifiedClassName,
  $expectedTypes = null,
  $expectedPackages = null,
  $expectedMethods = null,
  $constructorArg = null 
)

Instantiates an object for a given fully qualified class name after executing several checks on the class.

The checks prevent certain vulnerabilities when instantiating classes generically.

NB: We currently only support one constructor argument. If we need arbitrary arguments later we can do that via func_get_args() which allows us to handle an arbitrary number of optional constructor arguments. The $constructorArg parameter needs to be last in the parameter list to be forward compatible with this potential use case.

Parameters
$fullyQualifiedClassNamestring
$expectedTypesstring|array the class must conform to at least one of the given types.
$expectedPackagesstring|array the class must be part of at least one of the given packages.
$expectedMethodsstring|array names of methods that must all be present for the requested class.
$constructorArgmixed constructor argument
Returns
object|boolean the instantiated object or false if the class instantiation didn't result in the expected type.

Definition at line 165 of file functions.inc.php.

References fatalError().

Referenced by PluginRegistry\_instantiatePlugin(), Dispatcher\_instantiateRouter(), FilterDAO\_newDataObject(), FilterDAO\configureObject(), ScheduledTaskTool\executeTask(), DAORegistry\getDAO(), MetadataDataObjectAdapter\getMetadataSchema(), MetadataDescription\getMetadataSchema(), PKPComponentRouter\getRpcServiceEndpoint(), MetadataDataObjectAdapter\instantiateDataObject(), and TypeDescriptionFactory\instantiateTypeDescription().

◆ lcfirst_codesafe()

lcfirst_codesafe (   $str)

Perform a code-safe lcfirst, i.e. one that doesn't behave differently based on different locales. (tr_TR, I'm looking at you.)

Parameters
$strstring Input string
Returns
string

Definition at line 300 of file functions.inc.php.

References strtolower_codesafe().

◆ stripAssocArray()

stripAssocArray (   $values)

Recursively strip HTML from a (multidimensional) array.

Parameters
$valuesarray
Returns
array the cleansed array

Definition at line 263 of file functions.inc.php.

Referenced by Dc11SchemaArticleAdapter\_addLocalizedElements(), OAIMetadataFormat_RFC1807\toXml(), OAIMetadataFormat_MARC21\toXml(), and OAIMetadataFormat_MARC\toXml().

◆ strtolower_codesafe()

strtolower_codesafe (   $str)

◆ strtoupper_codesafe()

strtoupper_codesafe (   $str)

Perform a code-safe strtoupper, i.e. one that doesn't behave differently based on different locales. (tr_TR, I'm looking at you.)

Parameters
$strstring Input string
Returns
string

Definition at line 290 of file functions.inc.php.

Referenced by ucfirst_codesafe().

◆ ucfirst_codesafe()

ucfirst_codesafe (   $str)

Perform a code-safe ucfirst, i.e. one that doesn't behave differently based on different locales. (tr_TR, I'm looking at you.)

Parameters
$strstring Input string
Returns
string

Definition at line 310 of file functions.inc.php.

References strtoupper_codesafe().

Referenced by PKPString\uncamelize().