_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q800
|
Workbook.createWorkbookFromTemplate
|
train
|
public function createWorkbookFromTemplate($templateFileName)
{
if ($templateFileName == '')
throw new Exception('Template file not specified');
//build URI to merge Docs
$strURI
|
php
|
{
"resource": ""
}
|
q801
|
Workbook.getWorksheetsCount
|
train
|
public function getWorksheetsCount()
{
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets';
|
php
|
{
"resource": ""
}
|
q802
|
Workbook.getNamesCount
|
train
|
public function getNamesCount()
{
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/names';
|
php
|
{
"resource": ""
}
|
q803
|
Workbook.getDefaultStyle
|
train
|
public function getDefaultStyle()
{
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/defaultStyle';
|
php
|
{
"resource": ""
}
|
q804
|
Workbook.encryptWorkbook
|
train
|
public function encryptWorkbook($encryptionType = 'XOR', $password = '', $keyLength = '')
{
//Build JSON to post
$fieldsArray['EncriptionType'] = $encryptionType;
$fieldsArray['KeyLength'] = $keyLength;
$fieldsArray['Password'] = $password;
$json = json_encode($fieldsArray);
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/encryption';
$signedURI = Utils::sign($strURI);
|
php
|
{
"resource": ""
}
|
q805
|
Workbook.addWorksheet
|
train
|
public function addWorksheet($worksheetName)
{
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $worksheetName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
|
php
|
{
"resource": ""
}
|
q806
|
Workbook.mergeWorkbook
|
train
|
public function mergeWorkbook($mergeFileName)
{
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/merge?mergeWith=' . $mergeFileName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
|
php
|
{
"resource": ""
}
|
q807
|
Workbook.autofitRows
|
train
|
public function autofitRows($saveFormat = "")
{
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?isAutoFit=true';
if ($saveFormat != '')
$strURI .= '&format=' . $saveFormat;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($saveFormat == '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
|
php
|
{
"resource": ""
}
|
q808
|
Workbook.saveAs
|
train
|
public function saveAs($strXML, $outputFile)
{
if ($strXML == '')
throw new Exception('XML Data not specified');
if ($outputFile == '')
throw new Exception('Output Filename along extension not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/saveAs?newfilename=' . $outputFile;
$signedURI = Utils::Sign($strURI);
$responseStream = Utils::processCommand($signedURI, "POST", "XML", $strXML);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $outputFile;
|
php
|
{
"resource": ""
}
|
q809
|
Utils.codepointToUtf8
|
train
|
public static function codepointToUtf8( $codepoint ) {
if ( $codepoint < 0x80 ) {
return chr( $codepoint );
}
if ( $codepoint < 0x800 ) {
return chr( $codepoint >> 6 & 0x3f | 0xc0 ) .
chr( $codepoint & 0x3f | 0x80 );
}
if ( $codepoint < 0x10000 ) {
return chr( $codepoint >> 12 & 0x0f | 0xe0 ) .
chr( $codepoint >> 6 & 0x3f | 0x80 ) .
chr( $codepoint & 0x3f | 0x80 );
}
|
php
|
{
"resource": ""
}
|
q810
|
Utils.hexSequenceToUtf8
|
train
|
public static function hexSequenceToUtf8( $sequence ) {
$utf = '';
foreach ( explode( '
|
php
|
{
"resource": ""
}
|
q811
|
Utils.utf8ToHexSequence
|
train
|
private static function utf8ToHexSequence( $str ) {
$buf = '';
foreach ( preg_split( '//u', $str, -1, PREG_SPLIT_NO_EMPTY ) as $cp ) {
|
php
|
{
"resource": ""
}
|
q812
|
Utils.utf8ToCodepoint
|
train
|
public static function utf8ToCodepoint( $char ) {
# Find the length
$z = ord( $char[0] );
if ( $z & 0x80 ) {
$length = 0;
while ( $z & 0x80 ) {
$length++;
$z <<= 1;
}
} else {
$length = 1;
}
if ( $length != strlen( $char ) ) {
return false;
}
if ( $length == 1 ) {
return ord( $char );
}
#
|
php
|
{
"resource": ""
}
|
q813
|
HttpObservable.setContentLength
|
train
|
private function setContentLength()
{
if (!is_string($this->body)) {
return;
}
$headers = array_map('strtolower', array_keys($this->headers));
|
php
|
{
"resource": ""
}
|
q814
|
AttributeValue.instantiate
|
train
|
public static function instantiate(AttributeContract $attribute, $value)
{
if (! $attribute->supportsValues()) {
throw new AttributeMustSupportValues();
}
return new static([
|
php
|
{
"resource": ""
}
|
q815
|
Product.instantiate
|
train
|
public static function instantiate(ProductNumberContract $productNumber, ProductTypeContract $productType, $description)
{
return new static([
'product_number' => $productNumber,
|
php
|
{
"resource": ""
}
|
q816
|
CronController.actionStart
|
train
|
public function actionStart($taskCommand = null )
{
/**
* @var $cron Crontab
*/
$cron = $this->module->get($this->module->nameComponent);
$cron->eraseJobs();
$common_params = $this->module->params;
if(!empty($this->module->tasks)) {
if($taskCommand && isset($this->module->tasks[$taskCommand])){
$task = $this->module->tasks[$taskCommand];
$params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params );
$cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'],
$params,
ArrayHelper::getValue($task, 'min'),
ArrayHelper::getValue($task, 'hour'),
ArrayHelper::getValue($task, 'day'),
ArrayHelper::getValue($task, 'month'),
ArrayHelper::getValue($task,
|
php
|
{
"resource": ""
}
|
q817
|
CronController.actionLs
|
train
|
public function actionLs($params = false){
/**
* @var $cron Crontab
*/
if(false == $params) {
$cron = $this->module->get($this->module->nameComponent);
$jobs = $cron->getJobs();
foreach ($jobs as $index=>$job) {
/**
* @var $job Cronjob
*/
|
php
|
{
"resource": ""
}
|
q818
|
ActionsMadeMap.runActionHandler
|
train
|
protected function runActionHandler($action, TreeNodeInterface $node)
{
if ($node instanceof Token) {
try {
return $action($node->getContent());
} catch (AbortParsingException $e) {
if (null === $e->getOffset()) {
throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
}
throw $e;
} catch (AbortNodeException $e) {
throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
} catch (\Throwable $e) {
throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e);
}
}
$args = [];
foreach ($node->getChildren() as $child) {
$args[] = $child->made();
}
try {
$result = $action(...$args);
} catch (AbortNodeException $e) {
throw new AbortParsingException(
|
php
|
{
"resource": ""
}
|
q819
|
Extractor.extractTextFromLocalFile
|
train
|
public function extractTextFromLocalFile($localFile, $language, $useDefaultDictionaries)
{
$strURI = Product::$baseProductUri . '/ocr/recognize?language=' . $language . '&useDefaultDictionaries=';
$strURI .= ($useDefaultDictionaries) ? 'true' : 'false';
$signedURI = Utils::sign($strURI);
$stream = file_get_contents($localFile);
|
php
|
{
"resource": ""
}
|
q820
|
Extractor.extractTextFromUrl
|
train
|
public function extractTextFromUrl($url, $language, $useDefaultDictionaries)
{
$strURI = Product::$baseProductUri . '/ocr/recognize?url=' . $url . '&language=' . $language . '&useDefaultDictionaries=' . $useDefaultDictionaries;
$signedURI = Utils::sign($strURI);
|
php
|
{
"resource": ""
}
|
q821
|
BaseLexer.parse
|
train
|
public function parse(string $input)
{
$pos = 0;
while (null !== ($match = $this->parseOne($input, $pos))) {
$pos =
|
php
|
{
"resource": ""
}
|
q822
|
BaseLexer.parseOne
|
train
|
public function parseOne(string $input, int $pos, array $preferredTokens = []): ?Match
{
$length = strlen($input);
if ($pos >= $length) {
return null;
}
$this->compile();
$whitespace_length = $this->getWhitespaceLength($input, $pos);
if ($whitespace_length) {
$pos += $whitespace_length;
if ($pos >= $length) {
return null;
}
}
$match = $this->match($input, $pos, $preferredTokens);
if (!$match) {
|
php
|
{
"resource": ""
}
|
q823
|
BaseLexer.checkOverlappingNames
|
train
|
private function checkOverlappingNames(array $maps): void
{
$index = 0;
foreach ($maps as $type => $map) {
$rest_maps = array_slice($maps, $index + 1, null, true);
foreach ($rest_maps as $type2 => $map2) {
$same = array_intersect_key($map, $map2);
if ($same) {
throw new \InvalidArgumentException(
|
php
|
{
"resource": ""
}
|
q824
|
BaseLexer.buildFixedAndInlines
|
train
|
private function buildFixedAndInlines(array $fixedMap, array $inlines): array
{
$overlapped = array_intersect($fixedMap, $inlines);
if ($overlapped) {
throw new \InvalidArgumentException(
"Duplicating fixed tokens and inline tokens strings: "
. join(', ', array_map('json_encode', $overlapped))
);
}
// $fixedMap all keys are valid names, so + with integer keys will not loss anything
$all = $fixedMap + array_values($inlines);
// sort in reverse order to let more long items match first
// so /'$$' | '$'/ will find ['$$', '$'] in '$$$' and not ['$', '$', '$']
arsort($all, SORT_STRING);
|
php
|
{
"resource": ""
}
|
q825
|
BaseLexer.buildMap
|
train
|
private function buildMap(array $map, string $join): string
{
$alt = [];
foreach ($map as $type => $re) {
$alt[] = "(?<$type>$re)";
}
if
|
php
|
{
"resource": ""
}
|
q826
|
BaseLexer.match
|
train
|
private function match(string $input, int $pos, array $preferredTokens): ?Match
{
$current_regexp = $this->getRegexpForTokens($preferredTokens);
if (false === preg_match($current_regexp, $input, $match, 0, $pos)) {
$error_code = preg_last_error();
throw new \RuntimeException(
"PCRE error #" . $error_code
. " for token at input pos $pos; REGEXP = $current_regexp",
$error_code
);
}
if (!$match) {
return null;
}
$full_match = $match[0];
if ('' === $full_match) {
throw new DevException(
'Tokens should not match empty string'
. '; context: `' . substr($input, $pos, 10) . '`'
|
php
|
{
"resource": ""
}
|
q827
|
BaseLexer.getWhitespaceLength
|
train
|
private function getWhitespaceLength(string $input, int $pos): int
{
if ($this->regexpWhitespace) {
if (
false === preg_match(
$this->regexpWhitespace,
$input,
$match,
0,
$pos
)
) {
$error_code = preg_last_error();
throw new \RuntimeException(
|
php
|
{
"resource": ""
}
|
q828
|
BaseLexer.checkMapNames
|
train
|
private function checkMapNames(array $map): void
{
$names = array_keys($map);
$bad_names = preg_grep(self::RE_NAME, $names, PREG_GREP_INVERT);
if ($bad_names) {
|
php
|
{
"resource": ""
}
|
q829
|
BaseLexer.validateRegExp
|
train
|
private static function validateRegExp(string $regExp, string $displayName): void
{
/** @uses convertErrorToException() */
set_error_handler([__CLASS__, 'convertErrorToException'], E_WARNING);
try {
if (false === preg_match($regExp, null)) {
throw new \InvalidArgumentException(
"PCRE error in $displayName RegExp: $regExp",
preg_last_error()
);
|
php
|
{
"resource": ""
}
|
q830
|
BaseLexer.textToRegExp
|
train
|
protected function textToRegExp(string $text): string
{
// preg_quote() is useless with /x modifier: https://3v4l.org/brdeT
if (false === strpos($this->modifiers, 'x') || !preg_match('~[\\s/#]|\\\\E~', $text)) {
return preg_quote($text, '/');
}
// foo\Efoo --> \Qfoo\E\\\QEfoo\E
// ---^==== --- ^^ ====
//
|
php
|
{
"resource": ""
}
|
q831
|
Symbol.compare
|
train
|
public static function compare(Symbol $a, Symbol $b): int
{
return ($a->isTerminal
|
php
|
{
"resource": ""
}
|
q832
|
Symbol.compareList
|
train
|
public static function compareList(array $a, array $b): int
{
foreach ($a as $i => $symbol) {
// $b finished, but $a not yet
if (!isset($b[$i])) {
// $a > $b
return 1;
}
// $a[$i] <=> $b[$i]
$result = static::compare($symbol, $b[$i]);
if ($result) {
//# $a[$i] <> $b[$i]
return $result;
|
php
|
{
"resource": ""
}
|
q833
|
Symbol.dumpName
|
train
|
public static function dumpName(string $name): string
{
if (self::isLikeName($name)) {
|
php
|
{
"resource": ""
}
|
q834
|
Symbol.dumpType
|
train
|
public static function dumpType(string $type): string
{
if (self::isLikeName($type)) {
|
php
|
{
"resource": ""
}
|
q835
|
Symbol.dumpInline
|
train
|
public static function dumpInline(string $inline): string
{
if (false === strpos($inline, '"')) {
|
php
|
{
"resource": ""
}
|
q836
|
Extractor.getText
|
train
|
public function getText()
{
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/textItems';
$signedURI
|
php
|
{
"resource": ""
}
|
q837
|
Extractor.getDrawingObject
|
train
|
public function getDrawingObject($objectURI, $outputPath)
{
if ($outputPath == '')
throw new Exception('Output path not specified');
if ($objectURI == '')
throw new Exception('Object URI not specified');
$url_arr = explode('/', $objectURI);
$objectIndex = end($url_arr);
$strURI = $objectURI;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
if ($json->DrawingObject->ImageDataLink != '') {
$strURI = $strURI . '/imageData';
$outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.jpeg';
} else if ($json->DrawingObject->OleDataLink != '') {
$strURI = $strURI . '/oleData';
$outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.xlsx';
} else {
$strURI = $strURI . '?format=jpeg';
|
php
|
{
"resource": ""
}
|
q838
|
Extractor.getProtection
|
train
|
public function getProtection()
{
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection';
$signedURI = Utils::sign($strURI);
|
php
|
{
"resource": ""
}
|
q839
|
StatementPool.push
|
train
|
protected function push(Statement $statement)
{
$maxConnections = $this->pool->getConnectionLimit();
if ($this->statements->count() > ($maxConnections / 10)) {
return;
}
if ($maxConnections
|
php
|
{
"resource": ""
}
|
q840
|
StatementPool.pop
|
train
|
protected function pop(): \Generator
{
while (!$this->statements->isEmpty()) {
$statement = $this->statements->shift();
\assert($statement instanceof Statement);
|
php
|
{
"resource": ""
}
|
q841
|
Converter.convertToImagebySize
|
train
|
public function convertToImagebySize($slideNumber, $imageFormat, $width, $height)
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '?format=' . $imageFormat . '&width=' . $width . '&height=' . $height;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
|
php
|
{
"resource": ""
}
|
q842
|
Converter.convertWithAdditionalSettings
|
train
|
public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance ='', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat;
if ($textCompression != '')
$strURI .= '&TextCompression=' . $textCompression;
if ($embedFullFonts != '')
$strURI .= '&EmbedFullFonts=' . $embedFullFonts;
if ($compliance != '')
$strURI .= '&Compliance=' . $compliance;
if ($jpegQuality != '')
$strURI .= '&JpegQuality=' . $jpegQuality;
if ($saveMetafilesAsPng != '')
$strURI .= '&SaveMetafilesAsPng=' . $saveMetafilesAsPng;
if ($pdfPassword != '')
$strURI .= '&PdfPassword=' . $pdfPassword;
if ($embedTrueTypeFontsForASCII != '')
|
php
|
{
"resource": ""
}
|
q843
|
Extractor.getTiffFrameProperties
|
train
|
public function getTiffFrameProperties($frameId)
{
if ($frameId == '')
throw new Exception('Frame ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '/properties';
//sign URI
$signedURI = Utils::sign($strURI);
|
php
|
{
"resource": ""
}
|
q844
|
Extractor.extractFrames
|
train
|
public function extractFrames($frameId, $outPath)
{
if ($frameId == '')
throw new Exception('Frame ID not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
|
php
|
{
"resource": ""
}
|
q845
|
Extractor.cropFrame
|
train
|
public function cropFrame($frameId, $x, $y, $recWidth, $recHeight, $outPath)
{
if ($frameId == '')
throw new Exception('Frame ID not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($recWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($recHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=true&$x=' . $x . '&y=' . $y . '&rectWidth=' . $recWidth . '&rectHeight=' . $recHeight . '&outPath=' . $outPath;
|
php
|
{
"resource": ""
}
|
q846
|
Extractor.manipulateFrame
|
train
|
public function manipulateFrame($frameId, $rotateFlipMethod, $newWidth, $newHeight, $x, $y, $rectWidth, $rectHeight, $outPath)
{
if ($frameId == '')
throw new Exception('Frame ID not specified');
if ($rotateFlipMethod == '')
throw new Exception('RotateFlip method not specified');
if ($newWidth == '')
throw new Exception('New width not specified');
if ($newHeight == '')
throw new Exception('New height not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($rectHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
|
php
|
{
"resource": ""
}
|
q847
|
UserIsAuthor.checkFlag
|
train
|
public function checkFlag(array $context): bool
{
if (!isset($context['user'])) {
throw new \InvalidArgumentException(sprintf('The context parameter must contain a "user" key to be able to evaluate the %s flag.', $this->getName()));
}
$user = $context['user'];
if (is_string($user)) { //Anonymous user
return false;
}
if (!($user instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
if (!isset($context['model'])) {
throw new \InvalidArgumentException(sprintf('Missing key "model" in context parameter. We cannot evaluate the %s flag without a model.', $this->getName()));
}
$model = $context['model'];
if (is_string($model) && class_exists($model)) {
// A class string was passed which means that we don't have an actual object to evaluate. We interpret this as it not having an author which means that we return false.
return false;
}
if ($model instanceof UserInterface) {
return $user->getId() === $model->getId();
}
if ($model instanceof ModelInterface) {
$author = $model->getAuthor();
// If there is no author it probably means that the entity is not yet
|
php
|
{
"resource": ""
}
|
q848
|
Stack.shift
|
train
|
public function shift(TreeNodeInterface $node, int $stateIndex): void
{
$item = new StackItem();
$item->state = $stateIndex;
$item->node = $node;
if ($this->actions) {
$this->actions->applyToNode($node);
}
|
php
|
{
"resource": ""
}
|
q849
|
Stack.reduce
|
train
|
public function reduce(): void
{
$rule = $this->stateRow->reduceRule;
if (!$rule) {
throw new NoReduceException();
}
$reduce_count = count($rule->getDefinition());
$total_count = count($this->items);
if ($total_count < $reduce_count) {
throw new InternalException('Not enough items in stack');
}
$nodes = [];
$offset = null;
$reduce_items = array_slice($this->items, -$reduce_count);
foreach ($rule->getDefinition() as $i => $symbol) {
$item = $reduce_items[$i];
if ($item->node->getNodeName() !== $symbol->getName()) {
throw new InternalException('Unexpected stack content');
}
if (!$symbol->isHidden()) {
$nodes[] = $item->node;
}
if (null === $offset) {
$offset = $item->node->getOffset();
}
}
|
php
|
{
"resource": ""
}
|
q850
|
QuoteManager.setInstallmentDataBeforeAuthorization
|
train
|
public function setInstallmentDataBeforeAuthorization($installmentQuantity)
{
if ($this->_calculator === null) {
throw new LocalizedException(new Phrase('You need to set an installment calculator befor prior to' .
'installments'));
}
/* @var Quote $quote */
$quote = $this->_getQuote();
$interestRate = $this->_getCalculator()->getInterestRateForInstallment($installmentQuantity);
$interestAmount = $this->_getCalculator()->getInterestAmount($this->_getPaymentAmount(), $installmentQuantity);
$baseinterestAmount = $this->_getCalculator()
->getInterestAmount($this->_getBasePaymentAmount(),
|
php
|
{
"resource": ""
}
|
q851
|
Calculator.getInstallmentConfig
|
train
|
public function getInstallmentConfig()
{
$installmentConfig = $this->_dataObjectFactory->create();
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
$installmentConfig->maximumInstallmentQty = $maxInstallmentQty;
$installmentConfig->minimumInstallmentAmount = $this->getMinimumInstallmentAmount();
$installmentConfig->interestRate = $this->getInterestRate();
$installments = [];
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and
|
php
|
{
"resource": ""
}
|
q852
|
Calculator.getInstallments
|
train
|
public function getInstallments($paymentAmount)
{
$installments = [];
$this->setPaymentAmount($paymentAmount);
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and only one installment, no interest
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->installmentValue = $paymentAmount;
$installments[$curInstallment]->numberInstallments = 1;
$installments[$curInstallment]->interestsApplied = false;
continue;
} else {
$totalAmountAfterInterest = $this->getTotalAmountAfterInterest($curInstallment);
$amountPerInstallment = $totalAmountAfterInterest / $curInstallment;
# If the total per installment is less then the minimum installment amount, we won't
# include this installment
|
php
|
{
"resource": ""
}
|
q853
|
Calculator.getInterestAmount
|
train
|
public function getInterestAmount($amount, $installmentQuantity)
{
$minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity);
if (
($minimumAmountNoInterest === null) ||
($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest)
) {
$interestRateForInstallment = $this->getInterestRateForInstallment($installmentQuantity);
|
php
|
{
"resource": ""
}
|
q854
|
Calculator.getInterestRateForInstallment
|
train
|
public function getInterestRateForInstallment($installments)
{
$interestRate = $this->getInterestRate();
$computationInstallments = ($installments - 1);
|
php
|
{
"resource": ""
}
|
q855
|
Calculator.getMinimumAmountNoInterest
|
train
|
public function getMinimumAmountNoInterest($installments)
{
$return = null;
foreach ($this->_minimumAmountNoInterest as $installmentQty => $minOrderValue) {
if ($installmentQty == $installments) {
|
php
|
{
"resource": ""
}
|
q856
|
Calculator.getTotalAmountAfterInterest
|
train
|
public function getTotalAmountAfterInterest($installments)
{
$return = $amount = $this->getPaymentAmount();
if ($this->isApplyInterest($installments)) {
|
php
|
{
"resource": ""
}
|
q857
|
Calculator.isApplyInterest
|
train
|
public function isApplyInterest($installments)
{
$return = true;
$interestRate = $this->getInterestRate();
$paymentAmount = $this->getPaymentAmount();
if (($installments > 1) && ($interestRate > 1)) {
# If we're not dealing with a one time payment and the interest rate is defined, interest will always be
# applied, except when the payment total is higher than the minimum order value for no
|
php
|
{
"resource": ""
}
|
q858
|
Consumer.reset
|
train
|
public function reset()
{
// clears the object entirely
$this->url = null;
$this->params = array();
|
php
|
{
"resource": ""
}
|
q859
|
Consumer.setParams
|
train
|
public function setParams($params)
{
// $param should be a single key => value pair
if (is_array($params)) {
foreach
|
php
|
{
"resource": ""
}
|
q860
|
Consumer.setOptions
|
train
|
public function setOptions($options)
{
// $param should be a single key => value pair
if (is_array($options)) {
foreach ($options
|
php
|
{
"resource": ""
}
|
q861
|
Consumer.doApiCall
|
train
|
public function doApiCall()
{
$parsedResponse = array();
$jsonResponse = false;
$curlUrl = $this->createUrl();
if ($curlUrl) {
$jsonResponse = $this->submitCurlRequest($curlUrl);
}
if
|
php
|
{
"resource": ""
}
|
q862
|
Consumer.createUrl
|
train
|
public function createUrl()
{
$curlUrl = $this->url . '?';
foreach ($this->params as $key => $value) {
$curlUrl
|
php
|
{
"resource": ""
}
|
q863
|
Consumer.submitCurlRequest
|
train
|
protected function submitCurlRequest($curlUrl)
{
$session = curl_init();
curl_setopt($session, CURLOPT_URL, $curlUrl);
curl_setopt($session, CURLOPT_HEADER, 0);
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
if (!empty($this->options)) {
foreach ($this->options
|
php
|
{
"resource": ""
}
|
q864
|
Utils.processCommand
|
train
|
public static function processCommand($url, $method = 'GET', $headerType = 'XML', $src = '', $returnType = 'xml')
{
$dispatcher = AsposeApp::getEventDispatcher();
$method = strtoupper($method);
$headerType = strtoupper($headerType);
AsposeApp::getLogger()->info("Aspose Cloud SDK: processCommand called", array(
'url' => $url,
'method' => $method,
'headerType' => $headerType,
'src' => $src,
'returnType' => $returnType,
));
$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
if ($method == 'GET') {
curl_setopt($session, CURLOPT_HTTPGET, 1);
} else {
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $src);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($session, CURLOPT_HEADER, false);
if ($headerType == 'XML') {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/' . $returnType . '', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0'));
} else {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0'));
}
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
if (preg_match('/^(https)/i', $url))
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
// Allow users to register curl options before the call is executed
$event = new ProcessCommandEvent($session);
$dispatcher->dispatch(ProcessCommandEvent::PRE_CURL, $event);
$result = curl_exec($session);
$headers = curl_getinfo($session);
|
php
|
{
"resource": ""
}
|
q865
|
Utils.uploadFileBinary
|
train
|
public static function uploadFileBinary($url, $localFile, $headerType = 'XML', $method = 'PUT')
{
$method = strtoupper($method);
$headerType = strtoupper($headerType);
AsposeApp::getLogger()->info("Aspose Cloud SDK: uploadFileBinary called", array(
'url' => $url,
'localFile' => $localFile,
'headerType' => $headerType,
'method' => $method,
));
$fp = fopen($localFile, 'r');
$session = curl_init();
curl_setopt($session, CURLOPT_VERBOSE, 1);
curl_setopt($session, CURLOPT_USERPWD, 'user:password');
curl_setopt($session, CURLOPT_URL, $url);
|
php
|
{
"resource": ""
}
|
q866
|
Utils.saveFile
|
train
|
public static function saveFile($input, $fileName)
{
$fh = fopen($fileName, 'w') or die('cant open file');
|
php
|
{
"resource": ""
}
|
q867
|
Utils.getFieldCount
|
train
|
public function getFieldCount($jsonResponse, $fieldName)
{
$arr =
|
php
|
{
"resource": ""
}
|
q868
|
WeChatVideoDriver.getVideo
|
train
|
private function getVideo()
{
$videoUrl = 'http://file.api.wechat.com/cgi-bin/media/get?
|
php
|
{
"resource": ""
}
|
q869
|
BarcodeReader.read
|
train
|
public function read($symbology)
{
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?' . (!isset($symbology) || trim($symbology) === '' ? 'type=' : 'type=' . $symbology);
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
|
php
|
{
"resource": ""
}
|
q870
|
BarcodeReader.readFromLocalImage
|
train
|
public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType)
{
$folder = new Folder();
$folder->UploadFile($localImage, $remoteFolder);
|
php
|
{
"resource": ""
}
|
q871
|
BarcodeReader.readR
|
train
|
public function readR($remoteImageName, $remoteFolder, $readType)
{
$uri = $this->uriBuilder($remoteImageName, $remoteFolder, $readType);
$signedURI = Utils::sign($uri);
|
php
|
{
"resource": ""
}
|
q872
|
BarcodeReader.uriBuilder
|
train
|
public function uriBuilder($remoteImage, $remoteFolder, $readType)
{
$uri = Product::$baseProductUri . '/barcode/';
if ($remoteImage != null)
$uri .= $remoteImage . '/';
$uri .= 'recognize?';
if ($readType == 'AllSupportedTypes')
|
php
|
{
"resource": ""
}
|
q873
|
BarcodeReader.readFromURL
|
train
|
public function readFromURL($url, $symbology)
{
if ($url == '')
throw new Exception('URL not specified');
if ($symbology == '')
throw new Exception('Symbology not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/recognize?type=' . $symbology . '&url=' . $url;
//sign URI
$signedURI = Utils::sign($strURI);
|
php
|
{
"resource": ""
}
|
q874
|
BarcodeReader.readSpecificRegion
|
train
|
public function readSpecificRegion($symbology, $rectX, $rectY, $rectWidth, $rectHeight)
{
if ($symbology == '')
throw new Exception('Symbology not specified');
if ($rectX == '')
throw new Exception('X position not specified');
if ($rectY == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width not specified');
if ($rectHeight == '')
throw new Exception('Height not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&rectX=' . $rectX . '&rectY=' . $rectY
|
php
|
{
"resource": ""
}
|
q875
|
BarcodeReader.readWithChecksum
|
train
|
public function readWithChecksum($symbology, $checksumValidation)
{
if ($symbology == '')
throw new Exception('Symbology not specified');
if ($checksumValidation == '')
throw new Exception('Checksum not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&checksumValidation=' . $checksumValidation;
//sign URI
$signedURI
|
php
|
{
"resource": ""
}
|
q876
|
BarcodeReader.readByAlgorithm
|
train
|
public function readByAlgorithm($symbology, $binarizationHints)
{
if ($symbology == '')
throw new Exception('Symbology not specified');
if ($binarizationHints == '')
throw new Exception('Binarization Hints count not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&BinarizationHints=' . $binarizationHints;
//sign URI
|
php
|
{
"resource": ""
}
|
q877
|
Field.insertPageNumber
|
train
|
public function insertPageNumber($fileName, $alignment, $format, $isTop, $setPageNumberOnFirstPage)
{
//check whether files are set or not
if ($fileName == '')
throw new Exception('File not specified');
//Build JSON to post
$fieldsArray = array('Format' => $format, 'Alignment' => $alignment,
'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage);
$json = json_encode($fieldsArray);
//build URI to insert page number
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/insertPageNumbers';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
|
php
|
{
"resource": ""
}
|
q878
|
Field.getMailMergeFieldNames
|
train
|
public function getMailMergeFieldNames($fileName)
{
//check whether file is set or not
if ($fileName == '')
throw new Exception('No file name specified');
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/mailMergeFieldNames';
$signedURI
|
php
|
{
"resource": ""
}
|
q879
|
ProductRepository.query
|
train
|
public function query($q = null)
{
return Product::where(function ($query) use ($q) {
if ($q) {
foreach (explode(' ', $q) as $keyword) {
$query->where('description', 'like', "%{$keyword}%");
|
php
|
{
"resource": ""
}
|
q880
|
ProductRepository.save
|
train
|
public function save(ProductContract $product, array $attributes = [])
{
$result = $product->save();
$details = [];
foreach ($attributes as $key => $value) {
if ($value) {
|
php
|
{
"resource": ""
}
|
q881
|
Resource.getResources
|
train
|
public function getResources()
{
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
|
php
|
{
"resource": ""
}
|
q882
|
Resource.getResource
|
train
|
public function getResource($resourceId)
{
if ($resourceId == '')
throw new Exception('Resource ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/' . $resourceId;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream
|
php
|
{
"resource": ""
}
|
q883
|
HasStub.getStubContent
|
train
|
protected function getStubContent($name)
{
if (!isset(static::$stubs[$name])) {
if (!is_file($path = base_path("resources/stubs/vendor/models-generator/$name.stub"))) {
|
php
|
{
"resource": ""
}
|
q884
|
CommentsHelper.handle
|
train
|
public static function handle($model)
{
if (!$model->load(Yii::$app->request->post()))
|
php
|
{
"resource": ""
}
|
q885
|
Query.querySync
|
train
|
public function querySync(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
|
php
|
{
"resource": ""
}
|
q886
|
Query.prepare
|
train
|
public function prepare(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
|
php
|
{
"resource": ""
}
|
q887
|
Config.loadParameters
|
train
|
public function loadParameters()
{
$container = \System::getContainer();
if ($container->hasParameter('contao.video.valid_extensions'))
{
$GLOBALS['TL_CONFIG']['validVideoTypes'] = implode(',', $container->getParameter('contao.video.valid_extensions'));
}
|
php
|
{
"resource": ""
}
|
q888
|
Session.getFromRequest
|
train
|
public static function getFromRequest($create = true)
{
$sessionData = [
'LastIP' => inet_pton($_SERVER['REMOTE_ADDR']),
'LastRequest' => time(),
];
// try to load from cookie
if (!empty($_COOKIE[static::$cookieName])) {
if ($Session = static::getByHandle($_COOKIE[static::$cookieName])) {
// update session & check expiration
$Session = static::updateSession($Session, $sessionData);
}
}
// try to load from any request method
if (empty($Session) && !empty($_REQUEST[static::$cookieName])) {
if ($Session = static::getByHandle($_REQUEST[static::$cookieName])) {
|
php
|
{
"resource": ""
}
|
q889
|
EditorController.overviewAction
|
train
|
public function overviewAction(
Request $request,
FormFactoryInterface $formFactory,
ExtraFormBuilderInterface $extraFormBuilder
) {
$formName = 'overview';
$data = $request->request->get($formName);
$configurationRaw = $data['configuration'];
$configuration = json_decode($configurationRaw, true);
$overviewBuilder = $formFactory
->createNamedBuilder($formName)
->setAction($this->generateUrl('idci_extra_form_editor_overview'))
|
php
|
{
"resource": ""
}
|
q890
|
ImageThumb.create
|
train
|
public function create($filename = null, array $options = [], array $plugins = [])
{
try {
$thumb = new PHPThumb($filename, $options, $plugins);
} catch (\Exception $exc) {
|
php
|
{
"resource": ""
}
|
q891
|
ImageThumb.createReflection
|
train
|
public function createReflection($percent, $reflection, $white, $border, $borderColor)
|
php
|
{
"resource": ""
}
|
q892
|
ImageThumb.createWatermark
|
train
|
public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5)
{
|
php
|
{
"resource": ""
}
|
q893
|
Table.offsetSet
|
train
|
public function offsetSet($columnName, $value)
{
if (!in_array($columnName, static::$_primary)){
|
php
|
{
"resource": ""
}
|
q894
|
SerializerSubscriber.onPreSerialize
|
train
|
public function onPreSerialize(ObjectEvent $event)
{
$configuredType = $event->getObject();
if ($configuredType instanceof ConfiguredType) {
try {
$configurationArray = json_decode($configuredType->getConfiguration(), true);
|
php
|
{
"resource": ""
}
|
q895
|
Comments.outputComment
|
train
|
protected function outputComment($comment)
{
if ($this->commentOptions instanceof \Closure) {
$options = call_user_func($this->commentOptions, $comment);
} else {
$options = $this->commentOptions;
}
$options = ArrayHelper::merge($options, ['data-comment-id'=>$comment->id]);
if ($this->useBootstrapClasses) Html::addCssClass($options, 'media');
//render comment
echo Html::beginTag('div', $options);
//body
$wrapperOptions = ['class'=>'comment-wrapper'];
if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body');
echo Html::beginTag('div', $wrapperOptions);
//title
if (!empty($comment->title)) {
$titleOptions = ['class'=>'comment-title'];
if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading');
$title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title;
echo Html::tag($this->commentTitleTag, $title, $titleOptions);
}
//content
$content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content;
echo Html::tag('div', $content, ['class'=>'comment-content']);
//meta
echo Html::beginTag('dl', ['class'=>'comment-meta']);
echo Html::tag('dt', Yii::t('app', 'Created'));
|
php
|
{
"resource": ""
}
|
q896
|
PHPGit_Repository.create
|
train
|
public static function create($dir, $debug = false, array $options = array())
{
$options = array_merge(self::$defaultOptions, $options);
$commandString =
|
php
|
{
"resource": ""
}
|
q897
|
PHPGit_Repository.cloneUrl
|
train
|
public static function cloneUrl($url, $dir, $debug = false, array $options = array())
{
$options = array_merge(self::$defaultOptions, $options);
$commandString = $options['git_executable'].'
|
php
|
{
"resource": ""
}
|
q898
|
PHPGit_Repository.getCommits
|
train
|
public function getCommits($nbCommits = 10)
{
$output = $this->git(sprintf('log -n %d --date=%s --format=format:%s', $nbCommits,
|
php
|
{
"resource": ""
}
|
q899
|
PHPGit_Repository.parseLogsIntoArray
|
train
|
private function parseLogsIntoArray($logOutput)
{
$commits = array();
foreach(explode("\n", $logOutput) as $line) {
$infos = explode('|', $line);
$commits[] = array(
'id' => $infos[0],
'tree' => $infos[1],
'author' => array(
'name' => $infos[2],
'email' => $infos[3]
),
'authored_date' => $infos[4],
'commiter' => array(
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.