_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6900 | ConfigurationReader.createRepository | train | protected function createRepository(ObjectAccess $repository)
{
if ($repository->exists('packagist')) {
return new PackagistRepository(
$repository->get('packagist'),
$repository->data()
);
}
$type = $repository->get('type');
if ('package' === $type) {
$repository = new PackageRepository(
$this->objectToArray($repository->get('package')),
$this->objectToArray($repository->getDefault('options')),
$repository->data()
);
| php | {
"resource": ""
} |
q6901 | ConfigurationReader.createProjectConfiguration | train | protected function createProjectConfiguration(stdClass $config = null)
{
if (null === $config) {
return new ProjectConfiguration(
null,
null,
null,
null,
null,
null,
null,
$this->defaultCacheDir()
);
}
$configData = new ObjectAccess($config);
$cacheDir = $configData->getDefault('cache-dir');
if (null === $cacheDir) {
$cacheDir = $this->defaultCacheDir();
}
return new ProjectConfiguration(
$configData->getDefault('process-timeout'),
$configData->getDefault('use-include-path'),
$this->createInstallationMethod(
$configData->getDefault('preferred-install')
),
$configData->getDefault('github-protocols'),
$this->objectToArray($configData->getDefault('github-oauth')),
$configData->getDefault('vendor-dir'),
$configData->getDefault('bin-dir'),
$cacheDir,
$configData->getDefault('cache-files-dir'),
$configData->getDefault('cache-repo-dir'),
$configData->getDefault('cache-vcs-dir'),
| php | {
"resource": ""
} |
q6902 | ConfigurationReader.defaultCacheDir | train | protected function defaultCacheDir()
{
$cacheDir = getenv('COMPOSER_CACHE_DIR');
if ($cacheDir) {
return $cacheDir;
}
$home = getenv('COMPOSER_HOME');
$isWindows = defined('PHP_WINDOWS_VERSION_MAJOR');
if (!$home) {
if ($isWindows) {
if ($envAppData = getenv('APPDATA')) {
$home = strtr($envAppData, '\\', '/') . '/Composer';
}
} elseif ($envHome = getenv('HOME')) {
$home = rtrim($envHome, '/') . '/.composer';
}
}
if ($home && !$cacheDir) {
if ($isWindows) {
if ($cacheDir = getenv('LOCALAPPDATA')) {
| php | {
"resource": ""
} |
q6903 | ConfigurationReader.createInstallationMethod | train | protected function createInstallationMethod($method)
{
if (is_string($method)) {
return InstallationMethod::memberByValue($method, false);
}
if (is_object($method)) {
| php | {
"resource": ""
} |
q6904 | ConfigurationReader.createVcsChangePolicy | train | protected function createVcsChangePolicy($policy)
{
if (null !== $policy) { | php | {
"resource": ""
} |
q6905 | ConfigurationReader.createScripts | train | protected function createScripts(stdClass $scripts = null)
{
if (null !== $scripts) {
$scriptsData = new ObjectAccess($scripts);
$scripts = new ScriptConfiguration(
$this->arrayize($scriptsData->getDefault('pre-install-cmd')),
$this->arrayize($scriptsData->getDefault('post-install-cmd')),
$this->arrayize($scriptsData->getDefault('pre-update-cmd')),
$this->arrayize($scriptsData->getDefault('post-update-cmd')),
$this->arrayize($scriptsData->getDefault('pre-status-cmd')),
$this->arrayize($scriptsData->getDefault('post-status-cmd')),
$this->arrayize($scriptsData->getDefault('pre-package-install')),
$this->arrayize($scriptsData->getDefault('post-package-install')),
$this->arrayize($scriptsData->getDefault('pre-package-update')),
$this->arrayize($scriptsData->getDefault('post-package-update')),
| php | {
"resource": ""
} |
q6906 | ConfigurationReader.createArchiveConfiguration | train | protected function createArchiveConfiguration(stdClass $archive = null)
{
if (null !== $archive) {
$archiveData = new ObjectAccess($archive);
| php | {
"resource": ""
} |
q6907 | ConfigurationReader.objectToArray | train | protected function objectToArray(stdClass $data = null)
{
if (null !== $data) {
$data = (array) $data;
foreach ($data as $key => $value) {
if ($value instanceof stdClass) {
| php | {
"resource": ""
} |
q6908 | Template.execute | train | final function execute() {
//parse content first, to allow for any ADDTEMPLATE items
$content = $this->parseContent($this->data['bodycontent']);
if( !$this->getLayoutClass() ){
throw new \Exception('No layout class defined.');
}
$layoutClass = $this->getLayoutClass();
$layout = new $layoutClass($this->getSkin(), $this);
//set up standard content zones
//head element (including opening body tag)
$layout->addHTMLTo('head', $this->html('headelement') );
//the logo image defined in LocalSettings
$layout->addHTMLTo('logo', $this->data['logopath']);
$layout->addHTMLTo('prepend:body', $this->html( 'prebodyhtml' ));
//the article title
if($this->showTitle){
$layout->addHTMLTo('content-container.class', 'has-title');
$layout->addHTMLTo('title-html', $this->data['title']);
}
//article content
$layout->addHTMLTo('content-html', $content);
//the site notice
if( !empty($this->data['sitenotice'])){
$layout->addHTMLTo('site-notice', $this->data['sitenotice']);
}
//the site tagline, if there is one
if($this->showTagline){
$layout->addHTMLTo('content-container.class', 'has-tagline');
$layout->addHTMLTo('tagline', $this->getMsg('tagline') );
}
$breadcrumbTrees = $this->breadcrumbs();
$layout->addTemplateTo('breadcrumbs', 'breadcrumbs', array('trees' => $breadcrumbTrees) );
// if(\Skinny::hasContent('toc')){
// $layout->addHTMLTo('toc', (\Skinny::getContent('toc')[0]['html']));
// }
// if ( $this->data['dataAfterContent'] ) {
// $layout->addHTMLTo('append:content', $this->data['dataAfterContent']); | php | {
"resource": ""
} |
q6909 | Template.transclude | train | function transclude($string){
echo $GLOBALS['wgParser']->parse('{{'.$string.'}}', | php | {
"resource": ""
} |
q6910 | Template.parseContent | train | public function parseContent( $html ){
$pattern = '~<p>ADDTEMPLATE\(([\w_:-]*)\):([\w_-]+):ETALPMETDDA<\/p>~m';
if( preg_match_all($pattern, $html, $matches, PREG_SET_ORDER) ){
foreach($matches as $match){
//if a zone is specified, attach the | php | {
"resource": ""
} |
q6911 | ResolverExecutor.arrayToObject | train | private function arrayToObject(array $data, FieldsAwareDefinitionInterface $definition)
{
$class = null;
if ($definition instanceof ClassAwareDefinitionInterface) {
$class = $definition->getClass();
}
//normalize data
foreach ($data as $fieldName => &$value) {
if (!$definition->hasField($fieldName)) {
continue;
}
$fieldDefinition = $definition->getField($fieldName);
$value = $this->normalizeValue($value, $fieldDefinition->getType());
}
unset($value);
//instantiate object
if (class_exists($class)) {
$object = new $class();
} else {
$object = $data;
}
//populate object
foreach ($data as $key => $value) {
if (!$definition->hasField($key)) {
continue;
} | php | {
"resource": ""
} |
q6912 | AfricasTalkingGateway.getUserData | train | public function getUserData()
{
$username = $this->_username;
$this->_requestUrl = self::USER_DATA_URL.'?username='.$username;
$this->executeGet();
if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) {
$responseObject = json_decode($this->_responseBody); | php | {
"resource": ""
} |
q6913 | MGP25.processAllMessages | train | private function processAllMessages()
{
$processed = [];
$receivers = $this->receivers();
$messages = $this->manager->getMessages();
foreach ($receivers as $receiver)
{
foreach ($messages as $index => $message)
{
$this->composition($receiver, $message);
$id = $this->sendMessage($receiver, $message);
$copy = new stdClass();
$copy->id = $id;
$copy->type = $message->type;
| php | {
"resource": ""
} |
q6914 | MGP25.sendMessage | train | private function sendMessage($receiver, $message)
{
$id = null;
switch ($message->type)
{
case 'text':
$id = $this->broadcast
? $this->gateway()->sendBroadcastMessage($receiver, $message->message)
: $this->gateway()->sendMessage($receiver, $message->message);
break;
case 'image':
$id = $this->broadcast
? $this->gateway()->sendBroadcastImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption)
: $this->gateway()->sendMessageImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption);
break;
case 'audio':
$id = $this->broadcast
? $this->gateway()->sendBroadcastAudio($receiver, $message->file, false, $message->filesize, $message->hash)
: $this->gateway()->sendMessageAudio($receiver, $message->file, false, $message->filesize, $message->hash);
break;
case 'video':
$id = $this->broadcast
? $this->gateway()->sendBroadcastVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption)
: $this->gateway()->sendMessageVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption);
| php | {
"resource": ""
} |
q6915 | MGP25.receivers | train | private function receivers()
{
if(count($this->manager->getReceivers()) <= 10)
{
return $this->manager->getReceivers();
}
$this->broadcast = true;
$receivers = [];
$allReceivers = $this->manager->getReceivers();
| php | {
"resource": ""
} |
q6916 | MGP25.composition | train | private function composition($receiver, stdClass $message)
{
if(!$this->broadcast)
{
| php | {
"resource": ""
} |
q6917 | MGP25.connectAndLogin | train | public function connectAndLogin()
{
if(!$this->connected)
{
$account = $this->config["default"];
$this->whatsProt->connect();
$this->whatsProt->loginWithPassword($this->password);
$this->whatsProt->sendGetClientConfig();
$this->whatsProt->sendGetServerProperties();
$this->whatsProt->sendGetGroups();
| php | {
"resource": ""
} |
q6918 | MGP25.logoutAndDisconnect | train | public function logoutAndDisconnect()
{
if($this->connected)
{
// Adds some delay defore disconnect
sleep(rand(1, 2));
| php | {
"resource": ""
} |
q6919 | NewsHolder.getCMSFields | train | public function getCMSFields() {
$fields = parent::getCMSFields();
$modes = array(
'' => 'No filing',
'day' => '/Year/Month/Day',
'month' => '/Year/Month',
'year' => '/Year'
);
$fields->addFieldToTab('Root.Main', new DropdownField('FilingMode', _t('NewsHolder.FILING_MODE', 'File into'), $modes), 'Content');
$fields->addFieldToTab('Root.Main', new DropdownField('FileBy', _t('NewsHolder.FILE_BY', 'File by'), array('Published' => 'Published', 'Created' => 'Created')), 'Content');
$fields->addFieldToTab('Root.Main', new CheckboxField('PrimaryNewsSection', _t('NewsHolder.PRIMARY_SECTION', 'Is this a primary news section?'), true), | php | {
"resource": ""
} |
q6920 | NewsHolder.Articles | train | public function Articles($number=null) {
if (!$number) {
$number = $this->numberToDisplay;
}
$start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
if ($start < 0) {
$start = 0;
}
$articles = null;
$filter = null;
if ($this->PrimaryNewsSection) {
// get all where the holder = me
$filter = array('NewsSectionID' => $this->ID);
} else {
$subholders = $this->SubSections();
if ($subholders) {
$subholders->push($this);
} else {
$subholders = null;
}
if ($subholders && $subholders->Count()) {
$ids = $subholders->column('ID');
$filter = array('ParentID' => $ids);
} else {
$filter = array('ParentID' => (int) $this->ID);
}
}
$orderBy = strlen($this->OrderBy) ? $this->OrderBy | php | {
"resource": ""
} |
q6921 | NewsHolder.SubSections | train | public function SubSections($allChildren=true) {
$subs = null;
$childHolders = NewsHolder::get()->filter('ParentID', $this->ID);
if ($childHolders && $childHolders->count()) {
$subs = new ArrayList();
| php | {
"resource": ""
} |
q6922 | NewsHolder.getPartitionedHolderForArticle | train | public function getPartitionedHolderForArticle($article) {
if ($this->FileBy == 'Published' && $article->OriginalPublishedDate) {
$date = $article->OriginalPublishedDate;
} else if ($this->hasField($this->FileBy)) {
$field = $this->FileBy;
$date = $this->$field;
} else {
$date = $article->Created;
}
$year = date('Y', strtotime($date));
$month = date('M', strtotime($date));
$day = date('d', strtotime($date));
$yearFolder = $this->dateFolder($year);
if (!$yearFolder) {
throw new Exception("Failed retrieving folder");
}
if ($this->FilingMode == 'year') { | php | {
"resource": ""
} |
q6923 | NewsHolder.TotalChildArticles | train | public function TotalChildArticles($number = null) {
if (!$number) {
$number = $this->numberToDisplay;
}
$start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
if ($start < 0) {
$start = 0;
}
$articles = NewsArticle::get('NewsArticle', '', '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' | php | {
"resource": ""
} |
q6924 | TypeAutoLoader.autoloadTypes | train | public function autoloadTypes()
{
//loaded and static
if (self::$loaded) {
return;
}
if (!$this->kernel->isDebug() && $this->loadFromCacheCache()) {
self::$loaded = true;
return;
}
self::$loaded = true;
foreach ($this->kernel->getBundles() as $bundle) {
$path = $bundle->getPath().'/Type';
if (file_exists($path)) {
$this->registerBundleTypes($path, $bundle->getNamespace());
}
} | php | {
"resource": ""
} |
q6925 | TypeAutoLoader.registerBundleTypes | train | protected function registerBundleTypes($path, $namespace)
{
$finder = new Finder();
foreach ($finder->in($path)->name('/Type.php$/')->getIterator() as $file) {
$className = preg_replace('/.php$/', null, $file->getFilename());
if ($file->getRelativePath()) {
$subNamespace = str_replace('/', '\\', $file->getRelativePath());
$fullyClassName = $namespace.'\\Type\\'.$subNamespace.'\\'.$className;
} else {
$fullyClassName = $namespace.'\\Type\\'.$className;
}
if (class_exists($fullyClassName)) {
$ref = new \ReflectionClass($fullyClassName);
if ($ref->isSubclassOf(Type::class) && $ref->isInstantiable()) {
$requiredParams = false;
foreach ($ref->getConstructor()->getParameters() as $parameter) {
if ($parameter->getClass() && $parameter->getClass()->implementsInterface(DefinitionInterface::class)) {
continue 2;
| php | {
"resource": ""
} |
q6926 | TimeUtil.dateTimeToTimePoint | train | private function dateTimeToTimePoint(DateTime $date)
{
// missing or offset only timezone? correct to UTC
if (!$date->getTimezone() instanceof DateTimeZone || preg_match('#^[+-]{1}[0-9]{2}:?[0-9]{2}$#', $date->getTimezone()->getName())) {
$date->setTimezone(new DateTimeZone('UTC'));
}
try {
// DateTime::createFromFormat() will create an invalid DateTimeZone object when the timezone is an offset
// (-05:00, for example) instead of a named timezone. By recreating the DateTimeZone object, we can expose
// this problem and ensure that a valid DateTimeZone object is always set.
$timezone = new DateTimeZone($date->getTimezone()->getName());
} catch (Exception $e) {
| php | {
"resource": ""
} |
q6927 | TimeUtil.dateIntervalToIntervalSpec | train | private function dateIntervalToIntervalSpec(DateInterval $interval)
{
$date = sprintf('%uY%uM%uD', $interval->y, $interval->m, $interval->d);
$time = sprintf('%uH%uM%uS', $interval->h, $interval->i, $interval->s);
// build extra spec
$extra = '';
if ($interval->invert) {
$extra .= 'I';
}
if ($interval->days) {
| php | {
"resource": ""
} |
q6928 | StaticTranslator.sortPluralizedCompare | train | protected static function sortPluralizedCompare($a, $b)
{
if ($a == $b) {
return 0;
}
$rangeA = explode(':', $a);
$rangeB = explode(':', $b);
// Both range starts provided.
if (isset($rangeA[0]) && isset($rangeB[0])) {
return strcmp($rangeA[0], $rangeB[0]);
}
// Only second range has a starting point.
if (!isset($rangeA[0]) && isset($rangeB[0])) {
return -1;
| php | {
"resource": ""
} |
q6929 | StaticTranslator.setValuePluralized | train | public function setValuePluralized($string, $value, $min = null, $max = null, $domain = null, $locale = null)
{
if (!$domain) {
$domain = 'default';
}
if (!$locale) {
$locale = 'default';
}
if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) {
$this->values[$locale] = array();
}
if (!(isset($this->values[$locale][$domain]) && is_array($this->values[$locale][$domain]))) {
$this->values[$locale][$domain] = array();
}
if (isset($this->values[$locale][$domain][$string]) && is_array($this->values[$locale][$domain][$string])) {
$lang = $this->values[$locale][$domain][$string];
} else {
| php | {
"resource": ""
} |
q6930 | StaticTranslator.determineKey | train | protected function determineKey($min, $max)
{
$minGiven = ($min !== null);
$maxGiven = ($max !== null);
if (!$minGiven && !$maxGiven) {
throw new InvalidArgumentException('You must specify a valid value for min, max or both.');
}
if ($minGiven && !$maxGiven) {
// Open end range.
return $min . ':';
} elseif (!$minGiven && $maxGiven) {
| php | {
"resource": ""
} |
q6931 | StaticTranslator.setValue | train | public function setValue($string, $value, $domain = null, $locale = null)
{
if (!$domain) {
$domain = 'default';
}
if (!$locale) {
$locale = 'default';
}
if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) {
$this->values[$locale] = array();
}
| php | {
"resource": ""
} |
q6932 | StaticTranslator.getValue | train | protected function getValue($string, $domain, $locale)
{
if (!$domain) {
$domain = 'default';
}
if (!$locale) {
| php | {
"resource": ""
} |
q6933 | ThisData.getOrCreateEndpoint | train | private function getOrCreateEndpoint($endpoint)
{
if (!array_key_exists($endpoint, $this->endpoints)) {
if (!array_key_exists($endpoint, self::$endpointClassMap)) {
throw new \Exception(sprintf('Unknown endpoint "%s"', $endpoint));
}
| php | {
"resource": ""
} |
q6934 | SolrSearchService.getQueryBuilder | train | public function getQueryBuilder($type='default') {
return isset($this->queryBuilders[$type]) | php | {
"resource": ""
} |
q6935 | SolrSearchService.index | train | public function index($dataObject, $stage=null, $fieldBoost = array()) {
$document = $this->convertObjectToDocument($dataObject, $stage, $fieldBoost);
if ($document) {
try {
$this->getSolr()->addDocument($document);
$this->getSolr()->commit();
| php | {
"resource": ""
} |
q6936 | SolrSearchService.objectToFields | train | protected function objectToFields($dataObject) {
$ret = array();
$fields = Config::inst()->get($dataObject->ClassName, 'db');
$fields['Created'] = 'SS_Datetime';
$fields['LastEdited'] = 'SS_Datetime';
$ret['ClassName'] = array('Type' => 'Varchar', 'Value' => $dataObject->class);
$ret['SS_ID'] = array('Type' => 'Int', 'Value' => $dataObject->ID);
foreach ($fields as $name => $type) {
if (preg_match('/^(\w+)\(/', $type, $match)) {
$type = $match[1];
}
// Just index everything; the query can figure out what to exclude... !
$value = $dataObject->$name;
if ($type == 'MultiValueField' && $value instanceof MultiValueField) {
$value = $value->getValues();
}
$ret[$name] = array('Type' => $type, 'Value' => $value);
}
$rels = Config::inst()->get($dataObject->ClassName, 'has_one');
if($rels) foreach(array_keys($rels) as $rel) {
$ret["{$rel}ID"] = array(
'Type' | php | {
"resource": ""
} |
q6937 | SolrSearchService.unindex | train | public function unindex($typeOrId) {
$id = $typeOrId;
if (is_object($typeOrId)) {
$type = $typeOrId->class; // get_class($type);
$id = $type . '_' . $typeOrId->ID;
} else {
$id = self::RAW_DATA_KEY . $id;
}
try {
// delete all published/non-published versions | php | {
"resource": ""
} |
q6938 | SolrSearchService.parseSearch | train | public function parseSearch($query, $type='default') {
// if there's a colon in the search, assume that the user is doing a custom power search
if (strpos($query, ':')) {
return $query;
}
if (isset($this->queryBuilders[$type])) {
| php | {
"resource": ""
} |
q6939 | SolrSearchService.query | train | public function query($query, $offset = 0, $limit = 20, $params = array(), $andWith = array()) {
if (is_string($query)) {
$builder = $this->getQueryBuilder('default');
$builder->baseQuery($query);
$query = $builder;
}
// be very specific about the subsite support :).
if (ClassInfo::exists('Subsite')) {
$query->andWith('SubsiteID_i', Subsite::currentSubsiteID());
}
// add the stage details in - we should probably use an extension mechanism for this,
// but for now this will have to do. @TODO Refactor this....
$stage = Versioned::current_stage();
if (!$stage && !(isset($params['ignore_stage']) && $params['ignore_stage'])) {
// default to searching live content only
$stage = 'Live';
}
if(!isset($params['ignore_stage']) || !$params['ignore_stage']) {
$query->addFilter('SS_Stage_ms', $stage);
}
if($andWith) {
foreach($andWith as $field => $value) {
$query->andWith($field, $value);
}
}
$extraParams = $query->getParams();
$params = array_merge($params, $extraParams);
$query = $query->toString();
$response = null;
$rawResponse = null;
$solr = $this->getSolr();
$key = null;
if ($this->cache) {
$key = md5($query.$offset.$limit.serialize($params));
if ($rawResponse = $this->cache->load($key)) {
$response = new Apache_Solr_Response(
$rawResponse,
// we fake the following headers... :o
array(
'HTTP/1.1 200 OK',
'Content-Type: text/plain; charset=utf-8'
),
$solr->getCreateDocuments(),
$solr->getCollapseSingleValueArrays()
);
} | php | {
"resource": ""
} |
q6940 | SolrSearchService.getFacetsForFields | train | public function getFacetsForFields($fields, $number=10) {
if (!is_array($fields)) {
$fields = array($fields);
}
return $this->query('*', 0, | php | {
"resource": ""
} |
q6941 | SolrSearchService.getSolr | train | public function getSolr() {
if (!$this->client) {
if (!$this->solrTransport) {
$this->solrTransport = new Apache_Solr_HttpTransport_Curl;
}
$this->client = | php | {
"resource": ""
} |
q6942 | SolrSearchService.getAllSearchableFieldsFor | train | public function getAllSearchableFieldsFor($classNames) {
$allfields = array();
foreach ($classNames as $className) {
$fields = $this->getSearchableFieldsFor($className); | php | {
"resource": ""
} |
q6943 | SolrSearchService.buildSearchableFieldCache | train | protected function buildSearchableFieldCache() {
if (!$this->searchableCache) {
$objects = DataObject::get('SolrTypeConfiguration');
if ($objects) {
foreach ($objects as $obj) {
| php | {
"resource": ""
} |
q6944 | SolrSearchService.getSolrFieldName | train | public function getSolrFieldName($field, $classNames = null) {
if (!$classNames) {
$classNames = Config::inst()->get('SolrSearch', 'default_searchable_types');
}
if (!is_array($classNames)) {
$classNames = array($classNames);
}
foreach ($classNames as $className) {
if (!class_exists($className)) {
continue;
}
$dummy = singleton($className);
$fields = $this->objectToFields($dummy);
if ($field == 'ID') {
$field = | php | {
"resource": ""
} |
q6945 | SolrSchemaMapper.mapFieldNameFromType | train | public function mapFieldNameFromType($field, $type, $hint = '') {
if (isset($this->solrFields[$field])) {
return $this->solrFields[$field];
}
if (strpos($type, '(')) {
$type = substr($type, 0, strpos($type, '('));
}
if ($hint && is_string($hint) && $hint != 'default') {
return str_replace(':field', $field, $hint);
}
if ($pos = strpos($field, ':')) {
$field = substr($field, 0, $pos);
}
// otherwise, lets use a generic field for it
switch ($type) {
case 'MultiValueField': {
return $field . '_ms';
}
case 'Text':
case 'HTMLText': {
return $field . '_t';
}
case 'Date':
case 'SS_Datetime': {
return $field . '_dt';
}
case | php | {
"resource": ""
} |
q6946 | SolrSchemaMapper.mapValueToType | train | public function mapValueToType($name, $value) {
// just store as an untokenised string
$type = 'String';
if (strpos($name, ':')) {
list($name, $type) = explode(':', $name);
return $type;
}
// or an array of strings | php | {
"resource": ""
} |
q6947 | SolrSchemaMapper.convertValue | train | public function convertValue($value, $type) {
if (is_array($value)) {
$newReturn = array();
foreach ($value as $v) {
$newReturn[] = $this->convertValue($v, $type);
}
return $newReturn;
} else {
switch ($type) {
case 'Date':
case 'SS_Datetime': {
// we don't want a complete iso8601 date, we want it
// in UTC time with a Z at the end. It's okay, php's
// strtotime will correctly re-convert this to the correct
// timestamp, but this is how Solr wants things.
// If we don't have a full DateTime stamp we won't remove any hours
| php | {
"resource": ""
} |
q6948 | ObjectAccess.get | train | public function get($property)
{
if (!$this->exists($property)) {
| php | {
"resource": ""
} |
q6949 | TagFigInclude.fig_include | train | private function fig_include(Context $context) {
$file = $this->includedFile;
$realFilename = dirname($context->getFilename()).'/'.$file;
//Create a sub-view, attached to the current element.
$view = new View();
if ($context->view->getCachePath() && $context->view->getTemplatesRoot()) {
$view->setCachePath($context->view->getCachePath(), $context->view->getTemplatesRoot());
}
$view->loadFile($realFilename);
//Parse the subview (build its own tree).
$context->pushInclude($realFilename, $view->figNamespace);
$view->parse();
// If the included template specifies a doctype, use it globally for our context.
| php | {
"resource": ""
} |
q6950 | SuperCMSUser.getUserDefaultLocation | train | public static function getUserDefaultLocation()
{
try {
$user = self::getLoggedInUser();
if ($user->PrimaryLocation) {
return $user->PrimaryLocation;
}
if ($user->Locations && $user->Locations->count()) {
$user->PrimaryLocationID = $user->Locations[0]->UniqueIdentifier;
$user->save();
return $user->PrimaryLocation;
}
} catch (NotLoggedInException $ex) {
}
| php | {
"resource": ""
} |
q6951 | ResponseContext.theResponseIsGraphQLErrorWith | train | public function theResponseIsGraphQLErrorWith(string $message)
{
$this->assertResponseStatus(Response::HTTP_OK);
//success GraphQL response should not contains errors
if ($this->client->getGraphQL()) {
if ($this->isValidGraphQLResponse() && $errors = $this->getGraphQLResponseError()) {
$errorsStack = '';
foreach ($errors as $error) {
$errorsStack .= $error->message."\n";
| php | {
"resource": ""
} |
q6952 | UsersController.newPassword | train | public function newPassword($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->accessible('send_mail', true); // checkbox to send an e-mail
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
if ($user->send_mail) {
$this->EmailListener->passwordConfirmation($user);
}
| php | {
"resource": ""
} |
q6953 | UsersController.sendActivationMail | train | public function sendActivationMail($id = null)
{
$user = $this->Users->get($id, [
'contain' => []
]);
$user->set('active', false);
$user->set('activation_key', $this->Users->generateActivationKey());
if ($this->Users->save($user)) {
$this->EmailListener->activation($user);
| php | {
"resource": ""
} |
q6954 | ImageShack.withCredentials | train | public function withCredentials($username, $password)
{
$this->cookie | php | {
"resource": ""
} |
q6955 | ImageShack.upload | train | public function upload($file, $format = 'json')
{
// Is this "file" a URL?
$url = filter_var($file, FILTER_VALIDATE_URL) !== false;
$data = array(
'key' => $this->key,
'format' => $format
);
if ($url) {
$data['url'] = $file; | php | {
"resource": ""
} |
q6956 | ObjectTypeAnnotationParser.copyFieldsFromInterface | train | protected function copyFieldsFromInterface(InterfaceDefinition $intDef, FieldsAwareDefinitionInterface $fieldsAwareDefinition)
{
foreach ($intDef->getFields() as $field) {
if (!$fieldsAwareDefinition->hasField($field->getName())) {
$newField = clone $field;
| php | {
"resource": ""
} |
q6957 | ObjectTypeAnnotationParser.isExposed | train | protected function isExposed(ObjectDefinitionInterface $definition, $prop): bool
{
$exposed = $definition->getExclusionPolicy() === ObjectDefinitionInterface::EXCLUDE_NONE;
if ($prop instanceof \ReflectionMethod) {
$exposed = false;
//implicit inclusion
if ($this->getFieldAnnotation($prop, Annotation\Field::class)) {
$exposed = true;
}
}
if ($exposed && $this->getFieldAnnotation($prop, Annotation\Exclude::class)) {
$exposed = false;
} elseif (!$exposed && $this->getFieldAnnotation($prop, Annotation\Expose::class)) {
$exposed = true;
}
/** @var Annotation\Field $fieldAnnotation */
| php | {
"resource": ""
} |
q6958 | ObjectTypeAnnotationParser.getFieldAnnotation | train | protected function getFieldAnnotation($prop, string $annotationClass)
{
if ($prop instanceof \ReflectionProperty) {
return $this->reader->getPropertyAnnotation($prop, $annotationClass);
| php | {
"resource": ""
} |
q6959 | VerifyEndpoint.verify | train | public function verify($ip, array $user, $userAgent = null, array $source = null, array $session = null, array $device = null)
{
$event = [
self::PARAM_IP => $ip
];
if (!is_null($userAgent)) {
$event[self::PARAM_USER_AGENT] = $userAgent;
}
$event[self::PARAM_USER] = array_filter([
self::PARAM_USER__ID => $this->findValue(self::PARAM_USER__ID, $user),
self::PARAM_USER__NAME => $this->findValue(self::PARAM_USER__NAME, $user),
self::PARAM_USER__EMAIL => $this->findValue(self::PARAM_USER__EMAIL, $user),
self::PARAM_USER__MOBILE => $this->findValue(self::PARAM_USER__MOBILE, $user),
self::PARAM_USER__AUTHENTICATED => $this->findValue(self::PARAM_USER__AUTHENTICATED, $user),
]);
if (!is_null($source)) {
$event[self::PARAM_SOURCE] = array_filter([
self::PARAM_SOURCE__NAME => $this->findValue(self::PARAM_SOURCE__NAME, $source),
self::PARAM_SOURCE__LOGO_URL => $this->findValue(self::PARAM_SOURCE__LOGO_URL, $source)
]);
}
// Add information about the session
// First, the session ID if it's passed
$event[self::PARAM_SESSION] = array_filter([
self::PARAM_SESSION__ID => $this->findValue(self::PARAM_SESSION__ID, $session)
]);
// Then pull the | php | {
"resource": ""
} |
q6960 | Whois.clean | train | public function clean($domain)
{
$domain = trim($domain);
$domain = preg_replace('#^https?://#', '', $domain);
| php | {
"resource": ""
} |
q6961 | Whois.lookup | train | public function lookup()
{
if ($this->ip) {
$result = $this->lookupIp($this->ip);
} else {
| php | {
"resource": ""
} |
q6962 | Whois.lookupDomain | train | public function lookupDomain($domain)
{
$serverObj = new Server();
$server = $serverObj->getServerByTld($this->tld);
if (!$server) {
throw new Exception("Error: No appropriate Whois server found for $domain domain!");
}
$result = $this->queryServer($server, $domain);
if (!$result) {
throw new Exception("Error: No results retrieved from $server server for $domain domain!");
} else {
while (strpos($result, "Whois Server:") !== false) {
preg_match("/Whois Server: (.*)/", $result, $matches);
| php | {
"resource": ""
} |
q6963 | Whois.lookupIp | train | public function lookupIp($ip)
{
$results = array();
$continentServer = new Server();
foreach ($continentServer->getContinentServers() as $server) {
$result = $this->queryServer($server, $ip);
if ($result && !in_array($result, $results)) {
$results[$server]= $result;
}
}
$res = "RESULTS FOUND: " | php | {
"resource": ""
} |
q6964 | Whois.queryServer | train | public function queryServer($server, $domain)
{
$port = 43;
$timeout = 10;
$fp = @fsockopen($server, $port, $errno, $errstr, $timeout);
if ( !$fp ) {
throw new Exception("Socket Error " . $errno . " - " . $errstr);
}
// if($server == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while (!feof($fp)) {
$out .= fgets($fp);
}
fclose($fp);
| php | {
"resource": ""
} |
q6965 | MGP25.getRegistrationClient | train | private function getRegistrationClient($number)
{
$file = $this->customPath ? $this->customPath . '/phone-id-' . $number . '.dat' : null;
$registration = new Registration($number, $this->debug, $file);
| php | {
"resource": ""
} |
q6966 | Section.isAvailable | train | public function isAvailable(): bool
{
foreach ($this->items as $item) {
| php | {
"resource": ""
} |
q6967 | Skin.ResourceLoaderRegisterModules | train | public static function ResourceLoaderRegisterModules( \ResourceLoader $rl ){
self::$_modulesRegistered = true;
| php | {
"resource": ""
} |
q6968 | Skin.initPage | train | public function initPage( \OutputPage $out ){
parent::initPage( $out );
| php | {
"resource": ""
} |
q6969 | Skin.setupSkinUserCss | train | function setupSkinUserCss( \OutputPage $out ) {
parent::setupSkinUserCss( $out );
//TODO: load modules from parent of layout, too...
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$styles = array('mediawiki.skinning.interface');
| php | {
"resource": ""
} |
q6970 | Skin.addToBodyAttributes | train | public function addToBodyAttributes( $out, &$attrs){
$classes = array();
$layout = $this->getLayout();
$attrs['class'] .= ' sitename-'.strtolower(str_replace(' ','_',$GLOBALS['wgSitename']));
$layoutClass = self::getLayoutClass();
$layoutTree = \Skinny::getClassAncestors($layoutClass);
$layoutNames = array_flip(self::$layouts);
foreach ($layoutTree as $lc) {
if (isset($layoutNames[$lc])) | php | {
"resource": ""
} |
q6971 | Skin.addLayout | train | public static function addLayout ($name, $className){
if (!class_exists($className)) {
throw new \Exception('Invalid Layout class: '.$className);
}
| php | {
"resource": ""
} |
q6972 | Skin.addModules | train | public static function addModules ($modules=array(), $load=false){
if( static::$_modulesRegistered ){
throw new Exception('Skin is attempting to add modules after modules have already been registered.');
}
if(empty($modules)){
| php | {
"resource": ""
} |
q6973 | Validator.validateIp | train | public function validateIp($ip)
{
$ipnums = explode(".", $ip);
if (count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if (!is_numeric($ipnum) | php | {
"resource": ""
} |
q6974 | E621.prepareRequestParams | train | private function prepareRequestParams(array $data)
{
$has_resource = false;
$multipart = [];
foreach ($data as $key => $value) {
if (!is_array($value)) {
$multipart[] = ['name' => $key, 'contents' => $value];
continue;
}
foreach ($value as $multiKey => $multiValue) {
is_resource($multiValue) && $has_resource = true;
$multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
| php | {
"resource": ""
} |
q6975 | E621.debugLog | train | private function debugLog($message)
{
$this->debug_log_handler !== null && is_callable($this->debug_log_handler) | php | {
"resource": ""
} |
q6976 | E621.endDebugStream | train | private function endDebugStream()
{
if (is_resource($this->debug_log_stream_handle)) {
rewind($this->debug_log_stream_handle);
$this->debugLog('E621 API Verbose HTTP Request output:' . PHP_EOL . stream_get_contents($this->debug_log_stream_handle) | php | {
"resource": ""
} |
q6977 | E621.setProgressHandler | train | public function setProgressHandler($progress_handler)
{
if ($progress_handler !== null && is_callable($progress_handler)) {
$this->progress_handler = $progress_handler;
} elseif ($progress_handler === null) {
$this->progress_handler = null;
| php | {
"resource": ""
} |
q6978 | E621.setDebugLogHandler | train | public function setDebugLogHandler($debug_log_handler)
{
if ($debug_log_handler !== null && is_callable($debug_log_handler)) {
$this->debug_log_handler = $debug_log_handler;
} elseif ($debug_log_handler === null) {
$this->debug_log_handler = null;
| php | {
"resource": ""
} |
q6979 | E621.login | train | public function login($login, $api_key)
{
if (empty($login) || !is_string($login)) {
throw new \InvalidArgumentException('Argument "login" cannot be empty and must be a string');
}
if (empty($login) || !is_string($api_key)) {
throw | php | {
"resource": ""
} |
q6980 | Api.getClient | train | private function getClient(): Client
{
if (null !== $this->client) {
return $this->client;
}
| php | {
"resource": ""
} |
q6981 | Basket.getCurrentBasket | train | public static function getCurrentBasket()
{
$settings = SuperCMSSession::singleton();
try {
$user = SCmsLoginProvider::getLoggedInUser();
try {
$basket = Basket::findLast(new AndGroup(
[
new Equals('UserID', $user->UniqueIdentifier),
new Not(new Equals('Status', self::STATUS_COMPLETED))
]
));
} catch (RecordNotFoundException $ex) {
$basket = new Basket();
$basket->UserID = $user->UniqueIdentifier;
$basket->save();
}
| php | {
"resource": ""
} |
q6982 | Basket.markBasketPaid | train | public static function markBasketPaid(Basket $basket)
{
$basket->Status = Basket::STATUS_COMPLETED;
$basket->save();
$session | php | {
"resource": ""
} |
q6983 | Listener.registerEvents | train | protected function registerEvents(WhatsApiEventsManager $manager)
{
foreach ($this->events as $event)
{
if (is_callable(array($this, $event)))
{
| php | {
"resource": ""
} |
q6984 | RolesController.update | train | public function update(RoleProcessor $processor, $roles)
{
| php | {
"resource": ""
} |
q6985 | Synchronizer.handle | train | public function handle()
{
$admin = $this->app->make('orchestra.role')->admin();
| php | {
"resource": ""
} |
q6986 | ContainerLoader.get | train | public function get(string $name): AbstractCommand
{
if (!$this->has($name))
{
throw new CommandNotFoundException(sprintf('Command "%s" does not | php | {
"resource": ""
} |
q6987 | ContainerLoader.has | train | public function has($name): bool
{
return isset($this->commandMap[$name]) | php | {
"resource": ""
} |
q6988 | TypeExtensionsManager.getManager | train | static function getManager(?string $name = null): \Plasma\Types\TypeExtensionsManager {
if($name === null) {
if(!isset(static::$instances[static::GLOBAL_NAME])) {
static::$instances[static::GLOBAL_NAME] = new static();
| php | {
"resource": ""
} |
q6989 | TypeExtensionsManager.registerManager | train | static function registerManager(string $name, ?\Plasma\Types\TypeExtensionsManager $manager = null): void {
if(isset(static::$instances[$name])) {
throw new \Plasma\Exception('Name is already in use');
}
| php | {
"resource": ""
} |
q6990 | TypeExtensionsManager.encodeType | train | function encodeType($value, \Plasma\ColumnDefinitionInterface $column): \Plasma\Types\TypeExtensionResultInterface {
$type = \gettype($value);
if($type === 'double') {
$type = 'float';
}
if($type === 'object') {
$classes = \array_merge(
array(\get_class($value)),
\class_parents($value),
\class_implements($value)
);
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->classTypes as $key => $encoder) {
if(\in_array($key, $classes, true)) {
return $encoder->encode($value, $column);
}
}
}
/** @var \Plasma\Types\TypeExtensionInterface $encoder */
foreach($this->regularTypes as $key => $encoder) {
if($type === $key) {
return $encoder->encode($value, $column);
}
}
| php | {
"resource": ""
} |
q6991 | TypeExtensionsManager.decodeType | train | function decodeType($type, $value): \Plasma\Types\TypeExtensionResultInterface {
if($type === null && $this->enabledFuzzySearch) {
/** @var \Plasma\Types\TypeExtensionInterface $decoder */
foreach($this->dbTypes as $dbType => $decoder) {
if($decoder->canHandleType($value, null)) {
return $decoder->decode($value);
}
| php | {
"resource": ""
} |
q6992 | ColumnDefinition.parseValue | train | function parseValue($value) {
try {
return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
} catch (\Plasma\Exception $e) {
| php | {
"resource": ""
} |
q6993 | SolrSearchPermissionIndexExtension.updateQueryBuilder | train | public function updateQueryBuilder($builder) {
// Make sure the extension requirements have been met before enabling the custom search index.
if(SiteTree::has_extension('SolrIndexable') && SiteTree::has_extension('SiteTreePermissionIndexExtension') && ClassInfo::exists('QueuedJob')) {
// Define the initial user permissions using the general public access flag.
| php | {
"resource": ""
} |
q6994 | GraphQLClient.sendQuery | train | public function sendQuery(): Response
{
$data = [
'query' => $this->getGraphQL(),
'variables' => $this->getVariables(),
];
if ($this->operationName) {
$data['operationName'] = $this->operationName;
}
$content = json_encode($data);
$this->insulated = $this->config['insulated'] ?? false; | php | {
"resource": ""
} |
q6995 | GraphQLClient.sendRequest | train | public function sendRequest($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true)
{
set_error_handler(
function ($level, $message, $errFile, $errLine) {
if ($this->deprecationAdviser) {
$this->deprecationAdviser->addWarning($message, $errFile, $errLine);
}
},
| php | {
"resource": ""
} |
q6996 | SocialShareUrl.getUrl | train | public function getUrl($service, $url, $params = [])
{
if (!empty($this->stubs[$service])) {
$tokens = [];
$params['url'] = $url;
foreach ($this->tokens as $token) {
$tokens['/{' . $token . '}/'] = urlencode(
| php | {
"resource": ""
} |
q6997 | NativeFunctionFactory.create | train | public function create($funcName) {
$dirname = dirname(__FILE__).'/functions';
$filename = "$dirname/Function_$funcName.php";
if( !file_exists($filename) ) {
return null;
}
| php | {
"resource": ""
} |
q6998 | InvalidConfigurationException.buildMessage | train | protected function buildMessage(array $errors)
{
$errorList = array();
foreach ($errors as $error) {
$errorList[] = sprintf(
' - | php | {
"resource": ""
} |
q6999 | SparkPostTransport.send | train | public function send(Email $email)
{
// Load SparkPost configuration settings
$apiKey = $this->config('apiKey');
// Set up HTTP request adapter
$adapter = new CakeHttpAdapter(new Client());
// Create SparkPost API accessor
$sparkpost = new SparkPost($adapter, [ 'key' => $apiKey ]);
// Pre-process CakePHP email object fields
$from = (array) $email->from();
$sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
$to = (array) $email->to();
$replyTo = $email->getReplyTo() ? array_values($email->getReplyTo())[0] : null;
foreach ($to as $toEmail => $toName) {
$recipients[] = ['address' => [ 'name' => mb_encode_mimeheader($toName), 'email' => $toEmail]];
}
// Build message to send
$message = [
'from' => $sender,
'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'),
'text' => $email->message('text'),
'subject' => mb_decode_mimeheader($email->subject()),
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.