idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
23,500
public function getFormWidget ( $ field ) { if ( isset ( $ this -> formWidgets [ $ field ] ) ) { return $ this -> formWidgets [ $ field ] ; } return null ; }
Get a specified form widget
23,501
public function getField ( $ field ) { if ( isset ( $ this -> allFields [ $ field ] ) ) { return $ this -> allFields [ $ field ] ; } return null ; }
Get a specified field object
23,502
protected function getFieldValue ( $ field ) { if ( is_string ( $ field ) ) { if ( ! isset ( $ this -> allFields [ $ field ] ) ) { throw new ApplicationException ( Lang :: get ( 'backend::lang.form.missing_definition' , compact ( 'field' ) ) ) ; } $ field = $ this -> allFields [ $ field ] ; } $ defaultValue = ! $ this ...
Looks up the field value .
23,503
protected function getFieldDepends ( $ field ) { if ( ! $ field -> dependsOn ) { return '' ; } $ dependsOn = is_array ( $ field -> dependsOn ) ? $ field -> dependsOn : [ $ field -> dependsOn ] ; $ dependsOn = htmlspecialchars ( json_encode ( $ dependsOn ) , ENT_QUOTES , 'UTF-8' ) ; return $ dependsOn ; }
Returns a HTML encoded value containing the other fields this field depends on
23,504
protected function showFieldLabels ( $ field ) { if ( in_array ( $ field -> type , [ 'checkbox' , 'switch' , 'section' ] ) ) { return false ; } if ( $ field -> type === 'widget' ) { return $ this -> makeFormFieldWidget ( $ field ) -> showLabels ; } return true ; }
Helper method to determine if field should be rendered with label and comments .
23,505
public function getSaveData ( ) { $ this -> defineFormFields ( ) ; $ result = [ ] ; $ data = $ this -> arrayName ? post ( $ this -> arrayName ) : post ( ) ; if ( ! $ data ) { $ data = [ ] ; } foreach ( $ this -> allFields as $ field ) { if ( $ field -> disabled || $ field -> hidden ) { continue ; } $ parts = HtmlHelper...
Returns post data from a submitted form .
23,506
protected function getOptionsFromModel ( $ field , $ fieldOptions ) { if ( is_array ( $ fieldOptions ) && is_callable ( $ fieldOptions ) ) { $ fieldOptions = call_user_func ( $ fieldOptions , $ this , $ field ) ; } if ( ! is_array ( $ fieldOptions ) && ! $ fieldOptions ) { try { list ( $ model , $ attribute ) = $ field...
Looks at the model for defined options .
23,507
protected function objectMethodExists ( $ object , $ method ) { if ( method_exists ( $ object , 'methodExists' ) ) { return $ object -> methodExists ( $ method ) ; } return method_exists ( $ object , $ method ) ; }
Internal helper for method existence checks .
23,508
public function fill ( array $ attributes ) { foreach ( $ attributes as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> fillable ) ) { throw new ApplicationException ( Lang :: get ( 'cms::lang.cms_object.invalid_property' , [ 'name' => $ key ] ) ) ; } $ this -> $ key = $ value ; } }
Sets the object attributes .
23,509
public function save ( ) { $ this -> validateFileName ( ) ; $ fullPath = $ this -> getFilePath ( ) ; if ( File :: isFile ( $ fullPath ) && $ this -> originalFileName !== $ this -> fileName ) { throw new ApplicationException ( Lang :: get ( 'cms::lang.cms_object.file_already_exists' , [ 'name' => $ this -> fileName ] ) ...
Saves the object to the disk .
23,510
protected function validateFileName ( $ fileName = null ) { if ( $ fileName === null ) { $ fileName = $ this -> fileName ; } $ fileName = trim ( $ fileName ) ; if ( ! strlen ( $ fileName ) ) { throw new ValidationException ( [ 'fileName' => Lang :: get ( 'cms::lang.cms_object.file_name_required' , [ 'allowed' => implod...
Validate the supplied filename extension and path .
23,511
public function getFilters ( ) { $ filters = [ new Twig_SimpleFilter ( 'app' , [ $ this , 'appFilter' ] , [ 'is_safe' => [ 'html' ] ] ) , new Twig_SimpleFilter ( 'media' , [ $ this , 'mediaFilter' ] , [ 'is_safe' => [ 'html' ] ] ) , ] ; $ filters = $ this -> markupManager -> makeTwigFilters ( $ filters ) ; return $ fil...
Returns a list of filters this extensions provides .
23,512
public function searchRecords ( $ query , $ offset , $ count ) { return $ this -> fireEvent ( 'data.searchRecords' , [ $ query , $ offset , $ count ] , true ) ; }
Identical to getRecords except provided with a search query .
23,513
public function onSubmit ( ) { $ this -> setActiveTerm ( post ( $ this -> getName ( ) ) ) ; $ params = func_get_args ( ) ; $ result = $ this -> fireEvent ( 'search.submit' , [ $ params ] ) ; if ( $ result && is_array ( $ result ) ) { return call_user_func_array ( 'array_merge' , $ result ) ; } }
Search field has been submitted .
23,514
public function setActiveTerm ( $ term ) { if ( strlen ( $ term ) ) { $ this -> putSession ( 'term' , $ term ) ; } else { $ this -> resetSession ( ) ; } $ this -> activeTerm = $ term ; }
Sets an active search term for this widget instance .
23,515
protected function defineReportWidgets ( ) { if ( $ this -> reportsDefined ) { return ; } $ result = [ ] ; $ widgets = $ this -> getWidgetsFromUserPreferences ( ) ; foreach ( $ widgets as $ alias => $ widgetInfo ) { if ( $ widget = $ this -> makeReportWidget ( $ alias , $ widgetInfo ) ) { $ result [ $ alias ] = $ widge...
Registers the report widgets that will be included in this container . The chosen widgets are based on the user preferences .
23,516
public function fireSystemEvent ( $ event , $ params = [ ] , $ halt = true ) { $ result = [ ] ; $ shortEvent = substr ( $ event , strpos ( $ event , '.' ) + 1 ) ; $ longArgs = array_merge ( [ $ this ] , $ params ) ; if ( $ response = $ this -> fireEvent ( $ shortEvent , $ params , $ halt ) ) { if ( $ halt ) { return $ ...
Fires a combination of local and global events . The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally . Halting is also enabled by default .
23,517
public function fireViewEvent ( $ event , $ params = [ ] ) { array_unshift ( $ params , $ this ) ; if ( $ result = Event :: fire ( $ event , $ params ) ) { return implode ( PHP_EOL . PHP_EOL , ( array ) $ result ) ; } return '' ; }
Special event function used for extending within view files allowing HTML to be injected multiple times .
23,518
protected function prepareVars ( ) { $ this -> vars [ 'reorderRecords' ] = $ this -> getRecords ( ) ; $ this -> vars [ 'reorderModel' ] = $ this -> model ; $ this -> vars [ 'reorderSortMode' ] = $ this -> sortMode ; $ this -> vars [ 'reorderShowTree' ] = $ this -> showTree ; $ this -> vars [ 'reorderToolbarWidget' ] = ...
Prepares common form data
23,519
protected function getRecords ( ) { $ records = null ; $ model = $ this -> controller -> reorderGetModel ( ) ; $ query = $ model -> newQuery ( ) ; $ this -> controller -> reorderExtendQuery ( $ query ) ; if ( $ this -> sortMode == 'simple' ) { $ records = $ query -> orderBy ( $ model -> getSortOrderColumn ( ) ) -> get ...
Returns all the records from the supplied model .
23,520
public function getParsedMarkupAttribute ( ) { if ( array_key_exists ( 'parsedMarkup' , $ this -> attributes ) ) { return $ this -> attributes [ 'parsedMarkup' ] ; } return $ this -> attributes [ 'parsedMarkup' ] = $ this -> parseMarkup ( ) ; }
Returns a default value for parsedMarkup attribute .
23,521
public function parseMarkup ( ) { $ extension = strtolower ( File :: extension ( $ this -> fileName ) ) ; switch ( $ extension ) { case 'txt' : $ result = htmlspecialchars ( $ this -> markup ) ; break ; case 'md' : $ result = Markdown :: parse ( $ this -> markup ) ; break ; default : $ result = $ this -> markup ; } ret...
Parses the content markup according to the file type .
23,522
protected function applyEditorPreferences ( ) { $ preferences = BackendPreference :: instance ( ) ; $ this -> fontSize = $ preferences -> editor_font_size ; $ this -> wordWrap = $ preferences -> editor_word_wrap ; $ this -> codeFolding = $ preferences -> editor_code_folding ; $ this -> autoClosing = $ preferences -> ed...
Looks at the user preferences and overrides any set values .
23,523
protected function registerComponents ( ) { ComponentManager :: instance ( ) -> registerComponents ( function ( $ manager ) { $ manager -> registerComponent ( \ Cms \ Components \ ViewBag :: class , 'viewBag' ) ; $ manager -> registerComponent ( \ Cms \ Components \ Resources :: class , 'resources' ) ; } ) ; }
Register components .
23,524
protected function registerCombinerEvents ( ) { if ( App :: runningInBackend ( ) || App :: runningInConsole ( ) ) { return ; } Event :: listen ( 'cms.combiner.beforePrepare' , function ( $ combiner , $ assets ) { $ filters = array_flatten ( $ combiner -> getFilters ( ) ) ; ThemeData :: applyAssetVariablesToCombinerFilt...
Registers events for the asset combiner .
23,525
protected function bootMenuItemEvents ( ) { Event :: listen ( 'pages.menuitem.listTypes' , function ( ) { return [ 'cms-page' => 'cms::lang.page.cms_page' ] ; } ) ; Event :: listen ( 'pages.menuitem.getTypeInfo' , function ( $ type ) { if ( $ type === 'cms-page' ) { return CmsPage :: getMenuTypeInfo ( $ type ) ; } } ) ...
Registers events for menu items .
23,526
protected function bootRichEditorEvents ( ) { Event :: listen ( 'backend.richeditor.listTypes' , function ( ) { return [ 'cms-page' => 'cms::lang.page.cms_page' ] ; } ) ; Event :: listen ( 'backend.richeditor.getTypeInfo' , function ( $ type ) { if ( $ type === 'cms-page' ) { return CmsPage :: getRichEditorTypeInfo ( $...
Registers events for rich editor page links .
23,527
public function resetDefault ( ) { if ( $ record = $ this -> getSettingsRecord ( ) ) { $ record -> delete ( ) ; unset ( self :: $ instances [ $ this -> recordCode ] ) ; Cache :: forget ( $ this -> getCacheKey ( ) ) ; } }
Reset the settings to their defaults this will delete the record model
23,528
public function set ( $ key , $ value = null ) { $ data = is_array ( $ key ) ? $ key : [ $ key => $ value ] ; $ obj = self :: instance ( ) ; $ obj -> fill ( $ data ) ; return $ obj -> save ( ) ; }
Set a single or array key pair of values intended as a static method
23,529
public function getSettingsValue ( $ key , $ default = null ) { if ( array_key_exists ( $ key , $ this -> fieldValues ) ) { return $ this -> fieldValues [ $ key ] ; } return array_get ( $ this -> fieldValues , $ key , $ default ) ; }
Get a single setting value or return a default value
23,530
public function setSettingsValue ( $ key , $ value ) { if ( $ this -> isKeyAllowed ( $ key ) ) { return ; } $ this -> fieldValues [ $ key ] = $ value ; }
Set a single setting value if allowed .
23,531
public function afterModelFetch ( ) { $ this -> fieldValues = $ this -> model -> value ? : [ ] ; $ this -> model -> attributes = array_merge ( $ this -> fieldValues , $ this -> model -> attributes ) ; }
Populate the field values from the database record .
23,532
public function saveModelInternal ( ) { $ this -> model -> attributes = array_diff_key ( $ this -> model -> attributes , $ this -> fieldValues ) ; }
Internal save method for the model
23,533
public function afterModelSave ( ) { Cache :: forget ( $ this -> getCacheKey ( ) ) ; try { Artisan :: call ( 'queue:restart' ) ; } catch ( Exception $ e ) { Log :: warning ( $ e -> getMessage ( ) ) ; } }
After the model is saved clear the cached query entry and restart queue workers so they have the latest settings
23,534
protected function isKeyAllowed ( $ key ) { if ( $ key == 'id' || $ key == 'value' || $ key == 'item' ) { return true ; } if ( $ this -> model -> hasRelation ( $ key ) ) { return true ; } return false ; }
Checks if a key is legitimate or should be added to the field value collection
23,535
public function getFieldConfig ( ) { if ( $ this -> fieldConfig !== null ) { return $ this -> fieldConfig ; } return $ this -> fieldConfig = $ this -> makeConfig ( $ this -> model -> settingsFields ) ; }
Returns the field configuration used by this model .
23,536
public function resetUrlComponent ( $ name , $ property = null ) { $ this -> urlComponentName = $ name ; if ( $ property ) { $ this -> urlComponentProperty = $ property ; } static :: $ urlPageName = $ this -> url = null ; }
Changes the component used for generating the URLs dynamically .
23,537
public function getUrlAttribute ( ) { if ( $ this -> url === null ) { $ this -> url = $ this -> makeUrl ( ) ; } return $ this -> url ; }
Mutator for the url attribute . Returns the URL detected by the component .
23,538
public function getUrlPageName ( ) { if ( static :: $ urlPageName !== null ) { return static :: $ urlPageName ; } $ key = 'urlMaker' . $ this -> urlComponentName . crc32 ( get_class ( $ this ) ) ; $ cached = Cache :: get ( $ key , false ) ; if ( $ cached !== false && ( $ cached = @ unserialize ( $ cached ) ) !== false ...
Locates the page name where the detected component is found . This method uses the Cache service to improve performance .
23,539
protected function makeUrl ( ) { $ controller = Controller :: getController ( ) ? : new Controller ; return $ controller -> pageUrl ( $ this -> getUrlPageName ( ) , $ this -> getUrlParams ( ) ) ; }
Generates a real URL based on the page detected by the primary component . The CMS Controller is used for this process passing the declared params .
23,540
protected function hideAction ( $ methodName ) { if ( ! is_array ( $ methodName ) ) { $ methodName = [ $ methodName ] ; } $ this -> controller -> hiddenActions = array_merge ( $ this -> controller -> hiddenActions , $ methodName ) ; }
Protects a public method from being available as an controller action . These methods could be defined in a controller to override a behavior default action . Such methods should be defined as public to allow the behavior object to access it . By default public methods of a controller are considered as actions . To pre...
23,541
public function makeFileContents ( $ filePath , $ extraParams = [ ] ) { $ this -> controller -> vars = array_merge ( $ this -> controller -> vars , $ this -> vars ) ; return $ this -> controller -> makeFileContents ( $ filePath , $ extraParams ) ; }
Makes all views in context of the controller not the behavior .
23,542
public function bindToController ( ) { if ( $ this -> controller -> widget === null ) { $ this -> controller -> widget = new stdClass ; } $ this -> controller -> widget -> { $ this -> alias } = $ this ; }
Binds a widget to the controller for safe use .
23,543
public function getConfig ( $ name , $ default = null ) { $ keyParts = HtmlHelper :: nameToArray ( $ name ) ; $ fieldName = array_shift ( $ keyParts ) ; if ( ! isset ( $ this -> config -> { $ fieldName } ) ) { return $ default ; } $ result = $ this -> config -> { $ fieldName } ; foreach ( $ keyParts as $ key ) { if ( !...
Safe accessor for configuration values .
23,544
protected function getCollapseStatuses ( ) { if ( $ this -> collapseGroupStatusCache !== false ) { return $ this -> collapseGroupStatusCache ; } $ groups = $ this -> getSession ( $ this -> collapseSessionKey , [ ] ) ; if ( ! is_array ( $ groups ) ) { return $ this -> collapseGroupStatusCache = [ ] ; } return $ this -> ...
Returns the array of all collapsed states belonging to this widget .
23,545
protected function setCollapseStatus ( $ group , $ status ) { $ statuses = $ this -> getCollapseStatuses ( ) ; $ statuses [ $ group ] = $ status ; $ this -> collapseGroupStatusCache = $ statuses ; $ this -> putSession ( $ this -> collapseSessionKey , $ statuses ) ; }
Sets a collapsed state .
23,546
protected function getCollapseStatus ( $ group , $ default = true ) { $ statuses = $ this -> getCollapseStatuses ( ) ; if ( array_key_exists ( $ group , $ statuses ) ) { return $ statuses [ $ group ] ; } return $ default ; }
Gets a collapsed state .
23,547
public static function getConfiguredStyles ( $ key , $ default = null ) { $ instance = static :: instance ( ) ; $ value = $ instance -> get ( $ key ) ; $ defaultValue = $ instance -> getDefaultValue ( $ key ) ; if ( is_array ( $ value ) ) { $ value = array_build ( $ value , function ( $ key , $ value ) { return [ array...
Same as getConfigured but uses special style structure .
23,548
public static function getConfigured ( $ key , $ default = null ) { $ instance = static :: instance ( ) ; $ value = $ instance -> get ( $ key ) ; $ defaultValue = $ instance -> getDefaultValue ( $ key ) ; return $ value != $ defaultValue ? $ value : $ default ; }
Returns the value only if it differs from the default value .
23,549
public function listInjectRowClass ( $ record , $ definition = null ) { if ( $ record -> disabledByConfig ) { return 'hidden' ; } if ( $ record -> orphaned || $ record -> is_disabled ) { return 'safe disabled' ; } if ( $ definition != 'manage' ) { return ; } if ( $ record -> disabledBySystem ) { return 'negative' ; } i...
Override for ListController behavior . Modifies the CSS class for each row in the list to
23,550
public function onExecuteStep ( ) { @ set_time_limit ( 3600 ) ; $ manager = UpdateManager :: instance ( ) ; $ stepCode = post ( 'code' ) ; switch ( $ stepCode ) { case 'downloadCore' : $ manager -> downloadCore ( post ( 'hash' ) ) ; break ; case 'extractCore' : $ manager -> extractCore ( ) ; break ; case 'setBuild' : $...
Runs a specific update step .
23,551
protected function processImportantUpdates ( $ result ) { $ hasImportantUpdates = false ; if ( isset ( $ result [ 'core' ] ) ) { $ coreImportant = false ; foreach ( array_get ( $ result , 'core.updates' , [ ] ) as $ build => $ description ) { if ( strpos ( $ description , '!!!' ) === false ) continue ; $ detailsUrl = '...
Loops the update list and checks for actionable updates .
23,552
protected function processUpdateLists ( $ result ) { if ( $ core = array_get ( $ result , 'core' ) ) { $ result [ 'core' ] [ 'updates' ] = array_reverse ( array_get ( $ core , 'updates' , [ ] ) , true ) ; } foreach ( array_get ( $ result , 'plugins' , [ ] ) as $ code => $ plugin ) { $ result [ 'plugins' ] [ $ code ] [ ...
Reverses the update lists for the core and all plugins .
23,553
public function onApplyUpdates ( ) { try { $ coreHash = post ( 'hash' ) ; $ coreBuild = post ( 'build' ) ; $ core = [ $ coreHash , $ coreBuild ] ; $ plugins = post ( 'plugins' ) ; if ( is_array ( $ plugins ) ) { $ pluginCodes = [ ] ; foreach ( $ plugins as $ code => $ hash ) { $ pluginCodes [ ] = $ this -> decodeCode (...
Converts the update data to an actionable array of steps .
23,554
public function onAttachProject ( ) { try { if ( ! $ projectId = trim ( post ( 'project_id' ) ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.project.id.missing' ) ) ; } $ manager = UpdateManager :: instance ( ) ; $ result = $ manager -> requestProjectDetails ( $ projectId ) ; Parameter :: set ( [ 's...
Validate the project ID and execute the project installation
23,555
public function onInstallPlugin ( ) { try { if ( ! $ code = trim ( post ( 'code' ) ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.install.missing_plugin_name' ) ) ; } $ manager = UpdateManager :: instance ( ) ; $ result = $ manager -> requestPluginDetails ( $ code ) ; if ( ! isset ( $ result [ 'code...
Validate the plugin code and execute the plugin installation
23,556
public function onRemovePlugin ( ) { if ( $ pluginCode = post ( 'code' ) ) { PluginManager :: instance ( ) -> deletePlugin ( $ pluginCode ) ; Flash :: success ( Lang :: get ( 'system::lang.plugins.remove_success' ) ) ; } return Redirect :: refresh ( ) ; }
Rollback and remove a single plugin from the system .
23,557
public function onBulkAction ( ) { if ( ( $ bulkAction = post ( 'action' ) ) && ( $ checkedIds = post ( 'checked' ) ) && is_array ( $ checkedIds ) && count ( $ checkedIds ) ) { $ manager = PluginManager :: instance ( ) ; foreach ( $ checkedIds as $ pluginId ) { if ( ! $ plugin = PluginVersion :: find ( $ pluginId ) ) {...
Perform a bulk action on the provided plugins
23,558
public function onRemoveTheme ( ) { if ( $ themeCode = post ( 'code' ) ) { ThemeManager :: instance ( ) -> deleteTheme ( $ themeCode ) ; Flash :: success ( trans ( 'cms::lang.theme.delete_theme_success' ) ) ; } return Redirect :: refresh ( ) ; }
Deletes a single theme from the system .
23,559
protected function appendRequiredPlugins ( array $ plugins , array $ result ) { foreach ( ( array ) array_get ( $ result , 'require' ) as $ plugin ) { if ( ( $ name = array_get ( $ plugin , 'code' ) ) && ( $ hash = array_get ( $ plugin , 'hash' ) ) && ! PluginManager :: instance ( ) -> hasPlugin ( $ name ) ) { $ plugin...
Adds require plugin codes to the collection based on a result .
23,560
public static function getGlobalVars ( ) { if ( static :: $ globalVarCache !== null ) { return static :: $ globalVarCache ; } $ vars = array_filter ( ViewFacade :: getShared ( ) , function ( $ var ) { return is_scalar ( $ var ) || is_array ( $ var ) ; } ) ; return static :: $ globalVarCache = $ vars ; }
Returns shared view variables this should be used for simple rendering cycles . Such as content blocks and mail templates .
23,561
public static function loadCached ( $ theme , $ fileName ) { return static :: inTheme ( $ theme ) -> remember ( Config :: get ( 'cms.parsedPageCacheTTL' , 1440 ) ) -> find ( $ fileName ) ; }
Loads the object from a cache . This method is used by the CMS in the runtime . If the cache is not found it is created .
23,562
public static function listInTheme ( $ theme , $ skipCache = false ) { $ result = [ ] ; $ instance = static :: inTheme ( $ theme ) ; if ( $ skipCache ) { $ result = $ instance -> get ( ) ; } else { $ items = $ instance -> newQuery ( ) -> lists ( 'fileName' ) ; $ loadedItems = [ ] ; foreach ( $ items as $ item ) { $ loa...
Returns the list of objects in the specified theme . This method is used internally by the system .
23,563
public static function inTheme ( $ theme ) { if ( is_string ( $ theme ) ) { $ theme = Theme :: load ( $ theme ) ; } return static :: on ( $ theme -> getDirName ( ) ) ; }
Prepares the theme datasource for the model .
23,564
public function save ( array $ options = null ) { try { parent :: save ( $ options ) ; } catch ( Exception $ ex ) { $ this -> throwHalcyonSaveException ( $ ex ) ; } }
Save the object to the theme .
23,565
public function getThemeAttribute ( ) { if ( $ this -> themeCache !== null ) { return $ this -> themeCache ; } $ themeName = $ this -> getDatasourceName ( ) ? : static :: getDatasourceResolver ( ) -> getDefaultDatasource ( ) ; return $ this -> themeCache = Theme :: load ( $ themeName ) ; }
Returns the CMS theme this object belongs to .
23,566
public function getFilePath ( $ fileName = null ) { if ( $ fileName === null ) { $ fileName = $ this -> fileName ; } return $ this -> theme -> getPath ( ) . '/' . $ this -> getObjectTypeDirName ( ) . '/' . $ fileName ; }
Returns the full path to the template file corresponding to this object .
23,567
public function getTwigCacheKey ( ) { $ key = $ this -> getFilePath ( ) ; if ( $ event = $ this -> fireEvent ( 'cmsObject.getTwigCacheKey' , compact ( 'key' ) , true ) ) { $ key = $ event ; } return $ key ; }
Returns the key used by the Twig cache .
23,568
protected function throwHalcyonSaveException ( Exception $ ex ) { if ( $ ex instanceof \ October \ Rain \ Halcyon \ Exception \ MissingFileNameException ) { throw new ValidationException ( [ 'fileName' => Lang :: get ( 'cms::lang.cms_object.file_name_required' ) ] ) ; } elseif ( $ ex instanceof \ October \ Rain \ Halcy...
Converts an exception type thrown by Halcyon to a native CMS exception .
23,569
public function run ( $ action = null , $ params = [ ] ) { $ this -> action = $ action ; $ this -> params = $ params ; if ( ! $ this -> verifyCsrfToken ( ) ) { return Response :: make ( Lang :: get ( 'backend::lang.page.invalid_token.label' ) , 403 ) ; } if ( ! $ this -> verifyForceSecure ( ) ) { return Redirect :: sec...
Execute the controller action .
23,570
public function actionExists ( $ name , $ internal = false ) { if ( ! strlen ( $ name ) || substr ( $ name , 0 , 1 ) == '_' || ! $ this -> methodExists ( $ name ) ) { return false ; } foreach ( $ this -> hiddenActions as $ method ) { if ( strtolower ( $ name ) == strtolower ( $ method ) ) { return false ; } } $ ownMeth...
This method is used internally . Determines whether an action with the specified name exists . Action must be a class public method . Action name can not be prefixed with the underscore character .
23,571
public function actionUrl ( $ action = null , $ path = null ) { if ( $ action === null ) { $ action = $ this -> action ; } $ class = get_called_class ( ) ; $ uriPath = dirname ( dirname ( strtolower ( str_replace ( '\\' , '/' , $ class ) ) ) ) ; $ controllerName = strtolower ( class_basename ( $ class ) ) ; $ url = $ u...
Returns a URL for this controller and supplied action .
23,572
public function pageAction ( ) { if ( ! $ this -> action ) { return ; } $ this -> suppressView = true ; $ this -> execPageAction ( $ this -> action , $ this -> params ) ; }
Invokes the current controller action without rendering a view used by AJAX handler that may rely on the logic inside the action .
23,573
protected function execPageAction ( $ actionName , $ parameters ) { $ result = null ; if ( ! $ this -> actionExists ( $ actionName ) ) { if ( Config :: get ( 'app.debug' , false ) ) { throw new SystemException ( sprintf ( "Action %s is not found in the controller %s" , $ actionName , get_class ( $ this ) ) ) ; } else {...
This method is used internally . Invokes the controller action and loads the corresponding view .
23,574
protected function execAjaxHandlers ( ) { if ( $ handler = $ this -> getAjaxHandler ( ) ) { try { if ( ! preg_match ( '/^(?:\w+\:{2})?on[A-Z]{1}[\w+]*$/' , $ handler ) ) { throw new SystemException ( Lang :: get ( 'backend::lang.ajax_handler.invalid_name' , [ 'name' => $ handler ] ) ) ; } if ( $ partialList = trim ( Re...
This method is used internally . Invokes a controller event handler and loads the supplied partials .
23,575
protected function runAjaxHandler ( $ handler ) { if ( $ event = $ this -> fireSystemEvent ( 'backend.ajax.beforeRunHandler' , [ $ handler ] ) ) { return $ event ; } if ( strpos ( $ handler , '::' ) ) { list ( $ widgetName , $ handlerName ) = explode ( '::' , $ handler ) ; $ this -> pageAction ( ) ; if ( $ this -> fata...
Tries to find and run an AJAX handler in the page action . The method stops as soon as the handler is found .
23,576
protected function runAjaxHandlerForWidget ( $ widget , $ handler ) { $ this -> addViewPath ( $ widget -> getViewPaths ( ) ) ; $ result = call_user_func_array ( [ $ widget , $ handler ] , $ this -> params ) ; $ this -> vars = $ widget -> vars + $ this -> vars ; return $ result ; }
Specific code for executing an AJAX handler for a widget . This will append the widget view paths to the controller and merge the vars .
23,577
public function getId ( $ suffix = null ) { $ id = class_basename ( get_called_class ( ) ) . '-' . $ this -> action ; if ( $ suffix !== null ) { $ id .= '-' . $ suffix ; } return $ id ; }
Returns a unique ID for the controller and route . Useful in creating HTML markup .
23,578
public function onHideBackendHint ( ) { if ( ! $ name = post ( 'name' ) ) { throw new ApplicationException ( 'Missing a hint name.' ) ; } $ preferences = UserPreference :: forUser ( ) ; $ hiddenHints = $ preferences -> get ( 'backend::hints.hidden' , [ ] ) ; $ hiddenHints [ $ name ] = 1 ; $ preferences -> set ( 'backen...
Ajax handler to hide a backend hint once hidden the partial will no longer display for the user .
23,579
public function runDump ( Twig_Environment $ env , $ context ) { if ( ! $ env -> isDebug ( ) ) { return ; } $ result = '' ; $ count = func_num_args ( ) ; if ( $ count == 2 ) { $ this -> variablePrefix = true ; $ vars = [ ] ; foreach ( $ context as $ key => $ value ) { if ( ! $ value instanceof Twig_Template ) { $ vars ...
Processes the dump variables if none is supplied all the twig template variables are used
23,580
protected function makeTableHeader ( $ caption ) { if ( is_array ( $ caption ) ) { list ( $ caption , $ subcaption ) = $ caption ; } $ output = [ ] ; $ output [ ] = '<tr>' ; $ output [ ] = '<th colspan="3" colspan="100" style="' . $ this -> getHeaderCss ( ) . '">' ; $ output [ ] = $ caption ; if ( isset ( $ subcaption ...
Builds the HTML used for the table header .
23,581
protected function makeTableRow ( $ key , $ variable ) { $ this -> zebra = $ this -> zebra ? 0 : 1 ; $ css = $ this -> getDataCss ( $ variable ) ; $ output = [ ] ; $ output [ ] = '<tr>' ; $ output [ ] = '<td style="' . $ css . ';cursor:pointer" onclick="' . $ this -> evalToggleDumpOnClick ( ) . '">' . $ this -> evalKey...
Builds the HTML used for each table row .
23,582
protected function evalVarDump ( $ variable ) { $ dumper = new HtmlDumper ; $ cloner = new VarCloner ; $ output = '<div style="display:none">' ; $ output .= $ dumper -> dump ( $ cloner -> cloneVar ( $ variable ) , true ) ; $ output .= '</div>' ; return $ output ; }
Dumps a variable using HTML Dumper wrapped in a hidden DIV element .
23,583
protected function evalKeyLabel ( $ key ) { if ( $ this -> variablePrefix === true ) { $ output = '{{ <span>%s</span> }}' ; } elseif ( is_array ( $ this -> variablePrefix ) ) { $ prefix = implode ( '.' , $ this -> variablePrefix ) ; $ output = '{{ <span>' . $ prefix . '.%s</span> }}' ; } elseif ( $ this -> variablePref...
Returns a variable name as HTML friendly .
23,584
protected function evalObjLabel ( $ variable ) { $ class = get_class ( $ variable ) ; $ label = class_basename ( $ variable ) ; if ( $ variable instanceof ComponentBase ) { $ label = '<strong>Component</strong>' ; } elseif ( $ variable instanceof Collection ) { $ label = 'Collection(' . $ variable -> count ( ) . ')' ; ...
Evaluate an object type for label
23,585
protected function evalMethodDesc ( $ variable ) { $ parts = explode ( '|' , $ variable ) ; if ( count ( $ parts ) < 2 ) { return null ; } $ method = $ parts [ 1 ] ; return $ this -> commentMap [ $ method ] ?? null ; }
Evaluate an method type for description
23,586
protected function evalArrDesc ( $ variable ) { $ output = [ ] ; foreach ( $ variable as $ key => $ value ) { $ output [ ] = '<abbr title="' . e ( gettype ( $ value ) ) . '">' . $ key . '</abbr>' ; } return implode ( ', ' , $ output ) ; }
Evaluate an array type for description
23,587
protected function evalObjDesc ( $ variable ) { $ output = [ ] ; if ( $ variable instanceof ComponentBase ) { $ details = $ variable -> componentDetails ( ) ; $ output [ ] = '<abbr title="' . array_get ( $ details , 'description' ) . '">' ; $ output [ ] = array_get ( $ details , 'name' ) ; $ output [ ] = '</abbr>' ; } ...
Evaluate an object type for description
23,588
protected function objectToArray ( $ object ) { $ class = get_class ( $ object ) ; $ info = new \ ReflectionClass ( $ object ) ; $ this -> commentMap [ $ class ] = [ ] ; $ methods = [ ] ; foreach ( $ info -> getMethods ( ) as $ method ) { if ( ! $ method -> isPublic ( ) ) { continue ; } if ( $ method -> class != $ clas...
Returns a map of an object as an array containing methods and properties .
23,589
protected function evalDocBlock ( $ reflectionObj ) { $ comment = $ reflectionObj -> getDocComment ( ) ; $ comment = substr ( $ comment , 3 , - 2 ) ; $ parts = explode ( '@' , $ comment ) ; $ comment = array_shift ( $ parts ) ; $ comment = trim ( trim ( $ comment ) , '*' ) ; $ comment = implode ( ' ' , array_map ( 'tri...
Extracts the comment from a DocBlock
23,590
protected function getDataCss ( $ variable ) { $ css = [ 'padding' => '7px' , 'background-color' => $ this -> zebra ? '#D8D9DB' : '#FFF' , 'color' => '#405261' , ] ; $ type = gettype ( $ variable ) ; if ( $ type == 'NULL' ) { $ css [ 'color' ] = '#999' ; } return $ this -> arrayToCss ( $ css ) ; }
Get the CSS string for the output data
23,591
public function processHtml ( $ html ) { if ( ! is_string ( $ html ) ) { return $ html ; } $ mediaTags = $ this -> extractMediaTags ( $ html ) ; foreach ( $ mediaTags as $ tagInfo ) { $ pattern = preg_quote ( $ tagInfo [ 'declaration' ] ) ; $ generatedMarkup = $ this -> generateMediaTagMarkup ( $ tagInfo [ 'type' ] , $...
Replaces audio and video tags inserted by the Media Manager with players markup .
23,592
protected function findTemplate ( $ name ) { $ finder = App :: make ( 'view' ) -> getFinder ( ) ; if ( isset ( $ this -> cache [ $ name ] ) ) { return $ this -> cache [ $ name ] ; } if ( File :: isFile ( $ name ) ) { return $ this -> cache [ $ name ] = $ name ; } $ view = $ name ; if ( File :: extension ( $ view ) === ...
Gets the path of a view file
23,593
public function signin ( ) { $ this -> bodyClass = 'signin' ; try { if ( post ( 'postback' ) ) { return $ this -> signin_onSubmit ( ) ; } $ this -> bodyClass .= ' preload' ; } catch ( Exception $ ex ) { Flash :: error ( $ ex -> getMessage ( ) ) ; } }
Displays the log in page .
23,594
public function restore ( ) { try { if ( post ( 'postback' ) ) { return $ this -> restore_onSubmit ( ) ; } } catch ( Exception $ ex ) { Flash :: error ( $ ex -> getMessage ( ) ) ; } }
Request a password reset verification code .
23,595
public function reset ( $ userId = null , $ code = null ) { try { if ( post ( 'postback' ) ) { return $ this -> reset_onSubmit ( ) ; } if ( ! $ userId || ! $ code ) { throw new ApplicationException ( trans ( 'backend::lang.account.reset_error' ) ) ; } } catch ( Exception $ ex ) { Flash :: error ( $ ex -> getMessage ( )...
Reset backend user password using verification code .
23,596
protected function getAvailableColors ( ) { $ availableColors = $ this -> availableColors ; if ( is_array ( $ availableColors ) ) { return $ availableColors ; } elseif ( is_string ( $ availableColors ) && ! empty ( $ availableColors ) ) { if ( $ this -> model -> methodExists ( $ availableColors ) ) { return $ this -> a...
Gets the appropriate list of colors .
23,597
public function boot ( ) { if ( Config :: get ( 'database.connections.mysql.charset' ) === 'utf8mb4' ) { Schema :: defaultStringLength ( 191 ) ; } Paginator :: defaultSimpleView ( 'system::pagination.simple-default' ) ; PluginManager :: instance ( ) -> bootAll ( ) ; parent :: boot ( 'system' ) ; }
Bootstrap the module events .
23,598
protected function registerConsole ( ) { Event :: listen ( 'console.schedule' , function ( $ schedule ) { $ plugins = PluginManager :: instance ( ) -> getPlugins ( ) ; foreach ( $ plugins as $ plugin ) { if ( method_exists ( $ plugin , 'registerSchedule' ) ) { $ plugin -> registerSchedule ( $ schedule ) ; } } } ) ; Eve...
Register command line specifics
23,599
protected function registerMailer ( ) { MailManager :: instance ( ) -> registerCallback ( function ( $ manager ) { $ manager -> registerMailLayouts ( [ 'default' => 'system::mail.layout-default' , 'system' => 'system::mail.layout-system' , ] ) ; $ manager -> registerMailPartials ( [ 'header' => 'system::mail.partial-he...
Register mail templating and settings override .