_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q264700 | Application.getDBConnection | test | public function getDBConnection($dbName = null)
{
$rDBName = (!$dbName) ? "Default" : $dbName;
if (isset($this->_dbConnection[$rDBName])) {
$db = $this->_dbConnection[$rDBName];
if (!CLI) {
return $db;
}
}
$dbInfo = $this->getConfiguration()->getDatabaseInfo($rDBName);
//require_once 'Zend/Db.php';
$params = array(
'host' => $dbInfo["Server"],
'username' => $dbInfo["User"],
'password' => $dbInfo["Password"],
'dbname' => $dbInfo["DBName"],
'port' => $dbInfo["Port"],
'charset' => $dbInfo["Charset"]
);
if ($dbInfo["Options"]) {
$options = explode(";", $dbInfo["Options"]);
foreach ($options as $opt) {
list($k, $v) = explode("=", $opt);
$params[$k] = $v;
}
}
foreach ($params as $name => $val) {
if (empty($val)) {
unset($params[$name]);
}
}
if (strtoupper($dbInfo["Driver"]) == "PDO_MYSQL") {
$pdoParams = array(
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
);
$params["driver_options"] = $pdoParams;
}
$db = \Zend_Db::factory($dbInfo["Driver"], $params);
$db->setFetchMode(\PDO::FETCH_NUM);
if (strtoupper($dbInfo["Driver"]) == "PDO_MYSQL" &&
$dbInfo["Charset"] != "") {
$db->query("SET NAMES '" . $params['charset'] . "'");
}
$this->_dbConnection[$rDBName] = $db;
return $db;
} | php | {
"resource": ""
} |
q264701 | Application.removeDBConnection | test | public function removeDBConnection($dbName = "Default")
{
if (isset($this->_dbConnection[$dbName])) {
$this->_dbConnection[$dbName]->closeConnection();
unset($this->_dbConnection[$dbName]);
}
return $this->getDBConnection($dbName);
} | php | {
"resource": ""
} |
q264702 | Application.processSecurityFilters | test | public function processSecurityFilters()
{
$securityService = Openbizx::getService(SECURITY_SERVICE);
$securityService->processFilters();
$err_msg = $securityService->getErrorMessage();
if ($err_msg) {
if ($this->_securityDeniedView) {
$webpage = $this->_securityDeniedView;
} else {
$webpage = $this->_accessDeniedView;
}
$this->renderView($webpage);
return false;
}
return true;
} | php | {
"resource": ""
} |
q264703 | Application.dispatchRequest | test | public function dispatchRequest()
{
if ($this->request->hasInvocation()) {
if ($this->isSessionTimeout()) {
$this->getSessionContext()->destroy();
$this->getClientProxy()->redirectView($this->_userTimeoutView);
}
return $this->dispatchRPC();
} else {
return $this->dispatchView();
}
} | php | {
"resource": ""
} |
q264704 | Application.getParameters | test | private function getParameters()
{
$getKeys = array_keys($_GET);
$params = null;
// read parameters "param:name=value"
foreach ($getKeys as $key) {
if (substr($key, 0, 6) == "param:") {
$paramName = substr($key, 6);
$paramValue = $_GET[$key];
$params[$paramName] = $paramValue;
}
}
return $params;
} | php | {
"resource": ""
} |
q264705 | Application.renderView | test | public function renderView($webpageName, $form = "", $rule = "", $params = null, $hist = "")
{
/* @var $webpage \Openbizx\Easy\WebPage */
if ($webpageName == "__DynPopup") {
$webpage = Openbizx::getWebpageObject($webpageName);
return $webpage->render();
}
$this->setCurrentViewName($webpageName);
$webpage = Openbizx::getWebpageObject($webpageName);
if (!$webpage) {
return '';
}
$viewSet = $webpage->getViewSet();
$this->setCurrentViewSet($viewSet);
$this->getSessionContext()->clearSessionObjects(true);
if ($hist == "N") { // clean view history
$webpage->cleanViewHistory();
}
if ($form != "" && $rule != "") {
$webpage->processRule($form, $rule, TRUE);
}
if ($params) {
$webpage->setParameters($params);
}
if (isset($_GET['mode'])) { // can specify mode of form
$webpage->setFormMode($form, $_GET['mode']);
}
return $webpage->render();
} | php | {
"resource": ""
} |
q264706 | Application.validateRequest | test | protected function validateRequest($obj, $methodName)
{
if (is_a($obj, "Openbizx\Easy\EasyForm") || is_a($obj, "BaseForm")) {
if ($obj->validateRequest($methodName)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q264707 | Application.dispatchView | test | private function dispatchView()
{
$request = $this->request;
if (!ObjectFactoryHelper::getXmlFileWithPath($request->view)) {
return $this->renderNotFoundView();
}
if (!$this->canUserAccessView($request->view)) { //access denied error
return $this->renderView($this->_accessDeniedView);
}
return $this->renderView($request->view, $request->form, $request->rule, $request->params, $request->hist);
} | php | {
"resource": ""
} |
q264708 | Application.redirectToDefaultModuleView | test | public function redirectToDefaultModuleView($pmodule)
{
$module = strtolower($pmodule);
$modfile = $this->getModulePath() . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'mod.xml';
$xml = simplexml_load_file($modfile);
$defaultURL = OPENBIZ_APP_INDEX_URL . $xml->Menu->MenuItem['URL'];
header("Location: $defaultURL");
} | php | {
"resource": ""
} |
q264709 | Application.redirectToDefaultUserView | test | public function redirectToDefaultUserView()
{
$profile = $this->getUserProfile();
if ($profile['roleStartpage'][0]) {
$DEFAULT_URL = OPENBIZ_APP_INDEX_URL . $profile['roleStartpage'][0];
}
header("Location: $DEFAULT_URL");
exit;
} | php | {
"resource": ""
} |
q264710 | Application.initUserProfile | test | public function initUserProfile($username)
{
/* @var $profileService profileService */
$profileService = Openbizx::getService(PROFILE_SERVICE);
if (method_exists($profileService, 'InitProfile')) {
$profile = $profileService->initProfile($username);
} else {
$profile = $profileService->getProfile($username);
}
$this->getSessionContext()->setVar("_USER_PROFILE", $profile);
return $profile;
} | php | {
"resource": ""
} |
q264711 | Application.getUserPreference | test | public function getUserPreference($attribute = null)
{
if (!ObjectFactoryHelper::getXmlFileWithPath(OPENBIZ_PREFERENCE_SERVICE)) {
return null;
}
$preferenceService = Openbizx::getService(OPENBIZ_PREFERENCE_SERVICE);
if (method_exists($preferenceService, 'getPreference')) {
return $preferenceService->getPreference($attribute);
} else {
$preference = $this->getSessionContext()->getVar("_USER_PREFERENCE");
return isset($preference[$attribute]) ? $preference[$attribute] : "";
}
} | php | {
"resource": ""
} |
q264712 | Application.getDefaultPerm | test | public function getDefaultPerm($pgroup)
{
$group = strtolower($pgroup);
switch ($group) {
default:
case 'owner':
$setting = $this->getUserPreference('owner_perm');
if ($setting != '') {
$perm_code = $setting;
} else {
$perm_code = OPENBIZ_DEFAULT_OWNER_PERM;
}
break;
case 'group':
$setting = $this->getUserPreference('owner_group');
if ($setting != '') {
$perm_code = $setting;
} else {
$perm_code = OPENBIZ_DEFAULT_GROUP_PERM;
}
break;
case 'other':
$setting = $this->getUserPreference('owner_other');
if ($setting != '') {
$perm_code = $setting;
} else {
$perm_code = OPENBIZ_DEFAULT_OTHER_PERM;
}
break;
}
return $perm_code;
} | php | {
"resource": ""
} |
q264713 | Application.getCurrentViewName | test | public function getCurrentViewName()
{
if ($this->_currentViewName == "") {
$this->_currentViewName = $this->getSessionContext()->getVar("CVN"); // CVN stands for CurrentViewName
}
return $this->_currentViewName;
} | php | {
"resource": ""
} |
q264714 | Application.setCurrentViewName | test | public function setCurrentViewName($viewname)
{
$this->_currentViewName = $viewname;
$this->getSessionContext()->setVar("CVN", $this->_currentViewName); // CVN stands for CurrentViewName
} | php | {
"resource": ""
} |
q264715 | Application.getCurrentViewSet | test | public function getCurrentViewSet()
{
if ($this->_currentViewSet == "") {
$this->_currentViewSet = $this->getSessionContext()->getVar("CVS");
} // CVS stands for CurrentViewSet
return $this->_currentViewSet;
} | php | {
"resource": ""
} |
q264716 | Application.setCurrentViewSet | test | public function setCurrentViewSet($viewSet)
{
$this->_currentViewSet = $viewSet;
$this->getSessionContext()->setVar("CVS", $this->_currentViewSet); // CVS stands for CurrentViewSet
} | php | {
"resource": ""
} |
q264717 | Application.setBasePath | test | public function setBasePath($path)
{
$p = realpath($path);
if ($p !== false && is_dir($p)) {
$this->_basePath = $p;
} else {
throw new Exception("The directory does not exist: $path");
}
} | php | {
"resource": ""
} |
q264718 | Application.getModulePath | test | public function getModulePath()
{
if ($this->_modulePath === null) {
$this->_modulePath = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "modules";
}
return $this->_modulePath;
} | php | {
"resource": ""
} |
q264719 | Hasher.hashSQL | test | public function hashSQL($data, $columns, string $hash)
{
if (is_string($columns)) {
$columns = [$columns];
}
if (is_array($columns)) {
if ($data instanceof DbalCollection) {
$data = $data->getQueryBuilder();
}
if ($data instanceof Selection) {
$col = '';
foreach ($columns as $column) {
if ($col !== '') {
$col += ',';
}
$col += '`$column`';
}
return $data->where("SHA2(CONCAT($columns, '{$this->salt}'), 256)", $hash);
} elseif ($data instanceof QueryBuilder) {
return $data->andWhere('SHA2(CONCAT(%column[], %s), 256) = %s', $columns, $this->salt, $hash);
}
}
throw new InvalidArgumentException;
} | php | {
"resource": ""
} |
q264720 | Hasher.check | test | public function check($string, string $hash): bool
{
return hash_equals($this->hash($string), $hash);
} | php | {
"resource": ""
} |
q264721 | emailService.readMetadata | test | protected function readMetadata(&$xmlArr)
{
parent::readMetaData($xmlArr);
$this->accounts = new MetaIterator($xmlArr["PLUGINSERVICE"]["ACCOUNTS"]["ACCOUNT"], "EmailAccount");
$this->_logEnabled = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["ENABLED"];
if ($this->_logEnabled) {
$this->_logType = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["TYPE"];
$this->_logObject = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["OBJECT"];
}
} | php | {
"resource": ""
} |
q264722 | emailService.useAccount | test | public function useAccount($accountName)
{
//If a mail object exists, overwrite with new object
if ($this->_mail)
$this->_constructMail();
$this->useAccount = $accountName;
$account = $this->accounts->get($accountName);
if ($account->isSMTP == "Y") {
if ($account->sMTPAuth == "Y") {
$config = array('auth' => 'login', 'username' => $account->username, 'password' => $account->password, "port" => $account->port, 'ssl' => $account->sSL);
} else {
$config = array();
}
$mailTransport = new \Zend_Mail_Transport_Smtp($account->host, $config);
$this->_mail->setDefaultTransport($mailTransport);
} else {
require_once 'Zend/Mail/Transport/Sendmail.php';
$mailTransport = new \Zend_Mail_Transport_Sendmail();
$this->_mail->setDefaultTransport($mailTransport);
}
$this->_mail->setFrom($account->fromEmail, $account->fromName);
return $this;
} | php | {
"resource": ""
} |
q264723 | emailService.sendEmail | test | public function sendEmail($TOs = null, $CCs = null, $BCCs = null, $subject, $body, $attachments = null, $isHTML = false)
{
$mail = $this->_mail;
// add TO addresses
if ($TOs) {
foreach ($TOs as $to) {
if (is_array($to)) {
$mail->addTo($to['email'], $to['name']);
} else {
$mail->addTo($to);
}
}
}
// add CC addresses
if ($CCs) {
foreach ($CCs as $cc) {
if (is_array($cc)) {
$mail->AddCC($cc['email'], $cc['name']);
} else {
$mail->AddCC($cc);
}
}
}
// add BCC addresses
if ($BCCs) {
foreach ($BCCs as $bcc) {
if (is_array($bcc)) {
$mail->AddBCC($bcc['email'], $bcc['name']);
} else {
$mail->AddBCC($bcc);
}
}
}
// add attachments
if ($attachments)
foreach ($attachments as $att)
$mail->CreateAttachment(file_get_contents($att));
$mail->setSubject($subject);
$body = str_replace("\\n", "\n", $body);
if ($isHTML == TRUE) {
$mail->setBodyHTML($body);
} else {
$mail->setBodyText($body);
}
try {
$result = $mail->Send(); //Will throw an exception if sending fails
$this->logEmail('Success', $subject, $body, $TOs, $CCs, $BCCs);
return TRUE;
} catch (Exception $e) {
$result = "ERROR: " . $e->getMessage();
$this->logEmail($result, $subject, $body, $TOs, $CCs, $BCCs);
return FALSE;
}
} | php | {
"resource": ""
} |
q264724 | emailService.logEmail | test | public function logEmail($result, $subject, $body = NULL, $TOs = NULL, $CCs = NULL, $BCCs = NULL)
{
//Log the email attempt
$recipients = '';
// add TO addresses
if ($TOs) {
foreach ($TOs as $to) {
if (is_array($to)) {
$recipients .= $to['name'] . "<" . $to['email'] . ">;";
} else {
$recipients .= $to . ";";
}
}
}
// add CC addresses
if ($CCs) {
foreach ($CCs as $cc) {
if (is_array($cc)) {
$recipients .= $cc['name'] . "<" . $cc['email'] . ">;";
} else {
$recipients .= $cc . ";";
}
}
}
// add BCC addresses
if ($BCCs) {
foreach ($BCCs as $bcc) {
if (is_array($bcc)) {
$recipients .= $bcc['name'] . "<" . $bcc['email'] . ">;";
} else {
$recipients .= $bcc . ";";
}
}
}
if ($this->_logType == 'DB') {
$account = $this->accounts->get($this->useAccount);
$sender_name = $account->fromName;
$sender = $account->fromEmail;
// Store the message log
$boMessageLog = Openbizx::getObject($this->_logObject);
$mlArr = $boMessageLog->newRecord();
$mlArr["sender"] = $sender;
$mlArr["sender_name"] = $sender_name;
$mlArr["recipients"] = $recipients;
$mlArr["subject"] = $subject;
$mlArr["content"] = $body;
$mlArr["result"] = $result;
/*
* as long as data could read from db, its no longer need to addslashes
//Escape Data since this may contain quotes or other goodies
foreach ($mlArr as $key => $value)
{
$mlArr[$key] = addslashes($value);
}
*/
$ok = $boMessageLog->insertRecord($mlArr);
if (!$ok) {
return $boMessageLog->getErrorMessage();
} else {
return TRUE;
}
} else {
$back_trace = debug_backtrace();
if ($result == 'Success') {
$logNum = LOG_INFO;
} else {
$logNum = LOG_ERR;
}
Openbizx::$app->getLog()->log($logNum, "EmailService", "Sent email with subject - \"$subject\" and body - $body to - $recipients with result $result.", NULL, $back_trace);
}
} | php | {
"resource": ""
} |
q264725 | Tags.Info | test | public function Info($tag = mull)
{
if (empty($tag))
trigger_error("You didn't supply a tag, not sure what whill happen here...", E_USER_WARNING);
return $this->Get($this->buildUrl($tag));
} | php | {
"resource": ""
} |
q264726 | ClassLoader.getAutoloadLibFileWithPath | test | public static function getAutoloadLibFileWithPath($className)
{
if (!$className) {
return;
}
// use class map first
if (isset(self::$classMap[$className])) {
return self::$classMap[$className];
}
// search it in cache first
$cacheKey = $className . "_path";
if (extension_loaded('apc') && ($filePath = apc_fetch($cacheKey)) != null) {
return $filePath;
}
$filePath = self::getCoreLibFilePath($className);
// cache it to save file search
if ($filePath && extension_loaded('apc')) {
apc_store($cacheKey, $filePath);
}
return $filePath;
} | php | {
"resource": ""
} |
q264727 | ClassLoader.loadMetadataClass | test | public static function loadMetadataClass($className, $packageName = '')
{
if (class_exists($className, false)) {
return true;
}
if (isset(self::$_classNameCache[$packageName . $className])) {
return true;
}
$filePath = self::getLibFileWithPath($className, $packageName);
if ($filePath) {
include_once($filePath);
self::$_classNameCache[$packageName . $className] = 1;
return true;
}
return false;
} | php | {
"resource": ""
} |
q264728 | ClassLoader.getCoreLibFilePath | test | public static function getCoreLibFilePath($className)
{
// if class not yet collect on class map, scan core path.
$classFile = $className . '.php';
// TODO: search the file under bin/, bin/data, bin/ui. bin/service, bin/easy, bin/Easy/element.
// guess class type and folder
$lowClassName = strtolower($className);
if (strrpos($lowClassName, 'service') > 0) {
$corePaths = array('service/');
} else if (strrpos($lowClassName, 'form') > 0 || strrpos($lowClassName, 'form') === 0) {
$corePaths = array('easy/');
} else if (strrpos($lowClassName, 'view') > 0 || strrpos($lowClassName, 'view') === 0) {
$corePaths = array('easy/');
} else if (strrpos($lowClassName, 'dataobj') > 0) {
$corePaths = array('data/');
} else {
$corePaths = array('easy/element/', '', 'data/', 'easy/', 'service/');
}
//$corePaths = array('', 'data/', 'easy/', 'easy/element/', 'ui/', 'service/');
foreach ($corePaths as $path) {
$_classFile = OPENBIZ_BIN . $path . $classFile;
//echo "file_exists($_classFile)\n";
if (file_exists($_classFile)) {
return $_classFile;
}
}
return null;
} | php | {
"resource": ""
} |
q264729 | ClassLoader.findClassFileOnCache | test | private static function findClassFileOnCache($className) {
// search it in cache first
$cacheKey = $className . "_path";
if (extension_loaded('apc') ) {
$filePath = apc_fetch($cacheKey);
return $filePath;
}
return null;
} | php | {
"resource": ""
} |
q264730 | Alumni.fill | test | protected static function fill(Person $person, array $attrs)
{
$attrs = array_merge(
$attrs,
$attrs["PersonAffiliations"]["AlumPersonAffiliation"]
);
return parent::fill($person, $attrs);
} | php | {
"resource": ""
} |
q264731 | Scheduler.offsetSet | test | public function offsetSet($name, $job)
{
if (!is_callable($job)) {
throw new InvalidArgumentException('Each job must be callable');
}
$this->jobs[$name] = $job;
} | php | {
"resource": ""
} |
q264732 | Scheduler.process | test | public function process() : void
{
global $argv;
$specific = null;
foreach ($argv as $arg) {
if (preg_match('@--job=(.*?)$@', $arg, $match)) {
$specific = $match[1];
}
}
$start = time();
$tmp = sys_get_temp_dir();
array_walk($this->jobs, function ($job, $idx) use ($tmp, $specific, $argv) {
if (isset($specific) && $specific !== $idx) {
return;
}
if (in_array('--verbose', $argv) || in_array('-v', $argv)) {
echo "Starting $idx...";
}
$fp = fopen("$tmp/".md5($idx).'.lock', 'w+');
flock($fp, LOCK_EX);
try {
$job->call($this);
} catch (NotDueException $e) {
} catch (Exception $e) {
$this->logger->addCritial(sprintf(
"%s in file %s on line %d",
$e->getMessage(),
$e->getFile(),
$e->getLine()
));
}
flock($fp, LOCK_UN);
fclose($fp);
if (in_array('--verbose', $argv) || in_array('-v', $argv)) {
echo " [done]\n";
}
});
if (--$this->minutes > 0) {
$wait = max(60 - (time() - $start), 0);
if (!getenv('TOAST')) {
sleep($wait);
}
$this->now += 60;
$this->process();
}
} | php | {
"resource": ""
} |
q264733 | Scheduler.at | test | public function at(string $datestring) : void
{
global $argv;
if (in_array('--all', $argv) || in_array('-a', $argv)) {
return;
}
$date = date($datestring, $this->now);
if (!preg_match("@$date$@", date('Y-m-d H:i', $this->now))) {
throw new NotDueException;
}
} | php | {
"resource": ""
} |
q264734 | ColumnListbox.renderLabel | test | public function renderLabel()
{
if ($this->sortable == "Y")
{
$rule = $this->objectName;
$function = $this->formName . ".SortRecord($rule,$this->sortFlag)";
if($this->sortFlag == "ASC" || $this->sortFlag == "DESC"){
$class=" class=\"current\" ";
}else{
$class=" class=\"normal\" ";
}
if ($this->sortFlag == "ASC")
$span_class = " class=\"sort_up\" ";
else if ($this->sortFlag == "DESC")
$span_class = " class=\"sort_down\" ";
$sHTML = "<a href=javascript:Openbizx.CallFunction('" . $function . "') $class ><span $span_class >" . $this->label ."</span>";
$sHTML .= "</a>";
}
else
{
$sHTML = $this->label;
}
return $sHTML;
} | php | {
"resource": ""
} |
q264735 | DefaultContext.flattenPath | test | protected static function flattenPath(array $path)
{
$string = '';
foreach ($path as $i => $segment) {
if (\is_numeric($segment)) {
$string .= '[' . $segment . ']';
continue;
}
if ($i != 0) {
$string .= '.';
}
if (\is_array($segment)) {
$string .= $segment[0] . '(';
foreach ($segment[1] as $j => $arg) {
if ($j != 0) {
$string .= ', ';
}
$string .= $arg;
}
$string .= ')';
} else {
$string .= $segment;
}
}
return $string;
} | php | {
"resource": ""
} |
q264736 | Module.getConfig | test | public function getConfig()
{
$provider = new ConfigProvider();
$this->config = $provider->getTemplateConfig();
$this->config['middleware_pipeline'] = $provider->getMiddlewareConfig();
$this->config['service_manager'] = $provider->getDependencyConfig();
$this->config['router']['routes'] = $provider->getRouteConfig();
$this->config['navigation'] = $provider->getNavigationConfig();
$this->config['controllers'] = $provider->getControllerConfig();
$this->config['controller_plugins'] = $provider->getControllerPluginConfig();
// Overrides the default config to use Glob module config
return array_merge_recursive($this->config, $provider->getGlobConfig());
} | php | {
"resource": ""
} |
q264737 | WebRequest.Create | test | public function Create($url, $method = 'GET', $parameters = array())
{
$ch = curl_init();
$key= (string)$ch;
$query = '';
$res = null;
$options = $this->_options;
foreach ($parameters as $k => $v)
$query .= ((strlen ($query) == 0) ? "":"&") . sprintf('%s=%s', $k, urlencode($v));
switch (strtolower($method))
{
case 'post':
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = $query;
break;
case 'delete':
$options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
$url .= '?' . $query;
break;
default:
$url .= '?' . $query;
break;
}
$options[CURLOPT_URL] = $url;
curl_setopt_array($ch, $options);
$this->_requests[$key] = $ch;
$res = curl_multi_add_handle($this->mh, $this->_requests[$key]);
if ($res == CURLM_OK) {
curl_multi_exec($this->mh, $active);
return new WebRequestManager($key, $this->config);
}
return new Error('cURLError', curl_error($ch), curl_errno($ch), $options[CURLOPT_URL]);
} | php | {
"resource": ""
} |
q264738 | WebRequest.store | test | private function store()
{
while ($finished = curl_multi_info_read($this->mh, $messages)) {
$key = (string)$finished["handle"];
$this->_responses[$key] = new WebResponse(curl_multi_getcontent($finished["handle"]), curl_getinfo($finished["handle"]));
curl_multi_remove_handle($this->mh, $finished["handle"]);
}
} | php | {
"resource": ""
} |
q264739 | chartService.& | test | public function &getPlotData(&$bizObj, $fields, $labelField)
{
$oldCacheMode = $bizObj->GetCacheMode();
$bizObj->SetCacheMode(0); // turn off cache mode, not affect the current cache
$bizObj->runSearch(-1); // don't use page search
while (1)
{
$recArray = $bizObj->GetRecord(1);
if (!$recArray) break;
$bizObj->UnformatInputRecArr($recArray);
foreach($fields as $fld)
$recMatrix[$fld][] = $recArray[$fld]; // get data without format
$recMatrix[$labelField][] = $recArray[$labelField]; // get symbol with format
}
$bizObj->SetCacheMode($oldCacheMode);
return $recMatrix;
} | php | {
"resource": ""
} |
q264740 | chartService.renderXYPlot | test | public function renderXYPlot(&$data, &$xmlArr)
{
$id = $xmlArr['ATTRIBUTES']['ID'];
$field = $xmlArr['ATTRIBUTES']['FIELD'];
$chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
$pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
$weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
$color = $xmlArr['ATTRIBUTES']['COLOR'];
$fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
$showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
$legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
$visible = $xmlArr['ATTRIBUTES']['VISIBLE'];
if ($chartType == 'Line' or $chartType == 'Bar')
{
if ($chartType == 'Line')
{
include_once (JPGRAPH_DIR.'/jpgraph_line.php');
$plot = new LinePlot($data);
$this->_drawMark($plot->mark,
$xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'],
$xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
$plot->SetBarCenter();
$plot->SetCenter();
}
else if ($chartType == 'Bar')
{
include_once (JPGRAPH_DIR.'/jpgraph_bar.php');
$plot = new BarPlot($data);
$plot->SetAlign('center');
}
if ($color) $plot->SetColor($color);
if ($fillColor) $plot->SetFillColor($fillColor);
if ($weight) $plot->SetWeight($weight);
if ($showVal == 1) $plot->value->Show();
if ($legend) $plot->SetLegend($legend);
$this->_drawString($plot->value,$xmlArr['VALUE']['ATTRIBUTES']['FONT'],$xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
}
if ($chartType == 'GroupBar' or $chartType == 'AccBar')
{
$children = $xmlArr['ATTRIBUTES']['CHILDREN'];
$childList = explode(",",$children);
foreach($childList as $child)
{
$childPlotList[] = $this->plotList[$child];
}
if ($chartType == 'GroupBar')
$plot = new GroupBarPlot($childPlotList);
else if ($chartType == 'AccBar')
$plot = new AccBarPlot($childPlotList);
}
$this->plotList[$id] = $plot;
if ($visible == 1)
return $plot;
return null;
} | php | {
"resource": ""
} |
q264741 | chartService._getMark | test | private function _getMark($mark)
{
switch (strtoupper($mark))
{
case "SQUARE": return MARK_SQUARE;
case "UTRIANGLE": return MARK_UTRIANGLE;
case "DTRIANGLE": return MARK_DTRIANGLE;
case "DIAMOND": return MARK_DIAMOND;
case "CIRCLE": return MARK_CIRCLE;
case "FILLEDCIRCLE": return MARK_FILLEDCIRCLE;
case "CROSS": return MARK_CROSS;
case "STAR": return MARK_STAR;
case "X": return MARK_X;
default: return 0;
}
} | php | {
"resource": ""
} |
q264742 | chartService._getFont | test | private function _getFont($font)
{
switch (strtoupper($font))
{
case "ARIAL": return FF_ARIAL;
case "COURIER;": return FF_COURIER;
case "TIMES": return FF_TIMES;
case "VERDANA": return FF_VERDANA;
case "COMIC": return FF_COMIC;
case "GEORGIA": return FF_GEORGIA;
default: return FF_FONT1;
}
} | php | {
"resource": ""
} |
q264743 | Instaphp.Instance | test | public static function Instance($token = null, $config = array())
{
if (self::$instance == null || !empty($token)) {
self::$instance = new self($token, $config);
}
return self::$instance;
} | php | {
"resource": ""
} |
q264744 | Attributable.getAttribute | test | public function getAttribute($key)
{
if (isset($this->attributes[$key])) {
return $this->attributes[$key];
}
return null;
} | php | {
"resource": ""
} |
q264745 | Attributable.setAttributeInGroup | test | public function setAttributeInGroup($group, $key, $value)
{
$this->attributes[$group][$key] = $value;
return $this;
} | php | {
"resource": ""
} |
q264746 | Attributable.getAttributeInGroup | test | public function getAttributeInGroup($group, $key)
{
if (isset($this->attributes[$group][$key])) {
return $this->attributes[$group][$key];
}
return null;
} | php | {
"resource": ""
} |
q264747 | ModelRepository.findOrCreate | test | public function findOrCreate($id, array $columns = ['*'])
{
$model = $this->query()->find($id, $columns);
if (!$model) {
return $this->getModel()->newInstance();
}
return $model;
} | php | {
"resource": ""
} |
q264748 | ModelRepository.getModel | test | public function getModel()
{
if (!$this->hasDependency('model') && !$this->model instanceof Model) {
throw new Exceptions\NoModelSetException;
}
return $this->model;
} | php | {
"resource": ""
} |
q264749 | Hookable.uniqueId | test | private function uniqueId($hookName, $function, $priority)
{
static $count = 0;
if (is_string($function)) {
return $function;
}
if (is_object($function)) {
// Closures are currently implemented as objects
$function = array($function, '');
} elseif (!is_array($function)) {
$function = array($function);
}
if (is_object($function[0])) {
// Object Class Calling
if (function_exists('spl_object_hash')) {
return spl_object_hash($function[0]) . $function[1];
} else {
$object_id = get_class($function[0]).$function[1];
if (!isset($function[0]->id)) {
if (false === $priority) {
return false;
}
$object_id .= isset($this->filters[$hookName][$priority])
? count((array) $this->filters[$hookName][$priority])
: $count;
$function[0]->id = $count;
$count++;
} else {
$object_id .= $function[0]->id;
}
return $object_id;
}
} elseif (is_string($function[0])) {
// callas static
return $function[0] . '::' . $function[1];
}
// unexpected result
return null;
} | php | {
"resource": ""
} |
q264750 | Hookable.callAll | test | private function callAll($args)
{
if (isset($this->filters['all'])) {
reset($this->filters['all']);
do {
foreach ((array) current($this->filters['all']) as $fn_arr) {
if (!is_null($fn_arr['function'])) {
call_user_func_array($fn_arr['function'], $args);
}
}
} while (next($this->filters['all']) !== false);
}
} | php | {
"resource": ""
} |
q264751 | Hookable.append | test | public function append($hookName, $callable, $priority = 10, $accepted_args = 1, $create = true)
{
if ($create || ! $this->has($hookName, $callable)) {
return $this->add($hookName, $callable, $priority, $accepted_args);
}
return false;
} | php | {
"resource": ""
} |
q264752 | Hookable.exists | test | public function exists($hookName, $function_to_check = false)
{
$hookName = $this->sanitize($hookName);
if (!$hookName || !isset($this->filters[$hookName])) {
return false;
}
// Don't reset the internal array pointer
$has = !empty($this->filters[$hookName]);
// Make sure at least one priority has a filter callback
if ($has) {
$exists = false;
foreach ($this->filters[$hookName] as $callbacks) {
if (! empty($callbacks)) {
$exists = true;
break;
}
}
if (! $exists) {
$has = false;
}
}
// recheck
if (false === $function_to_check || false === $has) {
return $has;
}
if (! $id = $this->uniqueId($hookName, $function_to_check, false)) {
return false;
}
foreach (array_keys($this->filters[$hookName]) as $priority) {
if (isset($this->filters[$hookName][$priority][$id])) {
return $priority;
}
}
return false;
} | php | {
"resource": ""
} |
q264753 | Hookable.call | test | public function call($hookName, $arg = '')
{
$hookName = $this->sanitize($hookName);
if (!$hookName) {
return false;
}
if (! isset($this->actions[$hookName])) {
$this->actions[$hookName] = 1;
} else {
$this->actions[$hookName]++;
}
// Do 'all' actions first
if (isset($this->filters['all'])) {
$this->current[] = $hookName;
$all_args = func_get_args();
$this->callAll($all_args);
}
if (!isset($this->filters[$hookName])) {
if (isset($this->filters['all'])) {
array_pop($this->current);
}
return null;
}
if (!isset($this->filters['all'])) {
$this->current[] = $hookName;
}
$args = array();
if (is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0])) {
// array(&$this)
$args[] =& $arg[0];
} else {
$args[] = $arg;
}
for ($a = 2, $num = func_num_args(); $a < $num; $a++) {
$args[] = func_get_arg($a);
}
// Sort
if (!isset($this->merged[$hookName])) {
ksort($this->filters[$hookName]);
$this->merged[$hookName] = true;
}
reset($this->filters[$hookName]);
do {
foreach ((array) current($this->filters[$hookName]) as $the_) {
if (!is_null($the_['function'])) {
call_user_func_array(
$the_['function'],
array_slice($args, 0, (int) $the_['accepted_args'])
);
}
}
} while (next($this->filters[$hookName]) !== false);
array_pop($this->current);
return true;
} | php | {
"resource": ""
} |
q264754 | Hookable.replace | test | public function replace(
$hookName,
$function_to_replace,
$callable,
$priority = 10,
$accepted_args = 1,
$create = true
) {
$hookName = $this->sanitize($hookName);
if (!$hookName) {
throw new \Exception("Invalid Hook Name Specified", E_ERROR);
}
if (!is_callable($callable)) {
throw new \Exception("Invalid Hook Callable Specified", E_ERROR);
}
if (($has = $this->has($hookName, $function_to_replace)) || $create) {
$has && $this->remove($hookName, $function_to_replace);
// add hooks first
return $this->add($hookName, $callable, $priority, $accepted_args);
}
return false;
} | php | {
"resource": ""
} |
q264755 | Hookable.count | test | public function count($hookName)
{
$hookName = $this->sanitize($hookName);
if (!$hookName || !isset($this->filters[$hookName])) {
return false;
}
return count((array) $this->filters[$hookName]);
} | php | {
"resource": ""
} |
q264756 | Hookable.isDo | test | public function isDo($hookName = null)
{
if (null === $hookName) {
return ! empty($this->current);
}
$hookName = $this->sanitize($hookName);
return $hookName && in_array($hookName, $this->current);
} | php | {
"resource": ""
} |
q264757 | Hookable.isCalled | test | public function isCalled($hookName)
{
$hookName = $this->sanitize($hookName);
if (!$hookName || ! isset($this->actions[$hookName])) {
return 0;
}
return $this->actions[$hookName];
} | php | {
"resource": ""
} |
q264758 | App.addRoute | test | public function addRoute(
$path,
$middlewares = null,
string $method = null,
string $name = null
): Route {
if (!$path instanceof Route && null === $middlewares) {
throw new \InvalidArgumentException('Invalid route config');
}
if ($path instanceof Route) {
$route = $path;
}
if (!isset($route)) {
$path = $this->groupPath . $path;
if (count($this->groupMiddleware) > 0) {
$temp = $middlewares;
$middlewares = $this->groupMiddleware;
array_push($middlewares, $temp);
}
$middlewares = $this->buildMiddleware($middlewares);
$route = new Route($path, $middlewares, $method, $name);
}
$this->router->addRoute($route);
$this->log(
$this->container,
sprintf(
'App::addRoute - Add route %s %s (%s)',
implode(',', $route->getMethod()),
$route->getPath(),
null === $route->getName() ? 'no name' : $route->getName()
)
);
return $route;
} | php | {
"resource": ""
} |
q264759 | App.pipe | test | public function pipe($path, $middlewares = null, string $env = null): self
{
if (null !== $env && $this->env !== $env) {
return $this;
}
if (null === $middlewares) {
$middlewares = $this->buildMiddleware($path);
$path = '*';
}
if (!$middlewares instanceof MiddlewareInterface) {
$middlewares = $this->buildMiddleware($middlewares);
}
$route = new Route($path, $middlewares);
$this->dispatcher->pipe($route);
$this->log(
$this->container,
sprintf(
'App::pipe - Pipe middleware %s %s - %s',
implode(',', $route->getMethod()),
$route->getPath(),
get_class($middlewares)
)
);
return $this;
} | php | {
"resource": ""
} |
q264760 | App.run | test | public function run(?ServerRequestInterface $request = null, bool $returnResponse = false)
{
$request = (null !== $request) ? $request : ServerRequest::fromGlobals();
$request = $request->withAttribute('originalResponse', $this->response);
$response = $this->dispatcher->handle($request);
$this->log(
$this->container,
sprintf(
'App::run - Response [%d] %s',
$response->getStatusCode(),
$response->getReasonPhrase()
)
);
if (true === $returnResponse) {
return $response;
}
if (PHP_SAPI === 'cli') {
echo (string) $response->getBody();
} else {
\Http\Response\send($response);
}
} | php | {
"resource": ""
} |
q264761 | SignalExecutionCommand.singalExecution | test | protected function singalExecution(Node $node, Execution $execution, array $vars, array $delegation)
{
$behavior = $node->getBehavior();
if ($behavior instanceof SignalableBehaviorInterface) {
$behavior->signal($execution, $this->signal, $vars, $delegation);
}
} | php | {
"resource": ""
} |
q264762 | Container.set | test | public function set($id, $value)
{
if (!empty($this->locks[$id])) {
throw new ContainerException("Cannot override locked key {$id}");
}
$this->definitions[$id] = $value;
$this->calcs[$id] = false;
// unset on override
unset($this->objects[$id]);
} | php | {
"resource": ""
} |
q264763 | Container.raw | test | public function raw($idOrClosure)
{
if (is_object($idOrClosure) && method_exists($idOrClosure, "__invoke")) {
$this->raws->attach($idOrClosure);
return $idOrClosure;
}
if (!isset($this->definitions[$idOrClosure])) {
return null;
}
return $this->definitions[$idOrClosure];
} | php | {
"resource": ""
} |
q264764 | Encryption.encrypt | test | public function encrypt(string $value, string $key = null): string
{
if ($key === null) {
$key = $this->getDefaultKey();
}
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher));
return $iv . openssl_encrypt($value, $this->cipher, $key, 0, $iv);
} | php | {
"resource": ""
} |
q264765 | Encryption.decrypt | test | public function decrypt(string $value, string $key = null): ?string
{
if ($key === null) {
$key = $this->getDefaultKey();
}
$ivLength = openssl_cipher_iv_length($this->cipher);
$iv = substr($value, 0, $ivLength);
$result = @openssl_decrypt(substr($value, $ivLength), $this->cipher, $key, 0, $iv);
if ($result === false) {
return null;
}
return $result;
} | php | {
"resource": ""
} |
q264766 | Encryption.getDefaultKey | test | private function getDefaultKey()
{
if (isset($this->cache['defaultKey'])) {
return $this->cache['defaultKey'];
}
$app = App::get();
$cacheKey = 'ivopetkov-encryption-default-key';
$value = $app->cache->getValue($cacheKey);
if ($value === null) {
$dataKey = 'encryption/default.key';
$value = $app->data->getValue($dataKey);
if ($value === null) {
$value = md5(openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher)) . uniqid('', true) . rand(0, 999999999));
$app->data->set($app->data->make($dataKey, $value));
}
$app->cache->set($app->cache->make($cacheKey, $value));
}
$this->cache['defaultKey'] = $value;
return $value;
} | php | {
"resource": ""
} |
q264767 | DependencyObject.calculateArguments | test | private function calculateArguments(array $config): array
{
$args = [];
foreach ($config as $key => $item)
{
if (\is_string($item) && $this->base->has($item)) {
$args[] = $this->base->get($item);
continue;
}
if (\is_string($key) && \is_array($item)) {
$this->dc->set($key, $item);
$args[] = $this->dc->get($key);
continue;
}
$args[] = $item;
}
return $args;
} | php | {
"resource": ""
} |
q264768 | MySQL.getStrType | test | public static function getStrType( $str ) {
if ( null === $str ) {
return 's';
}
$chrType = substr((string)gettype($str),0,1);
return (!in_array($chrType,array("i","d","s"))) ? "b" : $chrType;
} | php | {
"resource": ""
} |
q264769 | Route.addApp | test | public function addApp(string $path, $ext, string $module)
{
$ext_key = empty($ext) ? '_' : $ext;
if (!isset($this->apps[$ext_key]))
{
$this->apps[$ext_key] = array(
'path' => $path,
'module' => $module,
'route' => $this->route,
'ext' => $ext,
'depth' => $this->depth
);
}
return $this;
} | php | {
"resource": ""
} |
q264770 | Route.getSubRoute | test | public function getSubRoute(string $route_part)
{
$sub_route = $this->route === '/' ? '/' . $route_part : $this->route . '/' . $route_part;
if (!isset($this->children[$route_part]))
$this->children[$route_part] = new Route($sub_route, $this->depth + 1);
return $this->children[$route_part];
} | php | {
"resource": ""
} |
q264771 | Route.serialize | test | public function serialize()
{
return serialize([
'route' => $this->route,
'depth' => $this->depth,
'apps' => $this->apps,
'children' => $this->children
]);
} | php | {
"resource": ""
} |
q264772 | Route.unserialize | test | public function unserialize($data)
{
$data = unserialize($data);
$this->route = $data['route'];
$this->depth = $data['depth'];
$this->apps = $data['apps'];
$this->children = $data['children'];
} | php | {
"resource": ""
} |
q264773 | Date.getYearToActual | test | public static function getYearToActual(int $beginYear): string
{
$actualYear = strftime('%Y');
if ($beginYear == $actualYear) {
return $actualYear;
} else {
return $beginYear . ' - ' . $actualYear;
}
} | php | {
"resource": ""
} |
q264774 | Date.getCurrentTimeStamp | test | public static function getCurrentTimeStamp(): string
{
$t = microtime(true);
$micro = sprintf('%06d', ($t - floor($t)) * 1000000);
$d = new DateTime(date('Y-m-d H:i:s.' . $micro, (int) $t));
return $d->format('Y_m_d_H_i_s_u');
} | php | {
"resource": ""
} |
q264775 | Date.getDay | test | public static function getDay($day): string
{
if ($day instanceof DateTimeInterface) {
$day = (int) $day->format('N');
}
if (!is_int($day)) {
throw new InvalidArgumentException;
}
return self::$dayNames[self::$locale][$day];
} | php | {
"resource": ""
} |
q264776 | Date.getShortDay | test | public static function getShortDay($day): string
{
if ($day instanceof DateTimeInterface) {
$day = (int) $day->format('N');
}
if (!is_int($day)) {
throw new InvalidArgumentException;
}
return self::$dayNamesShort[self::$locale][$day];
} | php | {
"resource": ""
} |
q264777 | Date.getMonth | test | public static function getMonth($month): string
{
if ($month instanceof DateTimeInterface) {
$month = (int) $month->format('n');
}
if (!is_int($month)) {
throw new InvalidArgumentException;
}
return self::$monthNames[self::$locale][$month];
} | php | {
"resource": ""
} |
q264778 | Date.getShortMonth | test | public static function getShortMonth($month): string
{
if ($month instanceof DateTimeInterface) {
$month = (int) $month->format('n');
}
if (!is_int($month)) {
throw new InvalidArgumentException;
}
return self::$monthNamesShort[self::$locale][$month];
} | php | {
"resource": ""
} |
q264779 | Date.formatDate | test | private static function formatDate($datetime, string $format): ?string
{
if (empty($datetime)) {
return null;
} elseif ($datetime instanceof DateTimeInterface) {
$date = $datetime;
} else {
$date = DateTime::createFromFormat('U', (string) $datetime);
}
return $date->format($format);
} | php | {
"resource": ""
} |
q264780 | Date.getDateTime | test | public static function getDateTime($datetime, bool $withSeconds = false): ?string
{
return self::formatDate($datetime, self::getFormat(true, true, $withSeconds));
} | php | {
"resource": ""
} |
q264781 | Application.registerBaseServices | test | public function registerBaseServices()
{
//see example https://github.com/slimphp/Slim/blob/3.x/Slim/DefaultServicesProvider.php
$container = $this->getContainer();
// wrapper for Request validation
if (!isset($container['validator'])) {
$container['validator'] = new \Amcms\Services\ValidatorService($container);
}
// Auth service
if (!isset($container['auth'])) {
$container['auth'] = new \Amcms\Services\AuthService($container);
}
// Twig View
if (!isset($container['twig'])) {
$container['twig'] = function ($c) {
$isDebug = $c['settings']['debug'] ?: false;
$twigTemplatesPath = $c['path'] . '/' . (isset($c['settings']['templates']['twig']['template_path']) ? trim($c['settings']['templates']['twig']['template_path'], '/') : 'resources/views/templates');
$twigCachePath = $c['path'] . '/' . (isset($c['settings']['templates']['twig']['cache_path']) ? trim($c['settings']['templates']['twig']['cache_path'], '/') : 'storage/cache');
$view = new \Amcms\View\TwigView($twigTemplatesPath, [
'cache' => $twigCachePath,
'debug' => $isDebug,
// 'auto_update' => false,
]);
$view->addExtension(new \Amcms\View\TwigExtension($c));
return $view;
};
}
} | php | {
"resource": ""
} |
q264782 | SectionTreeController.postSectiontreeAction | test | public function postSectiontreeAction() {
$serializer = $this->get("tpg_extjs.phpcr_serializer");
$entity = $serializer->deserialize(
$this->getRequest()->getContent(),
'Application\Togu\ApplicationModelsBundle\Document\Section',
'json',
DeserializationContext::create()->setGroups(array("Default", "post"))
);
$modelLoader = $this->get('togu.generator.model.config');
if(! $modelLoader->hasModel($entity->getType())) {
throw new \InvalidArgumentException(sprintf('The model %s does not exist', $entity->getType()));
}
$validator = $this->get('validator');
$validations = $validator->validate($entity, array('Default', 'post'));
if ($validations->count() === 0) {
$manager = $this->get('doctrine_phpcr.odm.default_document_manager');
$rootData = $manager->find(null, '/data');
$sectionClassName = $modelLoader->getFullClassName($entity->getType());
$section = new $sectionClassName(array(
"sectionConfig" => $entity,
"parentDocument" => $rootData
));
$entity->getParentSection()->getSectionConfig()->addNextSection($section);
$entity->getPage()->setSection($section);
$manager->persist($entity);
$manager->persist($section);
try {
$manager->flush();
} catch (DBALException $e) {
return $this->handleView(
View::create(array('errors'=>array($e->getMessage())), 400)
);
}
return $this->handleView(
View::create(array(
"success" => true,
"records" => array($entity)
), 200)->setSerializationContext($this->getSerializerContext(array('Default', 'post')))
);
} else {
return $this->handleView(
View::create(array('errors'=>$validations), 400)
);
}
} | php | {
"resource": ""
} |
q264783 | SessionEntity.setOwner | test | public function setOwner($type, $id)
{
$this->ownerType = $type;
$this->ownerId = $id;
return $this;
} | php | {
"resource": ""
} |
q264784 | PleasingMinifyFilter.removeComments | test | private function removeComments( $input, $proxy = false )
{
if ( preg_match_all("/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\//", $input, $comments) )
{
foreach ( $comments[ 0 ] as $comment )
{
$lines = explode(PHP_EOL, $comment);
$newComment = implode(PHP_EOL,preg_grep("/copyright|license|author|preserve|credit|http|\/\*\!/i",$lines));
if($newComment)
{
// Add proper comment encapsulation
if ( count( $lines ) > 1 )
{
$prefix = (substr($newComment,0,3) == '/*!') ? '' : '/*!' . PHP_EOL;
$newComment = $prefix . $newComment . PHP_EOL . " */";
}
else
{
$newComment = str_replace( array("/* ","/** "), "/*! ", $newComment );
}
if($proxy) { $this->comments[] = $newComment; }
$input = str_replace( $comment, $newComment, $input );
}
else
{
$input = str_replace( $comment, "", $input );
}
}
}
return $input;
} | php | {
"resource": ""
} |
q264785 | PleasingMinifyFilter.minifyCSS | test | private function minifyCSS($input)
{
$keepComments = null;
$output = $this->stashComments( $input );
// Remove Comments, preserving comments marked as important
$output = preg_replace('!/\*[^*\!]*\*+([^/][^*]*\*+)*/!', '', $output);
$output = $this->minifySpaceCSS($output);
$output = $this->shortenHex($output);
// Replace common units after 0's - they aren't needed
$output = preg_replace('/((?<!\\\\)\:|\s)\-?0(?:em|cm|mm|in|px|pt|%)/iS', '${1}0', $output);
// Remove Leading Zeros in Floats
$output = preg_replace("/0\.([0-9]+)/", '.$1', $output);
// Extra whitespace
$output = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $output);
// Add line breaks around remaining comments
$output = $this->retrieveComments( $output );
return $output;
} | php | {
"resource": ""
} |
q264786 | TwigView.setGlobal | test | public function setGlobal($name, $value, $options = []) {
if (isset($options['namespace'])) {
$this->getEnvironment()->addGlobal($options['namespace'], [$name => $value]);
} else {
$this->getEnvironment()->addGlobal($name, $value);
}
} | php | {
"resource": ""
} |
q264787 | StringUtils.quote | test | public static function quote($val = "", $q = "\"")
{
if (is_string($val)) {
return $q . $val . $q;
} elseif (is_numeric($val)) {
return $val;
} elseif (is_array($val)) {
return "StringUtils::quote returned 'array'! ";
} else {
return $q . $val . $q;
}
} | php | {
"resource": ""
} |
q264788 | StringUtils.explodeGeneric | test | public static function explodeGeneric($input = '', array $delims = [' '])
{
foreach ($delims as $delim) {
$input = str_replace($delim, ' ', $input);
}
$input = preg_replace('/\s\s+/', ' ', $input);
$input = trim($input);
$out = explode(' ', $input);
return $out;
} | php | {
"resource": ""
} |
q264789 | User.getRole | test | public function getRole($role)
{
foreach ($this->getRoles() as $roleItem) {
if ($role == $roleItem->getRole()) {
return $roleItem;
}
}
return null;
} | php | {
"resource": ""
} |
q264790 | User.addRole | test | public function addRole($role)
{
if (!$role instanceof Role) {
//throw new \Exception( "addRole takes a Role object as the parameter" );
$_role = new Role($role);
} else {
$_role = $role;
}
if (!$this->hasRole($_role->getRole())) {
$_role->addUser($this);
$this->roles->add($_role);
}
} | php | {
"resource": ""
} |
q264791 | User.hasRole | test | public function hasRole($role)
{
$roles = $this->getRoles();
/** @var Role $roleObject */
foreach ($roles as $roleObject) {
if ($roleObject->getRole() == strtoupper($role)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q264792 | ErrorHandler.errorHandler | test | public static function errorHandler($errNo, $errMsg, $fileName, $lineNum, $vars)
{
// don't respond to the error if it
// was suppressed with a '@'
if (error_reporting() == 0) {
return;
}
if ($errNo == E_NOTICE || $errNo == E_STRICT) { // || $errno == E_WARNING)
return; // ignore notice error
}
$debug_array = debug_backtrace();
$back_trace = self::_errorBacktrace($debug_array);
$err = self::_getOutputErrorMsg($errNo, $errMsg, $fileName, $lineNum, $back_trace);
Openbizx::$app->getLog()->logError($errNo, "ErrorHandler", $errMsg, null, $back_trace);
if ((defined('CLI') && CLI) || self::$errorMode == 'text') {
// echo $err;
} else {
Openbizx::$app->getClientProxy()->showErrorMessage($err, true);
}
if ($errNo == E_USER_ERROR || $errNo == E_ERROR) {
Openbizx::$app->getClientProxy()->printOutput();
exit();
}
} | php | {
"resource": ""
} |
q264793 | ErrorHandler.exceptionHandler | test | public static function exceptionHandler($exc)
{
$errno = $exc->getCode();
$errmsg = $exc->getMessage();
$filename = $exc->getFile();
$linenum = $exc->getLine();
$debug_array = $exc->getTrace();
$back_trace = self::_errorBacktrace($debug_array);
$err = self::_getOutputErrorMsg($errno, $errmsg, $filename, $linenum, $back_trace);
Openbizx::$app->getLog()->logError($errno, "ExceptionHandler", $errmsg, null, $back_trace);
if ((defined('CLI') && CLI) || self::$errorMode == 'text') {
echo $err;
} else {
Openbizx::$app->getClientProxy()->showErrorMessage($err, true);
}
if (!$exc->no_exit) {
Openbizx::$app->getClientProxy()->printOutput();
exit();
}
} | php | {
"resource": ""
} |
q264794 | ErrorHandler._getOutputErrorMsg | test | private static function _getOutputErrorMsg($errno, $errmsg, $filename, $linenum, $back_trace)
{
// timestamp for the error entry
date_default_timezone_set('GMT'); // to avoid error PHP 5.1
$dt = date("Y-m-d H:i:s (T)");
// TODO: use CSS class for style
$err = "<div style='font-size: 12px; color: blue; font-family:Arial; font-weight:bold;'>\n";
$err .= "[$dt] An exception occurred while executing this script:<br>\n";
$err .= "Error message: <font color=maroon> #$errno, $errmsg</font><br>\n";
$err .= "Script name and line number of error: <font color=maroon>$filename:$linenum</font><br>\n";
$err .= "<div style='font-weight:normal;'>" . $back_trace . "</div>\n";
//$err .= "Variable state when error occurred: $vars<br>";
$err .= "<hr>";
$err .= "Please ask system administrator for help...</div>\n";
if ((defined('CLI') && CLI) || self::$errorMode == 'text') {
$err = strip_tags($err);
}
return $err;
} | php | {
"resource": ""
} |
q264795 | ErrorHandler._errorBacktrace | test | private static function _errorBacktrace($debug_array = NULL)
{
if ($debug_array == NULL) {
$debug_array = debug_backtrace();
}
$counter = count($debug_array);
$msg = "";
for ($tmp_counter = 0; $tmp_counter != $counter; ++$tmp_counter) {
$msg .= "<br><b>function:</b> ";
$msg .= $debug_array[$tmp_counter]["function"] . " ( ";
//count how many args a there
$args_counter = count($debug_array[$tmp_counter]["args"]);
//print them
for ($tmp_args_counter = 0; $tmp_args_counter != $args_counter; ++$tmp_args_counter) {
$a = $debug_array[$tmp_counter]["args"][$tmp_args_counter];
switch (gettype($a)) {
case 'integer':
case 'double':
$msg .= $a;
break;
case 'string':
//$a = htmlspecialchars(substr($a, 0, 64)).((strlen($a) > 64) ? '...' : '');
//$msg .= "\"$a\"";
$a = htmlspecialchars($a);
$msg .= "\"$a\"";
break;
case 'array':
$msg .= 'Array(' . count($a) . ')';
break;
case 'object':
$msg .= 'Object(' . get_class($a) . ')';
break;
case 'resource':
$msg .= 'Resource(' . strstr($a, '#') . ')';
break;
case 'boolean':
$msg .= $a ? 'True' : 'False';
break;
case 'NULL':
$msg .= 'Null';
break;
default:
$msg .= 'Unknown';
}
if (($tmp_args_counter + 1) != $args_counter) {
$msg .= (", ");
} else {
$msg .= (" ");
}
}
$msg .= ") @ ";
if (isset($debug_array[$tmp_counter]["file"])) {
$msg .= ($debug_array[$tmp_counter]["file"] . " ");
}
if (isset($debug_array[$tmp_counter]["line"])) {
$msg .= ($debug_array[$tmp_counter]["line"]);
}
if (($tmp_counter + 1) != $counter) {
$msg .= "\n";
}
}
return $msg;
} | php | {
"resource": ""
} |
q264796 | Check.setName | test | public function setName($name = null)
{
if (null === $name || !is_string($name)) {
$this->name = self::getRandomString(8);
} else {
$this->name = $name;
}
return $this;
} | php | {
"resource": ""
} |
q264797 | Check.addSetting | test | protected function addSetting($name, $value, $group = null, $flag = ISetting::NORMAL, $cachable = false)
{
if (empty($name)) {
throw new \InvalidArgumentException('A setting must have a valid name.');
}
if (null === $group) {
$group = $this->getDefaultSettingGroupName();
}
$setting = new Setting($name, $value, $group, $flag);
$this->result->addSetting($setting, $cachable);
return $this;
} | php | {
"resource": ""
} |
q264798 | Check.addCachableSetting | test | protected function addCachableSetting($name, $value, $group = null, $flag = ISetting::NORMAL)
{
$this->addSetting($name, $value, $group, $flag, true);
return $this;
} | php | {
"resource": ""
} |
q264799 | Container.offsetUnset | test | public function offsetUnset($offset)
{
if (isset($this->map[$offset])) {
unset($this->map[$offset]);
}
if (isset($this->services[$offset])) {
unset($this->services[$offset]);
}
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.