id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
42,800
TCB13/thunder-tus-php
src/Server.php
Server.setUploadDir
public function setUploadDir(string $uploadDir): Server { $uploadDir = \realpath($uploadDir); if (!is_dir($uploadDir)) throw new ThunderTUSException("Invalid upload directory. Path doesn't exist or it isn't a directory."); $this->uploadDir = $uploadDir; return $this; }
php
public function setUploadDir(string $uploadDir): Server { $uploadDir = \realpath($uploadDir); if (!is_dir($uploadDir)) throw new ThunderTUSException("Invalid upload directory. Path doesn't exist or it isn't a directory."); $this->uploadDir = $uploadDir; return $this; }
[ "public", "function", "setUploadDir", "(", "string", "$", "uploadDir", ")", ":", "Server", "{", "$", "uploadDir", "=", "\\", "realpath", "(", "$", "uploadDir", ")", ";", "if", "(", "!", "is_dir", "(", "$", "uploadDir", ")", ")", "throw", "new", "Thunde...
Set the directory where Thunder-TUS should save uploads. @param string $uploadDir @return \ThunderTUS\Server @throws \ThunderTUS\ThunderTUSException
[ "Set", "the", "directory", "where", "Thunder", "-", "TUS", "should", "save", "uploads", "." ]
a6a8782407d4e03475e4e8fce24902509b8f4f9d
https://github.com/TCB13/thunder-tus-php/blob/a6a8782407d4e03475e4e8fce24902509b8f4f9d/src/Server.php#L394-L404
42,801
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.getConfiguration
public static function getConfiguration() { if (is_null(self::$_configuration)) { self::$_configuration = new stdClass(); self::$_configuration->trigger = 'never'; self::$_configuration->filters = new stdClass(); $file = BP . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'aoe_profiler.xml'; if (is_file($file)) { $conf = simplexml_load_file($file); if ($conf !== false) { self::$_configuration->trigger = (string)$conf->aoe_profiler->trigger; self::$_configuration->captureModelInfo = (bool)(string)$conf->aoe_profiler->captureModelInfo; self::$_configuration->captureBacktraces = (bool)(string)$conf->aoe_profiler->captureBacktraces; self::$_configuration->enableFilters = (bool)(string)$conf->aoe_profiler->enableFilters; if (self::$_configuration->enableFilters) { self::$_configuration->filters->sampling = (float)$conf->aoe_profiler->filters->sampling; self::$_configuration->filters->timeThreshold = (int)$conf->aoe_profiler->filters->timeThreshold; self::$_configuration->filters->memoryThreshold = (int)$conf->aoe_profiler->filters->memoryThreshold; self::$_configuration->filters->requestUriWhiteList = (string)$conf->aoe_profiler->filters->requestUriWhiteList; self::$_configuration->filters->requestUriBlackList = (string)$conf->aoe_profiler->filters->requestUriBlackList; } } } } return self::$_configuration; }
php
public static function getConfiguration() { if (is_null(self::$_configuration)) { self::$_configuration = new stdClass(); self::$_configuration->trigger = 'never'; self::$_configuration->filters = new stdClass(); $file = BP . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'aoe_profiler.xml'; if (is_file($file)) { $conf = simplexml_load_file($file); if ($conf !== false) { self::$_configuration->trigger = (string)$conf->aoe_profiler->trigger; self::$_configuration->captureModelInfo = (bool)(string)$conf->aoe_profiler->captureModelInfo; self::$_configuration->captureBacktraces = (bool)(string)$conf->aoe_profiler->captureBacktraces; self::$_configuration->enableFilters = (bool)(string)$conf->aoe_profiler->enableFilters; if (self::$_configuration->enableFilters) { self::$_configuration->filters->sampling = (float)$conf->aoe_profiler->filters->sampling; self::$_configuration->filters->timeThreshold = (int)$conf->aoe_profiler->filters->timeThreshold; self::$_configuration->filters->memoryThreshold = (int)$conf->aoe_profiler->filters->memoryThreshold; self::$_configuration->filters->requestUriWhiteList = (string)$conf->aoe_profiler->filters->requestUriWhiteList; self::$_configuration->filters->requestUriBlackList = (string)$conf->aoe_profiler->filters->requestUriBlackList; } } } } return self::$_configuration; }
[ "public", "static", "function", "getConfiguration", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "_configuration", ")", ")", "{", "self", "::", "$", "_configuration", "=", "new", "stdClass", "(", ")", ";", "self", "::", "$", "_configurati...
Get configuration object @return stdClass
[ "Get", "configuration", "object" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L46-L72
42,802
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.isEnabled
public static function isEnabled() { if (!self::$_checkedEnabled) { self::$_checkedEnabled = true; $conf = self::getConfiguration(); $enabled = false; if (strtolower($conf->trigger) == 'always') { $enabled = true; } elseif (strtolower($conf->trigger) == 'parameter') { if ((isset($_GET['profile']) && $_GET['profile'] == true) || (isset($_COOKIE['profile']) && $_COOKIE['profile'] == true)) { $enabled = true; } } // Process filters if ($enabled && $conf->enableFilters) { // sampling filter if ($enabled && rand(0,100000) > $conf->filters->sampling * 1000) { $enabled = false; } // request uri whitelist/blacklist $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; // TODO: use script name instead for cli? if ($enabled && $conf->filters->requestUriWhiteList && !preg_match($conf->filters->requestUriWhiteList, $requestUri)) { $enabled = false; } if ($enabled && $conf->filters->requestUriBlackList && preg_match($conf->filters->requestUriBlackList, $requestUri)) { $enabled = false; } // note: timeThreshold and memoryThreshold will be checked before persisting records. In these cases data will still be recorded during the request } if ($enabled) { self::enable(); } } return self::$_enabled; }
php
public static function isEnabled() { if (!self::$_checkedEnabled) { self::$_checkedEnabled = true; $conf = self::getConfiguration(); $enabled = false; if (strtolower($conf->trigger) == 'always') { $enabled = true; } elseif (strtolower($conf->trigger) == 'parameter') { if ((isset($_GET['profile']) && $_GET['profile'] == true) || (isset($_COOKIE['profile']) && $_COOKIE['profile'] == true)) { $enabled = true; } } // Process filters if ($enabled && $conf->enableFilters) { // sampling filter if ($enabled && rand(0,100000) > $conf->filters->sampling * 1000) { $enabled = false; } // request uri whitelist/blacklist $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; // TODO: use script name instead for cli? if ($enabled && $conf->filters->requestUriWhiteList && !preg_match($conf->filters->requestUriWhiteList, $requestUri)) { $enabled = false; } if ($enabled && $conf->filters->requestUriBlackList && preg_match($conf->filters->requestUriBlackList, $requestUri)) { $enabled = false; } // note: timeThreshold and memoryThreshold will be checked before persisting records. In these cases data will still be recorded during the request } if ($enabled) { self::enable(); } } return self::$_enabled; }
[ "public", "static", "function", "isEnabled", "(", ")", "{", "if", "(", "!", "self", "::", "$", "_checkedEnabled", ")", "{", "self", "::", "$", "_checkedEnabled", "=", "true", ";", "$", "conf", "=", "self", "::", "getConfiguration", "(", ")", ";", "$", ...
Check if profiler is enabled. @static @return bool
[ "Check", "if", "profiler", "is", "enabled", "." ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L106-L147
42,803
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.start
public static function start($name, $type = '') { if (!self::isEnabled()) { return; } $currentPointer = 'timetracker_' . self::$uniqueCounter++; array_push(self::$currentPointerStack, $currentPointer); array_push(self::$stack, $name); self::$stackLevel++; self::$stackLevelMax[] = self::$stackLevel; self::$stackLog[$currentPointer] = array( 'level' => self::$stackLevel, 'stack' => self::$stack, 'time_start' => microtime(true), 'realmem_start' => memory_get_usage(true), // 'emalloc_start' => memory_get_usage(false), 'type' => $type, ); if ($name == '__EAV_LOAD_MODEL__' && !empty(self::getConfiguration()->captureModelInfo)) { $trace = debug_backtrace(); $className = get_class($trace[1]['args'][0]); $entityId = isset($trace[1]['args'][1]) ? $trace[1]['args'][1] : 'not set'; $attributes = isset($trace[1]['args'][2]) ? $trace[1]['args'][2] : null; self::$stackLog[$currentPointer]['detail'] = "$className, id: $entityId, attributes: " . var_export($attributes, true); } if (!empty(self::getConfiguration()->captureBacktraces)) { $trace = isset($trace) ? $trace : debug_backtrace(); $fileAndLine = self::getFileAndLine($trace, $type, $name); self::$stackLog[$currentPointer]['file'] = $fileAndLine['file']; self::$stackLog[$currentPointer]['line'] = $fileAndLine['line']; } }
php
public static function start($name, $type = '') { if (!self::isEnabled()) { return; } $currentPointer = 'timetracker_' . self::$uniqueCounter++; array_push(self::$currentPointerStack, $currentPointer); array_push(self::$stack, $name); self::$stackLevel++; self::$stackLevelMax[] = self::$stackLevel; self::$stackLog[$currentPointer] = array( 'level' => self::$stackLevel, 'stack' => self::$stack, 'time_start' => microtime(true), 'realmem_start' => memory_get_usage(true), // 'emalloc_start' => memory_get_usage(false), 'type' => $type, ); if ($name == '__EAV_LOAD_MODEL__' && !empty(self::getConfiguration()->captureModelInfo)) { $trace = debug_backtrace(); $className = get_class($trace[1]['args'][0]); $entityId = isset($trace[1]['args'][1]) ? $trace[1]['args'][1] : 'not set'; $attributes = isset($trace[1]['args'][2]) ? $trace[1]['args'][2] : null; self::$stackLog[$currentPointer]['detail'] = "$className, id: $entityId, attributes: " . var_export($attributes, true); } if (!empty(self::getConfiguration()->captureBacktraces)) { $trace = isset($trace) ? $trace : debug_backtrace(); $fileAndLine = self::getFileAndLine($trace, $type, $name); self::$stackLog[$currentPointer]['file'] = $fileAndLine['file']; self::$stackLog[$currentPointer]['line'] = $fileAndLine['line']; } }
[ "public", "static", "function", "start", "(", "$", "name", ",", "$", "type", "=", "''", ")", "{", "if", "(", "!", "self", "::", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "currentPointer", "=", "'timetracker_'", ".", "self", "::", "$...
Pushes to the stack @param string $name @param string $type @return void
[ "Pushes", "to", "the", "stack" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L156-L193
42,804
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.getLineNumber
public static function getLineNumber($file, $regex) { $i = 0; $lineFound = false; $handle = @fopen($file, 'r'); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { $i++; if (preg_match($regex, $buffer)) { $lineFound = true; break; } } fclose($handle); } return $lineFound ? $i : false; }
php
public static function getLineNumber($file, $regex) { $i = 0; $lineFound = false; $handle = @fopen($file, 'r'); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { $i++; if (preg_match($regex, $buffer)) { $lineFound = true; break; } } fclose($handle); } return $lineFound ? $i : false; }
[ "public", "static", "function", "getLineNumber", "(", "$", "file", ",", "$", "regex", ")", "{", "$", "i", "=", "0", ";", "$", "lineFound", "=", "false", ";", "$", "handle", "=", "@", "fopen", "(", "$", "file", ",", "'r'", ")", ";", "if", "(", "...
Get the line number of the first line in a file matching a given regex Not the nicest solution, but probably the fastest @param $file @param $regex @return bool|int
[ "Get", "the", "line", "number", "of", "the", "first", "line", "in", "a", "file", "matching", "a", "given", "regex", "Not", "the", "nicest", "solution", "but", "probably", "the", "fastest" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L324-L340
42,805
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.stop
public static function stop($name) { if (!self::isEnabled()) { return; } $currentName = end(self::$stack); if ($currentName != $name) { if (Mage::getStoreConfigFlag('dev/debug/logInvalidNesting')) { Mage::log('[INVALID NESTING!] Found: ' . $name . " | Expecting: $currentName"); } if (in_array($name, self::$stack)) { // trying to stop something that has been started before, // but there are other unstopped stack items // -> auto-stop them while (($latestStackItem = end(self::$stack)) != $name) { if (Mage::getStoreConfigFlag('dev/debug/logInvalidNesting')) { Mage::log('Auto-stopping timer "' . $latestStackItem . '" because of incorrect nesting'); } self::stop($latestStackItem); } } else { // trying to stop something that hasn't been started before -> just ignore return; } // We shouldn't add another name to the stack if we've already crawled up to the current one... // $name = '[INVALID NESTING!] ' . $name; // self::start($name); // return; // throw new Exception(sprintf("Invalid nesting! Expected: '%s', was: '%s'", $currentName, $name)); } $currentPointer = end(self::$currentPointerStack); self::$stackLog[$currentPointer]['time_end'] = microtime(true); self::$stackLog[$currentPointer]['realmem_end'] = memory_get_usage(true); // self::$stackLog[$currentPointer]['emalloc_end'] = memory_get_usage(false); // TODO: introduce configurable threshold if (self::$_logCallStack !== false) { self::$stackLog[$currentPointer]['callstack'] = Varien_Debug::backtrace(true, false); } self::$stackLevel--; array_pop(self::$stack); array_pop(self::$currentPointerStack); }
php
public static function stop($name) { if (!self::isEnabled()) { return; } $currentName = end(self::$stack); if ($currentName != $name) { if (Mage::getStoreConfigFlag('dev/debug/logInvalidNesting')) { Mage::log('[INVALID NESTING!] Found: ' . $name . " | Expecting: $currentName"); } if (in_array($name, self::$stack)) { // trying to stop something that has been started before, // but there are other unstopped stack items // -> auto-stop them while (($latestStackItem = end(self::$stack)) != $name) { if (Mage::getStoreConfigFlag('dev/debug/logInvalidNesting')) { Mage::log('Auto-stopping timer "' . $latestStackItem . '" because of incorrect nesting'); } self::stop($latestStackItem); } } else { // trying to stop something that hasn't been started before -> just ignore return; } // We shouldn't add another name to the stack if we've already crawled up to the current one... // $name = '[INVALID NESTING!] ' . $name; // self::start($name); // return; // throw new Exception(sprintf("Invalid nesting! Expected: '%s', was: '%s'", $currentName, $name)); } $currentPointer = end(self::$currentPointerStack); self::$stackLog[$currentPointer]['time_end'] = microtime(true); self::$stackLog[$currentPointer]['realmem_end'] = memory_get_usage(true); // self::$stackLog[$currentPointer]['emalloc_end'] = memory_get_usage(false); // TODO: introduce configurable threshold if (self::$_logCallStack !== false) { self::$stackLog[$currentPointer]['callstack'] = Varien_Debug::backtrace(true, false); } self::$stackLevel--; array_pop(self::$stack); array_pop(self::$currentPointerStack); }
[ "public", "static", "function", "stop", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "currentName", "=", "end", "(", "self", "::", "$", "stack", ")", ";", "if", "(", "$", "c...
Pull element from stack @param string $name @throws Exception @return void
[ "Pull", "element", "from", "stack" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L378-L426
42,806
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.addData
public static function addData($data, $key = NULL) { $currentPointer = end(self::$currentPointerStack); if (!isset(self::$stackLog[$currentPointer]['messages'])) { self::$stackLog[$currentPointer]['messages'] = array(); } if (is_null($key)) { self::$stackLog[$currentPointer]['messages'][] = $data; } else { self::$stackLog[$currentPointer]['messages'][$key] = $data; } }
php
public static function addData($data, $key = NULL) { $currentPointer = end(self::$currentPointerStack); if (!isset(self::$stackLog[$currentPointer]['messages'])) { self::$stackLog[$currentPointer]['messages'] = array(); } if (is_null($key)) { self::$stackLog[$currentPointer]['messages'][] = $data; } else { self::$stackLog[$currentPointer]['messages'][$key] = $data; } }
[ "public", "static", "function", "addData", "(", "$", "data", ",", "$", "key", "=", "NULL", ")", "{", "$", "currentPointer", "=", "end", "(", "self", "::", "$", "currentPointerStack", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "stackLo...
Add data to the current stack @param $data @param null $key
[ "Add", "data", "to", "the", "current", "stack" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L434-L445
42,807
AOEpeople/Aoe_Profiler
app/code/community/Varien/Profiler.php
Varien_Profiler.calculate
public static function calculate() { foreach (self::$stackLog as &$data) { foreach (array('time', 'realmem' /* , 'emalloc' */) as $metric) { $data[$metric . '_end_relative'] = $data[$metric . '_end'] - self::$startValues[$metric]; $data[$metric . '_start_relative'] = $data[$metric . '_start'] - self::$startValues[$metric]; $data[$metric . '_total'] = $data[$metric . '_end_relative'] - $data[$metric . '_start_relative']; } } }
php
public static function calculate() { foreach (self::$stackLog as &$data) { foreach (array('time', 'realmem' /* , 'emalloc' */) as $metric) { $data[$metric . '_end_relative'] = $data[$metric . '_end'] - self::$startValues[$metric]; $data[$metric . '_start_relative'] = $data[$metric . '_start'] - self::$startValues[$metric]; $data[$metric . '_total'] = $data[$metric . '_end_relative'] - $data[$metric . '_start_relative']; } } }
[ "public", "static", "function", "calculate", "(", ")", "{", "foreach", "(", "self", "::", "$", "stackLog", "as", "&", "$", "data", ")", "{", "foreach", "(", "array", "(", "'time'", ",", "'realmem'", "/* , 'emalloc' */", ")", "as", "$", "metric", ")", "...
Calculate relative data @return void
[ "Calculate", "relative", "data" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Varien/Profiler.php#L512-L521
42,808
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php
Aoe_Profiler_Adminhtml_ProfilerController._initAction
protected function _initAction() { $this->loadLayout() ->_setActiveMenu('system/aoe_profiler') ->_addBreadcrumb(Mage::helper('aoe_profiler')->__('System'), Mage::helper('aoe_profiler')->__('System')) ->_addBreadcrumb(Mage::helper('aoe_profiler')->__('AOE Profiler'), Mage::helper('aoe_profiler')->__('AOE Profiler')); return $this; }
php
protected function _initAction() { $this->loadLayout() ->_setActiveMenu('system/aoe_profiler') ->_addBreadcrumb(Mage::helper('aoe_profiler')->__('System'), Mage::helper('aoe_profiler')->__('System')) ->_addBreadcrumb(Mage::helper('aoe_profiler')->__('AOE Profiler'), Mage::helper('aoe_profiler')->__('AOE Profiler')); return $this; }
[ "protected", "function", "_initAction", "(", ")", "{", "$", "this", "->", "loadLayout", "(", ")", "->", "_setActiveMenu", "(", "'system/aoe_profiler'", ")", "->", "_addBreadcrumb", "(", "Mage", "::", "helper", "(", "'aoe_profiler'", ")", "->", "__", "(", "'S...
Load layout, set active menu and breadcrumbs @return $this
[ "Load", "layout", "set", "active", "menu", "and", "breadcrumbs" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php#L16-L25
42,809
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php
Aoe_Profiler_Adminhtml_ProfilerController._initStackInstance
protected function _initStackInstance() { $this->_title($this->__('System'))->_title($this->__('AOE Profiler')); $stackId = $this->getRequest()->getParam('stack_id', null); if ($stackId) { $stackInstance = Mage::getModel('aoe_profiler/run'); /* @var $stackInstance Aoe_Profiler_Model_Run */ $stackInstance->load($stackId); if (!$stackInstance->getId()) { $this->_getSession()->addError(Mage::helper('aoe_profiler')->__('No data found with this id.')); return false; } Mage::register('current_stack_instance', $stackInstance); return $stackInstance; } return false; }
php
protected function _initStackInstance() { $this->_title($this->__('System'))->_title($this->__('AOE Profiler')); $stackId = $this->getRequest()->getParam('stack_id', null); if ($stackId) { $stackInstance = Mage::getModel('aoe_profiler/run'); /* @var $stackInstance Aoe_Profiler_Model_Run */ $stackInstance->load($stackId); if (!$stackInstance->getId()) { $this->_getSession()->addError(Mage::helper('aoe_profiler')->__('No data found with this id.')); return false; } Mage::register('current_stack_instance', $stackInstance); return $stackInstance; } return false; }
[ "protected", "function", "_initStackInstance", "(", ")", "{", "$", "this", "->", "_title", "(", "$", "this", "->", "__", "(", "'System'", ")", ")", "->", "_title", "(", "$", "this", "->", "__", "(", "'AOE Profiler'", ")", ")", ";", "$", "stackId", "=...
Init stack instance object and set it to registry @return Aoe_Profiler_Model_Run|false
[ "Init", "stack", "instance", "object", "and", "set", "it", "to", "registry" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php#L32-L49
42,810
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php
Aoe_Profiler_Adminhtml_ProfilerController.deleteAction
public function deleteAction() { try { $stack = $this->_initStackInstance(); if ($stack) { $stack->delete(); $this->_getSession()->addSuccess( $this->__( 'The entry has been deleted.' ) ); } } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); } $this->_redirect('*/*/'); }
php
public function deleteAction() { try { $stack = $this->_initStackInstance(); if ($stack) { $stack->delete(); $this->_getSession()->addSuccess( $this->__( 'The entry has been deleted.' ) ); } } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); } $this->_redirect('*/*/'); }
[ "public", "function", "deleteAction", "(", ")", "{", "try", "{", "$", "stack", "=", "$", "this", "->", "_initStackInstance", "(", ")", ";", "if", "(", "$", "stack", ")", "{", "$", "stack", "->", "delete", "(", ")", ";", "$", "this", "->", "_getSess...
Delete the selected stack instance. @return void
[ "Delete", "the", "selected", "stack", "instance", "." ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php#L57-L70
42,811
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php
Aoe_Profiler_Adminhtml_ProfilerController.viewAction
public function viewAction() { $stack = $this->_initStackInstance(); if (!$stack) { $this->_redirect('*/*/'); return; } $this->_initAction(); $this->renderLayout(); }
php
public function viewAction() { $stack = $this->_initStackInstance(); if (!$stack) { $this->_redirect('*/*/'); return; } $this->_initAction(); $this->renderLayout(); }
[ "public", "function", "viewAction", "(", ")", "{", "$", "stack", "=", "$", "this", "->", "_initStackInstance", "(", ")", ";", "if", "(", "!", "$", "stack", ")", "{", "$", "this", "->", "_redirect", "(", "'*/*/'", ")", ";", "return", ";", "}", "$", ...
Edit layout instance action
[ "Edit", "layout", "instance", "action" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/controllers/Adminhtml/ProfilerController.php#L122-L131
42,812
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/Model/Run.php
Aoe_Profiler_Model_Run.calcRelativeValues
protected function calcRelativeValues() { foreach ($this->stackLog as $key => $value) { foreach ($this->metrics as $metric) { foreach (array('own', 'sub', 'total') as $column) { if (!isset($this->stackLog[$key][$metric . '_' . $column])) { continue; } $this->stackLog[$key][$metric . '_rel_' . $column] = $this->stackLog[$key][$metric . '_' . $column] / $this->stackLog['timetracker_0'][$metric . '_total']; } $this->stackLog[$key][$metric . '_rel_offset'] = $this->stackLog[$key][$metric . '_start_relative'] / $this->stackLog['timetracker_0'][$metric . '_total']; } } }
php
protected function calcRelativeValues() { foreach ($this->stackLog as $key => $value) { foreach ($this->metrics as $metric) { foreach (array('own', 'sub', 'total') as $column) { if (!isset($this->stackLog[$key][$metric . '_' . $column])) { continue; } $this->stackLog[$key][$metric . '_rel_' . $column] = $this->stackLog[$key][$metric . '_' . $column] / $this->stackLog['timetracker_0'][$metric . '_total']; } $this->stackLog[$key][$metric . '_rel_offset'] = $this->stackLog[$key][$metric . '_start_relative'] / $this->stackLog['timetracker_0'][$metric . '_total']; } } }
[ "protected", "function", "calcRelativeValues", "(", ")", "{", "foreach", "(", "$", "this", "->", "stackLog", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "metrics", "as", "$", "metric", ")", "{", "foreach", "(", ...
Calculate relative values
[ "Calculate", "relative", "values" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/Model/Run.php#L127-L140
42,813
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/Model/Run.php
Aoe_Profiler_Model_Run._beforeSave
protected function _beforeSave() { $date = Mage::getModel('core/date')->gmtDate(); if ($this->isObjectNew() && !$this->getCreatedAt()) { $this->setCreatedAt($date); } $this->setStackData(serialize($this->stackLog)); return parent::_beforeSave(); }
php
protected function _beforeSave() { $date = Mage::getModel('core/date')->gmtDate(); if ($this->isObjectNew() && !$this->getCreatedAt()) { $this->setCreatedAt($date); } $this->setStackData(serialize($this->stackLog)); return parent::_beforeSave(); }
[ "protected", "function", "_beforeSave", "(", ")", "{", "$", "date", "=", "Mage", "::", "getModel", "(", "'core/date'", ")", "->", "gmtDate", "(", ")", ";", "if", "(", "$", "this", "->", "isObjectNew", "(", ")", "&&", "!", "$", "this", "->", "getCreat...
Before saving... @return Mage_Core_Model_Abstract
[ "Before", "saving", "..." ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/Model/Run.php#L169-L177
42,814
AOEpeople/Aoe_Profiler
app/code/community/Aoe/Profiler/Block/Tree.php
Aoe_Profiler_Block_Tree.renderProgressBar
protected function renderProgressBar($percent1, $percent2 = 0, $offset = 0) { $percent1 = round(max(1, $percent1)); $offset = round(max(0, $offset)); $offset = round(min(99, $offset)); $output = '<div class="progress">'; $output .= '<div class="progress-bar">'; $output .= '<div class="progress-bar1" style="width: ' . $percent1 . '%; margin-left: ' . $offset . '%;"></div>'; if ($percent2 > 0) { $percent2 = round(max(1, $percent2)); if ($percent1 + $percent2 + $offset > 100) { // preventing line break in css progress bar if widths and margins are bigger than 100% $percent2 = 100 - $percent1 - $offset; $percent2 = max(0, $percent2); } $output .= '<div class="progress-bar2" style="width: ' . $percent2 . '%"></div>'; } $output .= '</div>'; $output .= '</div>'; return $output; }
php
protected function renderProgressBar($percent1, $percent2 = 0, $offset = 0) { $percent1 = round(max(1, $percent1)); $offset = round(max(0, $offset)); $offset = round(min(99, $offset)); $output = '<div class="progress">'; $output .= '<div class="progress-bar">'; $output .= '<div class="progress-bar1" style="width: ' . $percent1 . '%; margin-left: ' . $offset . '%;"></div>'; if ($percent2 > 0) { $percent2 = round(max(1, $percent2)); if ($percent1 + $percent2 + $offset > 100) { // preventing line break in css progress bar if widths and margins are bigger than 100% $percent2 = 100 - $percent1 - $offset; $percent2 = max(0, $percent2); } $output .= '<div class="progress-bar2" style="width: ' . $percent2 . '%"></div>'; } $output .= '</div>'; $output .= '</div>'; return $output; }
[ "protected", "function", "renderProgressBar", "(", "$", "percent1", ",", "$", "percent2", "=", "0", ",", "$", "offset", "=", "0", ")", "{", "$", "percent1", "=", "round", "(", "max", "(", "1", ",", "$", "percent1", ")", ")", ";", "$", "offset", "="...
Render css progress bar @param $percent1 @param int $percent2 @param int $offset @return string
[ "Render", "css", "progress", "bar" ]
dd9fdf94879e687c2bb5140229910450c46e8f7f
https://github.com/AOEpeople/Aoe_Profiler/blob/dd9fdf94879e687c2bb5140229910450c46e8f7f/app/code/community/Aoe/Profiler/Block/Tree.php#L219-L242
42,815
silverstripe/silverstripe-asset-admin
code/Forms/RemoteFileFormFactory.php
RemoteFileFormFactory.getCreateFormFields
protected function getCreateFormFields() { return FieldList::create([ TextField::create( 'Url', 'Embed URL' ) ->setInputType('url') ->addExtraClass('insert-embed-modal__url-create') ->setDescription(_t( __CLASS__.'.UrlDescription', 'Embed Youtube and Vimeo videos, images and other media directly from the web.' )), ]); }
php
protected function getCreateFormFields() { return FieldList::create([ TextField::create( 'Url', 'Embed URL' ) ->setInputType('url') ->addExtraClass('insert-embed-modal__url-create') ->setDescription(_t( __CLASS__.'.UrlDescription', 'Embed Youtube and Vimeo videos, images and other media directly from the web.' )), ]); }
[ "protected", "function", "getCreateFormFields", "(", ")", "{", "return", "FieldList", "::", "create", "(", "[", "TextField", "::", "create", "(", "'Url'", ",", "'Embed URL'", ")", "->", "setInputType", "(", "'url'", ")", "->", "addExtraClass", "(", "'insert-em...
Get form fields for create new embed @return FieldList
[ "Get", "form", "fields", "for", "create", "new", "embed" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/RemoteFileFormFactory.php#L202-L216
42,816
silverstripe/silverstripe-asset-admin
code/Forms/RemoteFileFormFactory.php
RemoteFileFormFactory.getEditFormFields
protected function getEditFormFields($context) { // Check if the url is valid $url = (isset($context['url'])) ? $context['url'] : null; if (empty($url)) { return $this->getCreateFormFields(); } $url = trim($url); // Get embed $this->validateUrl($url); /** @var Embeddable $embed */ $embed = Injector::inst()->create(Embeddable::class, $url); $this->validateEmbed($embed); // Build form $alignments = array( 'leftAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeftAlone', 'Left'), 'center' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentCenter', 'Center'), 'rightAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRightAlone', 'Right'), 'left' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeft', 'Left wrap'), 'right' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRight', 'Right wrap'), ); $width = $embed->getWidth(); $height = $embed->getHeight(); $fields = CompositeField::create([ LiteralField::create( 'Preview', sprintf( '<img src="%s" class="%s" />', $embed->getPreviewURL(), 'insert-embed-modal__preview' ) )->addExtraClass('insert-embed-modal__preview-container'), HiddenField::create('PreviewUrl', 'PreviewUrl', $embed->getPreviewURL()), CompositeField::create([ TextField::create('UrlPreview', $embed->getName(), $url) ->setReadonly(true), HiddenField::create('Url', false, $url), TextField::create( 'CaptionText', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption') ), OptionsetField::create( 'Placement', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Placement', 'Placement'), $alignments ) ->addExtraClass('insert-embed-modal__placement'), $dimensions = FieldGroup::create( _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageSpecs', 'Dimensions'), TextField::create('Width', '', $width) ->setRightTitle(_t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageWidth', 'Width' )) ->setMaxLength(5) ->addExtraClass('flexbox-area-grow'), TextField::create('Height', '', $height) ->setRightTitle(_t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageHeight', 'Height' )) ->setMaxLength(5) ->addExtraClass('flexbox-area-grow') )->addExtraClass('fieldgroup--fill-width') ->setName('Dimensions') ])->addExtraClass('flexbox-area-grow'), ])->addExtraClass('insert-embed-modal__fields--fill-width'); if ($dimensions && $width && $height) { $ratio = $width / $height; $dimensions->setSchemaComponent('ProportionConstraintField'); $dimensions->setSchemaState([ 'data' => [ 'ratio' => $ratio ] ]); } return FieldList::create($fields); }
php
protected function getEditFormFields($context) { // Check if the url is valid $url = (isset($context['url'])) ? $context['url'] : null; if (empty($url)) { return $this->getCreateFormFields(); } $url = trim($url); // Get embed $this->validateUrl($url); /** @var Embeddable $embed */ $embed = Injector::inst()->create(Embeddable::class, $url); $this->validateEmbed($embed); // Build form $alignments = array( 'leftAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeftAlone', 'Left'), 'center' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentCenter', 'Center'), 'rightAlone' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRightAlone', 'Right'), 'left' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentLeft', 'Left wrap'), 'right' => _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AlignmentRight', 'Right wrap'), ); $width = $embed->getWidth(); $height = $embed->getHeight(); $fields = CompositeField::create([ LiteralField::create( 'Preview', sprintf( '<img src="%s" class="%s" />', $embed->getPreviewURL(), 'insert-embed-modal__preview' ) )->addExtraClass('insert-embed-modal__preview-container'), HiddenField::create('PreviewUrl', 'PreviewUrl', $embed->getPreviewURL()), CompositeField::create([ TextField::create('UrlPreview', $embed->getName(), $url) ->setReadonly(true), HiddenField::create('Url', false, $url), TextField::create( 'CaptionText', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption') ), OptionsetField::create( 'Placement', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Placement', 'Placement'), $alignments ) ->addExtraClass('insert-embed-modal__placement'), $dimensions = FieldGroup::create( _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageSpecs', 'Dimensions'), TextField::create('Width', '', $width) ->setRightTitle(_t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageWidth', 'Width' )) ->setMaxLength(5) ->addExtraClass('flexbox-area-grow'), TextField::create('Height', '', $height) ->setRightTitle(_t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ImageHeight', 'Height' )) ->setMaxLength(5) ->addExtraClass('flexbox-area-grow') )->addExtraClass('fieldgroup--fill-width') ->setName('Dimensions') ])->addExtraClass('flexbox-area-grow'), ])->addExtraClass('insert-embed-modal__fields--fill-width'); if ($dimensions && $width && $height) { $ratio = $width / $height; $dimensions->setSchemaComponent('ProportionConstraintField'); $dimensions->setSchemaState([ 'data' => [ 'ratio' => $ratio ] ]); } return FieldList::create($fields); }
[ "protected", "function", "getEditFormFields", "(", "$", "context", ")", "{", "// Check if the url is valid", "$", "url", "=", "(", "isset", "(", "$", "context", "[", "'url'", "]", ")", ")", "?", "$", "context", "[", "'url'", "]", ":", "null", ";", "if", ...
Get form fields for edit form @param array $context @return FieldList @throws InvalidUrlException
[ "Get", "form", "fields", "for", "edit", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/RemoteFileFormFactory.php#L225-L310
42,817
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getFormFieldTabs
protected function getFormFieldTabs($record, $context = []) { return TabSet::create( 'Editor', [ $this->getFormFieldDetailsTab($record, $context), $this->getFormFieldSecurityTab($record, $context), ] ); }
php
protected function getFormFieldTabs($record, $context = []) { return TabSet::create( 'Editor', [ $this->getFormFieldDetailsTab($record, $context), $this->getFormFieldSecurityTab($record, $context), ] ); }
[ "protected", "function", "getFormFieldTabs", "(", "$", "record", ",", "$", "context", "=", "[", "]", ")", "{", "return", "TabSet", "::", "create", "(", "'Editor'", ",", "[", "$", "this", "->", "getFormFieldDetailsTab", "(", "$", "record", ",", "$", "cont...
Gets the main tabs for the file edit form @param File $record @param array $context @return TabSet
[ "Gets", "the", "main", "tabs", "for", "the", "file", "edit", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L134-L143
42,818
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getDeleteAction
protected function getDeleteAction($record) { // Delete action if ($record && $record->isInDB() && $record->canDelete()) { $deleteText = _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.DELETE_BUTTON', 'Delete'); return FormAction::create('delete', $deleteText) ->setIcon('trash-bin'); } return null; }
php
protected function getDeleteAction($record) { // Delete action if ($record && $record->isInDB() && $record->canDelete()) { $deleteText = _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.DELETE_BUTTON', 'Delete'); return FormAction::create('delete', $deleteText) ->setIcon('trash-bin'); } return null; }
[ "protected", "function", "getDeleteAction", "(", "$", "record", ")", "{", "// Delete action", "if", "(", "$", "record", "&&", "$", "record", "->", "isInDB", "(", ")", "&&", "$", "record", "->", "canDelete", "(", ")", ")", "{", "$", "deleteText", "=", "...
Get delete action, if this record is deletable @param File $record @return FormAction
[ "Get", "delete", "action", "if", "this", "record", "is", "deletable" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L177-L186
42,819
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getPopoverMenu
protected function getPopoverMenu($record) { // Build popover actions $popoverActions = $this->getPopoverActions($record); if ($popoverActions) { return PopoverField::create($popoverActions) ->setPlacement('top') ->setName('PopoverActions') ->setButtonTooltip(_t( 'SilverStripe\\AssetAdmin\\Forms\\FileFormFactory.OTHER_ACTIONS', 'Other actions' )); } return null; }
php
protected function getPopoverMenu($record) { // Build popover actions $popoverActions = $this->getPopoverActions($record); if ($popoverActions) { return PopoverField::create($popoverActions) ->setPlacement('top') ->setName('PopoverActions') ->setButtonTooltip(_t( 'SilverStripe\\AssetAdmin\\Forms\\FileFormFactory.OTHER_ACTIONS', 'Other actions' )); } return null; }
[ "protected", "function", "getPopoverMenu", "(", "$", "record", ")", "{", "// Build popover actions", "$", "popoverActions", "=", "$", "this", "->", "getPopoverActions", "(", "$", "record", ")", ";", "if", "(", "$", "popoverActions", ")", "{", "return", "Popove...
Build popup menu @param File $record @return PopoverField
[ "Build", "popup", "menu" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L253-L267
42,820
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getFormFieldDetailsTab
protected function getFormFieldDetailsTab($record, $context = []) { /** @var Tab $tab */ $tab = Tab::create( 'Details', TextField::create('Name', _t(__CLASS__.'.FILENAME', 'Filename')), $location = TreeDropdownField::create( 'ParentID', _t(__CLASS__.'.FOLDERLOCATION', 'Location'), Folder::class ) ->setShowSelectedPath(true) ); $location ->setEmptyString(_t(__CLASS__.'.ROOTNAME', '(Top level)')) ->setShowSearch(true); return $tab; }
php
protected function getFormFieldDetailsTab($record, $context = []) { /** @var Tab $tab */ $tab = Tab::create( 'Details', TextField::create('Name', _t(__CLASS__.'.FILENAME', 'Filename')), $location = TreeDropdownField::create( 'ParentID', _t(__CLASS__.'.FOLDERLOCATION', 'Location'), Folder::class ) ->setShowSelectedPath(true) ); $location ->setEmptyString(_t(__CLASS__.'.ROOTNAME', '(Top level)')) ->setShowSearch(true); return $tab; }
[ "protected", "function", "getFormFieldDetailsTab", "(", "$", "record", ",", "$", "context", "=", "[", "]", ")", "{", "/** @var Tab $tab */", "$", "tab", "=", "Tab", "::", "create", "(", "'Details'", ",", "TextField", "::", "create", "(", "'Name'", ",", "_t...
Build "details" formfield tab @param File $record @param array $context @return Tab
[ "Build", "details", "formfield", "tab" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L292-L310
42,821
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getPath
protected function getPath($record, $context = []) { if ($record && $record->isInDB()) { if ($record->ParentID) { return $record->Parent()->getFilename(); } else { return '/'; } } if (isset($context['ParentID'])) { if ($context['ParentID'] === 0) { return '/'; } /** @var File $file */ $file = File::get()->byID($context['ParentID']); if ($file) { return $file->getFilename(); } } return null; }
php
protected function getPath($record, $context = []) { if ($record && $record->isInDB()) { if ($record->ParentID) { return $record->Parent()->getFilename(); } else { return '/'; } } if (isset($context['ParentID'])) { if ($context['ParentID'] === 0) { return '/'; } /** @var File $file */ $file = File::get()->byID($context['ParentID']); if ($file) { return $file->getFilename(); } } return null; }
[ "protected", "function", "getPath", "(", "$", "record", ",", "$", "context", "=", "[", "]", ")", "{", "if", "(", "$", "record", "&&", "$", "record", "->", "isInDB", "(", ")", ")", "{", "if", "(", "$", "record", "->", "ParentID", ")", "{", "return...
Get user-visible "Path" for this record @param File $record @param array $context @return string
[ "Get", "user", "-", "visible", "Path", "for", "this", "record" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L319-L339
42,822
silverstripe/silverstripe-asset-admin
code/Forms/AssetFormFactory.php
AssetFormFactory.getFormFieldSecurityTab
protected function getFormFieldSecurityTab($record, $context = []) { // Get permissions $viewersOptionsField = [ 'Inherit' => _t(__CLASS__.'.INHERIT', 'Inherit from parent folder'), 'Anyone' => _t(__CLASS__.'.ANYONE', 'Anyone'), 'LoggedInUsers' => _t(__CLASS__.'.LOGGED_IN', 'Logged-in users'), 'OnlyTheseUsers' => _t(__CLASS__.'.ONLY_GROUPS', 'Only these groups (choose from list)') ]; // No "Anyone" editors option $editorsOptionsField = $viewersOptionsField; unset($editorsOptionsField['Anyone']); return Tab::create( 'Permissions', OptionsetField::create( 'CanViewType', _t(__CLASS__.'.ACCESSHEADER', 'Who can view this file?') ) ->setSource($viewersOptionsField), TreeMultiselectField::create( 'ViewerGroups', _t(__CLASS__.'.VIEWERGROUPS', 'Viewer Groups') ), OptionsetField::create( "CanEditType", _t(__CLASS__.'.EDITHEADER', 'Who can edit this file?') ) ->setSource($editorsOptionsField), TreeMultiselectField::create( 'EditorGroups', _t(__CLASS__.'.EDITORGROUPS', 'Editor Groups') ) ); }
php
protected function getFormFieldSecurityTab($record, $context = []) { // Get permissions $viewersOptionsField = [ 'Inherit' => _t(__CLASS__.'.INHERIT', 'Inherit from parent folder'), 'Anyone' => _t(__CLASS__.'.ANYONE', 'Anyone'), 'LoggedInUsers' => _t(__CLASS__.'.LOGGED_IN', 'Logged-in users'), 'OnlyTheseUsers' => _t(__CLASS__.'.ONLY_GROUPS', 'Only these groups (choose from list)') ]; // No "Anyone" editors option $editorsOptionsField = $viewersOptionsField; unset($editorsOptionsField['Anyone']); return Tab::create( 'Permissions', OptionsetField::create( 'CanViewType', _t(__CLASS__.'.ACCESSHEADER', 'Who can view this file?') ) ->setSource($viewersOptionsField), TreeMultiselectField::create( 'ViewerGroups', _t(__CLASS__.'.VIEWERGROUPS', 'Viewer Groups') ), OptionsetField::create( "CanEditType", _t(__CLASS__.'.EDITHEADER', 'Who can edit this file?') ) ->setSource($editorsOptionsField), TreeMultiselectField::create( 'EditorGroups', _t(__CLASS__.'.EDITORGROUPS', 'Editor Groups') ) ); }
[ "protected", "function", "getFormFieldSecurityTab", "(", "$", "record", ",", "$", "context", "=", "[", "]", ")", "{", "// Get permissions", "$", "viewersOptionsField", "=", "[", "'Inherit'", "=>", "_t", "(", "__CLASS__", ".", "'.INHERIT'", ",", "'Inherit from pa...
Build security tab @param File $record @param array $context @return Tab
[ "Build", "security", "tab" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/AssetFormFactory.php#L348-L383
42,823
silverstripe/silverstripe-asset-admin
code/Forms/UploadField.php
UploadField.getFolderID
protected function getFolderID() { $folderName = $this->getFolderName(); if (!$folderName) { return 0; } $folder = Folder::find_or_make($folderName); return $folder ? $folder->ID : 0; }
php
protected function getFolderID() { $folderName = $this->getFolderName(); if (!$folderName) { return 0; } $folder = Folder::find_or_make($folderName); return $folder ? $folder->ID : 0; }
[ "protected", "function", "getFolderID", "(", ")", "{", "$", "folderName", "=", "$", "this", "->", "getFolderName", "(", ")", ";", "if", "(", "!", "$", "folderName", ")", "{", "return", "0", ";", "}", "$", "folder", "=", "Folder", "::", "find_or_make", ...
Get ID of target parent folder @return int
[ "Get", "ID", "of", "target", "parent", "folder" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/UploadField.php#L185-L193
42,824
silverstripe/silverstripe-asset-admin
code/Forms/UploadField.php
UploadField.getEncodedItems
protected function getEncodedItems() { $assetAdmin = AssetAdmin::singleton(); $fileData = []; foreach ($this->getItems() as $file) { $fileData[] = $assetAdmin->getMinimalistObjectFromData($file); } return $fileData; }
php
protected function getEncodedItems() { $assetAdmin = AssetAdmin::singleton(); $fileData = []; foreach ($this->getItems() as $file) { $fileData[] = $assetAdmin->getMinimalistObjectFromData($file); } return $fileData; }
[ "protected", "function", "getEncodedItems", "(", ")", "{", "$", "assetAdmin", "=", "AssetAdmin", "::", "singleton", "(", ")", ";", "$", "fileData", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getItems", "(", ")", "as", "$", "file", ")", "...
Encode selected values for react @return array
[ "Encode", "selected", "values", "for", "react" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/UploadField.php#L208-L216
42,825
silverstripe/silverstripe-asset-admin
code/Forms/UploadField.php
UploadField.getIsMultiUpload
public function getIsMultiUpload() { if (isset($this->multiUpload)) { return $this->multiUpload; } // Guess from record $record = $this->getRecord(); $name = $this->getName(); // Disabled for has_one components if ($record && DataObject::getSchema()->hasOneComponent(get_class($record), $name)) { return false; } return true; }
php
public function getIsMultiUpload() { if (isset($this->multiUpload)) { return $this->multiUpload; } // Guess from record $record = $this->getRecord(); $name = $this->getName(); // Disabled for has_one components if ($record && DataObject::getSchema()->hasOneComponent(get_class($record), $name)) { return false; } return true; }
[ "public", "function", "getIsMultiUpload", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "multiUpload", ")", ")", "{", "return", "$", "this", "->", "multiUpload", ";", "}", "// Guess from record", "$", "record", "=", "$", "this", "->", "getRe...
Check if allowed to upload more than one file @return bool
[ "Check", "if", "allowed", "to", "upload", "more", "than", "one", "file" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/UploadField.php#L223-L237
42,826
silverstripe/silverstripe-asset-admin
code/Forms/FileFormFactory.php
FileFormFactory.getFormFieldAttributesTab
protected function getFormFieldAttributesTab($record, $context = []) { return Tab::create( 'Placement', LiteralField::create( 'AttributesDescription', '<p>' . _t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AttributesDescription', 'These changes will only affect this particular placement of the file.' ) . '</p>' ), TextField::create('Caption', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption')) ); }
php
protected function getFormFieldAttributesTab($record, $context = []) { return Tab::create( 'Placement', LiteralField::create( 'AttributesDescription', '<p>' . _t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.AttributesDescription', 'These changes will only affect this particular placement of the file.' ) . '</p>' ), TextField::create('Caption', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.Caption', 'Caption')) ); }
[ "protected", "function", "getFormFieldAttributesTab", "(", "$", "record", ",", "$", "context", "=", "[", "]", ")", "{", "return", "Tab", "::", "create", "(", "'Placement'", ",", "LiteralField", "::", "create", "(", "'AttributesDescription'", ",", "'<p>'", ".",...
Create tab for file attributes @param File $record @param array $context @return Tab
[ "Create", "tab", "for", "file", "attributes" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/FileFormFactory.php#L169-L182
42,827
silverstripe/silverstripe-asset-admin
code/Forms/FileFormFactory.php
FileFormFactory.getPublishAction
protected function getPublishAction($record) { if (!$record || !$record->canPublish()) { return null; } // Build action $publishText = _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.PUBLISH_BUTTON', 'Publish'); /** @var FormAction $action */ $action = FormAction::create('publish', $publishText) ->setIcon('rocket') ->setSchemaState([ 'data' => [ 'isPublished' => $record->isPublished(), 'isModified' => $record->isModifiedOnDraft(), 'pristineTitle' => _t(__CLASS__ . 'PUBLISHED', 'Published'), 'pristineIcon' => 'tick', 'dirtyTitle' => _t(__CLASS__ . 'PUBLISH', 'Publish'), 'dirtyIcon' => 'rocket', 'pristineClass' => 'btn-outline-primary', 'dirtyClass' => '', ], ]) ->setSchemaData(['data' => ['buttonStyle' => 'primary']]); return $action; }
php
protected function getPublishAction($record) { if (!$record || !$record->canPublish()) { return null; } // Build action $publishText = _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.PUBLISH_BUTTON', 'Publish'); /** @var FormAction $action */ $action = FormAction::create('publish', $publishText) ->setIcon('rocket') ->setSchemaState([ 'data' => [ 'isPublished' => $record->isPublished(), 'isModified' => $record->isModifiedOnDraft(), 'pristineTitle' => _t(__CLASS__ . 'PUBLISHED', 'Published'), 'pristineIcon' => 'tick', 'dirtyTitle' => _t(__CLASS__ . 'PUBLISH', 'Publish'), 'dirtyIcon' => 'rocket', 'pristineClass' => 'btn-outline-primary', 'dirtyClass' => '', ], ]) ->setSchemaData(['data' => ['buttonStyle' => 'primary']]); return $action; }
[ "protected", "function", "getPublishAction", "(", "$", "record", ")", "{", "if", "(", "!", "$", "record", "||", "!", "$", "record", "->", "canPublish", "(", ")", ")", "{", "return", "null", ";", "}", "// Build action", "$", "publishText", "=", "_t", "(...
Get publish action @param File $record @return FormAction
[ "Get", "publish", "action" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/FileFormFactory.php#L243-L269
42,828
silverstripe/silverstripe-asset-admin
code/Forms/FileFormFactory.php
FileFormFactory.getSpecsMarkup
protected function getSpecsMarkup($record) { if (!$record || !$record->exists()) { return null; } return sprintf( '<div class="editor__specs">%s %s</div>', $record->getSize(), $this->getStatusFlagMarkup($record) ); }
php
protected function getSpecsMarkup($record) { if (!$record || !$record->exists()) { return null; } return sprintf( '<div class="editor__specs">%s %s</div>', $record->getSize(), $this->getStatusFlagMarkup($record) ); }
[ "protected", "function", "getSpecsMarkup", "(", "$", "record", ")", "{", "if", "(", "!", "$", "record", "||", "!", "$", "record", "->", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "return", "sprintf", "(", "'<div class=\"editor__specs\">%s %s...
get HTML for status icon @param File $record @return null|string
[ "get", "HTML", "for", "status", "icon" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/FileFormFactory.php#L329-L339
42,829
silverstripe/silverstripe-asset-admin
code/Forms/FileFormFactory.php
FileFormFactory.getUnpublishAction
protected function getUnpublishAction($record) { // Check if record is unpublishable if (!$record || !$record->isInDB() || !$record->isPublished() || !$record->canUnpublish()) { return null; } // Count live owners /** @var Versioned|RecursivePublishable $liveRecord */ $liveRecord = Versioned::get_by_stage($record->baseClass(), Versioned::LIVE) ->byID($record->ID); $liveOwners = $liveRecord->findOwners(false)->count(); // Build action $unpublishText = _t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.UNPUBLISH_BUTTON', 'Unpublish' ); $action = FormAction::create('unpublish', $unpublishText) ->setIcon('cancel-circled') ->setSchemaData(['data' => ['owners' => $liveOwners]]); return $action; }
php
protected function getUnpublishAction($record) { // Check if record is unpublishable if (!$record || !$record->isInDB() || !$record->isPublished() || !$record->canUnpublish()) { return null; } // Count live owners /** @var Versioned|RecursivePublishable $liveRecord */ $liveRecord = Versioned::get_by_stage($record->baseClass(), Versioned::LIVE) ->byID($record->ID); $liveOwners = $liveRecord->findOwners(false)->count(); // Build action $unpublishText = _t( 'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.UNPUBLISH_BUTTON', 'Unpublish' ); $action = FormAction::create('unpublish', $unpublishText) ->setIcon('cancel-circled') ->setSchemaData(['data' => ['owners' => $liveOwners]]); return $action; }
[ "protected", "function", "getUnpublishAction", "(", "$", "record", ")", "{", "// Check if record is unpublishable", "if", "(", "!", "$", "record", "||", "!", "$", "record", "->", "isInDB", "(", ")", "||", "!", "$", "record", "->", "isPublished", "(", ")", ...
Get action for publishing @param File $record @return FormAction
[ "Get", "action", "for", "publishing" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/FileFormFactory.php#L361-L383
42,830
silverstripe/silverstripe-asset-admin
code/Forms/FileFormFactory.php
FileFormFactory.getReplaceFileAction
protected function getReplaceFileAction($record) { // Check if record exists and user has correct permissions if (!$record || !$record->isInDB() || !$record->canEdit()) { return null; } $action = FormAction::create('replacefile', _t(__CLASS__ . '.REPLACE_FILE', 'Replace file')) ->setIcon('upload'); return $action; }
php
protected function getReplaceFileAction($record) { // Check if record exists and user has correct permissions if (!$record || !$record->isInDB() || !$record->canEdit()) { return null; } $action = FormAction::create('replacefile', _t(__CLASS__ . '.REPLACE_FILE', 'Replace file')) ->setIcon('upload'); return $action; }
[ "protected", "function", "getReplaceFileAction", "(", "$", "record", ")", "{", "// Check if record exists and user has correct permissions", "if", "(", "!", "$", "record", "||", "!", "$", "record", "->", "isInDB", "(", ")", "||", "!", "$", "record", "->", "canEd...
Get Replace file action @param File $record @return FormAction
[ "Get", "Replace", "file", "action" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Forms/FileFormFactory.php#L391-L402
42,831
silverstripe/silverstripe-asset-admin
code/Extensions/RemoteFileModalExtension.php
RemoteFileModalExtension.remoteEditForm
public function remoteEditForm() { $url = $this->getRequest()->requestVar('embedurl'); $form = null; $form = Injector::inst()->get(RemoteFileFormFactory::class) ->getForm( $this->getOwner(), 'remoteEditForm', ['type' => 'edit', 'url' => $url] ); return $form; }
php
public function remoteEditForm() { $url = $this->getRequest()->requestVar('embedurl'); $form = null; $form = Injector::inst()->get(RemoteFileFormFactory::class) ->getForm( $this->getOwner(), 'remoteEditForm', ['type' => 'edit', 'url' => $url] ); return $form; }
[ "public", "function", "remoteEditForm", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getRequest", "(", ")", "->", "requestVar", "(", "'embedurl'", ")", ";", "$", "form", "=", "null", ";", "$", "form", "=", "Injector", "::", "inst", "(", ")", ...
Form for editing a OEmbed object in the WYSIWYG, used by the InsertEmbedModal component @return Form
[ "Form", "for", "editing", "a", "OEmbed", "object", "in", "the", "WYSIWYG", "used", "by", "the", "InsertEmbedModal", "component" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Extensions/RemoteFileModalExtension.php#L78-L89
42,832
silverstripe/silverstripe-asset-admin
code/Extensions/RemoteFileModalExtension.php
RemoteFileModalExtension.remoteEditFormSchema
public function remoteEditFormSchema(HTTPRequest $request) { $schemaID = $request->getURL(); try { $form = $this->remoteEditForm(); return $this->getSchemaResponse($schemaID, $form); } catch (InvalidUrlException $exception) { $errors = ValidationResult::create() ->addError($exception->getMessage()); // @todo - Don't create dummy form (pass $form = null) $form = Form::create(null, 'Form', FieldList::create(), FieldList::create()); $code = $exception->getCode(); if ($code < 300) { $code = 500; } return $this ->getSchemaResponse($schemaID, $form, $errors) ->setStatusCode($code); } }
php
public function remoteEditFormSchema(HTTPRequest $request) { $schemaID = $request->getURL(); try { $form = $this->remoteEditForm(); return $this->getSchemaResponse($schemaID, $form); } catch (InvalidUrlException $exception) { $errors = ValidationResult::create() ->addError($exception->getMessage()); // @todo - Don't create dummy form (pass $form = null) $form = Form::create(null, 'Form', FieldList::create(), FieldList::create()); $code = $exception->getCode(); if ($code < 300) { $code = 500; } return $this ->getSchemaResponse($schemaID, $form, $errors) ->setStatusCode($code); } }
[ "public", "function", "remoteEditFormSchema", "(", "HTTPRequest", "$", "request", ")", "{", "$", "schemaID", "=", "$", "request", "->", "getURL", "(", ")", ";", "try", "{", "$", "form", "=", "$", "this", "->", "remoteEditForm", "(", ")", ";", "return", ...
Capture the schema handling process, as there is validation done to the URL provided before form is generated @param HTTPRequest $request @return HTTPResponse
[ "Capture", "the", "schema", "handling", "process", "as", "there", "is", "validation", "done", "to", "the", "URL", "provided", "before", "form", "is", "generated" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Extensions/RemoteFileModalExtension.php#L97-L118
42,833
silverstripe/silverstripe-asset-admin
code/Extensions/CampaignAdminExtension.php
CampaignAdminExtension.updatePopoverActions
public function updatePopoverActions(&$actions, $record) { if ($record && $record->canPublish()) { $action = FormAction::create( 'addtocampaign', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ADDTOCAMPAIGN', 'Add to campaign') )->setIcon('page-multiple'); array_unshift($actions, $action); } }
php
public function updatePopoverActions(&$actions, $record) { if ($record && $record->canPublish()) { $action = FormAction::create( 'addtocampaign', _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ADDTOCAMPAIGN', 'Add to campaign') )->setIcon('page-multiple'); array_unshift($actions, $action); } }
[ "public", "function", "updatePopoverActions", "(", "&", "$", "actions", ",", "$", "record", ")", "{", "if", "(", "$", "record", "&&", "$", "record", "->", "canPublish", "(", ")", ")", "{", "$", "action", "=", "FormAction", "::", "create", "(", "'addtoc...
Update the Popover menu of `FileFormFactory` with the "Add to campaign" button. @param array $actions @param File $record
[ "Update", "the", "Popover", "menu", "of", "FileFormFactory", "with", "the", "Add", "to", "campaign", "button", "." ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Extensions/CampaignAdminExtension.php#L22-L31
42,834
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdminFile.php
AssetAdminFile.getInsertDimensions
protected function getInsertDimensions() { $width = $this->owner->getWidth(); $height = $this->owner->getHeight(); if (!$height || !$width) { return null; } $maxWidth = $this->owner->config()->get('insert_width'); $maxHeight = $this->owner->config()->get('insert_height'); // Within bounds if ($width < $maxWidth && $height < $maxHeight) { return [ 'width' => $width, 'height' => $height, ]; } // Check if sizing by height or width if (($width * $maxHeight) < ($height * $maxWidth)) { // Size by height return [ 'width' => intval(($width * $maxHeight) / $height + 0.5), 'height' => $maxHeight, ]; } else { // Size by width return [ 'width' => $maxWidth, 'height' => intval(($height * $maxWidth) / $width + 0.5), ]; } }
php
protected function getInsertDimensions() { $width = $this->owner->getWidth(); $height = $this->owner->getHeight(); if (!$height || !$width) { return null; } $maxWidth = $this->owner->config()->get('insert_width'); $maxHeight = $this->owner->config()->get('insert_height'); // Within bounds if ($width < $maxWidth && $height < $maxHeight) { return [ 'width' => $width, 'height' => $height, ]; } // Check if sizing by height or width if (($width * $maxHeight) < ($height * $maxWidth)) { // Size by height return [ 'width' => intval(($width * $maxHeight) / $height + 0.5), 'height' => $maxHeight, ]; } else { // Size by width return [ 'width' => $maxWidth, 'height' => intval(($height * $maxWidth) / $width + 0.5), ]; } }
[ "protected", "function", "getInsertDimensions", "(", ")", "{", "$", "width", "=", "$", "this", "->", "owner", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "this", "->", "owner", "->", "getHeight", "(", ")", ";", "if", "(", "!", "$", "h...
Get dimensions of this image sized within insert_width x insert_height @return array|null
[ "Get", "dimensions", "of", "this", "image", "sized", "within", "insert_width", "x", "insert_height" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdminFile.php#L75-L108
42,835
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdminFile.php
AssetAdminFile.getFilesInUse
public function getFilesInUse() { $list = ArrayList::create(); // Check SiteTreeFileExtension if ($this->owner instanceof Folder) { // Join on tracking table $parents = static::nestedFolderIDs($this->owner->ID); $linkQuery = FileLink::get()->sql($linkParams); $list = File::get()->filter('ParentID', $parents) ->innerJoin( "({$linkQuery})", '"File"."ID" = "FileLinkTracking"."LinkedID"', 'FileLinkTracking', 20, $linkParams ); } // Allow extension $this->owner->extend('updateFilesInUse', $list); return $list; }
php
public function getFilesInUse() { $list = ArrayList::create(); // Check SiteTreeFileExtension if ($this->owner instanceof Folder) { // Join on tracking table $parents = static::nestedFolderIDs($this->owner->ID); $linkQuery = FileLink::get()->sql($linkParams); $list = File::get()->filter('ParentID', $parents) ->innerJoin( "({$linkQuery})", '"File"."ID" = "FileLinkTracking"."LinkedID"', 'FileLinkTracking', 20, $linkParams ); } // Allow extension $this->owner->extend('updateFilesInUse', $list); return $list; }
[ "public", "function", "getFilesInUse", "(", ")", "{", "$", "list", "=", "ArrayList", "::", "create", "(", ")", ";", "// Check SiteTreeFileExtension", "if", "(", "$", "this", "->", "owner", "instanceof", "Folder", ")", "{", "// Join on tracking table", "$", "pa...
Get the list of all nested files in use @return SS_List
[ "Get", "the", "list", "of", "all", "nested", "files", "in", "use" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdminFile.php#L182-L204
42,836
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdminFile.php
AssetAdminFile.nestedFolderIDs
public static function nestedFolderIDs($parentID, $maxDepth = 5) { $ids = [$parentID]; if ($maxDepth === 0) { return $ids; } $childIDs = Folder::get()->filter('ParentID', $parentID)->column('ID'); foreach ($childIDs as $childID) { $ids = array_merge($ids, static::nestedFolderIDs($childID, $maxDepth - 1)); } return $ids; }
php
public static function nestedFolderIDs($parentID, $maxDepth = 5) { $ids = [$parentID]; if ($maxDepth === 0) { return $ids; } $childIDs = Folder::get()->filter('ParentID', $parentID)->column('ID'); foreach ($childIDs as $childID) { $ids = array_merge($ids, static::nestedFolderIDs($childID, $maxDepth - 1)); } return $ids; }
[ "public", "static", "function", "nestedFolderIDs", "(", "$", "parentID", ",", "$", "maxDepth", "=", "5", ")", "{", "$", "ids", "=", "[", "$", "parentID", "]", ";", "if", "(", "$", "maxDepth", "===", "0", ")", "{", "return", "$", "ids", ";", "}", ...
Get recursive parent IDs @param int $parentID @param int $maxDepth Hard limit of max depth @return array List of parent IDs, including $parentID
[ "Get", "recursive", "parent", "IDs" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdminFile.php#L213-L224
42,837
silverstripe/silverstripe-asset-admin
code/Model/ThumbnailGenerator.php
ThumbnailGenerator.generateThumbnailLink
public function generateThumbnailLink(AssetContainer $file, $width, $height) { $thumbnail = $this->generateThumbnail($file, $width, $height); return $this->generateLink($thumbnail); }
php
public function generateThumbnailLink(AssetContainer $file, $width, $height) { $thumbnail = $this->generateThumbnail($file, $width, $height); return $this->generateLink($thumbnail); }
[ "public", "function", "generateThumbnailLink", "(", "AssetContainer", "$", "file", ",", "$", "width", ",", "$", "height", ")", "{", "$", "thumbnail", "=", "$", "this", "->", "generateThumbnail", "(", "$", "file", ",", "$", "width", ",", "$", "height", ")...
Generate thumbnail and return the "src" property for this thumbnail @param AssetContainer|DBFile|File $file @param int $width @param int $height @return string
[ "Generate", "thumbnail", "and", "return", "the", "src", "property", "for", "this", "thumbnail" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Model/ThumbnailGenerator.php#L70-L75
42,838
silverstripe/silverstripe-asset-admin
code/Model/ThumbnailGenerator.php
ThumbnailGenerator.generateThumbnail
public function generateThumbnail(AssetContainer $file, $width, $height) { if (!$file->getIsImage() || !$file->exists()) { return null; } // Disable generation if only querying existing files if (!$this->getGenerates()) { $file = $file->existingOnly(); } // Make large thumbnail return $file->FitMax($width, $height); }
php
public function generateThumbnail(AssetContainer $file, $width, $height) { if (!$file->getIsImage() || !$file->exists()) { return null; } // Disable generation if only querying existing files if (!$this->getGenerates()) { $file = $file->existingOnly(); } // Make large thumbnail return $file->FitMax($width, $height); }
[ "public", "function", "generateThumbnail", "(", "AssetContainer", "$", "file", ",", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "$", "file", "->", "getIsImage", "(", ")", "||", "!", "$", "file", "->", "exists", "(", ")", ")", "{", "...
Generate thumbnail object @param AssetContainer|DBFile|File $file @param int $width @param int $height @return AssetContainer|DBFile|File
[ "Generate", "thumbnail", "object" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Model/ThumbnailGenerator.php#L85-L98
42,839
silverstripe/silverstripe-asset-admin
code/Model/ThumbnailGenerator.php
ThumbnailGenerator.generateLink
public function generateLink(AssetContainer $thumbnail = null) { // Check if thumbnail can be found if (!$thumbnail || !$thumbnail->exists() || !$thumbnail->getIsImage()) { return null; } // Ensure thumbnail doesn't exceed safe bounds $maxSize = $this->config()->get('max_thumbnail_bytes'); if (!$thumbnail->getAbsoluteSize() > $maxSize) { return null; } // Determine best method to encode this thumbnail $urlRules = $this->config()->get('thumbnail_links'); $visibility = $thumbnail->getVisibility(); $urlRule = $urlRules[$visibility]; if (!isset($urlRule)) { throw new LogicException("Invalid visibility {$visibility}"); } // Build thumbnail switch ($urlRule) { case self::URL: return $thumbnail->getURL(); case self::INLINE: // Generate inline content $base64 = base64_encode($thumbnail->getString()); return sprintf( 'data:%s;base64,%s', $thumbnail->getMimeType(), $base64 ); default: throw new LogicException("Invalid url rule {$urlRule}"); } }
php
public function generateLink(AssetContainer $thumbnail = null) { // Check if thumbnail can be found if (!$thumbnail || !$thumbnail->exists() || !$thumbnail->getIsImage()) { return null; } // Ensure thumbnail doesn't exceed safe bounds $maxSize = $this->config()->get('max_thumbnail_bytes'); if (!$thumbnail->getAbsoluteSize() > $maxSize) { return null; } // Determine best method to encode this thumbnail $urlRules = $this->config()->get('thumbnail_links'); $visibility = $thumbnail->getVisibility(); $urlRule = $urlRules[$visibility]; if (!isset($urlRule)) { throw new LogicException("Invalid visibility {$visibility}"); } // Build thumbnail switch ($urlRule) { case self::URL: return $thumbnail->getURL(); case self::INLINE: // Generate inline content $base64 = base64_encode($thumbnail->getString()); return sprintf( 'data:%s;base64,%s', $thumbnail->getMimeType(), $base64 ); default: throw new LogicException("Invalid url rule {$urlRule}"); } }
[ "public", "function", "generateLink", "(", "AssetContainer", "$", "thumbnail", "=", "null", ")", "{", "// Check if thumbnail can be found", "if", "(", "!", "$", "thumbnail", "||", "!", "$", "thumbnail", "->", "exists", "(", ")", "||", "!", "$", "thumbnail", ...
Generate "src" property for this thumbnail. This can be either a url or base64 encoded data @param AssetContainer $thumbnail @return string
[ "Generate", "src", "property", "for", "this", "thumbnail", ".", "This", "can", "be", "either", "a", "url", "or", "base64", "encoded", "data" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Model/ThumbnailGenerator.php#L107-L143
42,840
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.init
public function init() { parent::init(); Requirements::add_i18n_javascript('silverstripe/asset-admin:client/lang', false, true); Requirements::javascript('silverstripe/asset-admin:client/dist/js/bundle.js'); Requirements::css('silverstripe/asset-admin:client/dist/styles/bundle.css'); CMSBatchActionHandler::register('delete', DeleteAssets::class, Folder::class); }
php
public function init() { parent::init(); Requirements::add_i18n_javascript('silverstripe/asset-admin:client/lang', false, true); Requirements::javascript('silverstripe/asset-admin:client/dist/js/bundle.js'); Requirements::css('silverstripe/asset-admin:client/dist/styles/bundle.css'); CMSBatchActionHandler::register('delete', DeleteAssets::class, Folder::class); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "Requirements", "::", "add_i18n_javascript", "(", "'silverstripe/asset-admin:client/lang'", ",", "false", ",", "true", ")", ";", "Requirements", "::", "javascript", "(", "'silver...
Set up the controller
[ "Set", "up", "the", "controller" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L183-L192
42,841
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.apiUploadFile
public function apiUploadFile(HTTPRequest $request) { $data = $request->postVars(); // When updating files, replace on conflict $upload = $this->getUpload(); $upload->setReplaceFile(true); // CSRF check $token = SecurityToken::inst(); if (empty($data[$token->getName()]) || !$token->check($data[$token->getName()])) { $this->jsonError(400); return null; } $tmpFile = $data['Upload']; if (empty($data['ID']) || empty($tmpFile['name']) || !array_key_exists('Name', $data)) { $this->jsonError(400, _t(__CLASS__.'.INVALID_REQUEST', 'Invalid request')); return null; } // Check parent record /** @var File $file */ $file = File::get()->byID($data['ID']); if (!$file) { $this->jsonError(404, _t(__CLASS__.'.FILE_NOT_FOUND', 'File not found')); return null; } $folder = $file->ParentID ? $file->Parent()->getFilename() : '/'; // If extension is the same, attempt to re-use existing name if (File::get_file_extension($tmpFile['name']) === File::get_file_extension($data['Name'])) { $tmpFile['name'] = $data['Name']; } else { // If we are allowing this upload to rename the underlying record, // do a uniqueness check. $renamer = $this->getNameGenerator($tmpFile['name']); foreach ($renamer as $name) { $filename = File::join_paths($folder, $name); if (!File::find($filename)) { $tmpFile['name'] = $name; break; } } } if (!$upload->validate($tmpFile)) { $errors = $upload->getErrors(); $message = array_shift($errors); $this->jsonError(400, $message); return null; } try { $tuple = $upload->load($tmpFile, $folder); } catch (Exception $e) { $this->jsonError(400, $e->getMessage()); return null; } if ($upload->isError()) { $errors = implode(' ' . PHP_EOL, $upload->getErrors()); $this->jsonError(400, $errors); return null; } $tuple['Name'] = basename($tuple['Filename']); return (new HTTPResponse(json_encode($tuple))) ->addHeader('Content-Type', 'application/json'); }
php
public function apiUploadFile(HTTPRequest $request) { $data = $request->postVars(); // When updating files, replace on conflict $upload = $this->getUpload(); $upload->setReplaceFile(true); // CSRF check $token = SecurityToken::inst(); if (empty($data[$token->getName()]) || !$token->check($data[$token->getName()])) { $this->jsonError(400); return null; } $tmpFile = $data['Upload']; if (empty($data['ID']) || empty($tmpFile['name']) || !array_key_exists('Name', $data)) { $this->jsonError(400, _t(__CLASS__.'.INVALID_REQUEST', 'Invalid request')); return null; } // Check parent record /** @var File $file */ $file = File::get()->byID($data['ID']); if (!$file) { $this->jsonError(404, _t(__CLASS__.'.FILE_NOT_FOUND', 'File not found')); return null; } $folder = $file->ParentID ? $file->Parent()->getFilename() : '/'; // If extension is the same, attempt to re-use existing name if (File::get_file_extension($tmpFile['name']) === File::get_file_extension($data['Name'])) { $tmpFile['name'] = $data['Name']; } else { // If we are allowing this upload to rename the underlying record, // do a uniqueness check. $renamer = $this->getNameGenerator($tmpFile['name']); foreach ($renamer as $name) { $filename = File::join_paths($folder, $name); if (!File::find($filename)) { $tmpFile['name'] = $name; break; } } } if (!$upload->validate($tmpFile)) { $errors = $upload->getErrors(); $message = array_shift($errors); $this->jsonError(400, $message); return null; } try { $tuple = $upload->load($tmpFile, $folder); } catch (Exception $e) { $this->jsonError(400, $e->getMessage()); return null; } if ($upload->isError()) { $errors = implode(' ' . PHP_EOL, $upload->getErrors()); $this->jsonError(400, $errors); return null; } $tuple['Name'] = basename($tuple['Filename']); return (new HTTPResponse(json_encode($tuple))) ->addHeader('Content-Type', 'application/json'); }
[ "public", "function", "apiUploadFile", "(", "HTTPRequest", "$", "request", ")", "{", "$", "data", "=", "$", "request", "->", "postVars", "(", ")", ";", "// When updating files, replace on conflict", "$", "upload", "=", "$", "this", "->", "getUpload", "(", ")",...
Upload a new asset for a pre-existing record. Returns the asset tuple. Note that conflict resolution is as follows: - If uploading a file with the same extension, we simply keep the same filename, and overwrite any existing files (same name + sha = don't duplicate). - If uploading a new file with a different extension, then the filename will be replaced, and will be checked for uniqueness against other File dataobjects. @param HTTPRequest $request Request containing vars 'ID' of parent record ID, and 'Name' as form filename value @return HTTPRequest|HTTPResponse
[ "Upload", "a", "new", "asset", "for", "a", "pre", "-", "existing", "record", ".", "Returns", "the", "asset", "tuple", "." ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L356-L424
42,842
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.legacyRedirectForEditView
public function legacyRedirectForEditView($request) { $fileID = $request->param('FileID'); /** @var File $file */ $file = File::get()->byID($fileID); $link = $this->getFileEditLink($file) ?: $this->Link(); $this->redirect($link); }
php
public function legacyRedirectForEditView($request) { $fileID = $request->param('FileID'); /** @var File $file */ $file = File::get()->byID($fileID); $link = $this->getFileEditLink($file) ?: $this->Link(); $this->redirect($link); }
[ "public", "function", "legacyRedirectForEditView", "(", "$", "request", ")", "{", "$", "fileID", "=", "$", "request", "->", "param", "(", "'FileID'", ")", ";", "/** @var File $file */", "$", "file", "=", "File", "::", "get", "(", ")", "->", "byID", "(", ...
Redirects 3.x style detail links to new 4.x style routing. @param HTTPRequest $request
[ "Redirects", "3", ".", "x", "style", "detail", "links", "to", "new", "4", ".", "x", "style", "routing", "." ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L529-L536
42,843
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getFileEditLink
public function getFileEditLink($file) { if (!$file || !$file->isInDB()) { return null; } return Controller::join_links( $this->Link('show'), $file->ParentID, 'edit', $file->ID ); }
php
public function getFileEditLink($file) { if (!$file || !$file->isInDB()) { return null; } return Controller::join_links( $this->Link('show'), $file->ParentID, 'edit', $file->ID ); }
[ "public", "function", "getFileEditLink", "(", "$", "file", ")", "{", "if", "(", "!", "$", "file", "||", "!", "$", "file", "->", "isInDB", "(", ")", ")", "{", "return", "null", ";", "}", "return", "Controller", "::", "join_links", "(", "$", "this", ...
Given a file return the CMS link to edit it @param File $file @return string
[ "Given", "a", "file", "return", "the", "CMS", "link", "to", "edit", "it" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L544-L556
42,844
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getFormFactory
public function getFormFactory(File $file) { // Get service name based on file class $name = null; if ($file instanceof Folder) { $name = FolderFormFactory::class; } elseif ($file instanceof Image) { $name = ImageFormFactory::class; } else { $name = FileFormFactory::class; } return Injector::inst()->get($name); }
php
public function getFormFactory(File $file) { // Get service name based on file class $name = null; if ($file instanceof Folder) { $name = FolderFormFactory::class; } elseif ($file instanceof Image) { $name = ImageFormFactory::class; } else { $name = FileFormFactory::class; } return Injector::inst()->get($name); }
[ "public", "function", "getFormFactory", "(", "File", "$", "file", ")", "{", "// Get service name based on file class", "$", "name", "=", "null", ";", "if", "(", "$", "file", "instanceof", "Folder", ")", "{", "$", "name", "=", "FolderFormFactory", "::", "class"...
Build a form scaffolder for this model NOTE: Volatile api. May be moved to {@see LeftAndMain} @param File $file @return FormFactory
[ "Build", "a", "form", "scaffolder", "for", "this", "model" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L610-L622
42,845
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.fileEditForm
public function fileEditForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileEditForm($id); }
php
public function fileEditForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileEditForm($id); }
[ "public", "function", "fileEditForm", "(", "$", "request", "=", "null", ")", "{", "// Get ID either from posted back value, or url parameter", "if", "(", "!", "$", "request", ")", "{", "$", "this", "->", "jsonError", "(", "400", ")", ";", "return", "null", ";"...
Get file edit form @param HTTPRequest $request @return Form|HTTPResponse
[ "Get", "file", "edit", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L649-L662
42,846
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.fileInsertForm
public function fileInsertForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileInsertForm($id); }
php
public function fileInsertForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileInsertForm($id); }
[ "public", "function", "fileInsertForm", "(", "$", "request", "=", "null", ")", "{", "// Get ID either from posted back value, or url parameter", "if", "(", "!", "$", "request", ")", "{", "$", "this", "->", "jsonError", "(", "400", ")", ";", "return", "null", "...
Get file insert media form @param HTTPRequest $request @return Form|HTTPResponse
[ "Get", "file", "insert", "media", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L684-L697
42,847
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.fileEditorLinkForm
public function fileEditorLinkForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileInsertForm($id); }
php
public function fileEditorLinkForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } return $this->getFileInsertForm($id); }
[ "public", "function", "fileEditorLinkForm", "(", "$", "request", "=", "null", ")", "{", "// Get ID either from posted back value, or url parameter", "if", "(", "!", "$", "request", ")", "{", "$", "this", "->", "jsonError", "(", "400", ")", ";", "return", "null",...
Get the file insert link form @param HTTPRequest $request @return Form|HTTPResponse
[ "Get", "the", "file", "insert", "link", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L717-L730
42,848
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getAbstractFileForm
protected function getAbstractFileForm($id, $name, $context = []) { /** @var File $file */ $file = File::get()->byID($id); if (!$file) { $this->jsonError(404); return null; } if (!$file->canView()) { $this->jsonError(403, _t( __CLASS__.'.ErrorItemPermissionDenied', "You don't have the necessary permissions to modify {ObjectTitle}", [ 'ObjectTitle' => $file->i18n_singular_name() ] )); return null; } // Pass to form factory $showLinkText = $this->getRequest()->getVar('requireLinkText'); $augmentedContext = array_merge( $context, [ 'Record' => $file, 'RequireLinkText' => isset($showLinkText) ] ); $scaffolder = $this->getFormFactory($file); $form = $scaffolder->getForm($this, $name, $augmentedContext); // Set form action handler with ID included $form->setRequestHandler( LeftAndMainFormRequestHandler::create($form, [ $id ]) ); // Configure form to respond to validation errors with form schema // if requested via react. $form->setValidationResponseCallback(function (ValidationResult $error) use ($form, $id, $name) { $schemaId = Controller::join_links($this->Link('schema'), $name, $id); return $this->getSchemaResponse($schemaId, $form, $error); }); return $form; }
php
protected function getAbstractFileForm($id, $name, $context = []) { /** @var File $file */ $file = File::get()->byID($id); if (!$file) { $this->jsonError(404); return null; } if (!$file->canView()) { $this->jsonError(403, _t( __CLASS__.'.ErrorItemPermissionDenied', "You don't have the necessary permissions to modify {ObjectTitle}", [ 'ObjectTitle' => $file->i18n_singular_name() ] )); return null; } // Pass to form factory $showLinkText = $this->getRequest()->getVar('requireLinkText'); $augmentedContext = array_merge( $context, [ 'Record' => $file, 'RequireLinkText' => isset($showLinkText) ] ); $scaffolder = $this->getFormFactory($file); $form = $scaffolder->getForm($this, $name, $augmentedContext); // Set form action handler with ID included $form->setRequestHandler( LeftAndMainFormRequestHandler::create($form, [ $id ]) ); // Configure form to respond to validation errors with form schema // if requested via react. $form->setValidationResponseCallback(function (ValidationResult $error) use ($form, $id, $name) { $schemaId = Controller::join_links($this->Link('schema'), $name, $id); return $this->getSchemaResponse($schemaId, $form, $error); }); return $form; }
[ "protected", "function", "getAbstractFileForm", "(", "$", "id", ",", "$", "name", ",", "$", "context", "=", "[", "]", ")", "{", "/** @var File $file */", "$", "file", "=", "File", "::", "get", "(", ")", "->", "byID", "(", "$", "id", ")", ";", "if", ...
Abstract method for generating a form for a file @param int $id Record ID @param string $name Form name @param array $context Form context @return Form|HTTPResponse
[ "Abstract", "method", "for", "generating", "a", "form", "for", "a", "file" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L740-L781
42,849
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.fileSelectForm
public function fileSelectForm() { // Get ID either from posted back value, or url parameter $request = $this->getRequest(); $id = $request->param('ID') ?: $request->postVar('ID'); return $this->getFileSelectForm($id); }
php
public function fileSelectForm() { // Get ID either from posted back value, or url parameter $request = $this->getRequest(); $id = $request->param('ID') ?: $request->postVar('ID'); return $this->getFileSelectForm($id); }
[ "public", "function", "fileSelectForm", "(", ")", "{", "// Get ID either from posted back value, or url parameter", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "id", "=", "$", "request", "->", "param", "(", "'ID'", ")", "?", ":", ...
Get form for selecting a file @return Form
[ "Get", "form", "for", "selecting", "a", "file" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L788-L794
42,850
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.fileHistoryForm
public function fileHistoryForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } $versionID = $request->param('VersionID'); if (!$versionID) { $this->jsonError(400); return null; } $form = $this->getFileHistoryForm([ 'RecordID' => $id, 'RecordVersion' => $versionID, ]); return $form; }
php
public function fileHistoryForm($request = null) { // Get ID either from posted back value, or url parameter if (!$request) { $this->jsonError(400); return null; } $id = $request->param('ID'); if (!$id) { $this->jsonError(400); return null; } $versionID = $request->param('VersionID'); if (!$versionID) { $this->jsonError(400); return null; } $form = $this->getFileHistoryForm([ 'RecordID' => $id, 'RecordVersion' => $versionID, ]); return $form; }
[ "public", "function", "fileHistoryForm", "(", "$", "request", "=", "null", ")", "{", "// Get ID either from posted back value, or url parameter", "if", "(", "!", "$", "request", ")", "{", "$", "this", "->", "jsonError", "(", "400", ")", ";", "return", "null", ...
Get file history form @param HTTPRequest $request @return Form|HTTPResponse
[ "Get", "file", "history", "form" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L926-L948
42,851
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getObjectFromData
public function getObjectFromData(File $file, $thumbnailLinks = true) { $object = $this->getMinimalistObjectFromData($file, $thumbnailLinks); // Slightly more accurate than graphql bulk-usage lookup, but more expensive $object['inUseCount'] = ($file->hasMethod('findOwners')) ? $file->findOwners()->count() : 0; $object['created'] = $file->Created; $object['lastUpdated'] = $file->LastEdited; $object['owner'] = null; $object['type'] = $file instanceof Folder ? 'folder' : $file->FileType; $object['name'] = $file->Name; $object['filename'] = $file->Filename; $object['url'] = $file->AbsoluteURL; $object['canEdit'] = $file->canEdit(); $object['canDelete'] = ($file->hasMethod('canArchive')) ? $file->canArchive() : $file->canDelete(); /** @var Member $owner */ $owner = $file->Owner(); if ($owner) { $object['owner'] = array( 'id' => $owner->ID, 'title' => $owner->Name, ); } return $object; }
php
public function getObjectFromData(File $file, $thumbnailLinks = true) { $object = $this->getMinimalistObjectFromData($file, $thumbnailLinks); // Slightly more accurate than graphql bulk-usage lookup, but more expensive $object['inUseCount'] = ($file->hasMethod('findOwners')) ? $file->findOwners()->count() : 0; $object['created'] = $file->Created; $object['lastUpdated'] = $file->LastEdited; $object['owner'] = null; $object['type'] = $file instanceof Folder ? 'folder' : $file->FileType; $object['name'] = $file->Name; $object['filename'] = $file->Filename; $object['url'] = $file->AbsoluteURL; $object['canEdit'] = $file->canEdit(); $object['canDelete'] = ($file->hasMethod('canArchive')) ? $file->canArchive() : $file->canDelete(); /** @var Member $owner */ $owner = $file->Owner(); if ($owner) { $object['owner'] = array( 'id' => $owner->ID, 'title' => $owner->Name, ); } return $object; }
[ "public", "function", "getObjectFromData", "(", "File", "$", "file", ",", "$", "thumbnailLinks", "=", "true", ")", "{", "$", "object", "=", "$", "this", "->", "getMinimalistObjectFromData", "(", "$", "file", ",", "$", "thumbnailLinks", ")", ";", "// Slightly...
Build the array containing the all attributes the AssetAdmin client interact with. @param File $file @param bool $thumbnailLinks Set to true if thumbnail links should be included. Set to false to skip thumbnail link generation. Note: Thumbnail content is always generated to pre-optimise for future use, even if links are not generated. @return array
[ "Build", "the", "array", "containing", "the", "all", "attributes", "the", "AssetAdmin", "client", "interact", "with", "." ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L1113-L1140
42,852
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getMinimalistObjectFromData
public function getMinimalistObjectFromData(File $file, $thumbnailLinks = true) { $object = array( 'id' => (int) $file->ID, 'parent' => null, 'title' => $file->Title, 'exists' => $file->exists(), // Broken file check 'category' => $file instanceof Folder ? 'folder' : $file->appCategory(), 'extension' => $file->Extension, 'size' => $file->AbsoluteSize, 'published' => ($file->hasMethod('isPublished')) ? $file->isPublished() : true, 'modified' => ($file->hasMethod('isModifiedOnDraft')) ? $file->isModifiedOnDraft() : false, 'draft' => ($file->hasMethod('isOnDraftOnly')) ? $file->isOnDraftOnly() : false, ); /** @var Folder $parent */ $parent = $file->Parent(); if ($parent) { $object['parent'] = array( 'id' => $parent->ID, 'title' => $parent->Title, 'filename' => $parent->Filename, ); } /** @var File $file */ if ($file->getIsImage()) { $thumbnails = $this->generateThumbnails($file, $thumbnailLinks); if ($thumbnailLinks) { $object = array_merge($object, $thumbnails); } // Save dimensions $object['width'] = $file->getWidth(); $object['height'] = $file->getHeight(); } else { $object['thumbnail'] = $file->PreviewLink(); } return $object; }
php
public function getMinimalistObjectFromData(File $file, $thumbnailLinks = true) { $object = array( 'id' => (int) $file->ID, 'parent' => null, 'title' => $file->Title, 'exists' => $file->exists(), // Broken file check 'category' => $file instanceof Folder ? 'folder' : $file->appCategory(), 'extension' => $file->Extension, 'size' => $file->AbsoluteSize, 'published' => ($file->hasMethod('isPublished')) ? $file->isPublished() : true, 'modified' => ($file->hasMethod('isModifiedOnDraft')) ? $file->isModifiedOnDraft() : false, 'draft' => ($file->hasMethod('isOnDraftOnly')) ? $file->isOnDraftOnly() : false, ); /** @var Folder $parent */ $parent = $file->Parent(); if ($parent) { $object['parent'] = array( 'id' => $parent->ID, 'title' => $parent->Title, 'filename' => $parent->Filename, ); } /** @var File $file */ if ($file->getIsImage()) { $thumbnails = $this->generateThumbnails($file, $thumbnailLinks); if ($thumbnailLinks) { $object = array_merge($object, $thumbnails); } // Save dimensions $object['width'] = $file->getWidth(); $object['height'] = $file->getHeight(); } else { $object['thumbnail'] = $file->PreviewLink(); } return $object; }
[ "public", "function", "getMinimalistObjectFromData", "(", "File", "$", "file", ",", "$", "thumbnailLinks", "=", "true", ")", "{", "$", "object", "=", "array", "(", "'id'", "=>", "(", "int", ")", "$", "file", "->", "ID", ",", "'parent'", "=>", "null", "...
Build the array containing the minimal attributes needed to render an UploadFieldItem. @param File $file @param bool $thumbnailLinks Set to true if thumbnail links should be included. Set to false to skip thumbnail link generation. Note: Thumbnail content is always generated to pre-optimise for future use, even if links are not generated. @return array
[ "Build", "the", "array", "containing", "the", "minimal", "attributes", "needed", "to", "render", "an", "UploadFieldItem", "." ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L1152-L1193
42,853
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.generateThumbnails
public function generateThumbnails(File $file, $thumbnailLinks = false) { $links = []; if (!$file->getIsImage()) { return $links; } $generator = $this->getThumbnailGenerator(); // Small thumbnail $smallWidth = UploadField::config()->uninherited('thumbnail_width'); $smallHeight = UploadField::config()->uninherited('thumbnail_height'); // Large thumbnail $width = $this->config()->get('thumbnail_width'); $height = $this->config()->get('thumbnail_height'); // Generate links if client requests them // Note: Thumbnails should always be generated even if links are not if ($thumbnailLinks) { $links['smallThumbnail'] = $generator->generateThumbnailLink($file, $smallWidth, $smallHeight); $links['thumbnail'] = $generator->generateThumbnailLink($file, $width, $height); } else { $generator->generateThumbnail($file, $smallWidth, $smallHeight); $generator->generateThumbnail($file, $width, $height); } $this->extend('updateGeneratedThumbnails', $file, $links, $generator); return $links; }
php
public function generateThumbnails(File $file, $thumbnailLinks = false) { $links = []; if (!$file->getIsImage()) { return $links; } $generator = $this->getThumbnailGenerator(); // Small thumbnail $smallWidth = UploadField::config()->uninherited('thumbnail_width'); $smallHeight = UploadField::config()->uninherited('thumbnail_height'); // Large thumbnail $width = $this->config()->get('thumbnail_width'); $height = $this->config()->get('thumbnail_height'); // Generate links if client requests them // Note: Thumbnails should always be generated even if links are not if ($thumbnailLinks) { $links['smallThumbnail'] = $generator->generateThumbnailLink($file, $smallWidth, $smallHeight); $links['thumbnail'] = $generator->generateThumbnailLink($file, $width, $height); } else { $generator->generateThumbnail($file, $smallWidth, $smallHeight); $generator->generateThumbnail($file, $width, $height); } $this->extend('updateGeneratedThumbnails', $file, $links, $generator); return $links; }
[ "public", "function", "generateThumbnails", "(", "File", "$", "file", ",", "$", "thumbnailLinks", "=", "false", ")", "{", "$", "links", "=", "[", "]", ";", "if", "(", "!", "$", "file", "->", "getIsImage", "(", ")", ")", "{", "return", "$", "links", ...
Generate thumbnails and provide links for a given file @param File $file @param bool $thumbnailLinks @return array
[ "Generate", "thumbnails", "and", "provide", "links", "for", "a", "given", "file" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L1202-L1230
42,854
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getRecordUpdatedResponse
protected function getRecordUpdatedResponse($record, $form) { // Return the record data in the same response as the schema to save a postback $schemaData = ['record' => $this->getObjectFromData($record)]; $schemaId = Controller::join_links($this->Link('schema/fileEditForm'), $record->ID); return $this->getSchemaResponse($schemaId, $form, null, $schemaData); }
php
protected function getRecordUpdatedResponse($record, $form) { // Return the record data in the same response as the schema to save a postback $schemaData = ['record' => $this->getObjectFromData($record)]; $schemaId = Controller::join_links($this->Link('schema/fileEditForm'), $record->ID); return $this->getSchemaResponse($schemaId, $form, null, $schemaData); }
[ "protected", "function", "getRecordUpdatedResponse", "(", "$", "record", ",", "$", "form", ")", "{", "// Return the record data in the same response as the schema to save a postback", "$", "schemaData", "=", "[", "'record'", "=>", "$", "this", "->", "getObjectFromData", "...
Get response for successfully updated record @param File $record @param Form $form @return HTTPResponse
[ "Get", "response", "for", "successfully", "updated", "record" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L1330-L1336
42,855
silverstripe/silverstripe-asset-admin
code/Controller/AssetAdmin.php
AssetAdmin.getFolderCreateForm
public function getFolderCreateForm($parentId = 0) { /** @var FolderCreateFormFactory $factory */ $factory = Injector::inst()->get(FolderCreateFormFactory::class); $form = $factory->getForm($this, 'folderCreateForm', [ 'ParentID' => $parentId ]); // Set form action handler with ParentID included $form->setRequestHandler( LeftAndMainFormRequestHandler::create($form, [ $parentId ]) ); return $form; }
php
public function getFolderCreateForm($parentId = 0) { /** @var FolderCreateFormFactory $factory */ $factory = Injector::inst()->get(FolderCreateFormFactory::class); $form = $factory->getForm($this, 'folderCreateForm', [ 'ParentID' => $parentId ]); // Set form action handler with ParentID included $form->setRequestHandler( LeftAndMainFormRequestHandler::create($form, [ $parentId ]) ); return $form; }
[ "public", "function", "getFolderCreateForm", "(", "$", "parentId", "=", "0", ")", "{", "/** @var FolderCreateFormFactory $factory */", "$", "factory", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "FolderCreateFormFactory", "::", "class", ")", ";", ...
Returns the form to be used for creating a new folder @param $parentId @return Form
[ "Returns", "the", "form", "to", "be", "used", "for", "creating", "a", "new", "folder" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/Controller/AssetAdmin.php#L1363-L1375
42,856
silverstripe/silverstripe-asset-admin
code/GraphQL/UnpublishFileMutationCreator.php
UnpublishFileMutationCreator.countLiveOwners
protected function countLiveOwners(File $file) { // In case no versioning if (!$file->hasExtension(RecursivePublishable::class)) { return 0; } // Query live record /** @var Versioned|RecursivePublishable $liveRecord */ $liveRecord = Versioned::get_by_stage(File::class, Versioned::LIVE)->byID($file->ID); if ($liveRecord) { return $liveRecord ->findOwners(false) ->count(); } // No live record, no live owners return 0; }
php
protected function countLiveOwners(File $file) { // In case no versioning if (!$file->hasExtension(RecursivePublishable::class)) { return 0; } // Query live record /** @var Versioned|RecursivePublishable $liveRecord */ $liveRecord = Versioned::get_by_stage(File::class, Versioned::LIVE)->byID($file->ID); if ($liveRecord) { return $liveRecord ->findOwners(false) ->count(); } // No live record, no live owners return 0; }
[ "protected", "function", "countLiveOwners", "(", "File", "$", "file", ")", "{", "// In case no versioning", "if", "(", "!", "$", "file", "->", "hasExtension", "(", "RecursivePublishable", "::", "class", ")", ")", "{", "return", "0", ";", "}", "// Query live re...
Count number of live owners this file uses @param File $file @return int Number of live owners
[ "Count", "number", "of", "live", "owners", "this", "file", "uses" ]
cfa36b7c61b79b81a035e1c2845e58340cd03b2e
https://github.com/silverstripe/silverstripe-asset-admin/blob/cfa36b7c61b79b81a035e1c2845e58340cd03b2e/code/GraphQL/UnpublishFileMutationCreator.php#L87-L105
42,857
symbiote/silverstripe-gridfieldextensions
src/GridFieldEditableColumns.php
GridFieldEditableColumns.getFields
public function getFields(GridField $grid, DataObjectInterface $record) { $cols = $this->getDisplayFields($grid); $fields = new FieldList(); /** @var DataList $list */ $list = $grid->getList(); $class = $list ? $list->dataClass() : null; foreach ($cols as $col => $info) { $field = null; if ($info instanceof Closure) { $field = call_user_func($info, $record, $col, $grid); } elseif (is_array($info)) { if (isset($info['callback'])) { $field = call_user_func($info['callback'], $record, $col, $grid); } elseif (isset($info['field'])) { if ($info['field'] == LiteralField::class) { $field = new $info['field']($col, null); } else { $field = new $info['field']($col); } } if (!$field instanceof FormField) { throw new Exception(sprintf( 'The field for column "%s" is not a valid form field', $col )); } } if (!$field && $list instanceof ManyManyList) { $extra = $list->getExtraFields(); if ($extra && array_key_exists($col, $extra)) { $field = Injector::inst()->create($extra[$col], $col)->scaffoldFormField(); } } if (!$field) { if (!$this->displayFields) { // If setDisplayFields() not used, utilize $summary_fields // in a way similar to base class // // Allows use of 'MyBool.Nice' and 'MyHTML.NoHTML' so that // GridFields not using inline editing still look good or // revert to looking good in cases where the field isn't // available or is readonly // $colRelation = explode('.', $col); if ($class && $obj = DataObject::singleton($class)->dbObject($colRelation[0])) { $field = $obj->scaffoldFormField(); } else { $field = new ReadonlyField($colRelation[0]); } } elseif ($class && $obj = DataObject::singleton($class)->dbObject($col)) { $field = $obj->scaffoldFormField(); } else { $field = new ReadonlyField($col); } } if (!$field instanceof FormField) { throw new Exception(sprintf( 'Invalid form field instance for column "%s"', $col )); } // Add CSS class for interactive fields if (!($field->isReadOnly() || $field instanceof LiteralField)) { $field->addExtraClass('editable-column-field'); } $fields->push($field); } return $fields; }
php
public function getFields(GridField $grid, DataObjectInterface $record) { $cols = $this->getDisplayFields($grid); $fields = new FieldList(); /** @var DataList $list */ $list = $grid->getList(); $class = $list ? $list->dataClass() : null; foreach ($cols as $col => $info) { $field = null; if ($info instanceof Closure) { $field = call_user_func($info, $record, $col, $grid); } elseif (is_array($info)) { if (isset($info['callback'])) { $field = call_user_func($info['callback'], $record, $col, $grid); } elseif (isset($info['field'])) { if ($info['field'] == LiteralField::class) { $field = new $info['field']($col, null); } else { $field = new $info['field']($col); } } if (!$field instanceof FormField) { throw new Exception(sprintf( 'The field for column "%s" is not a valid form field', $col )); } } if (!$field && $list instanceof ManyManyList) { $extra = $list->getExtraFields(); if ($extra && array_key_exists($col, $extra)) { $field = Injector::inst()->create($extra[$col], $col)->scaffoldFormField(); } } if (!$field) { if (!$this->displayFields) { // If setDisplayFields() not used, utilize $summary_fields // in a way similar to base class // // Allows use of 'MyBool.Nice' and 'MyHTML.NoHTML' so that // GridFields not using inline editing still look good or // revert to looking good in cases where the field isn't // available or is readonly // $colRelation = explode('.', $col); if ($class && $obj = DataObject::singleton($class)->dbObject($colRelation[0])) { $field = $obj->scaffoldFormField(); } else { $field = new ReadonlyField($colRelation[0]); } } elseif ($class && $obj = DataObject::singleton($class)->dbObject($col)) { $field = $obj->scaffoldFormField(); } else { $field = new ReadonlyField($col); } } if (!$field instanceof FormField) { throw new Exception(sprintf( 'Invalid form field instance for column "%s"', $col )); } // Add CSS class for interactive fields if (!($field->isReadOnly() || $field instanceof LiteralField)) { $field->addExtraClass('editable-column-field'); } $fields->push($field); } return $fields; }
[ "public", "function", "getFields", "(", "GridField", "$", "grid", ",", "DataObjectInterface", "$", "record", ")", "{", "$", "cols", "=", "$", "this", "->", "getDisplayFields", "(", "$", "grid", ")", ";", "$", "fields", "=", "new", "FieldList", "(", ")", ...
Gets the field list for a record. @param GridField $grid @param DataObjectInterface $record @return FieldList @throws Exception
[ "Gets", "the", "field", "list", "for", "a", "record", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldEditableColumns.php#L205-L285
42,858
symbiote/silverstripe-gridfieldextensions
src/GridFieldEditableColumns.php
GridFieldEditableColumns.getForm
public function getForm(GridField $grid, DataObjectInterface $record) { $fields = $this->getFields($grid, $record); $form = new Form($grid, null, $fields, new FieldList()); $form->loadDataFrom($record); $form->setFormAction(Controller::join_links( $grid->Link(), 'editable/form', $record->ID )); return $form; }
php
public function getForm(GridField $grid, DataObjectInterface $record) { $fields = $this->getFields($grid, $record); $form = new Form($grid, null, $fields, new FieldList()); $form->loadDataFrom($record); $form->setFormAction(Controller::join_links( $grid->Link(), 'editable/form', $record->ID )); return $form; }
[ "public", "function", "getForm", "(", "GridField", "$", "grid", ",", "DataObjectInterface", "$", "record", ")", "{", "$", "fields", "=", "$", "this", "->", "getFields", "(", "$", "grid", ",", "$", "record", ")", ";", "$", "form", "=", "new", "Form", ...
Gets the form instance for a record. @param GridField $grid @param DataObjectInterface $record @return Form
[ "Gets", "the", "form", "instance", "for", "a", "record", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldEditableColumns.php#L294-L308
42,859
symbiote/silverstripe-gridfieldextensions
src/GridFieldRequestHandler.php
GridFieldRequestHandler.Form
public function Form() { $form = new Form( $this, 'SilverStripe\\Forms\\Form', new FieldList($root = new TabSet('Root', new Tab('Main'))), new FieldList() ); if ($this->getTopLevelController() instanceof LeftAndMain) { $form->setTemplate('LeftAndMain_EditForm'); $form->addExtraClass('cms-content cms-edit-form cms-tabset center'); $form->setAttribute('data-pjax-fragment', 'CurrentForm Content'); $root->setTemplate('CMSTabSet'); $form->Backlink = $this->getBackLink(); } return $form; }
php
public function Form() { $form = new Form( $this, 'SilverStripe\\Forms\\Form', new FieldList($root = new TabSet('Root', new Tab('Main'))), new FieldList() ); if ($this->getTopLevelController() instanceof LeftAndMain) { $form->setTemplate('LeftAndMain_EditForm'); $form->addExtraClass('cms-content cms-edit-form cms-tabset center'); $form->setAttribute('data-pjax-fragment', 'CurrentForm Content'); $root->setTemplate('CMSTabSet'); $form->Backlink = $this->getBackLink(); } return $form; }
[ "public", "function", "Form", "(", ")", "{", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'SilverStripe\\\\Forms\\\\Form'", ",", "new", "FieldList", "(", "$", "root", "=", "new", "TabSet", "(", "'Root'", ",", "new", "Tab", "(", "'Main'", ")...
This method should be overloaded to build out the detail form. @return Form
[ "This", "method", "should", "be", "overloaded", "to", "build", "out", "the", "detail", "form", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldRequestHandler.php#L84-L103
42,860
symbiote/silverstripe-gridfieldextensions
src/GridFieldOrderableRows.php
GridFieldOrderableRows.validateSortField
public function validateSortField(SS_List $list) { $field = $this->getSortField(); // Check extra fields on many many relation types if ($list instanceof ManyManyList) { $extra = $list->getExtraFields(); if ($extra && array_key_exists($field, $extra)) { return; } } elseif ($list instanceof ManyManyThroughList) { $manipulator = $this->getManyManyInspector($list); $fieldTable = DataObject::getSchema()->tableForField($manipulator->getJoinClass(), $field); if ($fieldTable) { return; } } $classes = ClassInfo::dataClassesFor($list->dataClass()); foreach ($classes as $class) { if (singleton($class)->hasDataBaseField($field)) { return; } } throw new Exception("Couldn't find the sort field '" . $field . "'"); }
php
public function validateSortField(SS_List $list) { $field = $this->getSortField(); // Check extra fields on many many relation types if ($list instanceof ManyManyList) { $extra = $list->getExtraFields(); if ($extra && array_key_exists($field, $extra)) { return; } } elseif ($list instanceof ManyManyThroughList) { $manipulator = $this->getManyManyInspector($list); $fieldTable = DataObject::getSchema()->tableForField($manipulator->getJoinClass(), $field); if ($fieldTable) { return; } } $classes = ClassInfo::dataClassesFor($list->dataClass()); foreach ($classes as $class) { if (singleton($class)->hasDataBaseField($field)) { return; } } throw new Exception("Couldn't find the sort field '" . $field . "'"); }
[ "public", "function", "validateSortField", "(", "SS_List", "$", "list", ")", "{", "$", "field", "=", "$", "this", "->", "getSortField", "(", ")", ";", "// Check extra fields on many many relation types", "if", "(", "$", "list", "instanceof", "ManyManyList", ")", ...
Validates sortable list @param SS_List $list @throws Exception
[ "Validates", "sortable", "list" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldOrderableRows.php#L231-L259
42,861
symbiote/silverstripe-gridfieldextensions
src/GridFieldOrderableRows.php
GridFieldOrderableRows.handleSave
public function handleSave(GridField $grid, DataObjectInterface $record) { if (!$this->immediateUpdate) { $value = $grid->Value(); $sortedIDs = $this->getSortedIDs($value); if ($sortedIDs) { $this->executeReorder($grid, $sortedIDs); } } }
php
public function handleSave(GridField $grid, DataObjectInterface $record) { if (!$this->immediateUpdate) { $value = $grid->Value(); $sortedIDs = $this->getSortedIDs($value); if ($sortedIDs) { $this->executeReorder($grid, $sortedIDs); } } }
[ "public", "function", "handleSave", "(", "GridField", "$", "grid", ",", "DataObjectInterface", "$", "record", ")", "{", "if", "(", "!", "$", "this", "->", "immediateUpdate", ")", "{", "$", "value", "=", "$", "grid", "->", "Value", "(", ")", ";", "$", ...
Handle saving when 'immediateUpdate' is disabled, otherwise this isn't necessary for the default sort mode.
[ "Handle", "saving", "when", "immediateUpdate", "is", "disabled", "otherwise", "this", "isn", "t", "necessary", "for", "the", "default", "sort", "mode", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldOrderableRows.php#L530-L539
42,862
symbiote/silverstripe-gridfieldextensions
src/GridFieldOrderableRows.php
GridFieldOrderableRows.getManyManyInspector
protected function getManyManyInspector($list) { $inspector = $list; if ($list instanceof ManyManyThroughList) { foreach ($list->dataQuery()->getDataQueryManipulators() as $manipulator) { if ($manipulator instanceof ManyManyThroughQueryManipulator) { $inspector = $manipulator; break; } } } return $inspector; }
php
protected function getManyManyInspector($list) { $inspector = $list; if ($list instanceof ManyManyThroughList) { foreach ($list->dataQuery()->getDataQueryManipulators() as $manipulator) { if ($manipulator instanceof ManyManyThroughQueryManipulator) { $inspector = $manipulator; break; } } } return $inspector; }
[ "protected", "function", "getManyManyInspector", "(", "$", "list", ")", "{", "$", "inspector", "=", "$", "list", ";", "if", "(", "$", "list", "instanceof", "ManyManyThroughList", ")", "{", "foreach", "(", "$", "list", "->", "dataQuery", "(", ")", "->", "...
A ManyManyList defines functions such as getLocalKey, however on ManyManyThroughList these functions are moved to ManyManyThroughQueryManipulator, but otherwise retain the same signature. @param ManyManyList|ManyManyThroughList $list @return ManyManyList|ManyManyThroughQueryManipulator
[ "A", "ManyManyList", "defines", "functions", "such", "as", "getLocalKey", "however", "on", "ManyManyThroughList", "these", "functions", "are", "moved", "to", "ManyManyThroughQueryManipulator", "but", "otherwise", "retain", "the", "same", "signature", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldOrderableRows.php#L798-L810
42,863
symbiote/silverstripe-gridfieldextensions
src/GridFieldOrderableRows.php
GridFieldOrderableRows.getSortValuesFromManyManyThroughList
protected function getSortValuesFromManyManyThroughList($list, $sortField) { $manipulator = $this->getManyManyInspector($list); // Find the foreign key name, ID and class to look up $joinClass = $manipulator->getJoinClass(); $fromRelationName = $manipulator->getForeignKey(); $toRelationName = $manipulator->getLocalKey(); // Create a list of the MMTL relations $sortlist = DataList::create($joinClass)->filter([ $toRelationName => $list->column('ID'), // first() is safe as there are earlier checks to ensure our list to sort is valid $fromRelationName => $list->first()->getJoin()->$fromRelationName, ]); return $sortlist->map($toRelationName, $sortField)->toArray(); }
php
protected function getSortValuesFromManyManyThroughList($list, $sortField) { $manipulator = $this->getManyManyInspector($list); // Find the foreign key name, ID and class to look up $joinClass = $manipulator->getJoinClass(); $fromRelationName = $manipulator->getForeignKey(); $toRelationName = $manipulator->getLocalKey(); // Create a list of the MMTL relations $sortlist = DataList::create($joinClass)->filter([ $toRelationName => $list->column('ID'), // first() is safe as there are earlier checks to ensure our list to sort is valid $fromRelationName => $list->first()->getJoin()->$fromRelationName, ]); return $sortlist->map($toRelationName, $sortField)->toArray(); }
[ "protected", "function", "getSortValuesFromManyManyThroughList", "(", "$", "list", ",", "$", "sortField", ")", "{", "$", "manipulator", "=", "$", "this", "->", "getManyManyInspector", "(", "$", "list", ")", ";", "// Find the foreign key name, ID and class to look up", ...
Used to get sort orders from a many many through list relationship record, rather than the current record itself. @param ManyManyList|ManyManyThroughList $list @return int[] Sort orders for the
[ "Used", "to", "get", "sort", "orders", "from", "a", "many", "many", "through", "list", "relationship", "record", "rather", "than", "the", "current", "record", "itself", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldOrderableRows.php#L819-L836
42,864
symbiote/silverstripe-gridfieldextensions
src/GridFieldAddNewMultiClass.php
GridFieldAddNewMultiClass.getClasses
public function getClasses(GridField $grid) { $result = array(); if (is_null($this->classes)) { $classes = array_values(ClassInfo::subclassesFor($grid->getModelClass())); sort($classes); } else { $classes = $this->classes; } $kill_ancestors = array(); foreach ($classes as $class => $title) { if (!is_string($class)) { $class = $title; } if (!class_exists($class)) { continue; } $is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract()); if (!$is_abstract && $class === $title) { $title = singleton($class)->i18n_singular_name(); } if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor')) { $kill_ancestors[$ancestor_to_hide] = true; } if ($is_abstract || !singleton($class)->canCreate()) { continue; } $result[$class] = $title; } if ($kill_ancestors) { foreach ($kill_ancestors as $class => $bool) { unset($result[$class]); } } $sanitised = array(); foreach ($result as $class => $title) { $sanitised[$this->sanitiseClassName($class)] = $title; } return $sanitised; }
php
public function getClasses(GridField $grid) { $result = array(); if (is_null($this->classes)) { $classes = array_values(ClassInfo::subclassesFor($grid->getModelClass())); sort($classes); } else { $classes = $this->classes; } $kill_ancestors = array(); foreach ($classes as $class => $title) { if (!is_string($class)) { $class = $title; } if (!class_exists($class)) { continue; } $is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract()); if (!$is_abstract && $class === $title) { $title = singleton($class)->i18n_singular_name(); } if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor')) { $kill_ancestors[$ancestor_to_hide] = true; } if ($is_abstract || !singleton($class)->canCreate()) { continue; } $result[$class] = $title; } if ($kill_ancestors) { foreach ($kill_ancestors as $class => $bool) { unset($result[$class]); } } $sanitised = array(); foreach ($result as $class => $title) { $sanitised[$this->sanitiseClassName($class)] = $title; } return $sanitised; }
[ "public", "function", "getClasses", "(", "GridField", "$", "grid", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "classes", ")", ")", "{", "$", "classes", "=", "array_values", "(", "ClassInfo", ":...
Gets the classes that can be created using this button, defaulting to the model class and its subclasses. @param GridField $grid @return array a map of class name to title
[ "Gets", "the", "classes", "that", "can", "be", "created", "using", "this", "button", "defaulting", "to", "the", "model", "class", "and", "its", "subclasses", "." ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldAddNewMultiClass.php#L119-L166
42,865
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.getFirstShown
public function getFirstShown() { $firstShown = $this->getGridPagerState()->firstShown ?: 1; // Prevent visiting a page with an offset higher than the total number of items if ($firstShown > $this->getTotalRecords()) { $this->getGridPagerState()->firstShown = $firstShown = 1; } return $firstShown; }
php
public function getFirstShown() { $firstShown = $this->getGridPagerState()->firstShown ?: 1; // Prevent visiting a page with an offset higher than the total number of items if ($firstShown > $this->getTotalRecords()) { $this->getGridPagerState()->firstShown = $firstShown = 1; } return $firstShown; }
[ "public", "function", "getFirstShown", "(", ")", "{", "$", "firstShown", "=", "$", "this", "->", "getGridPagerState", "(", ")", "->", "firstShown", "?", ":", "1", ";", "// Prevent visiting a page with an offset higher than the total number of items", "if", "(", "$", ...
Get the first shown record number @return int
[ "Get", "the", "first", "shown", "record", "number" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L78-L86
42,866
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.setPageSizes
public function setPageSizes(array $pageSizes) { $this->pageSizes = $pageSizes; // Reset items per page $this->setItemsPerPage(current($pageSizes)); return $this; }
php
public function setPageSizes(array $pageSizes) { $this->pageSizes = $pageSizes; // Reset items per page $this->setItemsPerPage(current($pageSizes)); return $this; }
[ "public", "function", "setPageSizes", "(", "array", "$", "pageSizes", ")", "{", "$", "this", "->", "pageSizes", "=", "$", "pageSizes", ";", "// Reset items per page", "$", "this", "->", "setItemsPerPage", "(", "current", "(", "$", "pageSizes", ")", ")", ";",...
Set the page sizes to use in the "Show x" dropdown @param array $pageSizes @return $this
[ "Set", "the", "page", "sizes", "to", "use", "in", "the", "Show", "x", "dropdown" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L169-L177
42,867
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.getPageSizesAsList
public function getPageSizesAsList() { $pageSizes = ArrayList::create(); $perPage = $this->getItemsPerPage(); foreach ($this->getPageSizes() as $pageSize) { $pageSizes->push(array( 'Size' => $pageSize, 'Selected' => $pageSize == $perPage )); } return $pageSizes; }
php
public function getPageSizesAsList() { $pageSizes = ArrayList::create(); $perPage = $this->getItemsPerPage(); foreach ($this->getPageSizes() as $pageSize) { $pageSizes->push(array( 'Size' => $pageSize, 'Selected' => $pageSize == $perPage )); } return $pageSizes; }
[ "public", "function", "getPageSizesAsList", "(", ")", "{", "$", "pageSizes", "=", "ArrayList", "::", "create", "(", ")", ";", "$", "perPage", "=", "$", "this", "->", "getItemsPerPage", "(", ")", ";", "foreach", "(", "$", "this", "->", "getPageSizes", "("...
Gets a list of page sizes for use in templates as a dropdown @return ArrayList
[ "Gets", "a", "list", "of", "page", "sizes", "for", "use", "in", "templates", "as", "a", "dropdown" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L194-L205
42,868
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.getTemplateParameters
public function getTemplateParameters(GridField $gridField) { $state = $this->getGridPagerState(); if (is_numeric($state->pageSize)) { $this->setItemsPerPage($state->pageSize); } $arguments = $this->getPagerArguments(); // Figure out which page and record range we're on if (!$arguments['total-rows']) { return null; } // Define a list of the FormActions that should be generated for pager controls (see getPagerActions()) $controls = array( 'first' => array( 'title' => 'First', 'args' => array('first-shown' => 1), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ' . 'ss-gridfield-pagination-action ss-gridfield-firstpage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'prev' => array( 'title' => 'Previous', 'args' => array('first-shown' => $arguments['first-shown'] - $this->getItemsPerPage()), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ' . 'ss-gridfield-pagination-action ss-gridfield-previouspage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'next' => array( 'title' => 'Next', 'args' => array('first-shown' => $arguments['first-shown'] + $this->getItemsPerPage()), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-right ' .'ss-gridfield-pagination-action ss-gridfield-nextpage', 'disable-next' => ($this->getCurrentPage() == $arguments['total-pages']) ), 'last' => array( 'title' => 'Last', 'args' => array('first-shown' => ($this->getTotalPages() - 1) * $this->getItemsPerPage() + 1), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ' . 'ss-gridfield-pagination-action ss-gridfield-lastpage', 'disable-next' => ($this->getCurrentPage() == $arguments['total-pages']) ), 'pagesize' => array( 'title' => 'Page Size', 'args' => array('first-shown' => $arguments['first-shown']), 'extra-class' => 'ss-gridfield-pagination-action ss-gridfield-pagesize-submit' ), ); if ($controls['prev']['args']['first-shown'] < 1) { $controls['prev']['args']['first-shown'] = 1; } $actions = $this->getPagerActions($controls, $gridField); // Render in template return ArrayData::create(array( 'OnlyOnePage' => ($arguments['total-pages'] == 1), 'FirstPage' => $actions['first'], 'PreviousPage' => $actions['prev'], 'NextPage' => $actions['next'], 'LastPage' => $actions['last'], 'PageSizesSubmit' => $actions['pagesize'], 'CurrentPageNum' => $this->getCurrentPage(), 'NumPages' => $arguments['total-pages'], 'FirstShownRecord' => $arguments['first-shown'], 'LastShownRecord' => $arguments['last-shown'], 'NumRecords' => $arguments['total-rows'], 'PageSizes' => $this->getPageSizesAsList(), 'PageSizesName' => $gridField->getName() . '[page-sizes]', )); }
php
public function getTemplateParameters(GridField $gridField) { $state = $this->getGridPagerState(); if (is_numeric($state->pageSize)) { $this->setItemsPerPage($state->pageSize); } $arguments = $this->getPagerArguments(); // Figure out which page and record range we're on if (!$arguments['total-rows']) { return null; } // Define a list of the FormActions that should be generated for pager controls (see getPagerActions()) $controls = array( 'first' => array( 'title' => 'First', 'args' => array('first-shown' => 1), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ' . 'ss-gridfield-pagination-action ss-gridfield-firstpage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'prev' => array( 'title' => 'Previous', 'args' => array('first-shown' => $arguments['first-shown'] - $this->getItemsPerPage()), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ' . 'ss-gridfield-pagination-action ss-gridfield-previouspage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'next' => array( 'title' => 'Next', 'args' => array('first-shown' => $arguments['first-shown'] + $this->getItemsPerPage()), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-right ' .'ss-gridfield-pagination-action ss-gridfield-nextpage', 'disable-next' => ($this->getCurrentPage() == $arguments['total-pages']) ), 'last' => array( 'title' => 'Last', 'args' => array('first-shown' => ($this->getTotalPages() - 1) * $this->getItemsPerPage() + 1), 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ' . 'ss-gridfield-pagination-action ss-gridfield-lastpage', 'disable-next' => ($this->getCurrentPage() == $arguments['total-pages']) ), 'pagesize' => array( 'title' => 'Page Size', 'args' => array('first-shown' => $arguments['first-shown']), 'extra-class' => 'ss-gridfield-pagination-action ss-gridfield-pagesize-submit' ), ); if ($controls['prev']['args']['first-shown'] < 1) { $controls['prev']['args']['first-shown'] = 1; } $actions = $this->getPagerActions($controls, $gridField); // Render in template return ArrayData::create(array( 'OnlyOnePage' => ($arguments['total-pages'] == 1), 'FirstPage' => $actions['first'], 'PreviousPage' => $actions['prev'], 'NextPage' => $actions['next'], 'LastPage' => $actions['last'], 'PageSizesSubmit' => $actions['pagesize'], 'CurrentPageNum' => $this->getCurrentPage(), 'NumPages' => $arguments['total-pages'], 'FirstShownRecord' => $arguments['first-shown'], 'LastShownRecord' => $arguments['last-shown'], 'NumRecords' => $arguments['total-rows'], 'PageSizes' => $this->getPageSizesAsList(), 'PageSizesName' => $gridField->getName() . '[page-sizes]', )); }
[ "public", "function", "getTemplateParameters", "(", "GridField", "$", "gridField", ")", "{", "$", "state", "=", "$", "this", "->", "getGridPagerState", "(", ")", ";", "if", "(", "is_numeric", "(", "$", "state", "->", "pageSize", ")", ")", "{", "$", "this...
Add the configurable page size options to the template data {@inheritDoc} @param GridField $gridField @return ArrayData|null
[ "Add", "the", "configurable", "page", "size", "options", "to", "the", "template", "data" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L274-L346
42,869
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.getPagerActions
public function getPagerActions(array $controls, GridField $gridField) { $actions = array(); foreach ($controls as $key => $arguments) { $action = GridField_FormAction::create( $gridField, 'pagination_' . $key, $arguments['title'], 'paginate', $arguments['args'] ); if (isset($arguments['extra-class'])) { $action->addExtraClass($arguments['extra-class']); } if (isset($arguments['disable-previous']) && $arguments['disable-previous']) { $action = $action->performDisabledTransformation(); } elseif (isset($arguments['disable-next']) && $arguments['disable-next']) { $action = $action->performDisabledTransformation(); } $actions[$key] = $action; } return $actions; }
php
public function getPagerActions(array $controls, GridField $gridField) { $actions = array(); foreach ($controls as $key => $arguments) { $action = GridField_FormAction::create( $gridField, 'pagination_' . $key, $arguments['title'], 'paginate', $arguments['args'] ); if (isset($arguments['extra-class'])) { $action->addExtraClass($arguments['extra-class']); } if (isset($arguments['disable-previous']) && $arguments['disable-previous']) { $action = $action->performDisabledTransformation(); } elseif (isset($arguments['disable-next']) && $arguments['disable-next']) { $action = $action->performDisabledTransformation(); } $actions[$key] = $action; } return $actions; }
[ "public", "function", "getPagerActions", "(", "array", "$", "controls", ",", "GridField", "$", "gridField", ")", "{", "$", "actions", "=", "array", "(", ")", ";", "foreach", "(", "$", "controls", "as", "$", "key", "=>", "$", "arguments", ")", "{", "$",...
Returns FormActions for each of the pagination actions, in an array @param array $controls @param GridField $gridField @return GridField_FormAction[]
[ "Returns", "FormActions", "for", "each", "of", "the", "pagination", "actions", "in", "an", "array" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L388-L415
42,870
symbiote/silverstripe-gridfieldextensions
src/GridFieldConfigurablePaginator.php
GridFieldConfigurablePaginator.getGridPagerState
protected function getGridPagerState(GridField $gridField = null) { if (!$this->gridFieldState) { $state = $this->getGridField()->State->GridFieldConfigurablePaginator; // SS 3.1 compatibility (missing __call) if (is_object($state->firstShown)) { $state->firstShown = 1; } if (is_object($state->pageSize)) { $state->pageSize = $this->getItemsPerPage(); } // Handle free input in the page number field $parentState = $this->getGridField()->State->GridFieldPaginator; if (is_object($parentState->currentPage)) { $parentState->currentPage = 0; } if ($parentState->currentPage >= 1) { $state->firstShown = ($parentState->currentPage - 1) * $this->getItemsPerPage() + 1; $parentState->currentPage = null; } $this->gridFieldState = $state; } return $this->gridFieldState; }
php
protected function getGridPagerState(GridField $gridField = null) { if (!$this->gridFieldState) { $state = $this->getGridField()->State->GridFieldConfigurablePaginator; // SS 3.1 compatibility (missing __call) if (is_object($state->firstShown)) { $state->firstShown = 1; } if (is_object($state->pageSize)) { $state->pageSize = $this->getItemsPerPage(); } // Handle free input in the page number field $parentState = $this->getGridField()->State->GridFieldPaginator; if (is_object($parentState->currentPage)) { $parentState->currentPage = 0; } if ($parentState->currentPage >= 1) { $state->firstShown = ($parentState->currentPage - 1) * $this->getItemsPerPage() + 1; $parentState->currentPage = null; } $this->gridFieldState = $state; } return $this->gridFieldState; }
[ "protected", "function", "getGridPagerState", "(", "GridField", "$", "gridField", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "gridFieldState", ")", "{", "$", "state", "=", "$", "this", "->", "getGridField", "(", ")", "->", "State", "->", ...
Gets the state from the current request's GridField and sets some default values on it @param GridField $gridField Not used, but present for parent method compatibility @return GridState_Data
[ "Gets", "the", "state", "from", "the", "current", "request", "s", "GridField", "and", "sets", "some", "default", "values", "on", "it" ]
176922303e8fa27b9b52b68b635b58d09e0a0ec3
https://github.com/symbiote/silverstripe-gridfieldextensions/blob/176922303e8fa27b9b52b68b635b58d09e0a0ec3/src/GridFieldConfigurablePaginator.php#L428-L456
42,871
auth0/jwt-auth-bundle
src/Security/Auth0Service.php
Auth0Service.decodeJWT
public function decodeJWT($encToken) { $config = [ // The api_identifier setting could come through as an array or a string. 'valid_audiences' => is_array($this->api_identifier) ? $this->api_identifier : [$this->api_identifier], 'client_secret' => $this->api_secret, 'authorized_iss' => [$this->authorized_issuer], 'supported_algs' => $this->supported_algs, 'secret_base64_encoded' => $this->secret_base64_encoded ]; if (null !== $this->cache) { $config['cache'] = $this->cache; } $verifier = new JWTVerifier($config); return $verifier->verifyAndDecode($encToken); }
php
public function decodeJWT($encToken) { $config = [ // The api_identifier setting could come through as an array or a string. 'valid_audiences' => is_array($this->api_identifier) ? $this->api_identifier : [$this->api_identifier], 'client_secret' => $this->api_secret, 'authorized_iss' => [$this->authorized_issuer], 'supported_algs' => $this->supported_algs, 'secret_base64_encoded' => $this->secret_base64_encoded ]; if (null !== $this->cache) { $config['cache'] = $this->cache; } $verifier = new JWTVerifier($config); return $verifier->verifyAndDecode($encToken); }
[ "public", "function", "decodeJWT", "(", "$", "encToken", ")", "{", "$", "config", "=", "[", "// The api_identifier setting could come through as an array or a string.", "'valid_audiences'", "=>", "is_array", "(", "$", "this", "->", "api_identifier", ")", "?", "$", "th...
Decodes the JWT and validate it @return \stdClass
[ "Decodes", "the", "JWT", "and", "validate", "it" ]
7969686f06fc61d1858f217085813d769bf85894
https://github.com/auth0/jwt-auth-bundle/blob/7969686f06fc61d1858f217085813d769bf85894/src/Security/Auth0Service.php#L70-L88
42,872
TYPO3/styleguide
Classes/Controller/StyleguideController.php
StyleguideController.initializeView
protected function initializeView(ViewInterface $view) { parent::initializeView($view); // Early return for actions without valid view like tcaCreateAction or tcaDeleteAction if (!($this->view instanceof BackendTemplateView)) { return; } // Hand over flash message queue to module template $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); $this->view->assign('actions', ['index', 'typography', 'tca', 'trees', 'tab', 'tables', 'avatar', 'buttons', 'infobox', 'flashMessages', 'icons', 'debug', 'helpers', 'modal']); $this->view->assign('currentAction', $this->request->getControllerActionName()); // Shortcut button $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); $getVars = $this->request->getArguments(); $extensionName = $this->request->getControllerExtensionName(); $moduleName = $this->request->getPluginName(); if (count($getVars) === 0) { $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName); $getVars = array('id', 'M', $modulePrefix); } $shortcutButton = $buttonBar->makeShortcutButton() ->setModuleName($moduleName) ->setGetVariables($getVars); $buttonBar->addButton($shortcutButton); }
php
protected function initializeView(ViewInterface $view) { parent::initializeView($view); // Early return for actions without valid view like tcaCreateAction or tcaDeleteAction if (!($this->view instanceof BackendTemplateView)) { return; } // Hand over flash message queue to module template $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); $this->view->assign('actions', ['index', 'typography', 'tca', 'trees', 'tab', 'tables', 'avatar', 'buttons', 'infobox', 'flashMessages', 'icons', 'debug', 'helpers', 'modal']); $this->view->assign('currentAction', $this->request->getControllerActionName()); // Shortcut button $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); $getVars = $this->request->getArguments(); $extensionName = $this->request->getControllerExtensionName(); $moduleName = $this->request->getPluginName(); if (count($getVars) === 0) { $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName); $getVars = array('id', 'M', $modulePrefix); } $shortcutButton = $buttonBar->makeShortcutButton() ->setModuleName($moduleName) ->setGetVariables($getVars); $buttonBar->addButton($shortcutButton); }
[ "protected", "function", "initializeView", "(", "ViewInterface", "$", "view", ")", "{", "parent", "::", "initializeView", "(", "$", "view", ")", ";", "// Early return for actions without valid view like tcaCreateAction or tcaDeleteAction", "if", "(", "!", "(", "$", "thi...
Method is called before each action and sets up the doc header. @param ViewInterface $view
[ "Method", "is", "called", "before", "each", "action", "and", "sets", "up", "the", "doc", "header", "." ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/Controller/StyleguideController.php#L60-L88
42,873
TYPO3/styleguide
Classes/Controller/StyleguideController.php
StyleguideController.tcaCreateAction
public function tcaCreateAction() { /** @var Generator $generator */ $generator = GeneralUtility::makeInstance(Generator::class); $generator->create(); // Tell something was done here $this->addFlashMessage( LocalizationUtility::translate($this->languageFilePrefix . 'tcaCreateActionOkBody', 'styleguide'), LocalizationUtility::translate($this->languageFilePrefix . 'tcaCreateActionOkTitle', 'styleguide') ); // And redirect to display action $this->forward('tca'); }
php
public function tcaCreateAction() { /** @var Generator $generator */ $generator = GeneralUtility::makeInstance(Generator::class); $generator->create(); // Tell something was done here $this->addFlashMessage( LocalizationUtility::translate($this->languageFilePrefix . 'tcaCreateActionOkBody', 'styleguide'), LocalizationUtility::translate($this->languageFilePrefix . 'tcaCreateActionOkTitle', 'styleguide') ); // And redirect to display action $this->forward('tca'); }
[ "public", "function", "tcaCreateAction", "(", ")", "{", "/** @var Generator $generator */", "$", "generator", "=", "GeneralUtility", "::", "makeInstance", "(", "Generator", "::", "class", ")", ";", "$", "generator", "->", "create", "(", ")", ";", "// Tell somethin...
TCA create default data action
[ "TCA", "create", "default", "data", "action" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/Controller/StyleguideController.php#L135-L147
42,874
TYPO3/styleguide
Classes/Controller/StyleguideController.php
StyleguideController.tcaDeleteAction
public function tcaDeleteAction() { /** @var Generator $generator */ $generator = GeneralUtility::makeInstance(Generator::class); $generator->delete(); // Tell something was done here $this->addFlashMessage( LocalizationUtility::translate($this->languageFilePrefix . 'tcaDeleteActionOkBody', 'styleguide'), LocalizationUtility::translate($this->languageFilePrefix . 'tcaDeleteActionOkTitle', 'styleguide') ); // And redirect to display action $this->forward('tca'); }
php
public function tcaDeleteAction() { /** @var Generator $generator */ $generator = GeneralUtility::makeInstance(Generator::class); $generator->delete(); // Tell something was done here $this->addFlashMessage( LocalizationUtility::translate($this->languageFilePrefix . 'tcaDeleteActionOkBody', 'styleguide'), LocalizationUtility::translate($this->languageFilePrefix . 'tcaDeleteActionOkTitle', 'styleguide') ); // And redirect to display action $this->forward('tca'); }
[ "public", "function", "tcaDeleteAction", "(", ")", "{", "/** @var Generator $generator */", "$", "generator", "=", "GeneralUtility", "::", "makeInstance", "(", "Generator", "::", "class", ")", ";", "$", "generator", "->", "delete", "(", ")", ";", "// Tell somethin...
TCA delete default data action
[ "TCA", "delete", "default", "data", "action" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/Controller/StyleguideController.php#L152-L164
42,875
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGenerator/TypeInlineExpandsingle.php
TypeInlineExpandsingle.generate
public function generate(array $data): string { $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_expandsingle_child'); $childRowsToCreate = 3; for ($i = 0; $i < $childRowsToCreate; $i++) { // Insert an empty row again to have the uid already. This is useful for // possible further inline that may be attached to this child. $childFieldValues = [ 'pid' => $data['fieldValues']['pid'], 'parentid' => $data['fieldValues']['uid'], 'parenttable' => $data['tableName'], ]; $connection->insert( 'tx_styleguide_inline_expandsingle_child', $childFieldValues ); $childFieldValues['uid'] = $connection->lastInsertId('tx_styleguide_inline_expandsingle_child'); $recordData = GeneralUtility::makeInstance(RecordData::class); $childFieldValues = $recordData->generate('tx_styleguide_inline_expandsingle_child', $childFieldValues); $connection->update( 'tx_styleguide_inline_expandsingle_child', $childFieldValues, [ 'uid' => $childFieldValues['uid'] ] ); } return (string)$childRowsToCreate; }
php
public function generate(array $data): string { $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_expandsingle_child'); $childRowsToCreate = 3; for ($i = 0; $i < $childRowsToCreate; $i++) { // Insert an empty row again to have the uid already. This is useful for // possible further inline that may be attached to this child. $childFieldValues = [ 'pid' => $data['fieldValues']['pid'], 'parentid' => $data['fieldValues']['uid'], 'parenttable' => $data['tableName'], ]; $connection->insert( 'tx_styleguide_inline_expandsingle_child', $childFieldValues ); $childFieldValues['uid'] = $connection->lastInsertId('tx_styleguide_inline_expandsingle_child'); $recordData = GeneralUtility::makeInstance(RecordData::class); $childFieldValues = $recordData->generate('tx_styleguide_inline_expandsingle_child', $childFieldValues); $connection->update( 'tx_styleguide_inline_expandsingle_child', $childFieldValues, [ 'uid' => $childFieldValues['uid'] ] ); } return (string)$childRowsToCreate; }
[ "public", "function", "generate", "(", "array", "$", "data", ")", ":", "string", "{", "$", "connectionPool", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", ";", "$", "connection", "=", "$", "connectionPool", "->", "ge...
Generate 3 child rows @param array $data @return string
[ "Generate", "3", "child", "rows" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGenerator/TypeInlineExpandsingle.php#L62-L89
42,876
TYPO3/styleguide
Classes/TcaDataGenerator/TableHandler/InlineMnSymmetric.php
InlineMnSymmetric.handle
public function handle(string $tableName) { $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName); $recordData = GeneralUtility::makeInstance(RecordData::class); $isFirst = true; $numberOfRelationsForFirstRecord = 2; $relationUids = []; $uidOfFirstRecord = null; for ($i = 0; $i < 4; $i++) { $fieldValues = [ 'pid' => $pidOfMainTable, ]; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $fieldValues); $fieldValues['uid'] = $connection->lastInsertId($tableName); if ($isFirst) { $fieldValues['branches'] = $numberOfRelationsForFirstRecord; $uidOfFirstRecord = $fieldValues['uid']; } $fieldValues = $recordData->generate($tableName, $fieldValues); $connection->update( $tableName, $fieldValues, [ 'uid' => $fieldValues['uid'] ] ); $this->generateTranslatedRecords($tableName, $fieldValues); if (!$isFirst && count($relationUids) < $numberOfRelationsForFirstRecord) { $relationUids[] = $fieldValues['uid']; } $isFirst = false; } foreach ($relationUids as $uid) { $mmFieldValues = [ 'pid' => $pidOfMainTable, 'hotelid' => $uidOfFirstRecord, 'branchid' => $uid, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mnsymmetric_mm'); $connection->insert( 'tx_styleguide_inline_mnsymmetric_mm', $mmFieldValues ); } }
php
public function handle(string $tableName) { $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName); $recordData = GeneralUtility::makeInstance(RecordData::class); $isFirst = true; $numberOfRelationsForFirstRecord = 2; $relationUids = []; $uidOfFirstRecord = null; for ($i = 0; $i < 4; $i++) { $fieldValues = [ 'pid' => $pidOfMainTable, ]; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $fieldValues); $fieldValues['uid'] = $connection->lastInsertId($tableName); if ($isFirst) { $fieldValues['branches'] = $numberOfRelationsForFirstRecord; $uidOfFirstRecord = $fieldValues['uid']; } $fieldValues = $recordData->generate($tableName, $fieldValues); $connection->update( $tableName, $fieldValues, [ 'uid' => $fieldValues['uid'] ] ); $this->generateTranslatedRecords($tableName, $fieldValues); if (!$isFirst && count($relationUids) < $numberOfRelationsForFirstRecord) { $relationUids[] = $fieldValues['uid']; } $isFirst = false; } foreach ($relationUids as $uid) { $mmFieldValues = [ 'pid' => $pidOfMainTable, 'hotelid' => $uidOfFirstRecord, 'branchid' => $uid, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mnsymmetric_mm'); $connection->insert( 'tx_styleguide_inline_mnsymmetric_mm', $mmFieldValues ); } }
[ "public", "function", "handle", "(", "string", "$", "tableName", ")", "{", "$", "connectionPool", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", ";", "$", "recordFinder", "=", "GeneralUtility", "::", "makeInstance", "(", ...
Create 4 rows, add row 2 and 3 as branch to row 1 @param string $tableName @return string
[ "Create", "4", "rows", "add", "row", "2", "and", "3", "as", "branch", "to", "row", "1" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/TableHandler/InlineMnSymmetric.php#L40-L91
42,877
TYPO3/styleguide
Classes/TcaDataGenerator/TableHandler/InlineMn.php
InlineMn.handle
public function handle(string $tableName) { $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName); $recordData = GeneralUtility::makeInstance(RecordData::class); $childRelationUids = []; $numberOfChildRelationsToCreate = 2; $numberOfChildRows = 4; $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); for ($i = 0; $i < $numberOfChildRows; $i ++) { $fieldValues = [ 'pid' => $pidOfMainTable, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mn_child'); $connection->insert('tx_styleguide_inline_mn_child', $fieldValues); $fieldValues['uid'] = $connection->lastInsertId('tx_styleguide_inline_mn_child'); if (count($childRelationUids) < $numberOfChildRelationsToCreate) { $childRelationUids[] = $fieldValues['uid']; } $fieldValues = $recordData->generate('tx_styleguide_inline_mn_child', $fieldValues); $connection->update( 'tx_styleguide_inline_mn_child', $fieldValues, [ 'uid' => (int)$fieldValues['uid'] ] ); } $fieldValues = [ 'pid' => $pidOfMainTable, 'inline_1' => $numberOfChildRelationsToCreate, ]; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $fieldValues); $parentid = $fieldValues['uid'] = $connection->lastInsertId($tableName); $fieldValues = $recordData->generate($tableName, $fieldValues); $connection->update( $tableName, $fieldValues, [ 'uid' => (int)$fieldValues['uid'] ] ); $this->generateTranslatedRecords($tableName, $fieldValues); foreach ($childRelationUids as $uid) { $mmFieldValues = [ 'pid' => $pidOfMainTable, 'parentid' => $parentid, 'childid' => $uid, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mn_mm'); $connection->insert('tx_styleguide_inline_mn_mm', $mmFieldValues); } }
php
public function handle(string $tableName) { $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $pidOfMainTable = $recordFinder->findPidOfMainTableRecord($tableName); $recordData = GeneralUtility::makeInstance(RecordData::class); $childRelationUids = []; $numberOfChildRelationsToCreate = 2; $numberOfChildRows = 4; $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); for ($i = 0; $i < $numberOfChildRows; $i ++) { $fieldValues = [ 'pid' => $pidOfMainTable, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mn_child'); $connection->insert('tx_styleguide_inline_mn_child', $fieldValues); $fieldValues['uid'] = $connection->lastInsertId('tx_styleguide_inline_mn_child'); if (count($childRelationUids) < $numberOfChildRelationsToCreate) { $childRelationUids[] = $fieldValues['uid']; } $fieldValues = $recordData->generate('tx_styleguide_inline_mn_child', $fieldValues); $connection->update( 'tx_styleguide_inline_mn_child', $fieldValues, [ 'uid' => (int)$fieldValues['uid'] ] ); } $fieldValues = [ 'pid' => $pidOfMainTable, 'inline_1' => $numberOfChildRelationsToCreate, ]; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $fieldValues); $parentid = $fieldValues['uid'] = $connection->lastInsertId($tableName); $fieldValues = $recordData->generate($tableName, $fieldValues); $connection->update( $tableName, $fieldValues, [ 'uid' => (int)$fieldValues['uid'] ] ); $this->generateTranslatedRecords($tableName, $fieldValues); foreach ($childRelationUids as $uid) { $mmFieldValues = [ 'pid' => $pidOfMainTable, 'parentid' => $parentid, 'childid' => $uid, ]; $connection = $connectionPool->getConnectionForTable('tx_styleguide_inline_mn_mm'); $connection->insert('tx_styleguide_inline_mn_mm', $mmFieldValues); } }
[ "public", "function", "handle", "(", "string", "$", "tableName", ")", "{", "$", "recordFinder", "=", "GeneralUtility", "::", "makeInstance", "(", "RecordFinder", "::", "class", ")", ";", "$", "pidOfMainTable", "=", "$", "recordFinder", "->", "findPidOfMainTableR...
Create 1 main row, 4 child child rows, add 2 child child rows in mn @param string $tableName @return string
[ "Create", "1", "main", "row", "4", "child", "child", "rows", "add", "2", "child", "child", "rows", "in", "mn" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/TableHandler/InlineMn.php#L40-L93
42,878
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGenerator/TypeSelect.php
TypeSelect.generate
public function generate(array $data): string { $result = []; if (isset($data['fieldConfig']['config']['items']) && count($data['fieldConfig']['config']['items']) > 1) { $numberOfItemsToSelect = 1; if (isset($data['fieldConfig']['config']['minitems'])) { $numberOfItemsToSelect = $data['fieldConfig']['config']['minitems']; } $isFirst = true; foreach ($data['fieldConfig']['config']['items'] as $item) { if ($isFirst) { // Ignore first item $isFirst = false; continue; } // Ignore divider if (isset($item[1]) && $item[1] !== '--div--') { if (count($result) <= $numberOfItemsToSelect) { $result[] = $item[1]; } if (count($result) === $numberOfItemsToSelect) { break; } } } } return implode(',', $result); }
php
public function generate(array $data): string { $result = []; if (isset($data['fieldConfig']['config']['items']) && count($data['fieldConfig']['config']['items']) > 1) { $numberOfItemsToSelect = 1; if (isset($data['fieldConfig']['config']['minitems'])) { $numberOfItemsToSelect = $data['fieldConfig']['config']['minitems']; } $isFirst = true; foreach ($data['fieldConfig']['config']['items'] as $item) { if ($isFirst) { // Ignore first item $isFirst = false; continue; } // Ignore divider if (isset($item[1]) && $item[1] !== '--div--') { if (count($result) <= $numberOfItemsToSelect) { $result[] = $item[1]; } if (count($result) === $numberOfItemsToSelect) { break; } } } } return implode(',', $result); }
[ "public", "function", "generate", "(", "array", "$", "data", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "data", "[", "'fieldConfig'", "]", "[", "'config'", "]", "[", "'items'", "]", ")", "&&", "count",...
Selects the second item from a static item list if there are at least two items. @param array $data @return string
[ "Selects", "the", "second", "item", "from", "a", "static", "item", "list", "if", "there", "are", "at", "least", "two", "items", "." ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGenerator/TypeSelect.php#L45-L72
42,879
TYPO3/styleguide
Classes/UserFunctions/ExtensionConfiguration/User1.php
User1.user_1
public function user_1(&$params, &$tsObj) { $out = ''; // Params; $out .= '<pre>'; ob_start(); var_dump($params); $out .= ob_get_contents(); ob_end_clean(); $out .= '</pre>'; return $out; }
php
public function user_1(&$params, &$tsObj) { $out = ''; // Params; $out .= '<pre>'; ob_start(); var_dump($params); $out .= ob_get_contents(); ob_end_clean(); $out .= '</pre>'; return $out; }
[ "public", "function", "user_1", "(", "&", "$", "params", ",", "&", "$", "tsObj", ")", "{", "$", "out", "=", "''", ";", "// Params;", "$", "out", ".=", "'<pre>'", ";", "ob_start", "(", ")", ";", "var_dump", "(", "$", "params", ")", ";", "$", "out"...
Simple user function returning a var_dump of input parameters @param array $params @param mixed $tsObj @return string
[ "Simple", "user", "function", "returning", "a", "var_dump", "of", "input", "parameters" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/UserFunctions/ExtensionConfiguration/User1.php#L29-L42
42,880
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGeneratorResolver.php
FieldGeneratorResolver.resolve
public function resolve(array $data): FieldGeneratorInterface { $generator = NULL; foreach ($this->fieldValueGenerators as $fieldValueGenerator) { $generator = GeneralUtility::makeInstance($fieldValueGenerator); if (!$generator instanceof FieldGeneratorInterface) { throw new Exception( 'Field value generator ' . $fieldValueGenerator . ' must implement FieldGeneratorInterface', 1457693564 ); } if ($generator->match($data)) { break; } else { $generator = null; } } if (is_null($generator)) { throw new GeneratorNotFoundException( 'No generator found', 1457873493 ); } return $generator; }
php
public function resolve(array $data): FieldGeneratorInterface { $generator = NULL; foreach ($this->fieldValueGenerators as $fieldValueGenerator) { $generator = GeneralUtility::makeInstance($fieldValueGenerator); if (!$generator instanceof FieldGeneratorInterface) { throw new Exception( 'Field value generator ' . $fieldValueGenerator . ' must implement FieldGeneratorInterface', 1457693564 ); } if ($generator->match($data)) { break; } else { $generator = null; } } if (is_null($generator)) { throw new GeneratorNotFoundException( 'No generator found', 1457873493 ); } return $generator; }
[ "public", "function", "resolve", "(", "array", "$", "data", ")", ":", "FieldGeneratorInterface", "{", "$", "generator", "=", "NULL", ";", "foreach", "(", "$", "this", "->", "fieldValueGenerators", "as", "$", "fieldValueGenerator", ")", "{", "$", "generator", ...
Resolve a generator class and return its instance. Either returns an instance of FieldGeneratorInterface or throws exception @param array $data Criteria data @return FieldGeneratorInterface @throws GeneratorNotFoundException|Exception
[ "Resolve", "a", "generator", "class", "and", "return", "its", "instance", ".", "Either", "returns", "an", "instance", "of", "FieldGeneratorInterface", "or", "throws", "exception" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGeneratorResolver.php#L119-L143
42,881
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGenerator/TypeInlineUsecombination.php
TypeInlineUsecombination.match
public function match(array $data): bool { $match = parent::match($data); if ($match) { if ($data['fieldConfig']['config']['foreign_table'] !== 'tx_styleguide_inline_usecombination_mm' && $data['fieldConfig']['config']['foreign_table'] !== 'tx_styleguide_inline_usecombinationbox_mm' ) { $match = false; } } return $match; }
php
public function match(array $data): bool { $match = parent::match($data); if ($match) { if ($data['fieldConfig']['config']['foreign_table'] !== 'tx_styleguide_inline_usecombination_mm' && $data['fieldConfig']['config']['foreign_table'] !== 'tx_styleguide_inline_usecombinationbox_mm' ) { $match = false; } } return $match; }
[ "public", "function", "match", "(", "array", "$", "data", ")", ":", "bool", "{", "$", "match", "=", "parent", "::", "match", "(", "$", "data", ")", ";", "if", "(", "$", "match", ")", "{", "if", "(", "$", "data", "[", "'fieldConfig'", "]", "[", ...
Check for tx_styleguide_inline_usecombination and tx_styleguide_inline_usecombinationbox table @param array $data @return bool
[ "Check", "for", "tx_styleguide_inline_usecombination", "and", "tx_styleguide_inline_usecombinationbox", "table" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGenerator/TypeInlineUsecombination.php#L52-L63
42,882
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGenerator/TypeInlineUsecombination.php
TypeInlineUsecombination.generate
public function generate(array $data): string { if (!isset($GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'])) { throw new \RuntimeException( 'mm child table name not found', 1459941569 ); } $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $childChildTableName = $GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table']; $numberOfChildChildRowsToCreate = 4; $uidsOfChildrenToConnect = []; for ($i = 0; $i < $numberOfChildChildRowsToCreate; $i++) { // Insert an empty row again to have the uid already. This is useful for // possible further inline that may be attached to this child. $childFieldValues = [ 'pid' => $data['fieldValues']['pid'], ]; $connection = $connectionPool->getConnectionForTable($childChildTableName); $connection->insert($childChildTableName, $childFieldValues); $childFieldValues['uid'] = $connection->lastInsertId($childChildTableName); if (count($uidsOfChildrenToConnect) < 2) { $uidsOfChildrenToConnect[] = $childFieldValues['uid']; } $recordData = GeneralUtility::makeInstance(RecordData::class); $childFieldValues = $recordData->generate($childChildTableName, $childFieldValues); $connection->update( $childChildTableName, $childFieldValues, [ 'uid' => (int)$childFieldValues['uid'] ] ); } foreach ($uidsOfChildrenToConnect as $uid) { $mmFieldValues = [ 'pid' => $data['fieldValues']['pid'], 'select_parent' => $data['fieldValues']['uid'], 'select_child' => $uid, ]; $tableName = $data['fieldConfig']['config']['foreign_table']; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $mmFieldValues); } return (string)count($uidsOfChildrenToConnect); }
php
public function generate(array $data): string { if (!isset($GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table'])) { throw new \RuntimeException( 'mm child table name not found', 1459941569 ); } $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $childChildTableName = $GLOBALS['TCA'][$data['fieldConfig']['config']['foreign_table']]['columns']['select_child']['config']['foreign_table']; $numberOfChildChildRowsToCreate = 4; $uidsOfChildrenToConnect = []; for ($i = 0; $i < $numberOfChildChildRowsToCreate; $i++) { // Insert an empty row again to have the uid already. This is useful for // possible further inline that may be attached to this child. $childFieldValues = [ 'pid' => $data['fieldValues']['pid'], ]; $connection = $connectionPool->getConnectionForTable($childChildTableName); $connection->insert($childChildTableName, $childFieldValues); $childFieldValues['uid'] = $connection->lastInsertId($childChildTableName); if (count($uidsOfChildrenToConnect) < 2) { $uidsOfChildrenToConnect[] = $childFieldValues['uid']; } $recordData = GeneralUtility::makeInstance(RecordData::class); $childFieldValues = $recordData->generate($childChildTableName, $childFieldValues); $connection->update( $childChildTableName, $childFieldValues, [ 'uid' => (int)$childFieldValues['uid'] ] ); } foreach ($uidsOfChildrenToConnect as $uid) { $mmFieldValues = [ 'pid' => $data['fieldValues']['pid'], 'select_parent' => $data['fieldValues']['uid'], 'select_child' => $uid, ]; $tableName = $data['fieldConfig']['config']['foreign_table']; $connection = $connectionPool->getConnectionForTable($tableName); $connection->insert($tableName, $mmFieldValues); } return (string)count($uidsOfChildrenToConnect); }
[ "public", "function", "generate", "(", "array", "$", "data", ")", ":", "string", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "data", "[", "'fieldConfig'", "]", "[", "'config'", "]", "[", "'foreign_table'", "]", "]"...
Generate 4 child child rows, connect 2 of them in mm table @param array $data @return string
[ "Generate", "4", "child", "child", "rows", "connect", "2", "of", "them", "in", "mm", "table" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGenerator/TypeInlineUsecombination.php#L71-L114
42,883
TYPO3/styleguide
Classes/TcaDataGenerator/FieldGenerator/TypeInline1n.php
TypeInline1n.match
public function match(array $data): bool { $result = $this->checkMatchArray($data, $this->matchArray); if ($result && isset($data['fieldConfig']['config']['foreign_table'])) { $result = true; } else { $result = false; } return $result; }
php
public function match(array $data): bool { $result = $this->checkMatchArray($data, $this->matchArray); if ($result && isset($data['fieldConfig']['config']['foreign_table'])) { $result = true; } else { $result = false; } return $result; }
[ "public", "function", "match", "(", "array", "$", "data", ")", ":", "bool", "{", "$", "result", "=", "$", "this", "->", "checkMatchArray", "(", "$", "data", ",", "$", "this", "->", "matchArray", ")", ";", "if", "(", "$", "result", "&&", "isset", "(...
Additionally check that "foreign_table" is set to something. @param array $data @return bool
[ "Additionally", "check", "that", "foreign_table", "is", "set", "to", "something", "." ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/FieldGenerator/TypeInline1n.php#L47-L56
42,884
TYPO3/styleguide
Classes/TcaDataGenerator/Generator.php
Generator.create
public function create() { // Add entry page on top level $newIdOfEntryPage = StringUtility::getUniqueId('NEW'); $data = [ 'pages' => [ $newIdOfEntryPage => [ 'title' => 'styleguide TCA demo', 'pid' => 0 - $this->getUidOfLastTopLevelPage(), // Mark this page as entry point 'tx_styleguide_containsdemo' => 'tx_styleguide', // Have the "globus" icon for this page 'is_siteroot' => 1, ], ], ]; // Add rows of third party tables like be_users and fal records $this->populateRowsOfThirdPartyTables(); $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $sysLanguageStyleguideDemoUids = $recordFinder->findUidsOfDemoLanguages(); // Add a page for each main table below entry page $mainTables = $this->getListOfStyleguideMainTables(); // Have the first main table inside entry page $neighborPage = $newIdOfEntryPage; foreach ($mainTables as $mainTable) { $newIdOfPage = StringUtility::getUniqueId('NEW'); $data['pages'][$newIdOfPage] = [ 'title' => str_replace('_', ' ', substr($mainTable, strlen('tx_styleguide_'))), 'tx_styleguide_containsdemo' => $mainTable, 'hidden' => 0, 'pid' => $neighborPage, ]; if (!empty($sysLanguageStyleguideDemoUids)) { foreach ($sysLanguageStyleguideDemoUids as $languageUid) { $newIdOfLocalizedPage = StringUtility::getUniqueId('NEW'); $data['pages'][$newIdOfLocalizedPage] = [ 'title' => str_replace('_', ' ', substr($mainTable . " - language " . $languageUid, strlen('tx_styleguide_'))), 'tx_styleguide_containsdemo' => $mainTable, 'hidden' => 0, 'pid' => $neighborPage, 'sys_language_uid' => $languageUid, 'l10n_parent' => $newIdOfPage, 'l10n_source' => $newIdOfPage, ]; } } // Have next page after this page $neighborPage = '-' . $newIdOfPage; } // Populate page tree via DataHandler $dataHandler = GeneralUtility::makeInstance(DataHandler::class); $dataHandler->start($data, []); $dataHandler->process_datamap(); BackendUtility::setUpdateSignal('updatePageTree'); // Create data for each main table foreach ($mainTables as $mainTable) { $generator = NULL; foreach ($this->tableHandler as $handlerName) { $generator = GeneralUtility::makeInstance($handlerName); if (!$generator instanceof TableHandlerInterface) { throw new Exception( 'Table handler ' . $handlerName . ' must implement TableHandlerInterface', 1458302830 ); } if ($generator->match($mainTable)) { break; } else { $generator = null; } } if (is_null($generator)) { throw new GeneratorNotFoundException( 'No table handler found', 1458302901 ); } $generator->handle($mainTable); } }
php
public function create() { // Add entry page on top level $newIdOfEntryPage = StringUtility::getUniqueId('NEW'); $data = [ 'pages' => [ $newIdOfEntryPage => [ 'title' => 'styleguide TCA demo', 'pid' => 0 - $this->getUidOfLastTopLevelPage(), // Mark this page as entry point 'tx_styleguide_containsdemo' => 'tx_styleguide', // Have the "globus" icon for this page 'is_siteroot' => 1, ], ], ]; // Add rows of third party tables like be_users and fal records $this->populateRowsOfThirdPartyTables(); $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $sysLanguageStyleguideDemoUids = $recordFinder->findUidsOfDemoLanguages(); // Add a page for each main table below entry page $mainTables = $this->getListOfStyleguideMainTables(); // Have the first main table inside entry page $neighborPage = $newIdOfEntryPage; foreach ($mainTables as $mainTable) { $newIdOfPage = StringUtility::getUniqueId('NEW'); $data['pages'][$newIdOfPage] = [ 'title' => str_replace('_', ' ', substr($mainTable, strlen('tx_styleguide_'))), 'tx_styleguide_containsdemo' => $mainTable, 'hidden' => 0, 'pid' => $neighborPage, ]; if (!empty($sysLanguageStyleguideDemoUids)) { foreach ($sysLanguageStyleguideDemoUids as $languageUid) { $newIdOfLocalizedPage = StringUtility::getUniqueId('NEW'); $data['pages'][$newIdOfLocalizedPage] = [ 'title' => str_replace('_', ' ', substr($mainTable . " - language " . $languageUid, strlen('tx_styleguide_'))), 'tx_styleguide_containsdemo' => $mainTable, 'hidden' => 0, 'pid' => $neighborPage, 'sys_language_uid' => $languageUid, 'l10n_parent' => $newIdOfPage, 'l10n_source' => $newIdOfPage, ]; } } // Have next page after this page $neighborPage = '-' . $newIdOfPage; } // Populate page tree via DataHandler $dataHandler = GeneralUtility::makeInstance(DataHandler::class); $dataHandler->start($data, []); $dataHandler->process_datamap(); BackendUtility::setUpdateSignal('updatePageTree'); // Create data for each main table foreach ($mainTables as $mainTable) { $generator = NULL; foreach ($this->tableHandler as $handlerName) { $generator = GeneralUtility::makeInstance($handlerName); if (!$generator instanceof TableHandlerInterface) { throw new Exception( 'Table handler ' . $handlerName . ' must implement TableHandlerInterface', 1458302830 ); } if ($generator->match($mainTable)) { break; } else { $generator = null; } } if (is_null($generator)) { throw new GeneratorNotFoundException( 'No table handler found', 1458302901 ); } $generator->handle($mainTable); } }
[ "public", "function", "create", "(", ")", "{", "// Add entry page on top level", "$", "newIdOfEntryPage", "=", "StringUtility", "::", "getUniqueId", "(", "'NEW'", ")", ";", "$", "data", "=", "[", "'pages'", "=>", "[", "$", "newIdOfEntryPage", "=>", "[", "'titl...
Create a page tree for styleguide records and add records on them. @throws Exception @throws GeneratorNotFoundException
[ "Create", "a", "page", "tree", "for", "styleguide", "records", "and", "add", "records", "on", "them", "." ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/Generator.php#L59-L144
42,885
TYPO3/styleguide
Classes/TcaDataGenerator/Generator.php
Generator.delete
public function delete() { $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $commands = []; // Delete page tree and all their records on this tree $topUids = $recordFinder->findUidsOfStyleguideEntryPages(); if (!empty($topUids)) { foreach ($topUids as $topUid) { $commands['pages'][(int)$topUid]['delete'] = 1; } } // Delete all the sys_language demo records $languageUids = $recordFinder->findUidsOfDemoLanguages(); if (!empty($languageUids)) { foreach ($languageUids as $languageUid) { $commands['sys_language'][(int)$languageUid]['delete'] = 1; } } // Delete demo users $demoUserUids = $recordFinder->findUidsOfDemoBeUsers(); if (!empty($demoUserUids)) { foreach ($demoUserUids as $demoUserUid) { $commands['be_users'][(int)$demoUserUid]['delete'] = 1; } } // Delete demo groups $demoGroupUids = $recordFinder->findUidsOfDemoBeGroups(); if (!empty($demoGroupUids)) { foreach ($demoGroupUids as $demoUserGroup) { $commands['be_groups'][(int)$demoUserGroup]['delete'] = 1; } } // Do the thing if (!empty($commands)) { $dataHandler = GeneralUtility::makeInstance(DataHandler::class); $dataHandler->deleteTree = true; $dataHandler->start([], $commands); $dataHandler->process_cmdmap(); BackendUtility::setUpdateSignal('updatePageTree'); } // Delete demo images in fileadmin again $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); $storage = $storageRepository->findByUid(1); $folder = $storage->getRootLevelFolder(); try { $folder = $folder->getSubfolder('styleguide'); $folder->delete(true); } catch (\InvalidArgumentException $e) { // No op if folder does not exist } }
php
public function delete() { $recordFinder = GeneralUtility::makeInstance(RecordFinder::class); $commands = []; // Delete page tree and all their records on this tree $topUids = $recordFinder->findUidsOfStyleguideEntryPages(); if (!empty($topUids)) { foreach ($topUids as $topUid) { $commands['pages'][(int)$topUid]['delete'] = 1; } } // Delete all the sys_language demo records $languageUids = $recordFinder->findUidsOfDemoLanguages(); if (!empty($languageUids)) { foreach ($languageUids as $languageUid) { $commands['sys_language'][(int)$languageUid]['delete'] = 1; } } // Delete demo users $demoUserUids = $recordFinder->findUidsOfDemoBeUsers(); if (!empty($demoUserUids)) { foreach ($demoUserUids as $demoUserUid) { $commands['be_users'][(int)$demoUserUid]['delete'] = 1; } } // Delete demo groups $demoGroupUids = $recordFinder->findUidsOfDemoBeGroups(); if (!empty($demoGroupUids)) { foreach ($demoGroupUids as $demoUserGroup) { $commands['be_groups'][(int)$demoUserGroup]['delete'] = 1; } } // Do the thing if (!empty($commands)) { $dataHandler = GeneralUtility::makeInstance(DataHandler::class); $dataHandler->deleteTree = true; $dataHandler->start([], $commands); $dataHandler->process_cmdmap(); BackendUtility::setUpdateSignal('updatePageTree'); } // Delete demo images in fileadmin again $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); $storage = $storageRepository->findByUid(1); $folder = $storage->getRootLevelFolder(); try { $folder = $folder->getSubfolder('styleguide'); $folder->delete(true); } catch (\InvalidArgumentException $e) { // No op if folder does not exist } }
[ "public", "function", "delete", "(", ")", "{", "$", "recordFinder", "=", "GeneralUtility", "::", "makeInstance", "(", "RecordFinder", "::", "class", ")", ";", "$", "commands", "=", "[", "]", ";", "// Delete page tree and all their records on this tree", "$", "topU...
Delete all pages and their records that belong to the tx_styleguide demo pages @return void
[ "Delete", "all", "pages", "and", "their", "records", "that", "belong", "to", "the", "tx_styleguide", "demo", "pages" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/Generator.php#L152-L209
42,886
TYPO3/styleguide
Classes/TcaDataGenerator/Generator.php
Generator.getListOfStyleguideMainTables
protected function getListOfStyleguideMainTables(): array { $prefixes = [ 'tx_styleguide_', 'tx_styleguide_elements_', 'tx_styleguide_inline_', ]; $result = []; foreach ($GLOBALS['TCA'] as $tablename => $_) { if ($tablename === 'tx_styleguide_staticdata') { continue; } foreach ($prefixes as $prefix) { if (!StringUtility::beginsWith($tablename, $prefix)) { continue; } // See if string after $prefix is only one _ separated segment $suffix = substr($tablename, strlen($prefix)); $suffixArray = explode('_', $suffix); if (count($suffixArray) !== 1) { continue; } // Found a main table $result[] = $tablename; // No need to scan other prefixes break; } } // Manual resorting - the "staticdata" table is used by other tables later. // We resort this on top so it is handled first and other tables can rely on // created data already. This is a bit hacky but a quick workaround. array_unshift($result, 'tx_styleguide_staticdata'); return $result; }
php
protected function getListOfStyleguideMainTables(): array { $prefixes = [ 'tx_styleguide_', 'tx_styleguide_elements_', 'tx_styleguide_inline_', ]; $result = []; foreach ($GLOBALS['TCA'] as $tablename => $_) { if ($tablename === 'tx_styleguide_staticdata') { continue; } foreach ($prefixes as $prefix) { if (!StringUtility::beginsWith($tablename, $prefix)) { continue; } // See if string after $prefix is only one _ separated segment $suffix = substr($tablename, strlen($prefix)); $suffixArray = explode('_', $suffix); if (count($suffixArray) !== 1) { continue; } // Found a main table $result[] = $tablename; // No need to scan other prefixes break; } } // Manual resorting - the "staticdata" table is used by other tables later. // We resort this on top so it is handled first and other tables can rely on // created data already. This is a bit hacky but a quick workaround. array_unshift($result, 'tx_styleguide_staticdata'); return $result; }
[ "protected", "function", "getListOfStyleguideMainTables", "(", ")", ":", "array", "{", "$", "prefixes", "=", "[", "'tx_styleguide_'", ",", "'tx_styleguide_elements_'", ",", "'tx_styleguide_inline_'", ",", "]", ";", "$", "result", "=", "[", "]", ";", "foreach", "...
List of styleguide "main" pages. A styleguide table is either a "main" entry table or a "child" table that belongs to a main table. Each "main" table is located at an own page with all its children. The difference is a naming thing, styleguide tables have a "prefix"_"identifier"_"childidentifier" structure. Example: prefix = tx_styleguide_inline, identifier = 1n -> "tx_styleguide_inline_1n" is a "main" table -> "tx_styleguide_inline_1n1n" is a "child" table In general the list of prefixes is hard coded. If a specific table name is a concatenation of a prefix plus a single word, then the table is considered a "main" table, if there are more than one words after prefix, it is a "child" table. This method return the list of "main" tables. @return array
[ "List", "of", "styleguide", "main", "pages", "." ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/Generator.php#L331-L367
42,887
TYPO3/styleguide
Classes/TcaDataGenerator/RecordFinder.php
RecordFinder.findUidsOfStyleguideEntryPages
public function findUidsOfStyleguideEntryPages(): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $rows = $queryBuilder->select('uid') ->from('pages') ->where( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 'tx_styleguide_containsdemo', $queryBuilder->createNamedParameter('tx_styleguide', \PDO::PARAM_STR) ) ) ->execute() ->fetchAll(); $uids = []; if (is_array($rows)) { foreach ($rows as $row) { $uids[] = (int)$row['uid']; } } return $uids; }
php
public function findUidsOfStyleguideEntryPages(): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $rows = $queryBuilder->select('uid') ->from('pages') ->where( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 'tx_styleguide_containsdemo', $queryBuilder->createNamedParameter('tx_styleguide', \PDO::PARAM_STR) ) ) ->execute() ->fetchAll(); $uids = []; if (is_array($rows)) { foreach ($rows as $row) { $uids[] = (int)$row['uid']; } } return $uids; }
[ "public", "function", "findUidsOfStyleguideEntryPages", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "(", "'pages'", ")", ";", "$", "query...
Returns a uid list of existing styleguide demo top level pages. These are pages with pid=0 and tx_styleguide_containsdemo set to 'tx_styleguide'. This can be multiple pages if "create" button was clicked multiple times without "delete" in between. @return array
[ "Returns", "a", "uid", "list", "of", "existing", "styleguide", "demo", "top", "level", "pages", ".", "These", "are", "pages", "with", "pid", "=", "0", "and", "tx_styleguide_containsdemo", "set", "to", "tx_styleguide", ".", "This", "can", "be", "multiple", "p...
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/RecordFinder.php#L37-L62
42,888
TYPO3/styleguide
Classes/TcaDataGenerator/RecordFinder.php
RecordFinder.findPidOfMainTableRecord
public function findPidOfMainTableRecord(string $tableName): int { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $row = $queryBuilder->select('uid') ->from('pages') ->where( $queryBuilder->expr()->eq( 'tx_styleguide_containsdemo', $queryBuilder->createNamedParameter($tableName, \PDO::PARAM_STR) ) ) ->orderBy('pid', 'DESC') ->execute() ->fetch(); if (count($row) !== 1) { throw new Exception( 'Found no page for main table ' . $tableName, 1457690656 ); } return (int)$row['uid']; }
php
public function findPidOfMainTableRecord(string $tableName): int { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $row = $queryBuilder->select('uid') ->from('pages') ->where( $queryBuilder->expr()->eq( 'tx_styleguide_containsdemo', $queryBuilder->createNamedParameter($tableName, \PDO::PARAM_STR) ) ) ->orderBy('pid', 'DESC') ->execute() ->fetch(); if (count($row) !== 1) { throw new Exception( 'Found no page for main table ' . $tableName, 1457690656 ); } return (int)$row['uid']; }
[ "public", "function", "findPidOfMainTableRecord", "(", "string", "$", "tableName", ")", ":", "int", "{", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "(", "'pages'", "...
"Main" tables have a single page they are located on with their possible children. The methods find this page by getting the highest uid of a page where field tx_styleguide_containsdemo is set to given table name. @param string $tableName @return int @throws Exception
[ "Main", "tables", "have", "a", "single", "page", "they", "are", "located", "on", "with", "their", "possible", "children", ".", "The", "methods", "find", "this", "page", "by", "getting", "the", "highest", "uid", "of", "a", "page", "where", "field", "tx_styl...
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/RecordFinder.php#L73-L95
42,889
TYPO3/styleguide
Classes/TcaDataGenerator/RecordFinder.php
RecordFinder.findUidsOfDemoLanguages
public function findUidsOfDemoLanguages(): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $rows = $queryBuilder->select('uid') ->from('sys_language') ->where( $queryBuilder->expr()->eq( 'tx_styleguide_isdemorecord', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT) ) ) ->execute() ->fetchAll(); $result = []; if (is_array($rows)) { foreach ($rows as $row) { $result[] = $row['uid']; } } return $result; }
php
public function findUidsOfDemoLanguages(): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language'); $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $rows = $queryBuilder->select('uid') ->from('sys_language') ->where( $queryBuilder->expr()->eq( 'tx_styleguide_isdemorecord', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT) ) ) ->execute() ->fetchAll(); $result = []; if (is_array($rows)) { foreach ($rows as $row) { $result[] = $row['uid']; } } return $result; }
[ "public", "function", "findUidsOfDemoLanguages", "(", ")", ":", "array", "{", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "(", "'sys_language'", ")", ";", "$", "query...
Find uids of styleguide demo sys_language`s @return array List of uids
[ "Find", "uids", "of", "styleguide", "demo", "sys_language", "s" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/RecordFinder.php#L102-L123
42,890
TYPO3/styleguide
Classes/TcaDataGenerator/RecordFinder.php
RecordFinder.findDemoFolderObject
public function findDemoFolderObject(): Folder { /** @var StorageRepository $storageRepository */ $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); $storage = $storageRepository->findByUid(1); $folder = $storage->getRootLevelFolder(); return $folder->getSubfolder('styleguide'); }
php
public function findDemoFolderObject(): Folder { /** @var StorageRepository $storageRepository */ $storageRepository = GeneralUtility::makeInstance(StorageRepository::class); $storage = $storageRepository->findByUid(1); $folder = $storage->getRootLevelFolder(); return $folder->getSubfolder('styleguide'); }
[ "public", "function", "findDemoFolderObject", "(", ")", ":", "Folder", "{", "/** @var StorageRepository $storageRepository */", "$", "storageRepository", "=", "GeneralUtility", "::", "makeInstance", "(", "StorageRepository", "::", "class", ")", ";", "$", "storage", "=",...
Find the demo folder @return Folder
[ "Find", "the", "demo", "folder" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/RecordFinder.php#L230-L237
42,891
TYPO3/styleguide
Classes/TcaDataGenerator/RecordData.php
RecordData.generate
public function generate(string $tableName, array $fieldValues): array { $tca = $GLOBALS['TCA'][$tableName]; /** @var FieldGeneratorResolver $resolver */ $resolver = GeneralUtility::makeInstance(FieldGeneratorResolver::class); foreach ($tca['columns'] as $fieldName => $fieldConfig) { // Generate only if there is no value set, yet if (isset($fieldValues[$fieldName])) { continue; } $data = [ 'tableName' => $tableName, 'fieldName' => $fieldName, 'fieldConfig' => $fieldConfig, 'fieldValues' => $fieldValues, ]; try { $generator = $resolver->resolve($data); $fieldValues[$fieldName] = $generator->generate($data); } catch (GeneratorNotFoundException $e) { // No op if no matching generator was found } } return $fieldValues; }
php
public function generate(string $tableName, array $fieldValues): array { $tca = $GLOBALS['TCA'][$tableName]; /** @var FieldGeneratorResolver $resolver */ $resolver = GeneralUtility::makeInstance(FieldGeneratorResolver::class); foreach ($tca['columns'] as $fieldName => $fieldConfig) { // Generate only if there is no value set, yet if (isset($fieldValues[$fieldName])) { continue; } $data = [ 'tableName' => $tableName, 'fieldName' => $fieldName, 'fieldConfig' => $fieldConfig, 'fieldValues' => $fieldValues, ]; try { $generator = $resolver->resolve($data); $fieldValues[$fieldName] = $generator->generate($data); } catch (GeneratorNotFoundException $e) { // No op if no matching generator was found } } return $fieldValues; }
[ "public", "function", "generate", "(", "string", "$", "tableName", ",", "array", "$", "fieldValues", ")", ":", "array", "{", "$", "tca", "=", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "tableName", "]", ";", "/** @var FieldGeneratorResolver $resolver */", ...
Generate data for a given table and insert into database @param string $tableName The tablename to create data for @param array $fieldValues Incoming list of field values, Typically uid and pid are set already @return array @throws Exception
[ "Generate", "data", "for", "a", "given", "table", "and", "insert", "into", "database" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/TcaDataGenerator/RecordData.php#L33-L57
42,892
TYPO3/styleguide
Classes/Command/KauderwelschCommand.php
KauderwelschCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln(GeneralUtility::makeInstance(KauderwelschService::class)->getLoremIpsum()); return 0; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln(GeneralUtility::makeInstance(KauderwelschService::class)->getLoremIpsum()); return 0; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "GeneralUtility", "::", "makeInstance", "(", "KauderwelschService", "::", "class", ")", "->", "getLorem...
Random Kauderwelsch quote @param InputInterface $input @param OutputInterface $output @return int
[ "Random", "Kauderwelsch", "quote" ]
0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c
https://github.com/TYPO3/styleguide/blob/0c7af4ccd0aef49fdf5eda2c9cd494b907146f7c/Classes/Command/KauderwelschCommand.php#L36-L40
42,893
mage2pro/core
StripeClone/P/Preorder.php
Preorder.request
final static function request(M $m) { $i = df_new(df_con_heir($m, __CLASS__), $m); /** @var self $i */ return $i->p(); }
php
final static function request(M $m) { $i = df_new(df_con_heir($m, __CLASS__), $m); /** @var self $i */ return $i->p(); }
[ "final", "static", "function", "request", "(", "M", "$", "m", ")", "{", "$", "i", "=", "df_new", "(", "df_con_heir", "(", "$", "m", ",", "__CLASS__", ")", ",", "$", "m", ")", ";", "/** @var self $i */", "return", "$", "i", "->", "p", "(", ")", ";...
2017-06-12 @used-by \Df\StripeClone\Method::chargeNew() @param M $m @return array(string => mixed)
[ "2017", "-", "06", "-", "12" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/StripeClone/P/Preorder.php#L24-L27
42,894
mage2pro/core
Xml/X.php
X.asNiceXml
function asNiceXml($filename = '', $level = 0) { if (is_numeric($level)) { $pad = str_pad('', $level * 1, "\t", STR_PAD_LEFT); $nl = "\n"; } else { $pad = ''; $nl = ''; } $out = $pad . '<' . $this->getName(); $attributes = $this->attributes(); if ($attributes) { foreach ($attributes as $key => $value) { $out .= ' ' . $key . '="' . str_replace('"', '\"', (string)$value) . '"'; } } $attributes = $this->attributes('xsi', true); if ($attributes) { foreach ($attributes as $key => $value) { $out .= ' xsi:' . $key . '="' . str_replace('"', '\"', (string)$value) . '"'; } } if ($this->hasChildren()) { $out .= '>'; $value = trim((string)$this); if (strlen($value)) { $out .= $this->xmlentities($value); } $out .= $nl; foreach ($this->children() as $child) { /** @var X $child */ $out .= $child->asNiceXml('', is_numeric($level) ? $level + 1 : true); } $out .= $pad . '</' . $this->getName() . '>' . $nl; } else { $value = (string)$this; if (strlen($value)) { $out .= '>' . $this->xmlentities($value) . '</' . $this->getName() . '>' . $nl; } else { $out .= '/>' . $nl; } } if ((0 === $level || false === $level) && !empty($filename)) { file_put_contents($filename, $out); } return $out; }
php
function asNiceXml($filename = '', $level = 0) { if (is_numeric($level)) { $pad = str_pad('', $level * 1, "\t", STR_PAD_LEFT); $nl = "\n"; } else { $pad = ''; $nl = ''; } $out = $pad . '<' . $this->getName(); $attributes = $this->attributes(); if ($attributes) { foreach ($attributes as $key => $value) { $out .= ' ' . $key . '="' . str_replace('"', '\"', (string)$value) . '"'; } } $attributes = $this->attributes('xsi', true); if ($attributes) { foreach ($attributes as $key => $value) { $out .= ' xsi:' . $key . '="' . str_replace('"', '\"', (string)$value) . '"'; } } if ($this->hasChildren()) { $out .= '>'; $value = trim((string)$this); if (strlen($value)) { $out .= $this->xmlentities($value); } $out .= $nl; foreach ($this->children() as $child) { /** @var X $child */ $out .= $child->asNiceXml('', is_numeric($level) ? $level + 1 : true); } $out .= $pad . '</' . $this->getName() . '>' . $nl; } else { $value = (string)$this; if (strlen($value)) { $out .= '>' . $this->xmlentities($value) . '</' . $this->getName() . '>' . $nl; } else { $out .= '/>' . $nl; } } if ((0 === $level || false === $level) && !empty($filename)) { file_put_contents($filename, $out); } return $out; }
[ "function", "asNiceXml", "(", "$", "filename", "=", "''", ",", "$", "level", "=", "0", ")", "{", "if", "(", "is_numeric", "(", "$", "level", ")", ")", "{", "$", "pad", "=", "str_pad", "(", "''", ",", "$", "level", "*", "1", ",", "\"\\t\"", ",",...
2016-09-01 @override @see \Magento\Framework\Simplexml\Element::asNiceXml() Родительсктй метод задаёт вложенность тремя пробелами, а я предпочитаю символ табуляции. @param string $filename [optional] @param int $level [optional] @return string
[ "2016", "-", "09", "-", "01" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Xml/X.php#L117-L164
42,895
mage2pro/core
Xml/X.php
X.leafs
function leafs($path) { /** @var array(string => string) $result */ $result = []; /** @var X[] $nodes */ $nodes = $this->xpathA($path); foreach ($nodes as $node) { /** @var X $node */ $result[] = df_leaf_s($node); } return $result; }
php
function leafs($path) { /** @var array(string => string) $result */ $result = []; /** @var X[] $nodes */ $nodes = $this->xpathA($path); foreach ($nodes as $node) { /** @var X $node */ $result[] = df_leaf_s($node); } return $result; }
[ "function", "leafs", "(", "$", "path", ")", "{", "/** @var array(string => string) $result */", "$", "result", "=", "[", "]", ";", "/** @var X[] $nodes */", "$", "nodes", "=", "$", "this", "->", "xpathA", "(", "$", "path", ")", ";", "foreach", "(", "$", "n...
2015-08-15 @used-by \Dfr\Core\Realtime\Dictionary::hasEntry() @param string $path @return string[]
[ "2015", "-", "08", "-", "15" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Xml/X.php#L426-L436
42,896
mage2pro/core
Payment/W/Event.php
Event.tl
final function tl() {return dfc($this, function() {return $this->tl_( $this->useRawTypeForLabel() ? $this->_r->tRaw() : $this->t() );});}
php
final function tl() {return dfc($this, function() {return $this->tl_( $this->useRawTypeForLabel() ? $this->_r->tRaw() : $this->t() );});}
[ "final", "function", "tl", "(", ")", "{", "return", "dfc", "(", "$", "this", ",", "function", "(", ")", "{", "return", "$", "this", "->", "tl_", "(", "$", "this", "->", "useRawTypeForLabel", "(", ")", "?", "$", "this", "->", "_r", "->", "tRaw", "...
2017-03-10 Type label. @override @see \Df\Payment\W\IEvent::r() @used-by \Df\Payment\W\Action::ignoredLog() @used-by \Df\Payment\W\Handler::log() @used-by \Dfe\AllPay\Choice::title() @return string
[ "2017", "-", "03", "-", "10", "Type", "label", "." ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Payment/W/Event.php#L238-L240
42,897
mage2pro/core
Core/T/lib/db-column.php
DbColumn.df_db_column_exists
function df_db_column_exists() { $this->assertTrue(df_db_column_exists(self::$TABLE, 'customer_group_id')); $this->assertFalse(df_db_column_exists(self::$TABLE, 'non_existent_column')); }
php
function df_db_column_exists() { $this->assertTrue(df_db_column_exists(self::$TABLE, 'customer_group_id')); $this->assertFalse(df_db_column_exists(self::$TABLE, 'non_existent_column')); }
[ "function", "df_db_column_exists", "(", ")", "{", "$", "this", "->", "assertTrue", "(", "df_db_column_exists", "(", "self", "::", "$", "TABLE", ",", "'customer_group_id'", ")", ")", ";", "$", "this", "->", "assertFalse", "(", "df_db_column_exists", "(", "self"...
2016-11-01
[ "2016", "-", "11", "-", "01" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Core/T/lib/db-column.php#L37-L40
42,898
mage2pro/core
Config/Source/Block.php
Block.map
protected function map() {return df_map_0(df_sort_a(df_map_r(df_cms_blocks(), function(B $b) {return [ $b->getId(), $b->getTitle() ];})), '-- select a CMS block --');}
php
protected function map() {return df_map_0(df_sort_a(df_map_r(df_cms_blocks(), function(B $b) {return [ $b->getId(), $b->getTitle() ];})), '-- select a CMS block --');}
[ "protected", "function", "map", "(", ")", "{", "return", "df_map_0", "(", "df_sort_a", "(", "df_map_r", "(", "df_cms_blocks", "(", ")", ",", "function", "(", "B", "$", "b", ")", "{", "return", "[", "$", "b", "->", "getId", "(", ")", ",", "$", "b", ...
2018-05-21 @override @see \Df\Config\Source::map() @used-by \Df\Config\Source::toOptionArray() @return array(string => string)
[ "2018", "-", "05", "-", "21" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Config/Source/Block.php#L17-L19
42,899
mage2pro/core
Payment/Settings.php
Settings.applicableForQuoteByMinMaxTotal
final function applicableForQuoteByMinMaxTotal($option) { $a = df_quote()->getBaseGrandTotal(); /** @var float $a */ $max = $this->v("$option/" . T::MAX_ORDER_TOTAL); /** @var float $max */ $min = $this->v("$option/" . T::MIN_ORDER_TOTAL); /** @var float $min */ return !($min && $a < $min || $max && $a > $max); }
php
final function applicableForQuoteByMinMaxTotal($option) { $a = df_quote()->getBaseGrandTotal(); /** @var float $a */ $max = $this->v("$option/" . T::MAX_ORDER_TOTAL); /** @var float $max */ $min = $this->v("$option/" . T::MIN_ORDER_TOTAL); /** @var float $min */ return !($min && $a < $min || $max && $a > $max); }
[ "final", "function", "applicableForQuoteByMinMaxTotal", "(", "$", "option", ")", "{", "$", "a", "=", "df_quote", "(", ")", "->", "getBaseGrandTotal", "(", ")", ";", "/** @var float $a */", "$", "max", "=", "$", "this", "->", "v", "(", "\"$option/\"", ".", ...
2017-07-29 It is implemented by analogy with @see \Magento\Payment\Model\Checks\TotalMinMax::isApplicable() @used-by \Dfe\AlphaCommerceHub\ConfigProvider::option() @used-by \Dfe\Moip\ConfigProvider::config() @param string $option @return boolean
[ "2017", "-", "07", "-", "29", "It", "is", "implemented", "by", "analogy", "with" ]
e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f
https://github.com/mage2pro/core/blob/e04c31bb8a91376df2c2c8a9b29dbad5e8f0cc3f/Payment/Settings.php#L64-L69