_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4900 | Password.generate | train | public function generate($iGroupId)
{
$aPwRules = $this->getRules($iGroupId);
$aPwOut = [];
// --------------------------------------------------------------------------
/**
* We're generating a password, define all the charsets to use, at the very
* ;east have ... | php | {
"resource": ""
} |
q4901 | Password.getRules | train | protected function getRules($iGroupId)
{
$sCacheKey = 'password-rules-' . $iGroupId;
$aCacheResult = $this->getCache($sCacheKey);
if (!empty($aCacheResult)) {
return $aCacheResult;
}
$oDb = Factory::service('Database');
$oDb->select('password_rules');
... | php | {
"resource": ""
} |
q4902 | Password.getRulesAsString | train | public function getRulesAsString($iGroupId)
{
$aRules = $this->getRulesAsArray($iGroupId);
if (empty($aRules)) {
return '';
}
$sStr = 'Passwords must ' . strtolower(implode(', ', $aRules)) . '.';
return str_lreplace(', ', ' and ', $sStr);
} | php | {
"resource": ""
} |
q4903 | Password.getRulesAsArray | train | public function getRulesAsArray($iGroupId)
{
$aRules = $this->getRules($iGroupId);
$aOut = [];
if (!empty($aRules['min'])) {
$aOut[] = 'Have at least ' . $aRules['min'] . ' characters';
}
if (!empty($aRules['max'])) {
$aOut[] = 'Have at most ' . $a... | php | {
"resource": ""
} |
q4904 | Password.setToken | train | public function setToken($sIdentifier)
{
if (empty($sIdentifier)) {
return false;
}
// --------------------------------------------------------------------------
// Generate code
$sKey = sha1(sha1($this->salt()) . $this->salt() . APP_PRIVATE_KEY);
$iTt... | php | {
"resource": ""
} |
q4905 | Password.validateToken | train | public function validateToken($sCode, $bGenerateNewPw)
{
if (empty($sCode)) {
return false;
}
// --------------------------------------------------------------------------
$oDb = Factory::service('Database');
$oDb->select('id, group_id, forgotten_password_code')... | php | {
"resource": ""
} |
q4906 | PageSettingMapper.findPageSettings | train | public function findPageSettings($pageId)
{
$this->makeSelect();
$this->sql .= ' and page_id = ?';
$this->bindValues[] = $pageId;
return $this->find();
} | php | {
"resource": ""
} |
q4907 | WidgetHelper.getAll | train | protected function getAll()
{
$widgets = getConfig('Widgets.general', []);
if ($this->getView()->getRequest()->isUrl(['_name' => 'homepage']) && getConfig('Widgets.homepage')) {
$widgets = getConfig('Widgets.homepage');
}
return $widgets ? collection($widgets)->map(func... | php | {
"resource": ""
} |
q4908 | WidgetHelper.all | train | public function all()
{
foreach ($this->getAll() as $widget) {
foreach ($widget as $name => $args) {
$widgets[] = $this->widget($name, $args);
}
}
return empty($widgets) ? null : trim(implode(PHP_EOL, $widgets));
} | php | {
"resource": ""
} |
q4909 | WidgetHelper.widget | train | public function widget($name, array $data = [], array $options = [])
{
$parts = explode('::', $name);
$name = $parts[0] . 'Widgets';
$name = empty($parts[1]) ? $name : sprintf('%s::%s', $name, $parts[1]);
return $this->getView()->cell($name, $data, $options);
} | php | {
"resource": ""
} |
q4910 | BackupsController.index | train | public function index()
{
$backups = collection($this->BackupManager->index())
->map(function (Entity $backup) {
return $backup->set('slug', urlencode($backup->filename));
});
$this->set(compact('backups'));
} | php | {
"resource": ""
} |
q4911 | BackupsController.add | train | public function add()
{
$backup = new BackupForm;
if ($this->request->is('post')) {
//Creates the backup
if ($backup->execute($this->request->getData())) {
$this->Flash->success(I18N_OPERATION_OK);
return $this->redirect(['action' => 'index']... | php | {
"resource": ""
} |
q4912 | BackupsController.delete | train | public function delete($filename)
{
$this->request->allowMethod(['post', 'delete']);
$this->BackupManager->delete($this->getFilename($filename));
$this->Flash->success(I18N_OPERATION_OK);
return $this->redirect(['action' => 'index']);
} | php | {
"resource": ""
} |
q4913 | BackupsController.deleteAll | train | public function deleteAll()
{
$this->request->allowMethod(['post', 'delete']);
$this->BackupManager->deleteAll();
$this->Flash->success(I18N_OPERATION_OK);
return $this->redirect(['action' => 'index']);
} | php | {
"resource": ""
} |
q4914 | BackupsController.restore | train | public function restore($filename)
{
//Imports and clears the cache
(new BackupImport)->filename($this->getFilename($filename))->import();
Cache::clearAll();
$this->Flash->success(I18N_OPERATION_OK);
return $this->redirect(['action' => 'index']);
} | php | {
"resource": ""
} |
q4915 | BackupsController.send | train | public function send($filename)
{
$this->BackupManager->send($this->getFilename($filename), getConfigOrFail('email.webmaster'));
$this->Flash->success(I18N_OPERATION_OK);
return $this->redirect(['action' => 'index']);
} | php | {
"resource": ""
} |
q4916 | OEmbed.setURL | train | public function setURL($url)
{
if (!$this->validateURL($url)) {
throw new \InvalidArgumentException(sprintf('The URL "%s" is invalid.', $url));
}
$this->url = $url;
$this->endpoint = null;
} | php | {
"resource": ""
} |
q4917 | OEmbed.removeProvider | train | public function removeProvider(Provider $provider)
{
$index = array_search($provider, $this->providers);
if ($index !== false) {
unset($this->providers[$index]);
}
return $this;
} | php | {
"resource": ""
} |
q4918 | OEmbed.getObject | train | public function getObject(array $parameters = array())
{
if ($this->url === null) {
throw new \InvalidArgumentException('Missing URL.');
}
if ($this->endpoint === null) {
$this->endpoint = $this->discover($this->url);
}
$sign = '?';
if ($quer... | php | {
"resource": ""
} |
q4919 | OEmbed.discover | train | protected function discover($url)
{
$endpoint = $this->findEndpointFromProviders($url);
// if no provider was found, try to discover the endpoint URL
if ($this->discovery && !$endpoint) {
$discover = new Discoverer();
$endpoint = $discover->getEndpointForUrl($url);
... | php | {
"resource": ""
} |
q4920 | OEmbed.findEndpointFromProviders | train | protected function findEndpointFromProviders($url)
{
// try to find a provider matching the supplied URL if no one has been supplied
foreach ($this->providers as $provider) {
/** @var $provider Provider */
if ($provider->match($url)) {
return $provider->getEnd... | php | {
"resource": ""
} |
q4921 | PostsController.indexByDate | train | public function indexByDate($date)
{
//Data can be passed as query string, from a widget
if ($this->request->getQuery('q')) {
return $this->redirect([$this->request->getQuery('q')]);
}
list($start, $end) = $this->getStartAndEndDate($date);
$page = $this->request... | php | {
"resource": ""
} |
q4922 | PostsController.rss | train | public function rss()
{
//This method works only for RSS
is_true_or_fail($this->RequestHandler->prefers('rss'), ForbiddenException::class);
$posts = $this->Posts->find('active')
->select(['title', 'preview', 'slug', 'text', 'created'])
->limit(getConfigOrFail('defaul... | php | {
"resource": ""
} |
q4923 | PostsController.preview | train | public function preview($slug = null)
{
$post = $this->Posts->findPendingBySlug($slug)
->find('forIndex')
->firstOrFail();
$this->set(compact('post'));
//Gets related posts
if (getConfig('post.related')) {
$related = $this->Posts->getRelated($pos... | php | {
"resource": ""
} |
q4924 | GetPreviewsFromTextTrait.extractImages | train | protected function extractImages($html)
{
if (empty($html)) {
return [];
}
$libxmlPreviousState = libxml_use_internal_errors(true);
$dom = new DOMDocument;
$dom->loadHTML($html);
libxml_clear_errors();
libxml_use_internal_errors($libxmlPreviousS... | php | {
"resource": ""
} |
q4925 | GetPreviewsFromTextTrait.getPreviews | train | public function getPreviews($html)
{
$images = array_map(function ($url) {
if ($url && !is_url($url)) {
//If is relative path
$url = Folder::isAbsolute($url) ? $url : WWW_ROOT . 'img' . DS . $url;
if (!file_exists($url)) {
retu... | php | {
"resource": ""
} |
q4926 | Connection.get | train | public function get($resource, $body = null, $params = [])
{
return $this->send($this->prepare('GET', $resource, $body, $params));
} | php | {
"resource": ""
} |
q4927 | Connection.post | train | public function post($resource, $body = null, $params = [])
{
return $this->send($this->prepare('POST', $resource, $body, $params));
} | php | {
"resource": ""
} |
q4928 | Connection.send | train | protected function send(Request $request)
{
try {
$response = $this->client->send($request);
} catch (ClientException $e) {
$response = $e->getResponse();
} catch (ServerException $e) {
$response = $e->getResponse();
}
return $response;
... | php | {
"resource": ""
} |
q4929 | Connection.prepare | train | protected function prepare($method, $resource, $body, $params)
{
// Append the username parameter to the end of every resource URI.
$resource = trim($resource, '/').'/'.$this->username;
foreach ($params as $param) {
$resource .= '/'.$param;
}
return new Request(... | php | {
"resource": ""
} |
q4930 | PrintableAscii.escapeControlCode | train | protected function escapeControlCode($cp)
{
$table = [9 => '\\t', 10 => '\\n', 13 => '\\r'];
return (isset($table[$cp])) ? $table[$cp] : $this->escapeAscii($cp);
} | php | {
"resource": ""
} |
q4931 | BleedingEffect.bleed | train | public function bleed(Bleeding $bleeding, WoundsTable $woundsTable, WoundBoundary $woundBoundary): Wound
{
// see PPH page 78 right column, Bleeding
$effectSize = $bleeding->getAfflictionSize()->getValue() - 6;
$woundsFromTable = $woundsTable->toWounds(new WoundsBonus($effectSize, $woundsTab... | php | {
"resource": ""
} |
q4932 | ClientRepository.create | train | public function create($params)
{
$client = new Client;
$client->fill($params);
$client->save();
// update datacite_symbol
$this->generateDataciteSymbol($client);
return $client;
} | php | {
"resource": ""
} |
q4933 | ClientRepository.generateDataciteSymbol | train | public function generateDataciteSymbol(Client $client)
{
$prefix = "ANDS.";
$id = $client->client_id;
// prefix before the
if ($id < 100) {
$prefix .= "CENTRE";
}
if ($id < 10) {
$prefix .= "-";
} elseif ($id >= 100) {
// ... | php | {
"resource": ""
} |
q4934 | Request.postParam | train | public function postParam(string $name, $valueDefault = null)
{
return $this->params->post($name, $valueDefault);
} | php | {
"resource": ""
} |
q4935 | Request.cookieParam | train | public function cookieParam(string $name, $valueDefault = null)
{
return $this->params->cookie($name, $valueDefault);
} | php | {
"resource": ""
} |
q4936 | Request.loadHttpHeaders | train | private function loadHttpHeaders(): array
{
if (function_exists('getallheaders')) {
$headers = getallheaders(); // apache
} else {
$headers = [];
foreach ($_SERVER as $key => $value) {
if (stripos(strval($key), 'HTTP_') === 0) {
... | php | {
"resource": ""
} |
q4937 | IPValidator.validate | train | public static function validate($ip, $ip_range)
{
// first lets get the lists of ip address or ranges separated by commas
$ip_ranges = explode(',', $ip_range);
foreach ($ip_ranges as $ip_range) {
$ip_range = explode('-', $ip_range);
if (sizeof($ip_range) > 1) {
... | php | {
"resource": ""
} |
q4938 | IPValidator.ip_match | train | public static function ip_match($ip, $match)
{
if (ip2long($match)) {//is an actual IP
if ($ip == $match) {
return true;
}
} else {//is something weird
if (strpos($match, '/')) {//if it's a cidr notation
if (self::cidr_match($ip, $m... | php | {
"resource": ""
} |
q4939 | WeightTable.getMalusFromLoad | train | public function getMalusFromLoad(Strength $strength, Weight $cargoWeight): int
{
$requiredStrength = $cargoWeight->getBonus()->getValue();
$missingStrength = $requiredStrength - $strength->getValue();
$malus = -SumAndRound::half($missingStrength); // see PPH page 113, right column
if... | php | {
"resource": ""
} |
q4940 | OmmuThemes.getThemes | train | public static function getThemes($array=true)
{
$criteria=new CDbCriteria;
$model = self::model()->findAll($criteria);
if($array == true) {
$items = array();
if($model != null) {
foreach($model as $key => $val) {
$items[$val->theme_id] = $val->name;
}
return $items;
} else... | php | {
"resource": ""
} |
q4941 | Override.login_as | train | public function login_as()
{
// Perform lookup of user
$oUserModel = Factory::model('User', 'nails/module-auth');
$oUri = Factory::service('Uri');
$sHashId = $oUri->segment(4);
$sHashPw = $oUri->segment(5);
$oUser = $oUserModel->getByHashes($sHashId, $sHashP... | php | {
"resource": ""
} |
q4942 | DateTime.fromTimestampWithMicroseconds | train | public static function fromTimestampWithMicroseconds(int $timestamp) : self
{
$seconds = (int)($timestamp / 10 ** 6);
$microseconds = $timestamp - ($seconds * 10 ** 6);
// Ensure microseconds are right-padded with zeros because values like 012345 will be 12345 when expressed
//... | php | {
"resource": ""
} |
q4943 | DateTime.withDateAt | train | public function withDateAt(int $year = null, int $month = null, int $day = null) : self
{
if (null === $year && null === $month && null === $day) {
return $this;
}
$year = $year === null ? $this->year() : $year;
$month = $month ?: $this->month();
$day ... | php | {
"resource": ""
} |
q4944 | DateTime.withDateAtStartOfYear | train | public function withDateAtStartOfYear() : self
{
$instance = $this->withTimeAtMidnight();
$instance->date->setDate($instance->format('Y'), 1, 1);
return $instance;
} | php | {
"resource": ""
} |
q4945 | DateTime.withDateAtEndOfMonth | train | public function withDateAtEndOfMonth() : self
{
$instance = $this->withDateAtStartOfMonth();
$instance->date->modify('+1 month');
$instance->date->modify('-1 day');
return $instance;
} | php | {
"resource": ""
} |
q4946 | DateTime.withDateAtDayOfWeekInMonth | train | public function withDateAtDayOfWeekInMonth(int $dayOfWeek, int $occurrence) : self
{
self::assertValidDayOfWeek($dayOfWeek);
if ($occurrence < -5 || $occurrence === 0 || $occurrence > 5) {
throw new \InvalidArgumentException("Invalid occurrence: $occurrence.");
}
... | php | {
"resource": ""
} |
q4947 | DateTime.withTimeAt | train | public function withTimeAt(
int $hour = null,
int $minute = null,
int $second = null,
int $microsecond = null
) : self {
$instance = clone $this;
$hour = $hour === null ? $this->hour() : $hour;
$minute = $minute ... | php | {
"resource": ""
} |
q4948 | DateTime.withTimeZone | train | public function withTimeZone(\DateTimeZone $timezone) : self
{
if ($this->timezone()->getName() === $timezone->getName()) {
return $this;
}
$instance = clone $this;
$instance->date->setTimezone($timezone);
return $instance;
} | php | {
"resource": ""
} |
q4949 | DateTime.subtract | train | public function subtract($interval) : self
{
$instance = clone $this;
$instance->date->sub(self::resolveDateInterval($interval));
return $instance;
} | php | {
"resource": ""
} |
q4950 | DateTime.add | train | public function add($interval) : self
{
$instance = clone $this;
$instance->date->add(self::resolveDateInterval($interval));
return $instance;
} | php | {
"resource": ""
} |
q4951 | DateTime.modify | train | public function modify(string $specification) : self
{
$instance = clone $this;
$instance->date->modify($specification);
return $instance;
} | php | {
"resource": ""
} |
q4952 | DateRange.contains | train | public function contains(DateTime $dateTime) : bool
{
return $this->from->isEarlierThanOrEqualTo($dateTime) && $this->until->isLaterThan($dateTime);
} | php | {
"resource": ""
} |
q4953 | DateRange.equals | train | public function equals(self $other) : bool
{
if ($other === $this) {
return true;
}
return $other->from->equals($this->from) && $other->until->equals($this->until);
} | php | {
"resource": ""
} |
q4954 | DateRange.dateDiff | train | private function dateDiff() : DateInterval
{
if (null === $this->dateDiff) {
$this->dateDiff = $this->from->withTimeAtMidnight()->diff($this->until->withTimeAtMidnight());
}
return $this->dateDiff;
} | php | {
"resource": ""
} |
q4955 | DateRange.fullDiff | train | private function fullDiff() : DateInterval
{
if (null === $this->fullDiff) {
$this->fullDiff = $this->from->diff($this->until);
}
return $this->fullDiff;
} | php | {
"resource": ""
} |
q4956 | ObjectAttributeTrait.applyObjectConditions | train | protected function applyObjectConditions()
{
if ($this->object !== null) {
$this->andWhere(Db::parseParam('objectId', $this->object));
}
} | php | {
"resource": ""
} |
q4957 | AdminAccessController.requestLoginToken | train | public function requestLoginToken()
{
// Get dependencies
$session = $this->container->sessionHandler;
$email = $this->container->emailHandler;
$security = $this->container->accessHandler;
$userMapper = ($this->container->dataMapper)('UserMapper');
$body = $this->requ... | php | {
"resource": ""
} |
q4958 | AdminAccessController.processLoginToken | train | public function processLoginToken($args)
{
// Get dependencies
$session = $this->container->sessionHandler;
$security = $this->container->accessHandler;
$savedToken = $session->getData($this->loginTokenKey);
$tokenExpires = $session->getData($this->loginTokenExpiresKey);
... | php | {
"resource": ""
} |
q4959 | AdminSettingController.showSettings | train | public function showSettings()
{
// Get dependencies
$settingMapper = ($this->container->dataMapper)('SettingMapper');
$json = $this->container->json;
// Fetch settings from database
$allSettings = $settingMapper->findSiteSettings();
// Fetch custom settings
... | php | {
"resource": ""
} |
q4960 | ExternalDetector.lookForBrokenLinks | train | public function lookForBrokenLinks($postId = null, $url = null)
{
\BrokenLinkDetector\App::checkInstall();
$foundUrls = array();
if ($url) {
$url = "REGEXP ('.*(href=\"{$url}\").*')";
} else {
$url = "RLIKE ('href=*')";
}
global $wpdb;
... | php | {
"resource": ""
} |
q4961 | ExternalDetector.isBroken | train | public function isBroken($url)
{
if (!$domain = parse_url($url, PHP_URL_HOST)) {
return true;
}
if(in_array($domain, (array) apply_filters('brokenLinks/External/ExceptedDomains', array()))) {
return false;
}
// Convert domain name to IDNA ASCII form
... | php | {
"resource": ""
} |
q4962 | ExternalDetector.isDomainAvailable | train | public function isDomainAvailable($url, $timeOut = 7)
{
// Init curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
... | php | {
"resource": ""
} |
q4963 | ExternalDetector.isInternal | train | public function isInternal($url)
{
// Check if post exist by url (only works with 'public' posts)
$postId = url_to_postid($url);
if ($postId > 0) {
return true;
}
// Check if the URL is internal or external
$siteUrlComponents = parse_url(get_site_url());
... | php | {
"resource": ""
} |
q4964 | ViewHelper.call | train | public function call($presenter, array $data = [])
{
$response = $this->builder
->getView()
->start($this->request, $this->response)
->call($presenter, $data);
return $this->returnResponseBody($response);
} | php | {
"resource": ""
} |
q4965 | ViewHelper.render | train | public function render($viewFile, $data = [])
{
return $this->builder
->getView()
->start($this->request, $this->response)
->renderContents($viewFile, $data);
} | php | {
"resource": ""
} |
q4966 | EmailQueueItem.setIdent | train | public function setIdent($ident)
{
if ($ident === null) {
$this->ident = null;
return $this;
}
if (!is_string($ident)) {
throw new InvalidArgumentException(
'Ident needs to be a string'
);
}
$this->ident = $ide... | php | {
"resource": ""
} |
q4967 | EmailQueueItem.process | train | public function process(
callable $callback = null,
callable $successCallback = null,
callable $failureCallback = null
) {
if ($this->processed() === true) {
// Do not process twice, ever.
return null;
}
$email = $this->emailFactory()->create(... | php | {
"resource": ""
} |
q4968 | AdminController.home | train | public function home()
{
$json = $this->container->json;
// Get Piton Engine version from composer.lock
if (null === $definition = $json->getJson(ROOT_DIR . '/composer.lock')) {
$this->setAlert('danger', 'Error Reading composer.lock', $json->getErrorMessages());
}
... | php | {
"resource": ""
} |
q4969 | AdminController.release | train | public function release($args)
{
$json = $this->container->json;
$markdown = $this->container->markdownParser;
$responseBody = '';
// If curl is not installed display alert
if (!function_exists('curl_init')) {
$this->setAlert('warning', 'Required PHP cURL not ins... | php | {
"resource": ""
} |
q4970 | Module.onBootstrap | train | public function onBootstrap(MvcEvent $e)
{
// we attach with wildcard events name
$events = $e->getApplication()->getEventManager();
$events->attach(
MvcEvent::EVENT_RENDER,
new InjectSubNavigationListener(),
10
);
} | php | {
"resource": ""
} |
q4971 | Discoverer.getEndpointForUrl | train | public function getEndpointForUrl($url)
{
if (!isset($this->cachedEndpoints[$url])) {
$this->cachedEndpoints[$url] = $this->fetchEndpointForUrl($url);
}
return $this->cachedEndpoints[$url];
} | php | {
"resource": ""
} |
q4972 | Discoverer.fetchEndpointForUrl | train | protected function fetchEndpointForUrl($url)
{
$client = new Client($url);
$body = $client->send();
$regexp = str_replace(
'@formats@',
implode('|', $this->supportedFormats),
self::LINK_REGEXP
);
if (!preg_match_all($regexp, $body, $matc... | php | {
"resource": ""
} |
q4973 | DateTimeComparator.lowest | train | public static function lowest(... $datetimes)
{
$lowest = null;
foreach ($datetimes as $datetime) {
if (!$datetime instanceof \DateTimeInterface) {
continue;
}
if ($datetime < $lowest || null === $lowest) {
$lowest = $datetime;
... | php | {
"resource": ""
} |
q4974 | DOIServiceProvider.authenticate | train | public function authenticate(
$appID,
$sharedSecret = null,
$ipAddress = null,
$manual = false
) {
// set app_id before trying to authenticate for logging and report purpose
$this->setResponse('app_id', $appID);
// attempt authentication
$client = $t... | php | {
"resource": ""
} |
q4975 | DOIServiceProvider.isDoiAuthenticatedClients | train | public function isDoiAuthenticatedClients($doiValue, $client_id = null)
{
if ($client_id === null) {
return false;
}
$client = $this->getAuthenticatedClient();
if ($client->client_id != $client_id) {
return false;
}
// everyone has access to... | php | {
"resource": ""
} |
q4976 | DOIServiceProvider.mint | train | public function mint($url, $xml, $manual = false)
{
// @todo event handler, message
if (!$this->isClientAuthenticated()) {
$this->setResponse("responsecode", "MT009");
return false;
}
// Validate URL and URL Domain
$this->setResponse('url', $url);
... | php | {
"resource": ""
} |
q4977 | DOIServiceProvider.validateXML | train | public function validateXML($xml)
{
$xmlValidator = new XMLValidator();
$result = $xmlValidator->validateSchemaVersion($xml);
if ($result === false) {
$this->setResponse("verbosemessage", $xmlValidator->getValidationMessage());
return false;
}
return t... | php | {
"resource": ""
} |
q4978 | DOIServiceProvider.getNewDOI | train | public function getNewDOI()
{
// get the first active prefix for this authenticated client
$prefix = "";
$testStr = "";
$client = $this->getAuthenticatedClient();
//if this client is not in test mode grab their production prefix
if(sizeof($client->prefixes) > 0 && ... | php | {
"resource": ""
} |
q4979 | DOIServiceProvider.update | train | public function update($doiValue, $url=NULL, $xml=NULL)
{
if (!$this->isClientAuthenticated()) {
$this->setResponse("responsecode", "MT009");
return false;
}
$doi = $this->doiRepo->getByID($doiValue);
$this->setResponse('doi', $doiValue);
if ($doi =... | php | {
"resource": ""
} |
q4980 | DOIServiceProvider.activate | train | public function activate($doiValue)
{
// validate client
if (!$this->isClientAuthenticated()) {
$this->setResponse('responsecode', 'MT009');
return false;
}
//get the doi info
$doi = $this->doiRepo->getByID($doiValue);
$this->setResponse('doi'... | php | {
"resource": ""
} |
q4981 | DOIServiceProvider.getStatus | train | public function getStatus($doiValue)
{
// validate client
if (!$this->isClientAuthenticated()) {
$this->setResponse('responsecode', 'MT009');
return false;
}
//get the doi info
$doi = $this->doiRepo->getByID($doiValue);
$this->setResponse('doi... | php | {
"resource": ""
} |
q4982 | DOIServiceProvider.deactivate | train | public function deactivate($doiValue)
{
// validate client
if (!$this->isClientAuthenticated()) {
$this->setResponse('responsecode', 'MT009');
return false;
}
//get the doi info
$doi = $this->doiRepo->getByID($doiValue);
$this->setResponse('d... | php | {
"resource": ""
} |
q4983 | Level.guardLevelBoundaries | train | private function guardLevelBoundaries($levelValue)
{
if ($levelValue < static::MIN_LEVEL) {
throw new Exceptions\MinLevelUnderflow(
'Level has to be at least ' . self::MIN_LEVEL . ', got ' . $levelValue
);
}
if ($levelValue > static::MAX_LEVEL) {
... | php | {
"resource": ""
} |
q4984 | PhpException.toJson | train | public static function toJson($e, bool $getTrace = true, string $catcher = null): string
{
if (!$getTrace) {
return \json_encode(['msg' => "Error: {$e->getMessage()}"]);
}
$map = [
'code' => $e->getCode() ?: 500,
'msg' => sprintf(
'%s(%d)... | php | {
"resource": ""
} |
q4985 | Files.normalizeFilesArray | train | public static function normalizeFilesArray(array $files): array
{
$return = [];
foreach ($files as $i => $file) {
foreach ($file as $key => $value) {
$return[$key][$i] = $value;
}
}
return $return;
} | php | {
"resource": ""
} |
q4986 | PostsTagsController.index | train | public function index()
{
$page = $this->request->getQuery('page', 1);
$this->paginate['order'] = ['tag' => 'ASC'];
//Limit X4
$this->paginate['limit'] = $this->paginate['maxLimit'] = $this->paginate['limit'] * 4;
//Sets the cache name
$cache = sprintf('tags_limit_... | php | {
"resource": ""
} |
q4987 | PostsTagsController.view | train | public function view($slug = null)
{
//Data can be passed as query string, from a widget
if ($this->request->getQuery('q')) {
return $this->redirect([$this->request->getQuery('q')]);
}
$slug = Text::slug($slug, ['replacement' => ' ']);
$tag = $this->PostsTags->T... | php | {
"resource": ""
} |
q4988 | CreateGroupsCommand.execute | train | public function execute(Arguments $args, ConsoleIo $io)
{
$this->loadModel('MeCms.UsersGroups');
if (!$this->UsersGroups->find()->isEmpty()) {
$io->error(__d('me_cms', 'Some user groups already exist'));
return null;
}
//Truncates the table (this resets IDs... | php | {
"resource": ""
} |
q4989 | Glared.getCurrentMalus | train | public function getCurrentMalus(): int
{
if ($this->getGettingUsedToForRounds() === 0) {
return $this->malus;
}
if ($this->isShined()) {
// each rounds of getting used to lowers malus by one point
return $this->malus + $this->getGettingUsedToForRounds();
... | php | {
"resource": ""
} |
q4990 | Glared.setGettingUsedToForTime | train | public function setGettingUsedToForTime(Time $gettingUsedToFor)
{
$inRounds = $gettingUsedToFor->findRounds();
if ($inRounds === null) {
// it can not be expressed by rounds, so definitely get used to it - malus zeroed
if ($this->isShined()) {
$this->gettingUs... | php | {
"resource": ""
} |
q4991 | BaseMfa.loginUser | train | protected function loginUser()
{
// Set login data for this user
$oUserModel = Factory::model('User', 'nails/module-auth');
$oUserModel->setLoginData($this->mfaUser->id);
// If we're remembering this user set a cookie
if ($this->remember) {
$oUserModel->setReme... | php | {
"resource": ""
} |
q4992 | LoadSiteSettings.loadSettings | train | public function loadSettings()
{
$SettingMapper = ($this->dataMapper)('SettingMapper');
$siteSettings = $SettingMapper->find();
// Create new multi-dimensional array keyed by the setting category and key
$this->settings = array_column($siteSettings, 'setting_value', 'setting_key');
... | php | {
"resource": ""
} |
q4993 | LoadSiteSettings.loadPages | train | public function loadPages($request)
{
$pageMapper = ($this->dataMapper)('pageMapper');
// Fetch all published pages
$this->pages = $pageMapper->findPages();
// Set flag on page for current request
$url = $request->getUri()->getPath();
// Check if home page '/' to ma... | php | {
"resource": ""
} |
q4994 | Literal.getValue | train | public function getValue(Db $db, ...$args) {
$driver = $this->driverKey($db);
if (isset($this->driverValues[$driver])) {
return sprintf($this->driverValues[$driver], ...$args);
} elseif (isset($this->driverValues['default'])) {
return sprintf($this->driverValues['default... | php | {
"resource": ""
} |
q4995 | Literal.setValue | train | public function setValue($value, $driver = 'default') {
$driver = $this->driverKey($driver);
$this->driverValues[$driver] = $value;
return $this;
} | php | {
"resource": ""
} |
q4996 | Literal.driverKey | train | protected function driverKey($key) {
if (is_object($key)) {
$key = get_class($key);
}
$key = strtolower(basename($key));
if (preg_match('`([az]+)(Db)?$`', $key, $m)) {
$key = $m;
}
return $key;
} | php | {
"resource": ""
} |
q4997 | Helper.getOptions | train | public static function getOptions($userSpecified, $defaults)
{
$options = static::getAnyOptions($userSpecified, $defaults);
foreach ($options as $key => $null) {
if (array_key_exists($key, $defaults)) {
continue;
}
throw new \InvalidArgumentExcept... | php | {
"resource": ""
} |
q4998 | Helper.toString | train | public static function toString($data)
{
if (is_array($data)) {
$newData = [];
foreach ($data as $key => $val) {
$key = (string)$key;
$newData[$key] = static::toString($val);
}
} else {
$newData = (string)$data;
... | php | {
"resource": ""
} |
q4999 | Helper.toArray | train | public static function toArray($value)
{
# If it's already an array then just pass it back
if (is_array($value)) {
return $value;
}
if ($value instanceof SerialObject) {
return $value->asArray();
}
if ($value instanceof \ArrayObject) {
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.