_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q2900
|
Tx_Oelib_ConfigurationRegistry.getCompleteTypoScriptSetup
|
train
|
private function getCompleteTypoScriptSetup()
{
$pageUid = \Tx_Oelib_PageFinder::getInstance()->getPageUid();
if ($pageUid === 0) {
return [];
}
if ($this->existsFrontEnd()) {
return $this->getFrontEndController()->tmpl->setup;
}
/** @var TemplateService $template */
$template = GeneralUtility::makeInstance(TemplateService::class);
$template->tt_track = 0;
$template->init();
|
php
|
{
"resource": ""
}
|
q2901
|
Tx_Oelib_ConfigurationRegistry.existsFrontEnd
|
train
|
private function existsFrontEnd()
{
$frontEndController = $this->getFrontEndController();
return
|
php
|
{
"resource": ""
}
|
q2902
|
ThemeSettings.restrictAdminBarVisibility
|
train
|
public function restrictAdminBarVisibility()
{
// Don't go further if not logged in or within admin panel
if (is_admin() || !is_user_logged_in())
{
return;
}
$data = $this->getData();
// Don't go further if no setting
if ( !isset($data['admin_bar']) || empty($data['admin_bar']))
{
return;
}
$access = $data['admin_bar'];
// Is current user's role within our access roles?
$user = wp_get_current_user();
$role =
|
php
|
{
"resource": ""
}
|
q2903
|
ThemeSettings.restrictAdminPanelAccess
|
train
|
private function restrictAdminPanelAccess()
{
// Don't restrict anything when doing AJAX or CLI stuff
if ((defined('DOING_AJAX') && DOING_AJAX) || (defined('WP_CLI') && WP_CLI) || !is_user_logged_in())
{
return;
}
$data = $this->getData();
// Don't go further if no setting
if ( !isset($data['admin_access']) || empty($data['admin_access']) || !is_admin())
{
return;
}
$access = $data['admin_access'];
// Is current user's role within our access roles?
$user =
|
php
|
{
"resource": ""
}
|
q2904
|
Emogrifier.parseCssShorthandValue
|
train
|
private function parseCssShorthandValue($value)
{
$values = preg_split('/\\s+/', $value);
$css = [];
$css['top'] = $values[0];
$css['right'] = (count($values) > 1) ? $values[1] : $css['top'];
|
php
|
{
"resource": ""
}
|
q2905
|
Emogrifier.clearAllCaches
|
train
|
private function clearAllCaches()
{
$this->clearCache(self::CACHE_KEY_CSS);
$this->clearCache(self::CACHE_KEY_SELECTOR);
|
php
|
{
"resource": ""
}
|
q2906
|
Emogrifier.clearCache
|
train
|
private function clearCache($key)
{
$allowedCacheKeys = [
self::CACHE_KEY_CSS,
self::CACHE_KEY_SELECTOR,
self::CACHE_KEY_XPATH,
self::CACHE_KEY_CSS_DECLARATIONS_BLOCK,
|
php
|
{
"resource": ""
}
|
q2907
|
Emogrifier.normalizeStyleAttributes
|
train
|
private function normalizeStyleAttributes(\DOMElement $node)
{
$normalizedOriginalStyle = preg_replace_callback(
'/[A-z\\-]+(?=\\:)/S',
function (array $m) {
return strtolower($m[0]);
},
$node->getAttribute('style')
);
// in order to not overwrite existing style attributes in the HTML, we
// have to save the original HTML styles
|
php
|
{
"resource": ""
}
|
q2908
|
Emogrifier.getBodyElement
|
train
|
private function getBodyElement(\DOMDocument $document)
{
$bodyElement = $document->getElementsByTagName('body')->item(0);
if ($bodyElement === null) {
throw new \BadMethodCallException(
'getBodyElement method may only
|
php
|
{
"resource": ""
}
|
q2909
|
Emogrifier.createRawXmlDocument
|
train
|
private function createRawXmlDocument()
{
$xmlDocument = new \DOMDocument;
$xmlDocument->encoding = 'UTF-8';
$xmlDocument->strictErrorChecking = false;
$xmlDocument->formatOutput = true;
$libXmlState = libxml_use_internal_errors(true);
|
php
|
{
"resource": ""
}
|
q2910
|
Emogrifier.getUnifiedHtml
|
train
|
private function getUnifiedHtml()
{
$htmlWithoutUnprocessableTags = $this->removeUnprocessableTags($this->html);
$htmlWithDocumentType
|
php
|
{
"resource": ""
}
|
q2911
|
StatusTrait.onlyOffline
|
train
|
public static function onlyOffline()
{
$instance = new static;
$column = $instance->getQualifiedStatusColumn();
|
php
|
{
"resource": ""
}
|
q2912
|
Collection.current
|
train
|
public function current()
{
$currentKey = $this->keys[$this->position];
|
php
|
{
"resource": ""
}
|
q2913
|
Collection.valid
|
train
|
public function valid()
{
if (!isset($this->keys[$this->position])) {
return false;
}
|
php
|
{
"resource": ""
}
|
q2914
|
Tx_Oelib_DataMapper.getModel
|
train
|
public function getModel(array $data)
{
if (!isset($data['uid'])) {
throw new \InvalidArgumentException('$data must contain an element
|
php
|
{
"resource": ""
}
|
q2915
|
Tx_Oelib_DataMapper.getListOfModels
|
train
|
public function getListOfModels(array $dataOfModels)
{
$list = new \Tx_Oelib_List();
foreach ($dataOfModels as $modelRecord) {
|
php
|
{
"resource": ""
}
|
q2916
|
Tx_Oelib_DataMapper.existsModel
|
train
|
public function existsModel($uid, $allowHidden = false)
{
$model = $this->find($uid);
|
php
|
{
"resource": ""
}
|
q2917
|
Tx_Oelib_DataMapper.createRelations
|
train
|
protected function createRelations(array &$data, \Tx_Oelib_Model $model)
{
foreach (array_keys($this->relations) as $key) {
if ($this->isOneToManyRelationConfigured($key)) {
$this->createOneToManyRelation($data, $key, $model);
} elseif ($this->isManyToOneRelationConfigured($key)) {
|
php
|
{
"resource": ""
}
|
q2918
|
Tx_Oelib_DataMapper.getRelationConfigurationFromTca
|
train
|
private function getRelationConfigurationFromTca($key)
{
$tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName());
if (!isset($tca['columns'][$key])) {
throw new \BadMethodCallException(
'In the table ' . $this->getTableName() .
|
php
|
{
"resource": ""
}
|
q2919
|
Tx_Oelib_DataMapper.getNewGhost
|
train
|
public function getNewGhost()
{
$model = $this->createGhost($this->map->getNewUid());
|
php
|
{
"resource": ""
}
|
q2920
|
Tx_Oelib_DataMapper.save
|
train
|
public function save(\Tx_Oelib_Model $model)
{
if ($this->isModelAMemoryOnlyDummy($model)) {
throw new \InvalidArgumentException(
'This model is a memory-only dummy that must not be saved.',
1331319682
);
}
if (!$this->hasDatabaseAccess()
|| !$model->isDirty()
|| !$model->isLoaded()
|| $model->isReadOnly()
) {
return;
}
$data = $this->getPreparedModelData($model);
$this->cacheModelByKeys($model, $data);
if ($model->hasUid()) {
\Tx_Oelib_Db::update($this->getTableName(), 'uid = ' . $model->getUid(), $data);
$this->deleteManyToManyRelationIntermediateRecords($model);
} else {
$this->prepareDataForNewRecord($data);
|
php
|
{
"resource": ""
}
|
q2921
|
Tx_Oelib_DataMapper.getPreparedModelData
|
train
|
private function getPreparedModelData(\Tx_Oelib_Model $model)
{
if (!$model->hasUid()) {
$model->setCreationDate();
}
$model->setTimestamp();
$data = $model->getData();
foreach ($this->relations as $key => $relation) {
if ($this->isOneToManyRelationConfigured($key)) {
$functionName = 'count';
} elseif ($this->isManyToOneRelationConfigured($key)) {
$functionName = 'getUid';
if ($data[$key] instanceof \Tx_Oelib_Model) {
$this->saveManyToOneRelatedModels(
$data[$key],
\Tx_Oelib_MapperRegistry::get($relation)
);
}
} else {
if ($this->isManyToManyRelationConfigured($key)) {
$functionName = 'count';
|
php
|
{
"resource": ""
}
|
q2922
|
Tx_Oelib_DataMapper.prepareDataForNewRecord
|
train
|
protected function prepareDataForNewRecord(array &$data)
{
if ($this->testingFramework === null) {
return;
}
$tableName =
|
php
|
{
"resource": ""
}
|
q2923
|
Tx_Oelib_DataMapper.deleteOneToManyRelations
|
train
|
private function deleteOneToManyRelations(\Tx_Oelib_Model $model)
{
$data = $model->getData();
foreach ($this->relations as $key => $mapperName) {
if ($this->isOneToManyRelationConfigured($key)) {
$relatedModels = $data[$key];
if (!is_object($relatedModels)) {
continue;
}
|
php
|
{
"resource": ""
}
|
q2924
|
Tx_Oelib_DataMapper.getUniversalWhereClause
|
train
|
protected function getUniversalWhereClause($allowHiddenRecords = false)
{
$tableName = $this->getTableName();
if ($this->testingFramework !== null) {
$dummyColumnName = $this->testingFramework->getDummyColumnName($tableName);
$leftPart = \Tx_Oelib_Db::tableHasColumn($this->getTableName(), $dummyColumnName)
? $dummyColumnName . '
|
php
|
{
"resource": ""
}
|
q2925
|
Tx_Oelib_DataMapper.registerModelAsMemoryOnlyDummy
|
train
|
private function registerModelAsMemoryOnlyDummy(\Tx_Oelib_Model $model)
{
if (!$model->hasUid()) {
|
php
|
{
"resource": ""
}
|
q2926
|
Tx_Oelib_DataMapper.findByWhereClause
|
train
|
protected function findByWhereClause($whereClause = '', $sorting = '', $limit = '')
{
$orderBy = '';
$tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName());
if ($sorting !== '') {
$orderBy = $sorting;
} elseif (isset($tca['ctrl']['default_sortby'])) {
$matches = [];
if (preg_match(
'/^ORDER BY (.+)$/',
|
php
|
{
"resource": ""
}
|
q2927
|
Tx_Oelib_DataMapper.findByPageUid
|
train
|
public function findByPageUid($pageUids, $sorting = '', $limit = '')
{
if (($pageUids === '') || ($pageUids === '0') || ($pageUids === 0)) {
return $this->findByWhereClause('', $sorting, $limit);
}
|
php
|
{
"resource": ""
}
|
q2928
|
Tx_Oelib_DataMapper.findOneByKeyFromCache
|
train
|
protected function findOneByKeyFromCache($key, $value)
{
if ($key === '') {
throw new \InvalidArgumentException('$key must not be empty.', 1416847364);
}
if (!isset($this->cacheByKey[$key])) {
throw new \InvalidArgumentException('"' . $key . '" is not a valid key for this mapper.', 1331319882);
}
if ($value === '') {
|
php
|
{
"resource": ""
}
|
q2929
|
Tx_Oelib_DataMapper.findOneByCompoundKeyFromCache
|
train
|
public function findOneByCompoundKeyFromCache($value)
{
if ($value === '') {
throw new \InvalidArgumentException('$value must not be
|
php
|
{
"resource": ""
}
|
q2930
|
Tx_Oelib_DataMapper.cacheModelByCompoundKey
|
train
|
protected function cacheModelByCompoundKey(\Tx_Oelib_Model $model, array $data)
{
if (empty($this->compoundKeyParts)) {
throw new \BadMethodCallException(
'The compound key parts are not defined.',
1363806895
);
}
$values = [];
foreach ($this->compoundKeyParts as $key) {
if (isset($data[$key])) {
$values[] = $data[$key];
|
php
|
{
"resource": ""
}
|
q2931
|
Tx_Oelib_DataMapper.findOneByKey
|
train
|
public function findOneByKey($key, $value)
{
try {
$model = $this->findOneByKeyFromCache($key, $value);
} catch (\Tx_Oelib_Exception_NotFound $exception) {
|
php
|
{
"resource": ""
}
|
q2932
|
Tx_Oelib_DataMapper.findOneByCompoundKey
|
train
|
public function findOneByCompoundKey(array $compoundKeyValues)
{
if (empty($compoundKeyValues)) {
throw new \InvalidArgumentException(
get_class($this) . '::compoundKeyValues must not be empty.',
|
php
|
{
"resource": ""
}
|
q2933
|
Tx_Oelib_DataMapper.extractCompoundKeyValues
|
train
|
protected function extractCompoundKeyValues(array $compoundKeyValues)
{
$values = [];
foreach ($this->compoundKeyParts as $key) {
if (!isset($compoundKeyValues[$key])) {
throw new \InvalidArgumentException(
|
php
|
{
"resource": ""
}
|
q2934
|
Tx_Oelib_DataMapper.countByWhereClause
|
train
|
public function countByWhereClause($whereClause = '')
{
$completeWhereClause = ($whereClause === '')
? ''
: $whereClause . ' AND ';
|
php
|
{
"resource": ""
}
|
q2935
|
Tx_Oelib_DataMapper.countByPageUid
|
train
|
public function countByPageUid($pageUids)
{
if (($pageUids === '') || ($pageUids === '0')) {
return $this->countByWhereClause('');
|
php
|
{
"resource": ""
}
|
q2936
|
GiroCheckout_SDK_Tools.getCreditCardLogoName
|
train
|
public static function getCreditCardLogoName($visa_msc = false, $amex = false, $jcb = false) {
if( $visa_msc == false && $amex == false && $jcb == false ) {
return null;
}
$logoName = '';
if( $visa_msc ) {
$logoName .= 'visa_msc_';
|
php
|
{
"resource": ""
}
|
q2937
|
DataTablesRepositoryHelper.appendOrder
|
train
|
public static function appendOrder(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) {
foreach ($dtWrapper->getRequest()->getOrder() as $dtOrder) {
$dtColumn = array_values($dtWrapper->getColumns())[$dtOrder->getColumn()];
|
php
|
{
"resource": ""
}
|
q2938
|
DataTablesRepositoryHelper.appendWhere
|
train
|
public static function appendWhere(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) {
$operator = static::determineOperator($dtWrapper);
if (null === $operator) {
return;
}
$wheres = [];
$params = [];
$values = [];
foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) {
if (true === $dtColumn->getSearchable() && ("OR" === $operator || ""
|
php
|
{
"resource": ""
}
|
q2939
|
DataTablesRepositoryHelper.determineOperator
|
train
|
public static function determineOperator(DataTablesWrapperInterface $dtWrapper) {
foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) {
if (false === $dtColumn->getSearchable()) {
continue;
}
if ("" !== $dtColumn->getSearch()->getValue()) {
return "AND";
}
|
php
|
{
"resource": ""
}
|
q2940
|
Library.init
|
train
|
final public function init($sName, $xDialog)
{
// Set the library name
$this->sName = $sName;
// Set the dialog
$this->xDialog = $xDialog;
// Set the Response instance
$this->setResponse($xDialog->response());
// Set the default URI.
$this->sUri = $this->xDialog->getOption('dialogs.lib.uri', $this->sUri);
// Set the library URI.
$this->sUri =
|
php
|
{
"resource": ""
}
|
q2941
|
Library.hasOption
|
train
|
final public function hasOption($sName)
{
$sName = 'dialogs.' . $this->getName() . '.' . $sName;
|
php
|
{
"resource": ""
}
|
q2942
|
Configuration.create
|
train
|
public static function create($mapping = array())
{
$defaultMapping = array(
'autoload' => self::DEFAULT_INITIALIZER_NS . '\Autoload',
'dependencies' => self::DEFAULT_INITIALIZER_NS . '\Dependencies',
'general-settings' => self::DEFAULT_INITIALIZER_NS . '\ThemeSettings',
'customizer' => self::DEFAULT_INITIALIZER_NS . '\Customizer',
'image-sizes' => self::DEFAULT_INITIALIZER_NS . '\ImageSizes',
'widget-areas' => self::DEFAULT_INITIALIZER_NS . '\WidgetAreas',
'menu-locations' => self::DEFAULT_INITIALIZER_NS . '\MenuLocations',
|
php
|
{
"resource": ""
}
|
q2943
|
Configuration.apply
|
train
|
public function apply()
{
foreach ($this->initializers as $id => $initializer)
{
do_action('baobab/configuration/before-initializer?id=' .
|
php
|
{
"resource": ""
}
|
q2944
|
Configuration.getOrThrow
|
train
|
public function getOrThrow($section, $key)
{
if ( !isset($this->initializers[$section]))
|
php
|
{
"resource": ""
}
|
q2945
|
Configuration.get
|
train
|
public function get($section, $key, $defaultValue = null)
{
if ( !isset($this->initializers[$section]))
{
return $defaultValue;
}
|
php
|
{
"resource": ""
}
|
q2946
|
Tx_Oelib_ViewHelpers_UppercaseViewHelper.render
|
train
|
public function render()
{
$renderedChildren = $this->renderChildren();
|
php
|
{
"resource": ""
}
|
q2947
|
MustacheUtil.loadHelpers
|
train
|
public static function loadHelpers() {
// set-up helper container
$helpers = array();
// load defaults
$helperDir = Config::getOption("sourceDir").DIRECTORY_SEPARATOR."_mustache-components/helpers";
$helperExt = Config::getOption("mustacheHelperExt");
$helperExt = $helperExt ? $helperExt : "helper.php";
if (is_dir($helperDir)) {
// loop through the filter dir...
$finder = new Finder();
$finder->files()->name("*\.".$helperExt)->in($helperDir);
$finder->sortByName();
foreach ($finder as $file) {
// see if the file should be ignored or not
$baseName = $file->getBasename();
if ($baseName[0] != "_") {
include($file->getPathname());
// $key may
|
php
|
{
"resource": ""
}
|
q2948
|
Tx_Oelib_Mail.setSubject
|
train
|
public function setSubject($subject)
{
if ($subject === '') {
throw new \InvalidArgumentException('$subject must not be empty.', 1331488802);
}
if ((strpos($subject, CR) !== false) || (strpos($subject, LF) !== false)) {
throw new \InvalidArgumentException(
|
php
|
{
"resource": ""
}
|
q2949
|
Tx_Oelib_Mail.setHTMLMessage
|
train
|
public function setHTMLMessage($message)
{
if ($message === '') {
throw new \InvalidArgumentException('$message must not be empty.', 1331488845);
}
if ($this->hasCssFile()) {
$this->loadEmogrifierClass();
$emogrifier = new Emogrifier($message, $this->getCssFile());
|
php
|
{
"resource": ""
}
|
q2950
|
Tx_Oelib_Mail.setCssFile
|
train
|
public function setCssFile($cssFile)
{
if (!$this->cssFileIsCached($cssFile)) {
$absoluteFileName = GeneralUtility::getFileAbsFileName($cssFile);
if (($cssFile !== '') && is_readable($absoluteFileName)
) {
self::$cssFileCache[$cssFile] = file_get_contents($absoluteFileName);
|
php
|
{
"resource": ""
}
|
q2951
|
Tx_Oelib_Mapper_FrontEndUser.getGroupMembers
|
train
|
public function getGroupMembers($groupUids)
{
if ($groupUids === '') {
throw new \InvalidArgumentException('$groupUids must not be an empty string.', 1331488505);
}
return $this->getListOfModels(
|
php
|
{
"resource": ""
}
|
q2952
|
AuthHelper.generateAppCredentials
|
train
|
public function generateAppCredentials($apiKey, $apiSecret)
{
$apiKey = urlencode($apiKey);
$apiSecret = urlencode($apiSecret);
|
php
|
{
"resource": ""
}
|
q2953
|
MetadataAwareStringFrontend.insertMetadata
|
train
|
protected function insertMetadata($content, $entryIdentifier, array $tags, $lifetime)
{
if (!is_string($content)) {
throw new InvalidDataTypeException('Given data is of type "' . gettype($content) . '", but a string is expected for string cache.', 1433155737);
|
php
|
{
"resource": ""
}
|
q2954
|
MetadataAwareStringFrontend.extractMetadata
|
train
|
protected function extractMetadata($entryIdentifier, $content)
{
$separatorIndex = strpos($content, self::SEPARATOR);
if ($separatorIndex === false) {
$exception = new InvalidDataTypeException('Could not find cache metadata in entry with identifier ' . $entryIdentifier, 1433155925);
if ($this->environment->getContext()->isProduction()) {
$this->logger->logException($exception);
} else {
throw $exception;
}
}
$metadataJson = substr($content, 0, $separatorIndex);
$metadata = json_decode($metadataJson, true);
|
php
|
{
"resource": ""
}
|
q2955
|
Intuition.setLang
|
train
|
public function setLang( $lang ) {
if ( !IntuitionUtil::nonEmptyStr( $lang ) ) {
return false;
|
php
|
{
"resource": ""
}
|
q2956
|
Intuition.getMessagesFunctions
|
train
|
protected function getMessagesFunctions() {
if ( $this->messagesFunctions == null ) {
$this->messagesFunctions =
|
php
|
{
"resource": ""
}
|
q2957
|
Intuition.msg
|
train
|
public function msg( $key = 0, $options = [], $fail = null ) {
if ( !IntuitionUtil::nonEmptyStr( $key ) ) {
// Invalid message key
return $this->bracketMsg( $key, $fail );
}
$defaultOptions = [
'domain' => $this->getDomain(),
'lang' => $this->getLang(),
'variables' => [],
'raw-variables' => false,
'escape' => 'plain',
'parsemag' => true,
'externallinks' => false,
// Set to a wiki article path for converting
'wikilinks' => false,
];
// If $options was a domain string, convert it now.
if ( IntuitionUtil::nonEmptyStr( $options ) ) {
$options = [ 'domain' => $options ];
}
// If $options is still not an array, ignore it and use default
// Otherwise merge the options with the defaults.
if ( !is_array( $options ) ) {
// @codeCoverageIgnoreStart
$options = $defaultOptions;
} else {
// @codeCoverageIgnoreEnd
$options = array_merge( $defaultOptions, $options );
}
|
php
|
{
"resource": ""
}
|
q2958
|
Intuition.setMsg
|
train
|
public function setMsg( $key, $message, $domain = null, $lang = null ) {
$domain = IntuitionUtil::nonEmptyStr( $domain )
? $this->normalizeDomain( $domain )
: $this->getDomain();
$lang = IntuitionUtil::nonEmptyStr( $lang )
?
|
php
|
{
"resource": ""
}
|
q2959
|
Intuition.setMsgs
|
train
|
public function setMsgs( $messagesByKey, $domain = null, $lang = null ) {
foreach ( $messagesByKey as $key => $message
|
php
|
{
"resource": ""
}
|
q2960
|
Intuition.registerDomain
|
train
|
public function registerDomain( $domain, $dir, $info = [] ) {
|
php
|
{
"resource": ""
}
|
q2961
|
Intuition.addDomainInfo
|
train
|
public function addDomainInfo( $domain, array $info ) {
$domain = $this->normalizeDomain(
|
php
|
{
"resource": ""
}
|
q2962
|
Intuition.listMsgs
|
train
|
public function listMsgs( $domain ) {
$domain = $this->normalizeDomain( $domain );
$this->ensureLoaded( $domain, 'en' );
// Ignore load failure to allow listing of messages that
// were manually registered (in case there are any).
|
php
|
{
"resource": ""
}
|
q2963
|
Intuition.getLangFallbacks
|
train
|
public function getLangFallbacks( $lang ) {
if ( self::$fallbackCache === null ) {
// Lazy-initialize
self::$fallbackCache = $this->fetchLangFallbacks();
}
$lang
|
php
|
{
"resource": ""
}
|
q2964
|
Intuition.getLangName
|
train
|
public function getLangName( $lang = false ) {
$lang = $lang ? $this->normalizeLang( $lang ) :
|
php
|
{
"resource": ""
}
|
q2965
|
Intuition.getLangNames
|
train
|
public function getLangNames() {
// Lazy-load and cache
if ( $this->langNames === null ) {
$path = $this->localBaseDir . '/language/mw-classes/Names.php';
// @codeCoverageIgnoreStart
if ( !is_readable( $path ) ) {
$this->errTrigger( 'Names.php is missing', __METHOD__, E_NOTICE );
$this->langNames = [];
return [];
}
//
|
php
|
{
"resource": ""
}
|
q2966
|
Intuition.addAvailableLang
|
train
|
public function addAvailableLang( $code, $name ) {
// Initialise $this->langNames so that we can extend it
$this->getLangNames();
$normalizedCode = $this->normalizeLang( $code );
|
php
|
{
"resource": ""
}
|
q2967
|
Intuition.ensureLoaded
|
train
|
protected function ensureLoaded( $domain, $lang ) {
if ( isset( $this->loadedDomains[ $domain ][ $lang ] ) ) {
// Already tried
return $this->loadedDomains[ $domain ][ $lang ];
}
// Validate input and protect against path traversal
if ( !IntuitionUtil::nonEmptyStrs( $domain, $lang ) ||
strcspn( $domain, ":/\\\000" ) !== strlen( $domain ) ||
strcspn( $lang, ":/\\\000" ) !== strlen( $lang )
) {
$this->errTrigger( 'Illegal domain or lang', __METHOD__, E_NOTICE );
return false;
}
$this->loadedDomains[ $domain ][ $lang ] = false;
if ( !isset( self::$messageCache[ $domain ][ $lang ] ) ) {
// Load from disk
$domainInfo = $this->getDomainInfo( $domain );
if ( !$domainInfo ) {
// Unknown domain. Perhaps dev-mode only with
//
|
php
|
{
"resource": ""
}
|
q2968
|
Intuition.setExpiryTrackerCookie
|
train
|
protected function setExpiryTrackerCookie( $lifetime ) {
$val = time() + $lifetime;
|
php
|
{
"resource": ""
}
|
q2969
|
Intuition.renewCookies
|
train
|
public function renewCookies( $lifetime = 2592000 ) {
foreach ( $this->getCookieNames() as $key => $name ) {
if ( $key === 'track-expire' ) {
continue;
}
if ( isset( $_COOKIE[$name]
|
php
|
{
"resource": ""
}
|
q2970
|
Intuition.wipeCookies
|
train
|
public function wipeCookies() {
foreach ( $this->getCookieNames() as $key => $name ) {
$this->setCookie( $key, '', -3600,
|
php
|
{
"resource": ""
}
|
q2971
|
Intuition.getCookieExpiration
|
train
|
public function getCookieExpiration() {
$name = $this->getCookieName( 'track-expire' );
|
php
|
{
"resource": ""
}
|
q2972
|
Intuition.getPromoBox
|
train
|
public function getPromoBox( $imgSize = 28, $helpTranslateDomain = TSINT_HELP_CURRENT ) {
// Logo
if ( is_int( $imgSize ) && $imgSize > 0 ) {
$src = '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Tool_labs_logo.svg/'
. '/' . $imgSize . 'px-Tool_labs_logo.svg.png';
$src_2x = '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Tool_labs_logo.svg/'
. '/' . ( $imgSize * 2 ) . 'px-Tool_labs_logo.svg.png';
$img = IntuitionUtil::tag( '', 'img', [
'src' => $src,
'srcset' => "$src 1x, $src_2x 2x",
'width' => $imgSize,
'height' => $imgSize,
'alt' => '',
'title' => '',
'class' => 'int-logo',
] );
} else {
$img = '';
}
// Promo message
$promoMsgOpts = [
'domain' => 'tsintuition',
'escape' => 'html',
'raw-variables' => true,
'variables' => [
'<a href="//translatewiki.net/">translatewiki.net</a>',
'<a href="' . $this->dashboardHome . '">Intuition</a>'
],
];
$poweredHtml = $this->msg( 'bl-promo', $promoMsgOpts );
// "Help translation" link
$translateGroup = null;
if ( $helpTranslateDomain === TSINT_HELP_ALL ) {
$translateGroup = 'tsint-0-all';
$twLinkText = $this->msg( 'help-translate-all', 'tsintuition' );
} elseif ( $helpTranslateDomain === TSINT_HELP_CURRENT ) {
$domain = $this->getDomain();
$translateGroup = $this->isLocalDomain( $domain ) ? "tsint-{$domain}" : "int-{$domain}";
$twLinkText = $this->msg( 'help-translate-tool', 'tsintuition' );
} elseif
|
php
|
{
"resource": ""
}
|
q2973
|
Intuition.getDashboardReturnToUrl
|
train
|
public function getDashboardReturnToUrl() {
$p = [
'returnto' => $_SERVER['SCRIPT_NAME'],
'returntoquery' => http_build_query( $_GET ),
];
|
php
|
{
"resource": ""
}
|
q2974
|
Intuition.redirectTo
|
train
|
public function redirectTo( $url = 0, $code = 302 ) {
if ( $url === null ) {
$this->redirectTo = null;
return true;
}
if ( !is_string( $url ) || !is_int( $code
|
php
|
{
"resource": ""
}
|
q2975
|
Intuition.dateFormatted
|
train
|
public function dateFormatted( $first = null, $second = null, $lang = null ) {
// One argument or less
if ( $second === null ) {
// No arguments
if ( $first === null ) {
$format = $this->msg( 'dateformat', 'general' );
$timestamp = time();
// Timestamp only
} elseif ( is_int( $first ) ) {
$format = $this->msg( 'dateformat', 'general' );
$timestamp = $first;
// Date string only
} elseif ( strtotime( $first ) ) {
$format = $this->msg( 'dateformat', 'general' );
$timestamp = strtotime( $first );
// Format only
} else {
$format = $first;
$timestamp = time();
}
// Two arguments
} else {
|
php
|
{
"resource": ""
}
|
q2976
|
Intuition.initLangSelect
|
train
|
protected function initLangSelect( $option = null ) {
if ( $option !== null &&
$option !== false &&
$option !== '' &&
$this->setLang( $option )
) {
return true;
}
if ( $this->getUseRequestParam() ) {
$key = $this->paramNames['userlang'];
if ( isset( $_GET[ $key ] ) && $this->setLang( $_GET[ $key ] ) ) {
return true;
}
if ( isset( $_POST[ $key ] ) && $this->setLang( $_POST[ $key ] ) ) {
return true;
}
}
if ( isset( $_COOKIE[ $this->cookieNames['userlang'] ] ) ) {
$set = $this->setLang( $_COOKIE[ $this->cookieNames['userlang'] ] );
if ( $set ) {
return true;
}
}
$acceptableLanguages = IntuitionUtil::getAcceptableLanguages();
foreach ( $acceptableLanguages as $acceptLang => $qVal ) {
// If the
|
php
|
{
"resource": ""
}
|
q2977
|
Intuition.isRtl
|
train
|
public function isRtl( $lang = null ) {
static $rtlLanguages = null;
$lang = $lang ? $this->normalizeLang( $lang ) : $this->getLang();
if ( $rtlLanguages === null ) {
$file = $this->localBaseDir . '/language/rtl.json';
|
php
|
{
"resource": ""
}
|
q2978
|
Entity.delete
|
train
|
public function delete() {
$url = "entities";
if ($this->_id) {
$url .= "/{$this->_id}";
|
php
|
{
"resource": ""
}
|
q2979
|
Entity.getAttribute
|
train
|
public function getAttribute($attr) {
$url = "entities/{$this->_id}/attrs/$attr";
if ($this->_type) {
|
php
|
{
"resource": ""
}
|
q2980
|
Entity.getAttributeValue
|
train
|
public function getAttributeValue($attr, &$request = null) {
$url = "entities/{$this->_id}/attrs/$attr/value";
|
php
|
{
"resource": ""
}
|
q2981
|
Entity.deleteAttribute
|
train
|
public function deleteAttribute($attr) {
$url = "entities/{$this->_id}/attrs/$attr";
if ($this->_type) {
|
php
|
{
"resource": ""
}
|
q2982
|
Entity.replaceAttributes
|
train
|
public function replaceAttributes(array $attrs) {
$url = "entities/{$this->_id}/attrs";
if ($this->_type) {
$url .= "?type={$this->_type}";
}
$updateEntity =
|
php
|
{
"resource": ""
}
|
q2983
|
Entity.appendAttribute
|
train
|
public function appendAttribute($attr, $value, $type, $metadata = null, $options = []) {
$attrs = [
$attr => [
"value" => $value,
"type" => $type
]
|
php
|
{
"resource": ""
}
|
q2984
|
Entity.appendAttributes
|
train
|
public function appendAttributes(array $attrs, $options = ["option" => "append"]) {
$url = "entities/{$this->_id}/attrs";
if ($this->_type) {
$url .= "?type={$this->_type}";
}
if (count($options) > 0) {
$prefix
|
php
|
{
"resource": ""
}
|
q2985
|
Entity.coordsQueryString
|
train
|
private function coordsQueryString(array $coords) {
$count = count($coords);
//If is a simple lat long array
if ($count == 2) {
if (is_numeric($coords[0]) && is_numeric($coords[1])) {
/**
* Orion uses Lat/Lng value instead Lng/Lat as GeoJson format,
* since a geoJson is passed it should be reversed to fit on Orion Format.
* All function of array_reverse uses
*/
return implode(',', array_reverse($coords));
// return implode(',', $coords);
} elseif (is_array($coords[0]) && is_array($coords[1])) { //Maybe is a 2 points line
foreach ($coords[0] as $key => $coord) {
$coords[0][$key] = implode(',', array_reverse($coord));
// $coords[0][$key] = implode(',', $coord);
}
return implode(";", $coords[0]);
}
}
//If is a polygon geometry, multiple polygons aren't supported
if ($count == 1 && is_array($coords[0]) && count($coords[0]) >= 3) {
foreach ($coords[0] as $key => $coord) {
|
php
|
{
"resource": ""
}
|
q2986
|
Entity.geoQuery
|
train
|
public function geoQuery($georel, $geoJson, array $modifiers = [], array $options = [], &$request = null) {
if (is_string($geoJson)) {
$geoJson = json_decode($geoJson);
} elseif (is_array($geoJson)) {
$geoJson = (object) $geoJson;
}
if
|
php
|
{
"resource": ""
}
|
q2987
|
Entity.getCoveredBy
|
train
|
public function getCoveredBy($geoJson, array $modifiers = [], array $options = [], &$request = null) {
|
php
|
{
"resource": ""
}
|
q2988
|
Entity.getIntersections
|
train
|
public function getIntersections($geoJson, array $modifiers = [], array $options =
|
php
|
{
"resource": ""
}
|
q2989
|
Entity.getDisjoints
|
train
|
public function getDisjoints($geoJson, array $modifiers = [], array $options = [], &$request = null) {
|
php
|
{
"resource": ""
}
|
q2990
|
Entity.getGeoEquals
|
train
|
public function getGeoEquals($geoJson, array $modifiers = [], array $options = [], &$request) {
|
php
|
{
"resource": ""
}
|
q2991
|
GiroCheckout_SDK_Debug_helper.init
|
train
|
public function init($logFilePrefix) {
self::$logFileName = date('Y-m-d_H-i-s') . '-' . ucfirst($logFilePrefix) . '-' . md5(time()) . '.log';
$ssl = null;
$this->writeLog(sprintf($this->debugStrings['start'], date('Y-m-d H:i:s')));
if (in_array('curl', get_loaded_extensions())) {
$curl_version = curl_version();
$curl = $curl_version['version'];
$ssl = $curl_version['ssl_version'];
}
|
php
|
{
"resource": ""
}
|
q2992
|
GiroCheckout_SDK_Debug_helper.logParamsSet
|
train
|
public function logParamsSet($paramsArray) {
$paramsString = '';
foreach ($paramsArray as $k => $v) {
$paramsString .= "$k=$v\r\n";
}
|
php
|
{
"resource": ""
}
|
q2993
|
GiroCheckout_SDK_Debug_helper.logReplyParams
|
train
|
public function logReplyParams($params) {
$paramsString = '';
foreach ($params as $k => $v) {
$paramsString .=
|
php
|
{
"resource": ""
}
|
q2994
|
GiroCheckout_SDK_Debug_helper.logNotificationInput
|
train
|
public function logNotificationInput($paramsArray) {
$this->writeLog(sprintf($this->debugStrings['notifyInput'],
|
php
|
{
"resource": ""
}
|
q2995
|
GiroCheckout_SDK_Debug_helper.logNotificationParams
|
train
|
public function logNotificationParams($paramsArray) {
$this->writeLog(sprintf($this->debugStrings['notifyParams'],
|
php
|
{
"resource": ""
}
|
q2996
|
GiroCheckout_SDK_Debug_helper.writeLog
|
train
|
public function writeLog($string) {
$Config = GiroCheckout_SDK_Config::getInstance();
$path = str_replace('\\', '/', $Config->getConfig('DEBUG_LOG_PATH'));
if (!is_dir($path)) {
if (!mkdir($path)) {
error_log('Log directory does not exist. Please create directory: ' . $path . '.');
|
php
|
{
"resource": ""
}
|
q2997
|
WordPressLoopExtension.register
|
train
|
public function register($compiler)
{
$this->registerStartLoopQuery($compiler);
|
php
|
{
"resource": ""
}
|
q2998
|
DataTablesColumn.setOrderSequence
|
train
|
public function setOrderSequence($orderSequence) {
if (false === in_array($orderSequence, DataTablesEnumerator::enumOrderSequences())) {
$orderSequence = null;
|
php
|
{
"resource": ""
}
|
q2999
|
SitemapGenerator.add
|
train
|
public function add($object)
{
if (is_a($object, 'Closure')) {
return $this->closures[] = $object;
}
$this->validateObject($object);
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.