_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q10800 | Smarty_CacheResource_Mysql.delete | train | protected function delete($name, $cache_id, $compile_id, $exp_time)
{
// delete the whole cache
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache');
return - 1;
}
// build the filter
$where = array();
// equal test name
if ($name !== null) {
$where[] = 'name = ' . $this->db->quote($name);
}
// equal test compile_id
if ($compile_id !== null) {
$where[] = 'compile_id = ' . $this->db->quote($compile_id);
}
// range test expiration time
if ($exp_time !== null) {
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
return $query->rowCount();
} | php | {
"resource": ""
} |
q10801 | Iframe.render | train | public function render($src, $class = '', $id = '', array $attrs = array())
{
$attrs = array_merge(array(
'frameborder' => 0,
'content' => null,
'tag' => 'iframe',
'src' => Str::trim($src)
), $attrs);
$attrs = $this->_cleanAttrs($attrs);
$content = $attrs['content'];
unset($attrs['content']);
return Html::_('tag')->render($content, Str::trim($class), Str::trim($id), $attrs);
} | php | {
"resource": ""
} |
q10802 | BestCheckpoints.onLocalRecordsLoaded | train | public function onLocalRecordsLoaded($records, BaseRecords $baseRecords)
{
if (!$this->checkRecordPlugin($baseRecords)) {
return;
}
if (count($records) > 0) {
$this->updater->setLocalRecord($records[0]->getPlayer()->getNickname(), $records[0]->getCheckpoints());
} else {
$this->updater->setLocalRecord("-", []);
}
} | php | {
"resource": ""
} |
q10803 | RokkaFormatter.formatStackOperationOptions | train | public function formatStackOperationOptions(array $settings)
{
$data = [];
foreach ($settings as $name => $value) {
$data[] = $name.':'.$value;
}
return implode(' | ', $data);
} | php | {
"resource": ""
} |
q10804 | RokkaFormatter.outputImageInfo | train | public function outputImageInfo(SourceImage $sourceImage, OutputInterface $output)
{
$output->writeln([
' Hash: <info>'.$sourceImage->hash.'</info>',
' Organization: <info>'.$sourceImage->organization.'</info>',
' Name: <info>'.$sourceImage->name.'</info>',
' Size: <info>'.$sourceImage->size.'</info>',
' Format: <info>'.$sourceImage->format.'</info>',
' Created: <info>'.$sourceImage->created->format('Y-m-d H:i:s').'</info>',
' Dimensions: <info>'.$sourceImage->width.'x'.$sourceImage->height.'</info>',
]);
if ($output->isVerbose()) {
$output->writeln(' BinaryHash: <info>'.$sourceImage->binaryHash.'</info>');
}
if (!empty($sourceImage->dynamicMetadata)) {
if (!$output->isVerbose()) {
$metaNames = array_keys($sourceImage->dynamicMetadata);
$output->writeln(' DynamicMetadatas ('.\count($metaNames).'): '.implode(', ', $metaNames));
} else {
$output->writeln(' DynamicMetadatas:');
/** @var DynamicMetadataInterface $meta */
foreach ($sourceImage->dynamicMetadata as $name => $meta) {
$output->writeln(' - <info>'.$name.'</info> '.$this->formatDynamicMetadata($meta));
}
}
}
} | php | {
"resource": ""
} |
q10805 | RokkaFormatter.outputOrganizationInfo | train | public function outputOrganizationInfo(Organization $org, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$org->getId().'</info>',
' Name: <info>'.$org->getName().'</info>',
' Display Name: <info>'.$org->getDisplayName().'</info>',
' Billing eMail: <info>'.$org->getBillingEmail().'</info>',
]);
} | php | {
"resource": ""
} |
q10806 | RokkaFormatter.outputOrganizationMembershipInfo | train | public function outputOrganizationMembershipInfo(Membership $membership, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$membership->userId.'</info>',
' Roles: <info>'.json_encode($membership->roles).'</info>',
' Active: <info>'.($membership->active ? 'True' : 'False').'</info>',
' Last Access: <info>'.$membership->lastAccess->format('c').'</info>',
]);
} | php | {
"resource": ""
} |
q10807 | RokkaFormatter.outputStackInfo | train | public function outputStackInfo(Stack $stack, OutputInterface $output)
{
$output->writeln(' Name: <info>'.$stack->getName().'</info>');
$output->writeln(' Created: <info>'.$stack->getCreated()->format('Y-m-d H:i:s').'</info>');
$operations = $stack->getStackOperations();
if (!empty($operations)) {
$output->writeln(' Operations:');
foreach ($stack->getStackOperations() as $operation) {
$output->write(' '.$operation->name.': ');
$output->writeln($this->formatStackOperationOptions($operation->options));
}
}
$options = $stack->getStackOptions();
if (!empty($options)) {
$output->writeln(' Options:');
foreach ($stack->getStackOptions() as $name => $value) {
$output->write(' '.$name.': ');
$output->writeln('<info>'.$value.'</info>');
}
}
} | php | {
"resource": ""
} |
q10808 | RokkaFormatter.outputUserInfo | train | public function outputUserInfo(User $user, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$user->getId().'</info>',
' eMail: <info>'.$user->getEmail().'</info>',
' API-Key: <info>'.$user->getApiKey().'</info>',
]);
} | php | {
"resource": ""
} |
q10809 | RokkaFormatter.formatDynamicMetadata | train | private function formatDynamicMetadata(DynamicMetadataInterface $metadata)
{
$info = null;
switch ($metadata::getName()) {
case SubjectArea::getName():
$data = [];
/* @var SubjectArea $metadata */
foreach (['x', 'y', 'width', 'height'] as $property) {
$data[] = $property.':'.$metadata->$property;
}
$info = implode('|', $data);
break;
}
return $info;
} | php | {
"resource": ""
} |
q10810 | Link.attachAgent | train | private function attachAgent(): void
{
$this->agentName = strtolower((string) $this->config['agent']);
switch ($this->agentName) {
case self::AGENT_MYSQL:
$this->agent = new Mysql($this->config);
break;
case self::AGENT_PGSQL:
$this->agent = new Pgsql($this->config);
break;
default:
throw new LinkException("Sorry, but '{$this->agentName}' agent not implemented!");
}
} | php | {
"resource": ""
} |
q10811 | Sample.actionCreateObject | train | protected function actionCreateObject()
{
$blockCenter = new XmlBlockCollection($this->_myWords->Value("OBJECT"), BlockPosition::Center);
$breakLine = new XmlnukeBreakLine();
$firstParagraph = new XmlParagraphCollection();
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT1")));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT2"), true, true, true, true));
$firstParagraph->addXmlnukeObject($breakLine);
$firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT3")));
$secondParagraph = new XmlParagraphCollection();
$secondParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("OBJECTTEXT4")));
$secondParagraph->addXmlnukeObject($breakLine);
$secondParagraph->addXmlnukeObject($breakLine);
$xmlnukeImage = new XmlnukeImage("common/imgs/logo_xmlnuke.gif");
$link = new XmlAnchorCollection("engine:xmlnuke", "");
$link->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("CLICK")." -->"));
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject($xmlnukeImage);
$link->addXmlnukeObject($breakLine);
$link->addXmlnukeObject(new XmlnukeText(" -- ".$this->_myWords->Value("CLICK")));
$secondParagraph->addXmlnukeObject($link);
$secondParagraph->addXmlnukeObject($breakLine);
$thirdParagraph = new XmlParagraphCollection();
$arrayOptions = array();
$arrayOptions["OPTION1"] = $this->_myWords->Value("OPTIONTEST1");
$arrayOptions["OPTION2"] = $this->_myWords->Value("OPTIONTEST2");
$arrayOptions["OPTION3"] = $this->_myWords->Value("OPTIONTEST3");
$arrayOptions["OPTION4"] = $this->_myWords->Value("OPTIONTEST4");
$thirdParagraph->addXmlnukeObject(new XmlEasyList(EasyListType::UNORDEREDLIST, "name", "caption", $arrayOptions, "OP3"));
$blockCenter->addXmlnukeObject($firstParagraph);
$blockCenter->addXmlnukeObject($secondParagraph);
$blockCenter->addXmlnukeObject($thirdParagraph);
$blockLeft = new XmlBlockCollection($this->_myWords->Value("BLOCKLEFT"), BlockPosition::Left);
$blockLeft->addXmlnukeObject($firstParagraph);
$blockRight = new XmlBlockCollection($this->_myWords->Value("BLOCKRIGHT"), BlockPosition::Right);
$blockRight->addXmlnukeObject($firstParagraph);
$this->_document->addXmlnukeObject($blockCenter);
$this->_document->addXmlnukeObject($blockLeft);
$this->_document->addXmlnukeObject($blockRight);
} | php | {
"resource": ""
} |
q10812 | Ownable.isOwnedBy | train | public function isOwnedBy(Model $owner)
{
if ( ! $this->hasOwner())
{
return false;
}
return ($owner->getKey() === $this->owner->getKey());
} | php | {
"resource": ""
} |
q10813 | Map.getCurrentRoute | train | public static function getCurrentRoute()
{
$current = null;
$request = Request::current();
$routeStr = $request->getRouteStr();
$method = $request->getMethod();
//Search for the route
foreach (self::$routes as $route) {
//Check the method
if (!in_array($method, $route['methods'])) {
continue;
}
//Check number of slashes
if (
substr_count($route['route'], '/')
!= substr_count($routeStr, '/')
) {
continue;
}
//Checks the route string
if (
ParametrizedString
::make($route['route'])
->matches($routeStr)
) {
$current = $route;
break;
}
}
return $current;
} | php | {
"resource": ""
} |
q10814 | ResponseFormatter.format | train | public static function format($phantomJsResponse)
{
$response = new Response(
$phantomJsResponse->getStatus(),
$phantomJsResponse->getHeaders(),
$phantomJsResponse->getContent()
);
return $response;
} | php | {
"resource": ""
} |
q10815 | MimeTypeFileBinaryGuesser.guess | train | public static function guess(string $path, string $cmd = null): ?string
{
if (! \is_file($path)) {
throw new FileNotFoundException($path);
}
if (! \is_readable($path)) {
throw new AccessDeniedException($path);
}
if ($cmd === null) {
$cmd = 'file -b --mime %s';
if (\stripos(\PHP_OS, 'win') !== 0) {
$cmd .= ' 2>/dev/null';
}
}
\ob_start();
// need to use --mime instead of -i.
\passthru(\sprintf($cmd, \escapeshellarg($path)), $return);
if ($return > 0) {
\ob_end_clean();
return null;
}
$type = \trim((string) \ob_get_clean());
if (\preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match) === false) {
// it's not a type, but an error message
return null;
}
return $match[1];
} | php | {
"resource": ""
} |
q10816 | SlimData.addVariable | train | public function addVariable(string $name, ?string $type, ?bool $dynamic): KBEntry
{
$kbe = new KBEntry($name, $type, $dynamic);
$this->vars[] = $kbe;
return $kbe;
} | php | {
"resource": ""
} |
q10817 | SessionBuilder.build | train | public function build()
{
if ($this->handler) {
$handler = $this->handler;
} elseif ($this->pdo || $this->dbCredentials) {
$options = $this->dbCredentials;
$options['table'] = $this->table;
if ($this->pdo) {
$options['pdo'] = $this->pdo;
}
$handler = new PdoHandler($options);
} else {
$handler = new FileHandler($this->locking);
}
return new Session($handler, $this->name, $this->savePath, $this->serializer);
} | php | {
"resource": ""
} |
q10818 | Metadata.mergedWith | train | public function mergedWith(Metadata $additionalMetadata): self
{
$values = array_merge($this->values, $additionalMetadata->values);
if ($values === $this->values) {
return $this;
}
return new static($values);
} | php | {
"resource": ""
} |
q10819 | Metadata.withoutKeys | train | public function withoutKeys(array $keys): self
{
$values = array_diff_key($this->values, array_flip($keys));
if ($values === $this->values) {
return $this;
}
return new static($values);
} | php | {
"resource": ""
} |
q10820 | Number.toReadableSize | train | public static function toReadableSize($bytes, $decimals = 1, $system = 'metric')
{
$mod = ($system === 'binary') ? 1024 : 1000;
$units = [
'binary' => [
'B',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB',
],
'metric' => [
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
],
];
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f %s", $bytes / pow($mod, $factor), $units[$system][$factor]);
} | php | {
"resource": ""
} |
q10821 | Number.toReadableTime | train | public static function toReadableTime($time, $decimals = 3)
{
$decimals = (int) $decimals;
$unit = 'sec';
return sprintf("%.{$decimals}f %s", $time, $unit);
} | php | {
"resource": ""
} |
q10822 | PlayersWindow.getIgnoredStatus | train | private function getIgnoredStatus($login)
{
try {
$ignoreList = $this->factory->getConnection()->getIgnoreList();
foreach ($ignoreList as $player) {
if ($player->login === $login) {
return true;
}
}
return false;
} catch (\Exception $e) {
return false;
}
} | php | {
"resource": ""
} |
q10823 | Hidden.group | train | public function group(array $fields)
{
$output = array();
foreach ($fields as $name => $data) {
if (is_array($data)) {
list($data, $value, $class, $id) = $this->_findMainAttr($data);
$output[] = $this->render($name, $value, $class, $id, $data);
} else {
$output[] = $this->render($name, $data);
}
}
return implode(PHP_EOL, $output);
} | php | {
"resource": ""
} |
q10824 | MigrateUserFieldsTask.migrateFields | train | private function migrateFields()
{
if ($attendeeFields = AttendeeExtraField::get()) {
foreach ($attendeeFields as $attendeeField) {
$this->findOrMakeUserFieldFor($attendeeField);
}
}
} | php | {
"resource": ""
} |
q10825 | MigrateUserFieldsTask.findOrMakeUserFieldFor | train | private function findOrMakeUserFieldFor(AttendeeExtraField $attendeeField)
{
if (!$field = $this->getUserFields()->byID($attendeeField->ID)) {
/** @var UserField $field */
$class = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field = $class::create();
}
$field->ClassName = self::mapFieldType($attendeeField->FieldType, $attendeeField->FieldName);
$field->ID = $attendeeField->ID;
$field->Name = $attendeeField->FieldName;
$field->Title = $attendeeField->Title;
$field->Default = $attendeeField->DefaultValue;
$field->ExtraClass = $attendeeField->ExtraClass;
$field->Required = $attendeeField->Required;
$field->Editable = $attendeeField->Editable;
$field->EventID = $attendeeField->EventID;
$field->Sort = $attendeeField->Sort;
if ($attendeeField->Options()->exists() && $field->ClassName === 'UserOptionSetField') {
/** @var \UserOptionSetField $field */
/** @var AttendeeExtraFieldOption $attendeeOption */
foreach ($attendeeField->Options() as $option) {
$field->Options()->add($this->findOrMakeUserOptionFor($option));
echo "[{$field->ID}] Added AttendeeExtraFieldOption as UserFieldOption\n";
}
}
$field->write();
echo "[{$field->ID}] Migrated AttendeeExtraField to $field->ClassName\n";
} | php | {
"resource": ""
} |
q10826 | MigrateUserFieldsTask.findOrMakeUserOptionFor | train | private function findOrMakeUserOptionFor(AttendeeExtraFieldOption $attendeeOption)
{
if (!$option = $this->getUserFieldOption()->byID($attendeeOption->ID)) {
$option = UserFieldOption::create();
}
$option->ID = $attendeeOption->ID;
$option->Title = $attendeeOption->Title;
$option->Default = $attendeeOption->Default;
$option->Sort = $attendeeOption->Sort;
return $option;
} | php | {
"resource": ""
} |
q10827 | MigrateUserFieldsTask.mapFieldType | train | private static function mapFieldType($type, $name = null)
{
$types = array(
'TextField' => 'UserTextField',
'EmailField' => 'UserEmailField',
'CheckboxField' => 'UserCheckboxField',
'OptionsetField' => 'UserOptionSetField'
);
$currentDefaults = Attendee::config()->get('default_fields');
if ($currentDefaults && key_exists($name, $currentDefaults)) {
return $currentDefaults[$name]['FieldType'];
} else {
return $types[$type];
}
} | php | {
"resource": ""
} |
q10828 | VoteService.update | train | public function update()
{
if ($this->currentVote) {
$vote = $this->currentVote->getCurrentVote();
$this->currentVote->update(time());
switch ($vote->getStatus()) {
case Vote::STATUS_CANCEL:
$this->dispatcher->dispatch("votemanager.votecancelled",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_FAILED:
$this->dispatcher->dispatch("votemanager.votefailed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
case Vote::STATUS_PASSED:
$this->dispatcher->dispatch("votemanager.votepassed",
[$vote->getPlayer(), $vote->getType(), $vote]);
$this->currentVote = null;
$this->reset();
break;
}
}
} | php | {
"resource": ""
} |
q10829 | VoteService.startVote | train | public function startVote(Player $player, $typeCode, $params)
{
if ($this->getCurrentVote() !== null) {
$this->chatNotification->sendMessage("expansion_votemanager.error.in_progress");
return;
}
if (isset($this->voteMapping[$typeCode])) {
$typeCode = $this->voteMapping[$typeCode];
}
if (!isset($this->votePlugins[$typeCode])) {
// no vote-plugin found for native vote, so return silently
return;
}
$this->currentVote = $this->votePlugins[$typeCode];
$this->currentVote->start($player, $params);
$this->factory->getConnection()->cancelVote();
$this->dispatcher->dispatch(
"votemanager.votenew",
[$player, $this->currentVote->getCode(), $this->currentVote->getCurrentVote()]
);
} | php | {
"resource": ""
} |
q10830 | EloquentJournalEntry.byAccountIds | train | public function byAccountIds($ids, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->JournalEntry->setConnection($databaseConnectionName)->whereIn('account_id', $ids)->get();
} | php | {
"resource": ""
} |
q10831 | EloquentJournalEntry.getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear | train | public function getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear($plBsCategory, $organizationId, $fiscalYearId, $databaseConnectionName = null)
{
// $this->DB->connection()->enableQueryLog();
// $Entries = $this->DB->table('ACCT_Journal_Entry AS je')
// ->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
// ->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
// ->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')
// ->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
// ->where('jv.status', '=', 'B')
// ->where('jv.organization_id', '=', $organizationId)
// ->where('p.fiscal_year_id', '=', $fiscalYearId)
// // ->where('c.is_group', '=', 0)
// ->where('at.pl_bs_category', '=', $plBsCategory)
// ->whereNull('je.deleted_at')
// ->whereNull('jv.deleted_at')
// // ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->groupBy('journal_voucher_id', 'je.cost_center_id', 'je.account_id')
// ->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'),
// // $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// $this->DB->raw("$journalVoucherId AS journal_voucher_id"), 'je.cost_center_id', 'je.account_id'
// )
// )->get();
if(empty($databaseConnectionName))
{
$databaseConnectionName = $this->databaseConnectionName;
}
return $this->DB->connection($databaseConnectionName)
->table('ACCT_Journal_Entry AS je')
->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
->join('ACCT_Account AS c', 'c.id', '=', 'je.account_id')
->join('ACCT_Period AS p', 'p.id', '=', 'jv.period_id')
->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
->where('jv.organization_id', '=', $organizationId)
->where('p.fiscal_year_id', '=', $fiscalYearId)
->where('jv.status', '=', 'B')
->whereIn('at.pl_bs_category', $plBsCategory)
->whereNull('je.deleted_at')
->whereNull('jv.deleted_at')
->groupBy('je.cost_center_id', 'je.account_id', 'c.balance_type')
->select(array($this->DB->raw('SUM(je.debit) as debit'), $this->DB->raw('SUM(je.credit) as credit'), 'je.cost_center_id', 'je.account_id', 'c.balance_type'))
->get();
// var_dump($this->DB->getQueryLog(), $Entries);die();
} | php | {
"resource": ""
} |
q10832 | ButtonAbstract._getBtnClasses | train | protected function _getBtnClasses(array $attrs = array())
{
if (Arr::key('button', $attrs)) {
$classes = array($this->_btm);
foreach ((array) $attrs['button'] as $btn) {
$classes[] = $this->_btm . '-' . $btn;
}
$attrs = $this->_mergeAttr($attrs, implode(' ', $classes));
unset($attrs['button']);
}
return $attrs;
} | php | {
"resource": ""
} |
q10833 | Config.get | train | public static function get( $key = null ) {
$path = apply_filters(
'inc2734_view_controller_config_path',
untrailingslashit( __DIR__ ) . '/../config/config.php'
);
if ( ! file_exists( $path ) ) {
return;
}
$config = include( $path );
if ( is_null( $key ) ) {
return $config;
}
if ( ! isset( $config[ $key ] ) ) {
return;
}
return $config[ $key ];
} | php | {
"resource": ""
} |
q10834 | BaseRecords.startMap | train | public function startMap($map, $nbLaps)
{
// Load firs X records for this map.
$this->recordsHandler->loadForMap($map->uId, $nbLaps);
// Load time information for remaining players.
$this->recordsHandler->loadForPlayers($map->uId, $nbLaps, $this->allPlayersGroup->getLogins());
// Let others know that records information is now available.
$this->dispatchEvent(['event' => 'loaded', 'records' => $this->recordsHandler->getRecords()]);
} | php | {
"resource": ""
} |
q10835 | BaseRecords.dispatchEvent | train | public function dispatchEvent($eventData)
{
$event = $this->eventPrefix.'.'.$eventData['event'];
unset($eventData['event']);
$eventData[RecordHandler::COL_PLUGIN] = $this;
$this->dispatcher->dispatch($event, [$eventData]);
} | php | {
"resource": ""
} |
q10836 | AggregateRootTrait.registerEvent | train | protected function registerEvent($payload, $metadata = null)
{
if ($payload instanceof AbstractDomainEvent && null === $payload->aggregateId) {
$payload->setAggregateId($this->getId());
}
return $this->getEventContainer()
->addEvent($payload, $metadata);
} | php | {
"resource": ""
} |
q10837 | AssetBundle.registerAssetFiles | train | public function registerAssetFiles($view)
{
if (YII_ENV_PROD) {
if (!empty($this->productionJs)) {
$this->js = $this->productionJs;
}
if (!empty($this->productionCss)) {
$this->css = $this->productionCss;
}
}
parent::registerAssetFiles($view);
} | php | {
"resource": ""
} |
q10838 | FtpClient.login | train | public function login(string $user, string $password, $attempts = 1, $sleepBetweenAttempts = 5)
{
if (!@ftp_login($this->ftp, $user, $password)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->login($user, $password, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot login to host %s", $this->host));
}
return $this;
} | php | {
"resource": ""
} |
q10839 | FtpClient.listFilesRaw | train | public function listFilesRaw(string $dir = ".", int $attempts = 5, int $sleepBetweenAttempts = 5)
{
$total = @ftp_rawlist($this->ftp, $dir);
if ($total === false) {
// Check if tries left call method again
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->listFilesRaw($dir, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot list files in %s", $dir));
}
$columnMap = [
"permissions",
"number",
"owner",
"group",
"size",
"month",
"day",
"year",
"name",
];
$monthMap = [
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Sept' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12',
];
$files = [];
foreach ($total as $rawString) {
$data = [];
$rawList = preg_split("/\s*/", $rawString, -1, PREG_SPLIT_NO_EMPTY);
foreach ($rawList as $col => $value) {
if ($col > 8) { // Filename with spaces
$data[$columnMap[8]] .= " " . $value;
continue;
}
$data[$columnMap[$col]] = $value;
}
$data['month'] = $monthMap[$data['month']];
$data['time'] = "00:00";
if (strpos($data['year'], ':') !== false) {
$data['time'] = $data['year'];
if ((int) $data['month'] > (int) date('m')) {
$data['year'] = date('Y', time() - 60 * 60 * 24 * 365);
} else {
$data['year'] = date('Y');
}
}
$files[] = $data;
}
return $files;
} | php | {
"resource": ""
} |
q10840 | FtpClient.get | train | public function get(
string $remoteFile, string $localFile = null, int $mode = FTP_BINARY, int $attempts = 1,
int $sleepBetweenAttempts = 5
) {
if (!$localFile) {
$localFile = $remoteFile;
}
if (!@ftp_get($this->ftp, $localFile, $remoteFile, $mode)) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->get($remoteFile, $localFile, $mode, $attempts, $sleepBetweenAttempts);
}
throw new Exception(sprintf("Cannot copy file from %s to %s", $remoteFile, $localFile));
}
return $this;
} | php | {
"resource": ""
} |
q10841 | FtpClient.fget | train | public function fget(string $remoteFile, $handle, int $resumePos = 0)
{
if (!@ftp_fget($this->ftp, $handle, $remoteFile, FTP_BINARY, $resumePos)) {
throw new Exception("Cannot write in file handle");
}
return $this;
} | php | {
"resource": ""
} |
q10842 | FtpClient.passive | train | public function passive(bool $passive)
{
if (!@ftp_pasv($this->ftp, $passive)) {
throw new Exception(sprintf("Cannot switch to passive = %s", $passive ? "true" : "false"));
}
return $this;
} | php | {
"resource": ""
} |
q10843 | FtpClient.fput | train | public function fput(string $remoteFile, $handle, int $resumePos = 0)
{
if (!@ftp_fput($this->ftp, $remoteFile, $handle, FTP_BINARY, $resumePos)) {
throw new Exception(sprintf("Cannot copy data from file handle to %s", $remoteFile));
}
return $this;
} | php | {
"resource": ""
} |
q10844 | FtpClient.delete | train | public function delete(string $remoteFile)
{
if (!@ftp_delete($this->ftp, $remoteFile)) {
throw new Exception(sprintf("Cannot delete file %s", $remoteFile));
}
return $this;
} | php | {
"resource": ""
} |
q10845 | FtpClient.getSize | train | public function getSize(string $remoteFile)
{
$size = @ftp_size($this->ftp, $remoteFile);
if ($size == -1) {
throw new Exception("Cannot get file size");
}
return $size;
} | php | {
"resource": ""
} |
q10846 | FtpClient.getModifiedTimestamp | train | public function getModifiedTimestamp(string $remoteFile, int $attempts = 1, int $sleepBetweenAttempts = 5)
{
$timestamp = @ftp_mdtm($this->ftp, $remoteFile);
if ($timestamp < 0) {
if (--$attempts > 0) {
sleep($sleepBetweenAttempts);
return $this->getModifiedTimestamp($remoteFile, $attempts, $sleepBetweenAttempts);
}
throw new Exception("Cannot get file modification timestamp");
}
return $timestamp;
} | php | {
"resource": ""
} |
q10847 | Route.all | train | public static function all(
string $routeStr,
array $info
) {
$methods = Request::getValidMethods();
self::create($methods, $routeStr, $info);
} | php | {
"resource": ""
} |
q10848 | Route.create | train | public static function create(
array $methods,
string $routeStr,
array $info
) {
$middlewareList = isset($info['middleware']) ? (array) $info['middleware'] : [];
array_walk_recursive(
self::$middlewareGroupStack,
function ($middleware) use (&$middlewareList) {
$middlewareList[] = $middleware;
}
);
$route = new self();
$route->setMethods($methods);
$route->setAction(isset($info['action']) ? $info['action'] : 'index');
$route->setAlias(isset($info['alias']) ? $info['alias'] : '');
$route->setMiddlewareList($middlewareList);
$route->setControllerName($info['controller']);
$route->setMethods($methods);
$route->setRouteStr($routeStr);
Map::addRoute($route);
} | php | {
"resource": ""
} |
q10849 | Route.delete | train | public static function delete(
string $routeStr,
array $info
) {
self::create([Request::METHOD_DELETE], $routeStr, $info);
} | php | {
"resource": ""
} |
q10850 | Route.get | train | public static function get(
string $routeStr,
array $info
) {
self::create([Request::METHOD_GET], $routeStr, $info);
} | php | {
"resource": ""
} |
q10851 | Route.group | train | public static function group(string $prefix, Closure $closure, $middleware = [])
{
$prefix = trim($prefix, self::SEPARATOR);
//Prepend prefixes
if ($prefix) {
self::$prefixGroupStack[] = $prefix;
}
//Add group middleware
if ($middleware) {
self::$middlewareGroupStack[] = $middleware;
}
//Call group closure
$closure();
//Remove prefix
if ($prefix) {
array_pop(self::$prefixGroupStack);
}
//Remove current group middleware from the list
if ($middleware) {
array_pop(self::$middlewareGroupStack);
}
} | php | {
"resource": ""
} |
q10852 | Route.post | train | public static function post(
string $routeStr,
array $info
) {
self::create([Request::METHOD_POST], $routeStr, $info);
} | php | {
"resource": ""
} |
q10853 | Route.patch | train | public static function patch(
string $routeStr,
array $info
) {
self::create([Request::METHOD_PATCH], $routeStr, $info);
} | php | {
"resource": ""
} |
q10854 | Route.put | train | public static function put(
string $routeStr,
array $info
) {
self::create([Request::METHOD_PUT], $routeStr, $info);
} | php | {
"resource": ""
} |
q10855 | Group.addLogin | train | public function addLogin($login)
{
if (!isset($this->logins[$login])) {
$this->logins[$login] = true;
$this->dispatcher->dispatch(self::EVENT_NEW_USER, [$this, $login]);
}
} | php | {
"resource": ""
} |
q10856 | Group.removeLogin | train | public function removeLogin($login)
{
if (isset($this->logins[$login])) {
unset($this->logins[$login]);
$this->dispatcher->dispatch(self::EVENT_REMOVE_USER, [$this, $login]);
}
if (!$this->isPersistent() && empty($this->logins)) {
$this->dispatcher->dispatch(self::EVENT_DESTROY, [$this, $login]);
}
} | php | {
"resource": ""
} |
q10857 | VisitorMapper.add | train | public function add(array $data) {
try {
$document = (new Visitor($data))->toArray();
$this->collection->insert($document, ['w' => true]);
return new \MongoId($document['_id']);
}
catch (\MongoCursorException $e) {
throw new MongoMapperException($e->getMessage());
}
catch (\MongoException $e) {
throw new MongoMapperException($e->getMessage());
}
} | php | {
"resource": ""
} |
q10858 | ArrayToXML.buildXML | train | public function buildXML(array $data, $startElement = 'data')
{
if (!\is_array($data)) {
$err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__;
\trigger_error($err);
return false; //return false error occurred
}
$xml = new \XmlWriter();
$xml->openMemory();
$xml->startDocument($this->version, $this->encoding);
$xml->startElement($startElement);
$data = $this->writeAttr($xml, $data);
$this->writeEl($xml, $data);
$xml->endElement(); //write end element
//returns the XML results
return $xml->outputMemory(true);
} | php | {
"resource": ""
} |
q10859 | ArrayToXML.writeEl | train | protected function writeEl(XMLWriter $xml, $data)
{
foreach ($data as $key => $value) {
if (\is_array($value) && !$this->isAssoc($value)) { //numeric array
foreach ($value as $itemValue) {
if (\is_array($itemValue)) {
$xml->startElement($key);
$itemValue = $this->writeAttr($xml, $itemValue);
$this->writeEl($xml, $itemValue);
$xml->endElement();
} else {
$itemValue = $this->writeAttr($xml, $itemValue);
$xml->writeElement($key, "$itemValue");
}
}
} else if (\is_array($value)) { //associative array
$xml->startElement($key);
$value = $this->writeAttr($xml, $value);
$this->writeEl($xml, $value);
$xml->endElement();
} else { //scalar
$value = $this->writeAttr($xml, $value);
$xml->writeElement($key, "$value");
}
}
} | php | {
"resource": ""
} |
q10860 | ViewExtensionHelper._getActiveMenuPattern | train | protected function _getActiveMenuPattern($level = 0, $urlInfo = null) {
if (empty($urlInfo) || !is_array($urlInfo)) {
return false;
}
$level = (int)$level;
extract($urlInfo);
if (($level < 0) || ($level > 2)) {
$level = 0;
}
if ($level > 1) {
$action = 'index';
}
if ($level == 0) {
$userPrefix = $this->Session->read('Auth.User.prefix');
if (empty($prefix) && !empty($userPrefix)) {
$prefix = $userPrefix;
}
}
$url = compact(
'controller',
'action',
'plugin',
'prefix'
);
if (!empty($prefix)) {
$url[$prefix] = true;
}
$href = $this->url($url);
$href = preg_quote($href, '/');
if (!empty($pass) || !empty($named)) {
if (((($level == 0) && (mb_stripos($action, 'index') === false)) ||
($level == 2)) && ($href !== '\/')) {
$href .= '\/?.*';
}
}
$activePattern = '/<a\s+href=\"' . $href . '\".*>/iu';
return $activePattern;
} | php | {
"resource": ""
} |
q10861 | ViewExtensionHelper._getActiveMenuPatterns | train | protected function _getActiveMenuPatterns($urlInfo = null) {
$deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern();
$activePatterns = [];
for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) {
$activePatterns[] = $this->_getActiveMenuPattern($activePatternLevel, $urlInfo);
}
return $activePatterns;
} | php | {
"resource": ""
} |
q10862 | ViewExtensionHelper._prepareIconList | train | protected function _prepareIconList(array &$iconList) {
if (empty($iconList) || !is_array($iconList)) {
return;
}
foreach ($iconList as $i => &$iconListItem) {
if (is_array($iconListItem) && isAssoc($iconListItem)) {
foreach ($iconListItem as $topMenu => $subMenu) {
$subMenuList = '';
foreach ($subMenu as $subMenuItem) {
$subMenuClass = null;
if ($subMenuItem === 'divider') {
$subMenuItem = '';
$subMenuClass = 'divider';
}
$subMenuList .= $this->Html->tag('li', $subMenuItem, ['class' => $subMenuClass]);
}
$topMenuItem = $topMenu . $this->Html->tag('ul', $subMenuList, ['class' => 'dropdown-menu']);
}
$iconListItem = $topMenuItem;
}
}
} | php | {
"resource": ""
} |
q10863 | ViewExtensionHelper._parseCurrentUrl | train | protected function _parseCurrentUrl() {
$prefix = $this->request->param('prefix');
$plugin = $this->request->param('plugin');
$controller = $this->request->param('controller');
$action = $this->request->param('action');
$named = $this->request->param('named');
$pass = $this->request->param('pass');
$named = (!empty($named) ? true : false);
$pass = (!empty($pass) ? true : false);
$result = compact(
'prefix',
'plugin',
'controller',
'action',
'named',
'pass'
);
return $result;
} | php | {
"resource": ""
} |
q10864 | ViewExtensionHelper.getMenuList | train | public function getMenuList($iconList = null) {
$activeMenuUrl = $this->_View->get('activeMenuUrl');
$urlInfo = $this->_parseCurrentUrl();
if (!empty($activeMenuUrl) && is_array($activeMenuUrl)) {
$urlInfo = $activeMenuUrl + $urlInfo;
}
$activePatterns = $this->_getActiveMenuPatterns($urlInfo);
$deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern();
$activeMenu = [];
$menuList = '';
$cachePath = null;
if (empty($iconList) || !is_array($iconList)) {
return $menuList;
}
$this->_prepareIconList($iconList);
$dataStr = serialize($iconList + $urlInfo) . '_' . $this->_currUIlang;
$cachePath = 'MenuList.' . md5($dataStr);
$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS);
if (!empty($cached)) {
return $cached;
}
foreach ($iconList as $i => $iconListItem) {
for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) {
if (!$activePatterns[$activePatternLevel]) {
continue;
}
if (preg_match($activePatterns[$activePatternLevel], $iconListItem)) {
$activeMenu[$activePatternLevel][] = $i;
}
}
}
for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) {
if (isset($activeMenu[$activePatternLevel]) && !empty($activeMenu[$activePatternLevel])) {
break;
}
}
foreach ($iconList as $i => $iconListItem) {
$iconListItemClass = null;
if (isset($activeMenu[$activePatternLevel]) && in_array($i, $activeMenu[$activePatternLevel])) {
$iconListItemClass = 'active';
}
$menuList .= $this->Html->tag('li', $iconListItem, ['class' => $iconListItemClass]);
}
if (!empty($menuList)) {
$menuList = $this->Html->tag('ul', $menuList, ['class' => 'nav navbar-nav navbar-right']);
}
Cache::write($cachePath, $menuList, CAKE_THEME_CACHE_KEY_HELPERS);
return $menuList;
} | php | {
"resource": ""
} |
q10865 | ViewExtensionHelper.yesNo | train | public function yesNo($data = null) {
if ((bool)$data) {
$result = $this->_getOptionsForElem('yesNo.yes');
} else {
$result = $this->_getOptionsForElem('yesNo.no');
}
return $result;
} | php | {
"resource": ""
} |
q10866 | ViewExtensionHelper.popupModalLink | train | public function popupModalLink($title = null, $url = null, $options = []) {
$optionsDefault = $this->_getOptionsForElem('popupModalLink');
return $this->_createLink('modal-popover', $title, $url, $options, $optionsDefault);
} | php | {
"resource": ""
} |
q10867 | ViewExtensionHelper.confirmLink | train | public function confirmLink($title = null, $url = null, $options = []) {
$optionsDefault = $this->_getOptionsConfirmLink();
return $this->_createLink(null, $title, $url, $options, $optionsDefault);
} | php | {
"resource": ""
} |
q10868 | ViewExtensionHelper.confirmPostLink | train | public function confirmPostLink($title = null, $url = null, $options = []) {
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$optionsDefault = $this->_getOptionsConfirmLink();
$optionsDefault['role'] = 'post-link';
return $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault);
} | php | {
"resource": ""
} |
q10869 | ViewExtensionHelper._createLink | train | protected function _createLink($toggle = null, $title = null, $url = null, $options = [], $optionsDefault = []) {
if (empty($options)) {
$options = [];
}
if (empty($optionsDefault)) {
$optionsDefault = [];
}
if (!empty($toggle)) {
$options['data-toggle'] = $toggle;
}
if (!empty($optionsDefault)) {
$options += $optionsDefault;
}
return $this->Html->link($title, $url, $options);
} | php | {
"resource": ""
} |
q10870 | ViewExtensionHelper.ajaxLink | train | public function ajaxLink($title, $url = null, $options = []) {
return $this->_createLink('ajax', $title, $url, $options);
} | php | {
"resource": ""
} |
q10871 | ViewExtensionHelper.requestOnlyLink | train | public function requestOnlyLink($title, $url = null, $options = []) {
return $this->_createLink('request-only', $title, $url, $options);
} | php | {
"resource": ""
} |
q10872 | ViewExtensionHelper.pjaxLink | train | public function pjaxLink($title, $url = null, $options = []) {
return $this->_createLink('pjax', $title, $url, $options);
} | php | {
"resource": ""
} |
q10873 | ViewExtensionHelper.lightboxLink | train | public function lightboxLink($title, $url = null, $options = []) {
return $this->_createLink('lightbox', $title, $url, $options);
} | php | {
"resource": ""
} |
q10874 | ViewExtensionHelper.paginationSortPjax | train | public function paginationSortPjax($key = null, $title = null, $options = []) {
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$optionsDefault = $this->_getOptionsForElem('paginationSortPjax.linkOpt');
if ($this->request->is('modal')) {
$optionsDefault['data-toggle'] = 'modal';
//$optionsDefault['data-disable-use-stack'] = 'true';
}
$sortKey = $this->Paginator->sortKey();
if (!empty($sortKey) && ($key === $sortKey)) {
$sortDir = $this->Paginator->sortDir();
if ($sortDir === 'asc') {
$dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.asc');
} else {
$dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.desc');
}
$title .= $dirIcon;
$options['escape'] = false;
}
return $this->Paginator->sort($key, $title, $options + $optionsDefault);
} | php | {
"resource": ""
} |
q10875 | ViewExtensionHelper.progressSseLink | train | public function progressSseLink($title, $url = null, $options = []) {
return $this->_createLink('progress-sse', $title, $url, $options);
} | php | {
"resource": ""
} |
q10876 | ViewExtensionHelper._getClassForElement | train | protected function _getClassForElement($elementClass = null) {
$elementClass = mb_strtolower((string)$elementClass);
$cachePath = 'ClassForElem.' . md5($elementClass);
$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS);
if (!empty($cached)) {
return $cached;
}
$result = '';
if (empty($elementClass)) {
return $result;
}
if (mb_strpos($elementClass, 'fa-') !== false) {
$elemList = [];
$elemPrefixes = $this->_getListIconPrefixes();
$elemPrefix = (string)$this->_config['defaultIconPrefix'];
$elemSizes = $this->_getListIconSizes();
$elemSize = (string)$this->_config['defaultIconSize'];
} elseif (mb_strpos($elementClass, 'btn-') !== false) {
$elemList = $this->_getListButtons();
$elemPrefixes = $this->_getListButtonPrefixes();
$elemPrefix = (string)$this->_config['defaultBtnPrefix'];
$elemSizes = $this->_getListButtonSizes();
$elemSize = (string)$this->_config['defaultBtnSize'];
} else {
return $result;
}
$aElem = explode(' ', $elementClass, 5);
$aClass = [];
foreach ($aElem as $elemItem) {
if (empty($elemItem)) {
continue;
}
if (in_array($elemItem, $elemSizes)) {
$elemSize = $elemItem;
} elseif (in_array($elemItem, $elemPrefixes)) {
$elemPrefix = $elemItem;
} elseif (empty($elemList) || (!empty($elemList) && in_array($elemItem, $elemList))) {
$aClass[] = $elemItem;
}
}
if (!empty($elemList) && empty($aClass)) {
return $result;
}
if (!empty($elemPrefix)) {
array_unshift($aClass, $elemPrefix);
}
if (!empty($elemSize)) {
array_push($aClass, $elemSize);
}
$aClass = array_unique($aClass);
$result = implode(' ', $aClass);
Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS);
return $result;
} | php | {
"resource": ""
} |
q10877 | ViewExtensionHelper.getBtnClass | train | public function getBtnClass($btn = null) {
$btnClass = $this->_getClassForElement($btn);
if (!empty($btnClass)) {
$result = $btnClass;
} else {
$result = $this->_getClassForElement('btn-default');
}
return $result;
} | php | {
"resource": ""
} |
q10878 | ViewExtensionHelper.iconTag | train | public function iconTag($icon = null, $options = []) {
$icon = mb_strtolower((string)$icon);
$dataStr = serialize(compact('icon', 'options')) . '_' . $this->_currUIlang;
$cachePath = 'iconTag.' . md5($dataStr);
$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS);
if (!empty($cached)) {
return $cached;
}
$result = '';
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$iconClass = $this->_getClassForElement($icon);
if (empty($iconClass)) {
return $result;
}
$options['class'] = $iconClass;
$result = $this->Html->tag('span', '', $options);
Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS);
return $result;
} | php | {
"resource": ""
} |
q10879 | ViewExtensionHelper.buttonLink | train | public function buttonLink($icon = null, $btn = null, $url = null, $options = []) {
$result = '';
if (empty($icon)) {
return $result;
}
$title = '';
if ($icon === strip_tags($icon)) {
if ($this->_getClassForElement($icon)) {
$icon .= ' fa-fw';
}
$title = $this->iconTag($icon);
}
if (empty($title)) {
$title = $icon;
}
$button = $this->getBtnClass($btn);
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : '');
$optionsDefault = [
'escape' => false,
];
if (isset($options['title'])) {
$optionsDefault['data-toggle'] = 'title';
}
$postLink = $this->_processActionTypeOpt($options);
if ($postLink) {
if (!isset($options['block'])) {
$options['block'] = 'confirm-form';
}
$result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault);
} else {
$result = $this->Html->link($title, $url, $options + $optionsDefault);
}
return $result;
} | php | {
"resource": ""
} |
q10880 | ViewExtensionHelper.button | train | public function button($icon = null, $btn = null, $options = []) {
$result = '';
if (empty($icon)) {
return $result;
}
$title = '';
if ($icon === strip_tags($icon)) {
if ($this->_getClassForElement($icon)) {
$icon .= ' fa-fw';
}
$title = $this->iconTag($icon);
}
if (empty($title)) {
$title = $icon;
}
$button = $this->getBtnClass($btn);
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : '');
$optionsDefault = [
'escape' => false,
'type' => 'button',
];
if (isset($options['title'])) {
$optionsDefault['data-toggle'] = 'title';
}
$result = $this->ExtBs3Form->button($title, $options + $optionsDefault);
return $result;
} | php | {
"resource": ""
} |
q10881 | ViewExtensionHelper.addUserPrefixUrl | train | public function addUserPrefixUrl($url = null) {
if (empty($url)) {
return $url;
}
$userPrefix = $this->Session->read('Auth.User.prefix');
if (empty($userPrefix)) {
return $url;
}
if (!is_array($url)) {
if (($url === '/') || (stripos($url, '/') === false)) {
return $url;
}
$url = Router::parse($url);
}
if (isset($url['prefix']) && ($url['prefix'] === false)) {
$url[$userPrefix] = false;
if (isset($url['prefix'])) {
unset($url['prefix']);
}
return $url;
}
$url[$userPrefix] = true;
return $url;
} | php | {
"resource": ""
} |
q10882 | ViewExtensionHelper.menuItemLabel | train | public function menuItemLabel($title = null) {
$result = '';
if (empty($title)) {
return $result;
}
$result = $this->Html->tag('span', $title, ['class' => 'menu-item-label visible-xs-inline']);
return $result;
} | php | {
"resource": ""
} |
q10883 | ViewExtensionHelper.menuItemLink | train | public function menuItemLink($icon = null, $title = null, $url = null, $options = [], $badgeNumber = 0) {
$result = '';
if (empty($icon) || empty($title)) {
return $result;
}
$caret = '';
if (empty($options) || !is_array($options)) {
$options = [];
}
$options['escape'] = false;
$options['title'] = $title;
$badgeNumber = (int)$badgeNumber;
if (empty($url)) {
$url = '#';
$caret = $this->Html->tag('span', '', ['class' => 'caret']);
$options += [
'class' => 'dropdown-toggle',
'data-toggle' => 'dropdown',
'role' => 'button',
'aria-haspopup' => 'true',
'aria-expanded' => 'false'
];
} else {
$url = $this->addUserPrefixUrl($url);
}
if ($this->_getClassForElement($icon)) {
$icon .= ' fa-fw';
}
$iconTag = $this->iconTag($icon) . $this->menuItemLabel($title) . $caret;
if ($badgeNumber > 0) {
$iconTag .= ' ' . $this->Html->tag('span', $this->Number->format(
$badgeNumber,
['thousands' => ' ', 'before' => '', 'places' => 0]
), ['class' => 'badge']);
}
if (!isset($options['data-toggle'])) {
$options['data-toggle'] = 'tooltip';
}
$result = $this->Html->link(
$iconTag,
$url,
$options
);
return $result;
} | php | {
"resource": ""
} |
q10884 | ViewExtensionHelper.menuActionLink | train | public function menuActionLink($icon = null, $titleText = null, $url = null, $options = []) {
$result = '';
if (empty($icon)) {
return $result;
}
if ($this->_getClassForElement($icon)) {
$icon .= ' fa-fw';
}
$iconClass = $this->_getClassForElement($icon);
if (empty($iconClass)) {
return $result;
}
$title = $this->Html->tag('span', '', ['class' => $iconClass]);
if (!empty($titleText)) {
$title .= $this->Html->tag('span', $titleText, ['class' => 'menu-item-label']);
}
if (empty($options)) {
$options = [];
} elseif (!is_array($options)) {
$options = [$options];
}
$optionsDefault = [
'escape' => false,
];
if (isset($options['title'])) {
$optionsDefault['data-toggle'] = 'title';
}
$url = $this->addUserPrefixUrl($url);
$postLink = $this->_processActionTypeOpt($options);
if ($postLink) {
$result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault);
} else {
$result = $this->Html->link($title, $url, $options + $optionsDefault);
}
return $result;
} | php | {
"resource": ""
} |
q10885 | ViewExtensionHelper.timeAgo | train | public function timeAgo($time = null, $format = null) {
if (empty($time)) {
$time = time();
}
if (empty($format)) {
$format = '%x %X';
}
$result = $this->Html->tag(
'time',
$this->Time->i18nFormat($time, $format),
[
'data-toggle' => 'timeago',
'datetime' => date('c', $this->Time->fromString($time)),
'class' => 'help'
]
);
return $result;
} | php | {
"resource": ""
} |
q10886 | ViewExtensionHelper.getIconForExtension | train | public function getIconForExtension($extension = null) {
$extension = mb_strtolower((string)$extension);
$cachePath = 'IconForExtension.' . md5($extension);
$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS);
if (!empty($cached)) {
return $cached;
}
$result = 'far fa-file';
if (empty($extension)) {
Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS);
return $result;
}
$extensions = [
'far fa-file-archive' => ['zip', 'rar', '7z'],
'far fa-file-word' => ['doc', 'docx'],
'far fa-file-code' => ['htm', 'html', 'xml', 'js'],
'far fa-file-image' => ['jpg', 'jpeg', 'png', 'gif'],
'far fa-file-pdf' => ['pdf'],
'far fa-file-video' => ['avi', 'mp4'],
'far fa-file-powerpoint' => ['ppt', 'pptx'],
'far fa-file-audio' => ['mp3', 'wav', 'flac'],
'far fa-file-excel' => ['xls', 'xlsx'],
'far fa-file-alt' => ['txt'],
];
foreach ($extensions as $icon => $extensionsList) {
if (in_array($extension, $extensionsList)) {
$result = $icon;
break;
}
}
Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS);
return $result;
} | php | {
"resource": ""
} |
q10887 | ViewExtensionHelper.truncateText | train | public function truncateText($text = null, $length = 0) {
$result = '';
if (empty($text)) {
return $result;
}
$text = (string)$text;
$length = (int)$length;
if ($length <= 0) {
$length = 50;
}
if (($text === h($text)) && (mb_strlen($text) <= $length)) {
return $text;
}
$truncateOpt = $this->_getOptionsForElem('truncateText.truncateOpt');
$tuncatedText = $this->Text->truncate($text, $length, $truncateOpt);
if ($tuncatedText === $text) {
return $tuncatedText;
}
$result = $this->Html->div('collapse-text-truncated', $tuncatedText);
$result .= $this->Html->div(
'collapse-text-original',
$text . $this->_getOptionsForElem('truncateText.collapseLink')
);
$result = $this->Html->div('collapse-text-expanded', $result);
return $result;
} | php | {
"resource": ""
} |
q10888 | ViewExtensionHelper.getFormOptions | train | public function getFormOptions($options = []) {
if (empty($options) || !is_array($options)) {
$options = [];
}
$optionsDefault = $this->_getOptionsForElem('form');
$result = $optionsDefault + $options;
return $result;
} | php | {
"resource": ""
} |
q10889 | ViewExtensionHelper._getLangForNumberText | train | protected function _getLangForNumberText($langCode = null) {
if (!is_object($this->_NumberTextLib)) {
return false;
}
$cachePath = 'lang_code_number_lib_' . md5(serialize(func_get_args()));
$cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_LANG_CODE);
if (!empty($cached)) {
return $cached;
}
$langNumb = $this->_Language->getLangForNumberText($langCode);
$result = $this->_NumberTextLib->setLang($langNumb);
Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_LANG_CODE);
return $result;
} | php | {
"resource": ""
} |
q10890 | ViewExtensionHelper.numberText | train | public function numberText($number = null, $langCode = null) {
if (!is_object($this->_NumberTextLib)) {
return false;
}
$langNumb = $this->_getLangForNumberText($langCode);
return $this->_NumberTextLib->numberText($number, $langNumb);
} | php | {
"resource": ""
} |
q10891 | ViewExtensionHelper.barState | train | public function barState($stateData = null) {
$result = '';
if (!is_array($stateData)) {
$stateData = [];
}
if (empty($stateData)) {
$stateData = [
[
'stateName' => $this->showEmpty(null),
'stateId' => null,
'amount' => 0,
'stateUrl' => null,
]
];
}
$totalAmount = Hash::apply($stateData, '{n}.amount', 'array_sum');
$percSum = 0;
$countState = count($stateData);
foreach ($stateData as $i => $stateItem) {
$class = 'progress-bar';
if (isset($stateItem['class']) && !empty($stateItem['class'])) {
$class .= ' ' . $stateItem['class'];
}
if ($totalAmount > 0) {
$perc = round($stateItem['amount'] / $totalAmount * 100, 2);
} else {
$perc = 100;
}
$percRound = round($perc);
if ($percSum + $percRound > 100) {
$percRound = 100 - $percSum;
} else {
if ($i == $countState - 1) {
$percRound = 100 - $percSum;
}
}
$percSum += $percRound;
$stateName = $stateItem['stateName'];
$progressBar = $this->Html->div(
$class,
$stateName,
['role' => 'progressbar', 'style' => 'width:' . $percRound . '%',
'title' => $stateName . ': ' . $this->Number->format(
$stateItem['amount'],
['thousands' => ' ', 'before' => '', 'places' => 0]
) . ' (' . $perc . '%)',
'data-toggle' => 'tooltip']
);
if (isset($stateItem['stateUrl']) && !empty($stateItem['stateUrl'])) {
$progressBar = $this->Html->link(
$progressBar,
$stateItem['stateUrl'],
['target' => '_blank', 'escape' => false]
);
}
$result .= $progressBar;
}
$result = $this->Html->div('progress', $result);
return $result;
} | php | {
"resource": ""
} |
q10892 | ViewExtensionHelper.listLastInfo | train | public function listLastInfo($lastInfo = null, $labelList = null, $controllerName = null, $actionName = null, $linkOptions = [], $length = 0) {
if (!is_array($lastInfo)) {
$lastInfo = [];
}
if (empty($labelList) && !empty($controllerName)) {
$labelList = Inflector::humanize(Inflector::underscore($controllerName));
}
if (empty($actionName)) {
$actionName = 'view';
}
$lastInfoList = '';
if (!empty($labelList)) {
$lastInfoList .= $this->Html->tag('dt', $labelList . ':');
}
if (!empty($lastInfo)) {
$lastInfoListData = [];
foreach ($lastInfo as $lastInfoItem) {
$label = $this->truncateText(h($lastInfoItem['label']), $length);
if (!empty($controllerName) && !empty($lastInfoItem['id'])) {
$url = $this->addUserPrefixUrl(['controller' => $controllerName, 'action' => $actionName, $lastInfoItem['id']]);
$label = $this->popupModalLink($label, $url, $linkOptions);
}
$lastInfoListData[] = $label .
' (' . $this->timeAgo($lastInfoItem['modified']) . ')';
}
$lastInfoListItem = $this->Html->nestedList($lastInfoListData, null, null, 'ol');
} else {
$lastInfoListItem = $this->showEmpty(null);
}
$lastInfoList .= $this->Html->tag('dd', $lastInfoListItem);
$result = $this->Html->tag('dl', $lastInfoList, ['class' => 'dl-horizontal']);
return $result;
} | php | {
"resource": ""
} |
q10893 | ViewExtensionHelper.buttonsMove | train | public function buttonsMove($url = null, $useDrag = true, $glue = '', $useGroup = false) {
$result = '';
if (empty($url) || !is_array($url)) {
return $result;
}
$actions = [];
if ($useDrag) {
$actions[] = $this->_getOptionsForElem('buttonsMove.btnDrag');
}
$buttons = $this->_getOptionsForElem('buttonsMove.btnsMove');
foreach ($buttons as $button) {
$actions[] = $this->buttonLink(
$button['icon'],
'btn-info',
array_merge($button['url'], $url),
['title' => $button['title'], 'data-toggle' => 'move']
);
}
$result = implode($glue, $actions);
if (empty($glue) && $useGroup) {
$result = $this->Html->div('btn-group', $result, ['role' => 'group']);
}
return $result;
} | php | {
"resource": ""
} |
q10894 | ViewExtensionHelper.buttonLoadMore | train | public function buttonLoadMore($targetSelector = null) {
$result = '';
if (empty($targetSelector)) {
$targetSelector = 'table tbody';
}
$hasNext = $this->Paginator->hasNext();
if (!$hasNext) {
$paginatorParams = $this->Paginator->params();
$count = (int)Hash::get($paginatorParams, 'count');
$records = __dn('view_extension', 'record', 'records', $count);
$result = $this->Html->div(
'load-more',
$this->Html->para('small', $this->Paginator->counter(__d('view_extension', 'Showing {:count} %s', $records)))
);
return $result;
}
$urlPaginator = [];
if (isset($this->Paginator->options['url'])) {
$urlPaginator = (array)$this->Paginator->options['url'];
}
$paginatorParams = $this->Paginator->params();
$count = (int)Hash::get($paginatorParams, 'count');
$page = (int)Hash::get($paginatorParams, 'page');
$limit = (int)Hash::get($paginatorParams, 'limit');
$urlLoadMore = $this->Paginator->url(['page' => $page + 1, 'show' => 'list'], true);
$urlLoadMore = array_merge($urlPaginator, $urlLoadMore);
$btnClass = $this->getBtnClass('btn-default btn-sm');
$btnClass .= ' btn-block';
$startRecord = 0;
if ($count >= 1) {
$startRecord = (($page - 1) * $limit) + 1;
}
$endRecord = $startRecord + $limit - 1;
$records = __dn('view_extension', 'record', 'records', $endRecord);
$result = $this->Html->div(
'load-more',
$this->Html->para('small', $this->Paginator->counter(
__d('view_extension', 'Current loaded page {:page} of {:pages}, showing {:end} %s of {:count} total', $records)
)) .
$this->Html->link(
$this->_getOptionsForElem('loadMore.linkTitle'),
$urlLoadMore,
[
'class' => $btnClass . ' hidden-print',
'data-target-selector' => $targetSelector,
] + $this->_getOptionsForElem('loadMore.linkOpt')
)
);
return $result;
} | php | {
"resource": ""
} |
q10895 | ViewExtensionHelper.buttonsPaging | train | public function buttonsPaging($targetSelector = null, $showCounterInfo = true, $useShowList = true, $useGoToPage = true, $useChangeNumLines = true) {
$showType = (string)$this->request->param('named.show');
if (mb_stripos($showType, 'list') === 0) {
$result = $this->buttonLoadMore($targetSelector);
} else {
$result = $this->barPaging($showCounterInfo, $useShowList, $useGoToPage, $useChangeNumLines);
}
return $result;
} | php | {
"resource": ""
} |
q10896 | ViewExtensionHelper.menuHeaderPage | train | public function menuHeaderPage($headerMenuActions = null) {
$result = '';
if (empty($headerMenuActions)) {
return $result;
}
if (!is_array($headerMenuActions)) {
$headerMenuActions = [$headerMenuActions];
}
$headerMenuActionsPrep = '';
foreach ($headerMenuActions as $action) {
$actionOptions = [];
if (!is_array($action)) {
if ($action === 'divider') {
$action = '';
$actionOptions = ['class' => 'divider'];
}
$headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions);
} elseif (is_array($action)) {
$actionSize = count($action);
if ($actionSize == 1) {
$actionLabal = array_shift($action);
if (empty($actionLabal)) {
continue;
}
$headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal);
} elseif ($actionSize == 2) {
$actionLabal = array_shift($action);
if (empty($actionLabal)) {
continue;
}
$actionOptions = array_shift($action);
if (!is_array($actionOptions)) {
$actionOptions = [];
}
$headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal, $actionOptions);
} elseif (($actionSize >= 3) && ($actionSize <= 4)) {
$action = call_user_func_array([$this, 'menuActionLink'], $action);
$headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions);
}
}
}
if (empty($headerMenuActionsPrep)) {
return $result;
}
$result = $this->Html->div(
'btn-group page-header-menu hidden-print',
$this->_getOptionsForElem('btnHeaderMenu') .
$this->Html->tag('ul', $headerMenuActionsPrep, ['class' => 'dropdown-menu', 'aria-labelledby' => 'pageHeaderMenu'])
);
return $result;
} | php | {
"resource": ""
} |
q10897 | ViewExtensionHelper.headerPage | train | public function headerPage($pageHeader = null, $headerMenuActions = null) {
$result = '';
if (empty($pageHeader)) {
return $result;
}
$pageHeader = (string)$pageHeader;
$pageHeader .= $this->menuHeaderPage($headerMenuActions);
return $this->Html->div('page-header well', $this->Html->tag('h2', $pageHeader, ['class' => 'header']));
} | php | {
"resource": ""
} |
q10898 | ViewExtensionHelper.collapsibleList | train | public function collapsibleList($listData = [], $showLimit = 10, $listClass = 'list-unstyled', $listTag = 'ul') {
$result = '';
if (empty($listData)) {
return $result;
}
$showLimit = (int)$showLimit;
if ($showLimit < 1) {
return $result;
}
if (!empty($listClass)) {
$listClass = ' ' . $listClass;
}
$tagsAllowed = ['ul', 'ol'];
if (!in_array($listTag, $tagsAllowed)) {
$listTag = 'ul';
}
$listDataShown = array_slice($listData, 0, $showLimit);
$result = $this->Html->nestedList($listDataShown, ['class' => 'list-collapsible-compact' . $listClass], [], $listTag);
if (count($listData) <= $showLimit) {
return $result;
}
$listId = uniqid('collapsible-list-');
$listDataHidden = array_slice($listData, $showLimit);
$result .= $this->Html->nestedList(
$listDataHidden,
[
'class' => 'list-collapsible-compact collapse' . $listClass,
'id' => $listId
],
[],
$listTag
) .
$this->button(
'fas fa-angle-double-down',
'btn-default',
[
'class' => 'top-buffer hide-popup',
'title' => __d('view_extension', 'Show or hide full list'),
'data-toggle' => 'collapse', 'data-target' => '#' . $listId,
'aria-expanded' => 'false',
'data-toggle-icons' => 'fa-angle-double-down,fa-angle-double-up'
]
);
return $result;
} | php | {
"resource": ""
} |
q10899 | ViewExtensionHelper.addBreadCrumbs | train | public function addBreadCrumbs($breadCrumbs = null) {
if (empty($breadCrumbs) || !is_array($breadCrumbs)) {
return;
}
foreach ($breadCrumbs as $breadCrumbInfo) {
if (empty($breadCrumbInfo)) {
continue;
}
$link = null;
if (is_array($breadCrumbInfo)) {
$name = array_shift($breadCrumbInfo);
$link = array_shift($breadCrumbInfo);
} else {
$name = $breadCrumbInfo;
}
if (empty($name)) {
continue;
}
$this->Html->addCrumb(h($name), $link);
}
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.