idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,200 | protected function getTotalColumns ( ) { $ columns = $ this -> visibleColumns ? : $ this -> getVisibleColumns ( ) ; $ total = count ( $ columns ) ; if ( $ this -> showCheckboxes ) { $ total ++ ; } if ( $ this -> showSetup ) { $ total ++ ; } return $ total ; } | Calculates the total columns used in the list including checkboxes and other additions . |
23,201 | public function getHeaderValue ( $ column ) { $ value = Lang :: get ( $ column -> label ) ; if ( $ response = $ this -> fireSystemEvent ( 'backend.list.overrideHeaderValue' , [ $ column , & $ value ] ) ) { $ value = $ response ; } return $ value ; } | Looks up the column header |
23,202 | public function getColumnValueRaw ( $ record , $ column ) { $ columnName = $ column -> columnName ; if ( $ column -> valueFrom && $ column -> relation ) { $ columnName = $ column -> relation ; if ( ! array_key_exists ( $ columnName , $ record -> getRelations ( ) ) ) { $ value = null ; } elseif ( $ this -> isColumnRelat... | Returns a raw column value |
23,203 | public function getColumnValue ( $ record , $ column ) { $ value = $ this -> getColumnValueRaw ( $ record , $ column ) ; if ( method_exists ( $ this , 'eval' . studly_case ( $ column -> type ) . 'TypeValue' ) ) { $ value = $ this -> { 'eval' . studly_case ( $ column -> type ) . 'TypeValue' } ( $ record , $ column , $ v... | Returns a column value with filters applied |
23,204 | public function getRowClass ( $ record ) { $ value = '' ; if ( $ response = $ this -> fireSystemEvent ( 'backend.list.injectRowClass' , [ $ record , & $ value ] ) ) { $ value = $ response ; } return $ value ; } | Adds a custom CSS class string to a record row |
23,205 | protected function evalCustomListType ( $ type , $ record , $ column , $ value ) { $ plugins = PluginManager :: instance ( ) -> getRegistrationMethodValues ( 'registerListColumnTypes' ) ; foreach ( $ plugins as $ availableTypes ) { if ( ! isset ( $ availableTypes [ $ type ] ) ) { continue ; } $ callback = $ availableTy... | Process a custom list types registered by plugins . |
23,206 | protected function evalTextTypeValue ( $ record , $ column , $ value ) { if ( is_array ( $ value ) && count ( $ value ) == count ( $ value , COUNT_RECURSIVE ) ) { $ value = implode ( ', ' , $ value ) ; } if ( is_string ( $ column -> format ) && ! empty ( $ column -> format ) ) { $ value = sprintf ( $ column -> format ,... | Process as text escape the value |
23,207 | protected function evalRelationTypeValue ( $ record , $ column , $ value ) { traceLog ( sprintf ( 'Warning: List column type "relation" for class "%s" is not valid.' , get_class ( $ record ) ) ) ; return $ this -> evalTextTypeValue ( $ record , $ column , $ value ) ; } | Common mistake relation is not a valid list column . |
23,208 | protected function evalPartialTypeValue ( $ record , $ column , $ value ) { return $ this -> controller -> makePartial ( $ column -> path ? : $ column -> columnName , [ 'listColumn' => $ column , 'listRecord' => $ record , 'listValue' => $ value , 'column' => $ column , 'record' => $ record , 'value' => $ value ] ) ; } | Process as partial reference |
23,209 | protected function evalSwitchTypeValue ( $ record , $ column , $ value ) { $ contents = '' ; if ( $ value ) { $ contents = Lang :: get ( 'backend::lang.list.column_switch_true' ) ; } else { $ contents = Lang :: get ( 'backend::lang.list.column_switch_false' ) ; } return $ contents ; } | Process as boolean switch |
23,210 | protected function evalDatetimeTypeValue ( $ record , $ column , $ value ) { if ( $ value === null ) { return null ; } $ dateTime = $ this -> validateDateTimeValue ( $ value , $ column ) ; if ( $ column -> format !== null ) { $ value = $ dateTime -> format ( $ column -> format ) ; } else { $ value = $ dateTime -> toDay... | Process as a datetime value |
23,211 | protected function validateDateTimeValue ( $ value , $ column ) { $ value = DateTimeHelper :: makeCarbon ( $ value , false ) ; if ( ! $ value instanceof Carbon ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.list.invalid_column_datetime' , [ 'column' => $ column -> columnName ] ) ) ; } return $ value ... | Validates a column type as a date |
23,212 | public function setSearchTerm ( $ term ) { if ( ! empty ( $ term ) ) { $ this -> showTree = false ; } $ this -> searchTerm = $ term ; } | Applies a search term to the list results searching will disable tree view if a value is supplied . |
23,213 | public function setSearchOptions ( $ options = [ ] ) { extract ( array_merge ( [ 'mode' => null , 'scope' => null ] , $ options ) ) ; $ this -> searchMode = $ mode ; $ this -> searchScope = $ scope ; } | Applies a search options to the list search . |
23,214 | protected function getSearchableColumns ( ) { $ columns = $ this -> getColumns ( ) ; $ searchable = [ ] ; foreach ( $ columns as $ column ) { if ( ! $ column -> searchable ) { continue ; } $ searchable [ ] = $ column ; } return $ searchable ; } | Returns a collection of columns which can be searched . |
23,215 | protected function applySearchToQuery ( $ query , $ columns , $ boolean = 'and' ) { $ term = $ this -> searchTerm ; if ( $ scopeMethod = $ this -> searchScope ) { $ searchMethod = $ boolean == 'and' ? 'where' : 'orWhere' ; $ query -> $ searchMethod ( function ( $ q ) use ( $ term , $ columns , $ scopeMethod ) { $ q -> ... | Applies the search constraint to a query . |
23,216 | public function onSort ( ) { if ( $ column = post ( 'sortColumn' ) ) { $ sortOptions = [ 'column' => $ this -> getSortColumn ( ) , 'direction' => $ this -> sortDirection ] ; if ( $ column != $ sortOptions [ 'column' ] || $ sortOptions [ 'direction' ] == 'asc' ) { $ this -> sortDirection = $ sortOptions [ 'direction' ] ... | Event handler for sorting the list . |
23,217 | protected function getSortColumn ( ) { if ( ! $ this -> isSortable ( ) ) { return false ; } if ( $ this -> sortColumn !== null ) { return $ this -> sortColumn ; } if ( $ this -> showSorting && ( $ sortOptions = $ this -> getSession ( 'sort' ) ) ) { $ this -> sortColumn = $ sortOptions [ 'column' ] ; $ this -> sortDirec... | Returns the current sorting column saved in a session or cached . |
23,218 | protected function isSortable ( $ column = null ) { if ( $ column === null ) { return ( count ( $ this -> getSortableColumns ( ) ) > 0 ) ; } return array_key_exists ( $ column , $ this -> getSortableColumns ( ) ) ; } | Returns true if the column can be sorted . |
23,219 | protected function getSortableColumns ( ) { if ( $ this -> sortableColumns !== null ) { return $ this -> sortableColumns ; } $ columns = $ this -> getColumns ( ) ; $ sortable = array_filter ( $ columns , function ( $ column ) { return $ column -> sortable ; } ) ; return $ this -> sortableColumns = $ sortable ; } | Returns a collection of columns which are sortable . |
23,220 | public function onLoadSetup ( ) { $ this -> vars [ 'columns' ] = $ this -> getSetupListColumns ( ) ; $ this -> vars [ 'perPageOptions' ] = $ this -> getSetupPerPageOptions ( ) ; $ this -> vars [ 'recordsPerPage' ] = $ this -> recordsPerPage ; return $ this -> makePartial ( 'setup_form' ) ; } | Event handler to display the list set up . |
23,221 | public function onApplySetup ( ) { if ( ( $ visibleColumns = post ( 'visible_columns' ) ) && is_array ( $ visibleColumns ) ) { $ this -> columnOverride = $ visibleColumns ; $ this -> putSession ( 'visible' , $ this -> columnOverride ) ; } $ this -> recordsPerPage = post ( 'records_per_page' , $ this -> recordsPerPage )... | Event handler to apply the list set up . |
23,222 | protected function getSetupPerPageOptions ( ) { $ perPageOptions = [ 20 , 40 , 80 , 100 , 120 ] ; if ( ! in_array ( $ this -> recordsPerPage , $ perPageOptions ) ) { $ perPageOptions [ ] = $ this -> recordsPerPage ; } sort ( $ perPageOptions ) ; return $ perPageOptions ; } | Returns an array of allowable records per page . |
23,223 | protected function getSetupListColumns ( ) { $ columns = $ this -> defineListColumns ( ) ; foreach ( $ columns as $ column ) { $ column -> invisible = true ; } return array_merge ( $ columns , $ this -> getVisibleColumns ( ) ) ; } | Returns all the list columns used for list set up . |
23,224 | public function validateTree ( ) { if ( ! $ this -> showTree ) { return ; } $ this -> showSorting = $ this -> showPagination = false ; if ( ! $ this -> model -> methodExists ( 'getChildren' ) ) { throw new ApplicationException ( 'To display list as a tree, the specified model must have a method "getChildren"' ) ; } if ... | Validates the model and settings if showTree is used |
23,225 | protected function isColumnRelated ( $ column , $ multi = false ) { if ( ! isset ( $ column -> relation ) || $ this -> isColumnPivot ( $ column ) ) { return false ; } if ( ! $ this -> model -> hasRelation ( $ column -> relation ) ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.model.missing_relation' ... | Check if column refers to a relation of the model |
23,226 | public function exportFromList ( $ definition = null , $ options = [ ] ) { $ lists = $ this -> controller -> makeLists ( ) ; $ widget = $ lists [ $ definition ] ?? reset ( $ lists ) ; $ defaultOptions = [ 'fileName' => $ this -> exportFileName , 'delimiter' => ',' , 'enclosure' => '"' ] ; $ options = array_merge ( $ de... | Outputs the list results as a CSV export . |
23,227 | protected function getFormatOptionsFromPost ( ) { $ presetMode = post ( 'format_preset' ) ; $ options = [ 'delimiter' => null , 'enclosure' => null , 'escape' => null , 'encoding' => null ] ; if ( $ presetMode == 'custom' ) { $ options [ 'delimiter' ] = post ( 'format_delimiter' ) ; $ options [ 'enclosure' ] = post ( '... | Returns the file format options from postback . This method can be used to define presets . |
23,228 | public function findFiles ( $ searchTerm , $ sortBy = 'title' , $ filter = null ) { $ words = explode ( ' ' , Str :: lower ( $ searchTerm ) ) ; $ result = [ ] ; $ findInFolder = function ( $ folder ) use ( & $ findInFolder , $ words , & $ result , $ sortBy , $ filter ) { $ folderContents = $ this -> listFolderContents ... | Finds files in the Library . |
23,229 | public function deleteFiles ( $ paths ) { $ fullPaths = [ ] ; foreach ( $ paths as $ path ) { $ path = self :: validatePath ( $ path ) ; $ fullPaths [ ] = $ this -> getMediaPath ( $ path ) ; } return $ this -> getStorageDisk ( ) -> delete ( $ fullPaths ) ; } | Deletes a file from the Library . |
23,230 | public function deleteFolder ( $ path ) { $ path = self :: validatePath ( $ path ) ; $ fullPaths = $ this -> getMediaPath ( $ path ) ; return $ this -> getStorageDisk ( ) -> deleteDirectory ( $ fullPaths ) ; } | Deletes a folder from the Library . |
23,231 | public function exists ( $ path ) { $ path = self :: validatePath ( $ path ) ; $ fullPath = $ this -> getMediaPath ( $ path ) ; return $ this -> getStorageDisk ( ) -> exists ( $ fullPath ) ; } | Determines if a file with the specified path exists in the library . |
23,232 | public function folderExists ( $ path ) { $ folderName = basename ( $ path ) ; $ folderPath = dirname ( $ path ) ; $ path = self :: validatePath ( $ folderPath ) ; $ fullPath = $ this -> getMediaPath ( $ path ) ; $ folders = $ this -> getStorageDisk ( ) -> directories ( $ fullPath ) ; foreach ( $ folders as $ folder ) ... | Determines if a folder with the specified path exists in the library . |
23,233 | public function listAllDirectories ( $ exclude = [ ] ) { $ fullPath = $ this -> getMediaPath ( '/' ) ; $ folders = $ this -> getStorageDisk ( ) -> allDirectories ( $ fullPath ) ; $ folders = array_unique ( $ folders , SORT_LOCALE_STRING ) ; $ result = [ ] ; foreach ( $ folders as $ folder ) { $ folder = $ this -> getMe... | Returns a list of all directories in the Library optionally excluding some of them . |
23,234 | public function get ( $ path ) { $ path = self :: validatePath ( $ path ) ; $ fullPath = $ this -> getMediaPath ( $ path ) ; return $ this -> getStorageDisk ( ) -> get ( $ fullPath ) ; } | Returns a file contents . |
23,235 | public function put ( $ path , $ contents ) { $ path = self :: validatePath ( $ path ) ; $ fullPath = $ this -> getMediaPath ( $ path ) ; return $ this -> getStorageDisk ( ) -> put ( $ fullPath , $ contents ) ; } | Puts a file to the library . |
23,236 | public function moveFile ( $ oldPath , $ newPath , $ isRename = false ) { $ oldPath = self :: validatePath ( $ oldPath ) ; $ fullOldPath = $ this -> getMediaPath ( $ oldPath ) ; $ newPath = self :: validatePath ( $ newPath ) ; $ fullNewPath = $ this -> getMediaPath ( $ newPath ) ; return $ this -> getStorageDisk ( ) ->... | Moves a file to another location . |
23,237 | public function copyFolder ( $ originalPath , $ newPath ) { $ disk = $ this -> getStorageDisk ( ) ; $ copyDirectory = function ( $ srcPath , $ destPath ) use ( & $ copyDirectory , $ disk ) { $ srcPath = self :: validatePath ( $ srcPath ) ; $ fullSrcPath = $ this -> getMediaPath ( $ srcPath ) ; $ destPath = self :: vali... | Copies a folder . |
23,238 | public static function validatePath ( $ path , $ normalizeOnly = false ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = '/' . trim ( $ path , '/' ) ; if ( $ normalizeOnly ) { return $ path ; } $ regexWhitelist = [ '\w' , preg_quote ( '@' , '/' ) , preg_quote ( '.' , '/' ) , '\s' , preg_quote ( '-' , '/' ) , ... | Checks if file path doesn t contain any substrings that would pose a security threat . Throws an exception if the path is not valid . |
23,239 | public function getPathUrl ( $ path ) { $ path = $ this -> validatePath ( $ path ) ; $ fullPath = $ this -> storagePath . implode ( "/" , array_map ( "rawurlencode" , explode ( "/" , $ path ) ) ) ; return Url :: to ( $ fullPath ) ; } | Returns a public file URL . |
23,240 | protected function getMediaRelativePath ( $ path ) { $ path = self :: validatePath ( $ path , true ) ; if ( substr ( $ path , 0 , $ this -> storageFolderNameLength ) == $ this -> storageFolder ) { return substr ( $ path , $ this -> storageFolderNameLength ) ; } throw new SystemException ( sprintf ( 'Cannot convert Medi... | Returns path relative to the Library root folder . |
23,241 | protected function initLibraryItem ( $ path , $ itemType ) { $ relativePath = $ this -> getMediaRelativePath ( $ path ) ; if ( ! $ this -> isVisible ( $ relativePath ) ) { return ; } $ lastModified = $ itemType == MediaLibraryItem :: TYPE_FILE ? $ this -> getStorageDisk ( ) -> lastModified ( $ path ) : null ; $ size = ... | Initializes a library item from a path and item type . |
23,242 | protected function getFolderItemCount ( $ path ) { $ folderItems = array_merge ( $ this -> getStorageDisk ( ) -> files ( $ path ) , $ this -> getStorageDisk ( ) -> directories ( $ path ) ) ; $ size = 0 ; foreach ( $ folderItems as $ folderItem ) { if ( $ this -> isVisible ( $ folderItem ) ) { $ size ++ ; } } return $ s... | Returns a number of items on a folder . |
23,243 | protected function scanFolderContents ( $ fullFolderPath ) { $ result = [ 'files' => [ ] , 'folders' => [ ] ] ; $ files = $ this -> getStorageDisk ( ) -> files ( $ fullFolderPath ) ; foreach ( $ files as $ file ) { if ( $ libraryItem = $ this -> initLibraryItem ( $ file , MediaLibraryItem :: TYPE_FILE ) ) { $ result [ ... | Fetches the contents of a folder from the Library . |
23,244 | protected function sortItemList ( & $ itemList , $ sortSettings ) { $ files = [ ] ; $ folders = [ ] ; if ( is_string ( $ sortSettings ) ) { $ sortSettings = [ 'by' => $ sortSettings , 'direction' => self :: SORT_DIRECTION_ASC , ] ; } usort ( $ itemList , function ( $ a , $ b ) use ( $ sortSettings ) { $ result = 0 ; sw... | Sorts the item list by title size or last modified date . |
23,245 | protected function filterItemList ( & $ itemList , $ filter ) { if ( ! $ filter ) return ; $ result = [ ] ; foreach ( $ itemList as $ item ) { if ( $ item -> getFileType ( ) == $ filter ) { $ result [ ] = $ item ; } } $ itemList = $ result ; } | Filters item list by file type . |
23,246 | protected function pathMatchesSearch ( $ path , $ words ) { $ path = Str :: lower ( $ path ) ; foreach ( $ words as $ word ) { $ word = trim ( $ word ) ; if ( ! strlen ( $ word ) ) { continue ; } if ( ! Str :: contains ( $ path , $ word ) ) { return false ; } } return true ; } | Determines if file path contains all words form the search term . |
23,247 | public function getSummaryAttribute ( ) { if ( preg_match ( "/with message '(.+)' in/" , $ this -> message , $ match ) ) { return $ match [ 1 ] ; } return Str :: limit ( $ this -> message , 100 ) ; } | Creates a shorter version of the message attribute extracts the exception message or limits by 100 characters . |
23,248 | public function url ( $ path = null ) { $ routeAction = 'Cms\Classes\CmsController@run' ; if ( self :: $ actionExists === null ) { self :: $ actionExists = Route :: getRoutes ( ) -> getByAction ( $ routeAction ) !== null ; } if ( substr ( $ path , 0 , 1 ) == '/' ) { $ path = substr ( $ path , 1 ) ; } if ( self :: $ act... | Returns a URL in context of the Frontend |
23,249 | public static function makeCarbon ( $ value , $ throwException = true ) { if ( $ value instanceof Carbon ) { } elseif ( $ value instanceof PhpDateTime ) { $ value = Carbon :: instance ( $ value ) ; } elseif ( is_numeric ( $ value ) ) { $ value = Carbon :: createFromTimestamp ( $ value ) ; } elseif ( preg_match ( '/^(\d... | Converts mixed inputs to a Carbon object . |
23,250 | public static function momentFormat ( $ format ) { $ replacements = [ 'd' => 'DD' , 'D' => 'ddd' , 'j' => 'D' , 'l' => 'dddd' , 'N' => 'E' , 'S' => 'o' , 'w' => 'e' , 'z' => 'DDD' , 'W' => 'W' , 'F' => 'MMMM' , 'm' => 'MM' , 'M' => 'MMM' , 'n' => 'M' , 't' => '' , 'L' => '' , 'o' => 'YYYY' , 'Y' => 'YYYY' , 'y' => 'YY'... | Converts a PHP date format to Moment . js format . |
23,251 | protected function makeRenderFormField ( ) { return $ this -> renderFormField = RelationBase :: noConstraints ( function ( ) { $ field = clone $ this -> formField ; $ relationObject = $ this -> getRelationObject ( ) ; $ query = $ relationObject -> newQuery ( ) ; list ( $ model , $ attribute ) = $ this -> resolveModelAt... | Makes the form object used for rendering a simple field type |
23,252 | protected function rebuild ( $ path ) { $ uniqueName = str_replace ( '.' , '' , uniqid ( '' , true ) ) . '_' . md5 ( mt_rand ( ) ) ; $ className = 'Cms' . $ uniqueName . 'Class' ; $ body = $ this -> object -> code ; $ body = preg_replace ( '/^\s*function/m' , 'public function' , $ body ) ; $ codeNamespaces = [ ] ; $ pa... | Rebuilds the current file cache . |
23,253 | public function source ( $ page , $ layout , $ controller ) { $ data = $ this -> parse ( ) ; $ className = $ data [ 'className' ] ; if ( ! class_exists ( $ className ) ) { require_once $ data [ 'filePath' ] ; } if ( ! class_exists ( $ className ) && ( $ data = $ this -> handleCorruptCache ( $ data ) ) ) { $ className =... | Runs the object s PHP file and returns the corresponding object . |
23,254 | protected function handleCorruptCache ( $ data ) { $ path = array_get ( $ data , 'filePath' , $ this -> getCacheFilePath ( ) ) ; if ( is_file ( $ path ) ) { if ( ( $ className = $ this -> extractClassFromFile ( $ path ) ) && class_exists ( $ className ) ) { $ data [ 'className' ] = $ className ; return $ data ; } @ unl... | In some rare cases the cache file will not contain the class name we expect . When this happens destroy the corrupt file flush the request cache and repeat the cycle . |
23,255 | protected function storeCachedInfo ( $ result ) { $ cacheItem = $ result ; $ cacheItem [ 'mtime' ] = $ this -> object -> mtime ; $ cached = $ this -> getCachedInfo ( ) ? : [ ] ; $ cached [ $ this -> filePath ] = $ cacheItem ; Cache :: put ( $ this -> dataCacheKey , base64_encode ( serialize ( $ cached ) ) , 1440 ) ; se... | Stores result data inside cache . |
23,256 | protected function getCacheFilePath ( ) { $ hash = md5 ( $ this -> filePath ) ; $ result = storage_path ( ) . '/cms/cache/' ; $ result .= substr ( $ hash , 0 , 2 ) . '/' ; $ result .= substr ( $ hash , 2 , 2 ) . '/' ; $ result .= basename ( $ this -> filePath ) ; $ result .= '.php' ; return $ result ; } | Returns path to the cached parsed file |
23,257 | protected function getCachedInfo ( ) { $ cached = Cache :: get ( $ this -> dataCacheKey , false ) ; if ( $ cached !== false && ( $ cached = @ unserialize ( @ base64_decode ( $ cached ) ) ) !== false ) { return $ cached ; } return null ; } | Returns information about all cached files . |
23,258 | protected function getCachedFileInfo ( ) { $ cached = $ this -> getCachedInfo ( ) ; if ( $ cached !== null && array_key_exists ( $ this -> filePath , $ cached ) ) { return $ cached [ $ this -> filePath ] ; } return null ; } | Returns information about a cached file |
23,259 | protected function extractClassFromFile ( $ path ) { $ fileContent = file_get_contents ( $ path ) ; $ matches = [ ] ; $ pattern = '/Cms\S+_\S+Class/' ; preg_match ( $ pattern , $ fileContent , $ matches ) ; if ( ! empty ( $ matches [ 0 ] ) ) { return $ matches [ 0 ] ; } return null ; } | Extracts the class name from a cache file |
23,260 | protected function writeContentSafe ( $ path , $ content ) { $ count = 0 ; $ tmpFile = tempnam ( dirname ( $ path ) , basename ( $ path ) ) ; if ( @ file_put_contents ( $ tmpFile , $ content ) === false ) { throw new SystemException ( Lang :: get ( 'system::lang.file.create_fail' , [ 'name' => $ tmpFile ] ) ) ; } while... | Writes content with concurrency support and cache busting This work is based on the Twig_Cache_Filesystem class |
23,261 | protected function makeDirectorySafe ( $ dir ) { $ count = 0 ; if ( is_dir ( $ dir ) ) { if ( ! is_writable ( $ dir ) ) { throw new SystemException ( Lang :: get ( 'system::lang.directory.create_fail' , [ 'name' => $ dir ] ) ) ; } return ; } while ( ! is_dir ( $ dir ) && ! @ mkdir ( $ dir , 0777 , true ) ) { usleep ( r... | Make directory with concurrency support |
23,262 | public static function setAppLocale ( ) { if ( Session :: has ( 'locale' ) ) { App :: setLocale ( Session :: get ( 'locale' ) ) ; } elseif ( ( $ user = BackendAuth :: getUser ( ) ) && ( $ locale = static :: get ( 'locale' ) ) ) { Session :: put ( 'locale' , $ locale ) ; App :: setLocale ( $ locale ) ; } } | Set the application s locale based on the user preference . |
23,263 | public static function setAppFallbackLocale ( ) { if ( Session :: has ( 'fallback_locale' ) ) { Lang :: setFallback ( Session :: get ( 'fallback_locale' ) ) ; } elseif ( ( $ user = BackendAuth :: getUser ( ) ) && ( $ locale = static :: get ( 'fallback_locale' ) ) ) { Session :: put ( 'fallback_locale' , $ locale ) ; La... | Same as setAppLocale except for the fallback definition . |
23,264 | public static function applyConfigValues ( ) { $ settings = self :: instance ( ) ; Config :: set ( 'app.locale' , $ settings -> locale ) ; Config :: set ( 'app.fallback_locale' , $ settings -> fallback_locale ) ; } | Overrides the config with the user s preference . |
23,265 | protected function getFallbackLocale ( $ locale ) { if ( $ position = strpos ( $ locale , '-' ) ) { $ target = substr ( $ locale , 0 , $ position ) ; $ available = $ this -> getLocaleOptions ( ) ; if ( isset ( $ available [ $ target ] ) ) { return $ target ; } } return Config :: get ( 'app.fallback_locale' ) ; } | Attempt to extract the language from the locale otherwise use the configuration . |
23,266 | public function getTimezoneOptions ( ) { $ timezoneIdentifiers = DateTimeZone :: listIdentifiers ( ) ; $ utcTime = new DateTime ( 'now' , new DateTimeZone ( 'UTC' ) ) ; $ tempTimezones = [ ] ; foreach ( $ timezoneIdentifiers as $ timezoneIdentifier ) { $ currentTimezone = new DateTimeZone ( $ timezoneIdentifier ) ; $ t... | Returns all available timezone options . |
23,267 | public function getEditorThemeOptions ( ) { $ themeDir = new DirectoryIterator ( "modules/backend/formwidgets/codeeditor/assets/vendor/ace/" ) ; $ themes = [ ] ; foreach ( $ themeDir as $ node ) { if ( ! $ node -> isDir ( ) && substr ( $ node -> getFileName ( ) , 0 , 6 ) == 'theme-' ) { $ themeId = substr ( $ node -> g... | Returns the theme options for the backend editor . |
23,268 | public static function loadOverrideCached ( $ theme , $ component , $ fileName ) { $ partial = Partial :: loadCached ( $ theme , strtolower ( $ component -> alias ) . '/' . $ fileName ) ; if ( $ partial === null ) { $ partial = Partial :: loadCached ( $ theme , $ component -> alias . '/' . $ fileName ) ; } return $ par... | Checks if a partial override exists in the supplied theme and returns it . Since the beginning of time October inconsistently checked for overrides using the component alias exactly resulting in a folder with uppercase characters subsequently this method checks for both variants . |
23,269 | public static function check ( ComponentBase $ component , $ fileName ) { $ partial = new static ( $ component ) ; $ filePath = $ partial -> getFilePath ( $ fileName ) ; if ( ! strlen ( File :: extension ( $ filePath ) ) ) { $ filePath .= '.' . $ partial -> getDefaultExtension ( ) ; } return File :: isFile ( $ filePath... | Returns true if the specific component contains a matching partial . |
23,270 | protected function validateFileName ( $ fileName ) { if ( ! FileHelper :: validatePath ( $ fileName , $ this -> maxNesting ) ) { throw new ApplicationException ( Lang :: get ( 'cms::lang.cms_object.invalid_file' , [ 'name' => $ fileName ] ) ) ; } if ( ! strlen ( File :: extension ( $ fileName ) ) ) { $ fileName .= '.' ... | Checks the supplied file name for validity . |
23,271 | public function getBaseFileName ( ) { $ pos = strrpos ( $ this -> fileName , '.' ) ; if ( $ pos === false ) { return $ this -> fileName ; } return substr ( $ this -> fileName , 0 , $ pos ) ; } | Returns the file name without the extension . |
23,272 | public function combine ( $ name ) { try { if ( ! strpos ( $ name , '-' ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.combiner.not_found' , [ 'name' => $ name ] ) ) ; } $ parts = explode ( '-' , $ name ) ; $ cacheId = $ parts [ 0 ] ; $ combiner = CombineAssets :: instance ( ) ; return $ combiner ->... | Combines JavaScript and StyleSheet assets . |
23,273 | public function listExtensions ( $ type ) { $ results = [ ] ; if ( $ this -> items === null ) { $ this -> loadExtensions ( ) ; } if ( isset ( $ this -> items [ $ type ] ) && is_array ( $ this -> items [ $ type ] ) ) { $ results = $ this -> items [ $ type ] ; } if ( $ this -> transactionItems !== null && isset ( $ this ... | Returns a list of the registered Twig extensions of a type . |
23,274 | public function makeTwigFunctions ( $ functions = [ ] ) { if ( ! is_array ( $ functions ) ) { $ functions = [ ] ; } foreach ( $ this -> listFunctions ( ) as $ name => $ callable ) { if ( strpos ( $ name , '*' ) !== false && $ this -> isWildCallable ( $ callable ) ) { $ callable = function ( $ name ) use ( $ callable ) ... | Makes a set of Twig functions for use in a twig extension . |
23,275 | public function makeTwigFilters ( $ filters = [ ] ) { if ( ! is_array ( $ filters ) ) { $ filters = [ ] ; } foreach ( $ this -> listFilters ( ) as $ name => $ callable ) { if ( strpos ( $ name , '*' ) !== false && $ this -> isWildCallable ( $ callable ) ) { $ callable = function ( $ name ) use ( $ callable ) { $ argume... | Makes a set of Twig filters for use in a twig extension . |
23,276 | public function makeTwigTokenParsers ( $ parsers = [ ] ) { if ( ! is_array ( $ parsers ) ) { $ parsers = [ ] ; } $ extraParsers = $ this -> listTokenParsers ( ) ; foreach ( $ extraParsers as $ obj ) { if ( ! $ obj instanceof Twig_TokenParser ) { continue ; } $ parsers [ ] = $ obj ; } return $ parsers ; } | Makes a set of Twig token parsers for use in a twig extension . |
23,277 | protected function isWildCallable ( $ callable , $ replaceWith = false ) { $ isWild = false ; if ( is_string ( $ callable ) && strpos ( $ callable , '*' ) !== false ) { $ isWild = $ replaceWith ? str_replace ( '*' , $ replaceWith , $ callable ) : true ; } if ( is_array ( $ callable ) ) { if ( is_string ( $ callable [ 0... | Tests if a callable type contains a wildcard also acts as a utility to replace the wildcard with a string . |
23,278 | public function makeWidget ( $ class , $ widgetConfig = [ ] ) { $ controller = property_exists ( $ this , 'controller' ) && $ this -> controller ? $ this -> controller : $ this ; if ( ! class_exists ( $ class ) ) { throw new SystemException ( Lang :: get ( 'backend::lang.widget.not_registered' , [ 'name' => $ class ] )... | Makes a widget object with the supplied configuration file . |
23,279 | public function makeFormWidget ( $ class , $ fieldConfig = [ ] , $ widgetConfig = [ ] ) { $ controller = property_exists ( $ this , 'controller' ) && $ this -> controller ? $ this -> controller : $ this ; if ( ! class_exists ( $ class ) ) { throw new SystemException ( Lang :: get ( 'backend::lang.widget.not_registered'... | Makes a form widget object with the supplied form field and widget configuration . |
23,280 | protected function processImportRow ( $ rowData , $ matches ) { $ newRow = [ ] ; foreach ( $ matches as $ columnIndex => $ dbNames ) { $ value = array_get ( $ rowData , $ columnIndex ) ; foreach ( ( array ) $ dbNames as $ dbName ) { $ newRow [ $ dbName ] = $ value ; } } return $ newRow ; } | Converts a single row of CSV data to the column map . |
23,281 | public function getImportFilePath ( $ sessionKey = null ) { $ file = $ this -> import_file ( ) -> withDeferred ( $ sessionKey ) -> orderBy ( 'id' , 'desc' ) -> first ( ) ; if ( ! $ file ) { return null ; } return $ file -> getLocalPath ( ) ; } | Returns an attached imported file local path if available . |
23,282 | public function getFormatEncodingOptions ( ) { $ options = [ 'utf-8' , 'us-ascii' , 'iso-8859-1' , 'iso-8859-2' , 'iso-8859-3' , 'iso-8859-4' , 'iso-8859-5' , 'iso-8859-6' , 'iso-8859-7' , 'iso-8859-8' , 'iso-8859-0' , 'iso-8859-10' , 'iso-8859-11' , 'iso-8859-13' , 'iso-8859-14' , 'iso-8859-15' , 'Windows-1251' , 'Win... | Returns all available encodings values from the localization config |
23,283 | protected function getSaveValueSecure ( $ value ) { $ newPermissions = is_array ( $ value ) ? array_map ( 'intval' , $ value ) : [ ] ; if ( ! empty ( $ newPermissions ) ) { $ existingPermissions = $ this -> model -> permissions ? : [ ] ; $ allowedPermissions = array_map ( function ( $ permissionObject ) { return $ perm... | Returns a safely parsed set of permissions ensuring the user cannot elevate their own permissions or permissions of another user above their own . |
23,284 | protected function getFilteredPermissions ( ) { $ permissions = BackendAuth :: listTabbedPermissions ( ) ; if ( $ this -> user -> isSuperUser ( ) ) { return $ permissions ; } foreach ( $ permissions as $ tab => $ permissionsArray ) { foreach ( $ permissionsArray as $ index => $ permission ) { if ( ! $ this -> user -> h... | Returns the available permissions ; removing those that the logged - in user does not have access to |
23,285 | public function afterFetch ( ) { $ manager = PluginManager :: instance ( ) ; $ pluginObj = $ manager -> findByIdentifier ( $ this -> code ) ; if ( $ pluginObj ) { $ pluginInfo = $ pluginObj -> pluginDetails ( ) ; foreach ( $ pluginInfo as $ attribute => $ info ) { if ( property_exists ( $ this , $ attribute ) ) { $ thi... | After the model is populated |
23,286 | public static function getVersion ( $ pluginCode ) { if ( self :: $ versionCache === null ) { self :: $ versionCache = self :: lists ( 'version' , 'code' ) ; } return self :: $ versionCache [ $ pluginCode ] ?? null ; } | Returns the current version for a plugin |
23,287 | public function beforeSave ( ) { $ staticAttributes = [ 'id' , 'theme' , 'data' , 'created_at' , 'updated_at' ] ; $ dynamicAttributes = array_except ( $ this -> getAttributes ( ) , $ staticAttributes ) ; $ this -> data = $ dynamicAttributes ; $ this -> setRawAttributes ( array_only ( $ this -> getAttributes ( ) , $ sta... | Before saving the model strip dynamic attributes applied from config . |
23,288 | public static function forTheme ( $ theme ) { $ dirName = $ theme -> getDirName ( ) ; if ( $ themeData = array_get ( self :: $ instances , $ dirName ) ) { return $ themeData ; } try { $ themeData = self :: firstOrCreate ( [ 'theme' => $ dirName ] ) ; } catch ( Exception $ ex ) { $ themeData = new self ( [ 'theme' => $ ... | Returns a cached version of this model based on a Theme object . |
23,289 | public function afterFetch ( ) { $ data = ( array ) $ this -> data + $ this -> getDefaultValues ( ) ; foreach ( $ this -> getFormFields ( ) as $ id => $ field ) { if ( ! isset ( $ field [ 'type' ] ) ) { continue ; } if ( $ field [ 'type' ] === 'repeater' ) { $ this -> jsonable [ ] = $ id ; } elseif ( $ field [ 'type' ]... | After fetching the model intiialize model relationships based on form field definitions . |
23,290 | public function getDefaultValues ( ) { $ result = [ ] ; foreach ( $ this -> getFormFields ( ) as $ attribute => $ field ) { if ( ( $ value = array_get ( $ field , 'default' ) ) === null ) { continue ; } $ result [ $ attribute ] = $ value ; } return $ result ; } | Gets default values for this model based on form field definitions . |
23,291 | public function getFormFields ( ) { if ( ! $ theme = CmsTheme :: load ( $ this -> theme ) ) { throw new Exception ( Lang :: get ( 'Unable to find theme with name :name' , $ this -> theme ) ) ; } $ config = $ theme -> getFormConfig ( ) ; return array_get ( $ config , 'fields' , [ ] ) + array_get ( $ config , 'tabs.field... | Returns all fields defined for this model based on form field definitions . |
23,292 | public function getAssetVariables ( ) { $ result = [ ] ; foreach ( $ this -> getFormFields ( ) as $ attribute => $ field ) { if ( ! $ varName = array_get ( $ field , 'assetVar' ) ) { continue ; } $ result [ $ varName ] = $ this -> { $ attribute } ; } return $ result ; } | Returns variables that should be passed to the asset combiner . |
23,293 | public static function applyAssetVariablesToCombinerFilters ( $ filters ) { $ theme = CmsTheme :: getActiveTheme ( ) ; if ( ! $ theme ) { return ; } if ( ! $ theme -> hasCustomData ( ) ) { return ; } $ assetVars = $ theme -> getCustomData ( ) -> getAssetVariables ( ) ; foreach ( $ filters as $ filter ) { if ( method_ex... | Applies asset variables to the combiner filters that support it . |
23,294 | public static function getCombinerCacheKey ( ) { $ theme = CmsTheme :: getActiveTheme ( ) ; if ( ! $ theme -> hasCustomData ( ) ) { return '' ; } $ customData = $ theme -> getCustomData ( ) ; return ( string ) $ customData -> updated_at ? : '' ; } | Generate a cache key for the combiner this allows variables to bust the cache . |
23,295 | protected function createModel ( $ item ) { if ( ! isset ( $ item -> class ) || ! strlen ( $ item -> class ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.settings.missing_model' ) ) ; } $ class = $ item -> class ; return $ class :: instance ( ) ; } | Internal method prepare the list model object |
23,296 | protected function findSettingItem ( $ author , $ plugin , $ code ) { $ manager = SettingsManager :: instance ( ) ; $ moduleOwner = $ author ; $ moduleCode = $ plugin ; $ item = $ manager -> findSettingItem ( $ moduleOwner , $ moduleCode ) ; if ( ! $ item ) { $ pluginOwner = $ author . '.' . $ plugin ; $ pluginCode = $... | Locates a setting item for a module or plugin |
23,297 | public function pluginDetails ( ) { $ thisClass = get_class ( $ this ) ; $ configuration = $ this -> getConfigurationFromYaml ( sprintf ( 'Plugin configuration file plugin.yaml is not ' . 'found for the plugin class %s. Create the file or override pluginDetails() ' . 'method in the plugin class.' , $ thisClass ) ) ; if... | Returns information about this plugin including plugin name and developer name . |
23,298 | public function registerNavigation ( ) { $ configuration = $ this -> getConfigurationFromYaml ( ) ; if ( array_key_exists ( 'navigation' , $ configuration ) ) { $ navigation = $ configuration [ 'navigation' ] ; if ( is_array ( $ navigation ) ) { array_walk_recursive ( $ navigation , function ( & $ item , $ key ) { if (... | Registers back - end navigation items for this plugin . |
23,299 | protected function getConfigurationFromYaml ( $ exceptionMessage = null ) { if ( $ this -> loadedYamlConfiguration !== false ) { return $ this -> loadedYamlConfiguration ; } $ reflection = new ReflectionClass ( get_class ( $ this ) ) ; $ yamlFilePath = dirname ( $ reflection -> getFileName ( ) ) . '/plugin.yaml' ; if (... | Read configuration from YAML file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.