_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q500 | Client.getActionsByResource | train | public function getActionsByResource($resource)
{
if (!isset($this->resources[$resource])) {
return null; // no resource found
}
$actions = array();
foreach ($this->resources[$resource] as $action => $path) {
$actions[] = $action;
}
return $actions;
} | php | {
"resource": ""
} |
q501 | Client.getMethodByAction | train | public function getMethodByAction($action)
{
foreach ($this->methods as $method => $actions) {
if (in_array($action, $actions)) {
return $method;
}
}
return 'get';
} | php | {
"resource": ""
} |
q502 | Client.isMultiPartAction | train | public function isMultiPartAction($resource, $action)
{
return isset($this->multiPartActions[$resource]) && in_array($action, $this->multiPartActions[$resource]);
} | php | {
"resource": ""
} |
q503 | Client.getRequestPath | train | private function getRequestPath($resource, $action, &$params)
{
if (!isset($this->resources[$resource]) || !isset($this->resources[$resource][$action])) {
throw new \UnexpectedValueException('Resource path not found');
}
// get path
$path = $this->resources[$resource][$action];
// replace variables
$matchCount = preg_match_all("/:(\w*)/", $path, $variables);
if ($matchCount) {
foreach ($variables[0] as $index => $placeholder) {
if (!isset($params[$variables[1][$index]])) {
throw new \InvalidArgumentException('Missing parameter: ' . $variables[1][$index]);
}
$path = str_replace($placeholder, $params[$variables[1][$index]], $path);
unset($params[$variables[1][$index]]); // remove parameter from $params
}
}
return $path;
} | php | {
"resource": ""
} |
q504 | Client.callApi | train | private function callApi($method, $path, $params, $isMultiPart)
{
// init session
$ch = curl_init();
// request settings
curl_setopt_array($ch, $this->curlSettings); // basic settings
// url
$url = $this->endpoint . $path;
$url .= $method == 'get' ? $this->getAuthQueryStringWithParams($params) : $this->getAuthQueryString();
curl_setopt($ch, CURLOPT_URL, $url);
// http header
$requestHeaders = $this->httpHeaders;
if (!$isMultiPart) {
$requestHeaders[] = "Content-Type: application/json";
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
// method specific settings
switch ($method) {
case 'post':
curl_setopt($ch, CURLOPT_POST, 1);
// request body
if ($isMultiPart) {
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
// fallback to old method
$params['file'] = '@' . $params['file'];
} else {
// make use of CURLFile
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
$params['file'] = new \CURLFile($params['file']);
}
$postBody = $params;
} else {
$postBody = json_encode($params);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
break;
case 'put':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
case 'delete':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
}
// execute request
$response = curl_exec($ch);
// error handling
if ($response === false) {
throw new \UnexpectedValueException(curl_error($ch));
}
// close connection
curl_close($ch);
// return response
return $response;
} | php | {
"resource": ""
} |
q505 | Data.getConfigData | train | public function getConfigData($field, $storeId = null)
{
if (null === $storeId) {
$storeId = $this->_storeManager->getStore(null);
}
$path = 'installments/' . $field;
return $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
} | php | {
"resource": ""
} |
q506 | Data.getAllInstallmentPaymentMethodCodes | train | public function getAllInstallmentPaymentMethodCodes()
{
$return = [];
$paymentMethods = (array) $this->_scopeConfig->getValue('installments/payment_methods');
foreach ($paymentMethods as $code => $null) {
$return[] = $code;
}
return $return;
} | php | {
"resource": ""
} |
q507 | Data._getInstallmentsHelperFromPaymentMethod | train | protected function _getInstallmentsHelperFromPaymentMethod($methodCode)
{
$helperClassName = $this->_scopeConfig->getValue('installments/payment_methods/'
. $methodCode . '/installments_helper');
$helper = $this->_helperFactory->get($helperClassName);
if (false === $helper instanceof \Magento\Framework\App\Helper\AbstractHelper) {
throw new \LogicException($helperClassName .
' doesn\'t extend Magento\Framework\App\Helper\AbstractHelper');
}
return $helper;
} | php | {
"resource": ""
} |
q508 | Converter.convertLocalFile | train | public function convertLocalFile($inputPath, $outputFormat)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($outputFormat == '')
throw new Exception('Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/saveAs?format=' . $outputFormat;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
$outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat;
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
return $outputFilename;
} else
return $v_output;
} | php | {
"resource": ""
} |
q509 | ProductsServiceProvider.bindRepositories | train | protected function bindRepositories()
{
$bindings = [
AttributeRepositoryContract::class => AttributeRepository::class,
AttributeValueRepositoryContract::class => AttributeValueRepository::class,
ProductRepositoryContract::class => ProductRepository::class,
ProductTypeRepositoryContract::class => ProductTypeRepository::class,
];
foreach ($bindings as $contract => $implementation) {
$this->app->bind($contract, $implementation);
}
} | php | {
"resource": ""
} |
q510 | InterestAmount.collect | train | public function collect(
Quote $quote,
ShippingAssignmentInterface $shippingAssignment,
Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
$baseInterest = (float) $quote->getBaseGabrielqsInstallmentsInterestAmount();
$interest = (float) $quote->getGabrielqsInstallmentsInterestAmount();
$total->addTotalAmount('gabrielqs_installments_interest_amount', $interest);
$total->addBaseTotalAmount('gabrielqs_installments_interest_amount', $baseInterest);
$total->setBaseGrandTotal($total->getBaseGrandTotal() + $baseInterest);
$total->setGrandTotal($total->getGrandTotal() + $interest);
return $this;
} | php | {
"resource": ""
} |
q511 | Method.checkPermission | train | public function checkPermission($method, $context)
{
if (!is_string($method)) {
throw new \TypeError('The method parameter must be a string.');
}
if (!$method) {
throw new \InvalidArgumentException('The method parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return strcasecmp($currentRequest->getMethod(), $method) == 0;
} | php | {
"resource": ""
} |
q512 | Ip.checkPermission | train | public function checkPermission($ip, $context)
{
if (!is_string($ip)) {
throw new \TypeError('The ip parameter must be a string.');
}
if (!$ip) {
throw new \InvalidArgumentException('The ip parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return IpUtils::checkIp($currentRequest->getClientIp(), $ip);
} | php | {
"resource": ""
} |
q513 | InterestAmount.initTotals | train | public function initTotals()
{
if ($value = $this->_getInterestAmount()) {
$installmentInterest = new DataObject(
[
'code' => 'gabrielqs_installments_interest_amount',
'strong' => false,
'value' => $value,
'label' => __('Interest'),
'class' => __('Interest'),
]
);
$this->getParentBlock()->addTotal($installmentInterest, 'gabrielqs_installments_interest_amount');
}
return $this;
} | php | {
"resource": ""
} |
q514 | Host.checkPermission | train | public function checkPermission($host, $context)
{
if (!is_string($host)) {
throw new \TypeError('The host parameter must be a string.');
}
if (!$host) {
throw new \InvalidArgumentException('The host parameter cannot be empty.');
}
$currentRequest = $this->requestStack->getCurrentRequest();
if (!$currentRequest) {
return false;
}
return !!preg_match('{'.$host.'}i', $currentRequest->getHost());
} | php | {
"resource": ""
} |
q515 | ModuleContainer.loadConfig | train | public function loadConfig()
{
$path = $this->getConfigPath();
if (!is_dir($path)) {
return [];
}
$configs = Cache::remember("moduleConfig::{$path}", Carbon::now()->addMinutes(10), function () use ($path) {
$configs = [];
foreach (new \DirectoryIterator($path) as $file) {
if ($file->isDot() or strpos($file->getFilename(), '.php') === false) {
continue;
}
$key = $file->getBasename('.php');
$configs[$key] = array_merge_recursive(require $file->getPathname(), app('config')->get($key, []));
}
return $configs;
});
return $configs;
} | php | {
"resource": ""
} |
q516 | Folder.fileExists | train | public function fileExists($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIExist . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'GET', '', ''));
if (!$responseStream->FileExist->IsExist) {
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q517 | Folder.deleteFile | train | public function deleteFile($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIFile . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q518 | Folder.createFolder | train | public function createFolder($strFolder, $storageName = '')
{
//build URI
$strURIRequest = $this->strURIFolder . $strFolder;
if ($storageName != '') {
$strURIRequest .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURIRequest);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q519 | Folder.deleteFolder | train | public function deleteFolder($folderName, $recursive = false)
{
//check whether folder is set or not
if ($folderName == '')
throw new Exception('No folder name specified');
//build URI
$strURI = $this->strURIFolder . $folderName;
if ($recursive) {
$strURI = $strURI . "?recursive=true";
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
if ($responseStream->Code != 200) {
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q520 | Folder.getFilesList | train | public function getFilesList($strFolder, $storageName = '')
{
//build URI
$strURI = $this->strURIFolder;
//check whether file is set or not
if (!$strFolder == '') {
$strURI .= $strFolder;
}
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Files;
} | php | {
"resource": ""
} |
q521 | Converter.convertByUrl | train | public function convertByUrl($url = '', $format = '', $outputFilename = '')
{
//check whether file is set or not
if ($url == '')
throw new Exception('Url not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?url=' . $url . '&format=' . $format;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($this->saveFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $this->saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . Utils::getFileName($outputFilename) . '.' . $format;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else {
return $v_output;
}
} | php | {
"resource": ""
} |
q522 | Converter.convertLocalFile | train | public function convertLocalFile($inputFile = '', $outputFilename = '', $outputFormat = '')
{
//check whether file is set or not
if ($inputFile == '')
throw new Exception('No file name specified');
if ($outputFormat == '')
throw new Exception('output format not specified');
$strURI = Product::$baseProductUri . '/pdf/convert?format=' . $outputFormat;
if (!file_exists($inputFile)) {
throw new Exception('input file doesnt exist.');
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml');
$v_output = Utils::validateOutput($responseStream, $outputFormat);
if ($v_output === '') {
if ($outputFormat == 'html') {
$saveFormat = 'zip';
} else {
$saveFormat = $outputFormat;
}
if ($outputFilename == '') {
$outputFilename = Utils::getFileName($inputFile) . '.' . $saveFormat;
}
$outputPath = AsposeApp::$outPutLocation . $outputFilename;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q523 | Rule.compare | train | public static function compare(Rule $a, Rule $b, bool $checkTag = false): int
{
return Symbol::compare($a->subject, $b->subject)
?: Symbol::compareList($a->definition, $b->definition)
?: ($b->eof - $a->eof)
?: ($checkTag ? self::compareTag($a->tag, $b->tag) : 0);
} | php | {
"resource": ""
} |
q524 | UserCanBypassAccess.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()));
}
$access = $user->getBypassAccess();
if (!is_bool($access)) {
throw new \UnexpectedValueException(sprintf('The method getBypassAccess() on the user object must return a boolean. Returned type is %s.', gettype($access)));
}
return $access;
} | php | {
"resource": ""
} |
q525 | Cart.getMaximumInstallment | train | public function getMaximumInstallment()
{
if ($this->_maximumInstallment === null) {
$grandTotal = $this->getCartGrandTotal();
$this->_maximumInstallment = $this->_installmentsHelper->getMaximumInstallment($grandTotal);
}
return $this->_maximumInstallment;
} | php | {
"resource": ""
} |
q526 | Import.read | train | public function read(string $filename): array
{
$lines = ['total' => 0, 'read' => 0];
// Open file as SPL object
$file = new \SplFileObject($filename);
// Read line by line
while (!$file->eof()) {
$line = $file->fgets();
// Save line only of not empty
if ($this->isLine($line) && \strlen($line) > 1) {
$line = trim(preg_replace('/\s+/', ' ', $line));
$this->_lines[] = $line;
$lines['read']++;
}
$lines['total']++;
}
return $lines;
} | php | {
"resource": ""
} |
q527 | Import.parse | train | public function parse(): ConfigInterface
{
$config = new Config();
array_map(
function($line) use ($config) {
if (preg_match('/^(\S+)\ (.*)/', $line, $matches)) {
switch ($matches[1]) {
case 'push':
$config->addPush($matches[2]);
break;
case 'ca':
case 'cert':
case 'key':
case 'dh':
case 'tls-auth':
$config->addCert($matches[1], $matches[2]);
break;
default:
$config->add($matches[1], $matches[2]);
break;
}
}
},
$this->_lines
);
return $config;
} | php | {
"resource": ""
} |
q528 | Document.getPageCount | train | public function getPageCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Pages->List);
} | php | {
"resource": ""
} |
q529 | Document.appendDocument | train | public function appendDocument($basePdf, $newPdf, $startPage = 0, $endPage = 0, $sourceFolder = '')
{
//check whether files are set or not
if ($basePdf == '')
throw new Exception('Base file not specified');
if ($newPdf == '')
throw new Exception('File to merge is not specified');
//build URI to merge PDFs
if ($sourceFolder == '')
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $newPdf . ($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '');
else
$strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
'/appendDocument?appendFile=' . $sourceFolder . '/' . $newPdf .
($startPage > 0 ? '&startPage=' . $startPage : '') .
($endPage > 0 ? '&endPage=' . $endPage : '') .
'&folder=' . $sourceFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
$folder = new Folder();
$path = "";
if ($sourceFolder == "") {
$path = $basePdf;
} else {
$path = $sourceFolder . '/' . $basePdf;
}
$outputStream = $folder->GetFile($path);
$outputPath = AsposeApp::$outPutLocation . $basePdf;
Utils::saveFile($outputStream, $outputPath);
} else {
return false;
}
} | php | {
"resource": ""
} |
q530 | Document.mergeDocuments | train | public function mergeDocuments(array $sourceFiles = array())
{
$mergedFileName = $this->getFileName();
//check whether files are set or not
if ($mergedFileName == '')
throw new Exception('Output file not specified');
if (empty($sourceFiles))
throw new Exception('File to merge are not specified');
if (count($sourceFiles) < 2)
throw new Exception('Two or more files are requred to merge');
//Build JSON to post
$documentsList = array('List' => $sourceFiles);
$json = json_encode($documentsList);
$strURI = Product::$baseProductUri . '/pdf/' . $mergedFileName . '/merge';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = json_decode(Utils::processCommand($signedURI, 'PUT', 'json', $json));
if ($responseStream->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q531 | Document.getFormFieldCount | train | public function getFormFieldCount()
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields';
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return count($json->Fields->List);
} | php | {
"resource": ""
} |
q532 | Document.getFormField | train | public function getFormField($fieldName)
{
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
$json = json_decode($responseStream);
return $json->Field;
} | php | {
"resource": ""
} |
q533 | Document.updateFormFields | train | public function updateFormFields(array $fieldArray, $documentFolder = '')
{
if (count($fieldArray) === 0)
throw new Exception('Field array cannot be empty');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields?folder=' . $documentFolder;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
'List' => $fieldArray
));
//get response stream
$responseStream = Utils::processCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save docs on server
$folder = new Folder();
if ($documentFolder) {
$outputStream = $folder->getFile($documentFolder . '/' . $this->getFileName());
} else {
$outputStream = $folder->getFile($this->getFileName());
}
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q534 | Document.updateFormField | train | public function updateFormField($fieldName, $fieldType, $fieldValue)
{
if ($fieldName == '')
throw new Exception('Field name not specified');
if ($fieldType == '')
throw new Exception('Field type not specified');
if ($fieldValue == '')
throw new Exception('Field value not specified');
//build URI
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
//sign URI
$signedURI = Utils::sign($strURI);
$postData = json_encode(array(
"Name" => $fieldName,
"Type" => $fieldType,
"Values" => array($fieldValue)
));
//get response stream
$responseStream = Utils::ProcessCommand($signedURI, 'PUT', 'JSON', $postData);
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Field;
else
return false;
} | php | {
"resource": ""
} |
q535 | Document.getDocumentProperties | train | public function getDocumentProperties()
{
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperties->List;
} | php | {
"resource": ""
} |
q536 | Document.getDocumentProperty | train | public function getDocumentProperty($propertyName = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | php | {
"resource": ""
} |
q537 | Document.setDocumentProperty | train | public function setDocumentProperty($propertyName = '', $propertyValue = '')
{
if ($propertyName == '')
throw new Exception('Property name not specified');
//build URI to replace image
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/documentProperties/' . $propertyName;
$putArray['Value'] = $propertyValue;
$json = json_encode($putArray);
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'PUT', 'json', $json);
$response_arr = json_decode($responseStream);
return $response_arr->DocumentProperty;
} | php | {
"resource": ""
} |
q538 | Document.splitPages | train | public function splitPages($from, $to)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/split?from=' . $from . '&to=' . $to;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
$dispatcher = AsposeApp::getEventDispatcher();
$pageNumber = 1;
foreach ($json->Result->Documents as $splitPage) {
$splitFileName = basename($splitPage->Href);
$strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$fileName = $this->getFileName() . '_' . $pageNumber . '.pdf';
$outputFile = AsposeApp::$outPutLocation . $fileName;
Utils::saveFile($responseStream, $outputFile);
echo $outputFile . '<br />';
$event = new SplitPageEvent($outputFile, $pageNumber);
$dispatcher->dispatch(SplitPageEvent::PAGE_IS_SPLIT, $event);
$pageNumber++;
}
} | php | {
"resource": ""
} |
q539 | Message.setClient | train | public function setClient($client)
{
if ($client instanceof Client && $this->client != $client) {
$this->configureDefaults($client->getMessageDefaults(), true);
}
$this->client = $client;
return $this;
} | php | {
"resource": ""
} |
q540 | Message.setChannel | train | public function setChannel($channel)
{
$this->removeTarget();
if ($channel) {
$this->channel = (string) $channel;
}
return $this;
} | php | {
"resource": ""
} |
q541 | Message.setUser | train | public function setUser($user)
{
$this->removeTarget();
if ($user) {
$this->user = (string) $user;
}
return $this;
} | php | {
"resource": ""
} |
q542 | Message.setAttachmentDefaults | train | public function setAttachmentDefaults($defaults)
{
if ($this->attachmentDefaults != ($defaults = (array) $defaults)) {
$this->attachmentDefaults = $defaults;
$this->setAttachments($this->attachments);
}
return $this;
} | php | {
"resource": ""
} |
q543 | Message.getAttachmentPayload | train | protected function getAttachmentPayload($text = null, $title = null, $images = null, $color = null)
{
$attachment = [];
if ($text) {
$attachment['text'] = $this->stringValue($text);
}
if ($title) {
$attachment['title'] = $this->stringValue($title);
}
if ($images = $this->getImagesPayload($images)) {
$attachment['images'] = $images;
}
if ($color) {
$attachment['color'] = (string) $color;
}
return $attachment;
} | php | {
"resource": ""
} |
q544 | Message.getImagesPayload | train | protected function getImagesPayload($value)
{
$images = [];
foreach ((array) $value as $img) {
if (! empty($img['url'])) {
$img = $img['url'];
}
if (is_string($img) && ! empty($img)) {
$images[] = ['url' => $img];
}
}
return $images;
} | php | {
"resource": ""
} |
q545 | Message.stringValue | train | protected function stringValue($value, $jsonOptions = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
{
if (is_string($value)) {
return $value;
}
if (method_exists($value, '__toString')) {
return (string) $value;
}
if (method_exists($value, 'toArray')) {
$value = $value->toArray();
}
return json_encode($value, $jsonOptions);
} | php | {
"resource": ""
} |
q546 | Message.addImage | train | public function addImage($image, $desc = null, $title = null)
{
return $this->addAttachment($desc, $title, $image);
} | php | {
"resource": ""
} |
q547 | Message.configureDefaults | train | public function configureDefaults(array $defaults, $force = false)
{
if ($force || empty($this->toArray())) {
$attachmentDefaults = $this->attachmentDefaults;
foreach (MessageDefaults::allKeys() as $key) {
if (isset($defaults[$key]) && ! is_null($value = $defaults[$key])) {
if (strpos($key, 'attachment_') !== false) {
if ($key = substr($key, strlen('attachment_'))) {
$attachmentDefaults[$key] = $value;
}
} else {
$this->fillDefaults($key, $value);
}
}
}
$this->setAttachmentDefaults($attachmentDefaults);
}
return $this;
} | php | {
"resource": ""
} |
q548 | Message.fillDefaults | train | protected function fillDefaults($key, $value)
{
if (
($key === MessageDefaults::USER || $key === MessageDefaults::CHANNEL) &&
(! is_null($this->getTarget()))
) {
return;
}
if ($suffix = $this->studlyCase($key)) {
$getMethod = 'get'.$suffix;
$setMethod = 'set'.$suffix;
if (
method_exists($this, $getMethod) &&
is_null($this->{$getMethod}()) &&
method_exists($this, $setMethod)
) {
$this->{$setMethod}($value);
}
}
} | php | {
"resource": ""
} |
q549 | Message.content | train | public function content()
{
$arguments = func_get_args();
$count = count($arguments);
if ($count > 0) {
$this->setText($arguments[0]);
}
if ($count > 1) {
if (is_bool($arguments[1])) {
$this->setMarkdown($arguments[1]);
if ($count > 2) {
$this->setNotification($arguments[2]);
}
} else {
call_user_func_array([$this, 'addAttachment'], array_slice($arguments, 1));
}
}
return $this;
} | php | {
"resource": ""
} |
q550 | Message.toArray | train | public function toArray()
{
return array_filter(
[
'text' => $this->getText(),
'notification' => $this->getNotification(),
'markdown' => $this->getMarkdown(),
'channel' => $this->getChannel(),
'user' => $this->getUser(),
'attachments' => $this->getAttachments(),
],
function ($value, $key) {
return ! (
is_null($value) ||
($key === 'markdown' && $value === true) ||
(is_array($value) && empty($value))
);
},
ARRAY_FILTER_USE_BOTH
);
} | php | {
"resource": ""
} |
q551 | AttributeRepository.syncWithProductType | train | public function syncWithProductType(ProductTypeContract $productType, $attributeIds, array $requiredAttributes = [])
{
$attributeIds = is_array($attributeIds) ? $attributeIds : [$attributeIds];
$pivot = [];
foreach ($attributeIds as $id) {
$pivot[$id] = ['required' => in_array($id, $requiredAttributes)];
}
return $productType->attributes()->sync($pivot);
} | php | {
"resource": ""
} |
q552 | LeaderBoard.getData | train | public function getData($order = self::SORT_DESC)
{
return array(
'items' => array_map(
function (Item $item) {
/*
* @var Item $item
*/
return $item->toArray();
},
array_values($this->getItems($order))
),
);
} | php | {
"resource": ""
} |
q553 | Config.generate | train | public function generate(): string
{
// Init the variable
$config = '';
foreach ($this->getParams() as $key => $value) {
$config .= $key . ((\strlen($value) > 0) ? ' ' . $value : '') . "\n";
}
$certs = $this->getCerts();
if (\count($certs) > 0) {
$config .= "\n### Certificates\n";
foreach ($this->getCerts() as $key => $value) {
$config .= isset($value['content'])
? "<$key>\n{$value['content']}\n</$key>\n"
: "$key {$value['path']}\n";
}
}
$pushes = $this->getPushes();
if (\count($pushes) > 0) {
$config .= "\n### Networking\n";
foreach ($this->getPushes() as $push) {
$config .= 'push "' . $push . "\"\n";
}
}
return $config;
} | php | {
"resource": ""
} |
q554 | Config.addCert | train | public function addCert(string $type, string $pathOrContent, bool $isContent = false): ConfigInterface
{
$type = mb_strtolower($type);
$this->throwIfNotInArray($type, self::CERTS);
if (true === $isContent) {
$this->_certs[$type]['content'] = $pathOrContent;
} else {
$this->_certs[$type]['path'] = $pathOrContent;
}
return $this;
} | php | {
"resource": ""
} |
q555 | Config.delCert | train | public function delCert(string $type): ConfigInterface
{
$type = mb_strtolower($type);
$this->throwIfNotInArray($type, self::CERTS);
unset($this->_certs[$type]);
return $this;
} | php | {
"resource": ""
} |
q556 | Config.getCert | train | public function getCert(string $type): array
{
$type = mb_strtolower($type);
$this->throwIfNotInArray($type, self::CERTS);
return $this->_certs[$type] ?? [];
} | php | {
"resource": ""
} |
q557 | Config.add | train | public function add(string $name, $value = null): ConfigInterface
{
$name = mb_strtolower($name);
// Check if key is certificate or push, or classic parameter
if (\in_array($name, self::CERTS, true)) {
$this->addCert($name, $value);
} elseif ($name === 'push') {
$this->addPush($value);
} else {
$this->_params[$name] = $this->isBool($value);
}
return $this;
} | php | {
"resource": ""
} |
q558 | Config.del | train | public function del(string $name): ConfigInterface
{
// Check if key is certificate or push, or classic parameter
if (\in_array($name, self::CERTS, true)) {
$this->delCert($name);
} elseif ($name === 'push') {
throw new \RuntimeException("Not possible to remove push, use 'delPush' instead");
} else {
$this->_params = array_map(
function($param) use ($name) {
return ($param['name'] === $name) ? null : $param;
},
$this->_params
);
}
return $this;
} | php | {
"resource": ""
} |
q559 | Document.getStats | train | public function getStats(array $options = array())
{
$resolver = new OptionsResolver();
$resolver
->setDefaults(array(
'includeTextInShapes' => 'true',
))
->setDefined(array(
'includeFootnotes', 'includeComments',
))
;
$options = $resolver->resolve($options);
//build URI to get document statistics including resolved parameters
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/statistics?' . http_build_query($options);
AsposeApp::getLogger()->info('WordsDocument getStats call will be made', array(
'call-uri' => $strURI,
));
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->StatData;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q560 | Document.appendDocument | train | public function appendDocument($appendDocs, $importFormatModes, $sourceFolder)
{
//check whether required information is complete
if (count($appendDocs) != count($importFormatModes))
throw new Exception('Please specify complete documents and import format modes');
$post_array = array();
$i = 0;
foreach ($appendDocs as $doc) {
$post_array[] = array("Href" => (($sourceFolder != "" ) ? $sourceFolder . "\\" . $doc : $doc), "ImportFormatMode" => $importFormatModes[$i]);
$i++;
}
$data = array("DocumentEntries" => $post_array);
$json = json_encode($data);
//build URI to merge Docs
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/appendDocument';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save merged docs on server
$folder = new Folder();
$outputStream = $folder->GetFile($sourceFolder . (($sourceFolder == '') ? '' : '/') . $this->getFileName());
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
}
AsposeApp::getLogger()->warning('Error occured, output could not be validated.', array(
'v-output' => $v_output,
));
return $v_output;
} | php | {
"resource": ""
} |
q561 | Document.unprotectDocument | train | public function unprotectDocument(array $options)
{
$resolver = new OptionsResolver();
$resolver->setRequired('Password')
->setDefaults(array(
'ProtectionType' => 'AllowOnlyComments'
))
->setAllowedValues('ProtectionType', array(
'AllowOnlyComments',
'AllowOnlyFormFields',
'AllowOnlyRevisions',
'ReadOnly',
'NoProtection',
));
$options = $resolver->resolve($options);
$json = json_encode($options);
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'DELETE', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$outputFile = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputFile);
return $outputFile;
} else {
return $v_output;
}
} | php | {
"resource": ""
} |
q562 | Document.updateProtection | train | public function updateProtection($oldPassword, $newPassword, $protectionType = 'AllowOnlyComments')
{
if ($oldPassword == '') {
throw new Exception('Please Specify Old Password');
}
if ($newPassword == '') {
throw new Exception('Please Specify New Password');
}
$fieldsArray = array('Password' => $oldPassword, 'NewPassword' => $newPassword, 'ProtectionType' => $protectionType);
$json = json_encode($fieldsArray);
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$outputFile = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($responseStream, $outputFile);
return $outputFile;
}
else
return $v_output;
} | php | {
"resource": ""
} |
q563 | Document.getPageSetup | train | public function getPageSetup($sectionid = '')
{
if ($sectionid == '')
throw new Exception('No Section Id specified');
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/sections/'.$sectionid.'/pageSetup';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET','');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->PageSetup;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q564 | Document.getAllParagraphs | train | public function getAllParagraphs()
{
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/paragraphs';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET','');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Paragraphs->ParagraphLinkList;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q565 | Document.getParagraph | train | public function getParagraph($paragraphid = '')
{
if ($paragraphid == '')
throw new Exception('No Paragraph Id specified');
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/paragraphs/'.$paragraphid.'';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET','');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Paragraph;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q566 | Document.updateParagraphRunFont | train | public function updateParagraphRunFont($options_xml = '', $paragraphid = '', $runid = '')
{
if ($options_xml == '')
throw new Exception('Options not specified.');
if ($paragraphid == '')
throw new Exception('No Paragraph Id specified');
if ($runid == '')
throw new Exception('No Run Id specified');
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/paragraphs/'.$paragraphid.'/runs/'.$runid.'/font';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'XML', $options_xml,'json');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Font;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q567 | Document.getHyperlinks | train | public function getHyperlinks()
{
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/hyperlinks';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Hyperlinks->HyperlinkList;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q568 | Document.getHyperlink | train | public function getHyperlink($hyperlinkIndex)
{
if ($hyperlinkIndex == '')
throw new Exception('Hyperlink index not specified');
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/hyperlinks/' . $hyperlinkIndex;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Hyperlink;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q569 | Document.getBookmarks | train | public function getBookmarks()
{
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/bookmarks';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Bookmarks->BookmarkList;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q570 | Document.getBookmark | train | public function getBookmark($bookmarkName)
{
if ($bookmarkName == '')
throw new Exception('Bookmark name not specified');
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/bookmarks/' . $bookmarkName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200) {
return $json->Bookmark;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q571 | Document.updateBookmark | train | public function updateBookmark($bookmarkName, $bookmarkText)
{
if ($bookmarkName == '')
throw new Exception('Bookmark name not specified');
if ($bookmarkText == '')
throw new Exception('Bookmark text not specified');
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/bookmarks/' . $bookmarkName;
//sign URI
$signedURI = Utils::sign($strURI);
$post_data_arr['Text'] = $bookmarkText;
$postData = json_encode($post_data_arr);
$responseStream = Utils::processCommand($signedURI, 'POST', 'JSON', $postData);
$json = json_decode($responseStream);
if ($json->Code == 200) {
return true;
}
AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
'json-code' => $json->Code,
));
return false;
} | php | {
"resource": ""
} |
q572 | Extractor.getComments | train | public function getComments($slideNo = '', $storageName = '', $folder = '')
{
//check whether file is set or not
if ($slideNo == '')
throw new Exception('Missing required parameter slideNo');
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNo . '/comments';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Status == 'OK')
return $json->SlideComments;
else
return false;
} | php | {
"resource": ""
} |
q573 | Extractor.getImageCount | train | public function getImageCount($storageName = '', $folder = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/images';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Images->List);
} | php | {
"resource": ""
} |
q574 | Extractor.getShapes | train | public function getShapes($slidenumber, $storageName = '', $folder = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slidenumber . '/shapes';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$shapes = array();
foreach ($json->ShapeList->ShapesLinks as $shape) {
$signedURI = Utils::sign($shape->Uri->Href);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$shapes[] = $json;
}
return $shapes;
} | php | {
"resource": ""
} |
q575 | Extractor.getShape | train | public function getShape($slideNumber, $shapeIndex, $storageName = '', $folderName = '') {
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/shapes/' . $shapeIndex;
if ($folderName != '') {
$strURI .= '?folder=' . $folderName;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Shape;
else
return false;
} | php | {
"resource": ""
} |
q576 | Extractor.getColorScheme | train | public function getColorScheme($slideNumber, $storageName = '')
{
//Build URI to get color scheme
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/theme/colorScheme';
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->ColorScheme;
} | php | {
"resource": ""
} |
q577 | Extractor.getFontScheme | train | public function getFontScheme($slideNumber, $storageName = '')
{
//Build URI to get font scheme
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/theme/fontScheme';
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->FontScheme;
} | php | {
"resource": ""
} |
q578 | Extractor.getFormatScheme | train | public function getFormatScheme($slideNumber, $storageName = '')
{
//Build URI to get format scheme
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/theme/formatScheme';
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->FormatScheme;
} | php | {
"resource": ""
} |
q579 | Extractor.getPlaceholderCount | train | public function getPlaceholderCount($slideNumber, $storageName = '', $folder = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/placeholders';
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
//Build URI to get placeholders
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return count($json->Placeholders->PlaceholderLinks);
} | php | {
"resource": ""
} |
q580 | Extractor.getPlaceholder | train | public function getPlaceholder($slideNumber, $placeholderIndex, $storageName = '', $folder = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '/placeholders/' . $placeholderIndex;
if ($folder != '') {
$strURI .= '?folder=' . $folder;
}
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
//Build URI to get placeholders
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->Placeholder;
} | php | {
"resource": ""
} |
q581 | Assignment.getAssignments | train | public function getAssignments()
{
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/assignments/';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Assignments->AssignmentItem;
else
return false;
} | php | {
"resource": ""
} |
q582 | Assignment.getAssignment | train | public function getAssignment($assignmentId)
{
if ($assignmentId == '')
throw new Exception('Assignment ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/assignments/' . $assignmentId;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Assignment;
else
return false;
} | php | {
"resource": ""
} |
q583 | Assignment.addAssignment | train | public function addAssignment($taskUid, $resourceUid, $units, $changedFileName = '')
{
if ($taskUid == '')
throw new Exception('Task Uid not specified');
if ($resourceUid == '')
throw new Exception('Resource Uid not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/assignments?taskUid=' . $taskUid . '&resourceUid=' . $resourceUid . '&units' . $units;
if ($changedFileName != '') {
$strURI .= '&fileName=' . $changedFileName;
$this->setFileName($changedFileName);
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($this->getFileName());
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q584 | Document.getTasks | train | public function getTasks()
{
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/tasks';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Tasks->TaskItem;
else
return false;
} | php | {
"resource": ""
} |
q585 | Document.getTask | train | public function getTask($taskId)
{
if ($taskId == '')
throw new Exception('Task ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/tasks/' . $taskId;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Task;
else
return false;
} | php | {
"resource": ""
} |
q586 | Document.addLink | train | public function addLink($link, $index, $predecessorUid, $successorUid, $linkType, $lag, $lagFormat)
{
if ($link == '')
throw new Exception('Link not specified');
if ($index == '')
throw new Exception('Index not specified');
if ($predecessorUid == '')
throw new Exception('Predecessor UID not specified');
if ($successorUid == '')
throw new Exception('Successor UID not specified');
if ($linkType == '')
throw new Exception('Link Type not specified');
if (!isset($lag))
throw new Exception('Lag not specified');
if ($lagFormat == '')
throw new Exception('Lag Format not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/taskLinks';
//sign URI
$signedURI = Utils::sign($strURI);
$data = array('Link' => $link, 'Index' => $index, 'PredecessorUid' => $predecessorUid,
'SuccessorUid' => $successorUid, 'LinkType' => $linkType, 'Lag' => $lag,
'LagFormat' => $lagFormat);
$jsonData = json_encode($data);
$response = Utils::processCommand($signedURI, 'POST', 'json', $jsonData);
$json = json_decode($response);
if ($json->Code == 200)
return true;
else
return false;
} | php | {
"resource": ""
} |
q587 | Document.getOutlineCode | train | public function getOutlineCode($outlineCodeId)
{
if ($outlineCodeId == '')
throw new Exception('Outline Code ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/outlineCodes/' . $outlineCodeId;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->OutlineCode;
else
return false;
} | php | {
"resource": ""
} |
q588 | Document.getExtendedAttribute | train | public function getExtendedAttribute($extendedAttributeId)
{
if ($extendedAttributeId == '')
throw new Exception('Extended Attribute ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/extendedAttributes/' . $extendedAttributeId;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->ExtendedAttribute;
else
return false;
} | php | {
"resource": ""
} |
q589 | Document.deleteExtendedAttribute | train | public function deleteExtendedAttribute($extendedAttributeId, $changedFileName)
{
if ($extendedAttributeId == '')
throw new Exception('Extended Attribute ID not specified');
//build URI
$strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/extendedAttributes/' . $extendedAttributeId;
if ($changedFileName != '') {
$strURI .= '?fileName=' . $changedFileName;
$this->setFileName($changedFileName);
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'DELETE', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($this->getFileName());
$outputPath = AsposeApp::$outPutLocation . $this->getFileName();
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q590 | BaseRule.compareTag | train | public static function compareTag(?string $a, ?string $b): int
{
if (null === $a) {
return null === $b ? 0 : -1;
}
return null === $b ? 1 : strcmp($a, $b);
} | php | {
"resource": ""
} |
q591 | Document.updateBMPPropertiesFromLocalFile | train | public function updateBMPPropertiesFromLocalFile($inputPath, $bitsPerPixel, $horizontalResolution, $verticalResolution, $outPath)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($bitsPerPixel == '')
throw new Exception('Color Depth not specified');
if ($horizontalResolution == '')
throw new Exception('Horizontal Resolution not specified');
if ($verticalResolution == '')
throw new Exception('Vertical Resolution not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/bmp?bitsPerPixel=' . $bitsPerPixel . '&horizontalResolution=' . $horizontalResolution . '&verticalResolution=' . $verticalResolution;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else {
return $v_output;
}
} | php | {
"resource": ""
} |
q592 | Document.updateGIFProperties | train | public function updateGIFProperties($backgroundColorIndex, $pixelAspectRatio, $interlaced, $outPath)
{
if ($backgroundColorIndex == '')
throw new Exception('Background color index not specified');
if ($pixelAspectRatio == '')
throw new Exception('Pixel aspect ratio not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/gif?backgroundColorIndex=' . $backgroundColorIndex . '&pixelAspectRatio=' . $pixelAspectRatio . '&interlaced=' . $interlaced . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q593 | Document.updateGIFPropertiesFromLocalFile | train | public function updateGIFPropertiesFromLocalFile($inputPath, $backgroundColorIndex, $pixelAspectRatio, $interlaced, $outPath)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($backgroundColorIndex == '')
throw new Exception('Background color index not specified');
if ($pixelAspectRatio == '')
throw new Exception('Pixel aspect ratio not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/gif?backgroundColorIndex=' . $backgroundColorIndex . '&pixelAspectRatio=' . $pixelAspectRatio;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else {
return $v_output;
}
} | php | {
"resource": ""
} |
q594 | Document.updateJPGPropertiesFromLocalFile | train | public function updateJPGPropertiesFromLocalFile($inputPath, $quality, $compressionType, $outPath)
{
//check whether files are set or not
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($quality == '')
throw new Exception('Quality not specified');
if ($compressionType == '')
throw new Exception('Compression Type not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/jpg?quality=' . $quality . '&compressionType=' . $compressionType . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outPath);
return $outPath;
} else {
return $v_output;
}
} | php | {
"resource": ""
} |
q595 | Document.updateTIFFPropertiesFromLocalFile | train | public function updateTIFFPropertiesFromLocalFile($inputPath, $compression, $resolutionUnit, $newWidth, $newHeight, $horizontalResolution, $verticalResolution, $outPath)
{
if ($inputPath == '')
throw new Exception('Input file not specified');
if ($compression == '')
throw new Exception('Compression not specified');
if ($resolutionUnit == '')
throw new Exception('Resolution unit not specified');
if ($newWidth == '')
throw new Exception('New image width not specified');
if ($newHeight == '')
throw new Exception('New image height not specified');
if ($horizontalResolution == '')
throw new Exception('Horizontal resolution not specified');
if ($verticalResolution == '')
throw new Exception('Vertical resolution not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/tiff?compression=' . $compression . '&resolutionUnit=' . $resolutionUnit . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&horizontalResolution=' . $horizontalResolution . '&verticalResolution=' . $verticalResolution . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q596 | Document.updatePSDPropertiesFromLocalFile | train | public function updatePSDPropertiesFromLocalFile($inputPath, $channelsCount, $compression, $outPath)
{
if ($channelsCount == '')
throw new Exception('Channels count not specified');
if ($compression == '')
throw new Exception('Compression method not specified');
if ($outPath == '')
throw new Exception('Output file name not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/psd?channelsCount=' . $channelsCount . '&compression=' . $compression . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | {
"resource": ""
} |
q597 | LogicalAuthorizationExtension.checkRouteAccess | train | public function checkRouteAccess(string $routeName, $user = null): bool
{
return $this->laRoute->checkRouteAccess($routeName, $user);
} | php | {
"resource": ""
} |
q598 | LogicalAuthorizationExtension.checkModelAccess | train | public function checkModelAccess($model, string $action, $user = null): bool
{
return $this->laModel->checkModelAccess($model, $action, $user);
} | php | {
"resource": ""
} |
q599 | LogicalAuthorizationExtension.checkFieldAccess | train | public function checkFieldAccess($model, string $fieldName, string $action, $user = null): bool
{
return $this->laModel->checkFieldAccess($model, $fieldName, $action, $user);
} | php | {
"resource": ""
} |