_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11400 | EloquentJournalVoucher.subsequentByPeriodByNumberAndByOrganization | train | public function subsequentByPeriodByNumberAndByOrganization($periodId, $number, $organizationId, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->JournalVoucher->setConnection($databaseConnectionName)
->where('period_id', '=', $periodId)
->where('number', '>', $number)
->where('organization_id', '=', $organizationId)
->get();
} | php | {
"resource": ""
} |
q11401 | EloquentJournalVoucher.subsequentByPeriodByVoucherTypeByNumberAndByOrganization | train | public function subsequentByPeriodByVoucherTypeByNumberAndByOrganization($periodId, $voucherTypeId, $number, $organizationId, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->JournalVoucher->setConnection($databaseConnectionName)
->where('period_id', '=', $periodId)
->where('voucher_type_id', '=', $voucherTypeId)
->where('number', '>', $number)
->where('organization_id', '=', $organizationId)
->get();
} | php | {
"resource": ""
} |
q11402 | EloquentJournalVoucher.subtractOneNumber | train | public function subtractOneNumber($journalVoucherIds, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
$this->JournalVoucher->setConnection($databaseConnectionName)
->whereIn('id', $journalVoucherIds)
->update(array('number' => $this->DB->raw('number - 1')));
return true;
} | php | {
"resource": ""
} |
q11403 | MapratingQuery.filterByMapuid | train | public function filterByMapuid($mapuid = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($mapuid)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MapratingTableMap::COL_MAPUID, $mapuid, $comparison);
} | php | {
"resource": ""
} |
q11404 | MapratingQuery.filterByScore | train | public function filterByScore($score = null, $comparison = null)
{
if (is_array($score)) {
$useMinMax = false;
if (isset($score['min'])) {
$this->addUsingAlias(MapratingTableMap::COL_SCORE, $score['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($score['max'])) {
$this->addUsingAlias(MapratingTableMap::COL_SCORE, $score['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MapratingTableMap::COL_SCORE, $score, $comparison);
} | php | {
"resource": ""
} |
q11405 | ConfigPass.createConfigs | train | protected function createConfigs($groups, $permissions, ContainerBuilder $container)
{
$configManager = $container->findDefinition(ConfigManagerInterface::class);
foreach ($groups as $groupCode => $group)
{
$pathPrefix = $container->getParameter('expansion.admin_groups.config.path') . "/$groupCode";
$id = 'expansion.admin_groups.config.label.' . $groupCode;
$container->setDefinition($id, new ChildDefinition('expansion.admin_groups.config.label.abstract'))
->replaceArgument('$path', "$pathPrefix/label")
->replaceArgument('$defaultValue', $group['label']);
$configManager->addMethodCall('registerConfig', [new Reference($id), $id]);
$id = 'expansion.admin_groups.config.logins.' . $groupCode;
$container->setDefinition($id, new ChildDefinition('expansion.admin_groups.config.logins.abstract'))
->setArgument('$path', "$pathPrefix/logins")
->setArgument('$defaultValue', $group['logins']);
$configManager->addMethodCall('registerConfig', [new Reference($id), $id]);
if ($groupCode != "master_admin") {
foreach ($permissions as $permission) {
$id = 'expansion.admin_groups.config.permissions.' . $groupCode . ".$permission";
$container->setDefinition($id, new ChildDefinition('expansion.admin_groups.config.permissions.abstract'))
->setArgument('$path', "$pathPrefix/perm_$permission")
->setArgument('$defaultValue', $group['logins'])
->setArgument('$name', "expansion_admingroups.permission.$permission.label")
->setArgument('$description', "expansion_admingroups.permission.$permission.description");
$configManager->addMethodCall('registerConfig', [new Reference($id), $id]);
}
}
}
} | php | {
"resource": ""
} |
q11406 | Profiler.getLastQuery | train | public function getLastQuery(string $key = null)
{
return $key ? $this->profiles['query'][$this->queryCount][$key] ?? null
: $this->profiles['query'][$this->queryCount] ?? null;
} | php | {
"resource": ""
} |
q11407 | Profiler.getTotalTime | train | public function getTotalTime(bool $indexed = false)
{
if ($this->profiles == null) {
return null;
}
$totalTime = 0.00;
$totalTimeIndexed = '';
if (isset($this->profiles['connection'])) {
$totalTime += $this->profiles['connection']['time'];
if ($indexed) {
$totalTimeIndexed .= "connection({$totalTime})";
}
}
if (isset($this->profiles['query'])) {
foreach ($this->profiles['query'] as $i => $profile) {
$totalTime += $profile['time'];
if ($indexed) {
$totalTimeIndexed .= " query{$i}({$profile['time']})";
}
}
}
return !$indexed ? $totalTime : $totalTimeIndexed;
} | php | {
"resource": ""
} |
q11408 | RoutesLoaderBuilder.build | train | public function build()
{
if ($this->container->hasDefinition($this->definitionName())) {
$this->container->getDefinition(
$this->definitionName()
)->replaceArgument(0, array_unique($this->configuration, SORT_REGULAR));
}
if ($this->container->hasDefinition($this->definitionApiName())) {
foreach ($this->configuration as $key => $config) {
$this->configuration[$key]['enabled'] = $config['api_enabled'];
if (array_key_exists('type', $config)) {
$this->configuration[$key]['type'] = $config['api_type'];
}
}
$this->container->getDefinition(
$this->definitionApiName()
)->replaceArgument(0, array_unique($this->configuration, SORT_REGULAR));
}
return $this->container;
} | php | {
"resource": ""
} |
q11409 | RoutesLoaderBuilder.sanitize | train | protected function sanitize(array $configuration)
{
foreach ($configuration as $key => $config) {
if (null === $config['name']) {
$configuration[$key]['name'] = $this->defaultRouteName($key);
}
if (null === $config['path']) {
$configuration[$key]['path'] = $this->defaultRoutePath($key);
}
if (null === $config['api_name']) {
$configuration[$key]['api_name'] = $this->defaultApiRouteName($key);
}
if (null === $config['api_path']) {
$configuration[$key]['api_path'] = $this->defaultApiRoutePath($key);
}
}
return $configuration;
} | php | {
"resource": ""
} |
q11410 | ParametrizedString.getParameters | train | public function getParameters() : array
{
if (is_null($this->parameters)) {
$matches = [];
$regExp = self::PARAMS_SEARCH_REGEXP;
preg_match_all($regExp, $this->str, $matches);
$this->parameters = $matches[2];
}
return $this->parameters;
} | php | {
"resource": ""
} |
q11411 | View.render | train | public function render( $view, $view_suffix = '' ) {
$this->view = $view;
$this->view_suffix = $view_suffix;
if ( is_singular() ) {
$this->_render_loop();
} else {
$this->_render_direct();
}
} | php | {
"resource": ""
} |
q11412 | View.view | train | public function view() {
$view = $this->_get_args_for_template_part();
$view = apply_filters( 'inc2734_wp_view_controller_view', $view );
Helper\get_template_part( $view['slug'], $view['name'] );
} | php | {
"resource": ""
} |
q11413 | View._get_args_for_template_part | train | protected function _get_args_for_template_part() {
$view = [
'slug' => '',
'name' => '',
];
$template_name = Helper\locate_template( (array) Helper\config( 'view' ), $this->view, $this->view_suffix );
if ( empty( $template_name ) ) {
return $view;
}
if ( ! $this->view_suffix ) {
$view = [
'slug' => $template_name,
'name' => '',
];
} else {
$view = [
'slug' => preg_replace( '|\-' . preg_quote( $this->view_suffix ) . '$|', '', $template_name ),
'name' => $this->view_suffix,
];
}
if ( is_404() || is_search() ) {
return $view;
}
$static_template_name = $this->get_static_view_template_name();
if ( locate_template( $static_template_name . '.php', false ) ) {
return [
'slug' => $static_template_name,
'name' => '',
];
}
return $view;
} | php | {
"resource": ""
} |
q11414 | View.get_static_view_template_name | train | public function get_static_view_template_name() {
// @codingStandardsIgnoreStart
// @todo サニタイズしているのに Detected usage of a non-validated input variable: $_SERVER がでる。バグ?
$request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
// @codingStandardsIgnoreEnd
$request_uri = $this->_get_relative_path( $request_uri );
$path = $this->_remove_http_query( $request_uri );
$path = $this->_remove_paged_slug( $path );
$path = trim( $path, '/' );
if ( ! $path ) {
return Helper\locate_template( (array) Helper\config( 'static' ), 'index' );
}
$template_name = Helper\locate_template( (array) Helper\config( 'static' ), $path );
if ( empty( $template_name ) ) {
$template_name = Helper\locate_template( (array) Helper\config( 'static' ), $path . '/index' );
}
return $template_name;
} | php | {
"resource": ""
} |
q11415 | View._remove_http_query | train | protected function _remove_http_query( $uri ) {
$uri = str_replace( http_build_query( $_GET, null, '&' ), '', $uri );
$uri = rtrim( $uri, '?' );
return $uri;
} | php | {
"resource": ""
} |
q11416 | Gravatar.getGravatarSize | train | protected function getGravatarSize()
{
$size = $this->getSize();
return $this->config['sizes'][$size] ?? (\is_int($size) ? $size : 'small');
} | php | {
"resource": ""
} |
q11417 | CsvBuilderBase.setCallback | train | public function setCallback($callback = null)
{
if (!is_null($callback) && !is_callable($callback)) {
throw new Exception("callback must be of type callable or null");
}
$this->callback = $callback;
return $this;
} | php | {
"resource": ""
} |
q11418 | CsvBuilderBase.setHeader | train | public function setHeader(array $header)
{
if (is_numeric(key($header))) {
$header = array_fill_keys($header, '');
}
$this->header = $header;
return $this;
} | php | {
"resource": ""
} |
q11419 | BaseService.CreatePage | train | public final function CreatePage()
{
$method = strtoupper($this->_context->get("REQUEST_METHOD"));
$customAction = strtolower($method) . ucfirst($this->_action);
if (method_exists($this, $customAction))
$this->$customAction($this->getRawRequest(), $this->_context->get("id"));
else
throw new BadMethodCallException("The method '$customAction' does not exists.");
return $this->defaultXmlnukeDocument;
} | php | {
"resource": ""
} |
q11420 | FileUtil.DeleteFilesFromPath | train | public static function DeleteFilesFromPath($file)
{
$files = self::RetrieveFilesFromFolder($file->PathSuggested(),null);
foreach ($files as $f)
{
if (strpos($f,$file->Extension())!== false)
{
self::DeleteFileString($f);
}
}
} | php | {
"resource": ""
} |
q11421 | FileUtil.AdjustSlashes | train | public static function AdjustSlashes($path)
{
if (self::isWindowsOS())
{
$search = "/";
$replace = "\\";
}
else
{
$search = "\\";
$replace = "/";
}
return str_replace($search, $replace, $path);
} | php | {
"resource": ""
} |
q11422 | FileUtil.getUriFromFile | train | public static function getUriFromFile($absolutepath)
{
if (self::isWindowsOS())
{
$result = "file:///".$absolutepath;
$search = "\\";
$replace = "/";
$result =str_replace($search, $replace, $result);
}
else
{
$result = "file://".$absolutepath;
}
return $result;
} | php | {
"resource": ""
} |
q11423 | FileUtil.isReadable | train | public static function isReadable($filename)
{
if (!is_readable($filename))
return false;
if ((self::isWindowsOS() || self::isMacOS()) && (count(glob($filename . '*')) == 0))
throw new \Xmlnuke\Core\Exception\CaseMismatchException(
'Your operating system is not case sensitive and it can find the file "' . $filename . '" ' .
'with different uppercase and lowercase combination in your name. ' .
'However Xmlnuke will not accept it for ensure your code will run on any platform.'
);
else
return true;
} | php | {
"resource": ""
} |
q11424 | FileUtil.ForceDirectories | train | public static function ForceDirectories($pathname, $mode = 0777)
{
// Crawl up the directory tree
$next_pathname = substr($pathname,0, strrpos($pathname, self::Slash()));
if ($next_pathname != "")
{
self::ForceDirectories($next_pathname, $mode);
}
if (!file_exists($pathname))
{
FileUtil::CreateDirectory($pathname, $mode);
}
} | php | {
"resource": ""
} |
q11425 | FileUtil.ForceRemoveDirectories | train | public static function ForceRemoveDirectories($dir)
{
if($objs = glob($dir."/*")){
foreach($objs as $obj) {
is_dir($obj)? self::ForceRemoveDirectories($obj) : self::DeleteFileString($obj);
}
}
self::DeleteDirectory($dir);
} | php | {
"resource": ""
} |
q11426 | FileUtil.OpenRemoteDocument | train | public static function OpenRemoteDocument($url)
{
// Expression Regular:
// [1]: http or ftp
// [2]: Server name
// [4]: Full Path
$pat = '/(http|ftp|https):\\/\\/((\\w|\\.)+)/i';
$urlParts = preg_split($pat, $url, -1,PREG_SPLIT_DELIM_CAPTURE);
$handle = fsockopen($urlParts[2], 80, $errno, $errstr, 30);
if (!$handle)
{
throw new FileUtilException("Socket error: $errstr ($errno)");
}
else
{
$out = "GET " . $urlParts[4] . " HTTP/1.1\r\n";
$out .= "Host: " . $urlParts[2] . "\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($handle, $out);
return $handle;
}
} | php | {
"resource": ""
} |
q11427 | FileUtil.ReadRemoteDocument | train | public static function ReadRemoteDocument($handle)
{
// THIS FUNCTION IS A CRAP!!!!
// I NEED REFACTORY THIS!
$retdocument = "";
$xml = true;
$canread = true;
// READ HEADER
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (strpos(strtolower($buffer), "content-type:")!==false)
{
$xml = (strpos(strtolower($buffer), "xml")!==false);
$canread = !$xml;
}
if (trim($buffer) == "")
{
break;
}
}
// READ CONTENT
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (!$canread && ($buffer[0] != "<"))
{
$buffer = "";
}
else
{
$canread = true;
}
$retdocument = $retdocument . $buffer;
}
fclose($handle);
if ($xml)
{
$lastvalid = strrpos($retdocument, ">");
$retdocument = substr($retdocument, 0, $lastvalid+1);
}
return $retdocument;
} | php | {
"resource": ""
} |
q11428 | Stringifier.stringify | train | public function stringify($value): string
{
if ($value instanceof \DateTimeInterface) {
return $value->format('Y-m-d');
}
if (is_array($value)) {
return self::ARRAY_VALUE;
}
if (is_object($value) && !method_exists($value, '__tostring')) {
return self::OBJECT_VALUE;
}
return (string)$value;
} | php | {
"resource": ""
} |
q11429 | Profiler.add | train | public function add(string $profile, $inheritContext = false)
{
if ($this->has($profile)) {
throw new Exception("Profile {$profile} already exist.");
}
if (!strlen($profile)) {
throw new Exception("Profile must be set.");
}
$child = clone $this;
$child->clear(!$inheritContext);
$child->name = ($this->name ? $this->name . ' > ' : '') . $profile;
$child->children = [];
$this->children[$profile] = $child;
return $child;
} | php | {
"resource": ""
} |
q11430 | Profiler.clear | train | public function clear($clearContext = false)
{
// Clear all stopwatch related values
$this->start = null;
$this->stop = null;
$this->laps = [];
if ($clearContext) {
$this->context = null;
}
return $this;
} | php | {
"resource": ""
} |
q11431 | Profiler.clearAll | train | public function clearAll($clearContext = false)
{
foreach ($this->getProfiles() as $child) {
$child->clearAll($clearContext);
}
$this->clear($clearContext);
return $this;
} | php | {
"resource": ""
} |
q11432 | Profiler.get | train | public function get(string $profile)
{
if (!$this->has($profile)) {
throw new Exception("Profile {$profile} does not exist.");
}
return $this->children[$profile];
} | php | {
"resource": ""
} |
q11433 | Profiler.note | train | public function note($message = 'Note', $context = [], $level = null)
{
// Check if method was called only with $context
if (is_array($message)) {
$level = $context ?: null;
$context = $message;
$message = 'Note';
}
// Skip log entry if message is null
if (is_null($message)) {
return $this;
}
// Add and format context
if ($this->context) {
$context = array_merge($this->context->all(), $context);
}
$context['profile'] = $this->name;
if (isset($context['runtime'])) {
$formatter = $this->getFormatter();
$context['runtime'] = $formatter($context['runtime']);
}
// Log
$this->logger->log($level ?: $this->level, $message, $context);
return $this;
} | php | {
"resource": ""
} |
q11434 | Profiler.remove | train | public function remove(string $profile)
{
$child = $this->get($profile);
$child->clearAll();
$child->removeAll();
unset($this->children[$profile]);
return $this;
} | php | {
"resource": ""
} |
q11435 | Profiler.removeAll | train | public function removeAll()
{
foreach ($this->getProfiles() as $profile => $child) {
$this->remove($profile);
}
return $this;
} | php | {
"resource": ""
} |
q11436 | Profiler.restart | train | public function restart($message = 'Restart', $context = [])
{
// Check if method was called only with $context
if (is_array($message)) {
$context = $message;
$message = 'Restart';
}
// Clear data and start (again)
$this->clear();
$this->start($message, $context);
} | php | {
"resource": ""
} |
q11437 | Profiler.set | train | public function set(string $profile, $inheritContext = false)
{
return $this->has($profile) ? $this->get($profile) : $this->add($profile, $inheritContext);
} | php | {
"resource": ""
} |
q11438 | Profiler.start | train | public function start($message = 'Start', $context = [])
{
// Check if method was called only with $context
if (is_array($message)) {
$context = $message;
$message = 'Start';
}
// A profile can only be started if never started or cleared before
if ($this->isStarted()) {
throw new Exception("Profile {$this->getName()} already started.");
}
// The main profile
if (null === $this->name) {
if ($this->children) {
throw new Exception("Profile {$this->getName()} must be started before all other profiles.");
}
$timeStart = $_SERVER['REQUEST_TIME_FLOAT'] ?? $this->timeCurrent();
} else {
$timeStart = $this->timeCurrent();
}
// Start counter and first lap
$this->start = $timeStart;
$this->laps[] = $timeStart;
// Log
$this->note($message, $context);
return $this;
} | php | {
"resource": ""
} |
q11439 | Profiler.startAll | train | public function startAll($message = 'Start', $context = [])
{
// Start this profile if not started
if (!$this->isStarted()) {
$this->start($message, $context);
}
// Start all child profiles afterwards
foreach ($this->getProfiles() as $child) {
$child->startAll($message, $context);
}
return $this;
} | php | {
"resource": ""
} |
q11440 | Profiler.stop | train | public function stop($message = 'Stop', $context = [], $lap = true)
{
// Check if method was called only with $context
if (is_array($message)) {
$lap = $context;
$context = $message;
$message = 'Stop';
} elseif (is_bool($message)) {
$lap = $message;
$context = [];
$message = 'Stop';
} elseif (is_bool($context)) {
$lap = $context;
$context = [];
}
if (!$this->isRunning()) {
throw new Exception("Profile {$this->getName()} not running.");
}
// Skip saving and logging lap for single lap profiles
if ($lap && count($this->laps) > 1) {
$this->lap();
}
// Stop counter
$this->stop = $this->timeCurrent();
// Add total runtime to context
$context['runtime'] = $this->timeTotal();
// Log
$this->note($message, $context);
return $this;
} | php | {
"resource": ""
} |
q11441 | Profiler.stopAll | train | public function stopAll($message = 'Stop', $context = [], $lap = true)
{
// Stop all running child profiles first
foreach ($this->getProfiles(true) as $child) {
$child->stopAll($message, $context, $lap);
}
// Stop this profile if still running
if ($this->isRunning()) {
$this->stop($message, $context, $lap);
}
return $this;
} | php | {
"resource": ""
} |
q11442 | SymfonyEventAdapter.dispatch | train | public function dispatch($eventName, $params)
{
$event = new DedicatedEvent();
$event->setParameters($params);
$this->symfonyEventDispatcher->dispatch("maniaplanet.game.".$eventName, $event);
} | php | {
"resource": ""
} |
q11443 | FlashController.flashcfg | train | public function flashcfg() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = $this->ConfigTheme->getConfigAjaxFlash();
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | {
"resource": ""
} |
q11444 | FlashController.flashmsg | train | public function flashmsg() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = [];
$dataDefault = [
'result' => false,
'key' => null,
'messages' => [],
];
$keys = $this->request->data('keys');
$delete = (bool)$this->request->data('delete');
if (empty($keys)) {
$data[] = $dataDefault;
$this->set(compact('data'));
$this->set('_serialize', 'data');
return;
}
$keys = (array)$keys;
foreach ($keys as $key) {
if (empty($key)) {
$key = 'flash';
}
$dataItem = $dataDefault;
$dataItem['key'] = $key;
if ($delete) {
$dataItem['result'] = $this->FlashMessage->deleteMessage($key);
} else {
$messages = $this->FlashMessage->getMessage($key);
$dataItem['messages'] = $messages;
$dataItem['result'] = !empty($messages);
}
$data[] = $dataItem;
}
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | {
"resource": ""
} |
q11445 | Radarr.postCommand | train | public function postCommand($name, array $params = null)
{
$uri = 'command';
$uriData = [
'name' => $name
];
if ($params != null) {
foreach ($params as $key=>$value) {
$uriData[$key]= $value;
}
}
try {
$response = $this->_request(
[
'uri' => $uri,
'type' => 'post',
'data' => $uriData
]
);
} catch ( \Exception $e ) {
throw new InvalidException($e->getMessage());
}
return $response->getBody()->getContents();
} | php | {
"resource": ""
} |
q11446 | Radarr.postMovie | train | public function postMovie(array $data)
{
$uri = 'movie';
try {
$response = $this->_request(
[
'uri' => $uri,
'type' => 'post',
'data' => $data
]
);
} catch ( \Exception $e ) {
return $e->getMessage();
}
return $response->getBody()->getContents();
} | php | {
"resource": ""
} |
q11447 | Radarr.updateMovie | train | public function updateMovie(array $data)
{
$uri = 'movie';
try {
$response = $this->_request(
[
'uri' => $uri,
'type' => 'put',
'data' => $data
]
);
} catch ( \Exception $e ) {
throw new InvalidException($e->getMessage());
}
return $response->getBody()->getContents();
} | php | {
"resource": ""
} |
q11448 | Radarr.deleteMovie | train | public function deleteMovie($id,$deleteFiles=false)
{
$uri = 'movie';
try {
$response = $this->_request(
[
'uri' => $uri . '/' . $id,
'type' => 'delete',
'deleteFiles' => $deleteFiles
]
);
} catch ( \Exception $e ) {
throw new InvalidException($e->getMessage());
}
return $response->getBody()->getContents();
} | php | {
"resource": ""
} |
q11449 | Ranking.order | train | public static function order(array $array, array $columns)
{
$arrayMultisortParameters = [];
foreach ($columns as $column => $order) {
$arrayMultisortParameters[] = array_column($array, $column);
$arrayMultisortParameters[] = $order;
}
$arrayMultisortParameters[] = &$array;
array_multisort(...$arrayMultisortParameters);
return $array;
} | php | {
"resource": ""
} |
q11450 | Ranking.addRank | train | public static function addRank($array, $key = 'rank', $columns = ['pointChart'], $boolEqual = false)
{
$rank = 1;
$compteur = 0;
$nbEqual = 1;
$nb = count($array);
for ($i = 0; $i <= $nb - 1; $i++) {
if ($i >= 1) {
$row1 = $array[$i - 1];
$row2 = $array[$i];
$isEqual = true;
foreach ($columns as $column) {
if ($row1[$column] != $row2[$column]) {
$isEqual = false;
break;
}
}
if ($isEqual) {
$compteur++;
++$nbEqual;
} else {
$rank = $rank + $compteur + 1;
$compteur = 0;
unset($nbEqual);
$nbEqual = 1;
}
}
$row = $array[$i];
$row[$key] = $rank;
if ($boolEqual) {
$row['nbEqual'] = &$nbEqual;
}
$array[$i] = $row;
}
unset($nbEqual);
return $array;
} | php | {
"resource": ""
} |
q11451 | Ranking.chartPointProvider | train | public static function chartPointProvider($iNbPartcipant)
{
$liste = [];
$pointRecord = 100 * $iNbPartcipant;
$nb = 80;// % différence entre deux positions
$compteur = 0;// compteur de position
// 1er
$liste[1] = $pointRecord;
for ($i = 2; $i <= $iNbPartcipant; $i++) {
$pointRecord = (int)($pointRecord * $nb / 100);
$liste[$i] = $pointRecord;
$compteur++;
if ($nb < 85) {
if ($compteur === 2) {
$nb++;// le % augmente donc la différence diminue
$compteur = 0;
}
} elseif ($nb < 99) {
$nb++;
}
}
return $liste;
} | php | {
"resource": ""
} |
q11452 | DebuggerTrait.reInitOptions | train | public function reInitOptions($options)
{
/* @var Renderer $this */
$this->setOptions([
'memory_limit' => null,
'execution_max_time' => null,
'enable_profiler' => false,
'profiler' => [
'display' => false,
'log' => false,
],
]);
$this->setOptions($options);
$this->initDebugOptions($this);
} | php | {
"resource": ""
} |
q11453 | DebuggerTrait.handleError | train | public function handleError($error, $code, $path, $source, $parameters, $options)
{
/* @var \Throwable $error */
$exception = $options['debug']
? $this->getDebuggedException($error, $code, $source, $path, $parameters, $options)
: $error;
$handler = $options['error_handler'];
if (!$handler) {
// @codeCoverageIgnoreStart
if ($options['debug'] && $options['exit_on_error']) {
if ($options['html_error']) {
echo $exception->getMessage();
exit(1);
}
if (!function_exists('xdebug_is_enabled') || !xdebug_is_enabled()) {
echo $exception->getMessage()."\n".$exception->getTraceAsString();
exit(1);
}
}
// @codeCoverageIgnoreEnd
throw $exception;
}
$handler($exception);
} | php | {
"resource": ""
} |
q11454 | Bubble.getRenderData | train | public function getRenderData( $useLabel = false )
{
$radius = ( $this->jsWriter instanceof \Altamira\JsWriter\Flot ) ? $this['radius'] * 10 : $this['radius'];
$data = array( $this['x'], $this['y'], $radius );
if ( $useLabel ) {
$data[] = $this['label'];
}
return $data;
} | php | {
"resource": ""
} |
q11455 | Translations.getTranslation | train | public function getTranslation($id, $parameters = [], $locale = null)
{
$parameters = array_merge($this->replacementPatterns, $parameters);
return $this->translator->trans($id, $parameters, null, $locale);
} | php | {
"resource": ""
} |
q11456 | Translations.getTranslations | train | public function getTranslations($id, $parameters = [])
{
$messages = [];
foreach ($this->supportedLocales as $locale) {
$message = $this->getTranslation($id, $parameters, $locale);
$messages[] = [
"Lang" => lcfirst($locale),
"Text" => $message,
];
}
return $messages;
} | php | {
"resource": ""
} |
q11457 | WebHookHandler.setUp | train | public function setUp($options = [])
{
parent::setUp($options);
if (isset($options['changeid'])) {
$this->changeid = $options['changeid'];
}
if (isset($options['operation'])) {
$this->setOperation($options['operation']);
if ($options['operation'] == 'delete') {
$this->ignore404(true);
}
}
if (isset($options['external-ids'])) {
$this->extids = $options['external-ids'];
}
} | php | {
"resource": ""
} |
q11458 | BrowserConsoleHandler.getResponseFormat | train | protected static function getResponseFormat()
{
// Check content type
foreach (headers_list() as $header) {
if (stripos($header, 'content-type:') === 0) {
// This handler only works with HTML and javascript outputs
// text/javascript is obsolete in favour of application/javascript, but still used
if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
return 'js';
}
if (stripos($header, 'text/html') === false) {
return 'unknown';
}
break;
}
}
return 'html';
} | php | {
"resource": ""
} |
q11459 | CompatibleFetcher.getCompatibleData | train | public function getCompatibleData($haystack, $title, $mode, $script)
{
// List of choices order by importance.
$choices = $this->getChoicesByPriority($title, $mode, $script);
foreach ($choices as $choice) {
$data = AssociativeArray::getFromKey($haystack, $choice);
if (!is_null($data)) {
return $data;
}
}
return null;
} | php | {
"resource": ""
} |
q11460 | CompatibleFetcher.getChoicesByPriority | train | public function getChoicesByPriority($titleId, $mode, $script)
{
$game = $this->getTitleGame($titleId);
return [
[$titleId, $mode, $script],
[$titleId, $mode, self::COMPATIBLE_ALL],
[$titleId, self::COMPATIBLE_ALL, self::COMPATIBLE_ALL],
// If perfect title is not found then fallback on game.
[$game, $mode, $script],
[$game, $mode, self::COMPATIBLE_ALL],
[$game, self::COMPATIBLE_ALL, self::COMPATIBLE_ALL],
// For modes that are common to all titles.
[self::COMPATIBLE_ALL, $mode, $script],
[self::COMPATIBLE_ALL, $mode, self::COMPATIBLE_ALL],
// For data providers compatible with every title/gamemode/script.
[self::COMPATIBLE_ALL, self::COMPATIBLE_ALL, self::COMPATIBLE_ALL],
];
} | php | {
"resource": ""
} |
q11461 | CompatibleFetcher.getTitleGame | train | public function getTitleGame($titleId)
{
$game = $this->titles->get($titleId, self::GAME_UNKNOWN);
return $game;
} | php | {
"resource": ""
} |
q11462 | PlayerListConfig.get | train | public function get()
{
$players = [];
foreach (parent::get() as $login) {
$player = $this->playerDb->get($login);
if (is_null($player)) {
$player = new Player();
$player->setLogin($login);
}
$players[] = $player;
}
return $players;
} | php | {
"resource": ""
} |
q11463 | XmlnukeTabView.addTabItem | train | public function addTabItem($title, $docobj, $tabdefault = false)
{
if (is_null($docobj) || !($docobj instanceof IXmlnukeDocumentObject))
{
throw new InvalidArgumentException("Object is null or not is IXmlnukeDocumentObject. Found object type: " . get_class($docobj), 853);
}
$this->_tabs[] = array($title, "OBJ", $docobj);
if ($tabdefault)
{
$this->_tabDefault = count($this->_tabs)-1;
}
} | php | {
"resource": ""
} |
q11464 | TicketsField.validate | train | public function validate($validator)
{
// Throw an error when there are no tickets selected
if (empty($this->value)) {
$validator->validationError($this->name, _t(
'TicketsField.VALIDATION_EMPTY',
'Select at least one ticket'
), 'validation');
return false;
}
// Get the availability
$available = $this->getForm()->event->getAvailability();
// get the sum of selected tickets
$ticketCount = array_sum(array_map(function ($item) {
return $item['Amount'];
}, $this->value));
// If the sum of tickets is 0 trow the same error as empty
if ($ticketCount === 0) {
$validator->validationError($this->name, _t(
'TicketsField.VALIDATION_EMPTY',
'Select at least one ticket'
), 'validation');
return false;
}
// Throw an error when there are more tickets selected than available
if ($ticketCount > $available) {
$validator->validationError($this->name, _t(
'TicketsField.VALIDATION_TO_MUCH',
'There are {ticketCount} tickets left',
null,
array(
'ticketCount' => $available
)
), 'validation');
return false;
}
return false;
} | php | {
"resource": ""
} |
q11465 | EloquentAccountChartType.accountsChartsTypesByCountry | train | public function accountsChartsTypesByCountry($id)
{
return $this->AccountChartType->where(function($query) use ($id)
{
$query->orWhere('country_id', '=', $id);
$query->orWhereNull('country_id');
})->get();
} | php | {
"resource": ""
} |
q11466 | WindowFrameFactory.callbackItemClick | train | public function callbackItemClick(ManialinkInterface $manialink, $login, $params, $args)
{
$this->menuContentFactory->create($login);
/** @var ItemInterface $item */
$item = $args['item'];
$item->execute($this->menuContentFactory, $manialink, $login, $params, $args);
} | php | {
"resource": ""
} |
q11467 | Pagination.clear | train | public function clear()
{
if (is_array($this->temp_properties)) {
foreach ($this->temp_properties as $key => $value) {
if (property_exists($this, $key)) {
$this->$key = $value;
}
}
unset($key, $value);
$this->temp_properties = null;
}
} | php | {
"resource": ""
} |
q11468 | Pagination.createLinks | train | public function createLinks($result_string = 'Displaying page :current_page_number_displaying of :total_pages<br>:pagination')
{
$pagination_data = $this->getPaginationData();
if (!is_array($pagination_data)) {
return null;
}
if ($result_string == null) {
$result_string = 'Displaying page :current_page_number_displaying of :total_pages<br>:pagination';
}
// render the pagination. --------------------------------------------------------------------------------------------
$pagination_rendered = "\n";
if (array_key_exists('overall_tag_open', $pagination_data)) {
$pagination_rendered .= $pagination_data['overall_tag_open'];
}
if (array_key_exists('generated_pages', $pagination_data) && is_array($pagination_data['generated_pages'])) {
foreach ($pagination_data['generated_pages'] as $page_key => $page_item) {
if (is_array($page_item)) {
if (array_key_exists('tag_open', $page_item)) {
$pagination_rendered .= $page_item['tag_open'];
}
if (array_key_exists('link', $page_item) && $page_item['link'] != null) {
$pagination_rendered .= '<a href="' . $page_item['link'] . '">';
}
if (array_key_exists('text', $page_item)) {
$pagination_rendered .= $page_item['text'];
}
if (array_key_exists('link', $page_item) && $page_item['link'] != null) {
$pagination_rendered .= '</a>';
}
if (array_key_exists('tag_close', $page_item)) {
$pagination_rendered .= $page_item['tag_close'];
}
}
}
unset($page_item, $page_key);
}
if (array_key_exists('overall_tag_close', $pagination_data)) {
$pagination_rendered .= $pagination_data['overall_tag_close'];
}
$pagination_rendered .= "\n";
// end render the pagination ----------------------------------------------------------------------------------------
$output = $result_string;
if (array_key_exists('total_pages', $pagination_data)) {
$output = str_replace(':total_pages', $pagination_data['total_pages'], $output);
}
if (array_key_exists('page_number_type', $pagination_data)) {
$output = str_replace(':page_number_type', $pagination_data['total_pages'], $output);
}
if (array_key_exists('current_page_number_displaying', $pagination_data)) {
$output = str_replace(':current_page_number_displaying', $pagination_data['current_page_number_displaying'], $output);
}
if (isset($pagination_rendered)) {
$output = str_replace(':pagination', $pagination_rendered, $output);
}
unset($pagination_data, $pagination_rendered);
return $output;
} | php | {
"resource": ""
} |
q11469 | Pagination.generateUrl | train | private function generateUrl($page_value, $direction = '', $return_value_only = false)
{
switch ($direction) {
case 'first':
if ($this->page_number_type == 'start_num') {
$page_value = 0;
} elseif ($this->page_number_type == 'page_num') {
$page_value = 1;
}
break;
case 'previous':
if ($this->page_number_type == 'start_num') {
$page_value = ($page_value - $this->items_per_page);
if ($page_value < 0) {
$page_value = 0;
}
} elseif ($this->page_number_type == 'page_num') {
$page_value = ($page_value - 1);
if ($page_value <= 0) {
$page_value = 1;
}
}
break;
case 'next':
if ($this->page_number_type == 'start_num') {
$page_value = ($page_value + $this->items_per_page);
if ($page_value > (($this->total_pages*$this->items_per_page) - $this->items_per_page)) {
$page_value = (($this->total_pages*$this->items_per_page) - $this->items_per_page);
}
} elseif ($this->page_number_type == 'page_num') {
$page_value = ($page_value + 1);
if ($page_value > (($this->total_pages*$this->items_per_page) / $this->items_per_page)) {
$page_value = (($this->total_pages*$this->items_per_page) / $this->items_per_page);
}
}
break;
case 'last':
if ($this->page_number_type == 'start_num') {
$page_value = ($page_value - $this->items_per_page);
} elseif ($this->page_number_type == 'page_num') {
$page_value = ($page_value / $this->items_per_page);
}
break;
default:
// calculate page querystring number from generated before and after current pages. example 1 2 [3] 4 5 current is 3, generated is 1 2 and 4 5
if ($this->page_number_type == 'start_num') {
$page_value = (($page_value * $this->items_per_page) - $this->items_per_page);
}
break;
}
if ($return_value_only === true) {
return $page_value;
} else {
return str_replace('%PAGENUMBER%', $page_value, $this->base_url);
}
} | php | {
"resource": ""
} |
q11470 | Pagination.isCurrentlyFirstPage | train | private function isCurrentlyFirstPage()
{
if ($this->page_number_type === 'start_num') {
if ($this->page_number_value === 0) {
return true;
}
return false;
} elseif ($this->page_number_type === 'page_num') {
if ($this->page_number_value === 1) {
return true;
}
return false;
}
return false;
} | php | {
"resource": ""
} |
q11471 | Pagination.isCurrentlyLastPage | train | private function isCurrentlyLastPage()
{
if ($this->page_number_type === 'start_num') {
if ($this->page_number_value >= ($this->total_pages*$this->items_per_page)-$this->items_per_page) {
return true;
}
return false;
} elseif ($this->page_number_type === 'page_num') {
if ($this->page_number_value >= $this->total_pages) {
return true;
}
return false;
}
return false;
} | php | {
"resource": ""
} |
q11472 | Pagination.validateCorrectProperties | train | private function validateCorrectProperties()
{
if (!is_bool($this->current_page_link)) {
$this->current_page_link = false;
}
if (!is_bool($this->first_page_always_show)) {
$this->first_page_always_show = false;
}
if (is_numeric($this->items_per_page)) {
$this->items_per_page = intval($this->items_per_page);
if ($this->items_per_page <= 0) {
$this->items_per_page = 10;
}
} elseif (!is_numeric($this->items_per_page)) {
$this->items_per_page = 10;
}
if (!is_bool($this->last_page_always_show)) {
$this->last_page_always_show = false;
}
if (!is_bool($this->next_page_always_show)) {
$this->next_page_always_show = false;
}
if (is_numeric($this->number_adjacent_pages)) {
$this->number_adjacent_pages = intval($this->number_adjacent_pages);
if ($this->number_adjacent_pages < 0) {
$this->number_adjacent_pages = 5;
}
} else {
$this->number_adjacent_pages = 5;
}
if (!is_bool($this->number_display)) {
$this->number_display = false;
}
if ($this->page_number_type != 'start_num' && $this->page_number_type != 'page_num') {
$this->page_number_type = 'start_num';
}
if (!is_bool($this->previous_page_always_show)) {
$this->previous_page_always_show = false;
}
if (is_numeric($this->unavailable_after)) {
$this->unavailable_after = intval($this->unavailable_after);
if ($this->unavailable_after <= 0) {
$this->unavailable_after = 2;
}
} else {
$this->unavailable_after = false;
}
if (is_numeric($this->unavailable_before)) {
$this->unavailable_before = intval($this->unavailable_before);
if ($this->unavailable_before <= 0) {
$this->unavailable_before = 2;
}
} else {
$this->unavailable_before = false;
}
if (!is_bool($this->unavailable_display)) {
$this->unavailable_display = false;
}
} | php | {
"resource": ""
} |
q11473 | Pagination.validateRequiredProperties | train | private function validateRequiredProperties()
{
if ($this->base_url == null) {
throw new \Exception('The base_url property was not set.');
}
if (is_numeric($this->total_records)) {
$this->total_records = intval($this->total_records);
} else {
throw new \Exception('The total_records property was not set.');
}
if (!is_numeric($this->page_number_value)) {
throw new \Exception('The page_number_value property was not set.');
}
} | php | {
"resource": ""
} |
q11474 | MessageBag.setSessionStore | train | public function setSessionStore(Session $session)
{
$this->session = $session;
$this->instance = null;
return $this;
} | php | {
"resource": ""
} |
q11475 | MessageBag.retrieve | train | public function retrieve()
{
$messages = null;
if (\is_null($this->instance)) {
$this->instance = new static();
$this->instance->setSessionStore($this->session);
if ($this->session->has('message')) {
$messages = \unserialize($this->session->pull('message'), ['allowed_classes' => false]);
}
if (\is_array($messages)) {
$this->instance->merge($messages);
}
}
return $this->instance;
} | php | {
"resource": ""
} |
q11476 | MessageBag.save | train | public function save(): void
{
$this->session->flash('message', $this->serialize());
$this->instance = null;
} | php | {
"resource": ""
} |
q11477 | Entity.addMethod | train | public function addMethod(string $methodName, callable $methodClosure): void
{
$this->methods[strtolower($methodName)] = $methodClosure->bindTo($this);
} | php | {
"resource": ""
} |
q11478 | FiltersExtension.passFilterManagerToListener | train | private function passFilterManagerToListener()
{
$enableFiltersSubscriberDefinition = $this->definitionFinder->getDefinitionByType(
EnableFiltersSubscriber::class
);
$filterManagerServiceName = $this->definitionFinder->getServiceNameByType(FilterManagerInterface::class);
$enableFiltersSubscriberDefinition->addSetup(
'setFilterManager',
['@' . $filterManagerServiceName]
);
} | php | {
"resource": ""
} |
q11479 | SecurityServicesPass.formLoginAuthenticator | train | private function formLoginAuthenticator(ContainerBuilder $container, $routes, $user)
{
$container->setDefinition(
'bengor.user_bundle.security.authenticator.form_login_' . $user . '_authenticator',
new Definition(
FormLoginAuthenticator::class, [
$container->getDefinition('router.default'),
$container->getDefinition('bengor_user.' . $user . '.command_bus'),
[
'login' => $routes[$user]['login']['name'],
'login_check' => $routes[$user]['login_check']['name'],
'success_redirection_route' => $routes[$user]['success_redirection_route'],
],
]
)
)->setPublic(false);
$container->setAlias(
'bengor_user.' . $user . '.form_login_authenticator',
'bengor.user_bundle.security.authenticator.form_login_' . $user . '_authenticator'
);
} | php | {
"resource": ""
} |
q11480 | SecurityServicesPass.userSymfonyDataTransformer | train | private function userSymfonyDataTransformer(ContainerBuilder $container, $user)
{
$container->setDefinition(
'bengor.user_bundle.security.' . $user . '_symfony_data_transformer',
new Definition(
UserSymfonyDataTransformer::class
)
)->setPublic(false);
$container->setAlias(
'bengor_user.' . $user . '.symfony_data_transformer',
'bengor.user_bundle.security.' . $user . '_symfony_data_transformer'
);
} | php | {
"resource": ""
} |
q11481 | SecurityServicesPass.userProvider | train | private function userProvider(ContainerBuilder $container, $user)
{
$container->setDefinition(
'bengor.user_bundle.security.' . $user . '_provider',
new Definition(
UserProvider::class, [
$container->getDefinition(
'bengor.user.application.query.' . $user . '_of_email'
),
$container->getDefinition(
'bengor.user_bundle.security.' . $user . '_symfony_data_transformer'
),
]
)
)->setPublic(false);
$container->setAlias(
'bengor_user.' . $user . '.provider',
'bengor.user_bundle.security.' . $user . '_provider'
);
} | php | {
"resource": ""
} |
q11482 | DateTimeCreator.getNowDateTime | train | public static function getNowDateTime()
{
if (PHP_VERSION_ID < 70100) {
$now = \DateTime::createFromFormat('U.u', \sprintf('%.6F', microtime(true)));
} else {
$now = new \DateTime(null);
}
return $now;
} | php | {
"resource": ""
} |
q11483 | PlayerStorage.getPlayerInfo | train | public function getPlayerInfo($login, $forceNew = false)
{
if (!isset($this->online[$login]) || $forceNew) {
// to make sure even if an exception happens, player has login and basic nickname
$playerInformation = new PlayerInfo();
$playerInformation->login = $login;
$playerDetails = new PlayerDetailedInfo();
$playerDetails->nickName = $login;
try {
//fetch additional informations
$playerInformation = $this->factory->getConnection()->getPlayerInfo($login);
$playerDetails = $this->factory->getConnection()->getDetailedPlayerInfo($login);
} catch (InvalidArgumentException $e) {
$this->logger->error("Login unknown: $login", ["exception" => $e]);
$this->console->writeln('$f00Login Unknown: '.$login.' dedicated server said: $fff'.$e->getMessage());
} catch (FaultException $ex) {
$this->logger->error("Login unknown: $login", ["exception" => $ex]);
$this->console->writeln('$f00Login Unknown: '.$login.' dedicated server said: $fff'.$ex->getMessage());
}
return $this->playerFactory->createPlayer($playerInformation, $playerDetails);
}
return $this->online[$login];
} | php | {
"resource": ""
} |
q11484 | PlayerStorage.onPlayerConnect | train | public function onPlayerConnect(Player $playerData)
{
$login = $playerData->getLogin();
$this->online[$login] = $playerData;
if ($playerData->isSpectator()) {
$this->spectators[$login] = $playerData;
} else {
$this->players[$login] = $playerData;
}
} | php | {
"resource": ""
} |
q11485 | PlayerStorage.onPlayerInfoChanged | train | public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
{
unset($this->players[$player->getLogin()]);
unset($this->spectators[$player->getLogin()]);
$this->onPlayerConnect($player);
} | php | {
"resource": ""
} |
q11486 | Installer.installFile | train | public function installFile($sSourcePath, $sInstallPath)
{
// If the temp file doesn't exist, we cannot install it
if(! file_exists($sSourcePath))
throw new NoSuchFileException($sSourcePath, 1);
try
{
// Create the install directory if needed
$sInstallDir = dirname($sInstallPath);
$this->installDir($sInstallDir);
}
catch(Exception $e)
{
throw new Exception("Cannot install file, no such directory no perms to create it: $sInstallPath", 11, $e);
}
// First move temp path up to a temporary filename on the install drive
$sTempInstallPath = $this->findTempSafeInstallPath($sInstallPath);
// @silence copy() PHP warnings, we check for failure and throw our own exception
$success = true;
$originalUmask = umask(0377); // set secure copy() permissions (read-only by current user, nobody else has ANY perms on it at all)
if(! @copy($sSourcePath, $sTempInstallPath))
$success = false;
umask($originalUmask); // reinstate original umask
if(! $success)
throw new Exception("Unable to copy file to temp install path: $sTempInstallPath", 17);
// Explicitly set the file owner and permissions of the newly copied file to be the same
// as the source path. PHP copy() seems to disregard the settings of the source file and
// instead use the current proc's umask() and user identity.
clearstatcache(); // We don't care what the cache says, we want to know the current stat info
$hSrcStat = stat($sSourcePath);
$sSrcOwner = $hSrcStat['uid'];
$sSrcGroup = $hSrcStat['gid'];
$sSrcMode = $hSrcStat['mode'];
$hDstStat = stat($sTempInstallPath);
$sDstOwner = $hDstStat['uid'];
$sDstGroup = $hDstStat['gid'];
$sDstMode = $hDstStat['mode'];
if($sSrcOwner !== $sDstOwner)
@chown($sTempInstallPath, $sSrcOwner);
if($sSrcGroup !== $sDstGroup)
@chgrp($sTempInstallPath, $sSrcGroup);
if($sSrcMode !== $sDstMode)
@chmod($sTempInstallPath, $sSrcMode);
// Now rename the temp path to the final location
// @silence rename() PHP warnings, we check for failure and throw our own exception
if(! @rename($sTempInstallPath, $sInstallPath))
throw new Exception("Unable to rename temp file to $sInstallPath", 21);
} | php | {
"resource": ""
} |
q11487 | Installer.findTempSafeInstallPath | train | public function findTempSafeInstallPath($sInstallPath)
{
try
{
$sTemp = $this->appendTempExtension($sInstallPath);
while(file_exists($sTemp))
{
$sTemp = $this->appendTempExtension($sTemp);
}
}
catch(Exception $e)
{
throw new Exception("No available temp file found for: $sInstallPath", 0, $e);
}
return $sTemp;
} | php | {
"resource": ""
} |
q11488 | StackCreateCommand.displayResume | train | protected function displayResume(OutputInterface $output)
{
$output->write("Creation of a new stack [<info>{$this->collectedData['name']}</info>]", true);
foreach ($this->collectedData['operations'] as $name => $operation) {
$output->write(" * Operation [<info>$name</info>] with ".json_encode($operation->options), true);
}
} | php | {
"resource": ""
} |
q11489 | JukeboxService.addMapFirst | train | public function addMapFirst(Map $map, $login = null, $force = false)
{
return $this->addMap($map, $login, $force, true);
} | php | {
"resource": ""
} |
q11490 | JukeboxService.addMapLast | train | public function addMapLast(Map $map, $login = null, $force = false)
{
return $this->addMap($map, $login, $force, false);
} | php | {
"resource": ""
} |
q11491 | JukeboxService.addMap | train | public function addMap(Map $map, $login = null, $force = false, $addFirst = false)
{
if (!$login) {
return false;
}
$player = $this->playerStorage->getPlayerInfo($login);
$jbMap = new JukeboxMap($map, $player);
if ($force) {
$this->add($jbMap, $addFirst);
return true;
}
// no some restrictions for admin
if ($this->adminGroups->hasPermission($login, "jukebox")) {
if ($this->checkMap($map) === false) {
$this->add($jbMap, $addFirst);
return true;
}
} else {
// restrict 1 map per 1 login
if ($this->checkLogin($login) === false && $this->checkMap($map) === false) {
$this->add($jbMap, $addFirst);
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q11492 | JukeboxService.checkLogin | train | private function checkLogin($login)
{
foreach ($this->mapQueue as $jukeboxMap) {
if ($jukeboxMap->getPlayer()->getLogin() == $login) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q11493 | WindowsPipes.removeFiles | train | private function removeFiles()
{
foreach ($this->files as $filename) {
if (file_exists($filename)) {
@unlink($filename);
}
}
$this->files = array();
} | php | {
"resource": ""
} |
q11494 | FilterHelper._getSchemaCache | train | protected function _getSchemaCache($model = null) {
if (empty($model) || !isset($this->_schemaCache[$model])) {
return null;
}
return $this->_schemaCache[$model];
} | php | {
"resource": ""
} |
q11495 | FilterHelper._setSchemaCache | train | protected function _setSchemaCache($model = null, $schema = null) {
if (empty($model)) {
return;
}
$this->_schemaCache[$model] = $schema;
} | php | {
"resource": ""
} |
q11496 | FilterHelper._getSchema | train | protected function _getSchema($model = null) {
$result = null;
if (empty($model)) {
return $result;
}
$modelObj = ClassRegistry::init($model, true);
if ($modelObj === false) {
return $result;
}
$result = $modelObj->schema();
if (empty($modelObj->virtualFields)) {
return $result;
}
foreach ($modelObj->virtualFields as $virtualFieldName => $virtualFieldVal) {
$result[$virtualFieldName] = ['type' => 'string'];
}
return $result;
} | php | {
"resource": ""
} |
q11497 | FilterHelper.openFilterForm | train | public function openFilterForm($usePost = false) {
$this->_setFlagUsePost($usePost);
$type = 'get';
$dataToggle = 'pjax-form';
if ($this->_getFlagUsePost()) {
$type = 'post';
$dataToggle = 'ajax-form';
} else {
$filterData = $this->getFilterData();
if (!empty($filterData)) {
$this->setFilterInputData($filterData);
}
$conditions = $this->getFilterConditions();
if (!empty($conditions)) {
$this->setFilterInputConditions($conditions);
}
}
$options = [
'data-toggle' => $dataToggle,
'type' => $type,
];
$optionsDefault = $this->_getOptionsForElem('openFilterForm');
$result = $this->ExtBs3Form->create(null, $options + $optionsDefault);
return $result;
} | php | {
"resource": ""
} |
q11498 | FilterHelper.closeFilterForm | train | public function closeFilterForm() {
$type = 'get';
if ($this->_getFlagUsePost()) {
$type = 'post';
}
$this->ExtBs3Form->requestType = $type;
$result = $this->ExtBs3Form->end();
return $result;
} | php | {
"resource": ""
} |
q11499 | FilterHelper._createPaginationTableRow | train | protected function _createPaginationTableRow($paginationFields = null) {
$result = '';
if (empty($paginationFields) || !is_array($paginationFields)) {
return $result;
}
$tableHeader = [];
$includeOptions = [
'class' => null,
'escape' => null,
];
foreach ($paginationFields as $paginationField => $paginationOptions) {
if (is_int($paginationField)) {
if (!is_string($paginationOptions)) {
continue;
}
$paginationField = $paginationOptions;
$paginationOptions = [];
}
if (strpos($paginationField, '.') === false) {
continue;
}
if (!is_array($paginationOptions)) {
$paginationOptions = [$paginationOptions];
}
$paginationFieldUse = $paginationField;
if (isset($paginationOptions['pagination-field']) && !empty($paginationOptions['pagination-field'])) {
$paginationFieldUse = $paginationOptions['pagination-field'];
}
$label = $paginationFieldUse;
if (isset($paginationOptions['label']) && !empty($paginationOptions['label'])) {
$label = $paginationOptions['label'];
}
$paginationSortLink = $label;
$paginationOptionsUse = array_intersect_key($paginationOptions, $includeOptions);
if (!isset($paginationOptions['disabled']) || !$paginationOptions['disabled']) {
$paginationSortLink = $this->ViewExtension->paginationSortPjax($paginationFieldUse, $label, $paginationOptionsUse);
}
if (isset($paginationOptions['class-header']) && !empty($paginationOptions['class-header'])) {
$paginationSortLink = [$paginationSortLink => ['class' => $paginationOptions['class-header']]];
}
$tableHeader[] = $paginationSortLink;
}
$tableHeader[] = [$this->_getOptionsForElem('paginTableRowHeaderActTitle') => ['class' => 'action hide-popup']];
$result = $this->Html->tableHeaders($tableHeader);
return $result;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.