idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
22,500 | public static function detectXss ( $ string ) { if ( null === $ string || ! \ is_string ( $ string ) || empty ( $ string ) ) { return false ; } $ orig = $ string ; $ string = urldecode ( $ string ) ; $ string = ( string ) preg_replace_callback ( '!(&#|\\\)[xX]([0-9a-fA-F]+);?!u' , function ( $ m ) { return \ chr ( hexd... | Determine if string potentially has a XSS attack . This simple function does not catch all XSS and it is likely to return false positives because of it tags all potentially dangerous HTML tags and attributes without looking into their content . |
22,501 | public function all ( ) { $ list = [ ] ; $ locator = $ this -> grav [ 'locator' ] ; $ iterator = $ locator -> getIterator ( 'themes://' ) ; foreach ( $ iterator as $ directory ) { if ( ! $ directory -> isDir ( ) || $ directory -> isDot ( ) ) { continue ; } $ theme = $ directory -> getFilename ( ) ; $ result = $ this ->... | Return list of all theme data with their blueprints . |
22,502 | public function get ( $ name ) { if ( ! $ name ) { throw new \ RuntimeException ( 'Theme name not provided.' ) ; } $ blueprints = new Blueprints ( 'themes://' ) ; $ blueprint = $ blueprints -> get ( "{$name}/blueprints" ) ; $ file = CompiledYamlFile :: instance ( "themes://{$name}/{$name}" . YAML_EXT ) ; if ( ! $ file ... | Get theme configuration or throw exception if it cannot be found . |
22,503 | public function load ( ) { $ grav = $ this -> grav ; $ config = $ this -> config ; $ name = $ this -> current ( ) ; $ locator = $ grav [ 'locator' ] ; $ file = $ locator ( 'theme://theme.php' ) ? : $ locator ( "theme://{$name}.php" ) ; $ inflector = $ grav [ 'inflector' ] ; if ( $ file ) { $ class = include $ file ; if... | Load current theme . |
22,504 | public function configure ( ) { $ name = $ this -> current ( ) ; $ config = $ this -> config ; $ this -> loadConfiguration ( $ name , $ config ) ; $ locator = $ this -> grav [ 'locator' ] ; $ registered = stream_get_wrappers ( ) ; $ schemes = $ config -> get ( "themes.{$name}.streams.schemes" , [ ] ) ; $ schemes += [ '... | Configure and prepare streams for current template . |
22,505 | protected function loadConfiguration ( $ name , Config $ config ) { $ themeConfig = CompiledYamlFile :: instance ( "themes://{$name}/{$name}" . YAML_EXT ) -> content ( ) ; $ config -> joinDefaults ( "themes.{$name}" , $ themeConfig ) ; } | Load theme configuration . |
22,506 | protected function loadLanguages ( Config $ config ) { $ locator = $ this -> grav [ 'locator' ] ; if ( $ config -> get ( 'system.languages.translations' , true ) ) { $ language_file = $ locator -> findResource ( 'theme://languages' . YAML_EXT ) ; if ( $ language_file ) { $ language = CompiledYamlFile :: instance ( $ la... | Load theme languages . |
22,507 | protected function autoloadTheme ( $ class ) { $ prefix = 'Grav\\Theme\\' ; if ( false !== strpos ( $ class , $ prefix ) ) { $ class = substr ( $ class , strlen ( $ prefix ) ) ; $ locator = $ this -> grav [ 'locator' ] ; $ path = strtolower ( $ class ) ; $ file = $ locator ( "themes://{$path}/theme.php" ) ? : $ locator... | Autoload theme classes for inheritance |
22,508 | public static function validate ( $ license = null ) { if ( ! is_string ( $ license ) ) { return false ; } return preg_match ( '#' . self :: $ regex . '#' , $ license ) ; } | Validates the License format |
22,509 | public static function getLicenseFile ( ) { if ( ! isset ( self :: $ file ) ) { $ path = Grav :: instance ( ) [ 'locator' ] -> findResource ( 'user-data://' ) . '/licenses.yaml' ; if ( ! file_exists ( $ path ) ) { touch ( $ path ) ; } self :: $ file = CompiledYamlFile :: instance ( $ path ) ; } return self :: $ file ; ... | Get s the License File object |
22,510 | public static function getComposerLocation ( ) { if ( ! \ function_exists ( 'shell_exec' ) || stripos ( PHP_OS , 'win' ) === 0 ) { return self :: DEFAULT_PATH ; } $ path = trim ( shell_exec ( 'command -v composer' ) ) ; if ( ! $ path || ! preg_match ( '/(composer|composer\.phar)$/' , $ path ) ) { $ path = self :: DEFAU... | Returns the location of composer . |
22,511 | public static function getComposerExecutor ( ) { $ executor = PHP_BINARY . ' ' ; $ composer = static :: getComposerLocation ( ) ; if ( $ composer !== static :: DEFAULT_PATH && is_executable ( $ composer ) ) { $ file = fopen ( $ composer , 'rb' ) ; $ firstLine = fgets ( $ file ) ; fclose ( $ file ) ; if ( ! preg_match (... | Return the composer executable file path |
22,512 | public static function instance ( array $ values = [ ] ) { if ( ! self :: $ instance ) { self :: $ instance = static :: load ( $ values ) ; } elseif ( $ values ) { $ instance = self :: $ instance ; foreach ( $ values as $ key => $ value ) { $ instance -> offsetSet ( $ key , $ value ) ; } } return self :: $ instance ; } | Return the Grav instance . Create it if it s not already instanced |
22,513 | public function setup ( string $ environment = null ) { if ( isset ( $ this -> initialized [ 'setup' ] ) ) { return $ this ; } $ this -> initialized [ 'setup' ] = true ; $ this -> measureTime ( '_setup' , 'Site Setup' , function ( ) use ( $ environment ) { if ( $ environment ) { Setup :: $ environment = $ environment ;... | Setup Grav instance using specific environment . |
22,514 | public function setLocale ( ) { if ( $ this [ 'language' ] -> enabled ( ) && $ this [ 'config' ] -> get ( 'system.languages.override_locale' ) ) { $ language = $ this [ 'language' ] -> getLanguage ( ) ; setlocale ( LC_ALL , \ strlen ( $ language ) < 3 ? ( $ language . '_' . strtoupper ( $ language ) ) : $ language ) ; ... | Set the system locale based on the language and configuration |
22,515 | public function redirect ( $ route , $ code = null ) { $ uri = $ this [ 'uri' ] ; $ regex = '/.*(\[(30[1-7])\])$/' ; preg_match ( $ regex , $ route , $ matches ) ; if ( $ matches ) { $ route = str_replace ( $ matches [ 1 ] , '' , $ matches [ 0 ] ) ; $ code = $ matches [ 2 ] ; } if ( $ code === null ) { $ code = $ this ... | Redirect browser to another location . |
22,516 | public function fireEvent ( $ eventName , Event $ event = null ) { $ events = $ this [ 'events' ] ; return $ events -> dispatch ( $ eventName , $ event ) ; } | Fires an event with optional parameters . |
22,517 | public function shutdown ( ) { if ( \ function_exists ( 'ignore_user_abort' ) ) { @ ignore_user_abort ( true ) ; } if ( isset ( $ this [ 'session' ] ) ) { $ this [ 'session' ] -> close ( ) ; } if ( $ this [ 'config' ] -> get ( 'system.debugger.shutdown.close_connection' , true ) ) { $ success = \ function_exists ( 'fas... | Set the final content length for the page and flush the buffer |
22,518 | public function measureTime ( string $ timerId , string $ timerTitle , callable $ callback ) { $ debugger = $ this [ 'debugger' ] ; $ debugger -> startTimer ( $ timerId , $ timerTitle ) ; $ result = $ callback ( ) ; $ debugger -> stopTimer ( $ timerId ) ; return $ result ; } | Measure how long it takes to do an action . |
22,519 | protected static function load ( array $ values ) { $ container = new static ( $ values ) ; $ container [ 'debugger' ] = new Debugger ( ) ; $ container [ 'grav' ] = function ( Container $ container ) { user_error ( 'Calling $grav[\'grav\'] or {{ grav.grav }} is deprecated since Grav 1.6, just use $grav or {{ grav }}' ,... | Initialize and return a Grav instance |
22,520 | protected function registerServices ( ) { foreach ( self :: $ diMap as $ serviceKey => $ serviceClass ) { if ( \ is_int ( $ serviceKey ) ) { $ this -> register ( new $ serviceClass ) ; } else { $ this [ $ serviceKey ] = function ( $ c ) use ( $ serviceClass ) { return new $ serviceClass ( $ c ) ; } ; } } } | Register all services Services are defined in the diMap . They can either only the class of a Service Provider or a pair of serviceKey = > serviceClass that gets directly mapped into the container . |
22,521 | public function fallbackUrl ( $ path ) { $ this -> fireEvent ( 'onPageFallBackUrl' ) ; $ uri = $ this [ 'uri' ] ; $ config = $ this [ 'config' ] ; $ uri_extension = strtolower ( $ uri -> extension ( ) ) ; $ fallback_types = $ config -> get ( 'system.media.allowed_fallback_types' , null ) ; $ supported_types = $ config ... | This attempts to find media other files and download them |
22,522 | protected function createObject ( array $ data = [ ] ) { if ( $ this -> withDefaults && empty ( $ data ) && \ is_callable ( $ this -> callable ) ) { $ blueprints = $ this -> callable ; $ data = $ blueprints ( ) -> getDefaults ( ) ; } $ this -> object = new Config ( $ data , $ this -> callable ) ; } | Create configuration object . |
22,523 | protected function finalizeObject ( ) { $ this -> object -> checksum ( $ this -> checksum ( ) ) ; $ this -> object -> timestamp ( $ this -> timestamp ( ) ) ; } | Finalize configuration object . |
22,524 | public function init ( ) { if ( $ this -> autoStart && ! $ this -> isStarted ( ) ) { $ this -> start ( ) ; $ this -> autoStart = false ; } } | Initialize session . |
22,525 | public function getFlashObject ( $ name ) { $ serialized = $ this -> __get ( $ name ) ; $ object = \ is_string ( $ serialized ) ? unserialize ( $ serialized , [ 'allowed_classes' => true ] ) : $ serialized ; $ this -> __unset ( $ name ) ; if ( $ name === 'files-upload' ) { $ grav = Grav :: instance ( ) ; if ( null === ... | Return object and remove it from session . |
22,526 | public function setFlashCookieObject ( $ name , $ object , $ time = 60 ) { setcookie ( $ name , json_encode ( $ object ) , time ( ) + $ time , '/' ) ; return $ this ; } | Store something in cookie temporarily . |
22,527 | public function getFlashCookieObject ( $ name ) { if ( isset ( $ _COOKIE [ $ name ] ) ) { $ object = json_decode ( $ _COOKIE [ $ name ] ) ; setcookie ( $ name , '' , time ( ) - 3600 , '/' ) ; return $ object ; } return null ; } | Return object and remove it from the cookie . |
22,528 | public function init ( ) { $ grav = Grav :: instance ( ) ; $ config = $ grav [ 'config' ] ; $ asset_config = ( array ) $ config -> get ( 'system.assets' ) ; $ locator = $ grav [ 'locator' ] ; $ this -> assets_dir = $ locator -> findResource ( 'asset://' ) . DS ; $ this -> assets_url = $ locator -> findResource ( 'asset... | Initialization called in the Grav lifecycle to initialize the Assets with appropriate configuration |
22,529 | public function addCss ( $ asset ) { return $ this -> addType ( Assets :: CSS_COLLECTION , Assets :: CSS_TYPE , $ asset , $ this -> unifyLegacyArguments ( \ func_get_args ( ) , Assets :: CSS_TYPE ) ) ; } | Add a CSS asset or a collection of assets . |
22,530 | public function addInlineCss ( $ asset ) { return $ this -> addType ( Assets :: CSS_COLLECTION , Assets :: INLINE_CSS_TYPE , $ asset , $ this -> unifyLegacyArguments ( \ func_get_args ( ) , Assets :: INLINE_CSS_TYPE ) ) ; } | Add an Inline CSS asset or a collection of assets . |
22,531 | public function addJs ( $ asset ) { return $ this -> addType ( Assets :: JS_COLLECTION , Assets :: JS_TYPE , $ asset , $ this -> unifyLegacyArguments ( \ func_get_args ( ) , Assets :: JS_TYPE ) ) ; } | Add a JS asset or a collection of assets . |
22,532 | public function addInlineJs ( $ asset ) { return $ this -> addType ( Assets :: JS_COLLECTION , Assets :: INLINE_JS_TYPE , $ asset , $ this -> unifyLegacyArguments ( \ func_get_args ( ) , Assets :: INLINE_JS_TYPE ) ) ; } | Add an Inline JS asset or a collection of assets . |
22,533 | public function getFlash ( ) : FormFlash { if ( null === $ this -> flash ) { $ grav = Grav :: instance ( ) ; $ id = null ; $ user = $ grav [ 'user' ] ?? null ; if ( isset ( $ user ) ) { $ rememberState = $ this -> getBlueprint ( ) -> get ( 'form/remember_state' ) ; if ( $ rememberState === 'user' ) { $ id = $ user -> u... | Get form flash object . |
22,534 | protected function parseRequest ( ServerRequestInterface $ request ) : array { $ method = $ request -> getMethod ( ) ; if ( ! \ in_array ( $ method , [ 'PUT' , 'POST' , 'PATCH' ] ) ) { throw new \ RuntimeException ( sprintf ( 'FlexForm: Bad HTTP method %s' , $ method ) ) ; } $ body = $ request -> getParsedBody ( ) ; $ ... | Parse PSR - 7 ServerRequest into data and files . |
22,535 | protected function validateUploads ( array $ files ) : void { foreach ( $ files as $ file ) { if ( null === $ file ) { continue ; } if ( $ file instanceof UploadedFileInterface ) { $ this -> validateUpload ( $ file ) ; } else { $ this -> validateUploads ( $ file ) ; } } } | Validate all uploaded files . |
22,536 | protected function validateUpload ( UploadedFileInterface $ file ) : void { $ filename = $ file -> getClientFilename ( ) ; if ( ! Utils :: checkFilename ( $ filename ) ) { $ grav = Grav :: instance ( ) ; throw new \ RuntimeException ( sprintf ( $ grav [ 'language' ] -> translate ( 'PLUGIN_FORM.FILEUPLOAD_UNABLE_TO_UPLO... | Validate uploaded file . |
22,537 | protected function decodeData ( $ data ) : array { if ( ! \ is_array ( $ data ) ) { return [ ] ; } if ( isset ( $ data [ '_json' ] ) ) { $ data = array_replace_recursive ( $ data , $ this -> jsonDecode ( $ data [ '_json' ] ) ) ; unset ( $ data [ '_json' ] ) ; } return $ data ; } | Decode POST data |
22,538 | protected function jsonDecode ( array $ data ) : array { foreach ( $ data as $ key => & $ value ) { if ( \ is_array ( $ value ) ) { $ value = $ this -> jsonDecode ( $ value ) ; } elseif ( $ value === '' ) { unset ( $ data [ $ key ] ) ; } else { $ value = json_decode ( $ value , true ) ; if ( $ value === null && json_la... | Recursively JSON decode POST data . |
22,539 | public static function saveConfig ( $ theme_name ) { if ( ! $ theme_name ) { return false ; } $ grav = Grav :: instance ( ) ; $ locator = $ grav [ 'locator' ] ; $ filename = 'config://themes/' . $ theme_name . '.yaml' ; $ file = YamlFile :: instance ( $ locator -> findResource ( $ filename , true , true ) ) ; $ content... | Persists to disk the theme parameters currently stored in the Grav Config object |
22,540 | protected function mergeConfig ( PageInterface $ page , $ deep = 'merge' , $ params = [ ] , $ type = 'themes' ) { return parent :: mergeConfig ( $ page , $ deep , $ params , $ type ) ; } | Override the mergeConfig method to work for themes |
22,541 | public function init ( \ SplFileInfo $ file , $ extension = null ) { $ config = Grav :: instance ( ) [ 'config' ] ; if ( empty ( $ extension ) ) { $ this -> extension ( '.' . $ file -> getExtension ( ) ) ; } else { $ this -> extension ( $ extension ) ; } $ language = trim ( basename ( $ this -> extension ( ) , 'md' ) ,... | Initializes the page instance variables based on a file |
22,542 | public function translatedLanguages ( $ onlyPublished = false ) { $ filename = substr ( $ this -> name , 0 , - ( strlen ( $ this -> extension ( ) ) ) ) ; $ config = Grav :: instance ( ) [ 'config' ] ; $ languages = $ config -> get ( 'system.languages.supported' , [ ] ) ; $ translatedLanguages = [ ] ; foreach ( $ langua... | Return an array with the routes of other translated languages |
22,543 | public function untranslatedLanguages ( $ includeUnpublished = false ) { $ filename = substr ( $ this -> name , 0 , - strlen ( $ this -> extension ( ) ) ) ; $ config = Grav :: instance ( ) [ 'config' ] ; $ languages = $ config -> get ( 'system.languages.supported' , [ ] ) ; $ untranslatedLanguages = [ ] ; foreach ( $ l... | Return an array listing untranslated languages available |
22,544 | public function raw ( $ var = null ) { $ file = $ this -> file ( ) ; if ( $ var ) { if ( $ file ) { $ file -> raw ( $ var ) ; } $ this -> modified = time ( ) ; $ this -> id ( $ this -> modified ( ) . md5 ( $ this -> filePath ( ) ) ) ; $ this -> header = null ; $ this -> content = null ; $ this -> summary = null ; } ret... | Gets and Sets the raw data |
22,545 | public function frontmatter ( $ var = null ) { if ( $ var ) { $ this -> frontmatter = ( string ) $ var ; $ file = $ this -> file ( ) ; if ( $ file ) { $ file -> frontmatter ( ( string ) $ var ) ; } $ this -> id ( time ( ) . md5 ( $ this -> filePath ( ) ) ) ; } if ( ! $ this -> frontmatter ) { $ this -> header ( ) ; } r... | Gets and Sets the page frontmatter |
22,546 | public function summary ( $ size = null , $ textOnly = false ) { $ config = ( array ) Grav :: instance ( ) [ 'config' ] -> get ( 'site.summary' ) ; if ( isset ( $ this -> header -> summary ) ) { $ config = array_merge ( $ config , $ this -> header -> summary ) ; } if ( ! $ config [ 'enabled' ] ) { return $ this -> cont... | Get the summary . |
22,547 | public function getContentMeta ( $ name = null ) { if ( $ name ) { if ( isset ( $ this -> content_meta [ $ name ] ) ) { return $ this -> content_meta [ $ name ] ; } return null ; } return $ this -> content_meta ; } | Return the whole contentMeta array as it currently stands |
22,548 | protected function processMarkdown ( ) { $ config = Grav :: instance ( ) [ 'config' ] ; $ defaults = ( array ) $ config -> get ( 'system.pages.markdown' ) ; if ( isset ( $ this -> header ( ) -> markdown ) ) { $ defaults = array_merge ( $ defaults , $ this -> header ( ) -> markdown ) ; } if ( ! isset ( $ defaults [ 'ext... | Process the Markdown content . Uses Parsedown or Parsedown Extra depending on configuration |
22,549 | private function processTwig ( ) { $ twig = Grav :: instance ( ) [ 'twig' ] ; $ this -> content = $ twig -> processPage ( $ this , $ this -> content ) ; } | Process the Twig page content . |
22,550 | public function cachePageContent ( ) { $ cache = Grav :: instance ( ) [ 'cache' ] ; $ cache_id = md5 ( 'page' . $ this -> id ( ) ) ; $ cache -> save ( $ cache_id , [ 'content' => $ this -> content , 'content_meta' => $ this -> content_meta ] ) ; } | Fires the onPageContentProcessed event and caches the page content using a unique ID for the page |
22,551 | public function save ( $ reorder = true ) { $ this -> doRelocation ( ) ; $ file = $ this -> file ( ) ; if ( $ file ) { $ file -> filename ( $ this -> filePath ( ) ) ; $ file -> header ( ( array ) $ this -> header ( ) ) ; $ file -> markdown ( $ this -> raw_content ) ; $ file -> save ( ) ; } if ( $ reorder && is_array ( ... | Save page if there s a file assigned to it . |
22,552 | public function move ( PageInterface $ parent ) { if ( ! $ this -> _original ) { $ clone = clone $ this ; $ this -> _original = $ clone ; } $ this -> _action = 'move' ; if ( $ this -> route ( ) === $ parent -> route ( ) ) { throw new \ RuntimeException ( 'Failed: Cannot set page parent to self' ) ; } if ( Utils :: star... | Prepare move page to new location . Moves also everything that s under the current page . |
22,553 | public function blueprints ( ) { $ grav = Grav :: instance ( ) ; $ pages = $ grav [ 'pages' ] ; $ blueprint = $ pages -> blueprints ( $ this -> blueprintName ( ) ) ; $ fields = $ blueprint -> fields ( ) ; $ edit_mode = isset ( $ grav [ 'admin' ] ) ? $ grav [ 'config' ] -> get ( 'plugins.admin.edit_mode' ) : null ; if (... | Get blueprints for the page . |
22,554 | public function filter ( ) { $ blueprints = $ this -> blueprints ( ) ; $ values = $ blueprints -> filter ( $ this -> toArray ( ) ) ; if ( $ values && isset ( $ values [ 'header' ] ) ) { $ this -> header ( $ values [ 'header' ] ) ; } } | Filter page header from illegal contents . |
22,555 | public function forms ( ) { if ( null === $ this -> forms ) { $ header = $ this -> header ( ) ; $ grav = Grav :: instance ( ) ; $ grav -> fireEvent ( 'onFormPageHeaderProcessed' , new Event ( [ 'page' => $ this , 'header' => $ header ] ) ) ; $ rules = $ header -> rules ?? null ; if ( ! \ is_array ( $ rules ) ) { $ rule... | Returns normalized list of name = > form pairs . |
22,556 | public function getMediaOrder ( ) { $ header = $ this -> header ( ) ; return isset ( $ header -> media_order ) ? array_map ( 'trim' , explode ( ',' , ( string ) $ header -> media_order ) ) : [ ] ; } | Get display order for the associated media . |
22,557 | public function template ( $ var = null ) { if ( $ var !== null ) { $ this -> template = $ var ; } if ( empty ( $ this -> template ) ) { $ this -> template = ( $ this -> modular ( ) ? 'modular/' : '' ) . str_replace ( $ this -> extension ( ) , '' , $ this -> name ( ) ) ; } return $ this -> template ; } | Gets and sets the template field . This is used to find the correct Twig template file to render . If no field is set it will return the name without the . md extension |
22,558 | public function extension ( $ var = null ) { if ( $ var !== null ) { $ this -> extension = $ var ; } if ( empty ( $ this -> extension ) ) { $ this -> extension = '.' . pathinfo ( $ this -> name ( ) , PATHINFO_EXTENSION ) ; } return $ this -> extension ; } | Gets and sets the extension field . |
22,559 | public function urlExtension ( ) { if ( $ this -> home ( ) ) { return '' ; } if ( null === $ this -> url_extension ) { $ this -> url_extension = Grav :: instance ( ) [ 'config' ] -> get ( 'system.pages.append_url_extension' , '' ) ; } return $ this -> url_extension ; } | Returns the page extension got from the page url_extension config and falls back to the system config system . pages . append_url_extension . |
22,560 | public function expires ( $ var = null ) { if ( $ var !== null ) { $ this -> expires = $ var ; } return $ this -> expires ?? Grav :: instance ( ) [ 'config' ] -> get ( 'system.pages.expires' ) ; } | Gets and sets the expires field . If not set will return the default |
22,561 | public function visible ( $ var = null ) { if ( $ var !== null ) { $ this -> visible = ( bool ) $ var ; } if ( $ this -> visible === null ) { if ( preg_match ( PAGE_ORDER_PREFIX_REGEX , $ this -> folder ) ) { $ this -> visible = true ; } else { $ this -> visible = false ; } } return $ this -> visible ; } | Gets and Sets whether or not this Page is visible for navigation |
22,562 | public function published ( $ var = null ) { if ( $ var !== null ) { $ this -> published = ( bool ) $ var ; } if ( $ this -> published === false ) { $ this -> visible = false ; } return $ this -> published ; } | Gets and Sets whether or not this Page is considered published |
22,563 | public function publishDate ( $ var = null ) { if ( $ var !== null ) { $ this -> publish_date = Utils :: date2timestamp ( $ var , $ this -> dateformat ) ; } return $ this -> publish_date ; } | Gets and Sets the Page publish date |
22,564 | public function unpublishDate ( $ var = null ) { if ( $ var !== null ) { $ this -> unpublish_date = Utils :: date2timestamp ( $ var , $ this -> dateformat ) ; } return $ this -> unpublish_date ; } | Gets and Sets the Page unpublish date |
22,565 | public function metadata ( $ var = null ) { if ( $ var !== null ) { $ this -> metadata = ( array ) $ var ; } if ( null === $ this -> metadata ) { $ header_tag_http_equivs = [ 'content-type' , 'default-style' , 'refresh' , 'x-ua-compatible' ] ; $ this -> metadata = [ ] ; $ metadata = [ ] ; $ metadata [ 'generator' ] = '... | Function to merge page metadata tags and build an array of Metadata objects that can then be rendered in the page . |
22,566 | public function slug ( $ var = null ) { if ( $ var !== null && $ var !== '' ) { $ this -> slug = $ var ; } if ( empty ( $ this -> slug ) ) { $ this -> slug = $ this -> adjustRouteCase ( preg_replace ( PAGE_ORDER_PREFIX_REGEX , '' , $ this -> folder ) ) ? : null ; } return $ this -> slug ; } | Gets and Sets the slug for the Page . The slug is used in the URL routing . If not set it uses the parent folder from the path |
22,567 | public function url ( $ include_host = false , $ canonical = false , $ include_base = true , $ raw_route = false ) { if ( isset ( $ this -> external_url ) ) { return $ this -> external_url ; } $ grav = Grav :: instance ( ) ; $ pages = $ grav [ 'pages' ] ; $ config = $ grav [ 'config' ] ; $ route = $ include_base ? $ pa... | Gets the url for the Page . |
22,568 | public function route ( $ var = null ) { if ( $ var !== null ) { $ this -> route = $ var ; } if ( empty ( $ this -> route ) ) { $ baseRoute = null ; $ parent = $ this -> parent ( ) ; if ( isset ( $ parent ) ) { if ( $ this -> hide_home_route && $ parent -> route ( ) === $ this -> home_route ) { $ baseRoute = '' ; } els... | Gets the route for the page based on the route headers if available else from the parents route and the current Page s slug . |
22,569 | public function rawRoute ( $ var = null ) { if ( $ var !== null ) { $ this -> raw_route = $ var ; } if ( empty ( $ this -> raw_route ) ) { $ parent = $ this -> parent ( ) ; $ baseRoute = $ parent ? ( string ) $ parent -> rawRoute ( ) : null ; $ slug = $ this -> adjustRouteCase ( preg_replace ( PAGE_ORDER_PREFIX_REGEX ,... | Gets and Sets the page raw route |
22,570 | public function routeAliases ( $ var = null ) { if ( $ var !== null ) { $ this -> routes [ 'aliases' ] = ( array ) $ var ; } if ( ! empty ( $ this -> routes ) && isset ( $ this -> routes [ 'aliases' ] ) ) { return $ this -> routes [ 'aliases' ] ; } return [ ] ; } | Gets the route aliases for the page based on page headers . |
22,571 | public function routeCanonical ( $ var = null ) { if ( $ var !== null ) { $ this -> routes [ 'canonical' ] = $ var ; } if ( ! empty ( $ this -> routes ) && isset ( $ this -> routes [ 'canonical' ] ) ) { return $ this -> routes [ 'canonical' ] ; } return $ this -> route ( ) ; } | Gets the canonical route for this page if its set . If provided it will use that value else if it s true it will use the default route . |
22,572 | public function id ( $ var = null ) { if ( $ var !== null ) { $ active_lang = Grav :: instance ( ) [ 'language' ] -> getLanguage ( ) ? : '' ; $ id = $ active_lang . $ var ; $ this -> id = $ id ; } return $ this -> id ; } | Gets and sets the identifier for this Page object . |
22,573 | public function eTag ( $ var = null ) { if ( $ var !== null ) { $ this -> etag = $ var ; } if ( ! isset ( $ this -> etag ) ) { $ this -> etag = ( bool ) Grav :: instance ( ) [ 'config' ] -> get ( 'system.pages.etag' ) ; } return $ this -> etag ; } | Gets and sets the option to show the etag header for the page . |
22,574 | public function lastModified ( $ var = null ) { if ( $ var !== null ) { $ this -> last_modified = $ var ; } if ( ! isset ( $ this -> last_modified ) ) { $ this -> last_modified = ( bool ) Grav :: instance ( ) [ 'config' ] -> get ( 'system.pages.last_modified' ) ; } return $ this -> last_modified ; } | Gets and sets the option to show the last_modified header for the page . |
22,575 | public function filePath ( $ var = null ) { if ( $ var !== null ) { $ this -> name = basename ( $ var ) ; $ this -> folder = basename ( dirname ( $ var ) ) ; $ this -> path = dirname ( $ var , 2 ) ; } return $ this -> path . '/' . $ this -> folder . '/' . ( $ this -> name ? : '' ) ; } | Gets and sets the path to the . md file for this Page object . |
22,576 | public function path ( $ var = null ) { if ( $ var !== null ) { $ this -> folder = basename ( $ var ) ; $ this -> path = dirname ( $ var ) ; } return $ this -> path ? $ this -> path . '/' . $ this -> folder : null ; } | Gets and sets the path to the folder where the . md for this Page object resides . This is equivalent to the filePath but without the filename . |
22,577 | public function date ( $ var = null ) { if ( $ var !== null ) { $ this -> date = Utils :: date2timestamp ( $ var , $ this -> dateformat ) ; } if ( ! $ this -> date ) { $ this -> date = $ this -> modified ; } return $ this -> date ; } | Gets and sets the date for this Page object . This is typically passed in via the page headers |
22,578 | public function orderDir ( $ var = null ) { if ( $ var !== null ) { $ this -> order_dir = $ var ; } if ( empty ( $ this -> order_dir ) ) { $ this -> order_dir = 'asc' ; } return $ this -> order_dir ; } | Gets and sets the order by which any sub - pages should be sorted . |
22,579 | public function maxCount ( $ var = null ) { if ( $ var !== null ) { $ this -> max_count = ( int ) $ var ; } if ( empty ( $ this -> max_count ) ) { $ config = Grav :: instance ( ) [ 'config' ] ; $ this -> max_count = ( int ) $ config -> get ( 'system.pages.list.count' ) ; } return $ this -> max_count ; } | Gets and sets the maxCount field which describes how many sub - pages should be displayed if the sub_pages header property is set for this page object . |
22,580 | public function taxonomy ( $ var = null ) { if ( $ var !== null ) { array_walk ( $ var , function ( & $ value ) { $ value = ( array ) $ value ; } ) ; array_walk_recursive ( $ var , function ( & $ value ) { $ value = ( string ) $ value ; } ) ; $ this -> taxonomy = $ var ; } return $ this -> taxonomy ; } | Gets and sets the taxonomy array which defines which taxonomies this page identifies itself with . |
22,581 | public function modularTwig ( $ var = null ) { if ( $ var !== null ) { $ this -> modular_twig = ( bool ) $ var ; if ( $ var ) { $ this -> visible ( false ) ; if ( empty ( $ this -> header -> routable ) ) { $ this -> routable = false ; } } } return $ this -> modular_twig ; } | Gets and sets the modular_twig var that helps identify this page as a modular child page that will need twig processing handled differently from a regular page . |
22,582 | public function parent ( PageInterface $ var = null ) { if ( $ var ) { $ this -> parent = $ var -> path ( ) ; return $ var ; } $ pages = Grav :: instance ( ) [ 'pages' ] ; return $ pages -> get ( $ this -> parent ) ; } | Gets and Sets the parent object for this page |
22,583 | public function topParent ( ) { $ topParent = $ this -> parent ( ) ; if ( ! $ topParent ) { return null ; } while ( true ) { $ theParent = $ topParent -> parent ( ) ; if ( $ theParent !== null && $ theParent -> parent ( ) !== null ) { $ topParent = $ theParent ; } else { break ; } } return $ topParent ; } | Gets the top parent object for this page |
22,584 | public function isFirst ( ) { $ parent = $ this -> parent ( ) ; $ collection = $ parent ? $ parent -> collection ( 'content' , false ) : null ; if ( $ collection instanceof Collection ) { return $ collection -> isFirst ( $ this -> path ( ) ) ; } return true ; } | Check to see if this item is the first in an array of sub - pages . |
22,585 | public function currentPosition ( ) { $ parent = $ this -> parent ( ) ; $ collection = $ parent ? $ parent -> collection ( 'content' , false ) : null ; if ( $ collection instanceof Collection ) { return $ collection -> currentPosition ( $ this -> path ( ) ) ; } return 1 ; } | Returns the item in the current position . |
22,586 | public function active ( ) { $ uri_path = rtrim ( urldecode ( Grav :: instance ( ) [ 'uri' ] -> path ( ) ) , '/' ) ? : '/' ; $ routes = Grav :: instance ( ) [ 'pages' ] -> routes ( ) ; return isset ( $ routes [ $ uri_path ] ) && $ routes [ $ uri_path ] === $ this -> path ( ) ; } | Returns whether or not this page is the currently active page requested via the URL . |
22,587 | public function activeChild ( ) { $ uri = Grav :: instance ( ) [ 'uri' ] ; $ pages = Grav :: instance ( ) [ 'pages' ] ; $ uri_path = rtrim ( urldecode ( $ uri -> path ( ) ) , '/' ) ; $ routes = Grav :: instance ( ) [ 'pages' ] -> routes ( ) ; if ( isset ( $ routes [ $ uri_path ] ) ) { $ child_page = $ pages -> dispatch... | Returns whether or not this URI s URL contains the URL of the active page . Or in other words is this page s URL in the current URL |
22,588 | public function home ( ) { $ home = Grav :: instance ( ) [ 'config' ] -> get ( 'system.home.alias' ) ; return $ this -> route ( ) === $ home || $ this -> rawRoute ( ) === $ home ; } | Returns whether or not this page is the currently configured home page . |
22,589 | public function ancestor ( $ lookup = null ) { $ pages = Grav :: instance ( ) [ 'pages' ] ; return $ pages -> ancestor ( $ this -> route , $ lookup ) ; } | Helper method to return an ancestor page . |
22,590 | public function inherited ( $ field ) { list ( $ inherited , $ currentParams ) = $ this -> getInheritedParams ( $ field ) ; $ this -> modifyHeader ( $ field , $ currentParams ) ; return $ inherited ; } | Helper method to return an ancestor page to inherit from . The current page object is returned . |
22,591 | public function find ( $ url , $ all = false ) { $ pages = Grav :: instance ( ) [ 'pages' ] ; return $ pages -> find ( $ url , $ all ) ; } | Helper method to return a page . |
22,592 | protected function cleanPath ( $ path ) { $ lastchunk = strrchr ( $ path , DS ) ; if ( strpos ( $ lastchunk , ':' ) !== false ) { $ path = str_replace ( $ lastchunk , '' , $ path ) ; } return $ path ; } | Cleans the path . |
22,593 | protected function doReorder ( $ new_order ) { if ( ! $ this -> _original ) { return ; } $ pages = Grav :: instance ( ) [ 'pages' ] ; $ pages -> init ( ) ; $ this -> _original -> path ( $ this -> path ( ) ) ; $ parent = $ this -> parent ( ) ; $ siblings = $ parent ? $ parent -> children ( ) : null ; if ( $ siblings ) {... | Reorders all siblings according to a defined order |
22,594 | protected function doRelocation ( ) { if ( ! $ this -> _original ) { return ; } if ( is_dir ( $ this -> _original -> path ( ) ) ) { if ( $ this -> _action === 'move' ) { Folder :: move ( $ this -> _original -> path ( ) , $ this -> path ( ) ) ; } elseif ( $ this -> _action === 'copy' ) { Folder :: copy ( $ this -> _orig... | Moves or copies the page in filesystem . |
22,595 | public function validate ( array $ data ) { try { $ messages = $ this -> validateArray ( $ data , $ this -> nested ) ; } catch ( \ RuntimeException $ e ) { throw ( new ValidationException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ) -> setMessages ( ) ; } if ( ! empty ( $ messages ) ) { throw ( new Validation... | Validate data against blueprints . |
22,596 | protected function init ( $ namespace = '' , $ defaultLifetime = null ) { $ this -> namespace = ( string ) $ namespace ; $ this -> defaultLifetime = $ this -> convertTtl ( $ defaultLifetime ) ; $ this -> miss = new \ stdClass ; } | Always call from constructor . |
22,597 | public function get ( $ type ) { if ( ! isset ( $ this -> instances [ $ type ] ) ) { $ this -> instances [ $ type ] = $ this -> loadFile ( $ type ) ; } return $ this -> instances [ $ type ] ; } | Get blueprint . |
22,598 | public function types ( ) { if ( $ this -> types === null ) { $ this -> types = [ ] ; $ grav = Grav :: instance ( ) ; $ locator = $ grav [ 'locator' ] ; if ( $ locator -> isStream ( $ this -> search ) ) { $ iterator = $ locator -> getIterator ( $ this -> search ) ; } else { $ iterator = new \ DirectoryIterator ( $ this... | Get all available blueprint types . |
22,599 | protected function loadFile ( $ name ) { $ blueprint = new Blueprint ( $ name ) ; if ( \ is_array ( $ this -> search ) || \ is_object ( $ this -> search ) ) { $ blueprint -> setOverrides ( $ this -> search ) ; $ blueprint -> setContext ( 'blueprints://pages' ) ; } else { $ blueprint -> setContext ( $ this -> search ) ;... | Load blueprint file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.