_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q236000 | PostObject.imageSizes | train | public static function imageSizes($size = false)
{
global $_wp_additional_image_sizes;
$additionalSizes = $_wp_additional_image_sizes;
$sizes = [];
$imageSizes = get_intermediate_image_sizes();
foreach($imageSizes as $imageSize)
{
if(in_array($imageSize,... | php | {
"resource": ""
} |
q236001 | PostObject.images | train | public static function images($id)
{
$sizes = self::imageSizes();
$urls = [];
if(has_post_thumbnail($id))
{
$image = wp_get_attachment_image_src(
get_post_thumbnail_id($id),
'full'
);
$image = pathinfo($image[0]);
... | php | {
"resource": ""
} |
q236002 | SchemaPropertyDescriptor.getQueryStatements | train | public function getQueryStatements($table){
// field declaration
$query = array();
array_push($query, $this->name . ' ' . $this->type);
if($this->nullable == false)
array_push($query, ' NOT NULL');
else array_push($query, ' NULL');
if(isset($this->default_value)){
$value = $this->default_value;
if(... | php | {
"resource": ""
} |
q236003 | DateField.footer | train | public static function footer()
{
$code = '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>'.chr(10);
if (App::getLocale() != 'en') {
$code .= ' <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepic... | php | {
"resource": ""
} |
q236004 | Slot.mustBeTypeOf | train | public function mustBeTypeOf(string $type) : Slot
{
static $allowed_types = [
'boolean',
'bool',
'integer',
'int',
'float',
'double',
'string',
'array',
'object',
'resource',
'... | php | {
"resource": ""
} |
q236005 | Slot.mustBeInstanceOf | train | public function mustBeInstanceOf(string $instanceOf) : Slot
{
$this->instanceOf = class_exists($instanceOf) || interface_exists($instanceOf) ? $instanceOf : self::INSTANCE_OF_ANY;
return $this;
} | php | {
"resource": ""
} |
q236006 | EventSubjectTrait.triggerEvent | train | public function triggerEvent($name, Event $event = null)
{
return $this->e->trigger($name, $event);
} | php | {
"resource": ""
} |
q236007 | GenericInitializer.initialize | train | public function initialize()
{
if (!file_exists($this->paramsPathname)) {
throw new \InvalidArgumentException("Invalid Magento root '$this->magentoRoot'.");
}
$params = $this->getParams();
$params['code'] = $this->store;
$params['type'] = $this->scope;
... | php | {
"resource": ""
} |
q236008 | ChromeLoggerAdaptor.write | train | public function write($level, $message, array $context = array())
{
if ($this->overflowed){
return;
}
$backtraceLine = '';
if ($this->logBacktrace) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3);
$backtrace = array_pop($backtrac... | php | {
"resource": ""
} |
q236009 | ChromeLoggerAdaptor.send | train | protected function send()
{
if (!$this->initialized) {
$this->initialized = true;
$this->sendHeader = $this->headersAccepted();
if (!$this->sendHeader) {
return;
}
}
$jsonEncoded = json_encode($this->json);
$jsonEncode... | php | {
"resource": ""
} |
q236010 | MathHelper.histogram | train | public static function histogram($values, $edges)
{
$bins = [];
foreach ($edges as $key => $val) {
if (!isset($edges[$key + 1])) break;
$bins[] = $val . '-' . ($edges[$key + 1]);
}
$histogram = array_fill_keys($bins, []);
foreach ($values as $value) {... | php | {
"resource": ""
} |
q236011 | BSoftModules.getmodulescounts_forgroups | train | public function getmodulescounts_forgroups($groupids){
if(!$db=BFactory::getDBO()){
return array();
}
$qr='select count(pageid)as cnt,pageid from soft_modules_rules ';
$qr.=' where pageid in ('.implode(',',$groupids).')';
$qr.='group by pageid';
$q=$db->Query($qr);
$counts=array();
while($l=$db->fet... | php | {
"resource": ""
} |
q236012 | RealUrlAutoConfiguration.addDVOConnectorConfig | train | public function addDVOConnectorConfig($params)
{
return array_merge_recursive($params['config'], [
'postVarSets' => [
'_DEFAULT' => [
'dvoconnector' => [
[
'GETvar' => 'tx_dvoconnector_pi1[controller]',
'noMatch' => ... | php | {
"resource": ""
} |
q236013 | ServiceProvider.register | train | public function register()
{
$this->container['config']->addLocation($this->container->basePath().'/dev/config');
foreach ($this->container['config']->get('app.providers') as $provider) {
$this->container->addProvider($provider);
}
} | php | {
"resource": ""
} |
q236014 | AclAwareTrait.hasAcl | train | public function hasAcl()
{
if ($this->acl instanceof Acl\Acl
|| static::$defaultAcl instanceof Acl\Acl
) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q236015 | AclAwareTrait.hasRole | train | public function hasRole()
{
if ($this->role instanceof Acl\Role\RoleInterface
|| is_string($this->role)
|| static::$defaultRole instanceof Acl\Role\RoleInterface
|| is_string(static::$defaultRole)
) {
return true;
}
return false;
... | php | {
"resource": ""
} |
q236016 | User.jsonEncode | train | public static function jsonEncode($data)
{
$json = json_encode($data);
// if json_encode failed
if ($json === false) {
self::jsonLastError();
}
return $json;
} | php | {
"resource": ""
} |
q236017 | User.updateName | train | private function updateName()
{
if (!LOCAL) {
$ds = ldap_connect("addressbook.ic.ac.uk");
$r = ldap_bind($ds);
$justthese = array("displayname");
$sr = ldap_search(
$ds,
"ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk",
... | php | {
"resource": ""
} |
q236018 | User.updateEmail | train | private function updateEmail()
{
if (!LOCAL) {
$ds = ldap_connect("addressbook.ic.ac.uk");
$r = ldap_bind($ds);
$justthese = array("mail");
$sr = ldap_search(
$ds,
"ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk",
"ui... | php | {
"resource": ""
} |
q236019 | Net_Notifier_ServerCLI.getUiXml | train | protected function getUiXml()
{
$dir = '@data-dir@' . DIRECTORY_SEPARATOR
. '@package-name@' . DIRECTORY_SEPARATOR . 'data';
if ($dir[0] == '@') {
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data... | php | {
"resource": ""
} |
q236020 | JobGraph.move | train | public function move($value)
{
// No need to update if $value is already current one
if ($value === $this->current()) {
return;
}
$index = $this->search($value);
if (false === $index) {
throw new \InvalidArgumentException(sprintf('"%s" value not foun... | php | {
"resource": ""
} |
q236021 | JobGraph.getJob | train | public function getJob($index)
{
if ($this->hasNextJob($index)) {
return $this->getIterator()->offsetGet($index);
}
return false;
} | php | {
"resource": ""
} |
q236022 | FA.css | train | public function css($css) {
$css = trim($css);
if (substr($css, -1) !== ';') {
$css = $css . ';';
}
return $this->att(['style' => $css]);
} | php | {
"resource": ""
} |
q236023 | MethodType.isXmlHttpRequest | train | function isXmlHttpRequest()
{
/** @var iHeader $header */
if (! $this->getMessageObject()->headers()->has('X-Requested-With') )
return false;
$header = $this->getMessageObject()->headers()->get('X-Requested-With');
return false !== $header && \Poirot\Http\Header\renderHe... | php | {
"resource": ""
} |
q236024 | MethodType.isFlashRequest | train | function isFlashRequest()
{
/** @var iHeader $header */
if (! $this->getMessageObject()->headers()->has('User-Agent') )
return false;
$header = $this->getMessageObject()->headers()->get('User-Agent');
return false !== $header && stristr(\Poirot\Http\Header\renderHeader($... | php | {
"resource": ""
} |
q236025 | Study.modules | train | public function modules()
{
$courses = $this->courses->pluck('course_id');
return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) {
$query->whereIn('course_id',$courses);
});
} | php | {
"resource": ""
} |
q236026 | Study.modulesActiveOn | train | public function modulesActiveOn($periodId)
{
$courses = $this->coursesActiveOn($periodId)->pluck('course_id');
return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) {
$query->whereIn('course_id',$courses);
});
} | php | {
"resource": ""
} |
q236027 | Virtual.__isset | train | public function __isset($prop)
{
if (property_exists($this, $prop) && $prop{0} != '_') {
return true;
}
$method = 'get'.ucfirst(Helper::denormalize($prop));
if (method_exists($this, $method)) {
return true;
}
if (method_exists($this, 'callback'... | php | {
"resource": ""
} |
q236028 | iauEors.Eors | train | public static function Eors(array $rnpb, $s) {
$x;
$ax;
$xs;
$ys;
$zs;
$p;
$q;
$eo;
/* Evaluate Wallace & Capitaine (2006) expression (16). */
$x = $rnpb[2][0];
$ax = $x / (1.0 + $rnpb[2][2]);
$xs = 1.0 - $ax * $x;
$ys = -$ax * $rnpb[2][1];
$zs = -$x;
$p = ... | php | {
"resource": ""
} |
q236029 | ResourcesController.scriptsAction | train | public function scriptsAction()
{
$locator = $this->get('file_locator');
$content =
file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ChangePasswordWindow.js')).
file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ValidateWindo... | php | {
"resource": ""
} |
q236030 | ResourcesController.translationsAction | train | public function translationsAction($language)
{
$language = $this->getUser()->getInterfaceLanguage($language);
$translations = $this->get('resourcesTranslations');
$content = $translations->get($language);
return new Response($content, 200, ['Content-Type' => 'text/javascript']);
... | php | {
"resource": ""
} |
q236031 | Client.setUri | train | public function setUri($uri)
{
if (filter_var($uri, FILTER_VALIDATE_URL)) {
$this->uri = $uri;
} else {
throw new RuntimeException('Invalid URI setted.');
}
return $this;
} | php | {
"resource": ""
} |
q236032 | Client.setMethod | train | public function setMethod($method = self::GET)
{
if (in_array($method, $this->allowedMethods)) {
$this->method = $method;
} else {
throw new RuntimeException('Invalid method setted.');
}
return $this;
} | php | {
"resource": ""
} |
q236033 | Client.setHeaders | train | public function setHeaders($name, $value = null)
{
//Verifying if is array
if (is_array($name)) {
foreach ($name as $k => $v) {
if (is_string($k)) {
$this->setHeaders($k, $v);
} else {
$this->setHeaders($v, null);
}
}
} else {
// Verifying if is a string without $value parameter
... | php | {
"resource": ""
} |
q236034 | Client.setParameterGet | train | public function setParameterGet($name, $value = null)
{
// Verifying if is array
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->setParameterGet($k,$v);
}
} else {
$parray = &$this->paramsGet;
if (is_null($value)) {
if (isset($parray[$name])) unset($parray[$name]);
} else ... | php | {
"resource": ""
} |
q236035 | Client.setParameterPost | train | public function setParameterPost($name, $value = null)
{
// Verifying if is array
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->setParameterPost($k,$v);
}
} else {
$parray = &$this->paramsPost;
if (is_null($value)) {
if (isset($parray[$name])) unset($parray[$name]);
} els... | php | {
"resource": ""
} |
q236036 | Client.rawData | train | public function rawData($bool = false)
{
if (is_bool($bool)) {
$this->useRawData = $bool;
} else {
throw new RuntimeException('Invalid parameter type, expected boolean, got ' . gettype($bool));
}
return $this;
} | php | {
"resource": ""
} |
q236037 | Client.setRawData | train | public function setRawData($data)
{
if (is_string($data)) {
$this->rawData(true);
$this->dataRaw = $data;
} else {
throw new RuntimeException('Invalid RAW data setted.');
}
return $this;
} | php | {
"resource": ""
} |
q236038 | Client.setFiles | train | public function setFiles($file, $name = null)
{
// Verifying if is array
if (is_array($file)) {
foreach ($file as $k => $v) {
$this->setFiles($v,$k);
}
} else {
$parray = &$this->files;
if (file_exists($file)) {
if (is_null($file)) {
if (isset($parray[$name])) unset($parray[$name]);
... | php | {
"resource": ""
} |
q236039 | Client.setHTTPVersion | train | public function setHTTPVersion($version = self::HTTP_1)
{
if ($version == self::HTTP_0 || $version == self::HTTP_1) {
$this->httpVersion = $version;
} else {
throw new RuntimeException('Invalid HTTP version setted.');
}
return $this;
} | php | {
"resource": ""
} |
q236040 | Client.setCurlOpts | train | public function setCurlOpts($opt, $value = null)
{
// Verifying if is array
if (is_array($opt)) {
foreach ($opt as $k => $v) {
$this->setCurlOpts($k,$v);
}
} else {
$this->curlOpts[$opt] = $value;
}
return $this;
} | php | {
"resource": ""
} |
q236041 | Client.noReset | train | public function noReset($bool = false)
{
if (is_bool($bool)) {
$this->noReset = $bool;
} else {
throw new RuntimeException('Invalid parameter type setted, expected boolean, got ' . gettype($bool));
}
} | php | {
"resource": ""
} |
q236042 | Client.reset | train | public function reset()
{
$this->uri = null;
$this->method = self::GET;
$this->headers = array();
$this->paramsGet = array();
$this->paramsPost = array();
$this->useRawData = false;
$this->dataRaw = null;
$this->httpVersion = self::HTTP_1;
$this->curlOpts = array();
retur... | php | {
"resource": ""
} |
q236043 | ModularSubscriber.loadClassMetadata | train | public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
/** @var ClassMetadata $classMetadata */
$classMetadata = $eventArgs->getClassMetadata();
if (null === $classMetadata->getReflectionClass() ||
false == $this->isModular($classMetadata) ||
'Har... | php | {
"resource": ""
} |
q236044 | ModularSubscriber.prePersist | train | public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$entityManager = $args->getEntityManager();
$classMetadata = $entityManager->getClassMetadata(get_class($entity));
if (false == $this->isModular($classMetadata)) {
return;
... | php | {
"resource": ""
} |
q236045 | Container.get | train | public function get($name, array $parameters = [])
{
// Shared services are preserved through whole request
if (isset($this->shared[$name])) {
return $this->shared[$name];
}
if (!$this->has($name)) {
throw new NotFoundException('No definition found for servic... | php | {
"resource": ""
} |
q236046 | Pair.calculate | train | public function calculate($values)
{
$dataToReplace = array();
foreach ($this->getVariables() as $mask => $var) {
$var = $values[$var];
if ($var instanceof \DateTime) {
$var = new \Zend_Date($var->getTimestamp());
$var = $var->get(self::DEFAULT... | php | {
"resource": ""
} |
q236047 | Zend_Gdata_Gapps_GroupEntry.getProperty | train | public function getProperty($rel = null)
{
if ($rel == null) {
return $this->_property;
} else {
foreach ($this->_property as $p) {
if ($p->rel == $rel) {
return $p;
}
}
return null;
}
} | php | {
"resource": ""
} |
q236048 | YamlBuildFileLoader.processTasks | train | protected function processTasks($tasks)
{
foreach ($tasks as $taskName => $taskConfig) {
$serviceId = sprintf('task.%s', $taskName);
$this->container->setDefinition(
$serviceId,
new Definition()
)->setSynthetic(true);
$command ... | php | {
"resource": ""
} |
q236049 | ActionPerformer.perform | train | public function perform(
AgentInterface $agent,
GridMetadata $gridMetadata,
string $actionName,
array $selectedIdentifiers
): ActionResponseInterface {
$actionMetadatas = $gridMetadata->getActions();
if (!isset($actionMetadatas[$actionName])) {
throw new \... | php | {
"resource": ""
} |
q236050 | iauRx.Rx | train | public static function Rx($phi, array &$r) {
$s;
$c;
$a10;
$a11;
$a12;
$a20;
$a21;
$a22;
$s = sin($phi);
$c = cos($phi);
$a10 = $c * $r[1][0] + $s * $r[2][0];
$a11 = $c * $r[1][1] + $s * $r[2][1];
$a12 = $c * $r[1][2] + $s * $r[2][2];
$a20 = - $s * $r[1][0] + $c... | php | {
"resource": ""
} |
q236051 | FileSystem.getIndex | train | private function getIndex($key, $tags)
{
// tags folder
$tagFolder = $this->createFolderNameFromTags($tags);
if (!is_dir($tagFolder)) {
mkdir($tagFolder, 0755, true);
}
// key folder
$folder = $tagFolder . substr($key, 0, 2) . DIRECTORY_SEPARATOR . subst... | php | {
"resource": ""
} |
q236052 | FileSystem.createFolderNameFromTags | train | private function createFolderNameFromTags(array $tags)
{
natsort($tags);
$tagFolder = '_';
foreach ($tags as $t) {
$tagFolder .= $t . '_';
}
return $this->indexDir . $tagFolder . DIRECTORY_SEPARATOR;
} | php | {
"resource": ""
} |
q236053 | UploadedFile.getErrorMessage | train | public function getErrorMessage(): string
{
static $messages = [
UPLOAD_ERR_OK => 'Upload successful',
UPLOAD_ERR_INI_SIZE => 'The size of the file exceeds the value of the "upload_max_filesize" directive in php.ini',
UPLOAD_ERR_FORM_SIZE => 'The size of the file exceeds the value of the "MAX_FIL... | php | {
"resource": ""
} |
q236054 | UploadedFile.moveTo | train | public function moveTo(string $destination)
{
if (!$this->isValid())
{
throw new FileMoveException('File was not uploaded successfully and thus cannot be moved');
}
if ($this->hasBeenMoved)
{
throw new FileMoveException('Uploaded file has already been moved');
}
if (is_dir($destination))
{
... | php | {
"resource": ""
} |
q236055 | InventoryController.getBought | train | public function getBought()
{
$items = Item::join('seller')
->leftJoin('purchases')
->where('purchases.user_id', Auth::user()->userId);
if (mustard_loaded('auctions')) {
$items->leftJoin('winningBid')
->orWhere('bids.user_id', Auth::user()->userId... | php | {
"resource": ""
} |
q236056 | InventoryController.getSold | train | public function getSold()
{
$items = Auth::user()->items()
->leftJoin('purchases')
->where(function ($query) {
$query->typeFixed()->whereNotNull('purchases.purchase_id');
});
// Allows sorting by buyer username
$items->getBaseQuery()
... | php | {
"resource": ""
} |
q236057 | InventoryController.getUnsold | train | public function getUnsold()
{
$items = Auth::user()->items()
->with('purchases')
->where(function ($query) {
$query->has('purchases', 0)
->where('end_date', '<', time())
->where('auction', false)
->orWhere(fu... | php | {
"resource": ""
} |
q236058 | AuthenticationServiceFactory.createService | train | public function createService( ServiceLocatorInterface $services )
{
$manager = $services->get( 'Zend\Session\ManagerInterface' );
$storage = new Session( null, null, $manager );
return new AuthenticationService( $services, $storage );
} | php | {
"resource": ""
} |
q236059 | Router.addMiddleware | train | public function addMiddleware(Middleware $middleware)
{
$group = $middleware->getGroup();
if (! isset($this->middleware[$group])) {
$this->middleware[$group] = array(
'before' => array(),
'after' => array()
);
}
$this->middlewa... | php | {
"resource": ""
} |
q236060 | Router.executeRoute | train | private function executeRoute(Route &$route, $method, $force = false)
{
$continue = true;
if (! $force) {
$continue = $this->executeRouteMiddleware($route, 'before', $method);
}
if ($continue === true) {
$route->execute($this->compiled);
}
if... | php | {
"resource": ""
} |
q236061 | Router.executeRouteMiddleware | train | private function executeRouteMiddleware(Route &$route, $position, $method)
{
$method = strtoupper($method);
/** @var Middleware[] $middleware */
$middleware = array();
$continue = true;
// Get all global middleware's.
if (isset(
$this->middleware['... | php | {
"resource": ""
} |
q236062 | Driver.subject | train | public function subject($subject)
{
$name = Config::get('name');
$subject = '[' . $name . '] ' . $subject;
/**
* strange subject encode error
* occurred when there's both chinese and english
* solution see: https://github.com/swiftmailer/swiftmailer/issues/665
... | php | {
"resource": ""
} |
q236063 | Driver.body | train | public function body($body, $contentType = null)
{
$this->message->setBody($body, $contentType);
return $this;
} | php | {
"resource": ""
} |
q236064 | Driver.view | train | public function view($template, $data = [])
{
$html = ViewService::getEngine()->render($template, $data);
$this->message->setBody($html, 'text/html');
return $this;
} | php | {
"resource": ""
} |
q236065 | Collection.median | train | public function median($key = null)
{
$count = $this->count();
if ($count == 0) {
return;
}
$values = $this->with(isset($key) ? $this->pluck($key) : $this)->sort()->values();
$middle = (int) ($count / 2);
if ($count % 2) {
return $values->... | php | {
"resource": ""
} |
q236066 | Collection.containsStrict | train | public function containsStrict($key, $value = null)
{
if (func_num_args() == 2) {
return $this->contains(function ($item) use ($key, $value) {
return ArrayHelper::dataGet($item, $key) === $value;
});
}
if ($this->useAsCallable($key)) {
... | php | {
"resource": ""
} |
q236067 | AbstractSelector.doRequest | train | protected final function doRequest()
{
$stepId = count($this->results);
$request = $this->steps[$stepId]($this->results);
$response = $this->requestor->doRequest($request);
$this->checkGotResponse($response);
$this->saveResult($stepId, $response);
} | php | {
"resource": ""
} |
q236068 | TweetPusher.pushTweet | train | public function pushTweet($tweet)
{
if ($this->maxPushesPerHour > 0 && $this->cache) {
$hourAgo = new \DateTime('- 1 hour');
/** @var \DateTime[] $tweetTimes */
$tweetTimes = $this->cache->fetch(static::CACHE_KEY) ?: [];
foreach ($tweetTimes as $k => $time) {
... | php | {
"resource": ""
} |
q236069 | HttpView.printDocument | train | public function printDocument()
{
header("Content-Type: {$this->_contentType}; {$this->_charset}");
try {
$this->controller->processRequest();
} catch (Exception $e) {
$message = substr(
preg_replace('/\s+/', ' ', $e->getMessage()), 0, 150
... | php | {
"resource": ""
} |
q236070 | PHPCache.getConfig | train | public function getConfig($name) {
return isset($this->settings[$name]) ? $this->settings[$name] : null;
} | php | {
"resource": ""
} |
q236071 | PHPCache.cacheVal | train | public function cacheVal($value, $id = null) {
if ($id == null) {
if (is_object($value))
$id = $this->getIDfromOjb($value);
if ($id == null && $this->getConfig('debug')) {
echo "no caching key";
return $value;
}
... | php | {
"resource": ""
} |
q236072 | PHPCache.cacheFun | train | public function cacheFun($function) {
if ($this->getConfig('debug') && !is_callable($function))
echo "no valid function";
$r = new ReflectionFunction($function);
$id = null;
foreach ($r->getStaticVariables() as $key => $var) {
if ($key == 'key')
... | php | {
"resource": ""
} |
q236073 | PHPCache.isCached | train | public function isCached($id) {
if ($id != null) {
$id = $this->getIDfromOjb($id);
}
if ($id == null)
return false;
$cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id);
$cachetime = $this->getConfig('cacheTime');
if (fi... | php | {
"resource": ""
} |
q236074 | PHPCache.clearCache | train | public function clearCache() {
$files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK);
foreach ($files as $file) {
unlink($file);
}
} | php | {
"resource": ""
} |
q236075 | PHPCache.gc | train | public function gc() {
$files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK);
$cachetime = $this->getConfig('cacheTime');
foreach ($files as $file) {
if(time() - $cachetime > fileatime($file))
unlink($file);
}
} | php | {
"resource": ""
} |
q236076 | Markdownify.parseString | train | function parseString($html) {
$this->parser->html = $html;
$this->parse();
return $this->output;
} | php | {
"resource": ""
} |
q236077 | Markdownify.flushStacked | train | function flushStacked() {
# links
foreach ($this->stack as $tag => $a) {
if (!empty($a)) {
call_user_func(array(&$this, 'flushStacked_'.$tag));
}
}
} | php | {
"resource": ""
} |
q236078 | Markdownify.flushLinebreaks | train | function flushLinebreaks() {
if ($this->lineBreaks && !empty($this->output)) {
$this->out(str_repeat("\n".$this->indent, $this->lineBreaks), true);
}
$this->lineBreaks = 0;
} | php | {
"resource": ""
} |
q236079 | Markdownify.handleText | train | function handleText() {
if ($this->hasParent('pre') && strpos($this->parser->node, "\n") !== false) {
$this->parser->node = str_replace("\n", "\n".$this->indent, $this->parser->node);
}
if (!$this->hasParent('code') && !$this->hasParent('pre')) {
# entity decode
$this->parser->node = $this... | php | {
"resource": ""
} |
q236080 | Markdownify.stack | train | function stack() {
if (!isset($this->stack[$this->parser->tagName])) {
$this->stack[$this->parser->tagName] = array();
}
array_push($this->stack[$this->parser->tagName], $this->parser->tagAttributes);
} | php | {
"resource": ""
} |
q236081 | Markdownify.unstack | train | function unstack() {
if (!isset($this->stack[$this->parser->tagName]) || !is_array($this->stack[$this->parser->tagName])) {
trigger_error('Trying to unstack from empty stack. This must not happen.', E_USER_ERROR);
}
return array_pop($this->stack[$this->parser->tagName]);
} | php | {
"resource": ""
} |
q236082 | Markdownify.decode | train | function decode($text, $quote_style = ENT_QUOTES) {
if (version_compare(PHP_VERSION, '5', '>=')) {
# UTF-8 is only supported in PHP 5.x.x and above
$text = html_entity_decode($text, $quote_style, 'UTF-8');
} else {
if (function_exists('html_entity_decode')) {
$text = html_entity_decode... | php | {
"resource": ""
} |
q236083 | AdminMediaTypeController.createCreateForm | train | private function createCreateForm(MediaType $entity)
{
$form = $this->createForm(new MediaTypeType(), $entity, array(
'action' => $this->generateUrl('mediatype_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
retu... | php | {
"resource": ""
} |
q236084 | AdminMediaTypeController.newAction | train | public function newAction()
{
$entity = new MediaType();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | {
"resource": ""
} |
q236085 | AdminMediaTypeController.createEditForm | train | private function createEditForm(MediaType $entity)
{
$form = $this->createForm(new MediaTypeType(), $entity, array(
'action' => $this->generateUrl('mediatype_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label... | php | {
"resource": ""
} |
q236086 | FetchUrl.extractHeaders | train | private function extractHeaders($str)
{
$this->debug->log(__METHOD__);
$this->debug->groupUncollapse();
$headerStart = 0;
#$this->debug->log(('top', \substr($return, 0, $this->curlInfo['header_size']));
$headerLenStack = array();
$i = 0;
while (true) {
... | php | {
"resource": ""
} |
q236087 | FetchUrl.curlGetOptions | train | protected function curlGetOptions($url, $options = array())
{
$this->debug->groupCollapsed(__METHOD__);
$urlParts = Html::parseUrl($url);
$optionsDefault = $this->curlOptionsDefault($url);
$options = $this->curlOptionsNormalize($options);
// $this->debug->log('optionsDefault'... | php | {
"resource": ""
} |
q236088 | FetchUrl.curlOptionsDefault | train | protected function curlOptionsDefault($url)
{
$this->debug->groupCollapsed(__METHOD__);
$opts = array(
// 'CURLOPT_VERBOSE' => 1,
// 'CURLOPT_STDERR' => fopen(dirname($_SERVER['SCRIPT_FILENAME']).'/stderr.txt','a'),
// 'CURLOPT_COOKIEJAR' => 'c:/shazbot.tx... | php | {
"resource": ""
} |
q236089 | FetchUrl.curlGetReturn | train | protected function curlGetReturn()
{
$follow = !isset($this->optionsPassed['CURLOPT_FOLLOWLOCATION'])
|| $this->optionsPassed['CURLOPT_FOLLOWLOCATION'];
$headers = $this->fetchResponse['headers'];
if ($follow && isset($headers['Location'])) { // follow location
$loc... | php | {
"resource": ""
} |
q236090 | Asset._setFile | train | protected function _setFile($path) {
$this->_name .= $path;
$this->_data['' . $path . ''] = file_get_contents($path);
if ($this->_type == 'css') {
$this->_currentPath = dirname($path) . '/';
$this->_data['' . $path . ''] = preg_replace_callback('`url\((.*)\)`isU', ['Gcs\... | php | {
"resource": ""
} |
q236091 | Asset._setDir | train | protected function _setDir($path) {
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
$extension = explode('.', basename($entry));
$ext = $extension[count($extension) - 1];
if ($ext == $this->_type) {
... | php | {
"resource": ""
} |
q236092 | Asset._parseRelativePathCss | train | protected function _parseRelativePathCss($m) {
/**
* We take the page. Each time we have a '../' in a path file in the css, we drop a folder of the parent file. Zxample :
* css file : css/dossier/truc/test.css
* image file in css : ../../test.png
* we have two ../ so we... | php | {
"resource": ""
} |
q236093 | Asset._compress | train | protected function _compress() {
//$before = '(?<=[:(, ])';
//$after = '(?=[ ,);}])';
//$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)';
foreach ($this->_data as $value) {
$this->_concatContent .= $value;
}
if ($this->_type == 'css') {
... | php | {
"resource": ""
} |
q236094 | Client.getResource | train | public function getResource($identifier)
{
/** @var ClientEntity $client */
$client = $this->getRepository()->findOneBy(array('id' => $identifier));
if (!$client) {
throw new NotFoundHttpException(
$this->translator->trans('error.client_not_found', array('%id%' =>... | php | {
"resource": ""
} |
q236095 | Client.getCollection | train | public function getCollection(array $options = array())
{
/** @var ClientEntity[] $collection */
$collection = $this->getRepository()->findAll();
$resource = new Resource($this->generateBrowseUrl(), array('count' => count($collection)));
foreach ($collection as $element) {
... | php | {
"resource": ""
} |
q236096 | Client.delete | train | public function delete(Resource $resource)
{
$data = $resource->toArray();
$client = $this->getRepository()->findOneBy(array('id' => $data['id']));
if (!$client) {
$errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id']));
throw... | php | {
"resource": ""
} |
q236097 | Client.createResourceFromClient | train | protected function createResourceFromClient(ClientEntity $client)
{
$resource = new Resource(
$this->generateReadUrl($client->getId()),
array(
'id' => $client->getId(),
'publicId' => $client->getPublicId(),
'secret' ... | php | {
"resource": ""
} |
q236098 | ElasticsearchContextListener.handle | train | public function handle(GetResponseEvent $event)
{
if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
$this->registered = true;
}
$request = $ev... | php | {
"resource": ""
} |
q236099 | ElasticsearchContextListener.onKernelResponse | train | public function onKernelResponse(FilterResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (!$event->getRequest()->hasSession()) {
return;
}
if (null !== $this->logger) {
$this->logger->debug('Write SecurityContext in t... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.