_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259600
SqliteDb.createIndex
test
public function createIndex($tablename, array $indexDef, $options = []) { $sql = 'create '. (val('type', $indexDef) === Db::INDEX_UNIQUE ? 'unique ' : ''). 'index '. (val(Db::OPTION_IGNORE, $options) ? 'if not exists ' : ''). $this->buildIndexName($tablename, $ind...
php
{ "resource": "" }
q259601
SqliteDb.forceType
test
protected function forceType($value, $type) { $type = strtolower($type); if ($type === 'null') { return null; } elseif (in_array($type, ['int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'unsigned big int', 'int2', 'int8', 'boolean'])) { return ...
php
{ "resource": "" }
q259602
SqliteDb.getPKValue
test
protected function getPKValue($tablename, array $row, $quick = false) { if ($quick && isset($row[$tablename.'ID'])) { return [$tablename.'ID' => $row[$tablename.'ID']]; } $tdef = $this->getTableDef($tablename); if (isset($tdef['indexes'][Db::INDEX_PK]['columns'])) { ...
php
{ "resource": "" }
q259603
SqliteDb.getTablenames
test
protected function getTablenames() { // Get the table names. $tables = (array)$this->get( 'sqlite_master', [ 'type' => 'table', 'name' => [Db::OP_LIKE => addcslashes($this->px, '_%').'%'] ], [ 'columns' => ['...
php
{ "resource": "" }
q259604
Route.create
test
public static function create($pattern, $callback) { if (is_callable($callback)) { $route = new CallbackRoute($pattern, $callback); } else { $route = new ResourceRoute($pattern, $callback); } return $route; }
php
{ "resource": "" }
q259605
Route.conditions
test
public function conditions($conditions = null) { if ($this->conditions === null) { $this->conditions = []; } if (is_array($conditions)) { $conditions = array_change_key_case($conditions); $this->conditions = array_replace( $this->conditions, ...
php
{ "resource": "" }
q259606
Route.methods
test
public function methods($methods = null) { if ($methods === null) { return $this->methods; } $this->methods = array_map('strtoupper', (array)$methods); return $this; }
php
{ "resource": "" }
q259607
Route.mappings
test
public function mappings($mappings = null) { if ($this->mappings === null) { $this->mappings = []; } if (is_array($mappings)) { $mappings = array_change_key_case($mappings); $this->mappings = array_replace( $this->mappings, $m...
php
{ "resource": "" }
q259608
Route.globalMappings
test
public static function globalMappings($mappings = null) { if (self::$globalMappings === null) { self::$globalMappings = []; } if (is_array($mappings)) { $mappings = array_change_key_case($mappings); self::$globalMappings = array_replace( self...
php
{ "resource": "" }
q259609
Route.isMapped
test
protected function isMapped($name) { $name = strtolower($name); return isset($this->mappings[$name]) || isset(self::$globalMappings[$name]); }
php
{ "resource": "" }
q259610
Route.mappedData
test
protected function mappedData($name, Request $request) { $name = strtolower($name); if (isset($this->mappings[$name])) { $mapping = $this->mappings[$name]; } elseif (isset(self::$globalMappings[$name])) { $mapping = self::$globalMappings[$name]; } else { ...
php
{ "resource": "" }
q259611
Route.matchesMethods
test
protected function matchesMethods(Request $request) { if (empty($this->methods)) { return true; } return in_array($request->getMethod(), $this->methods); }
php
{ "resource": "" }
q259612
Route.pattern
test
public function pattern($pattern = null) { if ($pattern !== null) { $this->pattern = '/'.ltrim($pattern, '/'); } return $this->pattern; }
php
{ "resource": "" }
q259613
CallbackRoute.dispatch
test
public function dispatch(Request $request, array &$args) { $callback = $args['callback']; $callback_args = reflect_args($callback, $args['args']); $result = call_user_func_array($callback, $callback_args); return $result; }
php
{ "resource": "" }
q259614
CallbackRoute.getPatternRegex
test
protected function getPatternRegex($pattern) { $result = preg_replace_callback('`{([^}]+)}`i', function ($match) { if (preg_match('`(.*?)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(.*?)`', $match[1], $matches)) { $before = preg_quote($matches[1], '`'); $param = $matche...
php
{ "resource": "" }
q259615
MySqlDb.query
test
public function query($sql, $type = Db::QUERY_READ, $options = []) { $mode = val(Db::OPTION_MODE, $options, $this->mode); if ($mode & Db::MODE_ECHO) { echo trim($sql, "\n;").";\n\n"; } if ($mode & Db::MODE_SQL) { return $sql; } $result = null; ...
php
{ "resource": "" }
q259616
MySqlDb.buildSelect
test
public function buildSelect($table, array $where, array $options = []) { $sql = ''; // Build the select clause. if (isset($options['columns'])) { $columns = array(); foreach ($options['columns'] as $value) { $columns[] = $this->backtick($value); ...
php
{ "resource": "" }
q259617
MySqlDb.bracketList
test
public function bracketList($row, $quote = "'") { switch ($quote) { case "'": $row = array_map([$this->pdo(), 'quote'], $row); $quote = ''; break; case '`': $row = array_map([$this, 'backtick'], $row); $quote...
php
{ "resource": "" }
q259618
MySqlDb.buildInsert
test
protected function buildInsert($tablename, array $row, $quotevals = true, $options = []) { if (val(Db::OPTION_UPSERT, $options)) { return $this->buildUpsert($tablename, $row, $quotevals, $options); } elseif (val(Db::OPTION_IGNORE, $options)) { $sql = 'insert ignore '; } e...
php
{ "resource": "" }
q259619
MySqlDb.buildUpsert
test
protected function buildUpsert($tablename, array $row, $quotevals = true, $options = []) { // Build the initial insert statement first. unset($options[Db::OPTION_UPSERT]); $sql = $this->buildInsert($tablename, $row, $quotevals, $options); // Add the duplicate key stuff. $updates...
php
{ "resource": "" }
q259620
MySqlDb.columnDefString
test
protected function columnDefString($name, array $def) { $result = $this->backtick($name).' '.$this->columnTypeString($def['type']); if (val('required', $def)) { $result .= ' not null'; } if (isset($def['default'])) { $result .= ' default '.$this->quoteVal($def['...
php
{ "resource": "" }
q259621
MySqlDb.indexDefString
test
protected function indexDefString($tablename, array $def) { $indexName = $this->backtick($this->buildIndexName($tablename, $def)); switch (val('type', $def, Db::INDEX_IX)) { case Db::INDEX_IX: return "index $indexName ".$this->bracketList($def['columns'], '`'); ca...
php
{ "resource": "" }
q259622
MySqlDb.getColumnOrders
test
protected function getColumnOrders($cdefs) { $orders = array_flip(array_keys($cdefs)); $prev = ' first'; foreach ($orders as $cname => &$value) { $value = $prev; $prev = ' after '.$this->backtick($cname); } return $orders; }
php
{ "resource": "" }
q259623
Porter.getFormatsFromDb
test
protected function getFormatsFromDb($db) { $tables = $db->tables(true); $formats = $this->fixFormats($tables); return $formats; }
php
{ "resource": "" }
q259624
Porter.translateRow
test
protected function translateRow($row, $format) { // Apply the row filter. if (isset($format['rowfilter'])) { call_user_func_array($format['rowfilter'], array(&$row)); } $result = array(); foreach ($format['columns'] as $key => $cdef) { if (array_key_exist...
php
{ "resource": "" }
q259625
PhpbbPassword.verify
test
public function verify($password, $hash) { if (strlen($hash) == 34) { return ($this->cryptPrivate($password, $hash) === $hash) ? true : false; } return (md5($password) === $hash) ? true : false; }
php
{ "resource": "" }
q259626
PhpbbPassword.encode64
test
protected function encode64($input, $count) { $itoa64 = PhpbbPassword::ITOA64; $output = ''; $i = 0; do { $value = ord($input[$i++]); $output .= $itoa64[$value & 0x3f]; if ($i < $count) { $value |= ord($input[$i]) << 8; } ...
php
{ "resource": "" }
q259627
Request.current
test
public static function current(Request $request = null) { if ($request !== null) { $bak = self::$current; self::$current = $request; return $bak; } return self::$current; }
php
{ "resource": "" }
q259628
Request.defaultEnvironment
test
public static function defaultEnvironment($key = null, $merge = false) { if (self::$defaultEnv === null) { self::$defaultEnv = array( 'REQUEST_METHOD' => 'GET', 'X_REWRITE' => true, 'SCRIPT_NAME' => '', 'PATH_INFO' => '/', ...
php
{ "resource": "" }
q259629
Request.globalEnvironment
test
public static function globalEnvironment($key = null) { // Check to parse the environment. if ($key === true || !isset(self::$globalEnv)) { self::$globalEnv = static::parseServerVariables(); } if ($key) { return val($key, self::$globalEnv); } retu...
php
{ "resource": "" }
q259630
Request.parseServerVariables
test
protected static function parseServerVariables() { $env = static::defaultEnvironment(); // REQUEST_METHOD. $env['REQUEST_METHOD'] = val('REQUEST_METHOD', $_SERVER) ?: 'CONSOLE'; // SCRIPT_NAME: This is the root directory of the application. $script_name = rtrim_substr($_SERVER[...
php
{ "resource": "" }
q259631
Request.overrideEnvironment
test
protected static function overrideEnvironment(&$env) { $get =& $env['QUERY']; // Check to override the method. if (isset($get['x-method'])) { $method = strtoupper($get['x-method']); $getMethods = array(self::METHOD_GET, self::METHOD_HEAD, self::METHOD_OPTIONS); ...
php
{ "resource": "" }
q259632
Request.getEnv
test
public function getEnv($key = null, $default = null) { if ($key === null) { return $this->env; } return val(strtoupper($key), $this->env, $default); }
php
{ "resource": "" }
q259633
Request.setEnv
test
public function setEnv($key, $value = null) { if (is_string($key)) { $this->env[strtoupper($key)] = $value; } elseif (is_array($key)) { $this->env = $key; } else { throw new \InvalidArgumentException("Argument 1 must be either a string or array.", 422); ...
php
{ "resource": "" }
q259634
Request.getHeaders
test
public function getHeaders() { $result = []; foreach ($this->env as $key => $value) { if (stripos($key, 'HTTP_') === 0 && !str_ends($key, '_RAW')) { $headerKey = static::normalizeHeaderName(substr($key, 5)); $result[$headerKey][] = $value; } ...
php
{ "resource": "" }
q259635
Request.getHostAndPort
test
public function getHostAndPort() { $host = $this->getHost(); $port = $this->getPort(); // Only append the port if it is non-standard. if (($port == 80 && $this->getScheme() === 'http') || ($port == 443 && $this->getScheme() === 'https')) { $port = ''; } else { ...
php
{ "resource": "" }
q259636
Request.setExt
test
public function setExt($ext) { if ($ext) { $this->env['EXT'] = '.'.ltrim($ext, '.'); } else { $this->env['EXT'] = ''; } return $this; }
php
{ "resource": "" }
q259637
Request.setPathExt
test
public function setPathExt($path) { // Strip the extension from the path. if (substr($path, -1) !== '/' && ($pos = strrpos($path, '.')) !== false) { $ext = substr($path, $pos); $path = substr($path, 0, $pos); $this->env['EXT'] = $ext; } else { $thi...
php
{ "resource": "" }
q259638
Request.setFullPath
test
public function setFullPath($fullPath) { $fullPath = '/'.ltrim($fullPath, '/'); // Try stripping the root out of the path first. $root = (string)$this->getRoot(); if ($root && strpos($fullPath, $root) === 0 && (strlen($fullPath) === strlen($root) || substr($full...
php
{ "resource": "" }
q259639
Request.setPort
test
public function setPort($port) { $this->env['SERVER_PORT'] = $port; // Override the scheme for standard ports. if ($port === 80) { $this->setScheme('http'); } elseif ($port === 443) { $this->setScheme('https'); } return $this; }
php
{ "resource": "" }
q259640
Request.getQuery
test
public function getQuery($key = null, $default = null) { if ($key === null) { return $this->env['QUERY']; } return isset($this->env['QUERY'][$key]) ? $this->env['QUERY'][$key] : $default; }
php
{ "resource": "" }
q259641
Request.setQuery
test
public function setQuery($key, $value = null) { if (is_string($key)) { $this->env['QUERY'][$key] = $value; } elseif (is_array($key)) { $this->env['QUERY'] = $key; } else { throw new \InvalidArgumentException("Argument 1 must be a string or array.", 422); ...
php
{ "resource": "" }
q259642
Request.getInput
test
public function getInput($key = null, $default = null) { if ($key === null) { return $this->env['INPUT']; } return isset($this->env['INPUT'][$key]) ? $this->env['INPUT'][$key] : $default; }
php
{ "resource": "" }
q259643
Request.getData
test
public function getData($key = null, $default = null) { if ($this->hasInput()) { return $this->getInput($key, $default); } else { return $this->getQuery($key, $default); } }
php
{ "resource": "" }
q259644
Request.setData
test
public function setData($key, $value = null) { if ($this->hasInput()) { $this->setInput($key, $value); } else { $this->setQuery($key, $value); } return $this; }
php
{ "resource": "" }
q259645
Request.getUrl
test
public function getUrl() { $query = $this->getQuery(); return $this->getScheme(). '://'. $this->getHostAndPort(). $this->getRoot(). $this->getPath(). (!empty($query) ? '?'.http_build_query($query) : ''); }
php
{ "resource": "" }
q259646
Request.setUrl
test
public function setUrl($url) { // Parse the url and set the individual components. $url_parts = parse_url($url); if (isset($url_parts['scheme'])) { $this->setScheme($url_parts['scheme']); } if (isset($url_parts['host'])) { $this->setHost($url_parts['host...
php
{ "resource": "" }
q259647
Request.makeUrl
test
public function makeUrl($path, $domain = false) { if (!$path) { $path = $this->getPath(); } // Check for a specific scheme. $scheme = $this->getScheme(); if ($domain === 'http' || $domain === 'https') { $scheme = $domain; $domain = true; ...
php
{ "resource": "" }
q259648
Request.splitPathExt
test
protected static function splitPathExt($path) { if (substr($path, -1) !== '/' && ($pos = strrpos($path, '.')) !== false) { $ext = substr($path, $pos); $path = substr($path, 0, $pos); return [$path, $ext]; } else { return [$path, '']; } }
php
{ "resource": "" }
q259649
DbDef.reset
test
public function reset() { $this->table = null; $this->columns = []; $this->indexes = []; $this->options = []; return $this; }
php
{ "resource": "" }
q259650
DbDef.column
test
public function column($name, $type, $nullDefault = false, $index = null) { $this->columns[$name] = $this->columnDef($type, $nullDefault); $index = (array)$index; foreach ($index as $typeStr) { if (strpos($typeStr, '.') === false) { $indexType = $typeStr; ...
php
{ "resource": "" }
q259651
DbDef.columnDef
test
protected function columnDef($type, $nullDefault = false) { $column = ['type' => $type]; if ($nullDefault === null || $nullDefault == true) { $column['required'] = false; } if ($nullDefault === false) { $column['required'] = true; } else { $co...
php
{ "resource": "" }
q259652
DbDef.primaryKey
test
public function primaryKey($name, $type = 'int') { $column = $this->columnDef($type, false); $column['autoincrement'] = true; $column['primary'] = true; $this->columns[$name] = $column; // Add the pk index. $this->index($name, Db::INDEX_PK); return $this; }
php
{ "resource": "" }
q259653
DbDef.exec
test
public function exec($reset = true) { $this->db->setTableDef( $this->table, $this->jsonSerialize(), $this->options ); if ($reset) { $this->reset(); } return $this; }
php
{ "resource": "" }
q259654
DbDef.table
test
public function table($name = null) { if ($name !== null) { $this->table = $name; return $this; } return $this->table; }
php
{ "resource": "" }
q259655
DbDef.index
test
public function index($columns, $type, $suffix = '') { $type = strtolower($type); $columns = (array)$columns; $suffix = strtolower($suffix); // Look for a current index row. $currentIndex = null; foreach ($this->indexes as $i => $index) { if ($type !== $index...
php
{ "resource": "" }
q259656
RobotsTxtController.index
test
public function index() { /** * Note that the config is originally loaded from this package's config file, but a config file can be published to the Laravel config dir. * If so, due to the nature of the config setup and Larvel's config merge, the original config gets completely overwritten. ...
php
{ "resource": "" }
q259657
Model.all
test
public function all($offset = 0, $pageSize = 10, $sort = 'time-descending') { $this->checkApiMethodIsSupported(__FUNCTION__); $pagingOptions = array( 'offset' => $offset, 'pageSize' => $pageSize, 'sort' => $sort, ); // Ressource Path with op...
php
{ "resource": "" }
q259658
Model.find
test
public function find($resourceId) { $this->checkApiMethodIsSupported(__FUNCTION__); return $this->request ->get($this->resourcePath.'/'.(int)$resourceId) ->json(); }
php
{ "resource": "" }
q259659
Model.validate
test
public function validate() { $this->checkApiMethodIsSupported(__FUNCTION__); $this->checkJudoId(); $this->checkRequiredAttributes($this->attributeValues); $validateResourcePath = $this->resourcePath.'/validate'; $response = $this->request->post( $validateResourc...
php
{ "resource": "" }
q259660
Model.getAttributeValue
test
public function getAttributeValue($attribute) { if (!array_key_exists($attribute, $this->attributeValues)) { return null; } return $this->attributeValues[$attribute]; }
php
{ "resource": "" }
q259661
Model.setAttributeValues
test
public function setAttributeValues($values) { foreach ($values as $key => $value) { // Does the attribute exist? if (!array_key_exists($key, $this->attributes)) { continue; } // Coerce to the right type if required $targetDataType ...
php
{ "resource": "" }
q259662
Model.checkApiMethodIsSupported
test
protected function checkApiMethodIsSupported($methodName) { if (empty($this->validApiMethods) || !in_array($methodName, $this->validApiMethods) ) { throw new ValidationError('API method is not supported'); } }
php
{ "resource": "" }
q259663
Model.checkRequiredAttributes
test
protected function checkRequiredAttributes($data) { $existingAttributes = array_keys($data); $errors = array(); foreach ($this->requiredAttributes as $requiredAttribute) { if (!in_array($requiredAttribute, $existingAttributes) || $data[$requiredAttribute] === '' ...
php
{ "resource": "" }
q259664
Model.checkJudoId
test
protected function checkJudoId() { $judoId = $this->getAttributeValue(static::JUDO_ID); if (!empty($judoId)) { return; } $configuration = $this->request->getConfiguration(); $this->attributeValues[static::JUDO_ID] = $configuration->get(static::JUDO_ID); }
php
{ "resource": "" }
q259665
ApiException.getSummary
test
public function getSummary() { return sprintf( static::MESSAGE, $this->getHttpStatusCode(), $this->getCode(), $this->getCategory(), $this->getMessage(), $this->getDetailsSummary() ); }
php
{ "resource": "" }
q259666
Judopay.getModel
test
public function getModel($modelName) { // If the model is already defined in the container, just return it if (isset($this->container[$modelName])) { return $this->get($modelName); } // Set up the model in the DI container $request = $this->get('request'); ...
php
{ "resource": "" }
q259667
ValidationError.getSummary
test
public function getSummary() { // As a sensible default, use the class name $message = get_class($this); // Append model errors summary if applicable $modelErrorSummary = $this->getModelErrorSummary(); if (!empty($modelErrorSummary)) { $message .= ' ('.$modelErro...
php
{ "resource": "" }
q259668
Request.get
test
public function get($resourcePath) { $endpointUrl = $this->configuration->get('endpointUrl'); $request = $this->client->createRequest( 'GET', $endpointUrl.'/'.$resourcePath, [ 'json' => null ] ); return $this->send($re...
php
{ "resource": "" }
q259669
Request.post
test
public function post($resourcePath, $data) { $endpointUrl = $this->configuration->get('endpointUrl'); $request = $this->client->createRequest( 'POST', $endpointUrl.'/'.$resourcePath, [ 'json' => $data ] ); return $this...
php
{ "resource": "" }
q259670
CardPaymentSpec.it_coerces_attributes_into_the_correct_data_type
test
public function it_coerces_attributes_into_the_correct_data_type() { $input = array( 'yourPaymentMetaData' => (object)array('val' => 'an unexpected string'), 'judoId' => 'judo123', 'amount' => '123.23', ); $expectedOutput = array...
php
{ "resource": "" }
q259671
TransmittedField.validate
test
protected function validate() { $errors = array(); foreach ($this->requiredAttributes as $requiredAttribute) { if (!ArrayHelper::keyExists($this->data, $requiredAttribute)) { $errors[] = $requiredAttribute.' is missing or empty'; } } if (count...
php
{ "resource": "" }
q259672
ArrayHelper.keyExists
test
public static function keyExists(array $array, $key) { if (($pos = strrpos($key, '.')) !== false && ($subKey = substr($key, 0, $pos)) !== false && static::keyExists($array, $subKey) && static::keyExists($array[$subKey], substr($key, $pos + 1)) ) { retu...
php
{ "resource": "" }
q259673
Toastr.render
test
public function render() { $notifications = $this->session->get('toastr::notifications'); if(!$notifications) $notifications = array(); $output = '<script type="text/javascript">'; $lastConfig = []; foreach($notifications as $notification) { $config = $this->config-...
php
{ "resource": "" }
q259674
Toastr.add
test
public function add($type, $message, $title = null,$options = array()) { $allowedTypes = array('error', 'info', 'success', 'warning'); if(!in_array($type, $allowedTypes)) return false; $this->notifications[] = array( 'type' => $type, 'title' => $title, 'messa...
php
{ "resource": "" }
q259675
Job.link
test
public function link($origin, $destination) { $delivery = new Delivery($origin, $destination); $this->deliveries[] = $delivery; return $delivery; }
php
{ "resource": "" }
q259676
JobToJson.convert
test
public static function convert($job) { $result = array( 'job' => array() ); if ($job->getTransportType() !== null) { $result['job']['transport_type'] = $job->getTransportType(); } if ($job->getAssignmentCode() !== null) { $result['job']['...
php
{ "resource": "" }
q259677
JsonToJob.convert
test
public static function convert($json) { $body = json_decode($json); $job = new Job(); $job->setId($body->id); $job->setTransportType(isset($body->transport_type) ? $body->transport_type : null); $job->setAssignmentCode(isset($body->assignment_code) ? $body->assignment_code :...
php
{ "resource": "" }
q259678
BasicServer.free
test
protected function free(\Throwable $exception = null) { $this->poll->free(); while (!$this->queue->isEmpty()) { /** @var \Icicle\Awaitable\Delayed $delayed */ $delayed = $this->queue->shift(); $delayed->reject($exception ?: new ClosedException('The server was une...
php
{ "resource": "" }
q259679
BasicDatagram.free
test
protected function free(Throwable $exception = null) { $this->poll->free(); if (null !== $this->await) { $this->await->free(); } while (!$this->readQueue->isEmpty()) { /** @var \Icicle\Awaitable\Delayed $delayed */ $delayed = $this->readQueue->sh...
php
{ "resource": "" }
q259680
DashboardChart.create
test
public static function create($title = null, $x_label = null, $y_label = null, $chartData = array ()) { self::$instances++; return new DashboardChart($title, $x_label, $y_label, $chartData); }
php
{ "resource": "" }
q259681
DashboardHasManyRelationEditor.handleItem
test
public function handleItem(SS_HTTPRequest $r) { if($r->param('ID') == "new") { $item = Object::create($this->relationClass); } else { $item = DataList::create($this->relationClass)->byID((int) $r->param('ID')); } if($item) { $handler = DashboardHasManyRelationEditor_ItemRequest::create($this->control...
php
{ "resource": "" }
q259682
DashboardHasManyRelationEditor.sort
test
public function sort(SS_HTTPRequest $r) { if($items = $r->getVar('item')) { foreach($items as $position => $id) { if($item = DataList::create($this->relationClass)->byID((int) $id)) { $item->SortOrder = $position; $item->write(); } } return new SS_HTTPResponse("OK"); } }
php
{ "resource": "" }
q259683
DashboardHasManyRelationEditor_ItemRequest.Link
test
public function Link($action = null) { return Controller::join_links($this->editor->Link(),"item",$this->item->ID ? $this->item->ID : "new",$action); }
php
{ "resource": "" }
q259684
DashboardHasManyRelationEditor_ItemRequest.DetailForm
test
public function DetailForm() { $form = Form::create( $this, "DetailForm", Injector::inst()->get($this->editor->relationClass)->getConfiguration(), FieldList::create( FormAction::create('saveDetail',_t('Dashboard.SAVE','Save')) ->setUseButtonTag(true) ->addExtraClass('ss-ui-action-constructiv...
php
{ "resource": "" }
q259685
DashboardHasManyRelationEditor_ItemRequest.saveDetail
test
public function saveDetail($data, $form) { $item = $this->item; if(!$item->exists()) { $item->DashboardPanelID = $this->panel->ID; $sort = DataList::create($item->class)->max("SortOrder"); $item->SortOrder = $sort+1; $item->write(); } $form->saveInto($item); $item->write(); return new SS_HTTPRes...
php
{ "resource": "" }
q259686
DashboardRSSFeedPanel.RSSItems
test
public function RSSItems() { if(!$this->FeedURL) return false; $doc = new DOMDocument(); @$doc->load($this->FeedURL); $items = $doc->getElementsByTagName('item'); $feeds = array (); foreach ($items as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue...
php
{ "resource": "" }
q259687
DashboardRecentEditsPanel.RecentEdits
test
public function RecentEdits() { $records = SiteTree::get()->sort("LastEdited DESC")->limit($this->Count); $set = ArrayList::create(array()); foreach($records as $r) { $set->push(ArrayData::create(array( 'EditLink' => Injector::inst()->get("CMSPagesController")->Link("edit/show/{$r->ID}"), 'Title' => $r...
php
{ "resource": "" }
q259688
DashboardMember.onAfterWrite
test
public function onAfterWrite() { if(!$this->owner->HasConfiguredDashboard && !$this->owner->DashboardPanels()->exists()) { foreach(SiteConfig::current_site_config()->DashboardPanels() as $p) { $clone = $p->duplicate(); $clone->SiteConfigID = 0; $clone->MemberID = $this->owner->ID; $clone->write(); ...
php
{ "resource": "" }
q259689
DashboardGridFieldPanel.getTemplate
test
protected function getTemplate() { $templateName = get_class($this) . '_' . $this->SubjectPage()->ClassName . '_' . $this->GridFieldName; if(SS_TemplateLoader::instance()->findTemplates($templateName)) { return $templateName; } return parent::getTemplate(); }
php
{ "resource": "" }
q259690
DashboardGridFieldPanel.ViewAllLink
test
public function ViewAllLink() { if($grid = $this->getGrid()) { return Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"), "show", $this->SubjectPageID )."#Root_".$this->getTabForGrid(); } }
php
{ "resource": "" }
q259691
DashboardGridFieldPanel.CreateModelLink
test
public function CreateModelLink() { if($grid = $this->getGrid()) { return Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"), "EditForm", "field", $this->GridFieldName, "item", "new", "?ID={$this->SubjectPageID}" ); } }
php
{ "resource": "" }
q259692
DashboardGridFieldPanel.getGridFieldsFor
test
public function getGridFieldsFor(SiteTree $page) { $grids = array (); if(!$page || !$page->exists()) return $grids; foreach($page->getCMSFields()->dataFields() as $field) { if($field instanceof GridField) { $grids[$field->getName()] = $field->Title(); } } if(empty($grids)) { return array( ''...
php
{ "resource": "" }
q259693
DashboardGridFieldPanel.getGrid
test
protected function getGrid() { if($this->SubjectPage()->exists() && $this->GridFieldName) { if($grid = $this->SubjectPage()->getCMSFields()->dataFieldByName($this->GridFieldName)) { $grid->setForm($this->Form()); return $grid; } } }
php
{ "resource": "" }
q259694
DashboardGridFieldPanel.getTabForGrid
test
protected function getTabForGrid() { if(!$this->SubjectPage()->exists() || !$this->GridFieldName) return false; $fields = $this->SubjectPage()->getCMSFields(); if($fields->hasTabSet()) { foreach($fields->fieldByName("Root")->Tabs() as $tab) { if($tab->fieldByName($this->GridFieldName)) { return $tab->...
php
{ "resource": "" }
q259695
DashboardGridFieldPanel.GridFieldItems
test
public function GridFieldItems() { if($grid = $this->getGrid()) { $list = $grid->getList() ->limit($this->Count) ->sort("LastEdited DESC"); $ret = ArrayList::create(array()); foreach($list as $record) { $record->EditLink = Controller::join_links( Injector::inst()->get("CMSMain")->Link("edit"...
php
{ "resource": "" }
q259696
DashboardGridField_PanelRequest.gridsforpage
test
public function gridsforpage(SS_HTTPRequest $r) { $pageid = (int) $r->requestVar('pageid'); return Convert::array2json($this->panel->getGridFieldsFor(SiteTree::get()->byID($pageid))); }
php
{ "resource": "" }
q259697
gapi.requestAccountData
test
public function requestAccountData($start_index=1, $max_results=1000) { $get_variables = array( 'start-index' => $start_index, 'max-results' => $max_results, ); $url = new gapiRequest(gapi::account_data_url); $response = $url->get($get_variables, $this->auth_method->generateAuthHeader()); ...
php
{ "resource": "" }
q259698
gapi.cleanErrorResponse
test
private function cleanErrorResponse($error) { if (strpos($error, '<html') !== false) { $error = preg_replace('/<(style|title|script)[^>]*>[^<]*<\/(style|title|script)>/i', '', $error); return trim(preg_replace('/\s+/', ' ', strip_tags($error))); } else { $json = json_decode($error); ...
php
{ "resource": "" }
q259699
gapi.processFilter
test
protected function processFilter($filter) { $valid_operators = '(!~|=~|==|!=|>|<|>=|<=|=@|!@)'; $filter = preg_replace('/\s\s+/', ' ', trim($filter)); //Clean duplicate whitespace $filter = str_replace(array(',', ';'), array('\,', '\;'), $filter); //Escape Google Analytics reserved characters $filter =...
php
{ "resource": "" }