_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | 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);
| php | {
"resource": ""
} |
q10801 | Iframe.render | train | public function render($src, $class = '', $id = '', array $attrs = array())
{
$attrs = array_merge(array(
'frameborder' => 0,
'content' => null,
'tag' | php | {
"resource": ""
} |
q10802 | BestCheckpoints.onLocalRecordsLoaded | train | public function onLocalRecordsLoaded($records, BaseRecords $baseRecords)
{
if (!$this->checkRecordPlugin($baseRecords)) {
return;
}
if (count($records) > 0) {
| php | {
"resource": ""
} |
q10803 | RokkaFormatter.formatStackOperationOptions | train | public function formatStackOperationOptions(array $settings)
{
$data = [];
foreach ($settings as $name => $value) {
| 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()) { | php | {
"resource": ""
} |
q10805 | RokkaFormatter.outputOrganizationInfo | train | public function outputOrganizationInfo(Organization $org, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$org->getId().'</info>',
| php | {
"resource": ""
} |
q10806 | RokkaFormatter.outputOrganizationMembershipInfo | train | public function outputOrganizationMembershipInfo(Membership $membership, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$membership->userId.'</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));
}
| php | {
"resource": ""
} |
q10808 | RokkaFormatter.outputUserInfo | train | public function outputUserInfo(User $user, OutputInterface $output)
{
$output->writeln([
' ID: <info>'.$user->getId().'</info>', | php | {
"resource": ""
} |
q10809 | RokkaFormatter.formatDynamicMetadata | train | private function formatDynamicMetadata(DynamicMetadataInterface $metadata)
{
$info = null;
switch ($metadata::getName()) {
case SubjectArea::getName():
$data = [];
| 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:
| 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();
| php | {
"resource": ""
} |
q10812 | Ownable.isOwnedBy | train | public function isOwnedBy(Model $owner)
{
if ( ! $this->hasOwner())
{
return false;
}
| 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;
}
| php | {
"resource": ""
} |
q10814 | ResponseFormatter.format | train | public static function format($phantomJsResponse)
{
$response = new Response(
$phantomJsResponse->getStatus(),
$phantomJsResponse->getHeaders(),
| 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.
| php | {
"resource": ""
} |
q10816 | SlimData.addVariable | train | public function addVariable(string $name, ?string $type, ?bool $dynamic): KBEntry
{
$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);
| php | {
"resource": ""
} |
q10818 | Metadata.mergedWith | train | public function mergedWith(Metadata $additionalMetadata): self
{
$values = array_merge($this->values, $additionalMetadata->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) {
| 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',
| php | {
"resource": ""
} |
q10821 | Number.toReadableTime | train | public static function toReadableTime($time, $decimals = 3)
{
$decimals = (int) $decimals;
$unit = 'sec'; | php | {
"resource": ""
} |
q10822 | PlayersWindow.getIgnoredStatus | train | private function getIgnoredStatus($login)
{
try {
$ignoreList = $this->factory->getConnection()->getIgnoreList();
foreach ($ignoreList as $player) {
if ($player->login === $login) {
| 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);
| php | {
"resource": ""
} |
q10824 | MigrateUserFieldsTask.migrateFields | train | private function migrateFields()
{
if ($attendeeFields = AttendeeExtraField::get()) {
| 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') { | php | {
"resource": ""
} |
q10826 | MigrateUserFieldsTask.findOrMakeUserOptionFor | train | private function findOrMakeUserOptionFor(AttendeeExtraFieldOption $attendeeOption)
{
if (!$option = $this->getUserFieldOption()->byID($attendeeOption->ID)) {
$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'); | 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;
| 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;
}
| php | {
"resource": ""
} |
q10830 | EloquentJournalEntry.byAccountIds | train | public function byAccountIds($ids, $databaseConnectionName = null)
{
if(empty($databaseConnectionName))
{
| 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))
| 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;
| 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'
| 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());
| php | {
"resource": ""
} |
q10835 | BaseRecords.dispatchEvent | train | public function dispatchEvent($eventData)
{
$event = $this->eventPrefix.'.'.$eventData['event'];
unset($eventData['event']);
| php | {
"resource": ""
} |
q10836 | AggregateRootTrait.registerEvent | train | protected function registerEvent($payload, $metadata = null)
{
if ($payload instanceof AbstractDomainEvent && null === $payload->aggregateId) {
$payload->setAggregateId($this->getId());
| 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)) {
| 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);
| 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
| 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) {
| 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 | php | {
"resource": ""
} |
q10842 | FtpClient.passive | train | public function passive(bool $passive)
{
if (!@ftp_pasv($this->ftp, $passive)) {
| 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 | php | {
"resource": ""
} |
q10844 | FtpClient.delete | train | public function delete(string $remoteFile)
{
if (!@ftp_delete($this->ftp, $remoteFile)) { | php | {
"resource": ""
} |
q10845 | FtpClient.getSize | train | public function getSize(string $remoteFile)
{
$size = @ftp_size($this->ftp, $remoteFile);
if ($size == -1) {
| 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);
| php | {
"resource": ""
} |
q10847 | Route.all | train | public static function all(
string $routeStr,
array $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');
| php | {
"resource": ""
} |
q10849 | Route.delete | train | public static function delete(
string $routeStr,
array $info
) {
| php | {
"resource": ""
} |
q10850 | Route.get | train | public static function get(
string $routeStr,
| 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
| php | {
"resource": ""
} |
q10852 | Route.post | train | public static function post(
string $routeStr,
array $info
) {
| php | {
"resource": ""
} |
q10853 | Route.patch | train | public static function patch(
string $routeStr,
array $info
) {
| php | {
"resource": ""
} |
q10854 | Route.put | train | public static function put(
string $routeStr,
| php | {
"resource": ""
} |
q10855 | Group.addLogin | train | public function addLogin($login)
{
if (!isset($this->logins[$login])) {
$this->logins[$login] = true;
| 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]);
}
| 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) {
| 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();
| 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");
}
}
| 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 | php | {
"resource": ""
} |
q10861 | ViewExtensionHelper._getActiveMenuPatterns | train | protected function _getActiveMenuPatterns($urlInfo = null) {
$deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern();
$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 = '';
| 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 : | 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;
}
| php | {
"resource": ""
} |
q10865 | ViewExtensionHelper.yesNo | train | public function yesNo($data = null) {
if ((bool)$data) {
$result = $this->_getOptionsForElem('yesNo.yes');
} else {
$result | php | {
"resource": ""
} |
q10866 | ViewExtensionHelper.popupModalLink | train | public function popupModalLink($title = null, $url = null, $options = []) {
$optionsDefault = $this->_getOptionsForElem('popupModalLink');
| php | {
"resource": ""
} |
q10867 | ViewExtensionHelper.confirmLink | train | public function confirmLink($title = null, $url = null, $options = []) {
$optionsDefault = $this->_getOptionsConfirmLink();
| 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();
| 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)) {
| php | {
"resource": ""
} |
q10870 | ViewExtensionHelper.ajaxLink | train | public function ajaxLink($title, $url = null, $options = []) {
| php | {
"resource": ""
} |
q10871 | ViewExtensionHelper.requestOnlyLink | train | public function requestOnlyLink($title, $url = null, $options = []) {
| php | {
"resource": ""
} |
q10872 | ViewExtensionHelper.pjaxLink | train | public function pjaxLink($title, $url = null, $options = []) {
| php | {
"resource": ""
} |
q10873 | ViewExtensionHelper.lightboxLink | train | public function lightboxLink($title, $url = null, $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') {
| php | {
"resource": ""
} |
q10875 | ViewExtensionHelper.progressSseLink | train | public function progressSseLink($title, $url = null, $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;
| php | {
"resource": ""
} |
q10877 | ViewExtensionHelper.getBtnClass | train | public function getBtnClass($btn = null) {
$btnClass = $this->_getClassForElement($btn);
if (!empty($btnClass)) | 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 | 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 = [];
| 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];
}
| 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'] | php | {
"resource": ""
} |
q10882 | ViewExtensionHelper.menuItemLabel | train | public function menuItemLabel($title = null) {
$result = '';
if (empty($title)) {
return $result;
}
$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; | 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];
| 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),
[
| 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 | 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 | php | {
"resource": ""
} |
q10888 | ViewExtensionHelper.getFormOptions | train | public function getFormOptions($options = []) {
if (empty($options) || !is_array($options)) {
$options = [];
} | 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;
}
| php | {
"resource": ""
} |
q10890 | ViewExtensionHelper.numberText | train | public function numberText($number = null, $langCode = null) {
if (!is_object($this->_NumberTextLib)) {
return false;
} | 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);
| 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 = | 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');
| 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; | 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');
| 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 | php | {
"resource": ""
} |
q10897 | ViewExtensionHelper.headerPage | train | public function headerPage($pageHeader = null, $headerMenuActions = null) {
$result = '';
if (empty($pageHeader)) {
return $result;
} | 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' . | 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 = | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.