_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| 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."'))" ;
|
php
|
{
"resource": ""
}
|
q265401
|
Resolver.castKey
|
test
|
public function castKey($key, string $default = ""): string
|
php
|
{
"resource": ""
}
|
q265402
|
Resolver.isAbstract
|
test
|
protected function isAbstract($middleware): bool
{
return is_string($middleware) &&
class_exists($middleware) &&
|
php
|
{
"resource": ""
}
|
q265403
|
Resolver.isCollection
|
test
|
public function isCollection($middleware): bool
{
$isArray = is_array($middleware) && ! is_callable($middleware);
|
php
|
{
"resource": ""
}
|
q265404
|
Resolver.resolve
|
test
|
public function resolve($middleware, &$key = null)
{
if ($this->isCollection($middleware)) {
return $this->resolveMany($middleware, $key ?: Group::DEFAULT_ID);
|
php
|
{
"resource": ""
}
|
q265405
|
Resolver.resolveOrFail
|
test
|
public function resolveOrFail($middleware, &$key = null)
{
if ($this->isCollection($middleware)) {
return $this->resolveManyOrFail($middleware, $key ?: Group::DEFAULT_ID);
|
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);
|
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);
|
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)
|
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";
|
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
|
php
|
{
"resource": ""
}
|
q265411
|
reportService.getUniqueString
|
test
|
public function getUniqueString()
{
$mdy = date("mdy");
$hms = date("His");
|
php
|
{
"resource": ""
}
|
q265412
|
HasRoleAndPermission.is
|
test
|
public function is($role, $all = false)
{
if ($this->isPretendEnabled()) {
return $this->pretend('is');
}
|
php
|
{
"resource": ""
}
|
q265413
|
HasRoleAndPermission.hasRole
|
test
|
protected function hasRole($role)
{
return $this->getRoles()->contains(function ($key, $value) use ($role) {
return
|
php
|
{
"resource": ""
}
|
q265414
|
Hash.getHash
|
test
|
public function getHash()
{
$paramString = $this->getParamString(func_get_args());
$encrypted = crypt($paramString, '$2a$07$'.$this->secret.'$');
|
php
|
{
"resource": ""
}
|
q265415
|
Client.getInfo
|
test
|
public function getInfo($opt = null) {
if (null === $opt) {
return curl_getinfo($this->getCurl());
}
|
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),
|
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();
|
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)
{
|
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) {
|
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
|
{
"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
|
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
|
{
"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
|
{
"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 &&
|
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 &&
|
php
|
{
"resource": ""
}
|
q265426
|
DomDocument.setDefaultNamespace
|
test
|
public function setDefaultNamespace($prefix = self::NAMESPACE_PREFIX, $uri = self::NAMESPACE_ENVIRONAUT_1_0)
{
$this->default_namespace_uri = $uri;
|
php
|
{
"resource": ""
}
|
q265427
|
DomDocument.registerEnvironautNamespace
|
test
|
public static function registerEnvironautNamespace(DOMDocument $doc)
{
|
php
|
{
"resource": ""
}
|
q265428
|
DomDocument.isEnvironautConfigurationDocument
|
test
|
public static function isEnvironautConfigurationDocument(DOMDocument $doc)
{
return (
$doc->documentElement &&
$doc->documentElement->localName === 'environaut' &&
|
php
|
{
"resource": ""
}
|
q265429
|
DomDocument.refreshXpath
|
test
|
protected function refreshXpath()
{
unset($this->xpath);
$this->xpath = new \DOMXPath($this);
if ($this->isEnvironautDocument()) {
|
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 . ': ';
|
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];
|
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();
|
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);
|
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());
|
php
|
{
"resource": ""
}
|
q265435
|
ClientProxy.printOutput
|
test
|
public function printOutput()
{
if ($this->isRpc == true) {
return $this->printJSONOuput();
}
foreach ($this->_otherOutput 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) {
|
php
|
{
"resource": ""
}
|
q265437
|
ClientProxy.redrawForm
|
test
|
public function redrawForm($formName, $sHTML)
{
if ($this->isRpc) {
$this->_formsOutput[$formName] = $this->buildTargetContent($formName, $sHTML);
|
php
|
{
"resource": ""
}
|
q265438
|
ClientProxy.showClientAlert
|
test
|
public function showClientAlert($alertText)
{
if ($this->isRpc) {
$msg = addslashes($alertText);
|
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();
|
php
|
{
"resource": ""
}
|
q265440
|
ClientProxy.closePopup
|
test
|
public function closePopup()
{
if ($this->isRpc) {
$this->_formsOutput[] = $this->callClientFunction("Openbizx.Window.closePopup()");
|
php
|
{
"resource": ""
}
|
q265441
|
ClientProxy.runClientScript
|
test
|
public function runClientScript($scriptStr)
{
if ($this->isRpc) {
|
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));
|
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'
|
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,
|
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) {
|
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) {
|
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);
}
|
php
|
{
"resource": ""
}
|
q265448
|
ClientProxy.includeRTEScripts
|
test
|
public function includeRTEScripts()
{
if (isset($this->_extraScripts['rte'])) {
return;
}
$script = "<script type=\"text/javascript\" src=\"" .
|
php
|
{
"resource": ""
}
|
q265449
|
ClientProxy.includeCKEditorScripts
|
test
|
public function includeCKEditorScripts()
{
if (isset($this->_extraScripts['ckeditor'])) {
return;
}
|
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\">";
|
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");
|
php
|
{
"resource": ""
}
|
q265452
|
doTriggerService.executeAllActions
|
test
|
protected function executeAllActions($doTrigger, $dataObj)
{
if (!$this->matchCondition($doTrigger, $dataObj))
return;
/* @var $triggerAction TriggerAction */
|
php
|
{
"resource": ""
}
|
q265453
|
doTriggerService._composeActionMessage
|
test
|
private function _composeActionMessage($triggerAction, $methodName, $argList)
{
$actionMsg["Method"] = $methodName;
$actionMsg["ArgList"] = $argList;
$actionMsg["DelayMinutes"] = $triggerAction->delayMinutes;
|
php
|
{
"resource": ""
}
|
q265454
|
doTriggerService._makeArray
|
test
|
static private function _makeArray($string)
{
if (!$string)
return null;
$arr = explode(";", $string);
$size = count($arr);
|
php
|
{
"resource": ""
}
|
q265455
|
EasyForm.processFormObjError
|
test
|
public function processFormObjError($errors)
{
$this->errors = $errors;
|
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 =
|
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
|
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;
}
|
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
|
php
|
{
"resource": ""
}
|
q265460
|
EasyForm.getElementID
|
test
|
public function getElementID()
{
$id = $this->dataPanel->getByField('Id')->getValue();
|
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) {
|
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'];
|
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)
|
php
|
{
"resource": ""
}
|
q265464
|
EasyForm.getEventLogMsg
|
test
|
protected function getEventLogMsg()
{
list($element, $eventHandler) = $this->getInvokingElement();
$eventLogMsg = $eventHandler->eventLogMsg;
if
|
php
|
{
"resource": ""
}
|
q265465
|
EasyForm.getOnEventElements
|
test
|
protected function getOnEventElements()
{
$elementList = array();
foreach ($this->dataPanel as $element)
|
php
|
{
"resource": ""
}
|
q265466
|
EasyForm.runEventLog
|
test
|
protected function runEventLog()
{
$logMessage = $this->getEventLogMsg();
$eventName = $this->eventName;
if ($logMessage && $eventName) {
|
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)
|
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");
/*
|
php
|
{
"resource": ""
}
|
q265469
|
MiddlewareManager.remove
|
test
|
public function remove(string $middlewareClass): void
{
foreach( $this->middlewareStack as $i => $middleware ){
if( $middleware instanceof
|
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 {
|
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);
|
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);
|
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
|
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;
}
|
php
|
{
"resource": ""
}
|
q265475
|
File.listAll
|
test
|
public function listAll($recursive = false, $showHidden = false)
{
$result = [];
foreach ($this->listAllIterator($recursive, $showHidden) as $element)
|
php
|
{
"resource": ""
}
|
q265476
|
File.listDirectories
|
test
|
public function listDirectories($recursive = false, $showHidden = false)
{
$result = [];
foreach ($this->listAllIterator($recursive,
|
php
|
{
"resource": ""
}
|
q265477
|
File.listFiles
|
test
|
public function listFiles($recursive = false, $showHidden = false)
{
$result = [];
foreach ($this->listAllIterator($recursive,
|
php
|
{
"resource": ""
}
|
q265478
|
File.makeFile
|
test
|
public function makeFile($override = false)
{
if ($this->exists() && !$override) {
return false;
|
php
|
{
"resource": ""
}
|
q265479
|
File.makeDirectory
|
test
|
public function makeDirectory($recursive = false, $permissions = 0775)
{
if ($this->exists()) {
return false;
}
$old = umask(0777 - $permissions);
$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,
|
php
|
{
"resource": ""
}
|
q265481
|
File.rename
|
test
|
public function rename($file, $override = false)
{
return $this->move($this->getDirectory()
|
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),
|
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 {
|
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 {
|
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);
|
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
|
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 {
|
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;
|
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] = [];
}
|
php
|
{
"resource": ""
}
|
q265490
|
ResourceController.getModels
|
test
|
public function getModels($queryBuilder, Context $context, $resourceDefinition = null, $records = null)
{
$resourceDefinition =
|
php
|
{
"resource": ""
}
|
q265491
|
ResourceController.outputList
|
test
|
protected function outputList($models, array $parameters = [], $resourceDefinition = null)
{
$resources = $this->filteredModelsToResources($models,
|
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)) {
|
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');
|
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) {
|
php
|
{
"resource": ""
}
|
q265495
|
Openbizx.getService
|
test
|
public static function getService($service, $new = 0)
{
$defaultPackage = "service";
$serviceName = $service;
if (strpos($service, ".") === false) {
|
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
|
php
|
{
"resource": ""
}
|
q265497
|
SerializerExceptionRenderer.renderHttpException
|
test
|
protected function renderHttpException(HttpException $error) {
if ($this->isJsonApiRequest()) {
return $this->renderHttpAsJsonApi($error);
}
if ($this->isJsonRequest()) {
|
php
|
{
"resource": ""
}
|
q265498
|
SerializerExceptionRenderer.renderCakeException
|
test
|
protected function renderCakeException(CakeException $error) {
if ($this->isJsonApiRequest()) {
return $this->renderCakeAsJsonApi($error);
}
if ($this->isJsonRequest()) {
|
php
|
{
"resource": ""
}
|
q265499
|
SerializerExceptionRenderer.renderSerializerException
|
test
|
protected function renderSerializerException(BaseSerializerException $error) {
if ($this->isJsonApiRequest()) {
return $this->renderSerializerAsJsonApi($error);
}
if ($this->isJsonRequest())
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.