_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q260600
Obj.read
test
public static function read($object, $property, $default = null) { if (is_null($object)) { return self::value($default); } if (isset($object->$property) || property_exists($object, $property)) { return $object->$property; } return self::value($default); }
php
{ "resource": "" }
q260601
Obj.fetch
test
public static function fetch($object, $property, $default = null) { if (is_null($object)) { return self::value($default); } return isset($object->$property) ? $object->$property : self::value($default); }
php
{ "resource": "" }
q260602
Obj.get
test
public static function get($target, $key, $default = null) { if (is_null($key) || !is_object($target)) { return self::value($default); } if (!is_array($key)) { if (isset($target->{$key}) || property_exists($target, $key)) { return $target->{$key}; } $keys = explode('.', $key); } else { $keys = $key; } foreach ($keys as $segment) { if (is_object($target) && isset($target->{$segment})) { $target = $target->{$segment}; } else { return self::value($default); } } return $target; }
php
{ "resource": "" }
q260603
Obj.set
test
public static function set(&$target, $key, $value, $overwrite = true) { if (is_null($key)) { return $target; } if (!is_array($key)) { if (isset($target->{$key}) || property_exists($target, $key)) { if ($overwrite) { $target->{$key} = self::value($value); } return $target; } $keys = explode('.', $key); } else { $keys = $key; } $keep = $target; while (count($keys) > 1) { $key = array_shift($keys); // If the key doesn't exist at this depth, we will just create an empty array // to hold the next value, allowing us to create the arrays to hold final // values at the correct depth. Then we'll keep digging into the array. if (!isset($target->{$key}) || !is_object($target->{$key}) && $overwrite) { $target->{$key} = new \stdClass; } elseif (!is_object($target->{$key})) { return $target; } $target = &$target->{$key}; } $key = array_shift($keys); if (!isset($target->{$key}) || $overwrite) { $target->{$key} = self::value($value); } return $keep; }
php
{ "resource": "" }
q260604
Handler.register
test
public static function register() { set_error_handler(function ($errno, $errstr, $errfile, $errline) { self::handleError($errno, $errstr, $errfile, $errline); }); set_exception_handler(function ($e) { self::handleException($e); }); register_shutdown_function(function () { // Handle Fatal error $error = error_get_last(); if (isset($error['type']) && $error['type'] === E_ERROR) { self::handleError($error['type'], $error['message'], $error['file'], $error['line']); } }); }
php
{ "resource": "" }
q260605
Handler.handleError
test
public static function handleError($errno, $errstr, $errfile, $errline) { if (!($errno & error_reporting())) { return; } static::handle(Error::fromError($errno, $errstr, $errfile, $errline)); }
php
{ "resource": "" }
q260606
Handler.handle
test
public static function handle(Error $error) { foreach (self::$writers as $class => $writer) { if (is_null($writer)) { self::$writers[$class] = $writer = new $class(); } $writer->handle($error); } }
php
{ "resource": "" }
q260607
Migrator.resolve
test
public function resolve($file) { $class = Str::studly(implode('_', array_slice(explode('_', $file), 4))); if (!class_exists($class)) { $className = str_replace('.', '\\', $this->getRepository()->getGroup()); $class = $className.'\\Database\\Migrations\\'.$class; } return new $class; }
php
{ "resource": "" }
q260608
LevelAwareLogger.shouldLog
test
protected function shouldLog($level) { if ($this->levels === ['*'] || $this->levels === ['all']) { return true; } return in_array($level, $this->levels); }
php
{ "resource": "" }
q260609
LevelAwareLogger.useFiles
test
public function useFiles($path, $level = 'debug') { if ($this->logger instanceof Log) { $this->logger->useFiles($path, $level); } }
php
{ "resource": "" }
q260610
LevelAwareLogger.useDailyFiles
test
public function useDailyFiles($path, $days = 0, $level = 'debug') { if ($this->logger instanceof Log) { $this->logger->useDailyFiles($path, $days, $level); } }
php
{ "resource": "" }
q260611
LoggerServiceProvider.registerLogger
test
protected function registerLogger() { $this->app->singleton('logger', function (Container $app) { $loggers = []; foreach ($app->config->get('logger.loggers', []) as $logger => $levels) { $loggers[] = new LevelAwareLogger($app->make($logger), (array) $levels); } return new LoggerWrapper($loggers); }); $this->app->alias('logger', LoggerWrapper::class); $this->app->alias('logger', LoggerInterface::class); $this->app->alias('logger', Log::class); }
php
{ "resource": "" }
q260612
SQL.setUp
test
public function setUp($options = []) { $this->setupProperty($options, 'dbType', 'DB_TYPE'); $this->setupProperty($options, 'server', 'DB_HOST'); $this->setupProperty($options, 'username', 'DB_USERNAME'); $this->setupProperty($options, 'password', 'DB_PASSWORD'); $this->setupProperty($options, 'database', 'DB_DATABASE'); $this->setupProperty($options, 'port', 'DB_PORT'); $this->setupProperty($options, 'connectionSettings', 'DB_SETUP'); }
php
{ "resource": "" }
q260613
SQL.logSqlError
test
public function logSqlError($ignoreErrors = false) { if (!$this->result && !$ignoreErrors) { $queryRaw = $this->lastQuery; $callerBackTrace = debug_backtrace(); $callerBackTrace = $callerBackTrace[2]; $caller = $callerBackTrace['function'].'()'; if (isset($callerBackTrace['class'])) { $caller .= ' in '.$callerBackTrace['class']; } if (isset($callerBackTrace['object'])) { $caller .= ' ('.get_class($callerBackTrace['object']).')'; } \Ease\Shared::logger()->addStatusMessage(new \Ease\Logger\Message('ExeQuery: #'.$this->errorNumber.': '.$this->errorText."\n".$queryRaw, 'error', $caller)); } }
php
{ "resource": "" }
q260614
UlTag.&
test
public function &addItemSmart($pageItem, $properties = []) { if (is_array($pageItem)) { foreach ($pageItem as $item) { $this->addItemSmart($item); } $itemAdded = &$this->lastItem; } else { if (isset($pageItem->tagType) && $pageItem->tagType == 'li') { $itemAdded = parent::addItem($pageItem); } else { $itemAdded = parent::addItem(new LiTag($pageItem, $properties)); } } return $itemAdded; }
php
{ "resource": "" }
q260615
Properties.getProperty
test
public function getProperty($property, $default = null) { if (!$property) return $default; $value = isset($this->properties[$property]) ? $this->properties[$property] : $default; // If the attribute exists within the cast array, we will convert it to // an appropriate native PHP type dependant upon the associated value // given with the key in the pair. Dayle made this comment line up. if ($this->hasCast($property)) { return $this->castGetProperty($property, $value); } return $value; }
php
{ "resource": "" }
q260616
Properties.setProperty
test
public function setProperty($property, $value) { $this->properties[$property] = ($this->hasCast($property)) ? $this->castSetProperty($property, $value) : $value; return $this; }
php
{ "resource": "" }
q260617
Properties.setProperties
test
public function setProperties(array $properties, $sync = false) { $this->properties = []; foreach ($properties as $property => $value) { $setMethod = 'set' . ucfirst($property); if (method_exists($this, $setMethod)) { $this->$setMethod($value); } else { $this->setProperty($property, $value); } } if ($sync) { $this->syncOriginal(); } return $this; }
php
{ "resource": "" }
q260618
Properties.getOriginal
test
public function getOriginal($property = null, $default = null) { if (is_null($property)) return $this->original; return isset($this->original[$property]) ? $this->original[$property] : $default; }
php
{ "resource": "" }
q260619
Properties.hasCast
test
public function hasCast($property, $types = null) { if (array_key_exists($property, $this->casts)) { return $types ? in_array($this->getCastType($property), (array)$types, true) : true; } return false; }
php
{ "resource": "" }
q260620
Properties.getDirty
test
public function getDirty() { $dirty = []; foreach ($this->properties as $property => $value) { if (!array_key_exists($property, $this->original)) { $dirty[$property] = $value; } elseif ($value !== $this->original[$property] && !$this->originalIsNumericallyEquivalent($property) ) { $dirty[$property] = $value; } } return $dirty; }
php
{ "resource": "" }
q260621
Navbar.navBarHeader
test
public static function navBarHeader($handle, $brand) { $navstyle = '.navbar-'.$handle.'-collapse'; $nbhc['button'] = new \Ease\Html\ButtonTag([new \Ease\Html\Span( _('Switch navigation'), ['class' => 'sr-only']), new \Ease\Html\Span( null, ['class' => 'icon-bar']), new \Ease\Html\Span( null, ['class' => 'icon-bar']), new \Ease\Html\Span( null, ['class' => 'icon-bar'])], ['type' => 'button', 'class' => 'navbar-toggle', 'data-toggle' => 'collapse', 'data-target' => $navstyle,]); if (strlen($brand)) { $nbhc['brand'] = new \Ease\Html\ATag('./', $brand, ['class' => 'navbar-brand']); } return new \Ease\Html\DivTag($nbhc, ['class' => 'navbar-header']); }
php
{ "resource": "" }
q260622
Navbar.&
test
public function &addDropDownSubmenu($name, $items) { $dropdown = $this->addItem(new \Ease\Html\UlTag(null, ['class' => 'dropdown-menu', 'role' => 'menu'])); if (count($items)) { foreach ($items as $item) { $this->addMenuItem($item); } } return $dropdown; }
php
{ "resource": "" }
q260623
ButtonGroup.addButton
test
public function addButton($content, $type = 'default', $properties = []) { if (isset($properties['class'])) { $properties['class'] = 'btn btn-'.$type.' '.$properties['class']; } else { $properties['class'] = 'btn btn-'.$type; } $button = new \Ease\Html\ButtonTag($content, $properties); return $this->addItem($button); }
php
{ "resource": "" }
q260624
ToStd.flush
test
public function flush($caller = null) { $flushed = 0; if (count($this->statusMessages)) { foreach ($this->statusMessages as $type => $messages) { foreach ($messages as $messageID => $message) { if (!isset($this->flushed[$type][$messageID])) { $this->addToLog($caller, $message, $type); $this->flushed[$type][$messageID] = true; ++$flushed; } } } } return $flushed; }
php
{ "resource": "" }
q260625
WebPage.&
test
public function &addItem($item, $pageItemName = null) { $added = $this->body->addItem($item, $pageItemName); return $added; }
php
{ "resource": "" }
q260626
WebPage.addCSS
test
public function addCSS($css) { if (is_array($css)) { $css = key($css).'{'.current($css).'}'; } $this->easeShared->cascadeStyles[md5($css)] = $css; return true; }
php
{ "resource": "" }
q260627
User.getGravatar
test
public static function getGravatar( $email, $size = 80, $default = 'mm', $maxRating = 'g' ) { $url = 'http://www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($email))); $url .= "?s=$size&d=$default&r=$maxRating"; return $url; }
php
{ "resource": "" }
q260628
Page.offsetSet
test
public function offsetSet($key, $value) { if (is_null($key)) { $this->content[] = $value; } else { $this->content[$key] = $value; } }
php
{ "resource": "" }
q260629
Shared.&
test
public static function &db($pdo = null) { $shared = self::instanced(); if (is_object($pdo)) { $shared->dbLink = &$pdo; } if (!is_object($shared->dbLink)) { $shared->dbLink = self::db(SQL\PDO::singleton(is_array($pdo) ? $pdo : [ ])); } return $shared->dbLink; }
php
{ "resource": "" }
q260630
Shared.&
test
public static function &locale($locale = null) { $shared = self::instanced(); if (is_object($locale)) { $shared->locale = &$locale; } if (!is_object($shared->locale)) { $shared->locale = Locale::singleton(); } return $shared->locale; }
php
{ "resource": "" }
q260631
Shared.addUrlParams
test
public static function addUrlParams($url, $addParams, $override = false) { $urlParts = parse_url($url); $urlFinal = ''; if (array_key_exists('scheme', $urlParts)) { $urlFinal .= $urlParts['scheme'].'://'.$urlParts['host']; } if (array_key_exists('port', $urlParts)) { $urlFinal .= ':'.$urlParts['port']; } if (array_key_exists('path', $urlParts)) { $urlFinal .= $urlParts['path']; } if (array_key_exists('query', $urlParts)) { parse_str($urlParts['query'], $queryUrlParams); $urlParams = $override ? array_merge($queryUrlParams, $addParams) : array_merge($addParams, $queryUrlParams); } else { $urlParams = $addParams; } if (!empty($urlParams)) { $urlFinal .= '?'; if (is_array($urlParams)) { $urlFinal .= http_build_query($urlParams); } else { $urlFinal .= $urlParams; } } return $urlFinal; }
php
{ "resource": "" }
q260632
Shared.linkify
test
public static function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) { // Link attributes $attr = ''; foreach ($attributes as $key => $val) { $attr = ' '.$key.'="'.htmlentities($val).'"'; } $links = array(); // Extract existing links and tags $value = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function ($match) use (&$links) { return '<'.array_push($links, $match[1]).'>'; }, $value); // Extract text links for each protocol foreach ((array) $protocols as $protocol) { switch ($protocol) { case 'http': case 'https': $value = preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { if ($match[1]) $protocol = $match[1]; $link = $match[2] ?: $match[3]; return '<'.array_push($links, "<a $attr href=\"$protocol://$link\">$link</a>").'>'; }, $value); break; case 'mail': $value = preg_replace_callback('~([^\s<]+?@[^\s<]+?\.[^\s<]+)(?<![\.,:])~', function ($match) use (&$links, $attr) { return '<'.array_push($links, "<a $attr href=\"mailto:{$match[1]}\">{$match[1]}</a>").'>'; }, $value); break; case 'twitter': $value = preg_replace_callback('~(?<!\w)[@#](\w++)~', function ($match) use (&$links, $attr) { return '<'.array_push($links, "<a $attr href=\"https://twitter.com/".($match[0][0] == '@' ? '' : 'search/%23').$match[1]."\">{$match[0]}</a>").'>'; }, $value); break; default: $value = preg_replace_callback('~'.preg_quote($protocol, '~').'://([^\s<]+?)(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) { return '<'.array_push($links, "<a $attr href=\"$protocol://{$match[1]}\">{$match[1]}</a>").'>'; }, $value); break; } } // Insert all link return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) { return $links[$match[1] - 1]; }, $value); }
php
{ "resource": "" }
q260633
TableTag.&
test
public function &addRowFooterColumns($columns = null, $properties = []) { $tableRow = $this->tFoot->addItem(new TrTag()); if (is_array($columns)) { foreach ($columns as $column) { if (is_object($column) && method_exists($column, 'getTagType') && $column->getTagType() == 'th') { $tableRow->addItem($column); } else { $tableRow->addItem(new ThTag($column, $properties)); } } } return $tableRow; }
php
{ "resource": "" }
q260634
Page.includeCss
test
public function includeCss($cssFile, $fwPrefix = false, $media = 'screen') { return \Ease\Shared::webPage()->includeCss($cssFile, $fwPrefix, $media); }
php
{ "resource": "" }
q260635
Page.phpSelf
test
public static function phpSelf($dropqs = true) { $url = null; if (php_sapi_name() != 'cli') { $schema = 'http'; if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) { $schema .= 's'; } $url = sprintf('%s://%s%s', $schema, $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']); $parts = parse_url($url); $port = $_SERVER['SERVER_PORT']; $scheme = $parts['scheme']; $host = $parts['host']; if (isset($parts['path'])) { $path = $parts['path']; } else { $path = null; } if (isset($parts['query'])) { $qs = $parts['query']; } else { $qs = null; } $port || $port = ($scheme == 'https') ? '443' : '80'; if (($scheme == 'https' && $port != '443') || ($scheme == 'http' && $port != '80') ) { $host = "$host:$port"; } $url = "$scheme://$host$path"; if (!$dropqs) { return "{$url}?{$qs}"; } else { return $url; } } }
php
{ "resource": "" }
q260636
NetLicensingCurl.buildPostData
test
public function buildPostData($data) { $this->data = $data; $query = parent::buildPostData($data); foreach ($data as $key => $value) { if (is_array($value)) $query = preg_replace('/&' . $key . '%5B%5D=/simU', '&' . $key . '=', $query); } $this->query = $query; return $query; }
php
{ "resource": "" }
q260637
Locale.availble
test
public function availble() { $locales = []; $d = dir(self::$i18n); while (false !== ($entry = $d->read())) { if (($entry[0] != '.') && file_exists(self::$i18n.'/'.$entry.'/LC_MESSAGES/'.self::$textDomain.'.mo')) { $locales[$entry] = _(self::$alllngs[$entry]); } } $d->close(); return $locales; }
php
{ "resource": "" }
q260638
Locale.langToLocale
test
public static function langToLocale($lang) { $defaultLocale = 'C'; $langs = []; foreach (self::$alllngs as $langCode => $language) { $langs[$langCode] = [strstr($langCode, '_') ? substr($langCode, 0, strpos($langCode, '_')) : $langCode, $language]; } foreach ($langs as $code => $langInfo) { if ($lang == $langInfo[0]) { $defaultLocale = $code; break; } } return $defaultLocale; }
php
{ "resource": "" }
q260639
Locale.useLocale
test
public static function useLocale($localeCode) { \setlocale(LC_ALL, $localeCode); \bind_textdomain_codeset(self::$textDomain, 'UTF-8'); \putenv("LC_ALL=$localeCode"); if (file_exists(self::$i18n)) { \bindtextdomain(self::$textDomain, self::$i18n); } \textdomain(self::$textDomain); if (isset($_SESSION)) { $_SESSION['locale'] = $localeCode; } self::$localeUsed = $localeCode; }
php
{ "resource": "" }
q260640
Molecule.setupProperty
test
public function setupProperty($options, $name, $constant = null) { if (isset($options[$name])) { $this->$name = $options[$name]; } else { if (is_null($this->$name) && !empty($constant) && defined($constant)) { $this->$name = constant($constant); } } }
php
{ "resource": "" }
q260641
Molecule.getStatusMessages
test
public function getStatusMessages($clean = false) { $messages = $this->easeShared->getStatusMessages(); if ($clean) { $this->easeShared->cleanMessages(); } return $messages; }
php
{ "resource": "" }
q260642
UtilityService.listCountries
test
public static function listCountries(Context $context, $filter = null) { $queryParams = (!is_null($filter)) ? [Constants::FILTER => $filter] : []; $response = NetLicensingService::getInstance() ->get($context, Constants::UTILITY_ENDPOINT_PATH . '/' . Constants::UTILITY_ENDPOINT_PATH_COUNTRIES, $queryParams); $countries = []; $pageNumber = !empty($response->items->pagenumber) ? $response->items->pagenumber : 0; $itemsNumber = !empty($response->items->itemsnumber) ? $response->items->itemsnumber : 0; $totalPages = !empty($response->items->totalpages) ? $response->items->totalpages : 0; $totalItems = !empty($response->items->totalitems) ? $response->items->totalitems : 0; if (!empty($response->items->item)) { foreach ($response->items->item as $item) { $country = ItemToCountryConverter::convert($item); $country->exists = true; $countries[] = $country; } } return new Page($countries, $pageNumber, $itemsNumber, $totalPages, $totalItems); }
php
{ "resource": "" }
q260643
ListGroup.&
test
public function &addItemSmart($pageItem, $properties = []) { $item = parent::addItemSmart($pageItem, $properties); $item->addTagClass('list-group-item'); return $item; }
php
{ "resource": "" }
q260644
LabelTag.setObjectName
test
public function setObjectName($objectName = null) { if (is_null($objectName)) { $objectName = get_class($this).'@'.$this->getTagProperty('for'); } return parent::setObjectName($objectName); }
php
{ "resource": "" }
q260645
ToConsole.set
test
public static function set($str, $color) { $color_attrs = explode("+", $color); $ansi_str = ""; foreach ($color_attrs as $attr) { $ansi_str .= "\033[".self::$ANSI_CODES[$attr]."m"; } $ansi_str .= $str."\033[".self::$ANSI_CODES["off"]."m"; return $ansi_str; }
php
{ "resource": "" }
q260646
ToConsole.getTypeColor
test
public static function getTypeColor($type) { switch ($type) { case 'mail': // Envelope $color = 'blue'; break; case 'warning': // Vykřičník v trojůhelníku $color = 'yellow'; break; case 'error': // Lebka $color = 'red'; break; case 'debug': // Kytička $color = 'magenta'; break; case 'success': // Kytička $color = 'green'; break; default: // i v kroužku $color = 'white'; break; } return $color; }
php
{ "resource": "" }
q260647
NetLicensingService.get
test
public function get(Context $context, $urlTemplate, array $queryParams = []) { return $this->request($context, 'get', $urlTemplate, $queryParams); }
php
{ "resource": "" }
q260648
NetLicensingService.post
test
public function post(Context $context, $urlTemplate, array $queryParams = []) { return $this->request($context, 'post', $urlTemplate, $queryParams); }
php
{ "resource": "" }
q260649
NetLicensingService.delete
test
public function delete(Context $context, $urlTemplate, array $queryParams = []) { return $this->request($context, 'delete', $urlTemplate, $queryParams); }
php
{ "resource": "" }
q260650
Sand.getMyKey
test
public function getMyKey($data = null) { $key = null; if (is_null($data)) { $data = $this->getData(); } if (isset($data) && isset($data[$this->keyColumn])) { $key = $data[$this->keyColumn]; } return $key; }
php
{ "resource": "" }
q260651
Sand.unsetDataValue
test
public function unsetDataValue($columnName) { if (array_key_exists($columnName, $this->data)) { unset($this->data[$columnName]); return true; } return false; }
php
{ "resource": "" }
q260652
Sand.reindexArrayBy
test
public static function reindexArrayBy($data, $indexBy = null) { $reindexedData = []; foreach ($data as $dataID => $data) { if (array_key_exists($indexBy, $data)) { $reindexedData[$data[$indexBy]] = $data; } else { throw new \Exception(sprintf('Data row does not contain column %s for reindexing', $indexBy)); } } return $reindexedData; }
php
{ "resource": "" }
q260653
Container.draw
test
public function draw() { foreach ($this->pageParts as $part) { if (is_object($part)) { if (method_exists($part, 'drawIfNotDrawn')) { $part->drawIfNotDrawn(); } else { $part->draw(); } } else { echo $part; } } $this->drawStatus = true; }
php
{ "resource": "" }
q260654
NetLicensingDemo.setUpContext
test
public function setUpContext() { return $this->context = (new \NetLicensing\Context()) ->setBaseUrl(self::BASE_URL) ->setSecurityMode(self::SECURITY_MODE) ->setUsername(self::USERNAME) ->setPassword(self::PASSWORD); }
php
{ "resource": "" }
q260655
Mailer.getItemsCount
test
public function getItemsCount($object = null) { if (is_null($object)) { $object = $this->htmlBody; } return parent::getItemsCount($object); }
php
{ "resource": "" }
q260656
Mailer.isEmpty
test
public function isEmpty($element = null) { if (is_null($element)) { $element = $this->htmlBody; } return parent::isEmpty($element); }
php
{ "resource": "" }
q260657
PDO.addSlashes
test
public function addSlashes($text) { if (isset($this->sqlLink) && method_exists($this->sqlLink, 'real_escape_string')) { $slashed = $this->sqlLink->real_escape_string($text); } else { $slashed = addslashes($text); } return $slashed; }
php
{ "resource": "" }
q260658
PDO.connect
test
public function connect() { if (is_null($this->dbType)) { $result = null; } else { switch ($this->dbType) { case 'mysql': $this->sqlLink = new \PDO($this->dbType.':dbname='.$this->database.';host='.$this->server.';port='.$this->port.';charset=utf8', $this->username, $this->password, [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8\'']); break; case 'pgsql': $this->sqlLink = new \PDO($this->dbType.':dbname='.$this->database.';host='.$this->server.';port='.$this->port, $this->username, $this->password); if (is_object($this->sqlLink)) { $this->sqlLink->query("SET NAMES 'UTF-8'"); } break; default: throw new \Ease\Exception(_('Unimplemented Database type').': '.$this->dbType); break; } if (is_object($this->sqlLink)) { $this->errorNumber = $this->sqlLink->errorCode(); $this->errorText = $this->sqlLink->errorInfo(); } else { $result = false; } if ($this->errorNumber != '00000') { $this->addStatusMessage('Connect: error #'.$this->errorNumer.' '.$this->errorText, 'error'); $result = false; } else { $result = parent::connect(); } } return $result; }
php
{ "resource": "" }
q260659
PDO.arrayToInsert
test
public function arrayToInsert($data) { $cc = $this->getColumnComma(); $set = ' '; if ($this->dbType == 'mysql') { $set = ' SET '; } return $this->exeQuery('INSERT INTO '.$cc.$this->myTable.$cc.$set.$this->arrayToQuery($data)); }
php
{ "resource": "" }
q260660
PDO.prepSelect
test
public function prepSelect($data, $ldiv = 'AND') { $operator = null; $conditions = []; $conditionsII = []; foreach ($data as $column => $value) { if (is_integer($column)) { $conditionsII[] = $value; continue; } if (($column == $this->keyColumn) && ($this->keyColumn == '')) { continue; } if (is_string($value) && (($value == '!=""') || ($value == "!=''"))) { $conditions[] = ' '.$this->getColumnComa().$column.$this->getColumnComma()." !='' "; continue; } if (is_null($value)) { $value = 'null'; $operator = ' IS '; } else { if (strlen($value) && ($value[0] == '!')) { $operator = ' != '; $value = substr($value, 1); } else { if (($value === '!null') || (strtoupper($value) === 'IS NOT NULL')) { $value = 'null'; $operator = 'IS NOT'; } else { if (is_null($operator)) { $operator = ' = '; } } } if (is_bool($value)) { if ($value === null) { $value .= ' null,'; } elseif ($value) { $value = ' TRUE'; } else { $value = ' FALSE'; } } elseif (!is_string($value)) { $value = " $value"; } else { if (strtoupper($value) == 'NOW()') { $value = " 'NOW()'"; } else { if ($value != 'null') { $value = " '".addslashes($value)."'"; } } if ($operator == ' != ') { $operator = ' NOT LIKE '; } else { if (is_null($operator)) { $operator = ' LIKE '; } } } } $conditions[] = ' '.$this->getColumnComma().$column.$this->getColumnComma()."$operator $value "; } return trim(implode($ldiv, $conditions).' '.implode(' ', $conditionsII)); }
php
{ "resource": "" }
q260661
PDO.useObject
test
public function useObject($object) { $this->setKeyColumn($object->getKeyColumn()); $this->setTableName($object->getMyTable()); }
php
{ "resource": "" }
q260662
Carousel.addSlide
test
public function addSlide($slide, $capHeading = '', $caption = '', $default = false) { $item = new \Ease\Html\DivTag($slide, ['class' => 'item']); if ($default) { $item->addTagClass('active'); } if ($capHeading || $caption) { $cpt = $item->addItem(new \Ease\Html\DivTag(null, ['class' => 'carousel-caption'])); if ($capHeading) { $cpt->addItem(new \Ease\Html\H4Tag($capHeading)); } if ($caption) { $cpt->addItem(new \Ease\Html\PTag($caption)); } } $to = $this->indicators->getItemsCount(); $indicator = new \Ease\Html\LiTag(null, ['data-target' => '#'.$this->name, 'data-slide-to' => $to]); if ($default) { $indicator->addTagClass('active'); $this->active = $to; } $this->indicators->addItem($indicator); $this->inner->addItem($item); }
php
{ "resource": "" }
q260663
Carousel.finalize
test
public function finalize() { Part::twBootstrapize(); if (is_null($this->active) && $this->getItemsCount() ) { //We need one slide active $this->indicators->getFirstPart()->setTagClass('active'); $this->inner->getFirstPart()->addTagClass('active'); } $this->inner->addItem( new \Ease\Html\ATag( '#'.$this->getTagID(), [ new \Ease\Html\Span(null, ['class' => 'glyphicon glyphicon-chevron-left', 'aria-hidden' => 'true']), new \Ease\Html\Span(_('Previous'), ['class' => 'sr-only']), ], ['class' => 'left carousel-control', 'data-slide' => 'prev', 'role' => 'button'] ) ); $this->inner->addItem( new \Ease\Html\ATag( '#'.$this->getTagID(), [ new \Ease\Html\Span(null, ['class' => 'glyphicon glyphicon-chevron-right', 'aria-hidden' => 'true']), new \Ease\Html\Span(_('Next'), ['class' => 'sr-only']), ], ['class' => 'right carousel-control', 'data-slide' => 'next', 'role' => 'button'] ) ); if ($this->getTagProperty('data-ride') != 'carousel') { $this->addJavaScript('$(\'#'.$this->name.'\').carousel();', null, true); } }
php
{ "resource": "" }
q260664
Regent.addToLog
test
public function addToLog($caller, $message, $type = 'info') { foreach ($this->loggers as $logger) { $logger->addToLog($caller, $message, $type); } }
php
{ "resource": "" }
q260665
Regent.addStatusObject
test
public function addStatusObject(Message $message, $type = 'info') { $this->addToLog($message->caller, $message->body, $message->type); \Ease\Shared::instanced()->addStatusMessage($message->body, $message->type); return parent::addStatusMessage($message->body, $message->type); }
php
{ "resource": "" }
q260666
Tag.getTagName
test
public function getTagName() { $tagName = null; if ($this->setName === true) { if (isset($this->tagProperties['name'])) { $tagName = $this->tagProperties['name']; } } else { $tagName = $this->tagName; } return $tagName; }
php
{ "resource": "" }
q260667
Tag.getTagProperty
test
public function getTagProperty($propertyName) { $property = null; if (isset($this->tagProperties[$propertyName])) { $property = $this->tagProperties[$propertyName]; } return $property; }
php
{ "resource": "" }
q260668
Modal.finalize
test
public function finalize() { Part::twBootstrapize(); $modalDialog = $this->addItem(new \Ease\Html\DivTag(null, ['class' => 'modal-dialog', 'role' => 'document'])); $modalContent = $modalDialog->addItem(new \Ease\Html\DivTag(null, ['class' => 'modal-content'])); $this->header->addItem(new \Ease\Html\H4Tag($this->title, ['class' => 'modal-title', 'id' => $this->title.'ID'])); $modalContent->addItem($this->header); $modalContent->addItem($this->body); $modalContent->addItem($this->footer); if (is_array($this->properties)) { \Ease\Shared::webPage()->addJavaScript( ' $(function () { $("#'.$this->name.'").modal( {'.Part::partPropertiesToString($this->properties).'}); }); ', null, true ); } else { \Ease\Shared::webPage()->addJavaScript( ' $(function () { $("#'.$this->name.'").modal( '.$this->properties.'); }); ', null, true ); } }
php
{ "resource": "" }
q260669
CommandRunner.cloneEarlyRunner
test
public function cloneEarlyRunner() { $ret = clone $this; $ret->nextRun = time(); $this->once = true; //\mdebug('Cloned early runner for process [%d]', $this->currentPid); return $ret; }
php
{ "resource": "" }
q260670
Tabs.&
test
public function &addAjaxTab($tabName, $tabUrl, $active = false) { $this->tabs[$tabName] = ['ajax' => $tabUrl]; if ($active) { $this->activeTab = $tabName; } \Ease\Shared::webPage()->addJavaScript(' $(\'#'.$this->getTagID().' a\').click(function (e) { e.preventDefault(); var url = $(this).attr("data-url"); var href = this.hash; var pane = $(this); // ajax load from data-url $(href).load(url,function(result){ pane.tab(\'show\'); }); }); '); return $this->tabs[$tabName]; }
php
{ "resource": "" }
q260671
Debug.trace
test
protected function trace($data) { if ($this->_debug) { //Open the tags and output request specific items if ($data->getType() == "request") { print '<table style="border-style: solid; border-width: 1px; border-color: #b1b1b1; margin: 5px"><tr><td style="vertical-align: top; padding: 10px; width: 400px">'; print "<h3>Request to server</h3>"; print "<p><strong>{$data->getMethod()}</strong> {$data->getRequestUrl()}</p>"; } //Output response specific items if ($data->getType() == "response") { print '<td style="vertical-align: top; padding: 10px; padding-left: 20px; width: 400px"><h3>Response from server</h3>'; if ($data->getHttpCode() >= 400) { print '<p style="color: red"><strong>' . $data->getHttpCode() . '</strong> ' . $data->getHttpCodeDefinition() . '</p>'; } else { print '<p style="color: green"><strong>' . $data->getHttpCode() . '</strong> ' . $data->getHttpCodeDefinition() . '</p>'; } } //Headers print "<pre>"; foreach ($data->getHeaders() as $header => $value) { print "$header : $value\n"; } print "</pre>"; //Body if ($data->getBody()) { $body = json_decode($data->getBody()); print "<pre>" . json_encode($body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "</pre>"; } //Close off the tags if ($data->getType() == "request") { print '</td>'; } if ($data->getType() == "response") { print '<p>Time taken: ' . $data->getTimeTaken() * 1000 . ' ms</pre>'; print "</td></tr></table>"; } } }
php
{ "resource": "" }
q260672
AObservable.attach
test
public function attach($events, IObserver $observer) { if (is_array($events)) { foreach ($events as $event) { $this->doAttach($event, $observer); } } elseif (is_string($events)) { $this->doAttach($events, $observer); } else { throw new ObservableException("Event can only be a string containing the name of the event or an array of event names."); } }
php
{ "resource": "" }
q260673
AObservable.doAttach
test
protected function doAttach($event, IObserver $observer) { if (!array_key_exists($event, $this->_observers)) { $this->_observers[$event] = array(); } if (in_array($observer, $this->_observers[$event], true)) { return; } array_push($this->_observers[$event], $observer); }
php
{ "resource": "" }
q260674
AObservable.detach
test
public function detach($event, IObserver $observer) { if (!isset($this->_observers[$event])) { return; } foreach ($this->_observers[$event] as $key=> $attachedObserver) { if ($attachedObserver === $observer) { array_splice($this->_observers[$event], $key, 1); } } }
php
{ "resource": "" }
q260675
AObservable.detachAllEventsForObserver
test
public function detachAllEventsForObserver(IObserver $observerToRemove) { foreach ($this->_observers as $event => $observers) { foreach ($observers as $position => $observer) { if ($observer === $observerToRemove) { array_splice($this->_observers[$event], $position, 1); break; //Save cycles by breaking here since there is each observer is only attached to each event once. } } } }
php
{ "resource": "" }
q260676
Toolbox.validatePod
test
public function validatePod($pod) { if ($pod instanceof AModel) { $pod = $pod->getPod(); } if ($pod->compareToolbox($this)) { return true; } else { throw new ToolboxException("The pod/model does not belong to this toolbox."); } }
php
{ "resource": "" }
q260677
Toolbox.getConnection
test
public function getConnection() { if (!$this->_connection) { $options = array( // server endpoint to connect to ConnectionOptions::OPTION_ENDPOINT => $this->_endpoint, // authorization type to use (currently supported: 'Basic') ConnectionOptions::OPTION_AUTH_TYPE => 'Basic', // user for basic authorization ConnectionOptions::OPTION_AUTH_USER => $this->_username, // password for basic authorization ConnectionOptions::OPTION_AUTH_PASSWD => $this->_password, ConnectionOptions::OPTION_TRACE => $this->_debug, ConnectionOptions::OPTION_ENHANCED_TRACE => true, ConnectionOptions::OPTION_DATABASE => $this->_database ); $this->_connection = new Connection($options); } return $this->_connection; }
php
{ "resource": "" }
q260678
Toolbox.getDriver
test
public function getDriver() { if (!$this->_driver) { if ($this->_graph) { $this->_driver = $this->getGraphHandler(); } else { $this->_driver = $this->getDocumentHandler(); } } return $this->_driver; }
php
{ "resource": "" }
q260679
Toolbox.generateBindingParameter
test
public function generateBindingParameter($parameter, $userParameters) { $userParameters = array_keys($userParameters); while (in_array($parameter, $userParameters)) { $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; for ($i = 0; $i < 7; $i++) { $parameter .= $characters[rand(0, strlen($characters) - 1)]; } } return $parameter; }
php
{ "resource": "" }
q260680
Toolbox.normaliseDriverExceptions
test
public function normaliseDriverExceptions(\Exception $exception) { if ($exception instanceof \triagens\ArangoDb\ServerException) { return array('message' => $exception->getServerMessage(), 'code' => $exception->getServerCode()); } else { return array('message' => $exception->getMessage(), 'code' => $exception->getCode()); } }
php
{ "resource": "" }
q260681
DatabaseManager.createDatabase
test
public function createDatabase($name) { try { Database::create($this->getConnection(), $name); return true; } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new DatabaseManagerException($normalised['message'], $normalised['code']); } }
php
{ "resource": "" }
q260682
DatabaseManager.deleteDatabase
test
public function deleteDatabase($name) { try { Database::delete($this->getConnection(), $name); return true; } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new DatabaseManagerException($normalised['message'], $normalised['code']); } }
php
{ "resource": "" }
q260683
DatabaseManager.getDatabaseInfo
test
public function getDatabaseInfo($name) { try { $connection = $this->getConnection($name); $info = Database::getInfo($connection); $result = array(); $result['id'] = $info['result']['id']; $result['name'] = $info['result']['name']; $result['path'] = $info['result']['path']; $result['isSystem'] = $info['result']['isSystem']; return $result; } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new DatabaseManagerException($normalised['message'], $normalised['code']); } }
php
{ "resource": "" }
q260684
DatabaseManager.listDatabases
test
public function listDatabases() { try { $connection = $this->getConnection(); $result = Database::listDatabases($connection); if (empty($result['result'])) { return array(); } else { return $result['result']; } } catch (\Exception $e) { $normalised = $this->_toolbox->normaliseDriverExceptions($e); throw new DatabaseManagerException($normalised['message'], $normalised['code']); } }
php
{ "resource": "" }
q260685
DatabaseManager.getConnection
test
private function getConnection($database = '_system') { $connection = clone $this->_toolbox->getConnection(); $connection->setDatabase($database); return $connection; }
php
{ "resource": "" }
q260686
Client.useConnection
test
public function useConnection($name) { if (!array_key_exists($name, $this->_toolboxes)) { throw new ClientException("The connection ($name) you are trying to use is not registered with the client."); } $this->_currentConnection = $name; }
php
{ "resource": "" }
q260687
Client.getToolbox
test
public function getToolbox($name = 'default') { if (!array_key_exists($name, $this->_toolboxes)) { throw new ClientException("The toolbox for connection ($name) does not exist! Is the connection added to the client?"); } return $this->_toolboxes[$name]; }
php
{ "resource": "" }
q260688
Client.setModelFormatter
test
public function setModelFormatter(IModelFormatter $formatter) { $this->_modelFormatter = $formatter; foreach ($this->_toolboxes as $toolbox) { $toolbox->setModelFormatter($formatter); } }
php
{ "resource": "" }
q260689
Client.load
test
public function load($collection, $id) { return $this->getToolbox($this->_currentConnection)->getPodManager()->load($collection, $id); }
php
{ "resource": "" }
q260690
Client.createGraph
test
public function createGraph($name) { $toolbox = $this->getToolbox($this->_currentConnection); $toolbox->getGraphManager()->createGraph($name); $this->addConnection($name, $toolbox->getEndpoint(), array('username' => $toolbox->getUsername(), 'password' => $toolbox->getPassword(), 'graph' => $name, 'database' => $toolbox->getDatabase())); return true; }
php
{ "resource": "" }
q260691
Client.renameCollection
test
public function renameCollection($collection, $newName) { return $this->getToolbox($this->_currentConnection)->getCollectionManager()->renameCollection($collection, $newName); }
php
{ "resource": "" }
q260692
Client.getIndexInfo
test
public function getIndexInfo($collection, $indexId) { return $this->getToolbox($this->_currentConnection)->getCollectionManager()->getIndexInfo($collection, $indexId); }
php
{ "resource": "" }
q260693
PodManager.load
test
public function load($type, $id) { $driver = $this->_toolbox->getDriver(); try { if ($this->_toolbox->isGraph()) { switch (strtolower($type)) { case "vertex": if ($this->hasTransaction()) { $this->_toolbox->getTransactionManager()->addReadCollection($this->_toolbox->getVertexCollectionName()); $this->addTransactionCommand("function () {var temp = graph.getVertex('$id'); return temp ? temp._properties : null}();", "PodManager:load", null, true, array('type' => $type)); } else { $vertex = $driver->getVertex($this->_toolbox->getGraph(), $id); return $this->convertDriverDocumentToPod($vertex); } break; case "edge": if ($this->hasTransaction()) { $this->_toolbox->getTransactionManager()->addReadCollection($this->_toolbox->getEdgeCollectionName()); $this->addTransactionCommand("graph.getEdge('$id')._properties;", "PodManager:load", null, true, array('type' => $type)); } else { $edge = $driver->getEdge($this->_toolbox->getGraph(), $id); return $this->convertDriverDocumentToPod($edge); } break; default: throw new PodManagerException("For graphs, only the types 'vertex' and 'edge' can be loaded."); } } else { if ($this->hasTransaction()) { $this->_toolbox->getTransactionManager()->addReadCollection($type); $this->addTransactionCommand("db.$type.document('$id');", "PodManager:load", null, false, array('type' => $type)); } else { $document = $driver->getById($type, $id); return $this->convertDriverDocumentToPod($document); } } } catch (\Exception $e) { //Rethrow the exception from the try block if ($e instanceof PodManagerException) { throw $e; //Otherwise just return a null if the pod does not exist, or if there is an error. } else { return null; } } }
php
{ "resource": "" }
q260694
PodManager.processStoreResult
test
public function processStoreResult($pod, $revision, $id = null) { $pod->setSaved(); $pod->setRevision($revision); if ($id && $pod->getId() === null) { $pod->setId($id); } //Signal here $this->notify("after_store", $pod); return $pod->getKey(); }
php
{ "resource": "" }
q260695
PodManager.convertToPods
test
public function convertToPods($type, array $documents) { $result = array(); foreach ($documents as $document) { if ($document instanceof \triagens\ArangoDb\Document) { $model = $this->convertDriverDocumentToPod($document); $result[$document->getInternalId()] = $model; } else { $model = $this->convertArrayToPod($type, $document); if (isset($document['_id'])) { $result[$document['_id']] = $model; } else { $result[] = $model; } } } return $result; }
php
{ "resource": "" }
q260696
PodManager.convertArrayToPod
test
public function convertArrayToPod($type, array $data) { $model = $this->dispense($type); $pod = $model->getPod(); $pod->loadFromArray($data); //Signal here $this->notify("after_open", $model->getPod()); return $model; }
php
{ "resource": "" }
q260697
PodManager.convertDriverDocumentToPod
test
public function convertDriverDocumentToPod(\triagens\ArangoDb\Document $driverDocument) { switch ($driverDocument) { case $driverDocument instanceof \triagens\ArangoDb\Vertex: $model = $this->dispense("vertex"); break; case $driverDocument instanceof \triagens\ArangoDb\Edge: $model = $this->dispense("edge"); break; default: @list($collection,) = explode('/', $driverDocument->getInternalId(), 2); $model = $this->dispense($collection); } $model->getPod()->loadFromDriver($driverDocument); $model->getPod()->setSaved(); //Signal here $this->notify("after_open", $model->getPod()); return $model; }
php
{ "resource": "" }
q260698
PodManager.createVertex
test
private function createVertex(array $data = array(), $new = true) { $vertex = new Vertex($this->_toolbox, $data, $new); $this->attachEventsToPod($vertex); return $this->setupModel($vertex, $vertex); }
php
{ "resource": "" }
q260699
PodManager.createEdge
test
private function createEdge(array $data = array(), $new = true) { $edge = new Edge($this->_toolbox, $data, $new); $this->attachEventsToPod($edge); return $this->setupModel($edge, $edge); }
php
{ "resource": "" }