_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q19800
CacheManager.startProd
train
public static function startProd(&$config) { self::$cacheDirectory = self::initialGetCacheDirectory ( $config ); $cacheDirectory = \ROOT .
php
{ "resource": "" }
q19801
CacheManager.checkCache
train
public static function checkCache(&$config, $silent = false) { $dirs = self::getCacheDirectories ( $config, $silent ); foreach ( $dirs
php
{ "resource": "" }
q19802
CacheManager.clearCache
train
public static function clearCache(&$config, $type = "all") { $cacheDirectories = self::checkCache ( $config ); $cacheDirs
php
{ "resource": "" }
q19803
UGitRepository.getModifiedFiles
train
public function getModifiedFiles() { try { return $this->extractFromCommand ( 'git diff --name-status HEAD', function ($array) { $array = trim ( preg_replace ( '!\s+!', ' ', $array ) );
php
{ "resource": "" }
q19804
UGitRepository.getRemoteUrl
train
public function getRemoteUrl() { try { $values = $this->extractFromCommand ( 'git config --get remote.origin.url', function ($str) {
php
{ "resource": "" }
q19805
RestBaseController._get
train
public function _get($condition = "1=1", $include = false, $useCache = false) { try { $condition = $this->getCondition ( $condition ); $include = $this->getInclude ( $include ); $useCache = UString::isBooleanTrue ( $useCache ); $datas = DAO::getAll ( $this->model, $condition, $include, null, $useCache ); ...
php
{ "resource": "" }
q19806
AssetsManager.getUrl
train
public static function getUrl($resource, $absolute = false) { if (strpos ( $resource, '//' ) !== false) { return
php
{ "resource": "" }
q19807
AssetsManager.getThemeUrl
train
public static function getThemeUrl($theme, $resource, $absolute = false) { if ($absolute) { return self::$siteURL . self::ASSETS_FOLDER . $theme . '/' . $resource;
php
{ "resource": "" }
q19808
AssetsManager.js
train
public static function js($resource, $attributes = [], $absolute
php
{ "resource": "" }
q19809
AssetsManager.css
train
public static function css($resource, $attributes = [], $absolute
php
{ "resource": "" }
q19810
RestServer.connect
train
public function connect() { if (! isset ( $this->apiTokens )) { $this->apiTokens = $this->_loadApiTokens (); } $token = $this->apiTokens->addToken (); $this->_addHeaderToken ( $token );
php
{ "resource": "" }
q19811
Controller.redirectToRoute
train
public function redirectToRoute($routeName, $parameters = [], $initialize = false, $finalize = false) { $path = Router::getRouteByName ( $routeName, $parameters ); if ($path !== false) { $route = Router::getRoute ( $path, false ); if ($route !== false) { $this->forward ( $route [0], $route [1], \array_sli...
php
{ "resource": "" }
q19812
Database.connect
train
public function connect() { try { $this->_connect (); return true; } catch ( \PDOException $e ) { throw
php
{ "resource": "" }
q19813
RestController.get
train
public function get($condition = "1=1", $included = false,
php
{ "resource": "" }
q19814
AuthControllerOverrideTrait.rememberMe
train
protected function rememberMe($connected){ $id= $this->toCookie($connected); if(isset($id)){
php
{ "resource": "" }
q19815
UFileSystem.safeMkdir
train
public static function safeMkdir($dir, $mode = 0777, $recursive = true) { if (! \is_dir ( $dir
php
{ "resource": "" }
q19816
UFileSystem.cleanPathname
train
public static function cleanPathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace ( "/", \DS, $path );
php
{ "resource": "" }
q19817
UFileSystem.cleanFilePathname
train
public static function cleanFilePathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace
php
{ "resource": "" }
q19818
UFileSystem.getLines
train
public static function getLines($filename, $reverse = false, $maxLines = null, $lineCallback = null) { if (file_exists ( $filename )) { if ($reverse && isset ( $maxLines )) { $result = [ ]; $fl = fopen ( $filename, "r" ); for($x_pos = 0, $ln = 0, $lines = [ ]; fseek ( $fl, $x_pos, SEEK_END ) !== - 1; $...
php
{ "resource": "" }
q19819
DiManager.init
train
public static function init(&$config) { $controllers = CacheManager::getControllers (); foreach ( $controllers as $controller ) { CacheManager::$cache->remove( self::getControllerCacheKey ( $controller )); $parser = new DiControllerParser (); $parser->parse ( $controller, $config
php
{ "resource": "" }
q19820
UArray.save
train
public static function save($array, $filename) { $content = "<?php\nreturn " . self::asPhpArray ( $array, "array", 1, true )
php
{ "resource": "" }
q19821
Router.getRoute
train
public static function getRoute($path, $cachedResponse = true) { $path = self::slashPath ( $path ); if (isset ( self::$routes [$path] )) { return self::getRoute_ ( self::$routes [$path], $path, [ $path ], $cachedResponse ); }
php
{ "resource": "" }
q19822
Router.url
train
public static function url($name, $parameters = []) {
php
{ "resource": "" }
q19823
Router.slashPath
train
public static function slashPath($path) { if (UString::startswith ( $path, "/" )
php
{ "resource": "" }
q19824
ValidatorsManager.validate
train
public static function validate($instance, $group = "") { $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache !== false) { return self::validateFromCache_ ( $instance, $cache ); } $members =
php
{ "resource": "" }
q19825
ValidatorsManager.validateInstances
train
public static function validateInstances($instances, $group = "") { if (sizeof ( $instances ) > 0) { $instance = current ( $instances ); $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache === false) { $members =
php
{ "resource": "" }
q19826
ModelsCacheTrait.getModels
train
public static function getModels(&$config, $silent = false) { $result = [ ]; $files = self::getModelsFiles (
php
{ "resource": "" }
q19827
CRUDController.refresh_
train
public function refresh_() { $model = $this->model; if (isset ( $_POST ["s"] )) { $instances = $this->search ( $model, $_POST ["s"] ); } else { $page = URequest::post ( "p", 1 ); $instances = $this->getInstances ( $totalCount, $page ); } if (! isset ( $totalCount )) { $totalCount = DAO::count ( $m...
php
{ "resource": "" }
q19828
CRUDController.edit
train
public function edit($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids, false ); $instance->_new = false; $this->_edit ( $instance, $modal ); }
php
{ "resource": "" }
q19829
CRUDController.newModel
train
public function newModel($modal = "no") { if (URequest::isAjax ()) { $model = $this->model; $instance = new $model (); $instance->_new = true; $this->_edit ( $instance, $modal ); }
php
{ "resource": "" }
q19830
CRUDController.display
train
public function display($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $key = OrmUtils::getFirstKeyValue ( $instance ); $this->jquery->execOn ( "click", "._close", '$("#table-details").html("");$("#dataTable").show();' ); $this->jquery->getOnClick ( "....
php
{ "resource": "" }
q19831
CRUDController.delete
train
public function delete($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $instanceString = $this->getInstanceToString ( $instance ); if (sizeof ( $_POST ) > 0) { try { if (DAO::remove ( $instance )) { $message = new CRUDMessage ( "Deletion of `<b>" . $instanceStr...
php
{ "resource": "" }
q19832
CRUDController.update
train
public function update() { $message = new CRUDMessage ( "Modifications were successfully saved", "Updating" ); $instance = $_SESSION ["instance"] ?? null; if (isset ( $instance )) { $isNew = $instance->_new; try { $updated = CRUDHelper::update ( $instance, $_POST ); if ($updated) { $message->se...
php
{ "resource": "" }
q19833
CRUDController.showDetail
train
public function showDetail($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $viewer = $this->_getModelViewer (); $hasElements = false; $model = $this->model; $fkInstances = CRUDHelper::getFKIntances ( $instance, $model ); $semantic = $this->jquery->semantic (); $gr...
php
{ "resource": "" }
q19834
ResponseFormatter.getDatas
train
public function getDatas($objects, &$classname = null) { $objects = \array_map ( function ($o) use (&$classname) { return $this->cleanRestObject
php
{ "resource": "" }
q19835
DAO.connect
train
public static function connect($dbType, $dbName, $serverName = '127.0.0.1', $port = '3306', $user = 'root', $password = '', $options = [], $cache = false) { self::$db = new Database ( $dbType, $dbName, $serverName, $port, $user, $password, $options, $cache ); try { self::$db->connect ();
php
{ "resource": "" }
q19836
DAO.isConnected
train
public static function isConnected() { return self::$db !== null && (self::$db
php
{ "resource": "" }
q19837
ClassUtils.getNamespaceFromParts
train
public static function getNamespaceFromParts($parts) { $resultArray = [ ]; if (! \is_array ( $parts )) { $parts = [ $parts ]; } foreach ( $parts as $part ) { $resultArray = \array_merge ( $resultArray, \explode ( "\\",
php
{ "resource": "" }
q19838
ClassUtils.getClassNameWithNS
train
public static function getClassNameWithNS($defaultNS, $name) { if (\strpos ( $name, "\\" ) === false) {
php
{ "resource": "" }
q19839
UResponse.setContentType
train
public static function setContentType($contentType, $encoding = null) { $value = $contentType; if (isset ( $encoding ))
php
{ "resource": "" }
q19840
USession.addOrRemoveValueFromArray
train
public static function addOrRemoveValueFromArray($arrayKey, $value, $add = null) { $array = self::getArray ( $arrayKey ); $_SESSION [$arrayKey] = $array; $search = array_search ( $value, $array
php
{ "resource": "" }
q19841
USession.setBoolean
train
public static function setBoolean($key, $value) { $_SESSION
php
{ "resource": "" }
q19842
USession.getBoolean
train
public static function getBoolean($key) { self::start (); $ret = false; if (isset ( $_SESSION [$key] )) {
php
{ "resource": "" }
q19843
USession.inc
train
public static function inc($key, $inc = 1)
php
{ "resource": "" }
q19844
USession.dec
train
public static function dec($key, $dec = 1)
php
{ "resource": "" }
q19845
USession.concat
train
public static function concat($key, $str, $default =
php
{ "resource": "" }
q19846
USession.apply
train
public static function apply($key, $callback, $default = NULL) { $value = self::get ( $key, $default ); if (is_string ( $callback ) && function_exists ( $callback )) { $value = call_user_func ( $callback, $value ); } elseif
php
{ "resource": "" }
q19847
USession.Walk
train
public static function Walk($callback, $userData = null) {
php
{ "resource": "" }
q19848
USession.start
train
public static function start($name = null) { if (! self::isStarted ()) { if (isset ( $name ) && $name !== "") { self::$name = $name; }
php
{ "resource": "" }
q19849
USession.init
train
public static function init($key, $value) { if (! isset ( $_SESSION [$key] )) { $_SESSION [$key]
php
{ "resource": "" }
q19850
USession.terminate
train
public static function terminate() { if (! self::isStarted ()) return; self::start (); $_SESSION = array (); if (\ini_get ( "session.use_cookies" )) { $params = \session_get_cookie_params (); \setcookie ( \session_name (), '', \time
php
{ "resource": "" }
q19851
JsonApiResponseFormatter.addPageLinks
train
protected function addPageLinks(&$r, $classname, $pages) { $pageSize = $pages ['pageSize']; unset ( $pages ['pageSize'] ); foreach ( $pages as $page => $number ) { $r ['links'] [$page] = $this->getLink ( $this->pageLink, [ "baseRoute"
php
{ "resource": "" }
q19852
CRUDControllerUtilitiesTrait._deleteMultiple
train
protected function _deleteMultiple($data, $action, $target, $condition) { if (URequest::isPost ()) { if (is_callable ( $condition )) { $condition = $condition ( $data ); } $rep = DAO::deleteAll ( $this->model, $condition ); if ($rep) { $message = new CRUDMessage ( "Deleting {count} objects", "Dele...
php
{ "resource": "" }
q19853
ValidatorsManagerInitTrait.initModelsValidators
train
public static function initModelsValidators(&$config) { $models = CacheManager::getModels ( $config, true ); foreach ( $models
php
{ "resource": "" }
q19854
ModelViewer.getForm
train
public function getForm($identifier, $instance) { $form = $this->jquery->semantic ()->dataForm ( $identifier, $instance ); $form->setLibraryId ( "frmEdit" ); $className = \get_class ( $instance ); $fields = $this->controller->_getAdminData ()->getFormFieldNames ( $className, $instance ); $relFields = OrmUtils...
php
{ "resource": "" }
q19855
ModelViewer.getFormTitle
train
protected function getFormTitle($form, $instance) { $type = ($instance->_new) ? "new" : "edit"; $messageInfos = [ "new" => [ "icon" => HtmlIconGroups::corner ( "table", "plus", "big" ),"subMessage"
php
{ "resource": "" }
q19856
ModelViewer.getModelDataElement
train
public function getModelDataElement($instance, $model, $modal) { $semantic = $this->jquery->semantic (); $fields = $this->controller->_getAdminData ()->getElementFieldNames ( $model ); $dataElement = $semantic->dataElement ( "de", $instance ); $pk = OrmUtils::getFirstKeyValue ( $instance ); $dataElement->get...
php
{ "resource": "" }
q19857
ModelViewer.getModelDataTable
train
public function getModelDataTable($instances, $model, $totalCount, $page = 1) { $adminRoute = $this->controller->_getBaseRoute (); $files = $this->controller->_getFiles (); $dataTable = $this->getDataTableInstance ( $instances, $model, $totalCount, $page ); $attributes = $this->controller->_getAdminData ()->get...
php
{ "resource": "" }
q19858
ModelViewer.getDataTableInstance
train
protected function getDataTableInstance($instances, $model, $totalCount, $page = 1): DataTable { $semantic = $this->jquery->semantic (); $recordsPerPage = $this->recordsPerPage ( $model, $totalCount ); if (is_numeric ( $recordsPerPage )) { $grpByFields = $this->getGroupByFields (); if (is_array ( $grpByFiel...
php
{ "resource": "" }
q19859
ThemesManager.setActiveTheme
train
public static function setActiveTheme($activeTheme) { self::$activeTheme = $activeTheme ?? ''; $engineInstance = Startup::$templateEngine; if ($engineInstance instanceof
php
{ "resource": "" }
q19860
ThemesManager.getAvailableThemes
train
public static function getAvailableThemes() { $path = \ROOT . \DS . 'views' . \DS . self::THEMES_FOLDER . \DS . '*'; $dirs = \glob ( $path, GLOB_ONLYDIR | GLOB_NOSORT ); $result = [ ];
php
{ "resource": "" }
q19861
URequest.getDatas
train
public static function getDatas() { $method = \strtolower ( $_SERVER ['REQUEST_METHOD'] ); switch ($method) { case 'post' : if (self::getContentType () == 'application/x-www-form-urlencoded') { return $_POST; }
php
{ "resource": "" }
q19862
URequest.getBoolean
train
public static function getBoolean($key) { $ret = false; if (isset ( $_REQUEST [$key] )) { $ret
php
{ "resource": "" }
q19863
URequest.getOrigin
train
public static function getOrigin() { $headers = getallheaders (); if (isset ( $headers ['Origin'] )) { return $headers ['Origin']; } if (isset ( $_SERVER ['HTTP_ORIGIN'] )) { return $_SERVER ['HTTP_ORIGIN']; } else if (isset
php
{ "resource": "" }
q19864
PhpFastCacheDriver.fetch
train
public function fetch($key) { $result = $this->cacheInstance->getItem ( $this->getRealKey ( $key
php
{ "resource": "" }
q19865
UCookie.set
train
public static function set($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { \setcookie
php
{ "resource": "" }
q19866
UCookie.deleteAll
train
public static function deleteAll($path = "/") { foreach ( $_COOKIE as $name => $value ) {
php
{ "resource": "" }
q19867
UCookie.setRaw
train
public static function setRaw($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { return
php
{ "resource": "" }
q19868
UString.pluralize
train
public static function pluralize($count, $zero, $one, $other) { $result = $other; if ($count === 0) { $result = $zero; } elseif ($count === 1) {
php
{ "resource": "" }
q19869
Client.get
train
public function get($url, array $params = []) { $queryString = '?' . http_build_query($params); $url = $url . $queryString; $request = new Request(
php
{ "resource": "" }
q19870
Verification.check
train
public function check($code, $ip = null) { try { $this->useClient()->check($this, $code, $ip); return true; } catch(RequestException $e) {
php
{ "resource": "" }
q19871
Verification.getChecks
train
public function getChecks() { $checks = $this->proxyArrayAccess('checks'); if(!$checks){ return []; } foreach($checks as $i =>
php
{ "resource": "" }
q19872
Call.lazyLoad
train
protected function lazyLoad() { if(!empty($this->data)){ return true;
php
{ "resource": "" }
q19873
Index.getShards
train
public function getShards(): array { $shards = []; foreach ($this->_data['shards'] as $shardNumber => $shard) { $shards[]
php
{ "resource": "" }
q19874
FunctionScore.addFunction
train
public function addFunction( string $functionType, $functionParams, AbstractQuery $filter = null, float $weight = null ): self { $function = [
php
{ "resource": "" }
q19875
FunctionScore.addScriptScoreFunction
train
public function addScriptScoreFunction(AbstractScript $script, AbstractQuery $filter = null, float $weight = null) {
php
{ "resource": "" }
q19876
FunctionScore.addDecayFunction
train
public function addDecayFunction( string $function, string $field, string $origin, string $scale, string $offset = null, float $decay = null, float $weight = null, AbstractQuery $filter = null, string $multiValueMode = null ) { $functio...
php
{ "resource": "" }
q19877
FunctionScore.addRandomScoreFunction
train
public function addRandomScoreFunction( int $seed, AbstractQuery $filter = null, float $weight = null, string $field = null ): self { $functionParams = [ 'seed' => $seed, ];
php
{ "resource": "" }
q19878
FunctionScore.setRandomScore
train
public function setRandomScore(int $seed = null): self { $seedParam = new \stdClass();
php
{ "resource": "" }
q19879
Phrase.setHighlight
train
public function setHighlight(string $preTag, string $postTag): Phrase { return
php
{ "resource": "" }
q19880
Scroll.next
train
public function next() { if ($this->currentPage < $this->totalPages) { $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
php
{ "resource": "" }
q19881
Scroll.rewind
train
public function rewind() { // reset state $this->_options = [null, null]; $this->currentPage = 0; // initial search $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
php
{ "resource": "" }
q19882
Scroll.clear
train
public function clear() { if (null !== $this->_nextScrollId) { $this->_search->getClient()->request( '_search/scroll', Request::DELETE, [Search::OPTION_SCROLL_ID => [$this->_nextScrollId]] );
php
{ "resource": "" }
q19883
Scroll._setScrollId
train
protected function _setScrollId(ResultSet $resultSet) { if (0 === $this->currentPage) { $this->totalPages = $resultSet->count() > 0 ? \ceil($resultSet->getTotalHits() / $resultSet->count()) : 0; } $this->_currentResultSet = $resultSet; ++$this->currentPage;
php
{ "resource": "" }
q19884
Scroll._saveOptions
train
protected function _saveOptions() { if ($this->_search->hasOption(Search::OPTION_SCROLL)) { $this->_options[0] = $this->_search->getOption(Search::OPTION_SCROLL); }
php
{ "resource": "" }
q19885
Scroll._revertOptions
train
protected function _revertOptions() { $this->_search->setOption(Search::OPTION_SCROLL, $this->_options[0]);
php
{ "resource": "" }
q19886
Search.addIndex
train
public function addIndex($index) { if ($index instanceof Index) { $index = $index->getName(); } if (!\is_scalar($index)) {
php
{ "resource": "" }
q19887
Search.addType
train
public function addType($type) { if ($type instanceof Type) { $type = $type->getName(); } if (!\is_string($type)) {
php
{ "resource": "" }
q19888
Search.getPath
train
public function getPath() { if (isset($this->_options[self::OPTION_SCROLL_ID])) { return '_search/scroll'; } $indices = $this->getIndices(); $path = ''; $types = $this->getTypes(); if (empty($indices)) { if (!empty($types)) { ...
php
{ "resource": "" }
q19889
Search.search
train
public function search($query = '', $options = null) { $this->setOptionsAndQuery($options, $query); $query = $this->getQuery(); $path = $this->getPath(); $params = $this->getOptions(); // Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids.
php
{ "resource": "" }
q19890
Ids.setIds
train
public function setIds($ids): self { if (\is_array($ids)) { $this->_params['values'] = $ids; } else {
php
{ "resource": "" }
q19891
Status.getIndicesWithAlias
train
public function getIndicesWithAlias($alias) { $endpoint = new Get(); $endpoint->setName($alias); $response = null; try { $response = $this->_client->requestEndpoint($endpoint); } catch (ResponseException $e) { // 404 means the index alias doesn't exi...
php
{ "resource": "" }
q19892
ResponseException.getElasticsearchException
train
public function getElasticsearchException(): ElasticsearchException { $response = $this->getResponse();
php
{ "resource": "" }
q19893
AbstractType.create
train
public function create(bool $recreate = false) { $this->getIndex()->create($this->_indexParams, $recreate);
php
{ "resource": "" }
q19894
AbstractType.search
train
public function search($query = '', $options = null): ResultSet {
php
{ "resource": "" }
q19895
Percentiles.setHdr
train
public function setHdr(string $key, float $value): self { $compression = [$key => $value];
php
{ "resource": "" }
q19896
SpanTerm.setTerm
train
public function setTerm(string $key, $value, float $boost = 1.0): self
php
{ "resource": "" }
q19897
ResultSet.getAggregation
train
public function getAggregation($name) { $data = $this->_response->getData(); if (isset($data['aggregations']) && isset($data['aggregations'][$name])) { return $data['aggregations'][$name];
php
{ "resource": "" }
q19898
Prefix.setPrefix
train
public function setPrefix(string $key, $value, float $boost = 1.0): self {
php
{ "resource": "" }
q19899
Aggregation.sum_bucket
train
public function sum_bucket(string $name, string $bucketsPath =
php
{ "resource": "" }