_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q249100 | WorkflowServiceProvider.registerWorkflowRunnersHook | validation | private function registerWorkflowRunnersHook()
{
$this->app->afterResolving(function(WorkflowRunner $runner, $app)
{
$runner->setWorkflow($app['cerbero.workflow']);
});
} | php | {
"resource": ""
} |
q249101 | WorkflowServiceProvider.registerCommands | validation | private function registerCommands()
{
foreach ($this->commands as $command)
{
$name = ucfirst(last(explode('.', $command)));
$this->app->singleton($command, function($app) use($name)
{
return $app["Cerbero\Workflow\Console\Commands\\{$name}WorkflowCommand"];
});
}
} | php | {
"resource": ""
} |
q249102 | Drawer.draw | validation | public function draw($workflow)
{
$this->geometry->setCore($workflow);
$this->setPipesOfWorkflow($workflow);
$this->drawCenteredChar(static::NOCK);
$this->drawPipesBeginning();
$this->drawCore();
$this->drawPipesEnd();
$this->drawCenteredChar(static::PILE);
return $this->drawing;
} | php | {
"resource": ""
} |
q249103 | Drawer.setPipesOfWorkflow | validation | protected function setPipesOfWorkflow($workflow)
{
$pipes = $this->pipelines->getPipesByPipeline($workflow);
$this->pipes = array_map(function($pipe)
{
$chunks = explode('\\', $pipe);
return end($chunks);
}, $pipes);
$this->geometry->setPipes($this->pipes);
} | php | {
"resource": ""
} |
q249104 | Drawer.drawCenteredChar | validation | protected function drawCenteredChar($character)
{
$spaces = str_repeat(' ', $this->geometry->getHalfWidth());
$this->drawRow($spaces . $character);
} | php | {
"resource": ""
} |
q249105 | Drawer.drawPipesBeginning | validation | protected function drawPipesBeginning()
{
foreach ($this->pipes as $pipe)
{
$this->drawBorderTop();
$this->drawBordered(
$this->geometry->getSpacedPipe($pipe, static::NOCK, 'before()')
);
}
} | php | {
"resource": ""
} |
q249106 | Drawer.drawBordered | validation | protected function drawBordered($content)
{
$left = $this->geometry->getLeftBordersWith(static::BORDER_X);
$right = $this->geometry->getRightBordersWith(static::BORDER_X);
$this->drawRow($left.$content.$right);
} | php | {
"resource": ""
} |
q249107 | Drawer.drawBorderTop | validation | protected function drawBorderTop($isCore = false)
{
$crossroads = $isCore ? static::CROSSROADS_UP : static::CROSSROADS;
$this->drawBorder(static::BORDER_NW, $crossroads, static::BORDER_NE);
$this->geometry->increaseNesting();
} | php | {
"resource": ""
} |
q249108 | Drawer.drawBorder | validation | protected function drawBorder($left, $middle, $right)
{
$width = $this->geometry->getWidthButBorders();
$border = str_repeat(static::BORDER_Y, $width);
$this->replaceUtf8($border, $left, 0);
$this->replaceUtf8($border, $middle, floor($width / 2));
$this->replaceUtf8($border, $right, $width - 1);
$this->drawBordered($border);
} | php | {
"resource": ""
} |
q249109 | Drawer.replaceUtf8 | validation | private function replaceUtf8(&$original, $replacement, $position)
{
$start = mb_substr($original, 0, $position, "UTF-8");
$end = mb_substr($original, $position + 1, mb_strlen($original, 'UTF-8'), "UTF-8");
$original = $start . $replacement . $end;
} | php | {
"resource": ""
} |
q249110 | Drawer.drawCore | validation | protected function drawCore()
{
$this->drawBorderTop(true);
$this->drawBordered($this->geometry->getSpacedCore());
$this->drawBorderBottom(true);
} | php | {
"resource": ""
} |
q249111 | Drawer.drawBorderBottom | validation | protected function drawBorderBottom($isCore = false)
{
$this->geometry->decreaseNesting();
$crossroads = $isCore ? static::CROSSROADS_DOWN : static::CROSSROADS;
$this->drawBorder(static::BORDER_SW, $crossroads, static::BORDER_SE);
} | php | {
"resource": ""
} |
q249112 | Drawer.drawPipesEnd | validation | protected function drawPipesEnd()
{
$pipes = array_reverse($this->pipes);
foreach ($pipes as $pipe)
{
$this->drawBordered(
$this->geometry->getSpacedPipe($pipe, static::NOCK, 'after()')
);
$this->drawBorderBottom();
}
} | php | {
"resource": ""
} |
q249113 | Zenziva.send | validation | public function send(array $destinations, string $message): ?array
{
$this->checkConfig();
if (!empty($destinations)) {
$destination = $destinations[0];
}
$query = http_build_query([
'userkey' => $this->userkey,
'passkey' => $this->passkey,
'nohp' => $destination,
'pesan' => $message,
]);
$response = Request::get($this->baseUrl.'/smsapi.php?'.$query);
$xml = simplexml_load_string($response->body);
$body = json_decode(json_encode($xml), true);
if (!empty($body['message']) and $body['message']['status'] != 0) {
Log::error(sprintf('Zenziva: %s.', $body['message']['text']));
}
return [
'code' => $response->code,
'message' => ($response->code == 200) ? 'OK' : $body['message']['text'] ?? '',
'data' => $body,
];
} | php | {
"resource": ""
} |
q249114 | Zenziva.credit | validation | public function credit(): ?array
{
$this->checkConfig();
$query = http_build_query([
'userkey' => $this->userkey,
'passkey' => $this->passkey,
]);
$response = Request::get($this->baseUrl.'/smsapibalance.php?'.$query);
$xml = simplexml_load_string($response->body);
$body = json_decode(json_encode($xml), true);
return [
'code' => $response->code,
'message' => ($response->code == 200) ? 'OK' : $body['message']['text'] ?? '',
'data' => $body,
];
} | php | {
"resource": ""
} |
q249115 | Zenziva.checkConfig | validation | private function checkConfig(): void
{
if (empty($this->userkey)) {
Log::warning('Config "message.zenziva.userkey" is not defined.');
}
if (empty($this->passkey)) {
Log::warning('Config "message.zenziva.passkey" is not defined.');
}
} | php | {
"resource": ""
} |
q249116 | CreateWorkflowCommand.settleRepositoryIfNotExists | validation | protected function settleRepositoryIfNotExists()
{
$source = $this->pipelines->getSource();
if( ! $this->files->exists($source))
{
$this->pipelines->settle();
}
} | php | {
"resource": ""
} |
q249117 | CreateWorkflowCommand.generateRequestIfGuarded | validation | protected function generateRequestIfGuarded()
{
if( ! $this->option('unguard'))
{
$name = $this->inflector->getRequest();
$this->call('make:request', compact('name'));
}
} | php | {
"resource": ""
} |
q249118 | LogViewerServiceProvider.setupPackage | validation | protected function setupPackage()
{
$source = realpath(__DIR__.'/../config/logviewer.php');
$this->publishes([$source => config_path('logviewer.php')], 'config');
$this->publishes([
realpath(__DIR__.'/../assets/css') => public_path('assets/styles'),
realpath(__DIR__.'/../assets/js') => public_path('assets/scripts'),
], 'public');
$this->mergeConfigFrom($source, 'logviewer');
$this->loadViewsFrom(realpath(__DIR__.'/../views'), 'logviewer');
} | php | {
"resource": ""
} |
q249119 | LogViewerServiceProvider.registerLogFilesystem | validation | protected function registerLogFilesystem()
{
$this->app->singleton('logviewer.filesystem', function ($app) {
$files = $app['files'];
$path = $app['path.storage'].'/logs';
return new Filesystem($files, $path);
});
$this->app->alias('logviewer.filesystem', Filesystem::class);
} | php | {
"resource": ""
} |
q249120 | LogViewerServiceProvider.registerLogViewer | validation | protected function registerLogViewer()
{
$this->app->singleton('logviewer', function ($app) {
$factory = $app['logviewer.factory'];
$filesystem = $app['logviewer.filesystem'];
$data = $app['logviewer.data'];
return new LogViewer($factory, $filesystem, $data);
});
$this->app->alias('logviewer', LogViewer::class);
} | php | {
"resource": ""
} |
q249121 | LogViewerServiceProvider.registerLogViewerController | validation | protected function registerLogViewerController()
{
$this->app->bind(LogViewerController::class, function ($app) {
$perPage = $app['config']['logviewer.per_page'];
$middleware = $app['config']['logviewer.middleware'];
return new LogViewerController($perPage, $middleware);
});
} | php | {
"resource": ""
} |
q249122 | Filesystem.read | validation | public function read($date)
{
try {
return $this->files->get($this->path($date));
} catch (FileNotFoundException $e) {
throw new FilesystemException('There was an reading the log.');
}
} | php | {
"resource": ""
} |
q249123 | LogViewerController.getIndex | validation | public function getIndex()
{
$today = Carbon::today()->format('Y-m-d');
if (Session::has('success') || Session::has('error')) {
Session::reflash();
}
return Redirect::to('logviewer/'.$today.'/all');
} | php | {
"resource": ""
} |
q249124 | LogViewerController.getDelete | validation | public function getDelete($date)
{
try {
LogViewer::delete($date);
$today = Carbon::today()->format('Y-m-d');
return Redirect::to('logviewer/'.$today.'/all')
->with('success', 'Log deleted successfully!');
} catch (\Exception $e) {
return Redirect::to('logviewer/'.$date.'/all')
->with('error', 'There was an error while deleting the log.');
}
} | php | {
"resource": ""
} |
q249125 | LogViewerController.getShow | validation | public function getShow($date, $level = null)
{
$logs = LogViewer::logs();
if (!is_string($level)) {
$level = 'all';
}
$page = Input::get('page');
if (empty($page)) {
$page = '1';
}
$data = [
'logs' => $logs,
'date' => $date,
'url' => 'logviewer',
'data_url' => URL::route('logviewer.index').'/data/'.$date.'/'.$level.'?page='.$page,
'levels' => LogViewer::levels(),
'current' => $level,
];
return View::make('logviewer::show', $data);
} | php | {
"resource": ""
} |
q249126 | LogViewerController.getData | validation | public function getData($date, $level = null)
{
if (!is_string($level)) {
$level = 'all';
}
$data = LogViewer::data($date, $level);
$paginator = new Paginator($data, $this->perPage);
$path = (new \ReflectionClass($paginator))->getProperty('path');
$path->setAccessible(true);
$path->setValue($paginator, URL::route('logviewer.index').'/'.$date.'/'.$level);
if (count($data) > $paginator->perPage()) {
$log = array_slice($data, $paginator->firstItem() - 1, $paginator->perPage());
} else {
$log = $data;
}
return View::make('logviewer::data', compact('paginator', 'log'));
} | php | {
"resource": ""
} |
q249127 | Data.levels | validation | public function levels()
{
if (!$this->levels) {
$class = new ReflectionClass(new LogLevel());
$this->levels = $class->getConstants();
}
return $this->levels;
} | php | {
"resource": ""
} |
q249128 | Log.parse | validation | protected function parse()
{
$log = [];
$pattern = "/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/";
preg_match_all($pattern, $this->raw, $headings);
$data = preg_split($pattern, $this->raw);
if ($data[0] < 1) {
$trash = array_shift($data);
unset($trash);
}
foreach ($headings as $heading) {
for ($i = 0, $j = count($heading); $i < $j; $i++) {
foreach ($this->levels as $level) {
if ($this->level == $level || $this->level == 'all') {
if (strpos(strtolower($heading[$i]), strtolower('.'.$level))) {
$log[] = ['level' => $level, 'header' => $heading[$i], 'stack' => $data[$i]];
}
}
}
}
}
unset($headings);
unset($data);
return array_reverse($log);
} | php | {
"resource": ""
} |
q249129 | LogViewer.logs | validation | public function logs()
{
$logs = array_reverse($this->filesystem->files());
foreach ($logs as $index => $file) {
$logs[$index] = preg_replace('/.*(\d{4}-\d{2}-\d{2}).*/', '$1', basename($file));
}
return $logs;
} | php | {
"resource": ""
} |
q249130 | Factory.make | validation | public function make($date, $level = 'all')
{
$raw = $this->filesystem->read($date);
$levels = $this->levels;
return new Log($raw, $levels, $level);
} | php | {
"resource": ""
} |
q249131 | EnvoyerDeployCommand.getDefaultProjectHook | validation | protected function getDefaultProjectHook()
{
// Get default project handle.
$default = $this->config->get(self::CONFIG_DEFAULT);
// Return project hook value.
return $this->config->get(sprintf(self::CONFIG_PROJECT, $default));
} | php | {
"resource": ""
} |
q249132 | EnvoyerDeployCommand.triggerDeploy | validation | protected function triggerDeploy($project)
{
// Ensure we have a project hook.
if (!$project) {
throw new InvalidArgumentException('Incorrect project hook.');
}
// Trigger the deploy hook.
file_get_contents(sprintf(self::DEPLOY_URL, $project));
// Output message.
$this->info('Deployment request successful!');
} | php | {
"resource": ""
} |
q249133 | BaseSchema.set | validation | public function set($property_name, $value)
{
$this->validateProperty($property_name, $value);
$this->data[$property_name] = $value;
return $this;
} | php | {
"resource": ""
} |
q249134 | BaseSchema.add | validation | public function add($property_name, $value)
{
$this->validateProperty($property_name, $value);
$this->data[$property_name][] =& $value;
return $this;
} | php | {
"resource": ""
} |
q249135 | BaseSchema.parseData | validation | private function parseData($data)
{
foreach ($data as $property_name => $property) {
//I think the best way to handle this, will at least always be consistent
//without writing the same code twice.
$types_to_try = [];
//Collect regular props
if (isset(static::$properties[$property_name])) {
$types_to_try = array_merge($types_to_try, static::$properties[$property_name]);
}
//Collect pattern props
foreach (static::$pattern_properties as $pattern_property) {
$types_to_try = array_merge($types_to_try, $pattern_property);
}
//Collect additional props
if (is_array(static::$additional_properties)) {
$types_to_try = array_merge($types_to_try, static::$additional_properties);
}
if (is_array($property)) {
foreach ($property as $property_element) {
$this->add($property_name, self::tryToCast($types_to_try, $property_element));
}
} else {
$this->set($property_name, self::tryToCast($types_to_try, $property));
}
}
} | php | {
"resource": ""
} |
q249136 | UploaderManager.extend | validation | public function extend($provider, Closure $callback)
{
if ($this->isProviderAliasExists($provider)) {
throw new InvalidArgumentException("Alias provider is already reserved [{$provider}]");
}
$this->customProviders[$provider] = $callback;
return $this;
} | php | {
"resource": ""
} |
q249137 | UploaderManager.from | validation | public function from($provider = null)
{
$provider = $provider ?: $this->getDefaultProvider();
return new Uploader(
$this->app->make('config'), $this->app->make('filesystem'), $this->createProviderInstance($provider)
);
} | php | {
"resource": ""
} |
q249138 | UploaderManager.createProviderInstance | validation | protected function createProviderInstance($provider)
{
if (! $this->isProviderAliasExists($provider)) {
throw new InvalidArgumentException("File provider [{$provider}] is invalid.");
}
if (! isset($this->resolvedProviders[$provider])) {
$this->resolvedProviders[$provider] = isset($this->customProviders[$provider])
? $this->callCustomProvider($provider)
: $this->app->make($this->providers[$provider]);
}
return $this->resolvedProviders[$provider];
} | php | {
"resource": ""
} |
q249139 | UploaderManager.dynamicFrom | validation | protected function dynamicFrom($from)
{
$provider = Str::snake(substr($from, 4));
return $this->from($provider);
} | php | {
"resource": ""
} |
q249140 | UploaderManager.isProviderAliasExists | validation | protected function isProviderAliasExists($provider)
{
return array_key_exists($provider, $this->providers) || array_key_exists($provider, $this->customProviders);
} | php | {
"resource": ""
} |
q249141 | Uploader.upload | validation | public function upload($file, Closure $callback = null)
{
$uploadedFile = $this->runUpload($file);
if (! $uploadedFile) {
return false;
}
if ($callback) {
$callback($uploadedFile);
}
return true;
} | php | {
"resource": ""
} |
q249142 | Uploader.runUpload | validation | protected function runUpload($file)
{
$this->provider->setFile($file);
if (! $this->provider->isValid()) {
throw new InvalidFileException("Given file [{$file}] is invalid.");
}
$filename = $this->getFullFileName($this->provider);
if ($this->filesystem->disk($this->disk)->put($filename, $this->provider->getContents(), $this->getVisibility())) {
return $filename;
}
return false;
} | php | {
"resource": ""
} |
q249143 | Uploader.getFullFileName | validation | protected function getFullFileName(Provider $provider)
{
$folder = $this->folder ? rtrim($this->folder, '/').'/' : '';
if ($this->filename) {
$filename = $this->filename;
} else {
$filename = md5(uniqid(microtime(true), true));
}
return $folder.$filename.'.'.$provider->getExtension();
} | php | {
"resource": ""
} |
q249144 | Uploader.dynamicUploadTo | validation | protected function dynamicUploadTo($uploadTo)
{
$disk = Str::snake(substr($uploadTo, 8));
return $this->uploadTo($disk);
} | php | {
"resource": ""
} |
q249145 | Shape.renderSides | validation | protected function renderSides($sides)
{
$lines = [];
$lines[] = Html::beginTag('div', $this->sidesOptions);
foreach($sides as $side) {
if(!array_key_exists('content', $side)) {
throw new InvalidConfigException("The 'content' option is required per sides");
}
$options = ArrayHelper::getValue($side, 'options', []);
Ui::addCssClass($options, 'side');
$active = ArrayHelper::getValue($side, 'active', false);
if($active === true) {
Ui::addCssClass($options, 'active');
}
$lines[] = Html::tag('div', $side['content'], $options);
}
$lines[] = Html::endTag('div');
return implode("\n", $lines);
} | php | {
"resource": ""
} |
q249146 | SideBar.renderToggleButton | validation | public function renderToggleButton()
{
if ($this->toggleButton !== false) {
$tag = ArrayHelper::remove($this->toggleButton, 'tag', 'div');
$label = ArrayHelper::remove($this->toggleButton, 'label', Html::tag('i', '', ['class' => 'content icon']));
Html::addCssClass($this->toggleButton, 'ui');
Html::addCssClass($this->toggleButton, 'launch-sidebar icon');
Html::addCssClass($this->toggleButton, 'button');
Html::addCssClass($this->toggleButton, 'fixed');
Html::addCssClass($this->toggleButton, 'attached');
if ($this->position === static::POS_LEFT) {
$position = static::POS_RIGHT;
} else {
$position = static::POS_LEFT;
}
Html::addCssClass($this->toggleButton, $position);
$view = $this->getView();
DosAmigosAsset::register($view);
$view->registerJs('dosamigos.semantic.init();');
return Html::tag($tag, $label, $this->toggleButton);
} else {
return null;
}
} | php | {
"resource": ""
} |
q249147 | Menu.renderMenu | validation | protected function renderMenu($items, $parentItem)
{
$options = ArrayHelper::getValue($parentItem, 'options');
$label = $this->getLabel($parentItem);
$items = Html::tag('div', $this->renderItems($items), ['class' => 'menu']);
Html::addCssClass($options, 'ui');
Html::addCssClass($options, 'header');
return
Html::tag(
'div',
Html::tag('div', $label, $options) . $items,
['class' => 'item']
);
} | php | {
"resource": ""
} |
q249148 | Menu.getLabel | validation | protected function getLabel($item)
{
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
return $encodeLabel ? Html::encode($item['label']) : $item['label'];
} | php | {
"resource": ""
} |
q249149 | Dropdown.renderDropdown | validation | protected function renderDropdown()
{
$lines = [];
$lines[] = $this->encodeText ? Html::encode($this->text) : $this->text;
if ($this->icon && is_string($this->icon)) {
$lines[] = $this->icon;
}
$lines[] = $this->renderItems($this->items, $this->options, $this->displaySearchInput);
return Html::tag('div', implode("\n", $lines), $this->options);
} | php | {
"resource": ""
} |
q249150 | Dropdown.renderSearchInput | validation | protected function renderSearchInput()
{
$lines = [];
$lines[] = Html::beginTag('div', ['class' =>'ui icon search input']);
$lines[] = Html::tag('i', '', ['class' => 'search icon']);
$lines[] = Html::input('text', $this->getId() . '-search', '', $this->searchInputOptions);
$lines[] = Html::endTag('div');
$lines[] = Html::tag('div', '', ['class' => 'divider']);
return implode("\n", $lines);
} | php | {
"resource": ""
} |
q249151 | Widget.init | validation | public function init()
{
parent::init();
Html::addCssClass($this->options, 'ui');
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
$this->registerTranslations();
} | php | {
"resource": ""
} |
q249152 | Widget.registerPlugin | validation | protected function registerPlugin($name)
{
$view = $this->getView();
SemanticUiPluginAsset::register($view);
$selector = $this->selector ? : '#' . $this->options['id'];
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
$js = "jQuery('$selector').$name($options);";
$view->registerJs($js);
}
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
$handler = $handler instanceof JsExpression ? $handler : new JsExpression($handler);
$js[] = "jQuery('$selector').$name('setting', '$event', $handler);";
}
$view->registerJs(implode("\n", $js));
}
} | php | {
"resource": ""
} |
q249153 | Modal.renderToggleButton | validation | protected function renderToggleButton()
{
if ($this->toggleButton !== false) {
$tag = ArrayHelper::remove($this->toggleButton, 'tag', 'div');
$label = ArrayHelper::remove($this->toggleButton, 'label', 'Show');
if ($tag === 'button' && !isset($this->toggleButton['type'])) {
$this->toggleButton['type'] = 'button';
}
if ($tag === 'div') {
Html::addCssClass($this->toggleButton, 'ui');
Html::addCssClass($this->toggleButton, 'button');
}
$view = $this->getView();
DosAmigosAsset::register($view);
$view->registerJs('dosamigos.semantic.init();');
return Html::tag($tag, $label, $this->toggleButton);
} else {
return null;
}
} | php | {
"resource": ""
} |
q249154 | Checkbox.renderInput | validation | protected function renderInput()
{
return $this->hasModel()
? Html::activeCheckbox($this->model, $this->attribute, $this->options)
: Html::checkbox($this->name, $this->checked, $this->options);
} | php | {
"resource": ""
} |
q249155 | Checkbox.renderLabel | validation | protected function renderLabel()
{
$label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
return $this->hasModel()
? Html::activeLabel($this->model, $this->attribute, $this->labelOptions)
: Html::label($label, $this->getId(), $this->labelOptions);
} | php | {
"resource": ""
} |
q249156 | Message.registerClientScript | validation | public function registerClientScript()
{
if ($this->closeIcon !== false) {
$view = $this->getView();
DosAmigosAsset::register($view);
$view->registerJs("dosamigos.semantic.initMessageCloseButtons();");
}
} | php | {
"resource": ""
} |
q249157 | Message.initOptions | validation | public function initOptions()
{
Ui::addCssClasses($this->options, ['ui', 'message']);
if (!empty($this->header) && isset($this->header['options'])) {
Ui::addCssClass($this->header['options'], 'header');
}
if (isset($this->icon)) {
Ui::addCssClass($this->options, 'icon');
}
} | php | {
"resource": ""
} |
q249158 | Radio.renderInput | validation | protected function renderInput()
{
return $this->hasModel()
? Html::activeRadio($this->model, $this->attribute, $this->options)
: Html::radio($this->name, $this->checked, $this->options);
} | php | {
"resource": ""
} |
q249159 | Element.labelGroup | validation | public static function labelGroup($labels = [], $options = [])
{
Ui::addCssClasses($options, ['ui', 'labels']);
$lines = [];
foreach ($labels as $label) {
$content = ArrayHelper::remove($label, 'content');
$lines[] = static::label($content, $label);
}
return Ui::tag('div', implode("\n", $lines), $options);
} | php | {
"resource": ""
} |
q249160 | Search.renderInput | validation | protected function renderInput($options = [], $resultsOptions = [])
{
Html::addCssClass($options, 'prompt');
$lines = [];
$input = $this->hasModel()
? Html::activeTextInput($this->model, $this->attribute, $options)
: Html::textInput($this->name, $this->value, $options);
if (!empty($this->displayIcon)) {
$lines[] = Html::beginTag('div', ['class' => 'ui icon input']);
$lines[] = $input;
$lines[] = Html::tag('i', '', ['class' => 'icon search']);
$lines[] = Html::endTag('div');
} else {
$lines[] = $input;
}
$lines[] = Html::tag('div', '', $resultsOptions);
return implode("\n", $lines);
} | php | {
"resource": ""
} |
q249161 | Unzip.openZipFile | validation | private function openZipFile($zipFile)
{
$zipArchive = new \ZipArchive;
if ($zipArchive->open($zipFile) !== true) {
throw new \Exception('Error opening '.$zipFile);
}
return $zipArchive;
} | php | {
"resource": ""
} |
q249162 | Unzip.extractFilenames | validation | private function extractFilenames(\ZipArchive $zipArchive)
{
$filenames = array();
$fileCount = $zipArchive->numFiles;
for ($i = 0; $i < $fileCount; $i++) {
if (($filename = $this->extractFilename($zipArchive, $i)) !== false) {
$filenames[] = $filename;
}
}
return $filenames;
} | php | {
"resource": ""
} |
q249163 | Unzip.isValidPath | validation | private function isValidPath($path)
{
$pathParts = explode('/', $path);
if (!strncmp($path, '/', 1) ||
array_search('..', $pathParts) !== false ||
strpos($path, ':') !== false)
{
return false;
}
return true;
} | php | {
"resource": ""
} |
q249164 | Unzip.extractFilename | validation | private function extractFilename(\ZipArchive $zipArchive, $fileIndex)
{
$entry = $zipArchive->statIndex($fileIndex);
// convert Windows directory separator to Unix style
$filename = str_replace('\\', '/', $entry['name']);
if ($this->isValidPath($filename)) {
return $filename;
}
throw new \Exception('Invalid filename path in zip archive');
} | php | {
"resource": ""
} |
q249165 | Unzip.extract | validation | public function extract($zipFile, $targetPath)
{
$zipArchive = $this->openZipFile($zipFile);
$targetPath = $this->fixPath($targetPath);
$filenames = $this->extractFilenames($zipArchive);
if ($zipArchive->extractTo($targetPath, $filenames) === false) {
throw new \Exception($this->getError($zipArchive->status));
}
$zipArchive->close();
return $filenames;
} | php | {
"resource": ""
} |
q249166 | Assetter.registerPlugin | validation | public function registerPlugin(PluginInterface $plugin)
{
$plugin->register($this);
$this->plugins[] = $plugin;
return $this;
} | php | {
"resource": ""
} |
q249167 | Assetter.fireEvent | validation | public function fireEvent($event, array $args = [])
{
if(isset($this->eventListeners[$event]) === false)
return $args;
foreach($this->eventListeners[$event] as $listener)
call_user_func_array($listener, $args);
return $args;
} | php | {
"resource": ""
} |
q249168 | Assetter.registerNamespace | validation | public function registerNamespace($ns, $def)
{
list($ns, $def) = $this->fireEvent('namespace.register', [ $ns, $def ]);
$this->namespaces[$ns] = $def;
return $this;
} | php | {
"resource": ""
} |
q249169 | Assetter.unregisterNamespace | validation | public function unregisterNamespace($ns)
{
list($ns) = $this->fireEvent('namespace.unregister', [ $ns ]);
unset($this->namespaces[$ns]);
return $this;
} | php | {
"resource": ""
} |
q249170 | Assetter.setDefaultGroup | validation | public function setDefaultGroup($defaultGroup)
{
list($defaultGroup) = $this->fireEvent('default-group.set', [ $defaultGroup ]);
$this->defaultGroup = $defaultGroup;
return $this;
} | php | {
"resource": ""
} |
q249171 | Assetter.setCollection | validation | public function setCollection(array $collection)
{
list($collection) = $this->fireEvent('collection.set', [ $collection ]);
$this->collection = [];
foreach($collection as $asset)
{
$this->appendToCollection($asset);
}
return $this;
} | php | {
"resource": ""
} |
q249172 | Assetter.appendToCollection | validation | public function appendToCollection(array $data)
{
list($data) = $this->fireEvent('append-to-collection', [ $data ]);
$files = [];
if(isset($data['files']['js']) && is_array($data['files']['js']))
$files['js'] = $this->resolveFilesList($data['files']['js'], isset($data['revision']) ? $data['revision'] : null);
if(isset($data['files']['css']) && is_array($data['files']['css']))
$files['css'] = $this->resolveFilesList($data['files']['css'], isset($data['revision']) ? $data['revision'] : null);
$this->collection[] = [
'order' => isset($data['order']) ? $data['order'] : 0,
'name' => isset($data['name']) ? $data['name'] : uniqid(),
'files' => $files,
'group' => isset($data['group']) ? $data['group'] : $this->defaultGroup,
'require' => isset($data['require']) ? $data['require'] : []
];
return $this;
} | php | {
"resource": ""
} |
q249173 | Assetter.load | validation | public function load($data)
{
list($data) = $this->fireEvent('load', [ $data ]);
if(is_array($data))
{
$this->loadFromArray($data);
}
else
{
$this->loadFromCollection($data);
}
return $this;
} | php | {
"resource": ""
} |
q249174 | Assetter.loadFromArray | validation | public function loadFromArray(array $data)
{
list($data) = $this->fireEvent('load-from-array', [ $data ]);
$files = [];
if(isset($data['files']['js']) && is_array($data['files']['js']))
$files['js'] = $this->resolveFilesList($data['files']['js'], isset($data['revision']) ? $data['revision'] : null);
if(isset($data['files']['css']) && is_array($data['files']['css']))
$files['css'] = $this->resolveFilesList($data['files']['css'], isset($data['revision']) ? $data['revision'] : null);
$item = [
'order' => isset($data['order']) ? $data['order'] : 0,
'name' => isset($data['name']) ? $data['name'] : uniqid(),
'files' => $files,
'group' => isset($data['group']) ? $data['group'] : $this->defaultGroup,
'require' => isset($data['require']) ? $data['require'] : []
];
if(isset($item['files']['js']) && is_array($item['files']['js']))
$item['files']['js'] = $this->applyNamespaces($item['files']['js']);
if(isset($item['files']['css']) && is_array($item['files']['css']))
$item['files']['css'] = $this->applyNamespaces($item['files']['css']);
$this->loaded[] = $item;
if(isset($item['require']) && is_array($item['require']))
{
foreach($item['require'] as $name)
{
$this->loadFromCollection($name);
}
}
return $this;
} | php | {
"resource": ""
} |
q249175 | Assetter.alreadyLoaded | validation | public function alreadyLoaded($name)
{
foreach($this->loaded as $item)
{
if($item['name'] === $name)
{
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q249176 | Sms.send | validation | public function send($from, $to, $msg)
{
$opt = array(
'sender' => $from,
'receivers' => array($to),
'message' => $msg
);
return $this->createJob($opt);
} | php | {
"resource": ""
} |
q249177 | Sms.getSeeOffers | validation | public function getSeeOffers($countryDestination, $countryCurrencyPrice, $quantity)
{
return json_decode(self::getClient()->getSeeOffers($this->domain, $countryDestination, $countryCurrencyPrice, $quantity));
} | php | {
"resource": ""
} |
q249178 | ServerClient.createBackupFTPAccess | validation | public function createBackupFTPAccess($domain, $ipBlock)
{
// $domain = (string)$domain;
// $ipBlock= (string)$ipBlock;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
if (!$ipBlock)
throw new BadMethodCallException('Parameter $ipBlock is missing.');
$payload = array(
'ftp' => (1==1), // why does this want a class specific variant of $true??
'ipBlock' => $ipBlock,
'nfs' => (1==0),
'cifs' => (1==0)
);
try {
$r = $this->post('dedicated/server/' . $domain . '/features/backupFTP/access', array('Content-Type' => 'application/json;charset=UTF-8'), json_encode($payload))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249179 | ServerClient.getBackupFTPaccessBlock | validation | public function getBackupFTPaccessBlock($domain,$ipBlock)
{
$domain = (string)$domain;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
if (!$ipBlock)
throw new BadMethodCallException('Parameter $ipBlock is missing.');
try {
$r = $this->get('dedicated/server/' . $domain . '/features/backupFTP/access/'.urlencode($ipBlock))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249180 | ServerClient.deleteBackupFTPaccessBlock | validation | public function deleteBackupFTPaccessBlock($domain,$ipBlock)
{
$domain = (string)$domain;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
if (!$ipBlock)
throw new BadMethodCallException('Parameter $ipBlock is missing.');
try {
$r = $this->delete('dedicated/server/' . $domain . '/features/backupFTP/access/'.urlencode($ipBlock))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249181 | ServerClient.setBackupFTPaccessBlock | validation | public function setBackupFTPaccessBlock($domain,$ipBlock, $ftp, $nfs, $cifs)
{
$domain = (string)$domain;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
if (!$ipBlock)
throw new BadMethodCallException('Parameter $ipBlock is missing.');
if (!$ftp)
throw new BadMethodCallException('Parameter $ftp is missing.');
if (!$nfs)
throw new BadMethodCallException('Parameter $nfs is missing.');
if (!$cifs)
throw new BadMethodCallException('Parameter $cifs is missing.');
$payload = array('ftp' => ($ftp=='on') , 'nfs' => ($nfs=='on') , 'cifs' => ($cifs=='on') );
try {
$r = $this->put('dedicated/server/' . $domain . '/features/backupFTP/access/'.urlencode($ipBlock),array('Content-Type' => 'application/json;charset=UTF-8'), json_encode($payload))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249182 | ServerClient.setBootDevice | validation | public function setBootDevice($domain, $currentState, $bootDevice)
{
//var_dump($currentState);
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
$domain = (string)$domain;
if (!$bootDevice)
throw new BadMethodCallException('Parameter $bootDevice is missing.');
$bootDevice = (string)$bootDevice;
$payload = array(
'bootId' => $bootDevice,
'monitoring' => $currentState->monitoring,
'rootDevice' => $currentState->rootDevice
);
// 'state' =>$currentState->state
// dont try and set 'state' unless the machine is in 'hacked' state.... ugh
try {
$r = $this->put('dedicated/server/' . $domain, array('Content-Type' => 'application/json;charset=UTF-8'), json_encode($payload))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249183 | ServerClient.addSecondaryDnsDomains | validation | public function addSecondaryDnsDomains($domain, $domain2add, $ip){
$domain = (string)$domain;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
$domain2add = (string)$domain2add;
if (!$domain2add)
throw new BadMethodCallException('Parameter $domain2add is missing.');
$ip = (string)$ip;
if (!$ip)
throw new BadMethodCallException('Parameter $ip is missing.');
$payload = array("domain"=>$domain2add, "ip"=>$ip);
try {
$r = $this->post('dedicated/server/'.$domain.'/secondaryDnsDomains', array('Content-Type' => 'application/json;charset=UTF-8'), json_encode($payload))->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
} | php | {
"resource": ""
} |
q249184 | ServerClient.deleteSecondaryDnsDomains | validation | public function deleteSecondaryDnsDomains($domain, $domain2delete){
$domain = (string)$domain;
if (!$domain)
throw new BadMethodCallException('Parameter $domain is missing.');
$domain2delete = (string)$domain2delete;
if (!$domain2delete)
throw new BadMethodCallException('Parameter $domain2getInfo is missing.');
try {
$r = $this->delete('dedicated/server/' . $domain . '/secondaryDnsDomains/'.$domain2delete)->send();
} catch (\Exception $e) {
throw new ServerException($e->getMessage(), $e->getCode(), $e);
}
} | php | {
"resource": ""
} |
q249185 | XdslClient.ipGetRange | validation | public function ipGetRange($id, $ip)
{
if (!$id)
throw new BadMethodCallException('Missing parameter $id.');
if (!$ip)
throw new BadMethodCallException('Missing parameter $ip.');
return json_decode($this->getIpProperties($id, $ip))->range;
} | php | {
"resource": ""
} |
q249186 | XdslClient.ipDeleteMonitoringNotification | validation | public function ipDeleteMonitoringNotification($id, $ip, $notificationId)
{
if (!$id)
throw new BadMethodCallException('Missing parameter $id.');
if (!$ip)
throw new BadMethodCallException('Missing parameter $ip.');
if (!$notificationId)
throw new BadMethodCallException('Missing parameter $notificationId.');
try {
$r = $this->delete('xdsl/' . $id . '/ips/' . $ip . '/monitoringNotifications/' . $notificationId)->send();
} catch (\Exception $e) {
throw new XdslException($e->getMessage(), $e->getCode(), $e);
}
return;
} | php | {
"resource": ""
} |
q249187 | XdslClient.getLineProperties | validation | public function getLineProperties($id, $line)
{
if (!$id)
throw new BadMethodCallException('Missing parameter $id.');
if (!$line)
throw new BadMethodCallException('Missing parameter $line.');
try {
$r = $this->get('xdsl/' . $id . '/lines/' . $line)->send();
} catch (\Exception $e) {
throw new XdslException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249188 | XdslClient.lineResetDslamPort | validation | public function lineResetDslamPort($id, $line)
{
if (!$id)
throw new BadMethodCallException('Missing parameter $id.');
if (!$line)
throw new BadMethodCallException('Missing parameter $line.');
try {
$r = $this->post('xdsl/' . $id . '/lines/' . $line . '/resetDslamPort')->send();
} catch (\Exception $e) {
throw new XdslException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249189 | XdslClient.getPppLoginByMail | validation | public function getPppLoginByMail($id){
if (!$id)
throw new BadMethodCallException('Missing parameter $id.');
try {
$this->post('xdsl/' . $id . '/requestPPPLoginMail')->send();
} catch (\Exception $e) {
throw new XdslException($e->getMessage(), $e->getCode(), $e);
}
return;
} | php | {
"resource": ""
} |
q249190 | Cdn.updateDomainProperties | validation | public function updateDomainProperties($domain, $properties)
{
self::getClient()->updateDomainProperties($this->sn, $domain, $properties);
} | php | {
"resource": ""
} |
q249191 | Cdn.orderBackend | validation | public function orderBackend($nbBackend, $duration)
{
return json_decode(self::getClient()->orderBackend($this->sn, $nbBackend, $duration));
} | php | {
"resource": ""
} |
q249192 | Cdn.orderCacheRule | validation | public function orderCacheRule($nbCacheRule, $duration)
{
return json_decode(self::getClient()->orderCacheRule($this->sn, $nbCacheRule, $duration));
} | php | {
"resource": ""
} |
q249193 | IPClient.setReverseProperties | validation | public function setReverseProperties($ipblock,$ip,$reverse)
{
if (!$ipblock)
throw new BadMethodCallException('Parameter $ipblock is missing.');
if (!$ip)
throw new BadMethodCallException('Parameter $ip is missing.');
// if (!$reverse)
// throw new BadMethodCallException('Parameter $reverse is missing.');
// if (inet_pton($ip) !== false)
// throw new BadMethodCallException('Parameter $ip is invalid.');
// if (substr($reverse, -1) != ".")
// throw new BadMethodCallException('Parameter $reverse must end in ".".');
$payload = array(
'ipReverse' => $ip,
'reverse' => $reverse
);
try {
$r = $this->post('ip/' . urlencode($ipblock) . '/reverse', array('Content-Type' => 'application/json;charset=UTF-8'), json_encode($payload))->send();
} catch (\Exception $e) {
throw new IpException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249194 | IPClient.getSpam | validation | public function getSpam($ipblock, $spamstate)
{
if (!$ipblock)
throw new BadMethodCallException('Parameter $ipblock is missing.');
if (!$spamstate)
throw new BadMethodCallException('Parameter $spamstate is missing.');
switch ($spamstate) {
case "blockedForSpam":
case "unblocked":
case "unblocking":
break;
default:
throw new BadMethodCallException('Parameter $spamstate is invalid.');
}
try {
$r = $this->get('ip/' . urlencode($ipblock) . '/spam/?state=' . $spamstate)->send();
} catch (\Exception $e) {
throw new IpException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249195 | IPClient.getSpamStats | validation | public function getSpamStats($ipblock, $spamstate, $fromdate, $todate)
{
if (!$ipblock)
throw new BadMethodCallException('Parameter $ipblock is missing.');
if (!$ipv4)
throw new BadMethodCallException('Parameter $ipv4 is missing.');
if (!$fromdate)
throw new BadMethodCallException('Parameter $fromdate is missing.');
if (!$todate)
throw new BadMethodCallException('Parameter $todate is missing.');
try {
$r = $this->get('ip/' . urlencode($ipblock) . '/spam/' . $ipv4 .'/stats?from='.urlencode($fromdate).'&to='.urlencode($todate))->send();
} catch (\Exception $e) {
throw new IpException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249196 | IPClient.setUnblockSpam | validation | public function setUnblockSpam($ipblock,$ipv4)
{
if (!$ipblock)
throw new BadMethodCallException('Parameter $ipblock is missing.');
if (!$ipv4)
throw new BadMethodCallException('Parameter $ipv4 is missing.');
try {
$r = $this->post('ip/' . urlencode($ipblock) . '/spam/' . $ipv4 .'/unblock' )->send();
} catch (\Exception $e) {
throw new IpException($e->getMessage(), $e->getCode(), $e);
}
return $r->getBody(true);
} | php | {
"resource": ""
} |
q249197 | Telephony.getBillingAccountServices | validation | public function getBillingAccountServices()
{
$serviceList = json_decode(self::getClient()->getBillingAccountServices($this->billingAccount));
$services = array();
foreach ($serviceList as $service)
{
$services[] = new TelephonyAccountService($service, $this);
}
return $services;
} | php | {
"resource": ""
} |
q249198 | Xdsl.getProperties | validation | public function getProperties()
{
$this->properties = json_decode(self::getClient()->getProperties($this->id));
return $this->properties;
} | php | {
"resource": ""
} |
q249199 | Xdsl.isIpv6Enabled | validation | public function isIpv6Enabled($forceReload = false)
{
if (!$this->properties || $forceReload)
$this->getProperties();
return $this->properties->ipv6Enabled;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.