_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259300
Logger.getConfigurator
test
private static function getConfigurator($configurator = null) { if ($configurator === null) { return new LoggerConfiguratorDefault(); } if (is_object($configurator)) { if ($configurator instanceof LoggerConfigurator) { return $configurator; } else { trigger_error("log4php: Given configurator object [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new LoggerConfiguratorDefault(); } } if (is_string($configurator)) { if (!class_exists($configurator)) { trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING); return new LoggerConfiguratorDefault(); } $instance = new $configurator(); if (!($instance instanceof LoggerConfigurator)) { trigger_error("log4php: Specified configurator class [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new LoggerConfiguratorDefault(); } return $instance; } trigger_error("log4php: Invalid configurator specified. Expected either a string or a LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING); return new LoggerConfiguratorDefault(); }
php
{ "resource": "" }
q259301
Recommendation.setRecordCount
test
public function setRecordCount($recordCount) { $parameters = $this->request->getParameters(); if (is_numeric($recordCount) && (int)$recordCount == (float)$recordCount // Is integer? && $recordCount > 0 ) { $parameters['maxResults'] = $recordCount; } else { unset($parameters['maxResults']); } // Make sure that the recommendations are fetched again. In theory, // we only have to do this when recordCount increases. $this->upToDate = false; }
php
{ "resource": "" }
q259302
Recommendation.addProductIDs
test
public function addProductIDs($productIDs) { $parameters = $this->request->getParameters(); $parameters->add('id', $productIDs); $this->upToDate = false; }
php
{ "resource": "" }
q259303
Recommendation.getRecommendations
test
public function getRecommendations() { if (is_null($this->recommendations) || !$this->upToDate ) { $this->request->resetLoaded(); $this->recommendations = $this->createRecommendations(); $this->upToDate = true; } return $this->recommendations; }
php
{ "resource": "" }
q259304
Tracking.trackClick
test
public function trackClick( $id, $query, $pos, $masterId = null, $sid = null, $cookieId = null, $origPos = -1, $page = 1, $simi = 100.0, $title = '', $pageSize = 12, $origPageSize = -1, $userId = null, $campaign = null, $instoreAds = false ) { $this->setupClickTracking($id, $query, $pos, $masterId, $sid, $cookieId, $origPos, $page, $simi, $title, $pageSize, $origPageSize, $userId, $campaign, $instoreAds); return $this->applyTracking(); }
php
{ "resource": "" }
q259305
Tracking.trackCart
test
public function trackCart( $id, $masterId = null, $title = '', $query = null, $sid = null, $cookieId = null, $count = 1, $price = null, $userId = null, $campaign = null, $instoreAds = false ) { $this->setupCartTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userId, $campaign, $instoreAds); return $this->applyTracking(); }
php
{ "resource": "" }
q259306
Tracking.trackCheckout
test
public function trackCheckout( $id, $masterId = null, $title = '', $query = null, $sid = null, $cookieId = null, $count = 1, $price = null, $userId = null, $campaign = null, $instoreAds = false ) { $this->setupCheckoutTracking($id, $masterId, $title, $query, $sid, $cookieId, $count, $price, $userId, $campaign, $instoreAds); return $this->applyTracking(); }
php
{ "resource": "" }
q259307
Tracking.trackRecommendationClick
test
public function trackRecommendationClick( $id, $mainId, $masterId = null, $sid = null, $cookieId = null, $userId = null ) { $this->setupRecommendationClickTracking($id, $mainId, $masterId, $sid, $cookieId, $userId); return $this->applyTracking(); }
php
{ "resource": "" }
q259308
Tracking.trackLogin
test
public function trackLogin( $sid = null, $cookieId = null, $userId = null ) { $this->setupLoginTracking($sid, $cookieId, $userId); return $this->applyTracking(); }
php
{ "resource": "" }
q259309
Compare.setProductIDs
test
public function setProductIDs($productIDs) { $parameters = $this->request->getParameters(); $parameters['ids'] = implode(';', $productIDs); $this->upToDate = false; }
php
{ "resource": "" }
q259310
Compare.getComparableAttributes
test
public function getComparableAttributes() { if (is_null($this->comparableAttributes) || !$this->upToDate ) { $this->comparableAttributes = $this->createComparableAttributes(); $this->upToDate = true; } return $this->comparableAttributes; }
php
{ "resource": "" }
q259311
Compare.getComparedRecords
test
public function getComparedRecords() { if (is_null($this->comparedRecords) || !$this->upToDate ) { $this->comparedRecords = $this->createComparedRecords(); $this->upToDate = true; } return $this->comparedRecords; }
php
{ "resource": "" }
q259312
LoggerPatternConverter.format
test
public function format(&$sbuf, $event) { $string = $this->convert($event); if (!isset($this->formattingInfo)) { $sbuf .= $string; return; } $fi = $this->formattingInfo; // Empty string if($string === '' || is_null($string)) { if($fi->min > 0) { $sbuf .= str_repeat(' ', $fi->min); } return; } $len = strlen($string); // Trim the string if needed if($len > $fi->max) { if ($fi->trimLeft) { $sbuf .= substr($string, $len - $fi->max, $fi->max); } else { $sbuf .= substr($string , 0, $fi->max); } } // Add padding if needed else if($len < $fi->min) { if($fi->padLeft) { $sbuf .= str_repeat(' ', $fi->min - $len); $sbuf .= $string; } else { $sbuf .= $string; $sbuf .= str_repeat(' ', $fi->min - $len); } } // No action needed else { $sbuf .= $string; } }
php
{ "resource": "" }
q259313
LoggerConfigurable.setBoolean
test
protected function setBoolean($property, $value) { try { $this->$property = LoggerOptionConverter::toBooleanEx($value); } catch (Exception $ex) { $value = var_export($value, true); $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed."); } }
php
{ "resource": "" }
q259314
LoggerConfigurable.setLevel
test
protected function setLevel($property, $value) { try { $this->$property = LoggerOptionConverter::toLevelEx($value); } catch (Exception $ex) { $value = var_export($value, true); $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed."); } }
php
{ "resource": "" }
q259315
LoggerConfigurable.setFileSize
test
protected function setFileSize($property, $value) { try { $this->$property = LoggerOptionConverter::toFileSizeEx($value); } catch (Exception $ex) { $value = var_export($value, true); $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed."); } }
php
{ "resource": "" }
q259316
LoggerConfigurable.setNumeric
test
protected function setNumeric($property, $value) { try { $this->$property = LoggerOptionConverter::toNumericEx($value); } catch (Exception $ex) { $value = var_export($value, true); $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed."); } }
php
{ "resource": "" }
q259317
LoggerConfigurable.setString
test
protected function setString($property, $value, $nullable = false) { if ($value === null) { if($nullable) { $this->$property= null; } else { $this->warn("Null value given for '$property' property. Expected a string. Property not changed."); } } else { try { $value = LoggerOptionConverter::toStringEx($value); $this->$property = LoggerOptionConverter::substConstants($value); } catch (Exception $ex) { $value = var_export($value, true); $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed."); } } }
php
{ "resource": "" }
q259318
LoggerLoggingEvent.getLocationInformation
test
public function getLocationInformation() { if($this->locationInfo === null) { $locationInfo = array(); $trace = debug_backtrace(); $prevHop = null; // make a downsearch to identify the caller $hop = array_pop($trace); while($hop !== null) { if(isset($hop['class'])) { // we are sometimes in functions = no class available: avoid php warning here $className = strtolower($hop['class']); if(!empty($className) and ($className == 'logger' or strtolower(get_parent_class($className)) == 'logger')) { $locationInfo['line'] = $hop['line']; $locationInfo['file'] = $hop['file']; break; } } $prevHop = $hop; $hop = array_pop($trace); } $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; if(isset($prevHop['function']) and $prevHop['function'] !== 'include' and $prevHop['function'] !== 'include_once' and $prevHop['function'] !== 'require' and $prevHop['function'] !== 'require_once') { $locationInfo['function'] = $prevHop['function']; } else { $locationInfo['function'] = 'main'; } $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn); } return $this->locationInfo; }
php
{ "resource": "" }
q259319
LoggerLoggingEvent.getStartTime
test
public static function getStartTime() { if(!isset(self::$startTime)) { self::$startTime = microtime(true); } return self::$startTime; }
php
{ "resource": "" }
q259320
LoggerLoggingEvent.getTime
test
public function getTime() { $eventTime = $this->getTimeStamp(); $eventStartTime = LoggerLoggingEvent::getStartTime(); return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); }
php
{ "resource": "" }
q259321
EasyCurlRequestFactory.getRequest
test
public function getRequest() { $connectionData = FF::getInstance( 'Core\Server\ConnectionData', clone $this->requestParameters ); return FF::getInstance('Core\Server\Request', $this->loggerClass, $connectionData, $this->dataProvider ); }
php
{ "resource": "" }
q259322
TagCloud.getTagCloud
test
public function getTagCloud($requestQuery = null) { if (is_null($this->tagCloud) || $requestQuery != $this->lastRequestQuery ) { $this->tagCloud = $this->createTagCloud($requestQuery); $this->lastRequestQuery = $requestQuery; } return $this->tagCloud; }
php
{ "resource": "" }
q259323
TagCloud.setWordCount
test
public function setWordCount($wordCount) { $parameters = $this->request->getParameters(); if (is_numeric($wordCount) && (int)$wordCount == (float)$wordCount // Is integer? && $wordCount > 0 ) { $parameters['wordCount'] = $wordCount; } else { unset($parameters['wordCount']); } // Make sure that the tag cloud is fetched again. In theory, we only // have to do this when wordCount increases. $this->tagCloud = null; }
php
{ "resource": "" }
q259324
Campaign.addFeedback
test
public function addFeedback(array $feedback) { foreach($feedback as $label => $text) $this->feedback[$label] = (string)$text; }
php
{ "resource": "" }
q259325
ProductCampaign.setProductNumbers
test
public function setProductNumbers($productNumbers) { $parameters = $this->request->getParameters(); $parameters['productNumber'] = $productNumbers; $this->upToDate = false; }
php
{ "resource": "" }
q259326
ProductCampaign.addProductNumbers
test
public function addProductNumbers($productNumbers) { $parameters = $this->request->getParameters(); $parameters->add('productNumber', $productNumbers); $this->upToDate = false; }
php
{ "resource": "" }
q259327
ProductCampaign.setPageId
test
public function setPageId($pageId) { $parameters = $this->request->getParameters(); $parameters->add('pageId', $pageId); $this->upToDate = false; }
php
{ "resource": "" }
q259328
ProductCampaign.makeProductCampaign
test
public function makeProductCampaign() { $this->isShoppingCartCampaign = false; $this->isLandingPageCampaign = false; $this->upToDate = false; $this->parameters['do'] = 'getProductCampaigns'; }
php
{ "resource": "" }
q259329
ProductCampaign.makeShoppingCartCampaign
test
public function makeShoppingCartCampaign() { $this->isShoppingCartCampaign = true; $this->isLandingPageCampaign = false; $this->upToDate = false; $this->parameters['do'] = 'getShoppingCartCampaigns'; }
php
{ "resource": "" }
q259330
ProductCampaign.getCampaigns
test
public function getCampaigns() { if (is_null($this->campaigns) || !$this->upToDate ) { $this->request->resetLoaded(); $this->campaigns = $this->createCampaigns(); $this->upToDate = true; } return $this->campaigns; }
php
{ "resource": "" }
q259331
ProductCampaign.getRawProductCampaigns
test
public function getRawProductCampaigns($format = null, $callback = null) { $this->usePassthroughResponseContentProcessor(); if (!is_null($format)) $this->parameters['format'] = $format; if (!is_null($callback)) $this->parameters['callback'] = $callback; return $this->getResponseContent(); }
php
{ "resource": "" }
q259332
LoggerPatternParser.addConverter
test
private function addConverter($word, $modifiers, $option) { $formattingInfo = $this->parseModifiers($modifiers); $option = trim($option, "{} "); if (isset($this->converterMap[$word])) { $converter = $this->getConverter($word, $formattingInfo, $option); $this->addToChain($converter); } else { trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING); } }
php
{ "resource": "" }
q259333
LoggerPatternParser.getConverter
test
private function getConverter($word, $info, $option) { if (!isset($this->converterMap[$word])) { throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword."); } $converterClass = $this->converterMap[$word]; if(!class_exists($converterClass)) { throw new LoggerException("Class '$converterClass' does not exist."); } $converter = new $converterClass($info, $option); if(!($converter instanceof LoggerPatternConverter)) { throw new LoggerException("Class '$converterClass' is not an instance of LoggerPatternConverter."); } return $converter; }
php
{ "resource": "" }
q259334
LoggerPatternParser.parseModifiers
test
private function parseModifiers($modifiers) { $info = new LoggerFormattingInfo(); // If no modifiers are given, return default values if (empty($modifiers)) { return $info; } // Validate $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/'; if (!preg_match($pattern, $modifiers)) { trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING); return $info; } $parts = explode('.', $modifiers); if (!empty($parts[0])) { $minPart = (integer) $parts[0]; $info->min = abs($minPart); $info->padLeft = ($minPart > 0); } if (!empty($parts[1])) { $maxPart = (integer) $parts[1]; $info->max = abs($maxPart); $info->trimLeft = ($maxPart < 0); } return $info; }
php
{ "resource": "" }
q259335
LoggerRoot.setLevel
test
public function setLevel(LoggerLevel $level = null) { if (isset($level)) { parent::setLevel($level); } else { trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING); } }
php
{ "resource": "" }
q259336
LoggerRendererMap.addRenderer
test
public function addRenderer($renderedClass, $renderingClass) { // Check the rendering class exists if (!class_exists($renderingClass)) { trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof LoggerRenderer)) { trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface."); return; } // Convert to lowercase since class names in PHP are not case sensitive $renderedClass = strtolower($renderedClass); $this->map[$renderedClass] = $renderer; }
php
{ "resource": "" }
q259337
LoggerRendererMap.setDefaultRenderer
test
public function setDefaultRenderer($renderingClass) { // Check the class exists if (!class_exists($renderingClass)) { trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found."); return; } // Create the instance $renderer = new $renderingClass(); // Check the class implements the right interface if (!($renderer instanceof LoggerRenderer)) { trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface."); return; } $this->defaultRenderer = $renderer; }
php
{ "resource": "" }
q259338
LoggerRendererMap.getByClassName
test
public function getByClassName($class) { for(; !empty($class); $class = get_parent_class($class)) { $class = strtolower($class); if(isset($this->map[$class])) { return $this->map[$class]; } } return null; }
php
{ "resource": "" }
q259339
AbstractConfiguration.getWhitelistServerParameters
test
public function getWhitelistServerParameters() { return array( '/^filter.*/' => true, '/^sort.*/' => true, '/^substringFilter.*/' => true, 'advisorStatus' => true, 'callback' => true, 'campaign' => true, 'catalog' => true, 'channel' => true, 'cookieId' => true, 'count' => true, 'do' => true, 'event' => true, 'followSearch' => true, 'format' => true, 'id' => true, 'ids' => true, 'idsOnly' => true, 'ignoreForCache' => true, 'instoreAds' => true, 'isArticleNumber' => true, 'log' => true, 'mainId' => true, 'masterId' => true, 'maxRecordCount' => true, 'maxResults' => true, 'navigation' => true, 'noArticleNumberSearch' => true, 'omitContextName' => true, 'origPageSize' => true, 'origPos' => true, 'page' => true, 'pageId' => true, 'pageSize' => true, 'pos' => true, 'price' => true, 'productNumber' => true, 'productsPerPage' => true, 'query' => true, 'queryFromSuggest' => true, 'searchField' => true, 'seoPath' => true, 'sid' => true, 'simi' => true, 'title' => true, 'useAsn' => true, 'useAso' => true, 'useCampaigns' => true, 'useFoundWords' => true, 'useKeywords' => true, 'usePersonalization' => true, 'userId' => true, 'userInput' => true, 'useSemanticEnhancer' => true, 'verbose' => true, 'wordCount' => true ); }
php
{ "resource": "" }
q259340
LoggerConfigurationAdapterINI.load
test
private function load($url) { if (!file_exists($url)) { throw new LoggerException("File [$url] does not exist."); } $properties = @parse_ini_file($url, true); if ($properties === false) { $error = error_get_last(); throw new LoggerException("Error parsing configuration file: {$error['message']}"); } return $properties; }
php
{ "resource": "" }
q259341
LoggerConfigurationAdapterINI.convert
test
public function convert($path) { // Load the configuration $properties = $this->load($path); // Parse threshold if (isset($properties[self::THRESHOLD_PREFIX])) { $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX]; } // Parse root logger if (isset($properties[self::ROOT_LOGGER_PREFIX])) { $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME); } $appenders = array(); foreach($properties as $key => $value) { // Parse loggers if ($this->beginsWith($key, self::LOGGER_PREFIX)) { $name = substr($key, strlen(self::LOGGER_PREFIX)); $this->parseLogger($value, $name); } // Parse additivity if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) { $name = substr($key, strlen(self::ADDITIVITY_PREFIX)); $this->config['loggers'][$name]['additivity'] = $value; } // Parse appenders else if ($this->beginsWith($key, self::APPENDER_PREFIX)) { $this->parseAppender($key, $value); } // Parse renderers else if ($this->beginsWith($key, self::RENDERER_PREFIX)) { $this->parseRenderer($key, $value); } } return $this->config; }
php
{ "resource": "" }
q259342
LoggerConfigurationAdapterINI.parseLogger
test
private function parseLogger($value, $name) { // Value is divided by commas $parts = explode(',', $value); if (empty($value) || empty($parts)) { return; } // The first value is the logger level $level = array_shift($parts); // The remaining values are appender references $appenders = array(); while($appender = array_shift($parts)) { $appender = trim($appender); if (!empty($appender)) { $appenders[] = trim($appender); } } // Find the target configuration if ($name == self::ROOT_LOGGER_NAME) { $this->config['rootLogger']['level'] = trim($level); $this->config['rootLogger']['appenders'] = $appenders; } else { $this->config['loggers'][$name]['level'] = trim($level); $this->config['loggers'][$name]['appenders'] = $appenders; } }
php
{ "resource": "" }
q259343
LoggerConfigurationAdapterINI.parseAppender
test
private function parseAppender($key, $value) { // Remove the appender prefix from key $subKey = substr($key, strlen(self::APPENDER_PREFIX)); // Divide the string by dots $parts = explode('.', $subKey); $count = count($parts); // The first part is always the appender name $name = trim($parts[0]); // Only one part - this line defines the appender class if ($count == 1) { $this->config['appenders'][$name]['class'] = $value; return; } // Two parts - either a parameter, a threshold or layout class else if ($count == 2) { if ($parts[1] == 'layout') { $this->config['appenders'][$name]['layout']['class'] = $value; return; } else if ($parts[1] == 'threshold') { $this->config['appenders'][$name]['threshold'] = $value; return; } else { $this->config['appenders'][$name]['params'][$parts[1]] = $value; return; } } // Three parts - this can only be a layout parameter else if ($count == 3) { if ($parts[1] == 'layout') { $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value; return; } } trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping."); }
php
{ "resource": "" }
q259344
LoggerConfigurationAdapterINI.parseRenderer
test
private function parseRenderer($key, $value) { // Remove the appender prefix from key $renderedClass = substr($key, strlen(self::APPENDER_PREFIX)); $renderingClass = $value; $this->config['renderers'][] = compact('renderedClass', 'renderingClass'); }
php
{ "resource": "" }
q259345
LoggerAppenderSyslog.append
test
public function append(LoggerLoggingEvent $event) { $priority = $this->getSyslogPriority($event->getLevel()); $message = $this->layout->format($event); openlog($this->ident, $this->intOption, $this->intFacility); syslog($priority, $message); closelog(); }
php
{ "resource": "" }
q259346
LoggerAppenderSyslog.parseOption
test
private function parseOption() { $value = 0; $options = explode('|', $this->option); foreach($options as $option) { if (!empty($option)) { $constant = "LOG_" . trim($option); if (defined($constant)) { $value |= constant($constant); } else { trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); } } } return $value; }
php
{ "resource": "" }
q259347
LoggerAppenderSyslog.parseFacility
test
private function parseFacility() { if (!empty($this->facility)) { $constant = "LOG_" . trim($this->facility); if (defined($constant)) { return constant($constant); } else { trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); } } }
php
{ "resource": "" }
q259348
LoggerAppenderSyslog.parsePriority
test
private function parsePriority() { if (!empty($this->priority)) { $constant = "LOG_" . trim($this->priority); if (defined($constant)) { return constant($constant); } else { trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); } } }
php
{ "resource": "" }
q259349
LoggerAppenderMongoDB.append
test
public function append(LoggerLoggingEvent $event) { try { if ($this->collection != null) { $this->collection->insert($this->format($event)); } } catch (MongoCursorException $ex) { $this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage())); } }
php
{ "resource": "" }
q259350
LoggerAppenderMongoDB.formatThrowable
test
protected function formatThrowable(Exception $ex) { $array = array( 'message' => $ex->getMessage(), 'code' => $ex->getCode(), 'stackTrace' => $ex->getTraceAsString(), ); if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) { $array['innerException'] = $this->formatThrowable($ex->getPrevious()); } return $array; }
php
{ "resource": "" }
q259351
LoggerAppenderMongoDB.close
test
public function close() { if($this->closed != true) { $this->collection = null; if ($this->connection !== null) { $this->connection->close(); $this->connection = null; } $this->closed = true; } }
php
{ "resource": "" }
q259352
LoggerConfiguratorDefault.configure
test
public function configure(LoggerHierarchy $hierarchy, $input = null) { $config = $this->parse($input); $this->doConfigure($hierarchy, $config); }
php
{ "resource": "" }
q259353
LoggerConfiguratorDefault.createAppenderLayout
test
private function createAppenderLayout(LoggerAppender $appender, $config) { $name = $appender->getName(); $class = $config['class']; if (empty($class)) { $this->warn("Layout class not specified for appender [$name]. Reverting to default layout."); return; } if (!class_exists($class)) { $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout."); return; } $layout = new $class(); if (!($layout instanceof LoggerLayout)) { $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout."); return; } if (isset($config['params'])) { $this->setOptions($layout, $config['params']); } $layout->activateOptions(); $appender->setLayout($layout); }
php
{ "resource": "" }
q259354
ConfigurableResponse.setIdsOnly
test
public function setIdsOnly($idsOnly) { if($this->idsOnly && !$idsOnly) $this->upToDate = false; $this->idsOnly = $idsOnly; $parameters = $this->request->getParameters(); $parameters['idsOnly'] = $idsOnly ? 'true' : 'false'; }
php
{ "resource": "" }
q259355
Search.getFollowSearchValue
test
public function getFollowSearchValue() { $jsonData = $this->getResponseContent(); //use searchParams of result if available if ($this->isValidResponse($jsonData) && isset($jsonData['searchResult']['searchParams'])) { $parameters = FF::getInstance( 'Util\Parameters', $jsonData['searchResult']['searchParams'] ); //fallback to current request } else { $parameters = $this->parameters; } $searchParameters = FF::getInstance( 'Data\SearchParameters', $parameters ); $sorting = $searchParameters->getSortings(); // check if followSearch was set in request data or sent by FF in result searchParams if($searchParameters->getFollowSearch() !== 0) { $followSearch = $searchParameters->getFollowSearch(); // use simiFirstRecord only if result was not sorted } elseif (empty($sorting)) { $jsonData = $this->getResponseContent(); if($jsonData && $jsonData['searchResult'] && isset($jsonData['searchResult']['simiFirstRecord'])) $followSearch = $jsonData['searchResult']['simiFirstRecord']; //mark as not valid } else { $followSearch = 0; } return $followSearch; }
php
{ "resource": "" }
q259356
LoggerFilter.addNext
test
public function addNext($filter) { if($this->next !== null) { $this->next->addNext($filter); } else { $this->next = $filter; } }
php
{ "resource": "" }
q259357
ConnectionData.setResponse
test
public function setResponse(Response $response, $url) { $this->response = $response; $this->previousUrl = $url; }
php
{ "resource": "" }
q259358
PersonalisedResponse.setSid
test
public function setSid($sessionId) { if (strcmp($sessionId, $this->sid) !== 0) { $this->sid = $sessionId; $this->parameters['sid'] = $this->sid; $this->upToDate = false; } }
php
{ "resource": "" }
q259359
LoggerLevel.equals
test
public function equals($other) { if($other instanceof LoggerLevel) { if($this->level == $other->level) { return true; } } else { return false; } }
php
{ "resource": "" }
q259360
LoggerLevel.getLevelOff
test
public static function getLevelOff() { if(!isset(self::$levelMap[LoggerLevel::OFF])) { self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', LOG_ALERT); } return self::$levelMap[LoggerLevel::OFF]; }
php
{ "resource": "" }
q259361
LoggerLevel.getLevelFatal
test
public static function getLevelFatal() { if(!isset(self::$levelMap[LoggerLevel::FATAL])) { self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', LOG_ALERT); } return self::$levelMap[LoggerLevel::FATAL]; }
php
{ "resource": "" }
q259362
LoggerLevel.getLevelError
test
public static function getLevelError() { if(!isset(self::$levelMap[LoggerLevel::ERROR])) { self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', LOG_ERR); } return self::$levelMap[LoggerLevel::ERROR]; }
php
{ "resource": "" }
q259363
LoggerLevel.getLevelWarn
test
public static function getLevelWarn() { if(!isset(self::$levelMap[LoggerLevel::WARN])) { self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', LOG_WARNING); } return self::$levelMap[LoggerLevel::WARN]; }
php
{ "resource": "" }
q259364
LoggerLevel.getLevelInfo
test
public static function getLevelInfo() { if(!isset(self::$levelMap[LoggerLevel::INFO])) { self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', LOG_INFO); } return self::$levelMap[LoggerLevel::INFO]; }
php
{ "resource": "" }
q259365
LoggerLevel.getLevelDebug
test
public static function getLevelDebug() { if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG); } return self::$levelMap[LoggerLevel::DEBUG]; }
php
{ "resource": "" }
q259366
LoggerLevel.getLevelTrace
test
public static function getLevelTrace() { if(!isset(self::$levelMap[LoggerLevel::TRACE])) { self::$levelMap[LoggerLevel::TRACE] = new LoggerLevel(LoggerLevel::TRACE, 'TRACE', LOG_DEBUG); } return self::$levelMap[LoggerLevel::TRACE]; }
php
{ "resource": "" }
q259367
LoggerLevel.getLevelAll
test
public static function getLevelAll() { if(!isset(self::$levelMap[LoggerLevel::ALL])) { self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', LOG_DEBUG); } return self::$levelMap[LoggerLevel::ALL]; }
php
{ "resource": "" }
q259368
LoggerLevel.toLevel
test
public static function toLevel($arg, $defaultLevel = null) { if(is_int($arg)) { switch($arg) { case self::ALL: return self::getLevelAll(); case self::TRACE: return self::getLevelTrace(); case self::DEBUG: return self::getLevelDebug(); case self::INFO: return self::getLevelInfo(); case self::WARN: return self::getLevelWarn(); case self::ERROR: return self::getLevelError(); case self::FATAL: return self::getLevelFatal(); case self::OFF: return self::getLevelOff(); default: return $defaultLevel; } } else { switch(strtoupper($arg)) { case 'ALL': return self::getLevelAll(); case 'TRACE': return self::getLevelTrace(); case 'DEBUG': return self::getLevelDebug(); case 'INFO': return self::getLevelInfo(); case 'WARN': return self::getLevelWarn(); case 'ERROR': return self::getLevelError(); case 'FATAL': return self::getLevelFatal(); case 'OFF': return self::getLevelOff(); default: return $defaultLevel; } } }
php
{ "resource": "" }
q259369
LoggerOptionConverter.getSystemProperty
test
public static function getSystemProperty($key, $def) { if(defined($key)) { return (string)constant($key); } else if(isset($_SERVER[$key])) { return (string)$_SERVER[$key]; } else if(isset($_ENV[$key])) { return (string)$_ENV[$key]; } else { return $def; } }
php
{ "resource": "" }
q259370
LoggerOptionConverter.toLevelEx
test
public static function toLevelEx($value) { if ($value instanceof LoggerLevel) { return $value; } $level = LoggerLevel::toLevel($value); if ($level === null) { throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level."); } return $level; }
php
{ "resource": "" }
q259371
LoggerOptionConverter.toStringEx
test
public static function toStringEx($value) { if (is_string($value)) { return $value; } if (is_numeric($value)) { return (string) $value; } if (is_object($value) && method_exists($value, '__toString')) { return (string) $value; } throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string."); }
php
{ "resource": "" }
q259372
LoggerOptionConverter.substConstants
test
public static function substConstants($string) { preg_match_all('/\${([^}]+)}/', $string, $matches); foreach($matches[1] as $key => $match) { $match = trim($match); $search = $matches[0][$key]; $replacement = defined($match) ? constant($match) : ''; $string = str_replace($search, $replacement, $string); } return $string; }
php
{ "resource": "" }
q259373
LoggerHierarchy.getLogger
test
public function getLogger($name) { if(!isset($this->loggers[$name])) { $logger = new Logger($name); $nodes = explode('.', $name); $firstNode = array_shift($nodes); // if name is not a first node but another first node is their if($firstNode != $name and isset($this->loggers[$firstNode])) { $logger->setParent($this->loggers[$firstNode]); } else { // if there is no father, set root logger as father $logger->setParent($this->root); } // if there are more nodes than one if(count($nodes) > 0) { // find parent node foreach($nodes as $node) { $parentNode = "$firstNode.$node"; if(isset($this->loggers[$parentNode]) and $parentNode != $name) { $logger->setParent($this->loggers[$parentNode]); } $firstNode .= ".$node"; } } $this->loggers[$name] = $logger; } return $this->loggers[$name]; }
php
{ "resource": "" }
q259374
RequestParser.getRequestTarget
test
public function getRequestTarget() { if ($this->requestTarget === null) { // Workaround for some servers (IIS) which do not provide // $_SERVER['REQUEST_URI']. Taken from // http://php.net/manual/en/reserved.variables.server.php#108186 if(!isset($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; if(isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } if (strpos($_SERVER['REQUEST_URI'], '?') === false) $this->requestTarget = $_SERVER['REQUEST_URI']; else { $parts = explode('?', $_SERVER['REQUEST_URI']); $this->requestTarget = $parts[0]; } $seoPathPosition = strrpos($this->requestTarget , "/s/"); if ($seoPathPosition > -1) { $this->requestTarget = substr($this->requestTarget , 0, $seoPathPosition); } // Use rawurldecode() so that +'s are not converted to spaces. $this->requestTarget = rawurldecode($this->requestTarget); if ($this->encodingConverter != null) { $this->requestTarget = $this->encodingConverter ->decodeClientUrlData($this->requestTarget); } } return $this->requestTarget; }
php
{ "resource": "" }
q259375
LoggerLayoutPattern.activateOptions
test
public function activateOptions() { if (!isset($this->pattern)) { throw new LoggerException("Mandatory parameter 'conversionPattern' is not set."); } $parser = new LoggerPatternParser($this->pattern, $this->converterMap); $this->head = $parser->parse(); }
php
{ "resource": "" }
q259376
LoggerLayoutPattern.format
test
public function format(LoggerLoggingEvent $event) { $sbuf = ''; $converter = $this->head; while ($converter !== null) { $converter->format($sbuf, $event); $converter = $converter->next; } return $sbuf; }
php
{ "resource": "" }
q259377
LoggerAppender.addFilter
test
public function addFilter($filter) { if($this->filter === null) { $this->filter = $filter; } else { $this->filter->addNext($filter); } }
php
{ "resource": "" }
q259378
LoggerAppender.isAsSevereAsThreshold
test
public function isAsSevereAsThreshold($level) { if($this->threshold === null) { return true; } return $level->isGreaterOrEqual($this->getThreshold()); }
php
{ "resource": "" }
q259379
LoggerAppender.warn
test
protected function warn($message) { $id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}"); trigger_error("log4php: [$id]: $message", E_USER_WARNING); }
php
{ "resource": "" }
q259380
Suggest.getSuggestions
test
public function getSuggestions() { if (is_null($this->suggestions)) $this->suggestions = $this->createSuggestions(); return $this->suggestions; }
php
{ "resource": "" }
q259381
Loader.getClassName
test
public static function getClassName($name) { $name = trim(preg_replace('/^FACTFinder\\\\/i', '', $name)); // check whether there is a custom or lib-unrelated class $customClassName = 'FACTFinder\Custom\\' . $name; $factfinderClassName = 'FACTFinder\\' . $name; $defaultClassName = $name; if (self::$loadCustomClasses && class_exists($customClassName)) $className = $customClassName; else if (class_exists($factfinderClassName)) $className = $factfinderClassName; else if (class_exists($defaultClassName)) $className = $defaultClassName; else throw new \Exception("class '$factfinderClassName' not found"); return $className; }
php
{ "resource": "" }
q259382
LoggerAppenderRollingFile.rollOver
test
private function rollOver() { // If maxBackups <= 0, then there is no file renaming to be done. if($this->maxBackupIndex > 0) { // Delete the oldest file, to keep Windows happy. $file = $this->file . '.' . $this->maxBackupIndex; if (file_exists($file) && !unlink($file)) { throw new LoggerException("Unable to delete oldest backup file from [$file]."); } // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} $this->renameArchievedLogs($this->file); // Backup the active file $this->moveToBackup($this->file); } // Truncate the active file ftruncate($this->fp, 0); rewind($this->fp); }
php
{ "resource": "" }
q259383
LoggerAppenderPDO.activateOptions
test
public function activateOptions() { try { $this->establishConnection(); } catch (PDOException $e) { $this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage()); $this->close(); return; } // Parse the insert patterns; pattern parts are comma delimited $pieces = explode(',', $this->insertPattern); $converterMap = LoggerLayoutPattern::getDefaultConverterMap(); foreach($pieces as $pattern) { $parser = new LoggerPatternParser($pattern, $converterMap); $this->converters[] = $parser->parse(); } $this->closed = false; }
php
{ "resource": "" }
q259384
LoggerAppenderPDO.append
test
public function append(LoggerLoggingEvent $event) { for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) { try { // Attempt to write to database $this->preparedInsert->execute($this->format($event)); $this->preparedInsert->closeCursor(); break; } catch (PDOException $e) { $this->warn("Failed writing to database: ". $e->getMessage()); // Close the appender if it's the last attempt if ($attempt > $this->reconnectAttempts) { $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender."); $this->close(); // Otherwise reconnect and try to write again } else { $this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts})."); $this->establishConnection(); } } } }
php
{ "resource": "" }
q259385
LoggerAppenderPDO.format
test
protected function format(LoggerLoggingEvent $event) { $params = array(); foreach($this->converters as $converter) { $buffer = ''; while ($converter !== null) { $converter->format($buffer, $event); $converter = $converter->next; } $params[] = $buffer; } return $params; }
php
{ "resource": "" }
q259386
UrlBuilder.generateUrl
test
public function generateUrl($parameters, $target = null) { $parameters = $this->parametersConverter ->convertServerToClientParameters($parameters); $parameters = $this->encodingConverter != null ? $this->encodingConverter->encodeClientUrlData($parameters) : $parameters; if (!is_string($target)) $target = $this->requestParser->getRequestTarget(); if ($parameters->offsetExists('seoPath')) { $seoPath = $parameters['seoPath']; $parameters->offsetUnset('seoPath'); $seoPathPosition = strrpos($target, "/s/"); if ($seoPathPosition > -1) { $target = substr($target, 0, $seoPathPosition); } $url = rtrim($target, '/') . '/s' . urldecode($seoPath) . '?' . $parameters->toPhpQueryString(); } else { $url = $target . '?' . $parameters->toPhpQueryString(); } return $url; }
php
{ "resource": "" }
q259387
CampaignIterator.getFeedback
test
public function getFeedback($label) { $feedback = array(); foreach ($this as $campaign) if ($campaign->hasFeedback($label)) $feedback[] = $campaign->getFeedback($label); return implode(PHP_EOL, $feedback); }
php
{ "resource": "" }
q259388
CampaignIterator.getPushedProducts
test
public function getPushedProducts() { $pushedProducts = array(); foreach ($this as $campaign) if ($campaign->hasPushedProducts()) foreach ($campaign->getPushedProducts() as $product) $pushedProducts[] = $product; return $pushedProducts; }
php
{ "resource": "" }
q259389
CampaignIterator.getActiveQuestions
test
public function getActiveQuestions() { $activeQuestions = array(); foreach ($this as $campaign) if ($campaign->hasActiveQuestions()) foreach ($campaign->getActiveQuestions() as $question) $activeQuestions[] = $question; return $activeQuestions; }
php
{ "resource": "" }
q259390
CampaignIterator.getAdvisorTree
test
public function getAdvisorTree() { $advisorTree = array(); foreach ($this as $campaign) if ($campaign->hasAdvisorTree()) foreach ($campaign->getAdvisorTree() as $question) $advisorTree[] = $question; return $advisorTree; }
php
{ "resource": "" }
q259391
LoggerAppenderDailyFile.activateOptions
test
public function activateOptions() { parent::activateOptions(); if (empty($this->datePattern)) { $this->warn("Required parameter 'datePattern' not set. Closing appender."); $this->closed = true; return; } }
php
{ "resource": "" }
q259392
LoggerAppenderDailyFile.append
test
public function append(LoggerLoggingEvent $event) { $eventDate = $this->getDate($event->getTimestamp()); // Initial setting of current date if (!isset($this->currentDate)) { $this->currentDate = $eventDate; } // Check if rollover is needed else if ($this->currentDate !== $eventDate) { $this->currentDate = $eventDate; // Close the file if it's open. // Note: $this->close() is not called here because it would set // $this->closed to true and the appender would not recieve // any more logging requests if (is_resource($this->fp)) { $this->write($this->layout->getFooter()); fclose($this->fp); } $this->fp = null; } parent::append($event); }
php
{ "resource": "" }
q259393
PermissionProvider.findById
test
public function findById($id) { if(!$permission = $this->createModel()->newQuery()->find($id)) { throw new PermissionNotFoundException("A permission could not be found with ID [$id]."); } return $permission; }
php
{ "resource": "" }
q259394
PermissionProvider.findByValue
test
public function findByValue($value) { if(!$permission = $this->createModel()->newQuery()->where('value', '=', $value)->get()->first()) { throw new PermissionNotFoundException("A permission could not be found with Value [$value]."); } return $permission; }
php
{ "resource": "" }
q259395
Breadcrumbs.renderItem
test
public static function renderItem($item, $active) { $class = ""; if($active === true) { $class = "current"; } $html = '<a href="'.URL::to($item["link"]).'" class="tip-bottom '.$class.'">'; if($item["icon"] !== '') { $html .= '<i class="glyphicon '.$item["icon"].'"></i>'; } $html .= $item["title"].'</a>'; return $html; }
php
{ "resource": "" }
q259396
BaseController.setupLayout
test
protected function setupLayout() { $this->layout = View::make(Config::get('syntara::views.master')); $this->layout->title = 'Syntara - Dashboard'; $this->layout->breadcrumb = array(); }
php
{ "resource": "" }
q259397
UserController.getIndex
test
public function getIndex() { // get alls users $emptyUsers = Sentry::getUserProvider()->getEmptyUser(); // users search $userId = Input::get('userIdSearch'); if(!empty($userId)) { $emptyUsers = $emptyUsers->where('users.id', $userId); } $username = Input::get('usernameSearch'); if(!empty($username)) { $emptyUsers = $emptyUsers->where('username', 'LIKE', '%'.$username.'%'); } $firstName = Input::get('firstNameSearch'); if(!empty($firstName)) { $emptyUsers = $emptyUsers->where('first_name', 'LIKE', '%'.$firstName.'%'); } $lastName = Input::get('lastNameSearch'); if(!empty($lastName)) { $emptyUsers = $emptyUsers->where('last_name', 'LIKE', '%'.$lastName.'%'); } $email = Input::get('emailSearch'); if(!empty($email)) { $emptyUsers = $emptyUsers->where('email', 'LIKE', '%'.$email.'%'); } $bannedUsers = Input::get('bannedSearch'); if(isset($bannedUsers) && $bannedUsers !== "") { $emptyUsers = $emptyUsers->join('throttle', 'throttle.user_id', '=', 'users.id') ->where('throttle.banned', '=', $bannedUsers) ->select('users.id', 'users.username', 'users.last_name', 'users.first_name', 'users.email', 'users.permissions', 'users.activated'); } $emptyUsers->distinct(); $users = $emptyUsers->paginate(Config::get('syntara::config.item-perge-page')); $datas['links'] = $users->links(); $datas['users'] = $users; // ajax request : reload only content container if(Request::ajax()) { $html = View::make(Config::get('syntara::views.users-list'), array('datas' => $datas))->render(); return Response::json(array('html' => $html)); } $this->layout = View::make(Config::get('syntara::views.users-index'), array('datas' => $datas)); $this->layout->title = trans('syntara::users.titles.list'); $this->layout->breadcrumb = Config::get('syntara::breadcrumbs.users'); }
php
{ "resource": "" }
q259398
UserController.getCreate
test
public function getCreate() { $groups = Sentry::getGroupProvider()->findAll(); $permissions = PermissionProvider::findAll(); $this->layout = View::make(Config::get('syntara::views.user-create'), array('groups' => $groups, 'permissions' => $permissions)); $this->layout->title = trans('syntara::users.titles.new'); $this->layout->breadcrumb = Config::get('syntara::breadcrumbs.create_user'); }
php
{ "resource": "" }
q259399
UserController.postCreate
test
public function postCreate() { try { $validator = new UserValidator(Input::all(), 'create'); $permissionsValues = Input::get('permission'); $permissions = $this->_formatPermissions($permissionsValues); if(!$validator->passes()) { return Response::json(array('userCreated' => false, 'errorMessages' => $validator->getErrors())); } // create user $user = Sentry::getUserProvider()->create(array( 'email' => Input::get('email'), 'password' => Input::get('pass'), 'username' => Input::get('username'), 'last_name' => (string)Input::get('last_name'), 'first_name' => (string)Input::get('first_name'), 'permissions' => $permissions )); // activate user $activationCode = $user->getActivationCode(); if(Config::get('syntara::config.user-activation') === 'auto') { $user->attemptActivation($activationCode); } elseif(Config::get('syntara::config.user-activation') === 'email') { $datas = array( 'code' => $activationCode, 'username' => $user->username ); // send email Mail::queue(Config::get('syntara::mails.user-activation-view'), $datas, function ($message) use ($user) { $message->from(Config::get('syntara::mails.email'), Config::get('syntara::mails.contact')) ->subject(Config::get('syntara::mails.user-activation-object')); $message->to($user->getLogin()); }); } $groups = Input::get('groups'); if(isset($groups) && is_array($groups)) { foreach($groups as $groupId) { $group = Sentry::getGroupProvider()->findById($groupId); $user->addGroup($group); } } } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e){} // already catch by validators catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e){} // already catch by validators catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e){} catch (\Cartalyst\Sentry\Users\UserExistsException $e) { return json_encode(array('userCreated' => false, 'message' => trans('syntara::users.messages.user-email-exists'), 'messageType' => 'danger')); } catch(\Exception $e) { return Response::json(array('userCreated' => false, 'message' => trans('syntara::users.messages.user-name-exists'), 'messageType' => 'danger')); } return json_encode(array('userCreated' => true, 'redirectUrl' => URL::route('listUsers'))); }
php
{ "resource": "" }