_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11700 | CryptBehavior.beforeSave | train | public function beforeSave(Event $event, EntityInterface $entity)
{
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
| php | {
"resource": ""
} |
q11701 | CryptBehavior.findDecrypted | train | public function findDecrypted(Query $query, array $options)
{
$options += ['fields' => []];
$mapper = function ($row) use ($options) {
$driver = $this->_table->connection()->driver();
foreach ($this->config('fields') as $field => $type) {
if (($options['fields'] && !in_array($field, (array)$options['fields']))
| php | {
"resource": ""
} |
q11702 | CryptBehavior.beforeFind | train | public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
{
| php | {
"resource": ""
} |
q11703 | CryptBehavior.decrypt | train | public function decrypt($cipher)
{
if (is_resource($cipher)) {
$cipher = stream_get_contents($cipher);
}
| php | {
"resource": ""
} |
q11704 | CryptBehavior._resolveStrategy | train | protected function _resolveStrategy($strategy)
{
$key = Security::salt();
if (!$strategy) {
$class = self::DEFAULT_STRATEGY;
$strategy = new $class($key);
}
if (is_string($strategy) && class_exists($strategy)) {
$strategy | php | {
"resource": ""
} |
q11705 | CryptBehavior._resolveFields | train | protected function _resolveFields($fields)
{
if (is_string($fields)) {
$fields = [$fields];
}
if (!is_array($fields)) {
throw new Exception('Invalid "fields" configuration.');
}
$types = array_keys(Type::map());
foreach ($fields as $field => $type) {
if (is_numeric($field) && is_string($type)) {
unset($fields[$field]);
$field = $type;
| php | {
"resource": ""
} |
q11706 | Parser._get_title | train | protected function _get_title( $content ) {
preg_match( '/<meta +?property=["\']og:title["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1]; | php | {
"resource": ""
} |
q11707 | Parser._get_permalink | train | protected function _get_permalink( $content ) {
preg_match( '/<meta +?property=["\']og:url["\'][^\/>]*? | php | {
"resource": ""
} |
q11708 | Parser._get_description | train | protected function _get_description( $content ) {
preg_match( '/<meta +?property=["\']og:description["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( ! empty( $reg[1] ) ) {
return $reg[1];
| php | {
"resource": ""
} |
q11709 | Parser._get_domain | train | protected function _get_domain( $content ) {
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
}
| php | {
"resource": ""
} |
q11710 | Parser._get_favicon | train | protected function _get_favicon( $content ) {
preg_match( '/<link +?rel=["\']shortcut icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
preg_match( '/<link +?rel=["\']icon["\'][^\/>]*? href=["\']([^"\']+?)["\'][^\/>]*?\/?>/si', $content, $reg );
}
if ( empty( $reg[1] ) ) {
return;
}
$favicon = $reg[1];
$favicon = $this->_relative_path_to_url( $favicon, $content );
if ( is_ssl() ) {
| php | {
"resource": ""
} |
q11711 | Parser._get_thumbnail | train | protected function _get_thumbnail( $content ) {
preg_match( '/<meta +?property=["\']og:image["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
if ( empty( $reg[1] ) ) {
return;
}
$thumbnail = $reg[1];
$thumbnail = $this->_relative_path_to_url( $thumbnail, $content );
if ( is_ssl() ) {
$thumbnail = preg_replace( '|^http:|', 'https:', $thumbnail );
}
$requester = new Requester( $thumbnail );
$response | php | {
"resource": ""
} |
q11712 | Parser._relative_path_to_url | train | protected function _relative_path_to_url( $path, $content ) {
if ( wp_http_validate_url( $path ) ) {
return $path;
}
$permalink = $this->get_permalink();
if ( ! $permalink ) {
$permalink = $this->_get_permalink( $content );
| php | {
"resource": ""
} |
q11713 | GameRepository.findWithLetter | train | public function findWithLetter($letter, $locale)
{
$query = $this->createQueryBuilder('g')
->addSelect('translation');
if ($letter === '0') {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) NOT IN (:list)')
->setParameter('list', range('a', 'z'));
} else {
$query
->innerJoin('g.translations', 'translation')
->where('SUBSTRING(translation.name , 1, 1) = :letter')
| php | {
"resource": ""
} |
q11714 | GameRepository.findSerieGames | train | public function findSerieGames($idSerie)
{
$query = $this->createQueryBuilder('g');
$query
->where('g.idSerie = :idSerie')
->setParameter('idSerie', $idSerie);
| php | {
"resource": ""
} |
q11715 | SyliusRuntime.getProductName | train | public function getProductName($productId): ?string
{
$product = $this->productRepository->find($productId);
| php | {
"resource": ""
} |
q11716 | SyliusRuntime.getTaxonPath | train | public function getTaxonPath($taxonId): ?array
{
$taxon = $this->taxonRepository->find($taxonId);
if (!$taxon instanceof TaxonInterface) {
return null;
}
$parts = [$taxon->getName()];
while ($taxon->getParent() instanceof TaxonInterface) {
| php | {
"resource": ""
} |
q11717 | Debug.separator | train | public static function separator($char = '=', $repeat = 50)
{
if (self::isCli()) {
echo str_repeat($char, $repeat) . "\n";
} else {
| php | {
"resource": ""
} |
q11718 | ExportComponent.export | train | public function export($id = null, $type = 'docx') {
$type = mb_strtolower($type);
if (!empty($type) && !$this->_controller->RequestHandler->prefers($type)) {
throw new BadRequestException(__d('view_extension', 'Invalid request'));
}
if (!method_exists($this->_model, 'generateExportFile') || !method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d('view_extension', 'Export method not found'));
}
| php | {
"resource": ""
} |
q11719 | ExportComponent.preview | train | public function preview($id = null) {
if (!method_exists($this->_model, 'generateExportFile')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'generateExportFile()',
$this->_model->name
));
}
if (!method_exists($this->_model, 'getExportFilename')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'getExportFilename()',
$this->_model->name
));
}
$tempFile = $this->_model->generateExportFile($id);
if (empty($tempFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
}
$previewFile = $tempFile;
$exportPath = $this->_getExportDir();
$pdfTempFile = $exportPath . | php | {
"resource": ""
} |
q11720 | ExportComponent._convertFileToPdf | train | protected function _convertFileToPdf($inputFile = null, $outputFile = null) {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === false) {
throw new InternalErrorException(__d('view_extension', 'Unoconv is not configured'));
}
if (!file_exists($inputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid input file for converting to PDF'));
}
if (empty($outputFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid output file for converting to PDF'));
}
if (mime_content_type($inputFile) === 'application/pdf') {
return false;
}
| php | {
"resource": ""
} |
q11721 | ExportComponent._createImgPreview | train | protected function _createImgPreview($inputFile = null) {
$result = [];
if (empty($inputFile) || !file_exists($inputFile)) {
return $result;
}
$previewFullPath = $this->_getPreviewDir();
$wwwRoot = Configure::read('App.www_root');
if (empty($wwwRoot)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to "www_root" directory'));
}
$wwwRootPos = mb_stripos($previewFullPath, $wwwRoot);
if ($wwwRootPos !== 0) {
throw new InternalErrorException(__d('view_extension', 'Path to preview directory is not contain path to "www_root" directory'));
}
$previewWebRootPath = mb_substr($previewFullPath, mb_strlen($wwwRoot) - 1);
if (empty($previewWebRootPath)) {
throw new InternalErrorException(__d('view_extension', 'Invalid path to preview directory'));
}
$jpgTempFile = uniqid();
$im = new Imagick();
$im->setResolution(150, 150);
if (!$im->readimage($inputFile)) {
$im->clear();
$im->destroy();
return $result;
}
$numPages = $im->getNumberImages();
for ($page = 0; $page < | php | {
"resource": ""
} |
q11722 | ExportComponent._setExportDir | train | protected function _setExportDir($path = null) {
$path = (string)$path;
| php | {
"resource": ""
} |
q11723 | ExportComponent._setPreviewDir | train | protected function _setPreviewDir($path = null) {
$path = (string)$path;
| php | {
"resource": ""
} |
q11724 | ExportComponent._setStorageTimeExport | train | protected function _setStorageTimeExport($time = null) {
$time = (int)$time;
if ($time | php | {
"resource": ""
} |
q11725 | ExportComponent._setStorageTimePreview | train | protected function _setStorageTimePreview($time = null) {
$time = (int)$time;
if ($time | php | {
"resource": ""
} |
q11726 | ExportComponent.download | train | public function download($id = null, $file = null) {
$type = $this->_controller->RequestHandler->prefers();
$exportFileName = null;
if (method_exists($this->_model, 'getExportFilename')) {
$exportFileName = $this->_model->getExportFilename($id, true);
}
$exportPath = $this->_getExportDir();
$downloadFile = $exportPath . $file;
if (!empty($type)) {
$downloadFile .= '.' . $type;
}
if (!file_exists($downloadFile)) {
throw new InternalErrorException(__d('view_extension', 'Invalid file for downloading'));
}
if (!empty($type) && !empty($exportFileName)) {
$this->_controller->response->type($type);
$exportFileName .= '.' . $type; | php | {
"resource": ""
} |
q11727 | ExportComponent._clearDir | train | protected function _clearDir($type = null, $timeNow = null) {
switch (mb_strtolower($type)) {
case 'export':
$clearPath = $this->_getExportDir();
$storageTime = $this->_getStorageTimeExport();
break;
case 'preview':
$clearPath = $this->_getPreviewDir();
$storageTime = $this->_getStorageTimePreview();
break;
default:
return false;
}
$result = true;
$oFolder = new Folder($clearPath, true);
$exportFiles = $oFolder->find('.*', false);
if (empty($exportFiles)) {
return $result;
}
if (!empty($timeNow)) {
$timeNow = (int)$timeNow;
| php | {
"resource": ""
} |
q11728 | ExportComponent._getUnoconvConfig | train | protected function _getUnoconvConfig() {
$cfgUnoconv = $this->_modelConfigTheme->getUnoconvConfig();
if (empty($cfgUnoconv)) {
| php | {
"resource": ""
} |
q11729 | ExportComponent.isUnoconvReady | train | public function isUnoconvReady() {
$cfgUnoconv = $this->_getUnoconvConfig();
if ($cfgUnoconv === | php | {
"resource": ""
} |
q11730 | TwigHandlerTrait.fetchTemplate | train | public function fetchTemplate(Request $request, $template)
{
if (!$this->view instanceof Twig) {
throw new Exception("Twig provider not registered.");
}
foreach ($this->settings['view']['global'] as $key => $map) {
$key = is_numeric($key) ? $map : $key;
switch ($key) {
| php | {
"resource": ""
} |
q11731 | TwigHandlerTrait.renderTemplate | train | public function renderTemplate(Request $request, Response $response, $template, $status = null)
{
$response->getBody()->write($this->fetchTemplate($request, $template));
if ($status) {
| php | {
"resource": ""
} |
q11732 | GateKeeper.isAccessibleBy | train | public static function isAccessibleBy($document, $user)
{
$result = null;
switch (Convertor::baseClassName($user)) {
case 'User': //Admin
$result = true;
break;
case 'Customer': //Customer
| php | {
"resource": ""
} |
q11733 | GateKeeper.getDocumentCompany | train | public static function getDocumentCompany($document)
{
return $document->getDataValue('firma') ? \FlexiPeeHP\FlexiBeeRO::uncode(
| php | {
"resource": ""
} |
q11734 | GateKeeper.getCustomerCompany | train | public static function getCustomerCompany($customer)
{
return $customer->adresar->getDataValue('kod') | php | {
"resource": ""
} |
q11735 | Controller.redirect | train | protected function redirect(string $ref, array $params = [], string $schema = null)
{
$url = $this->link($ref, $params, $schema);
$response = new Response();
| php | {
"resource": ""
} |
q11736 | Attribute.getDefaultValue | train | public function getDefaultValue()
{
if ($this->hasOption(self::OPTION_DEFAULT_VALUE)) {
return $this->getSanitizedValue(
| php | {
"resource": ""
} |
q11737 | Attribute.getValidator | train | public function getValidator()
{
if (!$this->validator) {
$default_validator_class = Validator::CLASS;
$validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);
if (!class_exists($validator_implementor, true)) {
throw new InvalidConfigException(
sprintf(
"Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
$validator_implementor,
$this->getName(),
$this->getType()->getName()
)
);
}
$validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
if (!$validator instanceof ValidatorInterface) {
throw new InvalidTypeException(
sprintf(
| php | {
"resource": ""
} |
q11738 | Attribute.createValueHolder | train | public function createValueHolder($apply_default_values = false)
{
if (!$this->value_holder_implementor) {
$implementor = $this->hasOption(self::OPTION_VALUE_HOLDER)
? $this->getOption(self::OPTION_VALUE_HOLDER)
: $this->buildDefaultValueHolderClassName();
if (!class_exists($implementor)) {
throw new InvalidConfigException(
sprintf(
"Invalid valueholder implementor '%s' configured for attribute '%s' on entity '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined'
)
);
}
$test_value_holder = new $implementor($this);
if (!$test_value_holder instanceof ValueHolderInterface) {
throw new InvalidTypeException(
sprintf(
"Invalid valueholder implementation '%s' given for attribute '%s' on entity type '%s'. " .
"Make sure to implement '%s'.",
$implementor,
$this->getName(),
$this->getType() ? $this->getType()->getName() : 'undefined',
ValueHolderInterface::CLASS
)
);
}
$this->value_holder_implementor = $implementor;
}
| php | {
"resource": ""
} |
q11739 | Console.init | train | public function init(OutputInterface $consoleOutput, $dispatcher)
{
$this->consoleOutput = $consoleOutput;
$this->dispatcher = $dispatcher;
| php | {
"resource": ""
} |
q11740 | Console.getSfStyleOutput | train | public function getSfStyleOutput(): SymfonyStyle
{
if (is_null($this->sfStyleOutput)) { | php | {
"resource": ""
} |
q11741 | BaseOAuth.getRequestToken | train | function getRequestToken($args = array()) {/*{{{*/
$r = $this->oAuthRequest($this->requestTokenURL(), $args);
$token = $this->oAuthParseResponse($r);
| php | {
"resource": ""
} |
q11742 | BaseOAuth.oAuthParseResponse | train | function oAuthParseResponse($responseString) {
$r = array();
foreach (explode('&', $responseString) as $param) {
$pair = explode('=', $param, 2);
| php | {
"resource": ""
} |
q11743 | BaseOAuth.getAccessToken | train | function getAccessToken($args = array()) {/*{{{*/
$r = $this->oAuthRequest($this->accessTokenURL(), $args);
//var_dump($r); | php | {
"resource": ""
} |
q11744 | SqLite.getDsn | train | public function getDsn(): string
{
/*
# File connection
$connection = new PDO('sqlite:<filename>', null, null
array(PDO::ATTR_PERSISTENT => true)
);
# Memory connection
$connection = new PDO('sqlite::memory:', null, null
array(PDO::ATTR_PERSISTENT => true)
| php | {
"resource": ""
} |
q11745 | RestartExpansion.execute | train | public function execute($login, InputInterface $input)
{
$scriptToExecute = 'run.sh';
if ($this->gameData->getServerOs() == GameDataStorage::OS_WINDOWS) {
$scriptToExecute = 'run.bat';
}
$player = $this->playerStorage->getPlayerInfo($login);
$this->chatNotification->sendMessage(
'expansion_core.chat_commands.restart.message',
null,
| php | {
"resource": ""
} |
q11746 | CsvReader.getHeader | train | public function getHeader()
{
if (null == $this->header) {
$header = $this->getNextDataSet();
| php | {
"resource": ""
} |
q11747 | CsvReader.reset | train | public function reset()
{
$this->header = null;
$this->line = 0;
| php | {
"resource": ""
} |
q11748 | SimpleEmailService.listVerifiedEmailAddresses | train | public function listVerifiedEmailAddresses() {
$rest = new SimpleEmailServiceRequest($this, 'GET');
$rest->setParameter('Action', 'ListVerifiedEmailAddresses');
$rest = $rest->getResponse();
if($rest->error === false && $rest->code !== 200) {
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
}
if($rest->error !== false) {
$this->__triggerError('listVerifiedEmailAddresses', $rest->error);
return false;
}
$response = array();
if(!isset($rest->body)) {
return $response;
| php | {
"resource": ""
} |
q11749 | SimpleEmailService.deleteVerifiedEmailAddress | train | public function deleteVerifiedEmailAddress($email) {
$rest = new SimpleEmailServiceRequest($this, 'DELETE');
$rest->setParameter('Action', 'DeleteVerifiedEmailAddress');
$rest->setParameter('EmailAddress', $email);
$rest = $rest->getResponse();
| php | {
"resource": ""
} |
q11750 | SimpleEmailService.__triggerError | train | public function __triggerError($functionname, $error)
{
if($error == false) {
trigger_error(sprintf("SimpleEmailService::%s(): Encountered an error, but no description given", $functionname), E_USER_WARNING);
}
else if(isset($error['curl']) && $error['curl'])
{
trigger_error(sprintf("SimpleEmailService::%s(): %s %s", | php | {
"resource": ""
} |
q11751 | SimpleEmailServiceRequest.setParameter | train | public function setParameter($key, $value, $replace = true) {
if(!$replace && isset($this->parameters[$key]))
{
$temp = (array)($this->parameters[$key]);
$temp[] = $value;
| php | {
"resource": ""
} |
q11752 | SimpleEmailServiceMessage.validate | train | public function validate() {
if(count($this->to) == 0)
return false;
if($this->from == null || strlen($this->from) == 0)
return false;
// messages require at least one of: subject, messagetext, messagehtml.
if(($this->subject == null || strlen($this->subject) == 0)
&& ($this->messagetext == null | php | {
"resource": ""
} |
q11753 | GamecurrencyQuery.filterBySenderlogin | train | public function filterBySenderlogin($senderlogin = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($senderlogin)) {
$comparison = Criteria::IN;
}
| php | {
"resource": ""
} |
q11754 | GamecurrencyQuery.filterByReceiverlogin | train | public function filterByReceiverlogin($receiverlogin = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($receiverlogin)) {
$comparison = Criteria::IN;
}
| php | {
"resource": ""
} |
q11755 | GamecurrencyQuery.filterByTransactionid | train | public function filterByTransactionid($transactionid = null, $comparison = null)
{
if (is_array($transactionid)) {
$useMinMax = false;
if (isset($transactionid['min'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_TRANSACTIONID, $transactionid['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($transactionid['max'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_TRANSACTIONID, $transactionid['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
| php | {
"resource": ""
} |
q11756 | GamecurrencyQuery.filterByBillid | train | public function filterByBillid($billid = null, $comparison = null)
{
if (is_array($billid)) {
$useMinMax = false;
if (isset($billid['min'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_BILLID, $billid['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($billid['max'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_BILLID, $billid['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
| php | {
"resource": ""
} |
q11757 | GamecurrencyQuery.filterByAmount | train | public function filterByAmount($amount = null, $comparison = null)
{
if (is_array($amount)) {
$useMinMax = false;
if (isset($amount['min'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_AMOUNT, $amount['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($amount['max'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_AMOUNT, $amount['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
| php | {
"resource": ""
} |
q11758 | GamecurrencyQuery.filterByMessage | train | public function filterByMessage($message = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($message)) {
$comparison = Criteria::IN;
}
| php | {
"resource": ""
} |
q11759 | GamecurrencyQuery.filterByDatetime | train | public function filterByDatetime($datetime = null, $comparison = null)
{
if (is_array($datetime)) {
$useMinMax = false;
if (isset($datetime['min'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_DATETIME, $datetime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($datetime['max'])) {
$this->addUsingAlias(GamecurrencyTableMap::COL_DATETIME, $datetime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
| php | {
"resource": ""
} |
q11760 | PriceModifier.setPriceModification | train | public function setPriceModification($value)
{
if ($this->exists()) {
$join = $this->manyMany('Reservations');
$table = end($join);
$where = $this->getSourceQueryParam('Foreign.Filter');
$where["`{$this->baseTable()}ID`"] = $this->ID;
SQLUpdate::create(
| php | {
"resource": ""
} |
q11761 | Reader.setOptions | train | public function setOptions(array $options)
{
foreach ($options as | php | {
"resource": ""
} |
q11762 | Reader.setOption | train | public function setOption($name, $value)
{
if (! in_array($name, $this->validOptions)) {
throw new Error('Invalid option ' . $name . '. Valid options are : ' . join(', ', $this->validOptions));
}
// Check duplicate fields in header
if ('header' == $name) {
$cnt = array_count_values($value);
$duplicates = array();
foreach ($cnt as $f => $c) {
if ($c > 1) {
| php | {
"resource": ""
} |
q11763 | Reader.openFile | train | protected function openFile()
{
if (is_null($this->fp)) {
$this->fp = @fopen($this->file, $this->mode);
| php | {
"resource": ""
} |
q11764 | Reader.readLine | train | protected function readLine()
{
if (! $this->valid()) {
throw new Error('End of stream reached, no data to read');
}
$this->currentData = fgetcsv($this->fp, null, $this->delimiter, $this->enclosure);
// Check if EOF is reached
if (false === $this->currentData) {
return false;
} elseif (array(null) == $this->currentData) {
/*
* An empty line in the csv file
| php | {
"resource": ""
} |
q11765 | Reader.fetch | train | public function fetch()
{
if (! $this->valid()) {
return false;
}
| php | {
"resource": ""
} |
q11766 | Reader.getHtmlPreview | train | public function getHtmlPreview($numLines = 5)
{
$html = '<table>';
if ($this->header) {
$html .= '<thead><tr>';
foreach ($this->header as $h) {
$html .= '<th>' . htmlentities($h, ENT_QUOTES, 'UTF-8') . '</th>';
}
$html .= '</tr></thead>';
}
$html .= '<tbody>';
$i = 0;
foreach ($this as $line) {
if ($i >= $numLines) {
| php | {
"resource": ""
} |
q11767 | FiscalYearManager.getNextFiscalYear | train | public function getNextFiscalYear()
{
$fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($this->AuthenticationManager->getCurrentUserOrganizationId()); | php | {
"resource": ""
} |
q11768 | FmlManialink.addDictionaryInformation | train | protected function addDictionaryInformation()
{
$translations = [];
$this->dictionary->removeAllEntries();
$this->getDictionaryInformation($this->manialink, $translations);
foreach ($translations as $msgId => $messages) {
foreach ($messages as $message) {
| php | {
"resource": ""
} |
q11769 | FmlManialink.getDictionaryInformation | train | protected function getDictionaryInformation($control, &$translations)
{
foreach ($control->getChildren() as $child) {
if (($child instanceof Label || $child instanceof FmlLabel) && $child->getTranslate()) {
$id = $child->getTextId();
if (!isset($this->cachedMessages[$id])) {
$textId = 'exp_'.md5($id);
$messages = $this->translationHelper->getTranslations($child->getTextId(), []);
$translations[$textId] = $messages;
$this->cachedMessages[$textId] = $messages;
// Replaces with text | php | {
"resource": ""
} |
q11770 | TypeAbstract.configure | train | protected function configure( \Altamira\JsWriter\JsWriterAbstract $jsWriter )
{
$confInstance = \Altamira\Config::getInstance();
$file = $confInstance['altamira.root'] . $confInstance['altamira.typeconfigpath'];
$config = \parse_ini_file( $file, true );
$libConfig = $config[strtolower( $jsWriter->getLibrary() )];
$type = static::TYPE;
$typeAttributes | php | {
"resource": ""
} |
q11771 | TypeAbstract.getRendererOptions | train | public function getRendererOptions()
{
$opts = array();
foreach( $this->allowedRendererOptions as $opt ) {
if( isset( | php | {
"resource": ""
} |
q11772 | NewBaseAdminModule.isUserAdmin | train | public function isUserAdmin()
{
$user = $this->getUsersDatabase();
$sr = $user->getById($this->_context->authenticatedUserId());
| php | {
"resource": ""
} |
q11773 | JournalManager.getVoucherTypes | train | public function getVoucherTypes()
{
$voucherTypes = array();
$this->VoucherType->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($VoucherType) use | php | {
"resource": ""
} |
q11774 | JournalManager.getFiscalYears | train | public function getFiscalYears()
{
$fiscalYears = array();
$this->FiscalYear->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($FiscalYear) use (&$fiscalYears)
| php | {
"resource": ""
} |
q11775 | JournalManager.getFirstAndLastDayOfCurrentMonth | train | public function getFirstAndLastDayOfCurrentMonth()
{
$Date = new Carbon('first day of this month');
$Date2 = new Carbon('last day of this month');
return array('userFormattedFrom' => $Date->format($this->Lang->get('form.phpShortDateFormat')), 'userFormattedTo' => | php | {
"resource": ""
} |
q11776 | JournalManager.updateJournalVoucherStatus | train | public function updateJournalVoucherStatus($id, $Journal = null, $JournalVoucher = null, $newStatus = null, $databaseConnectionName = null)
{
if(empty($newStatus))
{
$debitSum = $this->JournalEntry->getJournalVoucherDebitSum($id, $databaseConnectionName);
$creditSum = $this->JournalEntry->getJournalVoucherCreditSum($id, $databaseConnectionName);
// var_dump((string) $debitSum, (string) $creditSum, $debitSum == $creditSum, round($debitSum) == round($creditSum), (string) $debitSum == (string) $creditSum );
// var_dump(round($debitSum, 2), round($creditSum, 2), round($debitSum, 2) == round($creditSum, 2));
if(round($debitSum, 2) == round($creditSum, 2))
{
$status = 'B';
}
else
{
$status = 'A';
}
}
else
{
$status = $newStatus;
}
if(empty($JournalVoucher))
{
$JournalVoucher = $this->JournalVoucher->byId($id, $databaseConnectionName);
}
$currentStatus = $JournalVoucher->status;
if($currentStatus != $status)
{
$this->JournalVoucher->update(array('status' | php | {
"resource": ""
} |
q11777 | ClearTransientCache.clearTransients | train | protected function clearTransients()
{
// https://coderwall.com/p/yrqrkw/delete-all-existing-wordpress-transients-in-mysql-database
// DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient_%');
// DELETE FROM `wp_options` WHERE `option_name` LIKE ('_site_transient_%');
| php | {
"resource": ""
} |
q11778 | Factory.createConnection | train | public function createConnection($maxAttempts = 3)
{
if (is_null($this->connection)) {
$lastExcelption = $this->attemptConnection($maxAttempts);
if (!is_null($lastExcelption)) {
$this->console->getSfStyleOutput()->error(
[
"Looks like your Dedicated server is either offline or has wrong config settings",
"Error message: " . $lastExcelption->getMessage()
]
);
| php | {
"resource": ""
} |
q11779 | Linker.isLinked | train | public function isLinked(string $host = null): bool
{
// link exists?
// e.g: isLinked('localhost')
if ($host && isset($this->links[$host])) {
return ($this->links[$host]->status() === Link::STATUS_CONNECTED);
}
// without master/slave directives
// e.g: isLinked()
if (true !== $this->config->get('sharding')) {
foreach ($this->links as $link) {
return ($link->status() === Link::STATUS_CONNECTED);
}
}
// with master/slave directives, check by host
switch (trim((string) $host)) {
// e.g: isLinked(), isLinked('master')
case '':
case Link::TYPE_MASTER:
foreach ($this->links as $link) {
if ($link->getType() == Link::TYPE_MASTER) {
return ($link->status() === Link::STATUS_CONNECTED);
| php | {
"resource": ""
} |
q11780 | Linker.getLink | train | public function getLink(string $host = null): ?Link
{
// link exists?
// e.g: getLink('localhost')
if ($host && isset($this->links[$host])) {
return $this->links[$host];
}
$host = trim((string) $host);
// with master/slave directives
if (true === $this->config->get('sharding')) {
// e.g: getLink(), getLink('master'), getLink('master.mysql.local')
if ($host == '' || $host == Link::TYPE_MASTER) {
return Util::arrayRand(
array_filter($this->links, function($link) {
return $link->getType() == Link::TYPE_MASTER;
}));
}
// e.g: getLink(), getLink('slave'), getLink('slave1.mysql.local')
elseif ($host == Link::TYPE_SLAVE) {
return Util::arrayRand(
| php | {
"resource": ""
} |
q11781 | Generator.getStub | train | protected function getStub($name)
{
if (is_file($path = base_path("resources/stubs/vendor/crud-generator/{$this->stubsGroup}/$name.stub"))) {
| php | {
"resource": ""
} |
q11782 | Generator.getLangPath | train | protected function getLangPath()
{
$sectionSegments = $this->sectionSegments;
if ($this->langDir) {
| php | {
"resource": ""
} |
q11783 | Search.loadData | train | public static function loadData(): void
{
if (Search::$loaded === false) {
$filePath = Search::$DATA_DIR."merged-ultraslim.json";
$contents = @file_get_contents($filePath);
if ($contents === false) {
throw | php | {
"resource": ""
} |
q11784 | Search.getByName | train | public static function getByName(string $name, int $type = Search::ANY): string
{
self::loadData();
$kbEntrys = self::getVariable($name);
if (isset($kbEntrys->a)) {
foreach ($kbEntrys->a as $kbEntry) {
if ($type === Search::ANY) {
return Search::$data->urls[$kbEntry->u]."#".$kbEntry->a;
} | php | {
"resource": ""
} |
q11785 | Search.getVariable | train | public static function getVariable(string $name): stdClass
{
self::loadData();
if (isset(Search::$data->vars->{$name})) {
return Search::$data->vars->{$name};
| php | {
"resource": ""
} |
q11786 | Search.getVariableType | train | public static function getVariableType(string $name): string
{
self::loadData();
$kbEntry = self::getVariable($name);
if (isset($kbEntry->t)) {
| php | {
"resource": ""
} |
q11787 | AbstractController.notFound | train | public function notFound(Request $request, Response $response)
{
| php | {
"resource": ""
} |
q11788 | UpdaterWidgetFactory.setLocalRecord | train | public function setLocalRecord($nick, $checkpoints)
{
if (count($checkpoints) > 0) {
$this->updateValue($this->playerGroup, 'LocalRecordCheckpoints', Builder::getArray($checkpoints, true));
| php | {
"resource": ""
} |
q11789 | Strs.cutstr | train | public static function cutstr($string, $length, $suffix = true, $charset = "utf-8", $start = 0, $dot = ' ...')
{
$str = str_replace(['&', '"', '<', '>'], ['&', '"', '<', '>'], $string);
if (function_exists("mb_substr")) {
$strcut = mb_substr($str, $start, $length, $charset);
if (mb_strlen($str, $charset) > $length) {
return $suffix ? $strcut . $dot : $strcut;
}
return $strcut;
}
$re = [];
$match = [''];
$re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
$re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
| php | {
"resource": ""
} |
q11790 | Command.updateRoles | train | protected function updateRoles()
{
foreach ($this->roles() as $Role) {
$this->authManager->add($Role);
| php | {
"resource": ""
} |
q11791 | Command.updateRules | train | protected function updateRules()
{
foreach ($this->rules() as $Rule) {
$this->authManager->add($Rule);
| php | {
"resource": ""
} |
q11792 | Command.updatePermission | train | protected function updatePermission()
{
foreach ($this->permissions() as $Permission) {
$this->authManager->add($Permission);
| php | {
"resource": ""
} |
q11793 | Command.updateInheritanceRoles | train | protected function updateInheritanceRoles()
{
foreach ($this->inheritanceRoles() as $role => $items) {
foreach ($items as $item) {
$this->authManager
->addChild(RbacFactory::Role($role), RbacFactory::Role($item));
| php | {
"resource": ""
} |
q11794 | Command.updateInheritancePermissions | train | protected function updateInheritancePermissions()
{
foreach ($this->inheritancePermissions() as $role => $items) {
foreach ($items as $item) {
$this->authManager
->addChild(RbacFactory::Role($role), | php | {
"resource": ""
} |
q11795 | MelisInstallerModulesService.getModulePlugins | train | public function getModulePlugins($excludeModulesOnReturn = array())
{
$modules = array();
$excludeModules = array_values($this->getCoreModules());
foreach($this->getAllModules() as $module) {
| php | {
"resource": ""
} |
q11796 | MelisInstallerModulesService.getMelisModules | train | public function getMelisModules()
{
$modules = array();
foreach($this->getAllModules() as $module) {
if(strpos($module, 'Melis') !== false || strpos($module, 'melis') | php | {
"resource": ""
} |
q11797 | TreeComponent.tree | train | public function tree($id = null) {
Configure::write('debug', 0);
if (!method_exists($this->_model, 'getTreeData')) {
throw new InternalErrorException(__d(
'view_extension',
'Method "%s" is not exists in model "%s"',
'getTreeData()',
$this->_model->name
));
}
if (!$this->_controller->request->is('ajax') || !$this->_controller->request->is('post') | php | {
"resource": ""
} |
q11798 | InjectorBuilder.build | train | public function build(Injector $injector = null): Injector
{
if ($injector === null) {
$injector = new Injector();
}
| php | {
"resource": ""
} |
q11799 | Where.where | train | public function where(...$arguments): self
{
switch (count($arguments)) {
case 1:
if (! is_array($arguments[0])) {
throw new InvalidArgumentException;
}
foreach ($arguments[0] as $column => $data) {
if (is_array($data)) {
$this->where($column, ...$data);
} else {
$this->where($column, $data);
}
}
return $this;
break;
case 2:
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.