_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q265400
JqueryAjaxExtension.submitTag
test
public function submitTag($options = array()) { $jsSubmit = $this->submitCall(); return function ($options) use($jsSubmit) { $confirm = ''; if (isset($options['confirm']) && $options['confirm'] === true) { $msg = "Are you sure you want to perform this action?"; if(isset($options['confirm_msg'])) { $msg = htmlentities(str_replace("'", '"', $options['confirm_msg']), ENT_QUOTES); } $confirm .= "if(confirm('".$msg."'))" ; } $html = '<button class="' . (isset($options['class']) ? $options['class'] : "") . '" id="' . (isset($options['id']) ? $options['id'] : "") . '" onclick="' .$confirm. call_user_func($jsSubmit, $options) . 'return false;">'; $html .= $options['text']; $html .= '</button>'; return $html; }; }
php
{ "resource": "" }
q265401
Resolver.castKey
test
public function castKey($key, string $default = ""): string { return is_int($key) || empty($key) ? $default : (string)$key; }
php
{ "resource": "" }
q265402
Resolver.isAbstract
test
protected function isAbstract($middleware): bool { return is_string($middleware) && class_exists($middleware) && is_a($middleware, MiddlewareInterface::class, true); }
php
{ "resource": "" }
q265403
Resolver.isCollection
test
public function isCollection($middleware): bool { $isArray = is_array($middleware) && ! is_callable($middleware); return $isArray || $middleware instanceof Traversable || $middleware instanceof ArrayAccess; }
php
{ "resource": "" }
q265404
Resolver.resolve
test
public function resolve($middleware, &$key = null) { if ($this->isCollection($middleware)) { return $this->resolveMany($middleware, $key ?: Group::DEFAULT_ID); } else { return $this->resolveOne($middleware, $key); } }
php
{ "resource": "" }
q265405
Resolver.resolveOrFail
test
public function resolveOrFail($middleware, &$key = null) { if ($this->isCollection($middleware)) { return $this->resolveManyOrFail($middleware, $key ?: Group::DEFAULT_ID); } else { return $this->resolveOneOrFail($middleware, $key); } }
php
{ "resource": "" }
q265406
Resolver.resolveMany
test
protected function resolveMany($group, string $id = Group::DEFAULT_ID): MiddlewareCollection { $group = $group instanceof MiddlewareCollection ? clone $group : $this->collection($group, $id); foreach ($group as $key => $middleware) { $middleware = $this->resolveOne($middleware, $key); if ($middleware !== false) { $group->put($key, $middleware); } } return $group; }
php
{ "resource": "" }
q265407
Resolver.resolveManyOrFail
test
protected function resolveManyOrFail($group, string $id = Group::DEFAULT_ID): MiddlewareCollection { $group = $group instanceof MiddlewareCollection ? clone $group : $this->collection($group, $id); foreach ($group as $key => $middleware) { $middleware = $this->resolveOneOrFail($middleware, $key); if ($middleware !== false) { $group->put($key, $middleware); } } return $group; }
php
{ "resource": "" }
q265408
Resolver.resolveOne
test
protected function resolveOne($middleware, &$key = null) { if ($middleware instanceof Closure) { $key = $key ? $this->castKey($key) : ""; } elseif ($this->isAbstract($middleware)) { $key = $this->castKey($key, $middleware); $middleware = new $middleware; } elseif (is_object($middleware) && $middleware instanceof MiddlewareInterface) { $key = $this->castKey($key, get_class($middleware)); } elseif (is_callable($middleware)) { $key = $key ? $this->castKey($key) : ""; } elseif ($middleware instanceof MiddlewareCollection) { $key = $middleware->getId(); $middleware = $this->resolveMany($middleware, $middleware->getId()); } else { $middleware = false; } return $middleware; }
php
{ "resource": "" }
q265409
Resolver.resolveOneOrFail
test
protected function resolveOneOrFail($middleware, &$key = null) { $type = is_object($middleware) ? get_class($middleware) : gettype($middleware); $middleware = $this->resolveOne($middleware, $key); if ($middleware === false) { $className = MiddlewareInterface::class; $method = get_class($this) . "::resolve"; $msg = "%s expected a Closure, a callable or abstract %s string, or %s. Received: %s"; throw new InvalidArgumentException(sprintf($msg, $method, $className, $className, $type)); } return $middleware; }
php
{ "resource": "" }
q265410
reportService.render
test
public function render($objName) { // get the current UI bizobj $bizform = Openbizx::getObject($objName); // get the existing bizform object $bizobj = $bizform->getDataObj(); $h=opendir($this->targetReportPath); if (!$h) { echo "cannot read dir ".$this->targetReportPath; exit; } // create a tmp csv file for hold the data, then feed csv file to report engine $uid = $this->getUniqueString(); $tmpfname = $this->targetReportPath . $uid . ".csv"; //echo "csv file is at $tmpfname.<br>"; $fp = fopen($tmpfname, 'w'); $keyList = $bizform->recordRow->GetSortControlKeys(); $fieldNames = array(); foreach($keyList as $key) { $fieldNames[] = $bizform->GetControl($key)->bizFieldName; } fputcsv($fp, $fieldNames); $recList = $bizobj->directFetch(); foreach ($recList as $recArray) { unset($fieldValues); $fieldValues = array(); $line = ""; foreach($keyList as $key) { $fieldValues[] = $recArray[$bizform->GetControl($key)->bizFieldName]; } fputcsv($fp, $fieldValues); } fclose($fp); $i = 0; foreach($keyList as $key) { $rpt_fields[$i]["name"] = $bizform->GetControl($key)->bizFieldName; $rpt_fields[$i]["type"] = $bizobj->getField($rpt_fields[$i]["name"])->type; $i++; } // dataobj.rptdesign.tpl // $rpt_data_dir, $rpt_title, $rpt_csv_file, $rpt_fields[](name,type) $smarty = TemplateHelper::getSmartyTemplate(); $smarty->assign("rpt_data_dir", $this->targetReportPath); $smarty->assign("rpt_title", $bizform->title); $smarty->assign("rpt_csv_file", basename($tmpfname)); $smarty->assign("rpt_fields", $rpt_fields); $reportContent = $smarty->fetch($this->rptTemplate); $tmpRptDsgn = $this->targetReportPath . $uid . ".rptdesign"; //echo "temp rpt design file is at $tmpRptDsgn.<br>"; $fp = fopen($tmpRptDsgn, 'w'); fwrite($fp, $reportContent); fclose($fp); ob_clean(); $designFileName = $uid . ".rptdesign"; $content = "<div style='font-family:Arial; font-size:12px; background-color:#FCFCFC;'>"; $content .= "Reports can be viewed as "; $content .= "<li><a href='".$this->birtViewer."/run?__report=report\\$designFileName' target='__blank'>HTML report</a></li>"; $content .= "<li><a href='".$this->birtViewer."/run?__report=report\\$designFileName&__format=pdf' target='__blank'>PDF report</a></li>"; $content .= "<li><a href='".$this->birtViewer."/frameset?__report=report\\$designFileName' target='__blank'>Interactive report</a></li>"; $content .= "</div>"; echo $content; exit; }
php
{ "resource": "" }
q265411
reportService.getUniqueString
test
public function getUniqueString() { $mdy = date("mdy"); $hms = date("His"); $rightnow = $mdy.$hms; return md5($rightnow); }
php
{ "resource": "" }
q265412
HasRoleAndPermission.is
test
public function is($role, $all = false) { if ($this->isPretendEnabled()) { return $this->pretend('is'); } return $this->{$this->getMethodName('is', $all)}($this->getArrayFrom($role)); }
php
{ "resource": "" }
q265413
HasRoleAndPermission.hasRole
test
protected function hasRole($role) { return $this->getRoles()->contains(function ($key, $value) use ($role) { return $role == $value->id || Str::is($role, $value->slug); }); }
php
{ "resource": "" }
q265414
Hash.getHash
test
public function getHash() { $paramString = $this->getParamString(func_get_args()); $encrypted = crypt($paramString, '$2a$07$'.$this->secret.'$'); //echo "encrypted=$encrypted ; paramString=$paramString"; return $encrypted; }
php
{ "resource": "" }
q265415
Client.getInfo
test
public function getInfo($opt = null) { if (null === $opt) { return curl_getinfo($this->getCurl()); } return curl_getinfo($this->getCurl(), $opt); }
php
{ "resource": "" }
q265416
Client.perform
test
public function perform(): Client { if (!empty($this->getUrl())){ $this->setOption(CURLOPT_URL, $this->getUrl()); } if ($this->getOptions()[CURLOPT_HEADER] === 1) { $this->setResponse(substr($this->getResponse(), $this->getInfo(CURLINFO_HEADER_SIZE))); } $this->setResponse(curl_exec($this->getCurl())); /** * Check returned HTTP code between 100 and 399. * See issue #1 */ if (filter_var( $this->getInfo(CURLINFO_HTTP_CODE), FILTER_VALIDATE_INT, ['options' => ['min_range' => 100, 'max_range' => 399]]) ) { $this->_call($this->successCallback ?? function(Client $instance){}, $this); } else { $this->_call($this->errorCallback ?? function(Client $instance){}, $this); } return $this; }
php
{ "resource": "" }
q265417
accessService.allowViewAccess
test
public function allowViewAccess($viewName, $role=null) { if (!$role) $role = ""; $view = $this->getMatchView($viewName); if (!$view) return true; $roleList = $view->getRoleList(); if (!$roleList) return true; if ($roleList->get($role)) return true; return false; }
php
{ "resource": "" }
q265418
accessService.getMatchView
test
protected function getMatchView($viewName) { /* @var $viewObj WebPage */ $viewObj = $this->_restrictedViewList->get($viewName); if ($viewObj) return $viewObj; foreach ($this->_restrictedViewList as $view => $viewObj) { $preg_view = "/".$view."/"; if (preg_match($preg_view, $viewName)) { return $viewObj; } } return null; }
php
{ "resource": "" }
q265419
PhpSettingsWriter.format
test
public function format(IReport $report) { $output = ''; $params = $this->getParameters(); $file = $params->get('location', 'environaut-config.php'); $groups = $params->get('groups'); $nested = $params->get('nested', true); if (is_writable($file)) { $output .= '<comment>Overwriting</comment> '; } else { $output .= 'Writing '; } if (empty($groups)) { $output .= 'all groups '; } else { $output .= 'group(s) "' . implode(', ', $groups) . '" '; } $output .= 'to file "<comment>' . $file . '</comment>"...'; $default_template = <<<EOT <?php return %settings\$s; EOT; $template = $params->get('template', $default_template); $all_settings = $report->getSettingsAsArray($groups); $grouped_settings = array(); foreach ($all_settings as $setting) { if ($nested === true) { $grouped_settings[$setting['group']][$setting['name']] = $setting['value']; } else { $grouped_settings[$setting['name']] = $setting['value']; } } $content = XmlSettingsWriter::vksprintf($template, array('settings' => var_export($grouped_settings, true))); $ok = file_put_contents($file, $content, LOCK_EX); if ($ok !== false) { $output .= '<info>ok</info>.'; } else { $output .= '<error>FAILED</error>.'; } return $output; }
php
{ "resource": "" }
q265420
DomDocument.loadXml
test
public function loadXml($source, $options = 0) { $user_error_handling = $this->enableErrorHandling(); $success = parent::loadXML($source, $options); $this->handleErrors( 'Loading the document failed. Details are:' . PHP_EOL . PHP_EOL, PHP_EOL . 'Please fix the mentioned errors.', $user_error_handling ); $this->refreshXpath(); return $success; }
php
{ "resource": "" }
q265421
DomDocument.schemaValidate
test
public function schemaValidate($filename) { if (!is_readable($filename)) { throw new \DOMException("Schema file is not readable: $filename"); } $user_error_handling = $this->enableErrorHandling(); $success = parent::schemaValidate($filename); $this->handleErrors( 'Validating the document failed. Details are:' . PHP_EOL . PHP_EOL, PHP_EOL . 'Please fix the mentioned errors or use another schema file.', $user_error_handling ); return $success; }
php
{ "resource": "" }
q265422
DomDocument.schemaValidateSource
test
public function schemaValidateSource($source) { if (empty($source)) { throw new \DOMException('Schema is empty.'); } $user_error_handling = $this->enableErrorHandling(); $success = parent::schemaValidateSource($source); $this->handleErrors( 'Validating the document failed. Details are:' . PHP_EOL . PHP_EOL, PHP_EOL . 'Please fix the mentioned errors or use another schema.', $user_error_handling ); return $success; }
php
{ "resource": "" }
q265423
DomDocument.xinclude
test
public function xinclude($options = 0) { $user_error_handling = $this->enableErrorHandling(); $number_of_xincludes = parent::xinclude($options); $this->handleErrors( 'Resolving XInclude directives in the current document failed. Details are:' . PHP_EOL . PHP_EOL, PHP_EOL . 'Please fix the XInclude directives according to the mentioned errors.', $user_error_handling ); return $number_of_xincludes; }
php
{ "resource": "" }
q265424
DomDocument.getElementValue
test
public function getElementValue($element_name, $reference_element = null) { $element_name = trim($element_name); if (empty($element_name)) { throw new \InvalidArgumentException('Element name must not be empty.'); } if (null === $reference_element) { $reference_element = $this->documentElement; } if ($this->isEnvironautDocument()) { foreach ($reference_element->childNodes as $node) { if ($node->nodeType == XML_ELEMENT_NODE && $node->localName == $element_name && $node->namespaceURI == $this->documentElement->namespaceURI ) { return $node->nodeValue; } } } return null; }
php
{ "resource": "" }
q265425
DomDocument.getElement
test
public function getElement($name) { if ($this->isEnvironautDocument()) { foreach ($this->documentElement->childNodes as $node) { if ($node->nodeType == XML_ELEMENT_NODE && $node->localName == $name && $node->namespaceURI == $this->documentElement->namespaceURI ) { return $node; } } } return null; }
php
{ "resource": "" }
q265426
DomDocument.setDefaultNamespace
test
public function setDefaultNamespace($prefix = self::NAMESPACE_PREFIX, $uri = self::NAMESPACE_ENVIRONAUT_1_0) { $this->default_namespace_uri = $uri; $this->default_namespace_prefix = $prefix; $this->xpath->registerNamespace($prefix, $uri); }
php
{ "resource": "" }
q265427
DomDocument.registerEnvironautNamespace
test
public static function registerEnvironautNamespace(DOMDocument $doc) { $doc->getXpath()->registerNamespace(self::NAMESPACE_PREFIX, self::NAMESPACE_ENVIRONAUT_1_0); }
php
{ "resource": "" }
q265428
DomDocument.isEnvironautConfigurationDocument
test
public static function isEnvironautConfigurationDocument(DOMDocument $doc) { return ( $doc->documentElement && $doc->documentElement->localName === 'environaut' && $doc->documentElement->namespaceURI === self::NAMESPACE_ENVIRONAUT_1_0 ); }
php
{ "resource": "" }
q265429
DomDocument.refreshXpath
test
protected function refreshXpath() { unset($this->xpath); $this->xpath = new \DOMXPath($this); if ($this->isEnvironautDocument()) { $this->setDefaultNamespace(self::NAMESPACE_PREFIX, self::NAMESPACE_ENVIRONAUT_1_0); } }
php
{ "resource": "" }
q265430
DomDocument.parseError
test
protected function parseError(\LibXMLError $error) { $msg = ''; switch ($error->level) { case LIBXML_ERR_WARNING: $msg .= 'Warning ' . $error->code . ': '; break; case LIBXML_ERR_FATAL: $msg .= 'Fatal error: ' . $error->code . ': '; break; case LIBXML_ERR_ERROR: default: $msg .= 'Error ' . $error->code . ': '; break; } $msg .= trim($error->message) . PHP_EOL . ' Line: ' . $error->line . PHP_EOL . 'Column: ' . $error->column; if ($error->file) { $msg .= PHP_EOL . ' File: ' . $error->file; } return $msg; }
php
{ "resource": "" }
q265431
ExpressionResolverCache.getResolvers
test
public function getResolvers($subject) { $key = \is_object($subject) ? \get_class($subject) : \gettype($subject); if (\array_key_exists($key, $this->cache)) { return $this->cache[$key]; } $this->cache[$key] = []; foreach ($this->resolvers as $resolver) { if ($resolver->canResolve($subject)) { $this->cache[$key][] = $resolver; } } return $this->cache[$key]; }
php
{ "resource": "" }
q265432
AuthCodeGrant.checkAuthorizeParams
test
public function checkAuthorizeParams() { // Get required params $clientId = $this->server->getRequestHandler()->getParam('client_id'); if (is_null($clientId)) { throw new Exception\InvalidRequestException('client_id'); } $redirectUri = $this->server->getRequestHandler()->getParam('redirect_uri'); if (is_null($redirectUri)) { throw new Exception\InvalidRequestException('redirect_uri'); } // Validate client ID and redirect URI $client = $this->server->getClientStorage()->get( $clientId, null, $redirectUri, $this->getIdentifier() ); if (($client instanceof ClientEntity) === false) { throw new Exception\InvalidClientException(); } $state = $this->server->getRequestHandler()->getParam('state'); if ($this->server->stateParamRequired() === true && is_null($state)) { throw new Exception\InvalidRequestException('state', $redirectUri); } $responseType = $this->server->getRequestHandler()->getParam('response_type'); if (is_null($responseType)) { throw new Exception\InvalidRequestException('response_type', $redirectUri); } // Ensure response type is one that is recognised if (!in_array($responseType, $this->server->getResponseTypes())) { throw new Exception\UnsupportedResponseTypeException($responseType, $redirectUri); } // Validate any scopes that are in the request $scopeParam = $this->server->getRequestHandler()->getParam('scope'); $scopes = $this->validateScopes($scopeParam, $client, $redirectUri); return array( 'client' => $client, 'redirect_uri' => $redirectUri, 'state' => $state, 'response_type' => $responseType, 'scopes' => $scopes ); }
php
{ "resource": "" }
q265433
AuthCodeGrant.newAuthorizeRequest
test
public function newAuthorizeRequest($type, $typeId, $authParams = []) { // Create a new session $session = new SessionEntity($this->server); $session->setOwner($type, $typeId); $session->associateClient($authParams['client']); // Create a new auth code $authCode = new AuthCodeEntity($this->server); $authCode->setId(); $authCode->setRedirectUri($authParams['redirect_uri']); $authCode->setExpireTime(time() + $this->authTokenTTL); foreach ($authParams['scopes'] as $scope) { $authCode->associateScope($scope); $session->associateScope($scope); } $session->save(); $authCode->setSession($session); $authCode->save(); return $authCode->generateRedirectUri($authParams['state']); }
php
{ "resource": "" }
q265434
AuthCodeGrant.completeFlow
test
public function completeFlow(ClientEntity $client) { // Validate the auth code $authCode = $this->server->getRequestHandler()->getParam('code'); if (is_null($authCode)) { throw new Exception\InvalidRequestException('code'); } $code = $this->server->getAuthCodeStorage()->get($authCode); if (($code instanceof AuthCodeEntity) === false) { throw new Exception\InvalidRequestException('code'); } // Ensure the auth code hasn't expired if ($code->isExpired() === true) { throw new Exception\InvalidRequestException('code'); } // Check redirect URI presented matches redirect URI originally used in authorize request if ($code->getRedirectUri() !== $client->getRedirectUri()) { throw new Exception\InvalidRequestException('redirect_uri'); } $session = $code->getSession(); $session->associateClient($client); $authCodeScopes = $code->getScopes(); // Generate the access token $accessToken = new AccessTokenEntity($this->server); $accessToken->setId(); $accessToken->setExpireTime($this->getAccessTokenTTL() + time()); foreach ($authCodeScopes as $authCodeScope) { $session->associateScope($authCodeScope); } foreach ($session->getScopes() as $scope) { $accessToken->associateScope($scope); } $this->server->getTokenType()->setSession($session); $this->server->getTokenType()->setParam('access_token', $accessToken->getId()); $this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL()); // Associate a refresh token if set if ($this->server->hasGrantType('refresh_token')) { $refreshToken = new RefreshTokenEntity($this->server); $refreshToken->setId(); $refreshToken->setExpireTime($this->server->getGrantType('refresh_token')->getRefreshTokenTTL() + time()); $this->server->getTokenType()->setParam('refresh_token', $refreshToken->getId()); } // Expire the auth code $code->expire(); // Save all the things $accessToken->setSession($session); $accessToken->save(); if (isset($refreshToken) && $this->server->hasGrantType('refresh_token')) { $refreshToken->setAccessToken($accessToken); $refreshToken->save(); } return $this->server->getTokenType()->generateResponse(); }
php
{ "resource": "" }
q265435
ClientProxy.printOutput
test
public function printOutput() { if ($this->isRpc == true) { return $this->printJSONOuput(); } foreach ($this->_otherOutput as $output) { print $output; } foreach ($this->_formsOutput as $output) { print $output; } }
php
{ "resource": "" }
q265436
ClientProxy.getFormInputs
test
public function getFormInputs($controlName = null, $toString = TRUE) { if ($controlName) { if (isset($_GET[$controlName])) { $_POST[$controlName] = $_GET[$controlName]; } if (isset($_POST[$controlName])) { if (is_array($_POST[$controlName]) and $toString == TRUE) { $array_string = ''; foreach ($_POST[$controlName] as $rec) { $array_string .= $rec . ","; } $result = substr($array_string, 0, strlen($array_string) - 1); } else { $result = $_POST[$controlName]; } if (get_magic_quotes_gpc() == 1) { if (!is_array($result)) { $result = stripslashes($result); } } return $result; } else { if (isset($_FILES[$controlName])) { $result = true; return $result; } else { return null; } } } else { return $_POST; } }
php
{ "resource": "" }
q265437
ClientProxy.redrawForm
test
public function redrawForm($formName, $sHTML) { if ($this->isRpc) { $this->_formsOutput[$formName] = $this->buildTargetContent($formName, $sHTML); } else { $this->_formsOutput[$formName] = $sHTML; } }
php
{ "resource": "" }
q265438
ClientProxy.showClientAlert
test
public function showClientAlert($alertText) { if ($this->isRpc) { $msg = addslashes($alertText); $this->_otherOutput[] = $this->callClientFunction("alert('" . $msg . "')"); } }
php
{ "resource": "" }
q265439
ClientProxy.showErrorMessage
test
public function showErrorMessage($errMsg) { if (!$errMsg) { return; } if ($this->isRpc) { $_GET['ob_err_msg'] = $errMsg; ob_end_clean(); $form = "common.form.ErrorPopupForm"; $html = Openbizx::getObject($form)->render(); $html = $this->buildTargetContent("DIALOG", $html); $this->_formsOutput[] = $html; } else { $this->_errorOutput($errMsg); } }
php
{ "resource": "" }
q265440
ClientProxy.closePopup
test
public function closePopup() { if ($this->isRpc) { $this->_formsOutput[] = $this->callClientFunction("Openbizx.Window.closePopup()"); $this->_otherOutput[] = $this->callClientFunction("Openbizx.Window.closePopup()"); } }
php
{ "resource": "" }
q265441
ClientProxy.runClientScript
test
public function runClientScript($scriptStr) { if ($this->isRpc) { $this->_otherOutput[] = $this->buildTargetContent("SCRIPT", $scriptStr); } else { echo $scriptStr; } }
php
{ "resource": "" }
q265442
ClientProxy.redirectView
test
public function redirectView($view, $rule = null) { // get the view url form view name $viewParts = explode('.', $view); $viewMod = $viewParts[0]; $viewName = $viewParts[count($viewParts) - 1]; $viewName = strtolower(str_replace("View", "", $viewName)); $url = OPENBIZ_APP_INDEX_URL . "/$viewMod/$viewName"; $this->redirectPage($url); $this->printOutput(); //Openbizx::$app->getClientProxy()->printOutput(); }
php
{ "resource": "" }
q265443
ClientProxy.appendScripts
test
public function appendScripts($scriptKey, $scripts, $isFile = true) { // if has the script key already, ignore if (isset($this->_extraScripts[$scriptKey])) { return; } // add the scripts if ($isFile) { $_scripts = "<script type='text/javascript' src=\"" . Openbizx::$app->getJsUrl() . "/$scripts\"></script>"; $this->_extraScripts[$scriptKey] = $_scripts; } else { $this->_extraScripts[$scriptKey] = $scripts; } }
php
{ "resource": "" }
q265444
ClientProxy.getAppendedScripts
test
public function getAppendedScripts() { $currentView = Openbizx::$app->getCurrentViewName(); $initScripts = "<script>var APP_URL='" . OPENBIZ_APP_URL . "'; var APP_CONTROLLER='" . OPENBIZ_APP_URL . "/bin/controller.php';</script>\n"; $initScripts .= "<script>var APP_VIEWNAME='" . $currentView . "';</script>\n"; $extraScripts = implode("", $this->_extraScripts); $extraScript_array = explode("</script>", $extraScripts); /* if (defined("OPENBIZ_RESOURCE_PHP")) { $js_scripts = OPENBIZ_RESOURCE_PHP."?f="; foreach ($extraScript_array as $script) { // extract src part from each line if (preg_match('/.+src="([^"]+)".+/', $script, $matches) > 0 && !empty($matches[1])) { if (substr($js_scripts, -2)=='f=') $js_scripts .= $matches[1]; else $js_scripts .= ','.$matches[1]; } } return $initScripts."<script type=\"text/javascript\" src=\"".$js_scripts."\"></script>"; } */ $cleanScript_array = array(); foreach ($extraScript_array as $script) { if (in_array($script . "</script>", $cleanScript_array) == FALSE and strlen($script) != 0) { $cleanScript_array[] = $script . "</script>"; } } return $initScripts . implode("\n", $cleanScript_array); }
php
{ "resource": "" }
q265445
ClientProxy.appendStyles
test
public function appendStyles($scriptKey, $styles, $isFile = true) { // if has the script key already, ignore if (isset($this->_extraStyles[$scriptKey])) { return; } // add the styles $css = Openbizx::$app->getCssUrl(); if ($isFile) { $_styles = "<link rel=\"stylesheet\" href=\"$css/" . $styles . "\" type=\"text/css\">"; $this->_extraStyles[$scriptKey] = $_styles; } else { $this->_extraStyles[$scriptKey] = $styles; } }
php
{ "resource": "" }
q265446
ClientProxy.getAppendedStyles
test
public function getAppendedStyles($comb = 0) { $extraStyles = implode("", $this->_extraStyles); $extraStyle_array = explode("type=\"text/css\">", $extraStyles); if (defined("OPENBIZ_RESOURCE_PHP") && $comb) { $css_scripts = OPENBIZ_RESOURCE_PHP . "?f="; $matches = array(); foreach ($extraStyle_array as $style) { // extract href part from each line if (preg_match('/.+href="([^"]+)".+/', $style, $matches) > 0 && !empty($matches[1])) { if (substr($css_scripts, -2) == 'f=') { $css_scripts .= $matches[1]; } else { $css_scripts .= ',' . $matches[1]; } } } return "<link rel=\"stylesheet\" href=\"" . $css_scripts . "\" type=\"text/css\"/>"; } $cleanStyle_array = array(); foreach ($extraStyle_array as $style) { if (in_array($style . "type=\"text/css\">", $cleanStyle_array) == FALSE and strlen($style) != 0) { $cleanStyle_array[] = $style . "type=\"text/css\">"; } } $lang = I18n::getCurrentLangCode(); $localization_css_file = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "localization.css"; if (is_file($localization_css_file)) { $cleanStyle_array[] = "<link rel=\"stylesheet\" href=\"" . OPENBIZ_APP_URL . "/languages/$lang/localization.css\" type=\"text/css\">"; } return implode("\n", $cleanStyle_array); }
php
{ "resource": "" }
q265447
ClientProxy.includeBaseClientScripts
test
public function includeBaseClientScripts() { if (defined('OPENBIZ_JSLIB_BASE') && OPENBIZ_JSLIB_BASE == 'JQUERY') { Openbizx::$app->getClientProxy()->appendScripts("jquery", "jquery.js"); Openbizx::$app->getClientProxy()->appendScripts("jquery_class", "jquery.class.js"); Openbizx::$app->getClientProxy()->appendScripts("jquery_dollarj", "<script>try{var \$j=\$;}catch(e){}</script>", false); Openbizx::$app->getClientProxy()->appendStyles("default", "openbiz.css"); if (DeviceUtil::$PHONE_TOUCH) { Openbizx::$app->getClientProxy()->appendScripts("openbiz", "openbiz.mobile.js"); Openbizx::$app->getClientProxy()->appendScripts("jquery_mobile", "jqm/jquery.mobile-1.0.js"); $style = "<link rel=\"stylesheet\" href=\"" . Openbizx::$app->getJsUrl() . "/jqm/jquery.mobile-1.0.css\" type=\"text/css\">"; Openbizx::$app->getClientProxy()->appendStyles("jquery_mobile_css", $style, false); } else { Openbizx::$app->getClientProxy()->appendScripts("openbiz", "openbiz.js"); Openbizx::$app->getClientProxy()->appendScripts("jquery_ui", "jquery-ui-1.8.16.custom.min.js"); $style = "<link rel=\"stylesheet\" href=\"" . Openbizx::$app->getJsUrl() . "/jquery-ui/ui-lightness/jquery-ui-1.8.16.custom.css\" type=\"text/css\">"; $style .= "<link rel=\"stylesheet\" href=\"" . Openbizx::$app->getJsUrl() . "/jquery-ui/ui-openbiz/jquery.css\" type=\"text/css\">"; Openbizx::$app->getClientProxy()->appendStyles("jquery_ui_css", $style, false); } return; } // prototype is still the default js lib Openbizx::$app->getClientProxy()->appendScripts("prototype", "prototype.js"); Openbizx::$app->getClientProxy()->appendScripts("scriptaculous", "scriptaculous.js"); Openbizx::$app->getClientProxy()->appendScripts("effects", "effects.js"); Openbizx::$app->getClientProxy()->appendScripts("controls", "controls.js"); Openbizx::$app->getClientProxy()->appendScripts("cookies", "cookies.js"); Openbizx::$app->getClientProxy()->appendScripts("openbiz", "openbiz.js"); Openbizx::$app->getClientProxy()->appendStyles("default", "openbiz.css"); // window lib Openbizx::$app->getClientProxy()->includePropWindowScripts(); // validator lib //Openbizx::$app->getClientProxy()->includeValidatorScripts(); }
php
{ "resource": "" }
q265448
ClientProxy.includeRTEScripts
test
public function includeRTEScripts() { if (isset($this->_extraScripts['rte'])) { return; } $script = "<script type=\"text/javascript\" src=\"" . Openbizx::$app->getJsUrl() . "/richtext.js\"></script>"; $script .= "<script language=\"JavaScript\">initRTE('" . Openbizx::$app->getImageUrl() . "/rte/', '../pages/rte/', '', false);</script>"; $this->appendScripts("rte", $script, false); }
php
{ "resource": "" }
q265449
ClientProxy.includeCKEditorScripts
test
public function includeCKEditorScripts() { if (isset($this->_extraScripts['ckeditor'])) { return; } $script = "<script type=\"text/javascript\" src=\"" . Openbizx::$app->getJsUrl() . "/ckeditor/ckeditor.js\"></script>"; $this->appendScripts("ckeditor", $script, false); }
php
{ "resource": "" }
q265450
ClientProxy.includePropWindowScripts
test
public function includePropWindowScripts() { $this->appendScripts("scriptaculous", "scriptaculous.js"); $this->appendScripts("prop_window", "window.js"); $style = "<link rel=\"stylesheet\" href=\"" . Openbizx::$app->getJsUrl() . "/window/default.css\" type=\"text/css\">"; //$style .= "<link rel=\"stylesheet\" href=\"".Openbizx::$app->getJsUrl()."/window/spread.css\" type=\"text/css\">"; //$style .= "<link rel=\"stylesheet\" href=\"".Openbizx::$app->getJsUrl()."/window/lighting.css\" type=\"text/css\">"; $this->appendStyles("prop_window", $style, false); }
php
{ "resource": "" }
q265451
ClientProxy.includeValidatorScripts
test
public function includeValidatorScripts() { $this->appendScripts("yav", "yav/yav.js"); $this->appendScripts("yav-cfg", "yav/yav-config.js"); //$this->appendScripts("validator", "validator.js"); $style = "<link rel=\"stylesheet\" href=\"" . Openbizx::$app->getCssUrl() . "/validator.css\" type=\"text/css\">"; $this->appendStyles("yav", $style, false); }
php
{ "resource": "" }
q265452
doTriggerService.executeAllActions
test
protected function executeAllActions($doTrigger, $dataObj) { if (!$this->matchCondition($doTrigger, $dataObj)) return; /* @var $triggerAction TriggerAction */ foreach ($doTrigger->triggerActions as $triggerAction) { $this->executeAction($triggerAction, $dataObj); } }
php
{ "resource": "" }
q265453
doTriggerService._composeActionMessage
test
private function _composeActionMessage($triggerAction, $methodName, $argList) { $actionMsg["Method"] = $methodName; $actionMsg["ArgList"] = $argList; $actionMsg["DelayMinutes"] = $triggerAction->delayMinutes; $actionMsg["RepeatMinutes"] = $triggerAction->repeatMinutes; $actionMsg["StartTime"] = strftime("%Y-%m-%d %H:%M:%S"); }
php
{ "resource": "" }
q265454
doTriggerService._makeArray
test
static private function _makeArray($string) { if (!$string) return null; $arr = explode(";", $string); $size = count($arr); for ($i = 0; $i < $size; $i ++) $arr[$i] = trim($arr[$i]); return $arr; }
php
{ "resource": "" }
q265455
EasyForm.processFormObjError
test
public function processFormObjError($errors) { $this->errors = $errors; $this->hasError = true; return $this->rerender(); }
php
{ "resource": "" }
q265456
EasyForm.setSubForms
test
final public function setSubForms($subForms) { // sub controls string with format: ctrl1;ctrl2... if (!$subForms || strlen($subForms) < 1) { $this->subForms = null; return; } $subFormArr = explode(";", $subForms); unset($this->subForms); foreach ($subFormArr as $subForm) { $this->subForms[] = $this->prefixPackage($subForm); } }
php
{ "resource": "" }
q265457
EasyForm.loadPicker
test
public function loadPicker($formName, $elementName = "") { // set the ParentFormName and ParentCtrlName of the popup form /* @var $pickerForm EasyForm */ $pickerForm = Openbizx::getObject($formName); if ($elementName != "") { // set the picker map as well $element = $this->getElement($elementName); $pickerMap = $element->pickerMap; } $currentRecord = $this->readInputRecord(); $pickerForm->setParentForm($this->objectName); $pickerForm->setParentFormData($this->objectName, $elementName, $pickerMap); $pickerForm->parentFormRecord = $currentRecord; Openbizx::$app->getClientProxy()->redrawForm("DIALOG", $pickerForm->render()); }
php
{ "resource": "" }
q265458
EasyForm.setRequestParams
test
public function setRequestParams($paramFields) { if ($paramFields) { $this->fixSearchRule = null; // reset fixsearchrule to clean the previous one in session foreach ($paramFields as $fieldName => $val) { $element = $this->dataPanel->getByField($fieldName); if ($element->allowURLParam == 'Y') { if (!$this->getDataObj()) { return; } if ($this->getDataObj()->getField($fieldName)) { if ($this->getDataObj()->getField($fieldName)->checkValueType($val)) { //echo __METHOD__.__LINE__.'<br />'; $this->setFixSearchRule("[$fieldName]='$val'"); } } } } } }
php
{ "resource": "" }
q265459
EasyForm.fetchDataSet
test
public function fetchDataSet() { $dataObj = $this->getDataObj(); if (!$dataObj) { return null; } if ($this->isRefreshData) { $dataObj->resetRules(); } else { $dataObj->clearSearchRule(); } if ($this->fixSearchRule) { if ($this->searchRule) { $searchRule = $this->searchRule . " AND " . $this->fixSearchRule; } else { $searchRule = $this->fixSearchRule; } } else { $searchRule = $this->searchRule; } $dataObj->setQueryParameters($this->queryParams); $dataObj->setSearchRule($searchRule); if ($this->startItem > 1) { $dataObj->setLimit($this->range, $this->startItem); } else { $dataObj->setLimit($this->range, ($this->currentPage - 1) * $this->range); } if ($this->sortRule && $this->sortRule != $this->getDataObj()->sortRule) { $dataObj->setSortRule($this->sortRule); } $resultRecords = $dataObj->fetch(); $this->totalRecords = $dataObj->count(); if ($this->range && $this->range > 0) { $this->totalPages = ceil($this->totalRecords / $this->range); } $selectedIndex = 0; //if current page is large than total pages ,then reset current page to last page if ($this->currentPage > $this->totalPages && $this->totalPages > 0) { $this->currentPage = $this->totalPages; $dataObj->setLimit($this->range, ($this->currentPage - 1) * $this->range); $resultRecords = $dataObj->fetch(); } $this->getDataObj()->setActiveRecord($resultRecords[$selectedIndex]); if (!$this->recordId) { $this->recordId = $resultRecords[0]["Id"]; } else { $foundRecordId = false; foreach ($resultRecords as $record) { if ($this->recordId == $record['Id']) { $foundRecordId = true; } } if ($foundRecordId == false) { $this->recordId = $result[0]['Id']; } } return $resultRecords; }
php
{ "resource": "" }
q265460
EasyForm.getElementID
test
public function getElementID() { $id = $this->dataPanel->getByField('Id')->getValue(); if ($id) { return (int) $id; } else { return (int) $this->recordId; } }
php
{ "resource": "" }
q265461
EasyForm.autoSuggest
test
public function autoSuggest($input) { if (defined('OPENBIZ_JSLIB_BASE') && OPENBIZ_JSLIB_BASE == 'JQUERY') { $value = $_GET["term"]; // get the select from list of the element $element = $this->getElement($input); $element->setValue($value); $fromlist = array(); $element->getFromList($fromlist); $arr = array(); $i = 0; foreach ($fromlist as $item) { $arr[$i++] = array('label' => $item['txt'], 'value' => $item['val']); } echo json_encode($arr); return; } $foo = $_POST; $hidden_flag = FALSE; if (strpos($input, '_hidden')) { $realInput = str_replace('_hidden', '', $input); $hidden_flag = TRUE; } else { $realInput = $input; } $value = Openbizx::$app->getClientProxy()->getFormInputs($input); // get the select from list of the element $element = $this->getElement($realInput); $element->setValue($value); $fromlist = array(); $element->getFromList($fromlist); echo "<ul>"; if ($fromlist) { if ($hidden_flag = TRUE) { $count = 0; foreach ($fromlist as $item) { echo "<li id=" . $item['txt'] . ">" . $item['val'] . "</li>"; $count++; if ($count >= 5) break; } } else { $count = 0; foreach ($fromlist as $item) { echo "<li>" . $item['txt'] . "</li>"; $count++; if ($count >= 5) break; } } } echo "</ul>"; }
php
{ "resource": "" }
q265462
EasyForm.renderContextMenu
test
protected function renderContextMenu() { $menuList = array(); foreach ($this->panels as $panel) { $panel->rewind(); while ($element = $panel->current()) { $panel->next(); if (method_exists($element, 'getContextMenu') && $menus = $element->getContextMenu()) { foreach ($menus as $m) $menuList[] = $m; } } } if (count($menuList) == 0) return ""; $str = "<div class='contextMenu' id='" . $this->objectName . "_contextmenu'>\n"; $str .= "<div class=\"contextMenu_header\" ></div>\n"; $str .= "<ul>\n"; foreach ($menuList as $m) { $func = $m['func']; $shortcutKey = isset($m['key']) ? " (" . $m['key'] . ")" : ""; $str .= "<li><a href=\"javascript:void(0)\" onclick=\"$func\">" . $m['text'] . $shortcutKey . "</a></li>\n"; } $str .= "</ul>\n"; $str .= "<div class=\"contextMenu_footer\" ></div>\n"; $str .= "</div>\n"; if (defined('OPENBIZ_JSLIB_BASE') && OPENBIZ_JSLIB_BASE == 'JQUERY') { $str .= " <script> $(jq('" . $this->objectName . "')).removeAttr('onContextMenu'); $(jq('" . $this->objectName . "'))[0].oncontextmenu=function(event){return Openbizx.Menu.show(event, '" . $this->objectName . "_contextmenu');}; $(jq('" . $this->objectName . "')).bind('click',Openbizx.Menu.hide); </script>"; } else { $str .= " <script> $('" . $this->objectName . "').removeAttribute('onContextMenu'); $('" . $this->objectName . "').oncontextmenu=function(event){return Openbizx.Menu.show(event, '" . $this->objectName . "_contextmenu');}; $('" . $this->objectName . "').observe('click',Openbizx.Menu.hide); </script>"; } return $str; }
php
{ "resource": "" }
q265463
EasyForm.renderHTML
test
protected function renderHTML() { $formHTML = FormRenderer::render($this); $otherHTML = $this->rendercontextmenu(); if (preg_match('/iPad/si', $_SERVER['HTTP_USER_AGENT']) || preg_match('/iPhone/si', $_SERVER['HTTP_USER_AGENT'])) { $otherHTML.=" <script> var a=document.getElementsByTagName('a'); for(var i=0;i<a.length;i++) { if(a[i].getAttribute('href').indexOf('javascript:')==-1 && a[i].getAttribute('href').indexOf('#')==-1) { a[i].onclick=function() { try{ show_loader(); }catch(e){ } window.location=this.getAttribute('href'); return false } }else{ } } </script> "; } if (!$this->parentFormName) { if (($viewObj = $this->getWebpageObject()) != null) $viewObj->lastRenderedForm = $this->objectName; } return $formHTML . "\n" . $otherHTML; }
php
{ "resource": "" }
q265464
EasyForm.getEventLogMsg
test
protected function getEventLogMsg() { list($element, $eventHandler) = $this->getInvokingElement(); $eventLogMsg = $eventHandler->eventLogMsg; if ($eventLogMsg) { return $eventLogMsg; } else { return null; } }
php
{ "resource": "" }
q265465
EasyForm.getOnEventElements
test
protected function getOnEventElements() { $elementList = array(); foreach ($this->dataPanel as $element) { if ($element->onEventLog == "Y") $elementList[] = $element->value; } return $elementList; }
php
{ "resource": "" }
q265466
EasyForm.runEventLog
test
protected function runEventLog() { $logMessage = $this->getEventLogMsg(); $eventName = $this->eventName; if ($logMessage && $eventName) { $logElements = $this->getOnEventElements(); $eventlog = Openbizx::getService(OPENBIZ_EVENTLOG_SERVICE); $eventlog->log($eventName, $logMessage, $logElements); } }
php
{ "resource": "" }
q265467
EasyForm.getInvokingElement
test
protected function getInvokingElement() { if ($this->invokingElement) return $this->invokingElement; // __this is elementName:eventHandlerName $elementAndEventName = Openbizx::$app->getClientProxy()->getFormInputs("__this"); if (!$elementAndEventName) return array(null, null); list ($elementName, $eventHandlerName) = explode(":", $elementAndEventName); $element = $this->getElement($elementName); $eventHandler = $element->eventHandlers->get($eventHandlerName); $this->invokingElement = array($element, $eventHandler); return $this->invokingElement; }
php
{ "resource": "" }
q265468
EasyForm.setClientScripts
test
protected function setClientScripts() { // load custom js class if ($this->jsClass != "Openbizx.Form" && $this->jsClass != "Openbizx.TableForm" && $this->jsClass != "") Openbizx::$app->getClientProxy()->appendScripts($this->jsClass, $this->jsClass . ".js"); /* if ($this->formType == 'LIST') { Openbizx::$app->getClientProxy()->appendScripts("tablekit", "tablekit.js"); } */ }
php
{ "resource": "" }
q265469
MiddlewareManager.remove
test
public function remove(string $middlewareClass): void { foreach( $this->middlewareStack as $i => $middleware ){ if( $middleware instanceof $middlewareClass ){ unset($this->middlewareStack[$i]); } } }
php
{ "resource": "" }
q265470
MiddlewareManager.run
test
public function run(Request $request, callable $kernel): Response { $next = array_reduce(array_reverse($this->middlewareStack), function(callable $next, MiddlewareLayerInterface $layer): \Closure { return function(Request $request) use ($next, $layer): Response { return $layer->handle($request, $next); }; }, function(Request $request) use ($kernel): Response { return $kernel($request); }); return $next($request); }
php
{ "resource": "" }
q265471
Range.createFromString
test
public static function createFromString(string $interval): self { list($from, $to) = explode(self::$delimiter, $interval); $dateFrom = DateTime::createFromFormat(self::$format, $from); $dateTo = DateTime::createFromFormat(self::$format, $to); return new self($dateFrom, $dateTo); }
php
{ "resource": "" }
q265472
TOTPGenerator.generate
test
public static function generate($stamp, $key) { $key = self::base32_decode($key); if (strlen($key) < 8) { throw new TooShortKeyException('Secret key is too short. Must be at least 16 base 32 characters'); } $bin_counter = pack('N*', 0).pack('N*', $stamp); // Stamp must be 64-bit int $hash = hash_hmac('sha1', $bin_counter, $key, true); return str_pad(self::oath_truncate($hash), 6, '0', STR_PAD_LEFT); }
php
{ "resource": "" }
q265473
TOTPGenerator.base32_decode
test
protected static function base32_decode($b32) { $b32 = strtoupper($b32); if (!preg_match('/^[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]+$/', $b32, $match)) { throw new Exception('Invalid characters in the base32 string.'); } $l = strlen($b32); $n = 0; $j = 0; $binary = ''; for ($i = 0; $i < $l; ++$i) { $n = $n << 5; // Move buffer left by 5 to make room $n = $n + self::$lut[$b32[$i]]; // Add value into buffer $j = $j + 5; // Keep track of number of bits in buffer if ($j >= 8) { $j = $j - 8; $binary .= chr(($n & (0xFF << $j)) >> $j); } } return $binary; }
php
{ "resource": "" }
q265474
File.listAllIterator
test
private function listAllIterator($recursive = false, $showHidden = false) { if (!$this->isDirectory()) { return new \ArrayIterator([]); } $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO; if (!$showHidden) { $flags = $flags | \FilesystemIterator::SKIP_DOTS; } if ($recursive) { return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, $flags), \RecursiveIteratorIterator::SELF_FIRST); } return new \FilesystemIterator($this->path, $flags); }
php
{ "resource": "" }
q265475
File.listAll
test
public function listAll($recursive = false, $showHidden = false) { $result = []; foreach ($this->listAllIterator($recursive, $showHidden) as $element) { $result[] = $element->getFilename(); } return $result; }
php
{ "resource": "" }
q265476
File.listDirectories
test
public function listDirectories($recursive = false, $showHidden = false) { $result = []; foreach ($this->listAllIterator($recursive, $showHidden) as $element) { if ($element->isDir()) { $result[] = $element->getFilename(); } } return $result; }
php
{ "resource": "" }
q265477
File.listFiles
test
public function listFiles($recursive = false, $showHidden = false) { $result = []; foreach ($this->listAllIterator($recursive, $showHidden) as $element) { if ($element->isFile()) { $result[] = $element->getFilename(); } } return $result; }
php
{ "resource": "" }
q265478
File.makeFile
test
public function makeFile($override = false) { if ($this->exists() && !$override) { return false; } return file_put_contents($this->path, '') !== false; }
php
{ "resource": "" }
q265479
File.makeDirectory
test
public function makeDirectory($recursive = false, $permissions = 0775) { if ($this->exists()) { return false; } $old = umask(0777 - $permissions); $result = mkdir($this->path, $permissions, $recursive); umask($old); return $result; }
php
{ "resource": "" }
q265480
File.move
test
public function move($path, $override = false) { if (!$this->exists()) { return false; } $file = new File($path); if (($file->exists() && !$override) || !rename($this->path, $file->getPath())) { return false; } $this->path = $file->getPath(); return true; }
php
{ "resource": "" }
q265481
File.rename
test
public function rename($file, $override = false) { return $this->move($this->getDirectory() . static::DIRECTORY_SEPARATOR . basename($file), $override); }
php
{ "resource": "" }
q265482
File.removeDirectory
test
public function removeDirectory($recursive = false) { if (!$recursive) { return rmdir($this->path); } foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) { $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname()); } return true; }
php
{ "resource": "" }
q265483
aField.setName
test
private function setName(?string $n) : void { if ($n === null || $n === "") { $msg = "Invalid configuration. The attribute \"name\" is required."; throw new \InvalidArgumentException($msg); } else { // Se forem encontrados caracteres inválidos para o nome do campo preg_match("/^[a-zA-Z0-9_]+$/", $n, $fnd); if (count($fnd) === 0) { $msg = "Invalid given field name [\"" . $n . "\"]."; throw new \InvalidArgumentException($msg); } $this->name = $n; } }
php
{ "resource": "" }
q265484
aField.setType
test
private function setType(?string $t) : void { if ($t === null || $t === "") { $msg = "Invalid configuration. The attribute \"type\" is required."; throw new \InvalidArgumentException($msg); } else { if (class_exists($t) === false || $t === "DateTime") { $t = "AeonDigital\\SimpleTypes\\d" . $t; } if (class_exists($t) === false) { $msg = "The given \"type\" class does not exists."; throw new \InvalidArgumentException($msg); } else { $this->typeReflection = new \ReflectionClass($t); if ($this->isValidSimpleType() === false) { $msg = "The given \"type\" class does not implements the interface \"AeonDigital\\SimpleTypes\\Interfaces\\iSimpleType\"."; throw new \InvalidArgumentException($msg); } $this->type = $t; } } }
php
{ "resource": "" }
q265485
aField.setInputFormat
test
private function setInputFormat($if) : void { if ($if !== null) { if (is_array($if) === true) { $requiredKeys = ["name", "length", "check", "removeFormat", "format", "storageFormat"]; foreach ($requiredKeys as $key) { if (array_key_exists($key, $if) === false) { $msg = "Lost required key in the given input format rule."; throw new \InvalidArgumentException($msg); } else { $msg = null; $kVal = $if[$key]; switch ($key) { case "name": if (is_string($kVal) === false || strlen($kVal) === 0) { $msg = "Invalid given \"$key\" of input format. Expected a not empty string."; } break; case "length": if (is_int($kVal) === false && $kVal !== null) { $msg = "Invalid given \"$key\" of input format. Expected integer or null."; } break; case "check": case "removeFormat": case "format": case "storageFormat": if (is_callable($kVal) === false) { $msg = "Invalid given \"$key\" of input format. Expected callable."; } break; } if ($msg !== null) { throw new \InvalidArgumentException($msg); } } } $this->inputFormat = [ "name" => strtoupper($if["name"]), "length" => (($if["length"] === null) ? null : (int)$if["length"]), "check" => $if["check"], "removeFormat" => $if["removeFormat"], "format" => $if["format"], "storageFormat" => $if["storageFormat"] ]; } else { if (class_exists($if) === false) { $if = "AeonDigital\\DataFormat\\Patterns\\" . str_replace(".", "\\", $if); } if (class_exists($if) === false) { $msg = "The given \"inputFormat\" class does not exists."; throw new \InvalidArgumentException($msg); } else { $this->inputFormatReflection = new \ReflectionClass($if); if ($this->isValidInputFormat($if) === false) { $msg = "The given \"inputFormat\" class does not implements the interface \"AeonDigital\\DataFormat\\Interfaces\\iFormat\"."; throw new \InvalidArgumentException($msg); } $this->inputFormat = [ "name" => $if, "length" => $if::MaxLength, "check" => $if . "::check", "removeFormat" => $if . "::removeFormat", "format" => $if . "::format", "storageFormat" => $if . "::storageFormat" ]; } } } }
php
{ "resource": "" }
q265486
aField.setValue
test
public function setValue($v) : bool { $iPS = $this->internal_ProccessSet($v); if ($iPS["canSet"] === true) { $this->value = $iPS["value"]; $this->rawValue = $iPS["rawValue"]; $this->fieldState_IsValid = $iPS["valid"]; $this->fieldState_CurrentState = $iPS["state"]; $this->fieldState_CollectionState = $iPS["cState"]; } $this->fieldState_ValidateState = $iPS["state"]; $this->fieldState_ValidateStateCanSet = $iPS["canSet"]; $this->fieldState_CollectionValidateState = $iPS["cState"]; return ($iPS["canSet"] === true && $iPS["valid"] === true); }
php
{ "resource": "" }
q265487
aField.getStorageValue
test
public function getStorageValue() { if ($this->isValid() === true && ($this->value !== undefined || $this->default !== undefined)) { return $this->internal_ProccessGet($this->value, false); } else { if ($this->isCollection() === true) { return []; } else { return null; } } }
php
{ "resource": "" }
q265488
Model.saveTheChildren
test
protected function saveTheChildren() { $toReload = []; if (isset($this->addedChildren)) { foreach ($this->addedChildren as $relation => $children) { $relationship = call_user_func([ $this, $relation ]); if ($relationship instanceof HasMany) { $relationship->saveMany($children); } else { throw new PropertySetterException( "Relationship " . get_class($relationship) . " is not implemented yet." ); } // Also save the children foreach ($children as $child) { if ($child instanceof Model) { $child->saveTheChildren(); } } $toReload[$relation] = true; } } if (isset($this->removedChildren)) { foreach ($this->removedChildren as $relation => $children) { $relationship = call_user_func([ $this, $relation ]); if ($relationship instanceof HasMany) { foreach ($children as $child) { $child->delete(); } } else { throw new PropertySetterException( "Relationship " . get_class($relationship) . " is not implemented yet." ); } $toReload[$relation] = true; } } if (isset($this->editedChildren)) { foreach ($this->editedChildren as $relation => $children) { $relationship = call_user_func([ $this, $relation ]); foreach ($children as $child) { if ($child instanceof Model) { $child->saveRecursively(); } else { $child->save(); } } $toReload[$relation] = true; } } $toReload = array_keys($toReload); foreach ($toReload as $reload) { unset($this->relations[$reload]); } }
php
{ "resource": "" }
q265489
Model.addChildrenToEntity
test
public function addChildrenToEntity($name, array $childEntities, $setterParameters = []) { // For each relationship, keep a list of all children that were added. if (!isset($this->addedChildren[$name])) { $this->addedChildren[$name] = []; } foreach ($childEntities as $child) { $this->$name->add($child); $this->addedChildren[$name][] = $child; } }
php
{ "resource": "" }
q265490
ResourceController.getModels
test
public function getModels($queryBuilder, Context $context, $resourceDefinition = null, $records = null) { $resourceDefinition = $resourceDefinition ?? $this->resourceDefinition; $records = $records ?? $this->getRecordLimit(); return $this->filterAndGet($queryBuilder, $resourceDefinition, $context, $records); }
php
{ "resource": "" }
q265491
ResourceController.outputList
test
protected function outputList($models, array $parameters = [], $resourceDefinition = null) { $resources = $this->filteredModelsToResources($models, $parameters, $resourceDefinition); return $this->toResponse($resources); }
php
{ "resource": "" }
q265492
ResourceController.resourceToArray
test
protected function resourceToArray($data) { if ($data instanceof ResourceCollection) { return $data->toArray(); } else if ($data instanceof RESTResource) { return $data->toArray(); } else if (ArrayHelper::isIterable($data)) { foreach ($data as $k => $v) { $data[$k] = $this->resourceToArray($v); } return $data; } return $data; }
php
{ "resource": "" }
q265493
ReCaptcha.generate
test
public function generate() { $sClientKey = appSetting('site_key_client', 'nails/driver-captcha-recaptcha'); if (empty($sClientKey)) { throw new CaptchaDriverException('ReCaptcha not configured.'); } $oAsset = Factory::service('Asset'); $oAsset->load('https://www.google.com/recaptcha/api.js'); $oResponse = Factory::factory('CaptchaForm', 'nails/module-captcha'); $oResponse->setHtml('<div class="g-recaptcha" data-sitekey="' . $sClientKey . '"></div>'); return $oResponse; }
php
{ "resource": "" }
q265494
ReCaptcha.verify
test
public function verify() { $sServerKey = appSetting('site_key_server', 'nails/driver-captcha-recaptcha'); if ($sServerKey) { $oHttpClient = Factory::factory('HttpClient'); $oInput = Factory::service('Input'); try { $oResponse = $oHttpClient->post( 'https://www.google.com/recaptcha/api/siteverify', [ 'form_params' => [ 'secret' => $sServerKey, 'response' => $oInput->post('g-recaptcha-response'), 'remoteip' => $oInput->ipAddress(), ], ] ); if ($oResponse->getStatusCode() !== 200) { throw new CaptchaDriverException('Google returned a non 200 response.'); } $oResponse = json_decode((string) $oResponse->getBody()); if (empty($oResponse->success)) { throw new CaptchaDriverException('Google returned an unsuccessful response.'); } return true; } catch (\Exception $e) { return false; } } else { return false; } }
php
{ "resource": "" }
q265495
Openbizx.getService
test
public static function getService($service, $new = 0) { $defaultPackage = "service"; $serviceName = $service; if (strpos($service, ".") === false) { $serviceName = $defaultPackage . "." . $service; } return Openbizx::getObject($serviceName, $new); }
php
{ "resource": "" }
q265496
SerializerExceptionRenderer.render
test
public function render() { if ($this->error instanceof ValidationBaseSerializerException) { return $this->renderValidationSerializerException($this->error); } elseif ($this->error instanceof BaseSerializerException) { return $this->renderSerializerException($this->error); } elseif ($this->error instanceof CakeException) { return $this->renderCakeException($this->error); } elseif ($this->error instanceof HttpException) { return $this->renderHttpException($this->error); } else { // This isn't a standard CakeException, render it using the default error500 method return $this->error500($this->error); } }
php
{ "resource": "" }
q265497
SerializerExceptionRenderer.renderHttpException
test
protected function renderHttpException(HttpException $error) { if ($this->isJsonApiRequest()) { return $this->renderHttpAsJsonApi($error); } if ($this->isJsonRequest()) { return $this->renderHttpAsJson($error); } return $this->defaultHttpRender($error); }
php
{ "resource": "" }
q265498
SerializerExceptionRenderer.renderCakeException
test
protected function renderCakeException(CakeException $error) { if ($this->isJsonApiRequest()) { return $this->renderCakeAsJsonApi($error); } if ($this->isJsonRequest()) { return $this->renderCakeAsJson($error); } return $this->defaultCakeRender($error); }
php
{ "resource": "" }
q265499
SerializerExceptionRenderer.renderSerializerException
test
protected function renderSerializerException(BaseSerializerException $error) { if ($this->isJsonApiRequest()) { return $this->renderSerializerAsJsonApi($error); } if ($this->isJsonRequest()) { return $this->renderSerializerAsJson($error); } return $this->defaultSerializerRender($error); }
php
{ "resource": "" }