_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11500 | FilterHelper.createFilterForm | train | public function createFilterForm($formInputs = null, $plugin = null, $usePrint = true, $exportType = null) {
$result = '';
if (empty($formInputs) || !is_array($formInputs)) {
return $result;
}
if ($usePrint) {
$urlOptions = $this->_getExtendOptionsPaginationUrl();
if (!isset($this->Paginator->options['url'])) {
$this->Paginator->options['url'] = [];
}
$this->Paginator->options['url'] = Hash::merge($this->Paginator->options['url'], $urlOptions);
}
$result .= $this->_createPaginationTableRow($formInputs);
$result .= $this->_createFilterTableRow($formInputs, $plugin, $usePrint, $exportType);
return $result;
} | php | {
"resource": ""
} |
q11501 | FilterHelper.createGroupActionControls | train | public function createGroupActionControls($formInputs = null, $groupActions = null, $useSelectAll = false) {
$result = '';
if (empty($formInputs) || !is_array($formInputs) ||
(!empty($groupActions) && !is_array($groupActions)) ||
(empty($groupActions) && !$useSelectAll)) {
return $result;
}
if (empty($groupActions)) {
$groupActions = [];
}
$colspan = null;
$countFormInputs = count($formInputs);
if ($countFormInputs > 2) {
$colspan = $countFormInputs;
}
$selectOptions = [];
foreach ($groupActions as $value => $text) {
$selectOptions[] = compact('text', 'value');
}
$tableFoother = [];
if ($useSelectAll) {
if (!empty($colspan)) {
$colspan--;
}
$tableFoother[] = $this->_getOptionsForElem('createGroupActionControls.selectAllBtn');
}
$inputField = '';
if (!empty($selectOptions)) {
$this->ExtBs3Form->unlockField('FilterGroup.action');
$tableFoother[] = [
$this->ExtBs3Form->hidden('FilterGroup.action') . $this->_getOptionsForElem('createGroupActionControls.groupDataProcTitle'),
['colspan' => $colspan, 'class' => 'text-center']
];
$btnOptions = ['data-dialog-sel-options' => htmlentities(json_encode($selectOptions))];
$optionsDefault = $this->_getOptionsForElem('createGroupActionControls.performActionBtn');
$tableFoother[] = [
$this->ViewExtension->button(
'fas fa-cog',
'btn-warning',
$btnOptions + $optionsDefault
),
['class' => 'action text-center']];
} else {
if (!empty($colspan)) {
$colspan++;
}
$tableFoother[] = ['',
['colspan' => $colspan]];
}
$result = $this->Html->tableCells([$tableFoother], ['class' => 'active'], ['class' => 'active']);
return $result;
} | php | {
"resource": ""
} |
q11502 | FilterHelper.createFilterRowCheckbox | train | public function createFilterRowCheckbox($inputField = null, $value = null) {
$result = '';
if (is_array($inputField)) {
$inputField = array_keys($inputField);
$inputField = (string)array_shift($inputField);
}
if (empty($inputField) || (strpos($inputField, '.') === false)) {
return $result;
}
$uniqid = uniqid();
$dataPath = 'FilterData.0.' . $inputField;
$inputFieldName = $dataPath . '.';
$data = (array)$this->request->data($dataPath);
$options = [
'value' => $value,
'checked ' => in_array($value, $data),
'hiddenField' => false,
'required' => false,
'secure' => false,
];
$this->setEntity($inputFieldName . $uniqid);
$options = $this->domId($options);
$options = $this->_initInputField($inputFieldName, $options);
$result = $this->ExtBs3Form->checkbox($inputFieldName, $options) .
$this->ExtBs3Form->label($inputFieldName . $uniqid, '');
$result = $this->Html->div('checkbox', $result);
return $result;
} | php | {
"resource": ""
} |
q11503 | FilterHelper.getBtnConditionGroup | train | public function getBtnConditionGroup($inputCondField = null) {
$options = $this->_getOptionsForElem('getBtnConditionGroup.options');
$title = $this->_getOptionsForElem('getBtnConditionGroup.title');
return $this->_getBtnCondition($inputCondField, $options, $title, false);
} | php | {
"resource": ""
} |
q11504 | FilterHelper._getFilterRequestData | train | protected function _getFilterRequestData($baseKey = null, $key = null) {
$filterData = [];
if (empty($baseKey)) {
return $filterData;
}
if ($this->_getFlagUsePost()) {
$requestData = $this->request->data($baseKey);
if (!empty($requestData)) {
$filterData = $requestData;
}
} else {
$requestData = $this->request->query('data.' . $baseKey);
if (!empty($requestData)) {
$filterData = array_map('unserialize', array_unique(array_map('serialize', $requestData)));
}
}
if (!empty($key)) {
return Hash::get($filterData, $key);
}
return $filterData;
} | php | {
"resource": ""
} |
q11505 | FilterHelper._getExtendOptionsPaginationUrl | train | protected function _getExtendOptionsPaginationUrl() {
$options = [];
$ext = (string)$this->request->param('ext');
$ext = mb_strtolower($ext);
if (empty($ext) || ($ext !== 'prt')) {
return $options;
}
$options = compact('ext');
return $options;
} | php | {
"resource": ""
} |
q11506 | Manialink.destroy | train | public function destroy()
{
// This is not mandatory as GC will free the memory eventually but allows memory to be freed faster
// by removing circular dependencies.
if (!empty($this->data)) {
foreach ($this->data as $data) {
if ($data instanceof DestroyableObject) {
$data->destroy();
}
}
}
$this->data = [];
$this->manialinkFactory = null;
} | php | {
"resource": ""
} |
q11507 | GraphViz.getView | train | private function getView(string $name, array $data = [])
{
$filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
$templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
return $templating->render($name . '.phtml', $data);
} | php | {
"resource": ""
} |
q11508 | JsWriterAbstract.getFiles | train | public function getFiles()
{
$files = $this->files;
foreach ($this->types as $type) {
$files = array_merge($files, $type->getFiles());
}
$path = \Altamira\Config::getInstance()->getPluginPath( $this->getLibrary() );
array_walk( $files, function( &$val ) use ( $path ) { $val = $path . $val; } );
return $files;
} | php | {
"resource": ""
} |
q11509 | JsWriterAbstract.getOptionsForSeries | train | public function getOptionsForSeries( $series )
{
$seriesTitle = $this->getSeriesTitle( $series );
if (! isset( $this->options['seriesStorage'][$seriesTitle] ) ) {
throw new \Exception( 'Series not registered with JsWriter' );
}
return $this->options['seriesStorage'][$seriesTitle];
} | php | {
"resource": ""
} |
q11510 | JsWriterAbstract.getSeriesOption | train | public function getSeriesOption( $series, $option, $default = null )
{
$seriesTitle = $this->getSeriesTitle( $series );
return ( isset( $this->options['seriesStorage'][$seriesTitle] ) && isset( $this->options['seriesStorage'][$seriesTitle][$option] ) )
? $this->options['seriesStorage'][$seriesTitle][$option]
: $default;
} | php | {
"resource": ""
} |
q11511 | JsWriterAbstract.setSeriesOption | train | public function setSeriesOption( $series, $name, $value )
{
$this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), $name, $value );
return $this;
} | php | {
"resource": ""
} |
q11512 | JsWriterAbstract.setType | train | public function setType( $type, $options = array(), $series = 'default' )
{
$options = $options ?: array(); // i shouldn't have to do this
$className = $this->typeNamespace . ucwords( $type );
if( class_exists( $className ) ) {
$type = new $className( $this );
} else {
throw new \Exception( "Type {$type} does not exist" );
}
$type->setOptions( $options );
$series = $this->getSeriesTitle( $series );
$this->types[$series] = $type;
if ( isset( $this->options['seriesStorage'][$series] ) ) {
$this->options['seriesStorage'][$series] = array_merge_recursive( $this->options['seriesStorage'][$series], $type->getSeriesOptions() );
if ( $renderer = $type->getRenderer() ) {
$this->options['seriesStorage'][$series]['renderer'] = $renderer;
}
}
$this->options = array_merge_recursive( $this->options, $type->getOptions() );
return $this;
} | php | {
"resource": ""
} |
q11513 | JsWriterAbstract.getType | train | public function getType( $series = null )
{
$series = $series ?: 'default';
$seriesTitle = $this->getSeriesTitle( $series );
return isset( $this->types[$seriesTitle] ) ? $this->types[$seriesTitle] : null;
} | php | {
"resource": ""
} |
q11514 | JsWriterAbstract.setNestedOptVal | train | protected function setNestedOptVal( array &$options, $arg )
{
//@codeCoverageIgnoreStart
$args = func_get_args();
if ( count( $args ) == 2 && is_array( $args[1] ) ) {
$args = $args[1];
} else if ( count( $args ) < 3 ) {
throw new \BadMethodCallException( '\Altamira\JsWriterAbstract::setNestedOptVal requires at least three arguments' );
} else {
array_shift( $args );
}
do {
$arg = array_shift( $args );
if (! isset( $options[$arg] ) ) {
$options[$arg] = array();
}
$options = &$options[$arg];
} while ( count( $args ) > 2 );
$options[array_shift( $args )] = array_shift( $args );
return $this;
//@codeCoverageIgnoreEnd
} | php | {
"resource": ""
} |
q11515 | JsWriterAbstract.getNestedOptVal | train | protected function getNestedOptVal( array $options, $arg )
{
//@codeCoverageIgnoreStart
$args = func_get_args();
if ( count( $args ) == 2 && is_array( $args[1] ) ) {
$args = $args[1];
} else if ( count( $args ) < 3 ) {
throw new \BadMethodCallException( '\Altamira\JsWriterAbstract::getNestedOptVal requires at least three arguments' );
} else {
array_shift( $args );
}
do {
$arg = array_shift( $args );
if (! isset( $options[$arg] ) ) {
return null;
}
$options = &$options[$arg];
} while ( count( $args ) > 1 );
$finalArg = array_shift( $args );
return isset( $options[$finalArg] ) ? $options[$finalArg] : null;
//@codeCoverageIgnoreEnd
} | php | {
"resource": ""
} |
q11516 | MainMenuBuilderListener.onMainMenuBuild | train | public function onMainMenuBuild(MenuBuilderEvent $event): void
{
if (!$this->authorizationChecker->isGranted('ROLE_NGBM_ADMIN')) {
return;
}
$this->addLayoutsSubMenu($event->getMenu());
} | php | {
"resource": ""
} |
q11517 | Bar.setOption | train | public function setOption($name, $value)
{
switch ($name) {
case 'horizontal':
$this->options['bars']['horizontal'] = $value;
break;
case 'stackSeries':
$this->pluginFiles[] = 'jquery.flot.stack.js';
$this->options['series']['stack'] = true;
break;
case 'fillColor':
$this->options['series']['bars']['fillColor']['colors'] = $value;
break;
default:
parent::setOption($name, $value);
}
return $this;
} | php | {
"resource": ""
} |
q11518 | SlackHandler.prepareContentData | train | protected function prepareContentData($record)
{
$dataArray = array(
'token' => $this->token,
'channel' => $this->channel,
'username' => $this->username,
'text' => '',
'attachments' => array(),
);
if ($this->formatter) {
$message = $this->formatter->format($record);
} else {
$message = $record['message'];
}
if ($this->useAttachment) {
$attachment = array(
'fallback' => $message,
'color' => $this->getAttachmentColor($record['level']),
'fields' => array(),
);
if ($this->useShortAttachment) {
$attachment['title'] = $record['level_name'];
$attachment['text'] = $message;
} else {
$attachment['title'] = 'Message';
$attachment['text'] = $message;
$attachment['fields'][] = array(
'title' => 'Level',
'value' => $record['level_name'],
'short' => true,
);
}
if ($this->includeContextAndExtra) {
if (!empty($record['extra'])) {
if ($this->useShortAttachment) {
$attachment['fields'][] = array(
'title' => "Extra",
'value' => $this->stringify($record['extra']),
'short' => $this->useShortAttachment,
);
} else {
// Add all extra fields as individual fields in attachment
foreach ($record['extra'] as $var => $val) {
$attachment['fields'][] = array(
'title' => $var,
'value' => $val,
'short' => $this->useShortAttachment,
);
}
}
}
if (!empty($record['context'])) {
if ($this->useShortAttachment) {
$attachment['fields'][] = array(
'title' => "Context",
'value' => $this->stringify($record['context']),
'short' => $this->useShortAttachment,
);
} else {
// Add all context fields as individual fields in attachment
foreach ($record['context'] as $var => $val) {
$attachment['fields'][] = array(
'title' => $var,
'value' => $val,
'short' => $this->useShortAttachment,
);
}
}
}
}
$dataArray['attachments'] = json_encode(array($attachment));
} else {
$dataArray['text'] = $message;
}
if ($this->iconEmoji) {
$dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
}
return $dataArray;
} | php | {
"resource": ""
} |
q11519 | CacheManager.getCache | train | public function getCache(string $name='')
{
# Find the cache (if we already have it created)
$cache = $this->findCache($name);
if (\is_null($cache)) {
# Attempt to create the cache
$cache = $this->createCache($name);
if (!\is_null($cache)) {
$this->addCache($cache);
}
}
return $cache;
} | php | {
"resource": ""
} |
q11520 | CacheManager.findCache | train | public function findCache(string $name='')
{
if ( empty($name) ) {
# Take first available
$cache = \reset($this->caches);
if ($cache === false)
return null;
} else {
# Attempt to find the cache from the list
$cache = ( $this->caches[\strtolower($name)] ?? null);
}
return $cache;
} | php | {
"resource": ""
} |
q11521 | CacheManager.addCache | train | public function addCache(AbstractCacheAdapterInterface $cache)
{
$this->caches[\strtolower($cache->getDriver())] = $cache;
return $this;
} | php | {
"resource": ""
} |
q11522 | CacheManager.removeCache | train | public function removeCache(string $name)
{
# Sanity check
if (empty($name)) return false;
$cache = $this->findCache($name);
if ($cache) {
unset( $this->caches[\strtolower($cache->getDriver())] );
unset($cache);
$cache = null;
}
return $this;
} | php | {
"resource": ""
} |
q11523 | MenuItems.registerConfigItems | train | protected function registerConfigItems(ParentItem $root, $parentId, $configItems)
{
foreach ($configItems as $configId => $configItem) {
$subItems = reset($configItem);
$path = $parentId . '/' . $configId;
$configPath = str_replace("admin/server/config/",'', $path);
$translationKey = 'expansion_config.menu.' . implode('.', explode('/', $configPath)) . '.label';
if (is_array($subItems)) {
$root->addChild(
ParentItem::class,
$path,
$translationKey,
null
);
$this->registerConfigItems($root, $path, $configItem);
} else {
$root->addChild(
ChatCommandItem::class,
$path,
$translationKey,
'admin_config', // Default config on each element.
['cmd' => '/admin config "' . $configPath . '"']
);
}
}
} | php | {
"resource": ""
} |
q11524 | StreamFactory.createStreamFromFile | train | public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
# Open the file
$resource = \fopen($filename, $mode);
return \GuzzleHttp\Psr7\stream_for($resource);
} | php | {
"resource": ""
} |
q11525 | Config.apply | train | public function apply(Injector $injector): void
{
$dependencies = $this->config['dependencies'] ?? [];
// Define the "config" service, accounting for the fact that Auryn
// requires all returns are objects.
$dependencies['services']['config'] = new ArrayObject($this->config, ArrayObject::ARRAY_AS_PROPS);
$this->injectServices($injector, $dependencies);
$this->injectFactories($injector, $dependencies);
$this->injectInvokables($injector, $dependencies);
$this->injectAliases($injector, $dependencies);
} | php | {
"resource": ""
} |
q11526 | EnchantSpell.& | train | function &getSuggestions($lang, $word) {
$r = enchant_broker_init();
$suggs = array();
if (enchant_broker_dict_exists($r,$lang)) {
$d = enchant_broker_request_dict($r, $lang);
$suggs = enchant_dict_suggest($d, $word);
enchant_broker_free_dict($d);
} else {
}
enchant_broker_free($r);
return $suggs;
} | php | {
"resource": ""
} |
q11527 | AbstractPdfGenerator.generate | train | public function generate(array $parameters = array(), array $options = array())
{
$parametersResolver = new OptionsResolver();
$this->setDefaultParameters($parametersResolver);
$parameters = $parametersResolver->resolve($parameters);
$optionsResolver = new OptionsResolver();
$this->setDefaultOptions($optionsResolver);
$options = $optionsResolver->resolve($options);
return $this->doGenerate($parameters, $options);
} | php | {
"resource": ""
} |
q11528 | Profiler.finish | train | public static function finish() {
if(empty(self::$profiler) === false) {
self::$profiler = array_merge([
'elapsed' => self::getTime(time() - self::$profiler['start']),
'memory' => self::getMemoryUsage(),
'cpu' => self::getUsageCPU(),
'stack' => self::getStackCalls()
], self::$profiler);
unset(self::$profiler['start']);
}
} | php | {
"resource": ""
} |
q11529 | Profiler.getTime | train | public function getTime($seconds) {
$dtF = new \DateTime("@0");
$dtT = new \DateTime("@$seconds");
return $dtF->diff($dtT)->format('%h hours, %i minutes %s sec.');
} | php | {
"resource": ""
} |
q11530 | Profiler.getStackCalls | train | private static function getStackCalls() {
$i = 1;
$result = [];
foreach(xdebug_get_function_stack() as $node) {
if(isset($node['line']) === true) {
$result[] = "$i. ".basename($node['file']) .":" .$node['function'] ."(" .$node['line'].")";
}
$i++;
}
return $result;
} | php | {
"resource": ""
} |
q11531 | Profiler.getMemoryUsage | train | private static function getMemoryUsage() {
$memory = memory_get_peak_usage();
$floor = floor((strlen($memory) - 1) / 3);
return sprintf("%.2f", $memory/pow(1024, $floor)).' '.@'BKMGTPEZY'[$floor].'B';
} | php | {
"resource": ""
} |
q11532 | Profiler.pretty | train | private static function pretty(array $data) {
$color = new Color();
$output = $color->getColoredString(self::VERBOSE_TITLE, 'blue', 'light-gray').PHP_EOL;
foreach($data as $key => $value) {
if(is_array($value) === false) {
$output .= $color->getColoredString(sprintf(self::VERBOSE_ROW, $key, $value), 'dark_gray').PHP_EOL;
}
else {
$output .= $color->getColoredString(sprintf(self::VERBOSE_ROW, $key, ''), 'dark_gray').PHP_EOL;
foreach($value as $line => $string) {
$output .= $color->getColoredString(sprintf("\t".self::VERBOSE_ROW, '', $string), 'dark_gray').PHP_EOL;
}
}
}
$output .= $color->getColoredString('-----------------', 'blue', 'light-gray').PHP_EOL;
return $output;
} | php | {
"resource": ""
} |
q11533 | Bootstrap._block_filter_oembed_result | train | public function _block_filter_oembed_result( $response, $handler, $request ) {
if ( 'GET' !== $request->get_method() ) {
return $response;
}
if ( is_wp_error( $response ) && 'oembed_invalid_url' !== $response->get_error_code() ) {
return $response;
}
if ( '/oembed/1.0/proxy' !== $request->get_route() ) {
return $response;
}
$provider_name = 'wp-oembed-blog-card handler';
if ( isset( $response->provider_name ) && $response->provider_name === $provider_name ) {
return $response;
}
global $wp_embed;
$html = $wp_embed->shortcode( [], $request->get_param( 'url' ) );
if ( ! $html ) {
return $response;
}
return [
'provider_name' => $provider_name,
'html' => $html,
];
} | php | {
"resource": ""
} |
q11534 | Bootstrap._maybe_refresh_cache | train | protected function _maybe_refresh_cache( $url ) {
$cache = Cache::get( $url );
if ( ! $cache || is_admin() ) {
Cache::refresh( $url );
}
} | php | {
"resource": ""
} |
q11535 | Bootstrap._render | train | protected function _render( $url ) {
$this->_maybe_refresh_cache( $url );
if ( ! is_admin() ) {
return $this->_is_block_embed_rendering_request()
? View::get_block_template( $url )
: View::get_pre_blog_card_template( $url );
}
return View::get_template( $url );
} | php | {
"resource": ""
} |
q11536 | Bootstrap._is_admin_request | train | protected function _is_admin_request() {
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
return false;
}
$request_uri = wp_unslash( $_SERVER['REQUEST_URI'] ); // WPCS: sanitization ok.
if ( false !== strpos( $request_uri, '/wp-admin/admin-ajax.php' ) ) {
return false === strpos( $request_uri, 'action=wp_oembed_blog_card_render' );
}
if ( false !== strpos( $request_uri, '/wp-json/' ) ) {
return false === strpos( $request_uri, '/wp-json/oembed/' );
}
if ( false !== strpos( $request_uri, '/wp-cron.php' ) ) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q11537 | XmlInputTextBox.setAutosuggest | train | public function setAutosuggest($context, $url, $paramReq, $jsCallback="", $jsonArray = "select.option", $jsonObjKey = "value", $jsonObjValue = "_text", $jsonObjInfo = "_text")
{
$this->_context = $context;
$this->_autosuggestUrl = $url;
$this->_autosuggestParamReq = $paramReq;
$this->_autosuggestCallback = $jsCallback;
$this->_autosuggestJsonArray = $jsonArray;
$this->_autosuggestJsonObjKey = $jsonObjKey;
$this->_autosuggestJsonObjValue = $jsonObjValue;
$this->_autosuggestJsonObjInfo = $jsonObjInfo;
} | php | {
"resource": ""
} |
q11538 | CsvBase.getEncoding | train | public function getEncoding($direction)
{
if (!isset($this->encoding[$direction])) {
throw new Exception("Encoding direction invalid");
}
return $this->encoding[$direction];
} | php | {
"resource": ""
} |
q11539 | CsvBase.setEncoding | train | public function setEncoding($direction, $encoding)
{
if (!isset($this->encoding[$direction])) {
throw new Exception("Encoding direction invalid");
}
if (!$encoding) {
throw new Exception("Encoding value invalid");
} elseif (preg_match('/utf.?8/ui', $encoding)) {
$encoding = 'UTF-8';
} else {
$encoding = mb_strtoupper($encoding);
}
$this->encoding[$direction] = $encoding;
return $this;
} | php | {
"resource": ""
} |
q11540 | BaseProcessResult.SearchAndReplace | train | public function SearchAndReplace($buffer)
{
$context = Context::getInstance();
$posi = 0;
$i = strpos($buffer, "<param-", $posi);
while ($i !== false)
{
echo substr($buffer, $posi, $i-$posi);
$if = strpos($buffer, "</param-", $i);
$tamparam = $if-$i-8;
$var = substr($buffer, $i+7, $tamparam);
echo $context->get($var);
$posi = $if + $tamparam + 9;
$i = strpos($buffer, "<param-", $posi);
}
echo substr($buffer, $posi);
} | php | {
"resource": ""
} |
q11541 | PageXml.addJavaScript | train | public function addJavaScript($javascript, $location = 'up')
{
$nodeWorking = XmlUtil::CreateChild($this->_nodePage, "script", "");
XmlUtil::AddAttribute($nodeWorking, "language", "javascript");
XmlUtil::AddAttribute($nodeWorking, "location", $location);
XmlUtil::AddTextNode($nodeWorking, $javascript);
} | php | {
"resource": ""
} |
q11542 | AppService.run | train | public function run() {
if (PHP_SAPI !== 'cli') {
throw new AppServiceException('Warning: Script should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI');
}
try {
$this->socketService->run();
}
catch(SocketServiceException $e) {
throw new AppServiceException($e->getMessage());
}
} | php | {
"resource": ""
} |
q11543 | ManageUsersGroups.getRolesFromSite | train | protected function getRolesFromSite($site)
{
$newDataSet = new AnyDataset();
$it = $this->user->getRolesIterator($site);
while ($it->hasNext()) {
$sr = $it->moveNext();
$dataArray = $sr->getFieldArray($this->user->getRolesTable()->Role);
if (sizeof($dataArray) > 0) {
foreach ($dataArray as $roles) {
$siteName = $sr->getField($this->user->getRolesTable()->Site);
if ($siteName == "_all") {
$siteName = $this->myWords->Value("TEXT_ALLSITES");
}
$newDataSet->appendRow();
$newDataSet->addField($this->user->getRolesTable()->Site, $siteName);
$newDataSet->addField($this->user->getRolesTable()->Role, $roles);
}
}
}
return $newDataSet;
} | php | {
"resource": ""
} |
q11544 | ManageUsersGroups.AddListLink | train | protected function AddListLink($block)
{
$para = new XmlParagraphCollection();
$this->_mainBlock->addXmlnukeObject($para);
$this->url->addParam("action", ModuleAction::Listing);
$link = new XmlAnchorCollection($this->url->getUrl(), "");
$link->addXmlnukeObject(new XmlnukeText($this->myWords->Value("LINK_LISTROLES")));
$para->addXmlnukeObject($link);
} | php | {
"resource": ""
} |
q11545 | ManageUsersGroups.AddEditListToSite | train | protected function AddEditListToSite($block, $site, $dataset)
{
$para = new XmlParagraphCollection();
$this->_mainBlock->addXmlnukeObject($para);
$this->url->addParam("editsite", $site);
$editList = new XmlEditList($this->_context, $this->myWords->Value("EDITLIST_TITLE", $site), $this->url->getUrl(), true, false, true, true);
$editList->setDataSource($dataset->getIterator());
$listField = new EditListField();
$listField->editlistName = "";
$listField->fieldData = "role";
$editList->addEditListField($listField);
$listField = new EditListField();
$listField->editlistName = $this->myWords->Value("EDITLIST_ROLES");
$listField->fieldData = $this->user->getRolesTable()->Role;
$editList->addEditListField($listField);
$listField = new EditListField();
$listField->editlistName = $this->myWords->Value("EDITLIST_SITES");
$listField->fieldData = $this->user->getRolesTable()->Site;
$editList->addEditListField($listField);
$para->addXmlnukeObject($editList);
} | php | {
"resource": ""
} |
q11546 | Visitor.setUa | train | public function setUa($ua)
{
$this->ua = $this->detector->setUserAgent($ua);
// set browser & platform
$this->setBrowser();
return $this;
} | php | {
"resource": ""
} |
q11547 | Visitor.setBrowser | train | private function setBrowser()
{
$client = parse_user_agent($this->detector->getUserAgent());
$this->browser = $client['browser'];
$this->setPlatform($client['platform']);
return $this;
} | php | {
"resource": ""
} |
q11548 | Visitor.deviceDetect | train | private function deviceDetect()
{
$this->mobile = (int)$this->detector->isMobile();
$this->tablet = (int)$this->detector->isTablet();
if ($this->mobile === 0 && $this->tablet === 0) {
$this->pc = 1;
}
return $this;
} | php | {
"resource": ""
} |
q11549 | Visitor.toArray | train | public function toArray() {
$properties = get_object_vars($this);
foreach($properties as $var => &$value) {
if(gettype($value) === 'object') {
unset($properties[$var]);
}
}
return $properties;
} | php | {
"resource": ""
} |
q11550 | DecimaAccountingServiceProvider.registerAccountChartTypeInterface | train | protected function registerAccountChartTypeInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\System\Repositories\AccountChartType\AccountChartTypeInterface', function()
{
return new \Mgallegos\DecimaAccounting\System\Repositories\AccountChartType\EloquentAccountChartType( new AccountChartType() );
});
} | php | {
"resource": ""
} |
q11551 | DecimaAccountingServiceProvider.registerSettingInterface | train | protected function registerSettingInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
//var_dump($AuthenticationManager->getCurrentUserOrganizationConnection());die();
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\EloquentSetting(new Setting(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11552 | DecimaAccountingServiceProvider.registerAccountTypeInterface | train | protected function registerAccountTypeInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\AccountType\AccountTypeInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\AccountType\EloquentAccountType(new AccountType(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11553 | DecimaAccountingServiceProvider.registerPeriodInterface | train | protected function registerPeriodInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Period\EloquentPeriod(new Period(), $app['db'], $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11554 | DecimaAccountingServiceProvider.registerFiscalYearInterface | train | protected function registerFiscalYearInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\EloquentFiscalYear(new FiscalYear(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11555 | DecimaAccountingServiceProvider.registerAccountInterface | train | protected function registerAccountInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Account\AccountInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Account\EloquentAccount(new Account(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11556 | DecimaAccountingServiceProvider.registerSystemAccountInterface | train | protected function registerSystemAccountInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\System\Repositories\Account\AccountInterface', function()
{
return new \Mgallegos\DecimaAccounting\System\Repositories\Account\EloquentAccount( new SystemAccount() );
});
} | php | {
"resource": ""
} |
q11557 | DecimaAccountingServiceProvider.registerCostCenterInterface | train | protected function registerCostCenterInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\CostCenter\CostCenterInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\CostCenter\EloquentCostCenter(new CostCenter(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11558 | DecimaAccountingServiceProvider.registerDocumentTypeInterface | train | protected function registerDocumentTypeInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\DocumentType\DocumentTypeInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\DocumentType\EloquentDocumentType(new DocumentType(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11559 | DecimaAccountingServiceProvider.registerClientInterface | train | protected function registerClientInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Client\ClientInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Client\EloquentClient(new Client(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11560 | DecimaAccountingServiceProvider.registerSupplierInterface | train | protected function registerSupplierInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Supplier\SupplierInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Supplier\EloquentSupplier(new Supplier(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11561 | DecimaAccountingServiceProvider.registerEmployeeInterface | train | protected function registerEmployeeInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Employee\EmployeeInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Employee\EloquentEmployee(new Employee(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11562 | DecimaAccountingServiceProvider.registerApportionmentInterface | train | protected function registerApportionmentInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\Apportionment\ApportionmentInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\Apportionment\EloquentApportionment(new Apportionment(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11563 | DecimaAccountingServiceProvider.registerApportionmentEntryInterface | train | protected function registerApportionmentEntryInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\ApportionmentEntry\ApportionmentEntryInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\ApportionmentEntry\EloquentApportionmentEntry(new ApportionmentEntry(), $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11564 | DecimaAccountingServiceProvider.registerJournalVoucherInterface | train | protected function registerJournalVoucherInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\JournalVoucher\JournalVoucherInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\JournalVoucher\EloquentJournalVoucher(new JournalVoucher(), $app['db'], $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11565 | DecimaAccountingServiceProvider.registerJournalEntryInterface | train | protected function registerJournalEntryInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Repositories\JournalEntry\JournalEntryInterface', function($app)
{
$AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface');
return new \Mgallegos\DecimaAccounting\Accounting\Repositories\JournalEntry\EloquentJournalEntry(new JournalEntry(), $app['db'], $AuthenticationManager->getCurrentUserOrganizationConnection());
});
} | php | {
"resource": ""
} |
q11566 | DecimaAccountingServiceProvider.registerSettingManagementInterface | train | protected function registerSettingManagementInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Services\SettingManagement\SettingManagementInterface', function($app)
{
return new SettingManager(
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface'),
$app->make('Mgallegos\DecimaAccounting\System\Repositories\AccountChartType\AccountChartTypeInterface'),
$app->make('App\Kwaai\System\Repositories\Currency\CurrencyInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\AccountType\AccountTypeInterface'),
$app->make('Mgallegos\DecimaAccounting\System\Repositories\AccountType\AccountTypeInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\Account\AccountInterface'),
$app->make('Mgallegos\DecimaAccounting\System\Repositories\Account\AccountInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\VoucherType\VoucherTypeInterface'),
$app->make('Mgallegos\DecimaAccounting\System\Repositories\VoucherType\VoucherTypeInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\CostCenter\CostCenterInterface'),
$app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'),
$app->make('App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface'),
$app->make('App\Kwaai\Security\Repositories\Journal\JournalInterface'),
$app['db'],
$app['translator'],
$app['config']
);
});
} | php | {
"resource": ""
} |
q11567 | DecimaAccountingServiceProvider.registerPeriodManagementInterface | train | protected function registerPeriodManagementInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Services\PeriodManagement\PeriodManagementInterface', function($app)
{
return new PeriodManager(
$app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'),
$app->make('App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface'),
$app->make('App\Kwaai\Security\Repositories\Journal\JournalInterface'),
new \Mgallegos\LaravelJqgrid\Encoders\JqGridJsonEncoder($app->make('excel')),
new \Mgallegos\DecimaAccounting\Accounting\Repositories\Period\EloquentPeriodGridRepository(
$app['db'],
$app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'),
$app['translator']
),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\JournalVoucher\JournalVoucherInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface'),
new Carbon(),
$app['db'],
$app['translator'],
$app['config']
);
});
} | php | {
"resource": ""
} |
q11568 | DecimaAccountingServiceProvider.registerFiscalYearManagementInterface | train | protected function registerFiscalYearManagementInterface()
{
$this->app->bind('Mgallegos\DecimaAccounting\Accounting\Services\FiscalYearManagement\FiscalYearManagementInterface', function($app)
{
return new FiscalYearManager(
$app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'),
$app->make('App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Services\JournalManagement\JournalManagementInterface'),
$app->make('App\Kwaai\Security\Repositories\Journal\JournalInterface'),
new \Mgallegos\LaravelJqgrid\Encoders\JqGridJsonEncoder($app->make('excel')),
new \Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\EloquentFiscalYearGridRepository(
$app['db'],
$app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'),
$app['translator']
),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface'),
$app->make('Mgallegos\DecimaAccounting\Accounting\Repositories\JournalEntry\JournalEntryInterface'),
new Carbon(),
$app['db'],
$app['translator'],
$app['config']
);
});
} | php | {
"resource": ""
} |
q11569 | EntityType.getRoot | train | public function getRoot()
{
$next_parent = $this->getParent();
$parent = null;
while ($next_parent) {
$parent = $next_parent;
$next_parent = $parent->getParent();
}
return $parent ? $parent : $this;
} | php | {
"resource": ""
} |
q11570 | EntityType.getAttributes | train | public function getAttributes(array $attribute_names = [], array $types = [])
{
$attribute_map = [];
if (empty($attribute_names)) {
$attribute_map = $this->attribute_map->getItems();
} else {
foreach ($attribute_names as $attribute_name) {
$attribute_map[$attribute_name] = $this->getAttribute($attribute_name);
}
}
if (!empty($types)) {
$attribute_map = array_filter(
$attribute_map,
function ($attribute) use ($types) {
return in_array(get_class($attribute), $types);
}
);
}
return new AttributeMap($attribute_map);
} | php | {
"resource": ""
} |
q11571 | EntityType.getAttribute | train | public function getAttribute($name)
{
if (mb_strpos($name, '.')) {
return $this->getAttributeByPath($name);
}
if ($this->attribute_map->hasKey($name)) {
return $this->attribute_map->getItem($name);
} else {
throw new RuntimeException('Type has no attribute: ' . $name);
}
} | php | {
"resource": ""
} |
q11572 | EntityType.createEntity | train | public function createEntity(array $data = [], EntityInterface $parent_entity = null, $apply_default_values = false)
{
$implementor = $this->getEntityImplementor();
if (!class_exists($implementor, true)) {
throw new InvalidTypeException(
"Unable to resolve the given entity implementor '$implementor' upon entity creation request."
);
}
return new $implementor($this, $data, $parent_entity, $apply_default_values);
} | php | {
"resource": ""
} |
q11573 | RedisHandler.writeCapped | train | protected function writeCapped(array $record)
{
if ($this->redisClient instanceof \Redis) {
$this->redisClient->multi()
->rpush($this->redisKey, $record["formatted"])
->ltrim($this->redisKey, -$this->capSize, -1)
->exec();
} else {
$redisKey = $this->redisKey;
$capSize = $this->capSize;
$this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) {
$tx->rpush($redisKey, $record["formatted"]);
$tx->ltrim($redisKey, -$capSize, -1);
});
}
} | php | {
"resource": ""
} |
q11574 | GameCurrencyService.sendBill | train | public function sendBill($bill, callable $onSuccess, callable $onFailure)
{
// return if the bill is not defined by creating one.
if ($bill === false) {
return;
}
$currencyEntry = new CurrencyEntry();
$currencyEntry->setBill($bill);
$currencyEntry->setSuccessCallback($onSuccess);
$currencyEntry->setFailureCallback($onFailure);
$this->currencyPlugin->sendBill($currencyEntry);
} | php | {
"resource": ""
} |
q11575 | GameCurrencyService.createBill | train | public function createBill($login, $amount, $receiver, $message)
{
$currencyEntry = new Gamecurrency();
$currencyEntry->setAmount($amount);
$currencyEntry->setSenderlogin($login);
$currencyEntry->setReceiverlogin($receiver);
$currencyEntry->setMessage($message);
$currencyEntry->setDatetime(new \DateTime());
try {
$currencyEntry->save();
return $currencyEntry;
} catch (\Exception $e) {
$this->logger->error("Error while creating bill", ["exception" => $e]);
$this->console->write('$f00 Fail.', true);
return false;
}
} | php | {
"resource": ""
} |
q11576 | ReservationForm.goToNextStep | train | public function goToNextStep(array $data, ReservationForm $form)
{
$reservation = $form->getReservation();
foreach ($data['Attendee'] as $attendeeID => $attendeeData) {
/** @var Attendee $attendee */
$attendee = Attendee::get()->byID($attendeeID);
// populate the attendees
foreach ($attendeeData as $field => $value) {
if (is_int($field)) {
$attendee->Fields()->add($field, array('Value' => $value));
} else {
$attendee->setField($field, $value);
}
}
$attendee->write();
// Set the main contact
if (isset($attendeeData['Main']) && (bool)$attendeeData['Main']) {
$reservation->setMainContact($attendeeID);
}
}
// add the tax modifier
$reservation->PriceModifiers()->add(TaxModifier::findOrMake($reservation));
$reservation->calculateTotal();
$reservation->write();
$this->extend('beforeNextStep', $data, $form);
return $this->nextStep();
} | php | {
"resource": ""
} |
q11577 | BaseOAuth20.validateRequest | train | function validateRequest($result)
{
$statusCodes = array(
"200" => "",
"304" => "Not Modified",
"400" => "Bad Request",
"401" => "Unauthorized: Authentication credentials were missing or incorrect",
"403" => "Forbidden: The request is understood, but it has been refused",
"404" => "Not Found",
"406" => "Not Acceptable",
"420" => "Enhance Your Calm",
"500" => "Internal Server Error",
"502" => "Bad Gateway",
"503" => "Service Unavailable"
);
if (array_key_exists($this->lastStatusCode(), $statusCodes))
return $this->lastStatusCode() . " " . $statusCodes[$this->lastStatusCode()];
else {
return $this->lastStatusCode() . " Unknow";
}
} | php | {
"resource": ""
} |
q11578 | ParentItem.addChild | train | public function addChild($class, $id, $label, $permission, $options =[])
{
if (is_string($id)) {
$id = explode('/', $id);
}
if (count($id) == 1) {
if (isset($this->childItems[$id[0]])) {
return $this->childItems[$id[0]];
}
$item = $this->itemBuilder->create(
$class,
$id[0],
$this->getPath() . '/' . $id[0],
$label,
$permission,
$options
);
$this->childItems[$id[0]] = $item;
return $item;
}
$parent = array_splice($id, 0, count($id) - 1);
return $this->getChild($parent)->addChild($class, $id, $label, $permission, $options);
} | php | {
"resource": ""
} |
q11579 | ParentItem.getChild | train | public function getChild($path)
{
if (is_string($path)) {
$path = explode('/', $path);
}
$remaining = array_splice($path, 1, count($path) - 1);
foreach ($this->childItems as $childItem) {
if ($childItem->getId() == $path[0]) {
if (empty($remaining)) {
return $childItem;
} elseif ($childItem instanceof ParentItem) {
return $childItem->getChild($remaining);
} else {
return null;
}
}
}
return null;
} | php | {
"resource": ""
} |
q11580 | ParentItem.isVisibleFor | train | public function isVisibleFor($login)
{
$personalVisibility = parent::isVisibleFor($login);
if (!$personalVisibility) {
return $personalVisibility;
}
foreach ($this->getChilds() as $childItem) {
if ($childItem->isVisibleFor($login)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q11581 | Ean.hasValidLength | train | public static function hasValidLength($value)
{
// Sanitize
$value = (int) $value;
$length = strlen($value);
// Validate
return !($length < 9 || $length > 13);
} | php | {
"resource": ""
} |
q11582 | Ean.toIsbn10 | train | public static function toIsbn10($ean, $onError = null)
{
// Sanitize
$ean = preg_replace('/[^0-9]/', '', $ean);
// Validate
if (!preg_match('/^978(\d{9})\d?$/', $ean, $found)) {
return $onError;
}
// Convert
$isbn = $found[1];
$isbn = static::withCheckDigitForIsbn10($isbn);
return $isbn ?: $onError;
} | php | {
"resource": ""
} |
q11583 | Convertor.prepareRules | train | public function prepareRules()
{
switch (self::baseClassName($this->input)) {
case 'FakturaVydana':
case 'Banka':
switch (self::baseClassName($this->output)) {
case 'FakturaVydana':
// Banka['typPohybuK' => 'typPohybu.prijem'] -> FakturaVydana['typDokl' => 'ZDD']
// $this->output->setDataValue('firma', \FlexiPeeHP\FlexiBeeRO::code( $this->input->getDataValue('firma')));
$this->rules = array_combine($this->commonItems(),
$this->commonItems());
unset($this->rules['stavUhrK']);
unset($this->rules['datUcto']);
unset($this->rules['datUcto']);
foreach (array_keys($this->output->getData()) as $colname) {
unset($this->rules[$colname]);
}
if ($this->input->getDataValue('typDokl') != $this->output->getDataValue('typDokl')) {
unset($this->rules['rada']);
}
foreach ($this->rules as $rule) {
if (preg_match('/^sum/', $rule)) {
unset($this->rules[$rule]);
}
}
$polozkyDokladu = new \FlexiPeeHP\FakturaVydanaPolozka();
$itemColnames = array_keys($polozkyDokladu->getColumnsInfo());
$this->rules['polozkyFaktury'] = self::removeRoColumns(array_combine($itemColnames,
$itemColnames), $polozkyDokladu);
break;
default :
throw new \Ease\Exception(sprintf(_('Unsupported Source document type %s'),
get_class($this->output)));
break;
}
break;
default:
throw new \Ease\Exception(sprintf(_('Unsupported Source document type %s'),
get_class($this->input)));
break;
}
} | php | {
"resource": ""
} |
q11584 | Convertor.convertDocument | train | public function convertDocument($keepId = false, $addExtId = false,
$keepCode = false, $handleAccountig = false)
{
if ($handleAccountig === false) {
unset($this->rules['ucetni']);
}
$this->convertItems($keepId, $addExtId, $keepCode, $handleAccountig);
} | php | {
"resource": ""
} |
q11585 | Convertor.convertSubitems | train | public function convertSubitems($columnToTake, $keepId = false,
$keepCode = false, $keepAccountig = false)
{
$subitemRules = $this->rules[$columnToTake];
if (self::isAssoc($this->input->data[$columnToTake])) {
$sourceData = [$this->input->data[$columnToTake]];
} else {
$sourceData = $this->input->getDataValue($columnToTake);
}
$typUcOp = $this->input->getDataValue('typUcOp');
foreach ($sourceData as $subItemData) {
foreach (array_keys($subItemData) as $subitemColumn) {
if (!array_key_exists($subitemColumn, $subitemRules)) {
unset($subItemData[$subitemColumn]);
}
}
if ($keepAccountig && array_key_exists('ucetni', $subItemData) && array_key_exists('ucetni',
$this->output->getData())) {
$subItemData['ucetni'] = $this->output->getDataValue('ucetni');
} else {
unset($subItemData['ucetni']);
}
if ($typUcOp) {
$subItemData['typUcOp'] = $typUcOp;
} else {
unset($subItemData['typUcOp']);
}
if ($keepCode === false) {
unset($subItemData['kod']);
}
if ($keepId === false) {
unset($subItemData['id']);
unset($subItemData['external-ids']);
}
$this->output->addArrayToBranch($subItemData);
}
} | php | {
"resource": ""
} |
q11586 | Convertor.convertItems | train | public function convertItems($keepId = false, $addExtId = true,
$keepCode = false, $handleAccounting = false)
{
if ($keepCode === false) {
unset($this->rules['kod']);
}
if ($keepId === false) {
unset($this->rules['id']);
}
foreach (self::removeRoColumns($this->rules, $this->output) as $columnToTake => $subitemColumns) {
if (is_array($subitemColumns)) {
if (!empty($this->input->getSubItems())) {
$this->convertSubitems($columnToTake, $keepId, $keepCode,$handleAccounting);
}
} else {
$this->output->setDataValue($columnToTake,
$this->input->getDataValue($columnToTake));
}
}
if ($addExtId) {
$this->output->setDataValue('id',
'ext:src:'.$this->input->getEvidence().':'.$this->input->getMyKey());
}
} | php | {
"resource": ""
} |
q11587 | Convertor.removeRoColumns | train | public static function removeRoColumns(array $rules, $engine)
{
foreach ($rules as $index => $subrules) {
if (is_array($subrules)) {
$eback = $engine->getEvidence();
$engine->setEvidence($engine->getEvidence().'-polozka');
$rules[$index] = self::removeRoColumns($subrules, $engine);
$engine->setEvidence($eback);
} else {
$columnInfo = $engine->getColumnInfo($subrules);
if ($columnInfo['isWritable'] == 'false') {
unset($rules[$index]);
}
}
}
return $rules;
} | php | {
"resource": ""
} |
q11588 | Convertor.commonItems | train | public function commonItems()
{
return array_intersect(array_keys($this->input->getColumnsInfo()),
array_keys($this->output->getColumnsInfo()));
} | php | {
"resource": ""
} |
q11589 | CommandBuilder.doBuild | train | protected function doBuild($user, $isApi = false)
{
$this->register($user, $isApi);
$this->container->setAlias(
$this->alias($user, $isApi),
$this->definition($user, $isApi)
);
return $this->container;
} | php | {
"resource": ""
} |
q11590 | VisitorFactory.createVisitors | train | final public function createVisitors(int $flags = 0): VisitorInterface
{
$flag = function (int $needle) use ($flags) {
return ($needle & $flags) == $needle;
};
$errorObj = new ErrorObject;
$container = new VisitorContainer($errorObj);
if (!$flag(self::VISITOR_IGNORE_BASIC_VALIDATION)) {
$container->addVisitor(new NumberVisitor($errorObj));
$container->addVisitor(new TextVisitor($errorObj));
}
if (!$flag(self::VISITOR_IGNORE_MESSAGES)) {
$container->addVisitor(new MessageVisitor($errorObj));
}
if (!$flag(self::VISITOR_IGNORE_DATES)) {
$container->addVisitor(new DateVisitor($errorObj));
}
if (!$flag(self::VISITOR_IGNORE_ACCOUNTS)) {
$container->addVisitor(
new AccountVisitor(
$errorObj,
new DelegatingFactory(new AccountFactory, new BankgiroFactory),
new BankgiroFactory
)
);
}
if (!$flag(self::VISITOR_IGNORE_AMOUNTS)) {
$container->addVisitor(new AmountVisitor($errorObj));
}
if (!$flag(self::VISITOR_IGNORE_IDS)) {
$container->addVisitor(
new StateIdVisitor(
$errorObj,
new OrganizationIdFactory,
new PersonalIdFactory(new CoordinationIdFactory(new NullIdFactory))
)
);
}
if (!$flag(self::VISITOR_IGNORE_STRICT_VALIDATION)) {
$container->addVisitor(new PaymentVisitor($errorObj));
$container->addVisitor(new PayeeVisitor($errorObj));
$container->addVisitor(new CountingVisitor($errorObj));
$container->addVisitor(new SummaryVisitor($errorObj));
}
return $container;
} | php | {
"resource": ""
} |
q11591 | NewsController.listAction | train | public function listAction()
{
// Getting the Site config "MelisDemoCms.config.php"
$siteConfig = $this->getServiceLocator()->get('config');
$siteConfig = $siteConfig['site']['MelisDemoCms'];
$siteDatas = $siteConfig['datas'];
/**
* Listing News using MelisCmsNewsListNewsPlugin
*/
$listNewsPluginView = $this->MelisCmsNewsListNewsPlugin();
$listNewsParameters = array(
'template_path' => 'MelisDemoCms/plugin/news-list',
'pageId' => $this->idPage,
'pageIdNews' => $siteDatas['news_details_page_id'],
'pagination' => array(
'nbPerPage' => 6
),
'filter' => array(
'column' => 'cnews_publish_date',
'order' => 'DESC',
'unpublish_filter' => true,
'site_id' => $siteDatas['site_id'],
)
);
// add generated view to children views for displaying it in the contact view
$this->view->addChild($listNewsPluginView->render($listNewsParameters), 'listNews');
$this->view->setVariable('renderMode', $this->renderMode);
$this->view->setVariable('idPage', $this->idPage);
return $this->view;
} | php | {
"resource": ""
} |
q11592 | NewsController.detailsAction | train | public function detailsAction()
{
// Getting the Site config "MelisDemoCms.config.php"
$siteConfig = $this->getServiceLocator()->get('config');
$siteConfig = $siteConfig['site']['MelisDemoCms'];
$siteDatas = $siteConfig['datas'];
$dateMax = date("Y-m-d H:i:s", strtotime("now"));
$listNewsPluginView = $this->MelisCmsNewsShowNewsPlugin();
$listNewsParameters = array(
'id' => 'newsDetails',
'template_path' => 'MelisDemoCms/plugin/news-details',
);
// add generated view to children views for displaying it in the contact view
$this->view->addChild($listNewsPluginView->render($listNewsParameters), 'newsDetails');
/**
* Generating Homepage Latest News slider using MelisCmsNewsLatestNewsPlugin Plugin
*/
$latestNewsPluginView = $this->MelisCmsNewsLatestNewsPlugin();
$latestNewsParameters = array(
'template_path' => 'MelisDemoCms/plugin/latest-news',
'pageIdNews' => $siteDatas['news_details_page_id'],
'filter' => array(
'column' => 'cnews_publish_date',
'order' => 'DESC',
'limit' => 10,
'unpublish_filter' => true,
'date_max' => null,
'site_id' => $siteDatas['site_id'],
)
);
// add generated view to children views for displaying it in the contact view
$this->view->addChild($latestNewsPluginView->render($latestNewsParameters), 'latestNews');
$this->view->setVariable('renderMode', $this->renderMode);
$this->view->setVariable('idPage', $this->idPage);
return $this->view;
} | php | {
"resource": ""
} |
q11593 | RemoveDeletedAggregatesListener.preFlush | train | public function preFlush(PreFlushEventArgs $event)
{
$entityManager = $event->getEntityManager();
$uow = $entityManager->getUnitOfWork();
foreach ($uow->getIdentityMap() as $class => $entities) {
foreach ($entities as $entity) {
if ($entity instanceof DeletableInterface) {
if ($entity->isDeleted()) {
$entityManager->remove($entity);
}
}
}
}
} | php | {
"resource": ""
} |
q11594 | OrkestraPdfBundle.initializeTcpdf | train | private function initializeTcpdf()
{
if (defined('K_TCPDF_EXTERNAL_CONFIG')) {
return;
}
define('K_TCPDF_EXTERNAL_CONFIG', true);
/**
* Installation path (/var/www/tcpdf/).
*/
define('K_PATH_MAIN', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.root_dir')));
/**
* URL path to tcpdf installation folder (http://localhost/tcpdf/).
*
* TODO: This should probably be some public path
*/
define('K_PATH_URL', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.root_dir')));
/**
* path for PDF fonts
* use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
*/
define('K_PATH_FONTS', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.fonts_dir')));
/**
* cache directory for temporary files (full path)
*/
define('K_PATH_CACHE', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.cache_dir')));
/**
* cache directory for temporary files (url path)
*/
define('K_PATH_URL_CACHE', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.cache_dir')));
/**
*images directory
*/
define('K_PATH_IMAGES', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.image_dir')));
/**
* blank image
*/
define('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
/**
* height of cell respect font height
*/
define('K_CELL_HEIGHT_RATIO', 1.25);
/**
* reduction factor for small font
*/
define('K_SMALL_RATIO', 2/3);
/**
* set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
*/
define('K_THAI_TOPCHARS', true);
/**
* if true allows to call TCPDF methods using HTML syntax
* IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
*/
define('K_TCPDF_CALLS_IN_HTML', false);
} | php | {
"resource": ""
} |
q11595 | MySql.getDsn | train | public function getDsn(): string
{
/*
MYSQL:
$connection = new \PDO('mysql:host=localhost;port=3306;dbname=test', $user, $pass,
array(
\PDO::ATTR_PERSISTENT => true
\PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_AUTOCOMMIT => FALSE,
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" // Set UTF8 as charset
)
);
*/
# Build the DSN
$_dsn = $this->getDriver().':'.
'host='.$this->getHost().($this->getPort()!=0 ? ';port='.$this->getPort() : '' ).
';dbname='.$this->getSchema().
';charset='.$this->getCharset();
# Set it
$this->setDsn($_dsn);
return $_dsn;
} | php | {
"resource": ""
} |
q11596 | ClassFinder.isAfterOpeningBracket | train | private function isAfterOpeningBracket(FoundClass $c)
{
for ($k = $c->from; $k >= 0; $k--) {
if (is_string($this->file->tokens[$k])
&& $this->file->tokens[$k] === '{'
) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q11597 | JWT.checkProvider | train | public function checkProvider($provider)
{
if (($prv = $this->payload()->get('prv')) === null) {
return true;
}
return $this->hashProvider($provider) === $prv;
} | php | {
"resource": ""
} |
q11598 | AntiSpam._encodeEntities | train | public function _encodeEntities($string)
{
$string = mb_convert_encoding($string, 'UTF-32', 'UTF-8');
$t = unpack("N*", $string);
$t = array_map(function ($n) {
return "&#$n;";
},
$t);
return implode("", $t);
} | php | {
"resource": ""
} |
q11599 | GroupVersionHydrator.hydrateArray | train | private function hydrateArray($array, $group, $version)
{
foreach ($array as $key => $value) {
$this->hydrate($value, $group, $version);
}
return $array;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.