_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11800 | Where.getNextOperator | train | private function getNextOperator(string $column): ?string
{
reset($this->fragments['where']);
while (key($this->fragments['where']) !== $column) {
next($this->fragments['where']);
}
next($this->fragments['where']);
$key = key($this->fragments['where']);
return $this->fragments['where'][$key]['operator'];
} | php | {
"resource": ""
} |
q11801 | RedirectToRouteTrait.redirectToRoute | train | public function redirectToRoute(Response $response, $route, array $data = [], array $queryParams = [], $suffix = '')
{
$url = $this->router->pathFor($route, $data, $queryParams) . $suffix;
return $response->withRedirect($url, 301);
} | php | {
"resource": ""
} |
q11802 | FactoryRegistry.getFactory | train | public function getFactory($name)
{
if (!isset($this->factories[$name])) {
throw new \RuntimeException(sprintf('No factory registered with name "%s"', $name));
}
return $this->factories[$name];
} | php | {
"resource": ""
} |
q11803 | Smarty_Internal_Write_File.writeFile | train | public static function writeFile($_filepath, $_contents, Smarty $smarty)
{
$_error_reporting = error_reporting();
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
if ($smarty->_file_perms !== null) {
$old_umask = umask(0);
}
$_dirpath = dirname($_filepath);
// if subdirs, create dir structure
if ($_dirpath !== '.' && !file_exists($_dirpath)) {
mkdir($_dirpath, $smarty->_dir_perms === null ? 0777 : $smarty->_dir_perms, true);
}
// write to tmp file, then move to overt file lock race condition
$_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true));
if (!file_put_contents($_tmp_file, $_contents)) {
error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_tmp_file}");
}
/*
* Windows' rename() fails if the destination exists,
* Linux' rename() properly handles the overwrite.
* Simply unlink()ing a file might cause other processes
* currently reading that file to fail, but linux' rename()
* seems to be smart enough to handle that for us.
*/
if (Smarty::$_IS_WINDOWS) {
// remove original file
@unlink($_filepath);
// rename tmp file
$success = @rename($_tmp_file, $_filepath);
} else {
// rename tmp file
$success = @rename($_tmp_file, $_filepath);
if (!$success) {
// remove original file
@unlink($_filepath);
// rename tmp file
$success = @rename($_tmp_file, $_filepath);
}
}
if (!$success) {
error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_filepath}");
}
if ($smarty->_file_perms !== null) {
// set file permissions
chmod($_filepath, $smarty->_file_perms);
umask($old_umask);
}
error_reporting($_error_reporting);
return true;
} | php | {
"resource": ""
} |
q11804 | DataGenerator.fake | train | public function fake(EntityInterface $entity, array $options = array())
{
if (!empty($options[self::OPTION_LOCALE])) {
$loc = $options[self::OPTION_LOCALE];
if (!is_string($loc) || !preg_match('#[a-z]{2,6}_[A-Z]{2,6}#', $loc)) {
throw new BadValueException(
'Given option "' . self::OPTION_LOCALE
. '" is not a valid string. Use "languageCode_countryCode", e.g. "de_DE" or "en_UK".'
);
}
$this->locale = $loc;
$this->faker = Factory::create($this->locale);
}
$attributes_to_exclude = array();
if (!empty($options[self::OPTION_EXCLUDED_FIELDS])) {
$excluded = $options[self::OPTION_EXCLUDED_FIELDS];
if (!is_array($excluded)) {
throw new BadValueException(
'Given option "' . self::OPTION_EXCLUDED_FIELDS
. '" is not an array. It should be an array of attribute_names.'
);
}
$attributes_to_exclude = $excluded;
}
$type = $entity->getType();
foreach ($type->getAttributes() as $attribute_name => $attribute) {
if (in_array($attribute_name, $attributes_to_exclude, true)) {
continue;
}
$name = $this->getMethodNameFor($attribute);
if (null !== $name) {
$this->$name($entity, $attribute, $options);
} else {
$this->setValue($entity, $attribute, $attribute->getDefaultValue(), $options);
}
}
if (array_key_exists(self::OPTION_MARK_CLEAN, $options)
&& true === $options[self::OPTION_MARK_CLEAN]
) {
$entity->markClean();
}
} | php | {
"resource": ""
} |
q11805 | DataGenerator.fakeData | train | public function fakeData(EntityTypeInterface $type, array $options = array())
{
$entity = $type->createEntity();
$this->fake($entity, $options);
return $entity->toArray();
} | php | {
"resource": ""
} |
q11806 | DataGenerator.createFakeEntity | train | public function createFakeEntity(
EntityTypeInterface $type,
array $options = array(),
EntityInterface $parent = null
) {
$options[self::OPTION_MARK_CLEAN] = true;
$entity = $type->createEntity([], $parent);
$this->fake($entity, $options);
return $entity;
} | php | {
"resource": ""
} |
q11807 | DataGenerator.addText | train | protected function addText(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$min_length = $attribute->getOption('min_length');
$max_length = $attribute->getOption('max_length');
if ($this->shouldGuessByName($options)) {
$value = TextGuesser::guess($attribute->getName(), $this->faker);
}
if (!isset($value)) {
$value = $this->faker->words($this->faker->numberBetween(2, 10), true);
}
if ($min_length && ($len = mb_strlen($value)) < $min_length) {
$repeat = ceil(($min_length - $len) / $len);
$value .= str_repeat($value, $repeat);
}
if ($max_length && mb_strlen($value) > $max_length) {
$value = substr($value, 0, $max_length);
$value = preg_replace('#\s$#', 'o', $value);
}
$this->setValue($entity, $attribute, $value, $options);
} | php | {
"resource": ""
} |
q11808 | DataGenerator.addTextList | train | protected function addTextList(
EntityInterface $entity,
AttributeInterface $attribute,
array $options = array()
) {
$values = array();
$number_of_values = $this->faker->numberBetween(1, 5);
for ($i = 0; $i < $number_of_values; $i++) {
$text = $this->faker->words($this->faker->numberBetween(1, 3), true);
if ($this->shouldGuessByName($options)) {
$closure = TextGuesser::guess($attribute->getName(), $this->faker);
if (!empty($closure) && is_callable($closure)) {
$text = call_user_func($closure);
}
}
$values[] = $text;
}
$this->setValue($entity, $attribute, $values, $options);
} | php | {
"resource": ""
} |
q11809 | DataGenerator.addTextarea | train | protected function addTextarea(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$text = $this->faker->paragraphs($this->faker->numberBetween(1, 5));
$this->setValue($entity, $attribute, implode(PHP_EOL . PHP_EOL, $text), $options);
} | php | {
"resource": ""
} |
q11810 | DataGenerator.addInteger | train | protected function addInteger(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$this->setValue($entity, $attribute, $this->faker->randomNumber(5), $options);
} | php | {
"resource": ""
} |
q11811 | DataGenerator.addIntegerList | train | protected function addIntegerList(
EntityInterface $entity,
AttributeInterface $attribute,
array $options = array()
) {
$values = array();
$number_of_values = $this->faker->numberBetween(1, 5);
for ($i = 0; $i < $number_of_values; $i++) {
$values[] = $this->faker->randomNumber(5);
}
$this->setValue($entity, $attribute, $values, $options);
} | php | {
"resource": ""
} |
q11812 | DataGenerator.addFloat | train | protected function addFloat(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$this->setValue($entity, $attribute, $this->faker->randomFloat(5), $options);
} | php | {
"resource": ""
} |
q11813 | DataGenerator.addUrl | train | protected function addUrl(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$this->setValue($entity, $attribute, $this->faker->url(), $options);
} | php | {
"resource": ""
} |
q11814 | DataGenerator.addUuid | train | protected function addUuid(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$this->setValue($entity, $attribute, $this->faker->uuid(), $options);
} | php | {
"resource": ""
} |
q11815 | DataGenerator.addChoice | train | protected function addChoice(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$allowed_values = $attribute->getOption('allowed_values');
$choice = $allowed_values[array_rand($allowed_values)];
$this->setValue($entity, $attribute, $choice, $options);
} | php | {
"resource": ""
} |
q11816 | DataGenerator.addKeyValue | train | protected function addKeyValue(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$values = array();
$number_of_values = $this->faker->numberBetween(1, 5);
for ($i = 0; $i < $number_of_values; $i++) {
$values[$this->faker->word] = $this->faker->sentence;
}
$this->setValue($entity, $attribute, $values, $options);
} | php | {
"resource": ""
} |
q11817 | DataGenerator.addKeyValueList | train | protected function addKeyValueList(
EntityInterface $entity,
AttributeInterface $attribute,
array $options = array()
) {
$collection = array();
$numberOfEntries = $this->faker->numberBetween(1, 5);
for ($i = 0; $i < $numberOfEntries; $i++) {
$number_of_values = $this->faker->numberBetween(1, 5);
for ($i = 0; $i < $number_of_values; $i++) {
$collection[$this->faker->word] = $this->faker->words($this->faker->numberBetween(1, 3), true);
}
}
$this->setValue($entity, $attribute, $collection, $options);
} | php | {
"resource": ""
} |
q11818 | DataGenerator.createComplexValue | train | protected function createComplexValue(AttributeInterface $attribute, array $options = array())
{
$values = array();
$value_holder = $attribute->createValueHolder();
$value_type = $value_holder->getValueType();
if (class_exists($value_type)
&& preg_grep('#ComplexValueInterface$#', class_implements($value_type))
) {
foreach ($value_type::getPropertyMap() as $property_name => $property_type) {
switch ($property_type) {
case ComplexValue::VALUE_TYPE_TEXT:
if ($this->shouldGuessByName($options)) {
$values[$property_name] = TextGuesser::guess($property_name, $this->faker);
}
if (empty($values[$property_name])) {
$values[$property_name] = $this->faker->words(3, true);
}
break;
case ComplexValue::VALUE_TYPE_URL:
$values[$property_name] = $this->faker->url;
break;
case ComplexValue::VALUE_TYPE_BOOLEAN:
$values[$property_name] = $this->faker->boolean();
break;
case ComplexValue::VALUE_TYPE_INTEGER:
$values[$property_name] = $this->faker->numberBetween(0, 10);
break;
case ComplexValue::VALUE_TYPE_FLOAT:
$values[$property_name] = $this->faker->randomFloat(5);
break;
case ComplexValue::VALUE_TYPE_ARRAY:
$numberOfEntries = $this->faker->numberBetween(0, 3);
for ($i = 0; $i < $numberOfEntries; $i++) {
$values[$property_name][$this->faker->word] = $this->faker->word;
}
break;
default:
throw new BadValueException(sprintf(
'Unexpected ComplexValue property type "%s" on %s',
$property_type,
$value_type
));
}
}
}
return new $value_type($values);
} | php | {
"resource": ""
} |
q11819 | DataGenerator.addImage | train | protected function addImage(
EntityInterface $entity,
AttributeInterface $attribute,
array $options = array()
) {
$image = $this->createComplexValue($attribute, $options);
$this->setValue($entity, $attribute, $image, $options);
} | php | {
"resource": ""
} |
q11820 | DataGenerator.addImageList | train | protected function addImageList(
EntityInterface $entity,
AttributeInterface $attribute,
array $options = array()
) {
$collection = array();
$min_count = $attribute->getOption('min_count', 0);
$max_count = $attribute->getOption('max_count', 3);
$numberOfEntries = $this->faker->numberBetween($min_count, $max_count);
$image_attribute = new ImageAttribute('someimage', $entity->getType());
// @todo should we have an ImageList collection?
for ($i = 0; $i < $numberOfEntries; $i++) {
$collection[] = $this->createComplexValue($image_attribute, $options);
}
$this->setValue($entity, $attribute, $collection, $options);
} | php | {
"resource": ""
} |
q11821 | DataGenerator.addBoolean | train | protected function addBoolean(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$this->setValue($entity, $attribute, $this->faker->boolean, $options);
} | php | {
"resource": ""
} |
q11822 | DataGenerator.addEmbeddedEntityList | train | protected function addEmbeddedEntityList(
EntityInterface $entity,
EmbeddedEntityListAttribute $attribute,
array $options = array()
) {
$options_clone = $options;
$entity_collection = new EntityList();
$embedded_type_map = $attribute->getEmbeddedEntityTypeMap();
$min_count = $attribute->getOption('min_count', 0);
$max_count = $attribute->getOption('max_count', 3);
$inline_mode = $attribute->getOption('inline_mode', false);
if (true === $inline_mode) {
$number_of_new_embed_entries = 1;
} else {
$number_of_new_embed_entries = $this->faker->numberBetween($min_count, $max_count);
}
// add new entities to collection for embed types
for ($i = 0; $i < $number_of_new_embed_entries; $i++) {
$embed_type = $this->faker->randomElement($embedded_type_map->getValues());
$new_entity = $this->createFakeEntity($embed_type, $options_clone, $entity);
$entity_collection->addItem($new_entity);
}
$this->setValue($entity, $attribute, $entity_collection, $options);
} | php | {
"resource": ""
} |
q11823 | DataGenerator.addTimestamp | train | protected function addTimestamp(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$default_value = $attribute->getDefaultValue();
$this->setValue($entity, $attribute, $default_value ?: $this->faker->iso8601, $options);
} | php | {
"resource": ""
} |
q11824 | DataGenerator.addGeoPoint | train | protected function addGeoPoint(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$geopoint = [
'lon' => $this->faker->longitude,
'lat' => $this->faker->latitude
];
$this->setValue($entity, $attribute, $geopoint, $options);
} | php | {
"resource": ""
} |
q11825 | DataGenerator.addToken | train | protected function addToken(EntityInterface $entity, AttributeInterface $attribute, array $options = array())
{
$min_length = $attribute->getOption('min_length', 1);
$max_length = $attribute->getOption('max_length', 40);
$size = $this->faker->numberBetween($min_length, $max_length);
$token = bin2hex(mcrypt_create_iv(ceil($size/2), MCRYPT_DEV_URANDOM));
$truncated_token = substr($token, 0, $size);
$this->setValue($entity, $attribute, $truncated_token, $options);
} | php | {
"resource": ""
} |
q11826 | DataGenerator.setValue | train | protected function setValue(
EntityInterface $entity,
AttributeInterface $attribute,
$default_value,
array $options = array()
) {
$attribute_name = $attribute->getName();
$attribute_options = array();
if (!empty($options[self::OPTION_FIELD_VALUES])
&& is_array($options[self::OPTION_FIELD_VALUES])
) {
$attribute_options = $options[self::OPTION_FIELD_VALUES];
}
if (empty($attribute_options[$attribute_name])) {
$entity->setValue($attribute_name, $default_value);
} else {
$option = $attribute_options[$attribute_name];
if (is_callable($option)) {
$entity->setValue($attribute_name, call_user_func($option));
} else {
$entity->setValue($attribute_name, $option);
}
}
} | php | {
"resource": ""
} |
q11827 | DataGenerator.shouldGuessByName | train | protected function shouldGuessByName(array $options = array())
{
if (array_key_exists(self::OPTION_GUESS_PROVIDER_BY_NAME, $options)
&& false === $options[self::OPTION_GUESS_PROVIDER_BY_NAME]
) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q11828 | GamecurrencyTableMap.doDelete | train | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(GamecurrencyTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Framework\GameCurrencyBundle\Model\Gamecurrency) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(GamecurrencyTableMap::DATABASE_NAME);
$criteria->add(GamecurrencyTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = GamecurrencyQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
GamecurrencyTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
GamecurrencyTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | {
"resource": ""
} |
q11829 | Client.setErrorCallback | train | protected function setErrorCallback(ConnectionInterface $connection, callable $callback)
{
$connection->setErrorCallback(function ($connection, $exception) use ($callback) {
\call_user_func($callback, $this, $exception, $connection);
});
} | php | {
"resource": ""
} |
q11830 | Client.wrapCallback | train | protected function wrapCallback(callable $callback)
{
return function ($response, $connection, $command) use ($callback) {
if ($command && !$response instanceof ResponseInterface) {
$response = $command->parseResponse($response);
}
\call_user_func($callback, $response, $this, $command);
};
} | php | {
"resource": ""
} |
q11831 | UploadComponent._setStorageTimeUpload | train | protected function _setStorageTimeUpload($time = null) {
$time = (int)$time;
if ($time > 0) {
$this->_storageTimeUpload = $time;
}
} | php | {
"resource": ""
} |
q11832 | UploadComponent._setUploadDir | train | protected function _setUploadDir($path = null) {
$path = (string)$path;
if (file_exists($path)) {
$this->_pathUploadDir = $path;
}
} | php | {
"resource": ""
} |
q11833 | UploadComponent._clearDir | train | protected function _clearDir($timeNow = null) {
$clearPath = $this->getUploadDir();
$storageTime = $this->_getStorageTimeUpload();
$result = true;
$oFolder = new Folder($clearPath, true);
$uploadedFiles = $oFolder->find('.*', false);
if (empty($uploadedFiles)) {
return $result;
}
if (!empty($timeNow)) {
$timeNow = (int)$timeNow;
} else {
$timeNow = time();
}
$uploadedFilesPath = $oFolder->pwd();
foreach ($uploadedFiles as $uploadedFile) {
$oFile = new File($uploadedFilesPath . DS . $uploadedFile);
$lastChangeTime = $oFile->lastChange();
if ($lastChangeTime === false) {
continue;
}
if (($timeNow - $lastChangeTime) > $storageTime) {
if (!$oFile->delete()) {
$result = false;
}
}
}
return true;
} | php | {
"resource": ""
} |
q11834 | UploadComponent.upload | train | public function upload($maxFileSize = null, $acceptFileTypes = null) {
Configure::write('debug', 0);
if (!$this->_controller->request->is('ajax') || !$this->_controller->RequestHandler->prefers('json')) {
throw new BadRequestException(__d('view_extension', 'Invalid request'));
}
$uploadDir = $this->getUploadDir();
if (empty($acceptFileTypes)) {
$acceptFileTypes = '/.+$/i';
}
$opt = [
'script_url' => '',
'upload_url' => '',
'param_name' => 'files',
'upload_dir' => $uploadDir,
'max_file_size' => $maxFileSize,
'image_versions' => [
'' => ['auto_orient' => false]
],
'correct_image_extensions' => false,
'accept_file_types' => $acceptFileTypes
];
$uploadHandler = new UploadHandler($opt, false);
switch ($this->_controller->request->method()) {
case 'OPTIONS':
case 'HEAD':
$data = $uploadHandler->head(false);
break;
case 'GET':
$data = $uploadHandler->get(false);
break;
case 'PATCH':
case 'PUT':
case 'POST':
$data = $uploadHandler->post(false);
break;
default:
throw new MethodNotAllowedException();
}
return $data;
} | php | {
"resource": ""
} |
q11835 | ImageDownloadCommand.saveImageContents | train | private function saveImageContents(Image $client, SourceImage $image, $saveTo, OutputInterface $output, $stackName = null, $format = 'jpg')
{
if (!$stackName) {
$output->writeln('Getting source image contents for <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment>');
} else {
$output->writeln('Rendering image <info>'.$image->hash.'</info> from <comment>'.$image->organization.'</comment> on stack <info>'.$stackName.'</info>');
}
$contents = $this->rokkaHelper->getSourceImageContents($client, $image->hash, $image->organization, $stackName, $format);
if (!$contents) {
$output->writeln($this->formatterHelper->formatBlock([
'Error!',
'Error getting image contents from Rokka.io!',
], 'error', true));
return false;
}
// TODO: verify if target file exists, ask for permission to overwrite unless --force
$ret = file_put_contents($saveTo, $contents, FILE_BINARY);
if (false == $ret) {
$output->writeln($this->formatterHelper->formatBlock([
'Error!',
'Error writing image contents to <info>'.$saveTo.'</info>!',
], 'error', true));
return false;
}
$output->writeln('Image saved to <info>'.$saveTo.'</info>');
return true;
} | php | {
"resource": ""
} |
q11836 | RecordQuery.filterByNbfinish | train | public function filterByNbfinish($nbfinish = null, $comparison = null)
{
if (is_array($nbfinish)) {
$useMinMax = false;
if (isset($nbfinish['min'])) {
$this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($nbfinish['max'])) {
$this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish, $comparison);
} | php | {
"resource": ""
} |
q11837 | RecordQuery.filterByAvgscore | train | public function filterByAvgscore($avgscore = null, $comparison = null)
{
if (is_array($avgscore)) {
$useMinMax = false;
if (isset($avgscore['min'])) {
$this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($avgscore['max'])) {
$this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore, $comparison);
} | php | {
"resource": ""
} |
q11838 | RecordQuery.filterByCheckpoints | train | public function filterByCheckpoints($checkpoints = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($checkpoints)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RecordTableMap::COL_CHECKPOINTS, $checkpoints, $comparison);
} | php | {
"resource": ""
} |
q11839 | RecordQuery.filterByPlayerId | train | public function filterByPlayerId($playerId = null, $comparison = null)
{
if (is_array($playerId)) {
$useMinMax = false;
if (isset($playerId['min'])) {
$this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($playerId['max'])) {
$this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId, $comparison);
} | php | {
"resource": ""
} |
q11840 | RecordQuery.filterByPlayer | train | public function filterByPlayer($player, $comparison = null)
{
if ($player instanceof \eXpansion\Framework\PlayersBundle\Model\Player) {
return $this
->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $player->getId(), $comparison);
} elseif ($player instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $player->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByPlayer() only accepts arguments of type \eXpansion\Framework\PlayersBundle\Model\Player or Collection');
}
} | php | {
"resource": ""
} |
q11841 | RecordQuery.usePlayerQuery | train | public function usePlayerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinPlayer($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Player', '\eXpansion\Framework\PlayersBundle\Model\PlayerQuery');
} | php | {
"resource": ""
} |
q11842 | ScriptVariableUpdateFactory.updateValue | train | public function updateValue($group, $variableCode, $newValue)
{
$variable = clone $this->getVariable($variableCode);
$variable->setValue($newValue);
if (!isset($this->queuedForUpdate[$group->getName()])) {
$this->queuedForUpdate[$group->getName()]['time'] = microtime(true);
}
$checkVariable = clone $this->checkVariable;
$uniqueId = uniqid('exp_', true);
$checkVariable->setValue("\"$uniqueId\"");
$this->checkWindow->setValue(Builder::escapeText(get_called_class()));
$this->queuedForUpdate[$group->getName()]['group'] = $group;
$this->queuedForUpdate[$group->getName()]['variables'][$variableCode] = $variable;
$this->queuedForUpdate[$group->getName()]['check'] = $checkVariable;
} | php | {
"resource": ""
} |
q11843 | ScriptVariableUpdateFactory.getScriptInitialization | train | public function getScriptInitialization($defaultValues = false)
{
$scriptContent = '';
foreach ($this->variables as $variable) {
$scriptContent .= $variable->getScriptDeclaration()."\n";
if ($defaultValues) {
$scriptContent .= $variable->getScriptValueSet()."\n";
}
}
$scriptContent .= $this->checkVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkOldVariable->getScriptDeclaration()."\n";
$scriptContent .= $this->checkWindow->getScriptDeclaration()."\n";
$scriptContent .= "declare check_original = ".$this->checkWindow->getInitialValue().";\n";
if ($defaultValues) {
$scriptContent .= $this->checkVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkOldVariable->getScriptValueSet()."\n";
$scriptContent .= $this->checkWindow->getScriptValueSet()."\n";
}
return $scriptContent;
} | php | {
"resource": ""
} |
q11844 | Listeners.register | train | public function register(ListenerInterface $listener, EventEmitter $target = null)
{
$EElisteners = array();
if (null !== $target) {
$EElisteners = $this->forwardEvents($listener, $target, $listener->forwardedEvents());
}
$this->storage->attach($listener, $EElisteners);
return $this;
} | php | {
"resource": ""
} |
q11845 | Listeners.unregister | train | public function unregister(ListenerInterface $listener)
{
if (!isset($this->storage[$listener])) {
throw new InvalidArgumentException('Listener is not registered.');
}
foreach ($this->storage[$listener] as $event => $EElistener) {
$listener->removeListener($event, $EElistener);
}
$this->storage->detach($listener);
return $this;
} | php | {
"resource": ""
} |
q11846 | ThemeComponent._setLayout | train | protected function _setLayout(Controller &$controller) {
if ($controller->name == 'CakeError') {
$controller->layout = 'CakeTheme.error';
return;
}
$isAjax = $controller->request->is('ajax');
$isPjax = $controller->request->is('pjax');
$isHtml = $this->_controller->ViewExtension->isHtml();
if ($isPjax) {
$controller->layout = 'CakeTheme.pjax';
} elseif ($isHtml && !$isAjax) {
if ($controller->request->param('controller') === 'users') {
$controller->layout = 'CakeTheme.login';
} else {
if ($controller->layout === 'default') {
$controller->layout = 'CakeTheme.main';
}
}
}
} | php | {
"resource": ""
} |
q11847 | ThemeComponent._setConfigVar | train | protected function _setConfigVar(Controller &$controller) {
$additionalCssFiles = $this->_modelConfigTheme->getListCssFiles();
$additionalJsFiles = $this->_modelConfigTheme->getListJsFiles();
$controller->set(compact('additionalCssFiles', 'additionalJsFiles'));
} | php | {
"resource": ""
} |
q11848 | PlayerQuery.filterByLogin | train | public function filterByLogin($login = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($login)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LOGIN, $login, $comparison);
} | php | {
"resource": ""
} |
q11849 | PlayerQuery.filterByNickname | train | public function filterByNickname($nickname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nickname)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME, $nickname, $comparison);
} | php | {
"resource": ""
} |
q11850 | PlayerQuery.filterByNicknameStripped | train | public function filterByNicknameStripped($nicknameStripped = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($nicknameStripped)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_NICKNAME_STRIPPED, $nicknameStripped, $comparison);
} | php | {
"resource": ""
} |
q11851 | PlayerQuery.filterByPath | train | public function filterByPath($path = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($path)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_PATH, $path, $comparison);
} | php | {
"resource": ""
} |
q11852 | PlayerQuery.filterByWins | train | public function filterByWins($wins = null, $comparison = null)
{
if (is_array($wins)) {
$useMinMax = false;
if (isset($wins['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($wins['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_WINS, $wins['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_WINS, $wins, $comparison);
} | php | {
"resource": ""
} |
q11853 | PlayerQuery.filterByOnlineTime | train | public function filterByOnlineTime($onlineTime = null, $comparison = null)
{
if (is_array($onlineTime)) {
$useMinMax = false;
if (isset($onlineTime['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($onlineTime['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_ONLINE_TIME, $onlineTime, $comparison);
} | php | {
"resource": ""
} |
q11854 | PlayerQuery.filterByLastOnline | train | public function filterByLastOnline($lastOnline = null, $comparison = null)
{
if (is_array($lastOnline)) {
$useMinMax = false;
if (isset($lastOnline['min'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastOnline['max'])) {
$this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(PlayerTableMap::COL_LAST_ONLINE, $lastOnline, $comparison);
} | php | {
"resource": ""
} |
q11855 | PlayerQuery.filterByRecord | train | public function filterByRecord($record, $comparison = null)
{
if ($record instanceof \eXpansion\Bundle\LocalRecords\Model\Record) {
return $this
->addUsingAlias(PlayerTableMap::COL_ID, $record->getPlayerId(), $comparison);
} elseif ($record instanceof ObjectCollection) {
return $this
->useRecordQuery()
->filterByPrimaryKeys($record->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByRecord() only accepts arguments of type \eXpansion\Bundle\LocalRecords\Model\Record or Collection');
}
} | php | {
"resource": ""
} |
q11856 | PlayerQuery.useRecordQuery | train | public function useRecordQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRecord($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Record', '\eXpansion\Bundle\LocalRecords\Model\RecordQuery');
} | php | {
"resource": ""
} |
q11857 | View.draw | train | public function draw()
{
$file = Application::current()->getDirectory();
$file .= "views/{$this->templateName}.";
$file .= self::$extension;
if (!file_exists($file)) {
throw new Exception("Template file not found: $file");
}
return $this->templateEngine->draw(
$file, $this->data
);
} | php | {
"resource": ""
} |
q11858 | WebaccessUrl._bad | train | public function _bad($errstr, $isbad = true)
{
global $_web_access_retry_timeout;
$this->console->writeln($this->_webaccess_str.'$f00'.$errstr);
if ($this->_socket) {
@fclose($this->_socket);
}
$this->_socket = null;
if ($isbad) {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'BAD';
}
$this->_state = 'BAD';
$this->_bad_time = time();
if ($this->_bad_timeout < $_web_access_retry_timeout) {
$this->_bad_timeout = $_web_access_retry_timeout;
} else {
$this->_bad_timeout *= 2;
}
} else {
if (isset($this->_spool[0]['State'])) {
$this->_spool[0]['State'] = 'OPEN';
}
$this->_state = 'CLOSED';
}
$this->_callCallback($this->_webaccess_str.$errstr);
} | php | {
"resource": ""
} |
q11859 | PdoConnection.rawQuery | train | public function rawQuery(string $sql, array $params=[]): array
{
$rows = [];
# Sanity check
if (empty($sql)) {
return $rows;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
}
# Close the cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $rows;
} | php | {
"resource": ""
} |
q11860 | PdoConnection.rawExec | train | public function rawExec(string $sql, array $params=[]): bool
{
$result = false;
# Sanity check
if (empty($sql)) {
return $result;
}
# Obtain transaction, unelss already in a transaction
$autoCommit = $this->beginTransaction();
# Prepare
if ($sth = $this->prepare($sql)) {
# Binds
foreach ($params as $bind=>$value) {
$sth->bindValue( ':'.\ltrim($bind,':'), $value);
}
# Execute statement
if ($sth->execute()) {
$result = $sth->rowCount() > 0;
}
# Close cursor
$sth->closeCursor();
}
# If we had a loacl transaction, commit it
if ($autoCommit) $this->commit();
return $result;
} | php | {
"resource": ""
} |
q11861 | EventHandlerLocator.get | train | public function get($eventType)
{
$handlers = array_merge_recursive(
array_key_exists($eventType, $this->handlers) ? $this->handlers[$eventType] : [],
array_key_exists('*', $this->handlers) ? $this->handlers['*'] : []
);
krsort($handlers, SORT_NUMERIC);
$eventHandlers = [];
foreach ($handlers as $priority => $handlersByPriority) {
foreach ($handlersByPriority as $handler) {
if ($this->resolver) {
$handler = call_user_func($this->resolver, $handler, $eventType);
}
$eventHandlers[] = $handler;
}
}
return $eventHandlers;
} | php | {
"resource": ""
} |
q11862 | Analytics.handshake | train | protected function handshake()
{
$key = &$this->key;
$lastPing = &$this->lastPing;
$that = $this;
$logger = $this->logger;
$query = http_build_query(
['login' => $this->gameData->getSystemInfo()->serverLogin]
);
$url = $this->handshakeUrl . '?' . $query;
$lastPing = time();
$this->logger->debug("[eXpansion analytics]Starting handshake");
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$key, &$lastPing, $logger, $that) {
$key = null;
if ($result->getHttpCode() != '200') {
$logger->debug('[eXpansion analytics]Handshake failed', ['http_code' => $result->getHttpCode()]);
return;
}
$json = json_decode($result->getResponse());
if (isset($json->key) && !empty($json->key)) {
$logger->debug('[eXpansion analytics]Handshake successfull', ['key' => $json->key]);
$key = $json->key;
$that->ping();
// allow ping just after handshake.
$lastPing = 0;
}
}
);
} | php | {
"resource": ""
} |
q11863 | Analytics.ping | train | public function ping()
{
if (!$this->key || $this->operationInProgress || (time() - $this->lastPing) < $this->pingInterval) {
// Attempt a new handshake.
if (is_null($this->key) && (time() - $this->lastPing) > $this->retryInterval) {
$this->lastPing = time();
$this->handshake();
}
return;
}
$data = $this->getBasePingData();
$query = http_build_query(
$data
);
$url = $this->pingUrl . '?' . $query;
$this->operationInProgress = true;
$this->lastPing = time();
$operationInProgress = &$this->operationInProgress;
$key = &$this->key;
$logger = $this->logger;
$logger->debug('[eXpansion analytics]Starting ping');
$this->http->put(
$url,
[],
function (HttpResult $result) use (&$operationInProgress, &$key, $logger) {
if ($result->getHttpCode() == '200') {
$operationInProgress = false;
$logger->debug('[eXpansion analytics]Ping successfull');
} else {
$logger->debug('[eXpansion analytics]Ping failed', ['http_code' => $result->getHttpCode(), 'result' => $result->getResponse()]);
$key = null;
}
}
);
} | php | {
"resource": ""
} |
q11864 | Analytics.getBasePingData | train | protected function getBasePingData()
{
return [
'key' => $this->key,
'nbPlayers' => count($this->playerStorage->getOnline()),
'country' => $this->countries->getIsoAlpha2FromName($this->countries->parseCountryFromPath($this->gameData->getServerPath())),
'version' => Application::EXPANSION_VERSION,
'php_version' => $this->gameData->getServerCleanPhpVersion(),
'php_version_short' => $this->gameData->getServerMajorPhpVersion(),
'mysql_version' => 'unknown',
'memory' => memory_get_usage(),
'memory_peak' => memory_get_peak_usage(),
'title' => str_replace('@','_by_', $this->gameData->getVersion()->titleId),
'game' => $this->gameData->getTitleGame(),
'mode' => strtolower($this->gameData->getGameInfos()->scriptName),
'serverOs' => $this->gameData->getServerOs(),
];
} | php | {
"resource": ""
} |
q11865 | Datalist.render | train | public function render(array $data, array $attrs = array())
{
$output = array();
$attrs = array_merge(array('class' => 'uk-description-list-horizontal'), $attrs);
$attrs = $this->_mergeAttr($attrs, $this->_jbSrt('data-list'));
$output[] = '<dl ' . $this->buildAttrs($attrs) . '>';
foreach ($data as $label => $text) {
$label = $this->_translate($label);
$output[] = '<dt title="' . $this->_cleanValue($label) . '">' . $label . '</dt>';
$output[] = '<dd>' . $text . '</dd>';
}
$output[] = '</dl>';
return implode('', $output);
} | php | {
"resource": ""
} |
q11866 | NotificationUpdater.getTranslations | train | private function getTranslations($string, $params)
{
$out = [];
$messages = $this->translationsHelper->getTranslations($string, $params);
foreach ($messages as $message) {
$out[$message['Lang']] = $message['Text'];
}
return $out;
} | php | {
"resource": ""
} |
q11867 | ThrowableProxy.toThrowable | train | public function toThrowable()
{
$class = $this->class;
$prev = $this->prev !== null ? $this->prev->toThrowable() : $this->prev;
return new $class($this->message, 0, $prev);
} | php | {
"resource": ""
} |
q11868 | ParovacFaktur.setStartDay | train | public function setStartDay($daysBack)
{
if (!is_null($daysBack)) {
$this->addStatusMessage('Start Date '.date('Y-m-d',
mktime(0, 0, 0, date("m"), date("d") - $daysBack, date("Y"))));
}
$this->daysBack = $daysBack;
} | php | {
"resource": ""
} |
q11869 | ParovacFaktur.getInvoicer | train | public function getInvoicer()
{
if (!is_object($this->invoicer)) {
$this->invoicer = new \FlexiPeeHP\FakturaVydana(null, $this->config);
}
return $this->invoicer;
} | php | {
"resource": ""
} |
q11870 | ParovacFaktur.getPaymentsToProcess | train | public function getPaymentsToProcess($daysBack = 1, $direction = 'in')
{
$result = [];
$this->banker->defaultUrlParams['order'] = 'datVyst@A';
$payments = $this->banker->getColumnsFromFlexibee([
'id',
'kod',
'varSym',
'specSym',
'sumCelkem',
'buc',
'smerKod',
'mena',
'datVyst'],
["sparovano eq false AND typPohybuK eq '".(($direction == 'out') ? 'typPohybu.vydej'
: 'typPohybu.prijem' )."' AND storno eq false ".
(is_null($daysBack) ? '' :
"AND datVyst eq '".\FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate(mktime(0,
0, 0, date("m"), date("d") - $daysBack, date("Y")))."' ")
], 'id');
if ($this->banker->lastResponseCode == 200) {
if (empty($payments)) {
$result = [];
} else {
$result = $payments;
}
}
return $result;
} | php | {
"resource": ""
} |
q11871 | ParovacFaktur.getCompanyForBUC | train | public function getCompanyForBUC($account, $bankCode = null)
{
$bucer = new \FlexiPeeHP\FlexiBeeRW(null,
['evidence' => 'adresar-bankovni-ucet']);
$companyRaw = $bucer->getColumnsFromFlexibee(['firma'],
empty($bankCode) ? ['buc' => $account] : ['buc' => $account, 'smerKod' => $bankCode]);
return array_key_exists(0, $companyRaw) ? $companyRaw[0]['firma'] : null;
} | php | {
"resource": ""
} |
q11872 | ParovacFaktur.reorderInvoicesByAge | train | public static function reorderInvoicesByAge($invoices)
{
$invoicesByAge = [];
$invoicesByAgeRaw = [];
foreach ($invoices as $invoiceData) {
$invoicesByAgeRaw[\FlexiPeeHP\FlexiBeeRW::flexiDateToDateTime($invoiceData['datVyst'])->getTimestamp()]
= $invoiceData;
}
ksort($invoicesByAgeRaw);
foreach ($invoicesByAgeRaw as $invoiceData) {
$invoicesByAge[$invoiceData['kod']] = $invoiceData;
}
return $invoicesByAge;
} | php | {
"resource": ""
} |
q11873 | ParovacFaktur.getOriginDocumentType | train | public function getOriginDocumentType($typDokl)
{
if (empty($this->docTypes)) {
$this->docTypes = $this->getDocumentTypes();
}
$documentType = \FlexiPeeHP\FlexiBeeRO::uncode($typDokl);
return array_key_exists($documentType, $this->docTypes) ? $this->docTypes[$documentType]
: 'typDokladu.neznamy';
} | php | {
"resource": ""
} |
q11874 | MultipartFormDataParser.getFiles | train | public function getFiles() : array
{
$files = [];
if (!empty($_FILES)) {
foreach ($_FILES as $inputName => $phpFile) {
if (!is_array($phpFile['name'])) {
// When this was a single file
$files[$inputName] = $this->handleUniqueFile($phpFile);
} else {
//When the input has a 'multiple' attribute
$files[$inputName] = $this->handleMultipleFile($phpFile);
}
}
}
return $files;
} | php | {
"resource": ""
} |
q11875 | MultipartFormDataParser.handleUniqueFile | train | protected function handleUniqueFile($file)
{
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file['error']) {
$uploadedFile = new UploadedFile(
$file['tmp_name'],
$file['name'],
$file['type']
);
}
return $uploadedFile;
} | php | {
"resource": ""
} |
q11876 | MultipartFormDataParser.handleMultipleFile | train | protected function handleMultipleFile($file) : array
{
$fileBag = [];
foreach ($file['name'] as $idx => $name) {
$uploadedFile = null;
//The current file was uploaded successfully?
if (!$file[$idx]['error']) {
$uploadedFile = new UploadedFile(
$file[$idx]['tmp_name'],
$file[$idx]['name'],
$file[$idx]['type']
);
}
$fileBag[$idx] = $uploadedFile;
}
return $fileBag;
} | php | {
"resource": ""
} |
q11877 | GridViewWidget.setupDefaultConfigs | train | private function setupDefaultConfigs()
{
$this->setLayout();
$this->setSummary();
if (!$this->isEmpty()) {
$this->setActionBar();
}
$this->showOnEmpty = false;
} | php | {
"resource": ""
} |
q11878 | GridViewWidget.setLayout | train | private function setLayout()
{
$this->layout = Html::tag('div', "{items}", ['class' => 'table-responsive']) .
Html::tag(
'div',
Html::tag('div', "{summary}", ['class' => 'pagination-summary']) .
Html::tag('div', "{pager}", ['class' => 'pagination-wrap']),
['class' => 'pagination-box']
);
} | php | {
"resource": ""
} |
q11879 | GridViewWidget.setActionBar | train | public function setActionBar()
{
if (is_null($this->actionButtonLabel) && is_null($this->actionButtonModalId)) {
return;
}
$this->getView()->params['content-header-button'] = [
'label' => $this->actionButtonLabel,
'options' => [
'data-toggle' => 'modal',
'data-target' => $this->actionButtonModalId,
'href' => $this->actionButtonModalHref ?: '#'
]
];
} | php | {
"resource": ""
} |
q11880 | SummaryForm.getPaymentErrorMessage | train | public function getPaymentErrorMessage()
{
/** @var Payment $lastPayment */
// Get the last payment
if (!$lastPayment = $this->reservation->Payments()->first()) {
return false;
}
// Find the gateway error
$lastErrorMessage = null;
$errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
foreach ($errorMessages as $errorMessage) {
if ($errorMessage instanceof GatewayErrorMessage) {
$lastErrorMessage = $errorMessage;
break;
}
}
// If no error is found return
if (!$lastErrorMessage) {
return false;
}
return _t("{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}", $lastErrorMessage->Message);
} | php | {
"resource": ""
} |
q11881 | AbstractVotePlugin.start | train | public function start(Player $player, $params)
{
$this->currentVote = new Vote($player, $this->getCode(), $params);
return $this->currentVote;
} | php | {
"resource": ""
} |
q11882 | AbstractVotePlugin.castYes | train | public function castYes($login)
{
if ($this->currentVote) {
$this->currentVote->castYes($login);
$player = $this->playerStorage->getPlayerInfo($login);
$this->dispatcher->dispatch("votemanager.voteyes", [$player, $this->currentVote]);
}
} | php | {
"resource": ""
} |
q11883 | AbstractVotePlugin.update | train | public function update($time = null)
{
if (!$this->currentVote || $this->currentVote->getStatus() == Vote::STATUS_CANCEL) {
return;
}
if (is_null($time)) {
$time = time();
}
$playerCount = count($this->playerStorage->getOnline());
// Check if vote passes when we suppose that all palyers that didn't vote would vote NO.
if ($playerCount > 0 && ($this->currentVote->getYes() / $playerCount) > $this->ratio) {
$this->votePassed();
return;
}
// If the vote is still not decided wait for the end to decide.
if (($time - $this->currentVote->getStartTime()) > $this->duration) {
$totalVotes = $this->currentVote->getYes() + $this->currentVote->getNo() * 1.0;
if ($totalVotes >= 1 && ($this->currentVote->getYes() / $totalVotes) > $this->ratio) {
$this->votePassed();
} else {
$this->voteFailed();
}
}
} | php | {
"resource": ""
} |
q11884 | SendPage.showForm | train | public function showForm()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGFILL"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$form = new XmlFormCollection($this->_context, "module:sendpage", $this->_myWords->Value("CAPTION"));
$paragraph->addXmlnukeObject($form);
$caption = new XmlInputCaption($this->_myWords->ValueArgs("INFO", array(urldecode($this->_link))));
$form->addXmlnukeObject($caption);
$hidden = new XmlInputHidden("action", "submit");
$form->addXmlnukeObject($hidden);
$hidden = new XmlInputHidden("link", $this->_link);
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDNAME"), "fromname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDEMAIL"), "frommail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTONAME"), "toname", "", 40);
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("FLDTOEMAIL"), "tomail", "", 40);
$textbox->setDataType(INPUTTYPE::EMAIL );
$textbox->setRequired(true);
$form->addXmlnukeObject($textbox);
$memo = new XmlInputMemo($this->_myWords->Value("LABEL_MESSAGE"), "custommessage","");
$form->addXmlnukeObject($memo);
$form->addXmlnukeObject(new XmlInputImageValidate($this->_myWords->Value("TYPETEXTFROMIMAGE")));
$button = new XmlInputButtons();
$button->addSubmit($this->_myWords->Value("TXT_SUBMIT"), "");
$form->addXmlnukeObject($button);
} | php | {
"resource": ""
} |
q11885 | SendPage.goBack | train | public function goBack($showMessage)
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGERROR"), BlockPosition::Center );
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($showMessage,true));
$anchor = new XmlAnchorCollection("javascript:history.go(-1)");
$anchor->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("TXT_BACK")));
$paragraph->addXmlnukeObject($anchor);
} | php | {
"resource": ""
} |
q11886 | SendPage.showMessage | train | public function showMessage()
{
$blockcenter = new XmlBlockCollection($this->_myWords->Value("MSGOK"), BlockPosition::Center);
$this->_document->addXmlnukeObject($blockcenter);
$paragraph = new XmlParagraphCollection();
$blockcenter->addXmlnukeObject($paragraph);
$paragraph->addXmlnukeObject(new XmlnukeText($_customMessage));
} | php | {
"resource": ""
} |
q11887 | Request.fillCurrentHeaders | train | private static function fillCurrentHeaders(self $request)
{
$headers = [];
//Native method exists?
if (function_exists('getallheaders')) {
//try to use it
if (($headers = getallheaders()) === false) {
$headers = [];
}
}
//No header captured yet? Try to get it myself
if (empty($headers)) {
/*
* Based on a user note provided by joyview
* at http://php.net/manual/en/function.getallheaders.php
*/
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$newKey = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
$headers[$newKey] = $value;
}
}
}
$request->setHeaders($headers);
} | php | {
"resource": ""
} |
q11888 | Request.fillCurrentRouteString | train | private static function fillCurrentRouteString(self $request)
{
//Read data from $_SERVER array
$requestUri = urldecode($_SERVER['REQUEST_URI']);
$scriptName = $_SERVER['SCRIPT_NAME'];
//Extract route string from the URI
$length = strlen(dirname($scriptName));
$routeAux = substr(explode('?', $requestUri)[0], $length);
$route = '/';
if ($routeAux && $routeAux != '/') {
$route .= trim(str_replace('\\', '/', $routeAux), '/').'/';
}
$request->setRouteStr($route);
} | php | {
"resource": ""
} |
q11889 | Request.selectDataParser | train | private function selectDataParser()
{
/* @var ContentTypeParser $selected */
$selected = null;
//Has content?
if (!empty($this->getContentType())) {
//Search trough the registered parsers
foreach (self::$registeredParsers as $parser) {
/* @var ContentTypeParser $parser */
if ($parser->canHandle($this->getContentType())) {
$selected = $parser;
break;
}
}
}
//If no one was found, pick GenericParser
if (is_null($selected)) {
$selected = new GenericParser();
}
$selected->setRequest($this);
$this->parser = $selected;
} | php | {
"resource": ""
} |
q11890 | ResourceFactory.create | train | public function create($resource)
{
$className = $this->getResourceClassName($resource->type);
if (!class_exists($className)) {
throw new Exception(
'Unknown resource type "' . $resource->type . '".',
Exception::UNKNOWN_RESOURCE_TYPE
);
}
/** @var AbstractResource $object */
$object = $this->objectManager->get($className);
foreach ($resource as $property => $value) {
if (!ObjectAccess::isPropertySettable($object, $property)) {
continue;
}
ObjectAccess::setProperty($object, $property, $value);
}
$this->postProcessResources($object);
return $object;
} | php | {
"resource": ""
} |
q11891 | Period.getPeriod | train | public function getPeriod($period, $mode = self::DAYS_ONLY)
{
$result = $this->parsePeriod($period);
if ($result['max'] && $mode == self::DAYS_AND_TIME) {
$result['max']->modify("+1 day -1 second");
}
foreach ($result as $key => $value) {
if (!$value) {
unset($result[$key]);
} elseif ($mode == self::DAYS_ONLY) {
$result[$key] = new DateTime($result[$key]->format('Y-m-d'), $this->getTimezoneTo());
} elseif ($this->getTimezoneTo()) {
$result[$key]->setTimezone($this->getTimezoneTo());
}
}
return $result;
} | php | {
"resource": ""
} |
q11892 | Unoconv.transcode | train | public function transcode($input, $format, $outputFile, $pageRange = null)
{
if (!file_exists($input)) {
throw new InvalidFileArgumentException(sprintf('File %s does not exists', $input));
}
$arguments = array(
'--format=' . $format,
'--stdout'
);
if (preg_match('/\d+-\d+/', $pageRange)) {
$arguments[] = '-e';
$arguments[] = 'PageRange=' . $pageRange;
}
$arguments[] = $input;
try {
$output = $this->command($arguments);
} catch (ExecutionFailureException $e) {
throw new RuntimeException(
'Unoconv failed to transcode file', $e->getCode(), $e
);
}
if (!is_writable(dirname($outputFile)) || !file_put_contents($outputFile, $output)) {
throw new RuntimeException(sprintf(
'Unable to write to output file `%s`', $outputFile
));
}
return $this;
} | php | {
"resource": ""
} |
q11893 | DependentBenGorUserBundle.checkDependencies | train | public function checkDependencies(array $requiredBundles, ContainerBuilder $container)
{
if (false === ($this instanceof Bundle)) {
throw new RuntimeException('It is a bundle trait, you shouldn\'t have to use in other instances');
}
$enabledBundles = $container->getParameter('kernel.bundles');
foreach ($requiredBundles as $requiredBundle) {
if (!isset($enabledBundles[$requiredBundle])) {
throw new RuntimeException(
sprintf(
'In order to use "%s" you also need to enable and configure the "%s"',
$this->getName(),
$requiredBundle
)
);
}
}
} | php | {
"resource": ""
} |
q11894 | Customer.loadFromFlexiBee | train | public function loadFromFlexiBee($id = null)
{
$result = $this->adresar->loadFromFlexiBee($id);
$this->takeData($this->adresar->getData());
return $result;
} | php | {
"resource": ""
} |
q11895 | Customer.getCustomerScore | train | public function getCustomerScore($addressID)
{
$score = 0;
$debts = $this->getCustomerDebts($addressID);
$stitkyRaw = $this->adresar->getColumnsFromFlexiBee(['stitky'],
['id' => $addressID]);
$stitky = $stitkyRaw[0]['stitky'];
if (!empty($debts)) {
foreach ($debts as $did => $debt) {
$ddiff = \FlexiPeeHP\FakturaVydana::overdueDays($debt['datSplat']);
if (($ddiff <= 7) && ($ddiff >= 1)) {
$score = self::maxScore($score, 1);
} else {
if (($ddiff > 7 ) && ($ddiff <= 14)) {
$score = self::maxScore($score, 2);
} else {
if ($ddiff > 14) {
$score = self::maxScore($score, 3);
}
}
}
}
}
if ($score == 3 && !strstr($stitky, 'UPOMINKA2')) {
$score = 2;
}
if (!strstr($stitky, 'UPOMINKA1') && !empty($debts)) {
$score = 1;
}
return $score;
} | php | {
"resource": ""
} |
q11896 | Customer.getUserEmail | train | public function getUserEmail()
{
return strlen($this->kontakt->getDataValue($this->mailColumn)) ? $this->kontakt->getDataValue($this->mailColumn)
: $this->adresar->getDataValue($this->mailColumn);
} | php | {
"resource": ""
} |
q11897 | SseTask.getListQueuedTask | train | public function getListQueuedTask() {
$result = [];
if (!CakeSession::check($this->_sessionKey)) {
return $result;
}
$tasks = CakeSession::read($this->_sessionKey);
if (!is_array($tasks)) {
return $result;
}
return $tasks;
} | php | {
"resource": ""
} |
q11898 | SseTask.deleteQueuedTask | train | public function deleteQueuedTask($tasks = []) {
if (empty($tasks) || !is_array($tasks)) {
return false;
}
if (!CakeSession::check($this->_sessionKey)) {
return false;
}
$existsTasks = CakeSession::read($this->_sessionKey);
if (empty($existsTasks)) {
return false;
}
$resultTasks = array_values(array_diff((array)$existsTasks, $tasks));
return CakeSession::write($this->_sessionKey, $resultTasks);
} | php | {
"resource": ""
} |
q11899 | Score.parseChartMask | train | public static function parseChartMask($mask)
{
$result = [];
$arrayParts = explode('|', $mask);
foreach ($arrayParts as $partOfMask) {
$arrayLib = explode('~', $partOfMask);
$result[] = ['size' => (int)$arrayLib[0], 'suffixe' => $arrayLib[1]];
}
return $result;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.