idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,300 | public function renderPartial ( ) { $ this -> controller -> setComponentContext ( $ this ) ; $ result = call_user_func_array ( [ $ this -> controller , 'renderPartial' ] , func_get_args ( ) ) ; $ this -> controller -> setComponentContext ( null ) ; return $ result ; } | Renders a requested partial in context of this component see Cms \ Classes \ Controller |
23,301 | public function runAjaxHandler ( $ handler ) { if ( $ event = $ this -> fireSystemEvent ( 'cms.component.beforeRunAjaxHandler' , [ $ handler ] ) ) { return $ event ; } $ result = $ this -> $ handler ( ) ; if ( $ event = $ this -> fireSystemEvent ( 'cms.component.runAjaxHandler' , [ $ handler , $ result ] ) ) { return $... | Executes the event cycle when running an AJAX handler . |
23,302 | public function paramName ( $ name , $ default = null ) { if ( ( $ extName = $ this -> propertyName ( $ name ) ) && substr ( $ extName , 0 , 1 ) == ':' ) { return substr ( $ extName , 1 ) ; } return $ default ; } | Returns the external property name when the property value is a routing parameter reference . Otherwise the default value specified is returned . |
23,303 | public function makeLists ( ) { foreach ( $ this -> listDefinitions as $ definition => $ config ) { $ this -> listWidgets [ $ definition ] = $ this -> makeList ( $ definition ) ; } return $ this -> listWidgets ; } | Creates all the list widgets based on the definitions . |
23,304 | public function index ( ) { $ this -> controller -> pageTitle = $ this -> controller -> pageTitle ? : Lang :: get ( $ this -> getConfig ( 'title' , 'backend::lang.list.default_title' ) ) ; $ this -> controller -> bodyClass = 'slim-container' ; $ this -> makeLists ( ) ; } | Index Controller action . |
23,305 | public function index_onDelete ( ) { if ( method_exists ( $ this -> controller , 'onDelete' ) ) { return call_user_func_array ( [ $ this -> controller , 'onDelete' ] , func_get_args ( ) ) ; } $ checkedIds = post ( 'checked' ) ; if ( ! $ checkedIds || ! is_array ( $ checkedIds ) || ! count ( $ checkedIds ) ) { Flash :: ... | Bulk delete records . |
23,306 | public function listRender ( $ definition = null ) { if ( ! count ( $ this -> listWidgets ) ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.list.behavior_not_ready' ) ) ; } if ( ! $ definition || ! isset ( $ this -> listDefinitions [ $ definition ] ) ) { $ definition = $ this -> primaryDefinition ; } ... | Renders the widget collection . |
23,307 | public function listMakePartial ( $ partial , $ params = [ ] ) { $ contents = $ this -> controller -> makePartial ( 'list_' . $ partial , $ params + $ this -> vars , false ) ; if ( ! $ contents ) { $ contents = $ this -> makePartial ( $ partial , $ params ) ; } return $ contents ; } | Controller accessor for making partials within this behavior . |
23,308 | public function listRefresh ( $ definition = null ) { if ( ! count ( $ this -> listWidgets ) ) { $ this -> makeLists ( ) ; } if ( ! $ definition || ! isset ( $ this -> listDefinitions [ $ definition ] ) ) { $ definition = $ this -> primaryDefinition ; } return $ this -> listWidgets [ $ definition ] -> onRefresh ( ) ; } | Refreshes the list container only useful for returning in custom AJAX requests . |
23,309 | public function listGetWidget ( $ definition = null ) { if ( ! $ definition ) { $ definition = $ this -> primaryDefinition ; } return array_get ( $ this -> listWidgets , $ definition ) ; } | Returns the widget used by this behavior . |
23,310 | public function listGetConfig ( $ definition = null ) { if ( ! $ definition ) { $ definition = $ this -> primaryDefinition ; } if ( ! $ config = array_get ( $ this -> listConfig , $ definition ) ) { $ config = $ this -> listConfig [ $ definition ] = $ this -> makeConfig ( $ this -> listDefinitions [ $ definition ] , $ ... | Returns the configuration used by this behavior . |
23,311 | public static function extendListColumns ( $ callback ) { $ calledClass = self :: getCalledExtensionClass ( ) ; Event :: listen ( 'backend.list.extendColumns' , function ( $ widget ) use ( $ calledClass , $ callback ) { if ( ! is_a ( $ widget -> getController ( ) , $ calledClass ) ) { return ; } call_user_func_array ( ... | Static helper for extending list columns . |
23,312 | public static function extendListFilterScopes ( $ callback ) { $ calledClass = self :: getCalledExtensionClass ( ) ; Event :: listen ( 'backend.filter.extendScopes' , function ( $ widget ) use ( $ calledClass , $ callback ) { if ( ! is_a ( $ widget -> getController ( ) , $ calledClass ) ) { return ; } call_user_func_ar... | Static helper for extending filter scopes . |
23,313 | protected function loadComponents ( ) { foreach ( $ this -> callbacks as $ callback ) { $ callback ( $ this ) ; } $ pluginManager = PluginManager :: instance ( ) ; $ plugins = $ pluginManager -> getPlugins ( ) ; foreach ( $ plugins as $ plugin ) { $ components = $ plugin -> registerComponents ( ) ; if ( ! is_array ( $ ... | Scans each plugin an loads it s components . |
23,314 | public function registerComponent ( $ className , $ code = null , $ plugin = null ) { if ( ! $ this -> classMap ) { $ this -> classMap = [ ] ; } if ( ! $ this -> codeMap ) { $ this -> codeMap = [ ] ; } if ( ! $ code ) { $ code = Str :: getClassId ( $ className ) ; } if ( $ code == 'viewBag' && $ className != 'Cms\Compo... | Registers a single component . |
23,315 | public function listComponentDetails ( ) { if ( $ this -> detailsCache !== null ) { return $ this -> detailsCache ; } $ details = [ ] ; foreach ( $ this -> listComponents ( ) as $ componentAlias => $ componentClass ) { $ details [ $ componentAlias ] = $ this -> makeComponent ( $ componentClass ) -> componentDetails ( )... | Returns an array of all component detail definitions . |
23,316 | public function resolve ( $ name ) { $ codes = $ this -> listComponents ( ) ; if ( isset ( $ codes [ $ name ] ) ) { return $ codes [ $ name ] ; } $ name = Str :: normalizeClassName ( $ name ) ; if ( isset ( $ this -> classMap [ $ name ] ) ) { return $ name ; } return null ; } | Returns a class name from a component code Normalizes a class name or converts an code to it s class name . |
23,317 | public function hasComponent ( $ name ) { $ className = $ this -> resolve ( $ name ) ; if ( ! $ className ) { return false ; } return isset ( $ this -> classMap [ $ className ] ) ; } | Checks to see if a component has been registered . |
23,318 | public function makeComponent ( $ name , $ cmsObject = null , $ properties = [ ] ) { $ className = $ this -> resolve ( $ name ) ; if ( ! $ className ) { throw new SystemException ( sprintf ( 'Class name is not registered for the component "%s". Check the component plugin.' , $ name ) ) ; } if ( ! class_exists ( $ class... | Makes a component object with properties set . |
23,319 | public function findComponentPlugin ( $ component ) { $ className = Str :: normalizeClassName ( get_class ( $ component ) ) ; if ( isset ( $ this -> pluginMap [ $ className ] ) ) { return $ this -> pluginMap [ $ className ] ; } return null ; } | Returns a parent plugin for a specific component object . |
23,320 | public function sizeToString ( ) { return $ this -> type == self :: TYPE_FILE ? File :: sizeToString ( $ this -> size ) : $ this -> size . ' ' . trans ( 'system::lang.media.folder_size_items' ) ; } | Returns the item size as string . For file - type items the size is the number of bytes . For folder - type items the size is the number of items contained by the item . |
23,321 | public function getId ( $ suffix = null ) { $ id = 'column' ; $ id .= '-' . $ this -> columnName ; if ( $ suffix ) { $ id .= '-' . $ suffix ; } return HtmlHelper :: nameToId ( $ id ) ; } | Returns a value suitable for the column id property . |
23,322 | public function getValueFromData ( $ data , $ default = null ) { $ columnName = $ this -> valueFrom ? : $ this -> columnName ; return $ this -> getColumnNameFromData ( $ columnName , $ data , $ default ) ; } | Returns this columns value from a supplied data set which can be an array or a model or another generic collection . |
23,323 | protected function getColumnNameFromData ( $ columnName , $ data , $ default = null ) { $ keyParts = HtmlHelper :: nameToArray ( $ columnName ) ; $ result = $ data ; foreach ( $ keyParts as $ key ) { if ( $ result instanceof Model && $ result -> hasRelation ( $ key ) ) { $ result = $ result -> { $ key } ; } else { if (... | Internal method to extract the value of a column name from a data set . |
23,324 | protected function validateField ( $ field = null ) { $ field = $ field ? : post ( self :: PARAM_FIELD ) ; if ( $ field && $ field != $ this -> field ) { $ this -> initRelation ( $ this -> model , $ field ) ; } if ( ! $ field && ! $ this -> field ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.relatio... | Validates the supplied field and initializes the relation manager . |
23,325 | public function relationRender ( $ field , $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'sessionKey' => $ options ] ; } if ( isset ( $ options [ 'sessionKey' ] ) ) { $ this -> sessionKey = $ options [ 'sessionKey' ] ; } $ allowConfig = [ 'readOnly' , 'recordUrl' , 'recordOnClick' ] ; $ extraConfig... | Renders the relationship manager . |
23,326 | public function relationRefresh ( $ field = null ) { $ field = $ this -> validateField ( $ field ) ; $ result = [ '#' . $ this -> relationGetId ( 'view' ) => $ this -> relationRenderView ( $ field ) ] ; if ( $ toolbar = $ this -> relationRenderToolbar ( $ field ) ) { $ result [ '#' . $ this -> relationGetId ( 'toolbar'... | Refreshes the relation container only useful for returning in custom AJAX requests . |
23,327 | public function relationGetId ( $ suffix = null ) { $ id = class_basename ( $ this ) ; if ( $ this -> field ) { $ id .= '-' . $ this -> field ; } if ( $ suffix !== null ) { $ id .= '-' . $ suffix ; } return $ this -> controller -> getId ( $ id ) ; } | Returns a unique ID for this relation and field combination . |
23,328 | public function onRelationManageCreate ( ) { $ this -> forceManageMode = 'form' ; $ this -> beforeAjax ( ) ; $ saveData = $ this -> manageWidget -> getSaveData ( ) ; $ sessionKey = $ this -> deferredBinding ? $ this -> relationGetSessionKey ( true ) : null ; if ( $ this -> viewMode == 'multi' ) { $ newModel = $ this ->... | Create a new related model |
23,329 | public function onRelationManageUpdate ( ) { $ this -> forceManageMode = 'form' ; $ this -> beforeAjax ( ) ; $ saveData = $ this -> manageWidget -> getSaveData ( ) ; if ( $ this -> viewMode == 'multi' ) { $ model = $ this -> relationModel -> find ( $ this -> manageId ) ; $ modelsToSave = $ this -> prepareModelsToSave (... | Updated an existing related model s fields |
23,330 | public function onRelationManageDelete ( ) { $ this -> beforeAjax ( ) ; if ( $ this -> viewMode == 'multi' ) { if ( ( $ checkedIds = post ( 'checked' ) ) && is_array ( $ checkedIds ) ) { foreach ( $ checkedIds as $ relationId ) { if ( ! $ obj = $ this -> relationModel -> find ( $ relationId ) ) { continue ; } $ obj -> ... | Delete an existing related model completely |
23,331 | public function onRelationManageAdd ( ) { $ this -> beforeAjax ( ) ; $ recordId = post ( 'record_id' ) ; $ sessionKey = $ this -> deferredBinding ? $ this -> relationGetSessionKey ( ) : null ; if ( $ this -> viewMode == 'multi' ) { $ checkedIds = $ recordId ? [ $ recordId ] : post ( 'checked' ) ; if ( is_array ( $ chec... | Add an existing related model to the primary model |
23,332 | public function onRelationManageRemove ( ) { $ this -> beforeAjax ( ) ; $ recordId = post ( 'record_id' ) ; $ sessionKey = $ this -> deferredBinding ? $ this -> relationGetSessionKey ( ) : null ; $ relatedModel = $ this -> relationModel ; if ( $ this -> viewMode == 'multi' ) { $ checkedIds = $ recordId ? [ $ recordId ]... | Remove an existing related model from the primary model |
23,333 | protected function findExistingRelationIds ( $ checkIds = null ) { $ foreignKeyName = $ this -> relationModel -> getQualifiedKeyName ( ) ; $ results = $ this -> relationObject -> getBaseQuery ( ) -> select ( $ foreignKeyName ) ; if ( $ checkIds !== null && is_array ( $ checkIds ) && count ( $ checkIds ) ) { $ results =... | Returns the existing record IDs for the relation . |
23,334 | protected function evalToolbarButtons ( ) { $ buttons = $ this -> getConfig ( 'view[toolbarButtons]' ) ; if ( $ buttons === false ) { return null ; } elseif ( is_string ( $ buttons ) ) { return array_map ( 'trim' , explode ( '|' , $ buttons ) ) ; } elseif ( is_array ( $ buttons ) ) { return $ buttons ; } if ( $ this ->... | Determine the default buttons based on the model relationship type . |
23,335 | protected function evalManageTitle ( ) { if ( $ customTitle = $ this -> getConfig ( 'manage[title]' ) ) { return $ customTitle ; } switch ( $ this -> manageMode ) { case 'pivot' : case 'list' : if ( $ this -> eventTarget == 'button-link' ) { return 'backend::lang.relation.link_a_new' ; } return 'backend::lang.relation.... | Determine the management mode popup title . |
23,336 | protected function evalManageMode ( ) { if ( $ mode = post ( self :: PARAM_MODE ) ) { return $ mode ; } if ( $ this -> forceManageMode ) { return $ this -> forceManageMode ; } switch ( $ this -> eventTarget ) { case 'button-create' : case 'button-update' : return 'form' ; case 'button-link' : return 'list' ; } switch (... | Determine the management mode based on the relation type and settings . |
23,337 | protected function evalFormContext ( $ mode = 'manage' , $ exists = false ) { $ config = $ this -> config -> { $ mode } ?? [ ] ; if ( ( $ context = array_get ( $ config , 'context' ) ) && is_array ( $ context ) ) { $ context = $ exists ? array_get ( $ context , 'update' ) : array_get ( $ context , 'create' ) ; } if ( !... | Determine supplied form context . |
23,338 | protected function applyExtraConfig ( $ config , $ field = null ) { if ( ! $ field ) { $ field = $ this -> field ; } if ( ! $ config || ! isset ( $ this -> originalConfig -> { $ field } ) ) { return ; } if ( ! is_array ( $ config ) && ( ! $ config = @ json_decode ( @ base64_decode ( $ config ) , true ) ) ) { return ; }... | Apply extra configuration |
23,339 | public function beforeValidate ( ) { if ( ! $ theme = Theme :: getEditTheme ( ) ) { throw new ApplicationException ( 'Unable to find the active theme.' ) ; } $ themeMap = $ this -> getSettingsValue ( 'theme_map' , [ ] ) ; $ themeMap [ $ theme -> getDirName ( ) ] = $ this -> getSettingsValue ( 'cms_page' ) ; $ this -> s... | Ensure each theme has its own CMS page store it inside a mapping array . |
23,340 | public function afterFetch ( ) { if ( ( $ theme = Theme :: getEditTheme ( ) ) && ( $ themeMap = array_get ( $ this -> attributes , 'theme_map' ) ) && ( $ cmsPage = array_get ( $ themeMap , $ theme -> getDirName ( ) ) ) ) { $ this -> cms_page = $ cmsPage ; } else { $ this -> is_enabled = false ; } } | Restore the CMS page found in the mapping array or disable the maintenance mode . |
23,341 | public function stackPartial ( ) { if ( $ this -> activePartial !== null ) { array_unshift ( $ this -> partialStack , $ this -> activePartial ) ; } $ this -> activePartial = [ 'components' => [ ] ] ; } | Partial entry point appends a new partial to the stack . |
23,342 | public function getComponent ( $ name ) { if ( ! $ this -> activePartial ) { return null ; } $ component = $ this -> findComponentFromStack ( $ name , $ this -> activePartial ) ; if ( $ component !== null ) { return $ component ; } foreach ( $ this -> partialStack as $ stack ) { $ component = $ this -> findComponentFro... | Returns a component by its alias from the partial stack . |
23,343 | protected function findComponentFromStack ( $ name , $ stack ) { foreach ( $ stack [ 'components' ] as $ componentInfo ) { if ( $ componentInfo [ 'name' ] == $ name ) { return $ componentInfo [ 'obj' ] ; } } return null ; } | Locates a component by its alias from the supplied stack . |
23,344 | protected function init ( ) { $ this -> bindContainerObjects ( ) ; $ this -> metaFile = storage_path ( 'cms/disabled.json' ) ; $ this -> loadDisabled ( ) ; $ this -> loadPlugins ( ) ; if ( $ this -> app -> runningInBackend ( ) ) { $ this -> loadDependencies ( ) ; } } | Initializes the plugin manager |
23,345 | public function loadPlugin ( $ namespace , $ path ) { $ className = $ namespace . '\Plugin' ; $ classPath = $ path . '/Plugin.php' ; try { if ( ! class_exists ( $ className ) ) { include_once $ classPath ; } if ( ! class_exists ( $ className ) ) { return ; } $ classObj = new $ className ( $ this -> app ) ; } catch ( \ ... | Loads a single plugin in to the manager . |
23,346 | public function getPluginPath ( $ id ) { $ classId = $ this -> getIdentifier ( $ id ) ; if ( ! isset ( $ this -> pathMap [ $ classId ] ) ) { return null ; } return File :: normalizePath ( $ this -> pathMap [ $ classId ] ) ; } | Returns the directory path to a plugin |
23,347 | public function getPluginNamespaces ( ) { $ classNames = [ ] ; foreach ( $ this -> getVendorAndPluginNames ( ) as $ vendorName => $ vendorList ) { foreach ( $ vendorList as $ pluginName => $ pluginPath ) { $ namespace = '\\' . $ vendorName . '\\' . $ pluginName ; $ namespace = Str :: normalizeClassName ( $ namespace ) ... | Returns a flat array of vendor plugin namespaces and their paths |
23,348 | public function getVendorAndPluginNames ( ) { $ plugins = [ ] ; $ dirPath = plugins_path ( ) ; if ( ! File :: isDirectory ( $ dirPath ) ) { return $ plugins ; } $ it = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dirPath , RecursiveDirectoryIterator :: FOLLOW_SYMLINKS ) ) ; $ it -> setMaxDepth ( 2... | Returns a 2 dimensional array of vendors and their plugins . |
23,349 | public function getIdentifier ( $ namespace ) { $ namespace = Str :: normalizeClassName ( $ namespace ) ; if ( strpos ( $ namespace , '\\' ) === null ) { return $ namespace ; } $ parts = explode ( '\\' , $ namespace ) ; $ slice = array_slice ( $ parts , 1 , 2 ) ; $ namespace = implode ( '.' , $ slice ) ; return $ names... | Resolves a plugin identifier from a plugin class name or object . |
23,350 | public function getRegistrationMethodValues ( $ methodName ) { if ( isset ( $ this -> registrationMethodCache [ $ methodName ] ) ) { return $ this -> registrationMethodCache [ $ methodName ] ; } $ results = [ ] ; $ plugins = $ this -> getPlugins ( ) ; foreach ( $ plugins as $ id => $ plugin ) { if ( ! method_exists ( $... | Spins over every plugin object and collects the results of a method call . |
23,351 | protected function loadDisabled ( ) { $ path = $ this -> metaFile ; if ( ( $ configDisabled = Config :: get ( 'cms.disablePlugins' ) ) && is_array ( $ configDisabled ) ) { foreach ( $ configDisabled as $ disabled ) { $ this -> disabledPlugins [ $ disabled ] = true ; } } if ( File :: exists ( $ path ) ) { $ disabled = j... | Loads all disables plugins from the meta file . |
23,352 | public function isDisabled ( $ id ) { $ code = $ this -> getIdentifier ( $ id ) ; if ( array_key_exists ( $ code , $ this -> disabledPlugins ) ) { return true ; } return false ; } | Determines if a plugin is disabled by looking at the meta information or the application configuration . |
23,353 | protected function populateDisabledPluginsFromDb ( ) { if ( ! App :: hasDatabase ( ) ) { return ; } if ( ! Schema :: hasTable ( 'system_plugin_versions' ) ) { return ; } $ disabled = Db :: table ( 'system_plugin_versions' ) -> where ( 'is_disabled' , 1 ) -> lists ( 'code' ) ; foreach ( $ disabled as $ code ) { $ this -... | Populates information about disabled plugins from database |
23,354 | public function disablePlugin ( $ id , $ isUser = false ) { $ code = $ this -> getIdentifier ( $ id ) ; if ( array_key_exists ( $ code , $ this -> disabledPlugins ) ) { return false ; } $ this -> disabledPlugins [ $ code ] = $ isUser ; $ this -> writeDisabled ( ) ; if ( $ pluginObj = $ this -> findByIdentifier ( $ code... | Disables a single plugin in the system . |
23,355 | public function findMissingDependencies ( ) { $ missing = [ ] ; foreach ( $ this -> plugins as $ id => $ plugin ) { if ( ! $ required = $ this -> getDependencies ( $ plugin ) ) { continue ; } foreach ( $ required as $ require ) { if ( $ this -> hasPlugin ( $ require ) ) { continue ; } if ( ! in_array ( $ require , $ mi... | Scans the system plugins to locate any dependencies that are not currently installed . Returns an array of plugin codes that are needed . |
23,356 | protected function loadDependencies ( ) { foreach ( $ this -> plugins as $ id => $ plugin ) { if ( ! $ required = $ this -> getDependencies ( $ plugin ) ) { continue ; } $ disable = false ; foreach ( $ required as $ require ) { if ( ! $ pluginObj = $ this -> findByIdentifier ( $ require ) ) { $ disable = true ; } elsei... | Cross checks all plugins and their dependancies if not met plugins are disabled and vice versa . |
23,357 | public function getDependencies ( $ plugin ) { if ( is_string ( $ plugin ) && ( ! $ plugin = $ this -> findByIdentifier ( $ plugin ) ) ) { return false ; } if ( ! isset ( $ plugin -> require ) || ! $ plugin -> require ) { return null ; } return is_array ( $ plugin -> require ) ? $ plugin -> require : [ $ plugin -> requ... | Returns the plugin identifiers that are required by the supplied plugin . |
23,358 | public function sortByDependencies ( $ plugins = null ) { if ( ! is_array ( $ plugins ) ) { $ plugins = $ this -> getPlugins ( ) ; } $ result = [ ] ; $ checklist = $ plugins ; $ loopCount = 0 ; while ( count ( $ checklist ) ) { if ( ++ $ loopCount > 999 ) { throw new ApplicationException ( 'Too much recursion' ) ; } fo... | Sorts a collection of plugins in the order that they should be actioned according to their given dependencies . Least dependent come first . |
23,359 | public function deletePlugin ( $ id ) { UpdateManager :: instance ( ) -> rollbackPlugin ( $ id ) ; if ( $ pluginPath = self :: instance ( ) -> getPluginPath ( $ id ) ) { File :: deleteDirectory ( $ pluginPath ) ; } } | Completely roll back and delete a plugin from the system . |
23,360 | public function refreshPlugin ( $ id ) { $ manager = UpdateManager :: instance ( ) ; $ manager -> rollbackPlugin ( $ id ) ; $ manager -> updatePlugin ( $ id ) ; } | Tears down a plugin s database tables and rebuilds them . |
23,361 | public function url ( $ path = null , $ parameters = [ ] , $ secure = null ) { return Url :: to ( $ this -> uri ( ) . '/' . $ path , $ parameters , $ secure ) ; } | Returns a URL in context of the Backend |
23,362 | public function baseUrl ( $ path = null ) { $ backendUri = $ this -> uri ( ) ; $ baseUrl = Request :: getBaseUrl ( ) ; if ( $ path === null ) { return $ baseUrl . '/' . $ backendUri ; } $ path = RouterHelper :: normalizeUrl ( $ path ) ; return $ baseUrl . '/' . $ backendUri . $ path ; } | Returns the base backend URL |
23,363 | public function skinAsset ( $ path = null ) { $ skinPath = Skin :: getActive ( ) -> getPath ( $ path , true ) ; return Url :: asset ( $ skinPath ) ; } | Returns a URL in context of the active Backend skin |
23,364 | public function redirect ( $ path , $ status = 302 , $ headers = [ ] , $ secure = null ) { return Redirect :: to ( $ this -> uri ( ) . '/' . $ path , $ status , $ headers , $ secure ) ; } | Create a new redirect response to a given backend path . |
23,365 | public function redirectGuest ( $ path , $ status = 302 , $ headers = [ ] , $ secure = null ) { return Redirect :: guest ( $ this -> uri ( ) . '/' . $ path , $ status , $ headers , $ secure ) ; } | Create a new backend redirect response while putting the current URL in the session . |
23,366 | public function redirectIntended ( $ path , $ status = 302 , $ headers = [ ] , $ secure = null ) { return Redirect :: intended ( $ this -> uri ( ) . '/' . $ path , $ status , $ headers , $ secure ) ; } | Create a new redirect response to the previously intended backend location . |
23,367 | public function preview ( $ id ) { $ this -> addCss ( '/modules/system/assets/css/eventlogs/exception-beautifier.css' , 'core' ) ; $ this -> addJs ( '/modules/system/assets/js/eventlogs/exception-beautifier.js' , 'core' ) ; if ( in_array ( App :: environment ( ) , [ 'dev' , 'local' ] ) ) { $ this -> addJs ( '/modules/s... | Preview page action |
23,368 | public function getPath ( $ path = null , $ isPublic = false ) { $ path = RouterHelper :: normalizeUrl ( $ path ) ; $ assetFile = $ this -> skinPath . $ path ; if ( File :: isFile ( $ assetFile ) ) { return $ isPublic ? $ this -> publicSkinPath . $ path : $ this -> skinPath . $ path ; } return $ isPublic ? $ this -> de... | Looks up a path to a skin - based file if it doesn t exist the default path is used . |
23,369 | public static function getActive ( ) { if ( self :: $ skinCache !== null ) { return self :: $ skinCache ; } $ skinClass = Config :: get ( 'cms.backendSkin' ) ; $ skinObject = new $ skinClass ( ) ; return self :: $ skinCache = $ skinObject ; } | Returns the active skin . |
23,370 | protected function prepareVars ( $ model ) { $ this -> controller -> vars [ 'formModel' ] = $ model ; $ this -> controller -> vars [ 'formContext' ] = $ this -> formGetContext ( ) ; $ this -> controller -> vars [ 'formRecordName' ] = Lang :: get ( $ this -> getConfig ( 'name' , 'backend::lang.model.name' ) ) ; } | Prepares commonly used view data . |
23,371 | public function create ( $ context = null ) { try { $ this -> context = strlen ( $ context ) ? $ context : $ this -> getConfig ( 'create[context]' , self :: CONTEXT_CREATE ) ; $ this -> controller -> pageTitle = $ this -> controller -> pageTitle ? : $ this -> getLang ( "{$this->context}[title]" , 'backend::lang.form.cr... | Controller create action used for creating new model records . |
23,372 | public function create_onSave ( $ context = null ) { $ this -> context = strlen ( $ context ) ? $ context : $ this -> getConfig ( 'create[context]' , self :: CONTEXT_CREATE ) ; $ model = $ this -> controller -> formCreateModelObject ( ) ; $ model = $ this -> controller -> formExtendModel ( $ model ) ? : $ model ; $ thi... | AJAX handler onSave called from the create action and primarily used for creating new records . |
23,373 | public function update_onSave ( $ recordId = null , $ context = null ) { $ this -> context = strlen ( $ context ) ? $ context : $ this -> getConfig ( 'update[context]' , self :: CONTEXT_UPDATE ) ; $ model = $ this -> controller -> formFindModelObject ( $ recordId ) ; $ this -> initForm ( $ model ) ; $ this -> controlle... | AJAX handler onSave called from the update action and primarily used for updating existing records . |
23,374 | public function update_onDelete ( $ recordId = null ) { $ this -> context = $ this -> getConfig ( 'update[context]' , self :: CONTEXT_UPDATE ) ; $ model = $ this -> controller -> formFindModelObject ( $ recordId ) ; $ this -> initForm ( $ model ) ; $ model -> delete ( ) ; $ this -> controller -> formAfterDelete ( $ mod... | AJAX handler onDelete called from the update action and used for deleting existing records . |
23,375 | public function makeRedirect ( $ context = null , $ model = null ) { $ redirectUrl = null ; if ( post ( 'close' ) && ! ends_with ( $ context , '-close' ) ) { $ context .= '-close' ; } if ( post ( 'refresh' , false ) ) { return Redirect :: refresh ( ) ; } if ( post ( 'redirect' , true ) ) { $ redirectUrl = $ this -> get... | Returns a Redirect object based on supplied context and parses the model primary key . |
23,376 | protected function getRedirectUrl ( $ context = null ) { $ redirectContext = explode ( '-' , $ context , 2 ) [ 0 ] ; $ redirectSource = ends_with ( $ context , '-close' ) ? 'redirectClose' : 'redirect' ; $ redirects = [ $ context => $ this -> getConfig ( "{$redirectContext}[{$redirectSource}]" , '' ) ] ; $ redirects [ ... | Internal method that returns a redirect URL from the config based on supplied context . Otherwise the default redirect is used . |
23,377 | protected function getLang ( $ name , $ default = null , $ extras = [ ] ) { $ name = $ this -> getConfig ( $ name , $ default ) ; $ vars = [ 'name' => Lang :: get ( $ this -> getConfig ( 'name' , 'backend::lang.model.name' ) ) ] ; $ vars = array_merge ( $ vars , $ extras ) ; return Lang :: get ( $ name , $ vars ) ; } | Parses in some default variables to a language string defined in config . |
23,378 | public function formFindModelObject ( $ recordId ) { if ( ! strlen ( $ recordId ) ) { throw new ApplicationException ( $ this -> getLang ( 'not-found-message' , 'backend::lang.form.missing_id' ) ) ; } $ model = $ this -> controller -> formCreateModelObject ( ) ; $ query = $ model -> newQuery ( ) ; $ this -> controller ... | Finds a Model record by its primary identifier used by update actions . This logic can be changed by overriding it in the controller . |
23,379 | public static function extendFormFields ( $ callback ) { $ calledClass = self :: getCalledExtensionClass ( ) ; Event :: listen ( 'backend.form.extendFields' , function ( $ widget ) use ( $ calledClass , $ callback ) { if ( ! is_a ( $ widget -> getController ( ) , $ calledClass ) ) { return ; } call_user_func_array ( $ ... | Static helper for extending form fields . |
23,380 | public static function getRecent ( $ user ) { $ records = static :: where ( 'user_id' , $ user -> id ) -> orderBy ( 'created_at' , 'desc' ) -> limit ( 2 ) -> get ( ) ; if ( ! count ( $ records ) ) { return null ; } $ first = $ records -> first ( ) ; return ! $ first -> created_at -> isToday ( ) ? $ first : $ records ->... | Returns a recent entry latest entry is not considered recent if the creation day is the same as today . |
23,381 | public function getLayoutOptions ( ) { if ( ! ( $ theme = Theme :: getEditTheme ( ) ) ) { throw new ApplicationException ( Lang :: get ( 'cms::lang.theme.edit.not_found' ) ) ; } $ layouts = Layout :: listInTheme ( $ theme , true ) ; $ result = [ ] ; $ result [ null ] = Lang :: get ( 'cms::lang.page.no_layout' ) ; forea... | Returns a list of layouts available in the theme . This method is used by the form widget . |
23,382 | public static function getNameList ( ) { $ result = [ ] ; $ pages = self :: sortBy ( 'baseFileName' ) -> all ( ) ; foreach ( $ pages as $ page ) { $ result [ $ page -> baseFileName ] = $ page -> title . ' (' . $ page -> baseFileName . ')' ; } return $ result ; } | Helper that returns a nicer list of pages for use in dropdowns . |
23,383 | public static function url ( $ page , array $ params = [ ] ) { $ controller = Controller :: getController ( ) ? : new Controller ; return $ controller -> pageUrl ( $ page , $ params , true ) ; } | Helper that makes a URL for a page in the active theme . |
23,384 | public static function getRichEditorTypeInfo ( string $ type ) { $ result = [ ] ; if ( $ type === 'cms-page' ) { $ theme = Theme :: getActiveTheme ( ) ; $ pages = self :: listInTheme ( $ theme , true ) ; foreach ( $ pages as $ page ) { $ url = self :: url ( $ page -> getBaseFileName ( ) ) ; $ result [ $ url ] = $ page ... | Handler for the backend . richeditor . getTypeInfo event . Returns a menu item type information . The type information is returned as array |
23,385 | public static function validateExtension ( $ fileName , $ allowedExtensions , $ allowEmpty = true ) { $ extension = strtolower ( pathinfo ( $ fileName , PATHINFO_EXTENSION ) ) ; if ( empty ( $ extension ) ) { return $ allowEmpty ; } return in_array ( $ extension , $ allowedExtensions ) ; } | Validates whether a file has an allowed extension . |
23,386 | public static function validatePath ( $ filePath , $ maxNesting = 2 ) { if ( strpos ( $ filePath , '..' ) !== false ) { return false ; } if ( strpos ( $ filePath , './' ) !== false || strpos ( $ filePath , '//' ) !== false ) { return false ; } $ segments = explode ( '/' , $ filePath ) ; if ( $ maxNesting !== null && co... | Validates a CMS object path . CMS object directory and file names can contain only alphanumeric symbols dashes and dots . CMS objects support only a single level of subdirectories . |
23,387 | public function listNewVersions ( $ plugin ) { $ code = is_string ( $ plugin ) ? $ plugin : $ this -> pluginManager -> getIdentifier ( $ plugin ) ; if ( ! $ this -> hasVersionFile ( $ code ) ) { return [ ] ; } $ databaseVersion = $ this -> getDatabaseVersion ( $ code ) ; return $ this -> getNewFileVersions ( $ code , $... | Returns a list of unapplied plugin versions . |
23,388 | protected function applyPluginUpdate ( $ code , $ version , $ details ) { if ( is_array ( $ details ) ) { $ comment = array_shift ( $ details ) ; $ scripts = $ details ; } else { $ comment = $ details ; $ scripts = [ ] ; } foreach ( $ scripts as $ script ) { if ( $ this -> hasDatabaseHistory ( $ code , $ version , $ sc... | Applies a single version update to a plugin . |
23,389 | public function purgePlugin ( $ pluginCode ) { $ versions = Db :: table ( 'system_plugin_versions' ) -> where ( 'code' , $ pluginCode ) ; if ( $ countVersions = $ versions -> count ( ) ) { $ versions -> delete ( ) ; } $ history = Db :: table ( 'system_plugin_history' ) -> where ( 'code' , $ pluginCode ) ; if ( $ countH... | Deletes all records from the version and history tables for a plugin . |
23,390 | protected function getNewFileVersions ( $ code , $ version = null ) { if ( $ version === null ) { $ version = self :: NO_VERSION_VALUE ; } $ versions = $ this -> getFileVersions ( $ code ) ; $ position = array_search ( $ version , array_keys ( $ versions ) ) ; return array_slice ( $ versions , ++ $ position ) ; } | Returns any new versions from a supplied version ie . unapplied versions . |
23,391 | protected function getFileVersions ( $ code ) { if ( $ this -> fileVersions !== null && array_key_exists ( $ code , $ this -> fileVersions ) ) { return $ this -> fileVersions [ $ code ] ; } $ versionFile = $ this -> getVersionFile ( $ code ) ; $ versionInfo = Yaml :: parseFile ( $ versionFile ) ; if ( ! is_array ( $ ve... | Returns all versions of a plugin from its version file . |
23,392 | protected function getDatabaseVersion ( $ code ) { if ( $ this -> databaseVersions === null ) { $ this -> databaseVersions = Db :: table ( 'system_plugin_versions' ) -> lists ( 'version' , 'code' ) ; } if ( ! isset ( $ this -> databaseVersions [ $ code ] ) ) { $ this -> databaseVersions [ $ code ] = Db :: table ( 'syst... | Returns the latest version of a plugin from the database . |
23,393 | protected function setDatabaseVersion ( $ code , $ version = null ) { $ currentVersion = $ this -> getDatabaseVersion ( $ code ) ; if ( $ version && ! $ currentVersion ) { Db :: table ( 'system_plugin_versions' ) -> insert ( [ 'code' => $ code , 'version' => $ version , 'created_at' => new Carbon ] ) ; } elseif ( $ ver... | Updates a plugin version in the database . |
23,394 | protected function applyDatabaseComment ( $ code , $ version , $ comment ) { Db :: table ( 'system_plugin_history' ) -> insert ( [ 'code' => $ code , 'type' => self :: HISTORY_TYPE_COMMENT , 'version' => $ version , 'detail' => $ comment , 'created_at' => new Carbon ] ) ; } | Registers a database update comment in the history table . |
23,395 | protected function removeDatabaseComment ( $ code , $ version ) { Db :: table ( 'system_plugin_history' ) -> where ( 'code' , $ code ) -> where ( 'type' , self :: HISTORY_TYPE_COMMENT ) -> where ( 'version' , $ version ) -> delete ( ) ; } | Removes a database update comment in the history table . |
23,396 | protected function applyDatabaseScript ( $ code , $ version , $ script ) { $ updateFile = $ this -> pluginManager -> getPluginPath ( $ code ) . '/updates/' . $ script ; if ( ! File :: isFile ( $ updateFile ) ) { $ this -> note ( '- <error>v' . $ version . ': Migration file "' . $ script . '" not found</error>' ) ; } $... | Registers a database update script in the history table . |
23,397 | protected function removeDatabaseScript ( $ code , $ version , $ script ) { $ updateFile = $ this -> pluginManager -> getPluginPath ( $ code ) . '/updates/' . $ script ; $ this -> updater -> packDown ( $ updateFile ) ; Db :: table ( 'system_plugin_history' ) -> where ( 'code' , $ code ) -> where ( 'type' , self :: HIST... | Removes a database update script in the history table . |
23,398 | protected function getDatabaseHistory ( $ code ) { if ( $ this -> databaseHistory !== null && array_key_exists ( $ code , $ this -> databaseHistory ) ) { return $ this -> databaseHistory [ $ code ] ; } $ historyInfo = Db :: table ( 'system_plugin_history' ) -> where ( 'code' , $ code ) -> orderBy ( 'id' ) -> get ( ) ->... | Returns all the update history for a plugin . |
23,399 | protected function hasDatabaseHistory ( $ code , $ version , $ script = null ) { $ historyInfo = $ this -> getDatabaseHistory ( $ code ) ; if ( ! $ historyInfo ) { return false ; } foreach ( $ historyInfo as $ history ) { if ( $ history -> version != $ version ) { continue ; } if ( $ history -> type == self :: HISTORY_... | Checks if a plugin has an applied update version . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.