idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
48,000 | protected function getScandir ( $ path ) { $ files = array ( ) ; ! isset ( $ this -> dirsCache [ $ path ] ) && $ this -> cacheDir ( $ path ) ; foreach ( $ this -> dirsCache [ $ path ] as $ p ) { if ( ( $ stat = $ this -> stat ( $ p ) ) && empty ( $ stat [ 'hidden' ] ) ) { $ files [ ] = $ stat ; } } return $ files ; } | Return required dir s files info . If onlyMimes is set - return only dirs and files of required mimes |
48,001 | protected function gettmb ( $ path , $ stat ) { if ( $ this -> tmbURL && $ this -> tmbPath ) { if ( strpos ( $ path , $ this -> tmbPath ) === 0 ) { return basename ( $ path ) ; } $ name = $ this -> tmbname ( $ stat ) ; if ( file_exists ( $ this -> tmbPath . DIRECTORY_SEPARATOR . $ name ) ) { return $ name ; } } return false ; } | Return thumnbnail name if exists |
48,002 | protected function rmTmb ( $ stat ) { if ( $ stat [ 'mime' ] === 'directory' ) { foreach ( $ this -> scandirCE ( $ this -> decode ( $ stat [ 'hash' ] ) ) as $ p ) { @ set_time_limit ( 30 ) ; $ name = $ this -> basenameCE ( $ p ) ; $ name != '.' && $ name != '..' && $ this -> rmTmb ( $ this -> stat ( $ p ) ) ; } } else if ( ! empty ( $ stat [ 'tmb' ] ) && $ stat [ 'tmb' ] != "1" ) { $ tmb = $ this -> tmbPath . DIRECTORY_SEPARATOR . $ stat [ 'tmb' ] ; file_exists ( $ tmb ) && @ unlink ( $ tmb ) ; clearstatcache ( ) ; } } | Remove thumbnail also remove recursively if stat is directory |
48,003 | protected function gdImageCreate ( $ path , $ mime ) { switch ( $ mime ) { case 'image/jpeg' : return imagecreatefromjpeg ( $ path ) ; case 'image/png' : return imagecreatefrompng ( $ path ) ; case 'image/gif' : return imagecreatefromgif ( $ path ) ; case 'image/xbm' : return imagecreatefromxbm ( $ path ) ; } return false ; } | Create an gd image according to the specified mime type |
48,004 | protected function gdImage ( $ image , $ filename , $ destformat , $ mime ) { if ( $ destformat == 'jpg' || ( $ destformat == null && $ mime == 'image/jpeg' ) ) { return imagejpeg ( $ image , $ filename , 100 ) ; } if ( $ destformat == 'gif' || ( $ destformat == null && $ mime == 'image/gif' ) ) { return imagegif ( $ image , $ filename , 7 ) ; } return imagepng ( $ image , $ filename , 7 ) ; } | Output gd image to file |
48,005 | protected function gdImageBackground ( $ image , $ bgcolor ) { if ( $ bgcolor == 'transparent' ) { imagesavealpha ( $ image , true ) ; $ bgcolor1 = imagecolorallocatealpha ( $ image , 255 , 255 , 255 , 127 ) ; } else { list ( $ r , $ g , $ b ) = sscanf ( $ bgcolor , "#%02x%02x%02x" ) ; $ bgcolor1 = imagecolorallocate ( $ image , $ r , $ g , $ b ) ; } imagefill ( $ image , 0 , 0 , $ bgcolor1 ) ; } | Assign the proper background to a gd image |
48,006 | protected function stripos ( $ haystack , $ needle , $ offset = 0 ) { if ( function_exists ( 'mb_stripos' ) ) { return mb_stripos ( $ haystack , $ needle , $ offset ) ; } else if ( function_exists ( 'mb_strtolower' ) && function_exists ( 'mb_strpos' ) ) { return mb_strpos ( mb_strtolower ( $ haystack ) , mb_strtolower ( $ needle ) , $ offset ) ; } return stripos ( $ haystack , $ needle , $ offset ) ; } | Find position of first occurrence of string in a string with multibyte support |
48,007 | public function rmdirRecursive ( $ dir ) { if ( is_dir ( $ dir ) ) { foreach ( array_diff ( scandir ( $ dir ) , array ( '.' , '..' ) ) as $ file ) { @ set_time_limit ( 30 ) ; $ path = $ dir . '/' . $ file ; ( is_dir ( $ path ) ) ? $ this -> rmdirRecursive ( $ path ) : @ unlink ( $ path ) ; } return @ rmdir ( $ dir ) ; } else if ( is_file ( $ dir ) ) { return @ unlink ( $ dir ) ; } return false ; } | Remove directory recursive on local file system |
48,008 | public static function formatter ( $ view , $ field ) { $ out = '' ; $ viewModeSettings = $ field -> viewModeSettings ; foreach ( ( array ) $ field -> extra as $ image ) { if ( ! empty ( $ image [ 'file_name' ] ) ) { $ img = '' ; $ originalURL = normalizePath ( "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}" , '/' ) ; $ imageOptions = [ ] ; foreach ( [ 'title' , 'alt' ] as $ attr ) { if ( ! empty ( $ field -> metadata -> settings [ "{$attr}_attr" ] ) && ! empty ( $ image [ $ attr ] ) ) { $ imageOptions [ $ attr ] = h ( $ image [ $ attr ] ) ; } } if ( $ viewModeSettings [ 'size' ] ) { $ thumbnail = static :: thumbnail ( normalizePath ( WWW_ROOT . "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}" ) , $ viewModeSettings [ 'size' ] ) ; if ( $ thumbnail !== false ) { $ thumbnail = basename ( $ thumbnail ) ; $ img = $ view -> Html -> image ( normalizePath ( "/files/{$field->metadata->settings['upload_folder']}/.tmb/{$thumbnail}" , '/' ) , $ imageOptions ) ; } } else { $ img = $ view -> Html -> image ( $ originalURL , $ imageOptions ) ; } if ( $ img ) { switch ( $ viewModeSettings [ 'link_type' ] ) { case 'content' : $ entityURL = $ field -> metadata -> entity -> get ( 'url' ) ; if ( $ entityURL ) { $ out .= $ view -> Html -> link ( $ img , $ entityURL , [ 'escape' => false ] ) ; } else { $ out .= $ img ; } break ; case 'file' : $ out .= $ view -> Html -> link ( $ img , $ originalURL , [ 'escape' => false , 'target' => '_blank' ] ) ; break ; default : $ out .= $ img ; break ; } } } } return $ out ; } | Renders the given field instance . |
48,009 | public static function thumbnail ( $ filePath , $ previewSize ) { $ filePath = normalizePath ( $ filePath ) ; if ( ! is_readable ( $ filePath ) ) { return false ; } $ srcFileName = basename ( $ filePath ) ; $ srcPath = dirname ( $ filePath ) . DS ; $ dstPath = normalizePath ( "{$srcPath}/.tmb/" ) ; $ previewInfo = static :: getPreviews ( $ previewSize ) ; require_once Plugin :: classPath ( 'Field' ) . 'Lib/class.upload.php' ; $ handle = new \ upload ( $ srcPath . $ srcFileName ) ; if ( empty ( $ previewInfo ) ) { $ previews = static :: getPreviews ( ) ; $ previewInfo = reset ( $ previews ) ; } $ dstFileNameBody = static :: removeExt ( "{$previewInfo['width']}x{$previewInfo['height']}_{$srcFileName}" ) ; $ dstFilePath = normalizePath ( "{$dstPath}/{$dstFileNameBody}.jpg" ) ; if ( is_readable ( $ dstFilePath ) ) { return $ dstFilePath ; } $ handle -> image_x = $ previewInfo [ 'width' ] ; $ handle -> image_y = $ previewInfo [ 'height' ] ; $ handle -> image_resize = true ; $ handle -> image_ratio = false ; $ handle -> image_ratio_crop = true ; $ handle -> image_convert = 'jpg' ; $ handle -> file_new_name_body = $ dstFileNameBody ; $ handle -> process ( $ dstPath ) ; if ( empty ( $ handle -> error ) ) { return $ handle -> file_dst_pathname ; } return false ; } | Creates a thumbnail for the given image . |
48,010 | public static function previewsOptions ( ) { static :: _initPreviews ( ) ; $ options = [ ] ; foreach ( static :: $ _previews as $ value => $ info ) { $ options [ $ value ] = $ info [ 'label' ] ; } return $ options ; } | Returns an array list of available previews modes suitable for select boxes . |
48,011 | public static function getPreviews ( $ slug = null ) { static :: _initPreviews ( ) ; if ( $ slug !== null ) { if ( isset ( static :: $ _previews [ $ slug ] ) ) { return static :: $ _previews [ $ slug ] ; } return [ ] ; } return static :: $ _previews ; } | Gets all defined previews or information for an specific preview . |
48,012 | public static function addPreview ( $ slug , $ label , $ width , $ height ) { static :: _initPreviews ( ) ; static :: $ _previews [ $ slug ] = [ 'label' => $ label , 'width' => $ width , 'height' => $ height , ] ; } | Defines a new preview configuration or overwrite if exists . |
48,013 | public static function delete ( $ imagePath ) { $ imagePath = normalizePath ( $ imagePath ) ; if ( is_readable ( $ imagePath ) ) { $ original = new File ( $ imagePath ) ; static :: deleteThumbnails ( $ imagePath ) ; $ original -> delete ( ) ; } } | Deletes the given image and all its thumbnails . |
48,014 | public static function deleteThumbnails ( $ imagePath ) { $ imagePath = normalizePath ( "{$imagePath}/" ) ; $ fileName = basename ( $ imagePath ) ; $ tmbPath = normalizePath ( dirname ( $ imagePath ) . '/.tmb/' ) ; $ folder = new Folder ( $ tmbPath ) ; $ pattern = preg_quote ( static :: removeExt ( $ fileName ) ) ; foreach ( $ folder -> find ( ".*{$pattern}.*" ) as $ tn ) { $ tn = new File ( $ tmbPath . $ tn ) ; $ tn -> delete ( ) ; } } | Delete image s thumbnails if exists . |
48,015 | public function edit ( $ id ) { $ this -> loadModel ( 'Menu.MenuLinks' ) ; $ this -> loadModel ( 'Content.Contents' ) ; $ link = $ this -> MenuLinks -> get ( $ id , [ 'contain' => [ 'Menus' ] ] ) ; if ( ! empty ( $ this -> request -> data ) ) { $ link = $ this -> MenuLinks -> patchEntity ( $ link , $ this -> request -> data , [ 'fieldList' => [ 'title' , 'url' , 'description' , 'target' , 'expanded' , 'active' , 'activation' , 'status' ] ] ) ; if ( $ this -> MenuLinks -> save ( $ link , [ 'associated' => false ] ) ) { $ this -> Flash -> success ( __d ( 'menu' , 'Link has been updated' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> danger ( __d ( 'menu' , 'Link could not be updated, please check your information' ) ) ; } } $ contentLinks = [ ] ; $ contents = $ this -> Contents -> find ( ) -> select ( [ 'id' , 'slug' , 'content_type_slug' , 'title' ] ) -> all ( ) ; foreach ( $ contents as $ content ) { $ contentLinks [ $ content -> get ( 'url' ) ] = __d ( 'menu' , '{0} [{1}]' , $ content -> title , $ content -> content_type_slug ) ; } $ this -> title ( __d ( 'menu' , 'Editing Link' ) ) ; $ this -> set ( compact ( 'link' , 'contentLinks' ) ) ; $ this -> Breadcrumb -> push ( '/admin/menu/manage' ) -> push ( __d ( 'menu' , 'Editing menu' ) , [ 'plugin' => 'Menu' , 'controller' => 'manage' , 'action' => 'edit' , $ link -> menu_id ] ) -> push ( __d ( 'menu' , 'Links' ) , [ 'plugin' => 'Menu' , 'controller' => 'links' , 'action' => 'menu' , $ link -> menu_id ] ) -> push ( __d ( 'menu' , 'Editing link' ) , '#' ) ; } | Edits the given menu link by ID . |
48,016 | public function delete ( $ id ) { $ this -> loadModel ( 'Menu.MenuLinks' ) ; $ link = $ this -> MenuLinks -> get ( $ id ) ; $ this -> MenuLinks -> addBehavior ( 'Tree' , [ 'scope' => [ 'menu_id' => $ link -> menu_id ] ] ) ; $ this -> MenuLinks -> removeFromTree ( $ link ) ; if ( $ this -> MenuLinks -> delete ( $ link ) ) { $ this -> Flash -> success ( __d ( 'menu' , 'Link successfully removed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'menu' , 'Link could not be removed, please try again' ) ) ; } $ this -> title ( __d ( 'menu' , 'Delete Link' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Deletes the given link . |
48,017 | public static function termsForBlock ( $ terms , $ block ) { foreach ( $ terms as $ term ) { $ title = $ term -> name ; if ( ! empty ( $ block -> settings [ 'show_counters' ] ) ) { $ countCacheKey = "t{$term->id}" ; $ count = ( string ) Cache :: read ( $ countCacheKey , 'terms_count' ) ; if ( $ count == '' ) { $ count = ( int ) TableRegistry :: get ( 'Taxonomy.EntitiesTerms' ) -> find ( ) -> where ( [ 'EntitiesTerms.term_id' => $ term -> id ] ) -> count ( ) ; Cache :: write ( $ countCacheKey , $ count , 'terms_count' ) ; } $ title .= " ({$count})" ; } $ term -> set ( 'title' , $ title ) ; $ term -> set ( 'url' , "/find/term:{$term->slug}" ) ; if ( ! empty ( $ term -> children ) ) { $ term -> set ( 'expanded' , true ) ; static :: termsForBlock ( $ term -> children , $ block ) ; } } } | Prepares the given threaded list of terms . |
48,018 | public function prepareConfig ( $ dbConfig = [ ] ) { if ( $ this -> config ( 'connection' ) ) { return true ; } if ( is_readable ( ROOT . '/config/settings.php.tmp' ) ) { $ dbConfig = include ROOT . '/config/settings.php.tmp' ; if ( empty ( $ dbConfig [ 'Datasources' ] [ 'default' ] ) ) { $ this -> error ( __d ( 'installer' , 'Invalid database information in file "{0}"' , ROOT . '/config/settings.php.tmp' ) ) ; return false ; } $ dbConfig = $ dbConfig [ 'Datasources' ] [ 'default' ] ; } else { if ( empty ( $ dbConfig [ 'driver' ] ) ) { $ dbConfig [ 'driver' ] = '__INVALID__' ; } if ( strpos ( $ dbConfig [ 'driver' ] , "\\" ) === false ) { $ dbConfig [ 'driver' ] = "Cake\\Database\\Driver\\{$dbConfig['driver']}" ; } } list ( , $ driverClass ) = namespaceSplit ( $ dbConfig [ 'driver' ] ) ; if ( ! in_array ( $ driverClass , [ 'Mysql' , 'Postgres' , 'Sqlite' , 'Sqlserver' ] ) ) { $ this -> error ( __d ( 'installer' , 'Invalid database type ({0}).' , $ driverClass ) ) ; return false ; } $ this -> config ( 'connection' , Hash :: merge ( $ this -> _defaultConnection , $ dbConfig ) ) ; return true ; } | Prepares database configuration attributes . |
48,019 | public function getConn ( ) { if ( ! $ this -> config ( 'connection.className' ) ) { $ this -> error ( __d ( 'installer' , 'Database engine cannot be empty.' ) ) ; return false ; } try { ConnectionManager :: drop ( 'installation' ) ; ConnectionManager :: config ( 'installation' , $ this -> config ( 'connection' ) ) ; $ conn = ConnectionManager :: get ( 'installation' ) ; $ conn -> connect ( ) ; return $ conn ; } catch ( \ Exception $ ex ) { $ this -> error ( __d ( 'installer' , 'Unable to connect to database, please check your information. Details: {0}' , '<p>' . $ ex -> getMessage ( ) . '</p>' ) ) ; return false ; } } | Generates a new connection to DB . |
48,020 | public function importTables ( $ conn ) { $ Folder = new Folder ( $ this -> config ( 'schemaPath' ) ) ; $ fixtures = $ Folder -> read ( false , false , true ) [ 1 ] ; try { return ( bool ) $ conn -> transactional ( function ( $ connection ) use ( $ fixtures ) { foreach ( $ fixtures as $ fixture ) { $ result = $ this -> _processFixture ( $ fixture , $ connection ) ; if ( ! $ result ) { $ this -> error ( __d ( 'installer' , 'Error importing "{0}".' , $ fixture ) ) ; return false ; } } return true ; } ) ; } catch ( \ Exception $ ex ) { $ this -> error ( __d ( 'installer' , 'Unable to import database information. Details: {0}' , '<p>' . $ ex -> getMessage ( ) . '</p>' ) ) ; return false ; } } | Imports tables schema and populates them . |
48,021 | public function isDbEmpty ( $ conn ) { $ Folder = new Folder ( $ this -> config ( 'schemaPath' ) ) ; $ existingSchemas = $ conn -> schemaCollection ( ) -> listTables ( ) ; $ newSchemas = array_map ( function ( $ item ) { return Inflector :: underscore ( str_replace ( 'Schema.php' , '' , $ item ) ) ; } , $ Folder -> read ( ) [ 1 ] ) ; $ result = ! array_intersect ( $ existingSchemas , $ newSchemas ) ; if ( ! $ result ) { $ this -> error ( __d ( 'installer' , 'A previous installation of QuickAppsCMS already exists, please drop your database tables before continue.' ) ) ; } return $ result ; } | Checks whether connected database is empty or not . |
48,022 | public function writeSetting ( ) { $ config = [ 'Datasources' => [ 'default' => $ this -> config ( 'connection' ) , ] , 'Security' => [ 'salt' => $ this -> salt ( ) ] , 'debug' => false , ] ; $ filePath = $ this -> config ( 'settingsPath' ) ; if ( ! str_ends_with ( strtolower ( $ filePath ) , '.tmp' ) ) { $ filePath .= '.tmp' ; } $ settingsFile = new File ( $ filePath , true ) ; return $ settingsFile -> write ( "<?php\n return " . var_export ( $ config , true ) . ";\n" ) ; } | Creates site s settings . php file . |
48,023 | protected function _processFixture ( $ path , Connection $ connection ) { if ( ! is_readable ( $ path ) ) { return false ; } require $ path ; $ fixtureClass = str_replace ( '.php' , '' , basename ( $ path ) ) ; $ schema = $ this -> _prepareSchema ( $ fixtureClass ) ; $ sql = $ schema -> createSql ( $ connection ) ; $ tableCreated = true ; foreach ( $ sql as $ stmt ) { try { if ( ! $ connection -> execute ( $ stmt ) ) { $ tableCreated = false ; } } catch ( \ Exception $ ex ) { $ this -> error ( __d ( 'installer' , 'Unable to create table "{0}". Details: {1}' , $ schema -> name ( ) , $ ex -> getMessage ( ) ) ) ; $ tableCreated = false ; } } if ( ! $ tableCreated ) { return false ; } if ( ! $ this -> _importRecords ( $ fixtureClass , $ schema , $ connection ) ) { return false ; } return true ; } | Process the given fixture class creates its schema and imports its records . |
48,024 | protected function _prepareSchema ( $ fixtureClassName ) { $ fixture = new $ fixtureClassName ; if ( ! empty ( $ fixture -> table ) ) { $ tableName = $ fixture -> table ; } else { $ tableName = ( string ) Inflector :: underscore ( str_replace_last ( 'Fixture' , '' , $ fixtureClassName ) ) ; } list ( $ fields , $ constraints , $ indexes , $ options ) = $ this -> _prepareSchemaProperties ( $ fixture ) ; $ schema = new TableSchema ( $ tableName , $ fields ) ; foreach ( $ constraints as $ name => $ attrs ) { $ schema -> addConstraint ( $ name , $ attrs ) ; } foreach ( $ indexes as $ name => $ attrs ) { $ schema -> addIndex ( $ name , $ attrs ) ; } if ( ! empty ( $ options ) ) { $ schema -> options ( $ options ) ; } return $ schema ; } | Gets an schema instance for the given fixture class . |
48,025 | protected function _importRecords ( $ fixtureClassName , TableSchema $ schema , Connection $ connection ) { $ fixture = new $ fixtureClassName ; if ( ! isset ( $ fixture -> records ) || empty ( $ fixture -> records ) ) { return true ; } $ fixture -> records = ( array ) $ fixture -> records ; if ( count ( $ fixture -> records ) > 100 ) { $ chunk = array_chunk ( $ fixture -> records , 100 ) ; } else { $ chunk = [ 0 => $ fixture -> records ] ; } foreach ( $ chunk as $ records ) { list ( $ fields , $ values , $ types ) = $ this -> _getRecords ( $ records , $ schema ) ; $ query = $ connection -> newQuery ( ) -> insert ( $ fields , $ types ) -> into ( $ schema -> name ( ) ) ; foreach ( $ values as $ row ) { $ query -> values ( $ row ) ; } try { $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; } catch ( \ Exception $ ex ) { $ this -> error ( __d ( 'installer' , 'Error while importing data for table "{0}". Details: {1}' , $ schema -> name ( ) , $ ex -> getMessage ( ) ) ) ; return false ; } } return true ; } | Imports all records of the given fixture . |
48,026 | protected function _getRecords ( array $ records , TableSchema $ schema ) { $ fields = $ values = $ types = [ ] ; $ columns = $ schema -> columns ( ) ; foreach ( $ records as $ record ) { $ fields = array_merge ( $ fields , array_intersect ( array_keys ( $ record ) , $ columns ) ) ; } $ fields = array_values ( array_unique ( $ fields ) ) ; foreach ( $ fields as $ field ) { $ types [ $ field ] = $ schema -> column ( $ field ) [ 'type' ] ; } $ default = array_fill_keys ( $ fields , null ) ; foreach ( $ records as $ record ) { $ values [ ] = array_merge ( $ default , $ record ) ; } return [ $ fields , $ values , $ types ] ; } | Converts the given array of records into data used to generate a query . |
48,027 | public function read ( ) { $ request = Router :: getRequest ( ) ; if ( ! empty ( $ request ) && empty ( $ this -> _postData ) ) { $ this -> _postData = ( array ) $ request -> data ( ) ; } if ( ! empty ( $ this -> _postData ) ) { $ keys = array_keys ( $ this -> _postData ) ; $ first = array_shift ( $ keys ) ; $ value = $ this -> _postData [ $ first ] ; unset ( $ this -> _postData [ $ first ] ) ; return $ value ; } return false ; } | Read a value from POST data . |
48,028 | public function settingsValidate ( Event $ event , $ data , Validator $ validator ) { if ( isset ( $ data [ 'password_min_length' ] ) ) { $ validator -> add ( 'password_min_length' , 'validNumber' , [ 'rule' => [ 'naturalNumber' , false ] , 'message' => __d ( 'user' , 'Invalid password min-length.' ) ] ) ; } $ validator -> requirePresence ( 'message_welcome_subject' ) -> notEmpty ( 'message_welcome_subject' , __d ( 'user' , 'This field cannot be empty.' ) ) -> requirePresence ( 'message_welcome_body' ) -> notEmpty ( 'message_welcome_body' , __d ( 'user' , 'This field cannot be empty.' ) ) -> requirePresence ( 'message_password_recovery_subject' ) -> notEmpty ( 'message_password_recovery_body' , __d ( 'user' , 'This field cannot be empty.' ) ) -> requirePresence ( 'message_cancel_request_subject' ) -> notEmpty ( 'message_cancel_request_body' , __d ( 'user' , 'This field cannot be empty.' ) ) ; if ( $ data [ 'message_activation' ] ) { $ validator -> requirePresence ( 'message_activation_subject' ) -> notEmpty ( 'message_activation_body' , __d ( 'user' , 'This field cannot be empty.' ) ) ; } if ( $ data [ 'message_blocked' ] ) { $ validator -> requirePresence ( 'message_blocked_subject' ) -> notEmpty ( 'message_blocked_body' , __d ( 'user' , 'This field cannot be empty.' ) ) ; } if ( $ data [ 'message_canceled' ] ) { $ validator -> requirePresence ( 'message_canceled_subject' ) -> notEmpty ( 'message_canceled_body' , __d ( 'user' , 'This field cannot be empty.' ) ) ; } } | Validates plugin s settings . |
48,029 | protected function _parseRange ( $ value ) { if ( strpos ( $ value , '..' ) !== false ) { list ( $ lower , $ upper ) = explode ( '..' , $ value ) ; } else { $ lower = $ upper = $ value ; } if ( intval ( $ lower ) > intval ( $ upper ) ) { list ( $ lower , $ upper ) = [ $ upper , $ lower ] ; } return [ 'lower' => $ lower , 'upper' => $ upper , ] ; } | Parses and extracts lower and upper values from the given range given as lower .. upper . |
48,030 | public function displayBlock ( Event $ event , $ block , $ options = [ ] ) { return $ this -> trigger ( [ 'Block.Menu.display' , $ event -> subject ( ) ] , $ block , $ options ) -> result ; } | All blocks registered by System plugin are associated blocks of some core s menus . So we redirect rendering task to Menu plugin s render . |
48,031 | private function tempDir ( ) { $ tempPath = tempnam ( $ this -> tmp , 'elFinder' ) ; if ( ! $ tempPath ) { $ this -> setError ( elFinder :: ERROR_CREATING_TEMP_DIR , $ this -> tmp ) ; return false ; } $ success = unlink ( $ tempPath ) ; if ( ! $ success ) { $ this -> setError ( elFinder :: ERROR_CREATING_TEMP_DIR , $ this -> tmp ) ; return false ; } $ success = mkdir ( $ tempPath , 0700 , true ) ; if ( ! $ success ) { $ this -> setError ( elFinder :: ERROR_CREATING_TEMP_DIR , $ this -> tmp ) ; return false ; } return $ tempPath ; } | Create writable temporary directory and return path to it . |
48,032 | private function deleteDir ( $ dirPath ) { if ( ! is_dir ( $ dirPath ) ) { $ success = unlink ( $ dirPath ) ; } else { $ success = true ; foreach ( array_reverse ( elFinderVolumeFTP :: listFilesInDirectory ( $ dirPath , false ) ) as $ path ) { $ path = $ dirPath . DIRECTORY_SEPARATOR . $ path ; if ( is_link ( $ path ) ) { unlink ( $ path ) ; } else if ( is_dir ( $ path ) ) { $ success = rmdir ( $ path ) ; } else { $ success = unlink ( $ path ) ; } if ( ! $ success ) { break ; } } if ( $ success ) { $ success = rmdir ( $ dirPath ) ; } } if ( ! $ success ) { $ this -> setError ( elFinder :: ERROR_RM , $ dirPath ) ; return false ; } return $ success ; } | Delete local directory recursively . |
48,033 | private static function listFilesInDirectory ( $ dir , $ omitSymlinks , $ prefix = '' ) { if ( ! is_dir ( $ dir ) ) { return false ; } $ excludes = array ( "." , ".." ) ; $ result = array ( ) ; $ files = scandir ( $ dir ) ; if ( ! $ files ) { return array ( ) ; } foreach ( $ files as $ file ) { if ( ! in_array ( $ file , $ excludes ) ) { $ path = $ dir . DIRECTORY_SEPARATOR . $ file ; if ( is_link ( $ path ) ) { if ( $ omitSymlinks ) { continue ; } else { $ result [ ] = $ prefix . $ file ; } } else if ( is_dir ( $ path ) ) { $ result [ ] = $ prefix . $ file . DIRECTORY_SEPARATOR ; $ subs = elFinderVolumeFTP :: listFilesInDirectory ( $ path , $ omitSymlinks , $ prefix . $ file . DIRECTORY_SEPARATOR ) ; if ( $ subs ) { $ result = array_merge ( $ result , $ subs ) ; } } else { $ result [ ] = $ prefix . $ file ; } } } return $ result ; } | Returns array of strings containing all files and folders in the specified local directory . |
48,034 | public function afterSave ( Event $ event , EntityInterface $ entity , ArrayObject $ options = null ) { if ( $ entity -> isNew ( ) ) { snapshot ( ) ; } } | Regenerates snapshot after new content type is created . |
48,035 | protected function _loadPermissions ( ) { if ( empty ( $ this -> _permissions ) ) { $ permissions = TableRegistry :: get ( 'Content.ContentTypePermissions' ) -> find ( ) -> where ( [ 'content_type_id' => $ this -> get ( 'id' ) ] ) -> toArray ( ) ; $ this -> _permissions = collection ( $ permissions ) ; } } | Loads ll permissions rules for this content type . |
48,036 | public function index ( ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ languages = $ this -> Languages -> find ( ) -> order ( [ 'ordering' => 'ASC' ] ) -> all ( ) ; $ this -> title ( __d ( 'locale' , 'Languages List' ) ) ; $ this -> set ( 'languages' , $ languages ) ; $ this -> Breadcrumb -> push ( '/admin/locale' ) ; } | Shows a list of languages . |
48,037 | public function add ( ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> newEntity ( ) ; $ languages = LocaleToolbox :: languagesList ( true ) ; $ icons = LocaleToolbox :: flagsList ( ) ; if ( ! empty ( $ this -> request -> data [ 'code' ] ) ) { $ info = LocaleToolbox :: info ( $ this -> request -> data [ 'code' ] ) ; $ language = $ this -> Languages -> patchEntity ( $ language , [ 'code' => normalizeLocale ( $ this -> request -> data [ 'code' ] ) , 'name' => $ info [ 'language' ] , 'direction' => $ info [ 'direction' ] , 'status' => ( isset ( $ this -> request -> data [ 'status' ] ) ? $ this -> request -> data [ 'status' ] : false ) , 'icon' => ( ! empty ( $ this -> request -> data [ 'icon' ] ) ? $ this -> request -> data [ 'icon' ] : null ) ] ) ; if ( $ this -> Languages -> save ( $ language ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Language was successfully registered!' ) ) ; $ this -> redirect ( [ 'plugin' => 'Locale' , 'controller' => 'manage' , 'action' => 'index' ] ) ; } else { $ this -> Flash -> danger ( __d ( 'locale' , 'Language could not be registered, please check your information' ) ) ; } } $ this -> title ( __d ( 'locale' , 'Register New Language' ) ) ; $ this -> set ( compact ( 'language' , 'languages' , 'icons' ) ) ; $ this -> Breadcrumb -> push ( '/admin/locale' ) -> push ( __d ( 'locale' , 'Add new language' ) , '' ) ; } | Registers a new language in the system . |
48,038 | public function edit ( $ id ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> get ( $ id ) ; $ languages = LocaleToolbox :: languagesList ( true ) ; $ icons = LocaleToolbox :: flagsList ( ) ; if ( $ this -> request -> data ( ) ) { $ language = $ this -> Languages -> patchEntity ( $ language , $ this -> request -> data , [ 'fieldList' => [ 'name' , 'direction' , 'icon' , ] ] ) ; if ( $ this -> Languages -> save ( $ language ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Language was successfully saved!' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> success ( __d ( 'locale' , 'Language could not be saved, please check your information.' ) ) ; } } $ this -> title ( __d ( 'locale' , 'Editing Language' ) ) ; $ this -> set ( compact ( 'language' , 'languages' , 'icons' ) ) ; $ this -> Breadcrumb -> push ( '/admin/locale' ) -> push ( __d ( 'locale' , 'Editing language' ) , '' ) ; } | Edits language . |
48,039 | public function setDefault ( $ id ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ this -> loadModel ( 'System.Options' ) ; $ language = $ this -> Languages -> get ( $ id ) ; if ( $ language -> status ) { if ( $ this -> Options -> update ( 'default_language' , $ language -> code ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Default language changed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'locale' , 'Default language could not be changed.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'locale' , 'You cannot set as default a disabled language.' ) ) ; } $ this -> title ( __d ( 'locale' , 'Set Default Language' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Sets the given language as site s default language . |
48,040 | public function move ( $ id , $ direction ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> get ( $ id ) ; $ unordered = $ this -> Languages -> find ( ) -> select ( [ 'id' , 'ordering' ] ) -> order ( [ 'ordering' => 'ASC' ] ) -> all ( ) -> extract ( 'id' ) -> toArray ( ) ; $ position = array_search ( $ language -> id , $ unordered ) ; if ( ! is_integer ( $ position ) ) { $ this -> redirect ( $ this -> referer ( ) ) ; } $ direction = $ direction === 'up' ? 'down' : 'up' ; $ ordered = array_move ( $ unordered , $ position , $ direction ) ; if ( md5 ( serialize ( $ ordered ) ) != md5 ( serialize ( $ unordered ) ) ) { foreach ( $ ordered as $ ordering => $ id ) { $ this -> Languages -> updateAll ( compact ( 'ordering' ) , compact ( 'id' ) ) ; } } $ this -> title ( __d ( 'locale' , 'Reorder Language' ) ) ; $ this -> Flash -> success ( __d ( 'locale' , 'Language successfully reordered!' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Moves language up or down . |
48,041 | public function enable ( $ id ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> get ( $ id ) ; $ language -> set ( 'status' , true ) ; if ( $ this -> Languages -> save ( $ language ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Language successfully enabled!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'locale' , 'Language could not be enabled, please try again.' ) ) ; } $ this -> title ( __d ( 'locale' , 'Enable Language' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Enables the given language . |
48,042 | public function disable ( $ id ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> get ( $ id ) ; if ( ! in_array ( $ language -> code , [ CORE_LOCALE , option ( 'default_language' ) ] ) ) { $ language -> set ( 'status' , false ) ; if ( $ this -> Languages -> save ( $ language ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Language successfully disabled!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'locale' , 'Language could not be disabled, please try again.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'locale' , 'You cannot disable this language as it still in use.' ) ) ; } $ this -> title ( __d ( 'locale' , 'Disable Language' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Disables the given language . |
48,043 | public function delete ( $ id ) { $ this -> loadModel ( 'Locale.Languages' ) ; $ language = $ this -> Languages -> get ( $ id ) ; if ( ! in_array ( $ language -> code , [ CORE_LOCALE , option ( 'default_language' ) ] ) ) { if ( $ this -> Languages -> delete ( $ language ) ) { $ this -> Flash -> success ( __d ( 'locale' , 'Language successfully removed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'locale' , 'Language could not be removed, please try again.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'locale' , 'You cannot remove this language as it still in use.' ) ) ; } $ this -> title ( __d ( 'locale' , 'Delete Language' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Unregisters the given language . |
48,044 | protected function _inResponseTo ( Comment $ comment ) { $ this -> loadModel ( 'Content.Contents' ) ; $ this -> Contents -> fieldable ( false ) ; $ content = $ this -> Contents -> get ( $ comment -> entity_id ) ; if ( $ content ) { $ out = __d ( 'content' , '<a href="{0}" target="_blank">{1}</a>' , Router :: url ( [ 'plugin' => 'Content' , 'controller' => 'manage' , 'action' => 'edit' , $ content -> id ] ) , $ content -> title ) ; $ out .= '<br />' ; $ out .= __d ( 'content' , '<a href="{0}" target="_blank">{1}</a>' , Router :: url ( $ content -> url ) , 'View content' ) ; return $ out ; } return __d ( 'content' , '-- Unknow --' ) ; } | Renders the description of the entity to which comment is attached to . |
48,045 | public function render ( $ options = [ ] ) { $ items = $ this -> getStack ( ) ; $ options = Hash :: merge ( [ 'breadcrumbGuessing' => false , 'class' => 'breadcrumb' , 'templates' => [ 'root' => '<ol{{attrs}}>{{content}}</ol>' , ] , 'formatter' => function ( $ entity , $ info ) { $ options = [ ] ; if ( $ info [ 'index' ] === $ info [ 'total' ] ) { $ options [ 'childAttrs' ] = [ 'class' => 'active' ] ; $ options [ 'templates' ] [ 'link' ] = '{{content}}' ; } return $ this -> Menu -> formatter ( $ entity , $ info , $ options ) ; } ] , $ options ) ; return $ this -> Menu -> render ( $ items , $ options ) ; } | Renders a breadcrumb menu list . |
48,046 | public function check ( ) { $ pass = true ; foreach ( $ this -> _rules as $ rule ) { if ( $ rule -> lhs ( ) instanceof BasePackage ) { $ package = $ rule -> lhs ( ) ; } else { $ package = PackageFactory :: create ( ( string ) $ rule -> lhs ( ) ) ; } if ( ! $ package -> versionMatch ( $ rule -> rhs ( ) ) ) { $ this -> _fail ( $ rule ) ; $ pass = false ; } else { $ this -> _pass ( $ rule ) ; } } $ this -> _checked = true ; return $ pass ; } | Checks all the rules of this class . |
48,047 | public function pass ( $ asString = false ) { if ( ! $ this -> _checked ) { $ this -> check ( ) ; } if ( ! $ asString ) { return $ this -> _pass ; } $ items = [ ] ; foreach ( $ this -> _pass as $ rule ) { $ items [ ] = "{$rule}" ; } return implode ( ', ' , $ items ) ; } | Gets all rules marked as PASS . |
48,048 | public function fail ( $ asString = false ) { if ( ! $ this -> _checked ) { $ this -> check ( ) ; } if ( ! $ asString ) { return $ this -> _fail ; } $ items = [ ] ; foreach ( $ this -> _fail as $ rule ) { $ items [ ] = "{$rule}" ; } return implode ( ', ' , $ items ) ; } | Gets all rules marked as FAIL . |
48,049 | public function render ( array $ data , ContextInterface $ context ) { $ data += [ 'name' => '' , 'val' => null , 'type' => 'text' , 'escape' => true , ] ; $ data [ 'value' ] = $ data [ 'val' ] ; $ data [ 'readonly' ] = 'readonly' ; unset ( $ data [ 'val' ] ) ; $ this -> _loadAssets ( ) ; $ data [ 'class' ] = ! empty ( $ data [ 'class' ] ) ? "{$data['class']} fontselector" : 'fontselector' ; return $ this -> _templates -> format ( 'input' , [ 'name' => $ data [ 'name' ] , 'type' => 'text' , 'attrs' => $ this -> _templates -> formatAttributes ( $ data , [ 'name' , 'type' ] ) , ] ) . '<p id="' . $ data [ 'id' ] . '-preview" style="font:' . $ data [ 'value' ] . ';">Example text</p>' ; } | Render a color picker widget . |
48,050 | protected function _loadAssets ( ) { $ this -> _View -> Html -> css ( 'System./font-panel/fontpanel.css' , [ 'block' => true ] ) ; $ this -> _View -> Html -> script ( 'System./font-panel/fontpanel.js' , [ 'block' => true ] ) ; $ this -> _View -> Html -> script ( 'System./font-panel/font-panel-init.js' , [ 'block' => true ] ) ; } | Load all CSS and JS assets required for this widget . |
48,051 | public function about ( $ pluginName ) { $ about = false ; if ( Plugin :: loaded ( $ pluginName ) ) { $ locale = I18n :: locale ( ) ; $ templatePath = App :: path ( 'Template' , $ pluginName ) [ 0 ] . 'Element/Help/' ; $ lookFor = [ "help_{$locale}" , 'help' ] ; foreach ( $ lookFor as $ ctp ) { if ( is_readable ( $ templatePath . "{$ctp}.ctp" ) ) { $ about = "{$pluginName}.Help/{$ctp}" ; break ; } } } if ( $ about ) { $ this -> set ( 'about' , $ about ) ; } else { throw new NotFoundException ( __d ( 'system' , 'No help was found.' ) ) ; } $ this -> title ( __d ( 'system' , 'About "{0}"' , $ pluginName ) ) ; $ this -> Breadcrumb -> push ( '/admin/system/help' ) -> push ( __d ( 'system' , 'About {0}' , $ pluginName ) , '#' ) ; } | Renders the help document of the given plugin . |
48,052 | public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ query -> formatResults ( function ( $ results ) use ( $ options ) { return $ results -> map ( function ( $ entity ) use ( $ options ) { if ( ! ( $ entity instanceof EntityInterface ) ) { return $ entity ; } foreach ( $ this -> config ( 'columns' ) as $ column ) { if ( $ entity -> has ( $ column ) ) { $ eventName = $ this -> _table -> alias ( ) . ".{$column}.defaultValues" ; $ defaultValue = $ this -> _table -> dispatchEvent ( $ eventName , compact ( 'entity' ) ) -> result ; $ currentValue = $ entity -> get ( $ column ) ; $ newValue = $ currentValue ; if ( is_array ( $ currentValue ) && is_array ( $ defaultValue ) ) { $ newValue = Hash :: merge ( $ defaultValue , $ currentValue ) ; } elseif ( is_string ( $ currentValue ) && $ currentValue === '' ) { $ newValue = $ defaultValue ; } elseif ( empty ( $ currentValue ) && ! empty ( $ defaultValue ) ) { $ newValue = $ defaultValue ; } $ entity -> set ( $ column , $ newValue ) ; if ( ! empty ( $ options [ 'flatten' ] ) && is_array ( $ entity -> get ( $ column ) ) ) { foreach ( $ entity -> get ( $ column ) as $ key => $ value ) { $ entity -> set ( "{$column}:{$key}" , $ value ) ; } } } } return $ entity ; } ) ; } ) ; } | Here we set default values for serializable columns . |
48,053 | protected function _slug ( $ string , $ entity ) { $ string = $ this -> _mbTrim ( mb_strtolower ( $ string ) ) ; $ config = $ this -> config ( ) ; $ slug = Inflector :: slug ( $ string , $ config [ 'separator' ] ) ; $ pk = $ this -> _table -> primaryKey ( ) ; if ( mb_strlen ( $ slug ) > $ config [ 'length' ] ) { $ slug = mb_substr ( $ slug , 0 , $ config [ 'length' ] ) ; } $ conditions = [ "{$config['slug']} LIKE" => "{$slug}%" ] ; if ( $ entity -> has ( $ pk ) ) { $ conditions [ "{$pk} NOT IN" ] = [ $ entity -> { $ pk } ] ; } $ same = $ this -> _table -> find ( ) -> where ( $ conditions ) -> all ( ) -> extract ( $ config [ 'slug' ] ) -> toArray ( ) ; if ( ! empty ( $ same ) ) { $ initialSlug = $ slug ; $ index = 1 ; while ( $ index > 0 ) { $ nextSlug = "{$initialSlug}{$config['separator']}{$index}" ; if ( ! in_array ( $ nextSlug , $ same ) ) { $ slug = $ nextSlug ; $ index = - 1 ; } $ index ++ ; } } return $ slug ; } | Generate a slug for the given string and entity . The generated slug is unique across the entire table . |
48,054 | public function beforeFind ( Event $ event , $ query , $ options , $ primary ) { if ( $ this -> _enabled && $ query -> count ( ) > 0 ) { $ pk = $ this -> _table -> primaryKey ( ) ; $ tableAlias = Inflector :: underscore ( $ this -> _table -> alias ( ) ) ; $ query -> contain ( [ 'Comments' => function ( $ query ) { return $ query -> find ( 'threaded' ) -> contain ( [ 'Users' ] ) -> order ( $ this -> config ( 'order' ) ) ; } , ] ) ; if ( $ this -> config ( 'count' ) || ( isset ( $ options [ 'comments_count' ] ) && $ options [ 'comments_count' ] === true ) ) { $ query -> formatResults ( function ( $ results ) use ( $ pk , $ tableAlias ) { return $ results -> map ( function ( $ entity ) use ( $ pk , $ tableAlias ) { $ entityId = $ entity -> { $ pk } ; $ count = TableRegistry :: get ( 'Comment.Comments' ) -> find ( ) -> where ( [ 'entity_id' => $ entityId , 'table_alias' => $ tableAlias ] ) -> count ( ) ; $ entity -> set ( 'comments_count' , $ count ) ; return $ entity ; } ) ; } ) ; } } } | Attaches comments to each entity on find operation . |
48,055 | public function findComments ( Query $ query , $ options ) { $ tableAlias = Inflector :: underscore ( $ this -> _table -> alias ( ) ) ; if ( empty ( $ options [ 'for' ] ) ) { throw new \ InvalidArgumentException ( "The 'for' key is required for find('children')" ) ; } $ comments = $ this -> _table -> Comments -> find ( 'threaded' ) -> where ( [ 'table_alias' => $ tableAlias , 'entity_id' => $ options [ 'for' ] ] ) -> order ( $ this -> config ( 'order' ) ) -> all ( ) ; return $ comments ; } | Get comments for the given entity . |
48,056 | public function viewMode ( $ slug = null ) { if ( $ slug === null ) { return ViewModeRegistry :: current ( ) ; } return ViewModeRegistry :: uses ( $ slug ) ; } | Sets a view mode or get current view mode . |
48,057 | public function onViewMode ( $ viewMode , callable $ method ) { $ viewMode = ! is_array ( $ viewMode ) ? [ $ viewMode ] : $ viewMode ; if ( in_array ( $ this -> viewMode ( ) , $ viewMode ) ) { return $ method ( ) ; } } | Runs the given callable when the in - use view mode matches . |
48,058 | public function asViewMode ( $ viewMode , callable $ method ) { $ prevViewMode = $ this -> viewMode ( ) ; $ this -> viewMode ( $ viewMode ) ; $ method ( ) ; $ this -> viewMode ( $ prevViewMode ) ; } | Runs the given callable as it were under the given view mode . |
48,059 | public function afterSave ( Event $ event , MenuLink $ link , ArrayObject $ options = null ) { $ this -> clearCache ( ) ; } | Triggered after menu link was persisted in DB . |
48,060 | public function alterTextarea ( MethodInvocation $ invocation ) { $ helper = $ invocation -> getThis ( ) ; list ( $ fieldName , $ options ) = array_pad ( $ invocation -> getArguments ( ) , 2 , null ) ; $ options = ( array ) $ options ; $ options = $ this -> _addClass ( $ helper , $ options , 'form-control' ) ; $ this -> _addTemplates ( $ helper ) ; $ this -> setProperty ( $ invocation , 'arguments' , [ $ fieldName , $ options ] ) ; return $ invocation -> proceed ( ) ; } | Appends some CSS classes to textarea elements . |
48,061 | public function alterSelectbox ( MethodInvocation $ invocation ) { $ helper = $ invocation -> getThis ( ) ; list ( $ fieldName , $ options , $ attributes ) = array_pad ( $ invocation -> getArguments ( ) , 3 , null ) ; $ options = $ options === null ? [ ] : $ options ; $ attributes = ( array ) $ attributes ; $ attributes = $ this -> _addClass ( $ helper , $ attributes , 'form-control' ) ; $ this -> setProperty ( $ invocation , 'arguments' , [ $ fieldName , $ options , $ attributes ] ) ; return $ invocation -> proceed ( ) ; } | Appends some CSS classes to select elements . |
48,062 | public function alterButton ( MethodInvocation $ invocation ) { $ helper = $ invocation -> getThis ( ) ; list ( $ title , $ options ) = array_pad ( $ invocation -> getArguments ( ) , 2 , null ) ; $ options = ( array ) $ options ; $ options = $ this -> _addClass ( $ helper , $ options , 'btn btn-default' ) ; $ this -> _addTemplates ( $ helper ) ; $ this -> setProperty ( $ invocation , 'arguments' , [ $ title , $ options ] ) ; return $ invocation -> proceed ( ) ; } | Appends some CSS classes to generic buttons . |
48,063 | public function alterSubmit ( MethodInvocation $ invocation ) { $ helper = $ invocation -> getThis ( ) ; list ( $ caption , $ options ) = array_pad ( $ invocation -> getArguments ( ) , 2 , null ) ; $ options = ( array ) $ options ; $ options = $ this -> _addClass ( $ helper , $ options , 'btn btn-primary' ) ; $ this -> _addTemplates ( $ helper ) ; $ this -> setProperty ( $ invocation , 'arguments' , [ $ caption , $ options ] ) ; return $ invocation -> proceed ( ) ; } | Appends some CSS classes to submit buttons . |
48,064 | protected function _addClass ( FormHelper $ formHelper , $ options , $ class ) { $ bootstrap = isset ( $ options [ 'bootstrap' ] ) ? ( bool ) $ options [ 'bootstrap' ] : true ; if ( $ bootstrap ) { $ options = $ formHelper -> addClass ( ( array ) $ options , $ class ) ; } if ( isset ( $ options [ 'bootstrap' ] ) ) { unset ( $ options [ 'bootstrap' ] ) ; } return $ options ; } | Add custom CSS classes to array of options . |
48,065 | protected function _addTemplates ( FormHelper $ formHelper ) { if ( ! static :: cache ( 'bootstrapTemplates' ) ) { $ formHelper -> templates ( $ this -> _templates ) ; static :: cache ( 'bootstrapTemplates' , true ) ; } } | Add custom set of templates to FormHelper . |
48,066 | public function thumbnail ( $ name ) { $ this -> loadModel ( 'Field.FieldInstances' ) ; $ instance = $ this -> _getInstance ( $ name ) ; if ( ! $ instance ) { throw new NotFoundException ( __d ( 'field' , 'Invalid field instance.' ) , 400 ) ; } if ( empty ( $ this -> request -> query [ 'file' ] ) ) { throw new NotFoundException ( __d ( 'field' , 'Invalid file name.' ) , 400 ) ; } if ( empty ( $ this -> request -> query [ 'size' ] ) ) { throw new NotFoundException ( __d ( 'field' , 'Invalid image size.' ) , 400 ) ; } $ imagePath = normalizePath ( WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}" ) ; $ tmb = ImageToolbox :: thumbnail ( $ imagePath , $ this -> request -> query [ 'size' ] ) ; if ( $ tmb !== false ) { $ this -> response -> file ( $ tmb ) ; return $ this -> response ; } throw new NotFoundException ( __d ( 'field' , 'Thumbnail could not be found, check write permissions?' ) , 500 ) ; } | Returns an scaled version of the given file image . |
48,067 | public function index ( ) { $ this -> loadModel ( 'Menu.Menus' ) ; $ menus = $ this -> Menus -> find ( ) -> all ( ) ; $ this -> title ( __d ( 'menu' , 'Menus List' ) ) ; $ this -> set ( 'menus' , $ menus ) ; $ this -> Breadcrumb -> push ( '/admin/menu/manage' ) ; } | Shows a list of all the menus . |
48,068 | public function edit ( $ id ) { $ this -> loadModel ( 'Menu.Menus' ) ; $ menu = $ this -> Menus -> get ( $ id ) ; if ( $ this -> request -> data ( ) ) { $ menu = $ this -> Menus -> patchEntity ( $ menu , $ this -> request -> data ( ) , [ 'fieldList' => [ 'title' , 'description' , 'settings' , ] , 'validate' => false ] ) ; if ( $ this -> Menus -> save ( $ menu , [ 'atomic' => true ] ) ) { $ this -> Flash -> success ( __d ( 'menu' , 'Menu has been saved!' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> danger ( __d ( 'menu' , 'Menu could not be saved, please check your information' ) ) ; } } $ this -> title ( __d ( 'menu' , 'Editing Menu' ) ) ; $ this -> set ( 'menu' , $ menu ) ; $ this -> Breadcrumb -> push ( '/admin/menu/manage' ) -> push ( __d ( 'menu' , 'Editing menu {0}' , $ menu -> title ) , '#' ) ; } | Edits the given menu by ID . |
48,069 | public function delete ( $ id ) { $ this -> loadModel ( 'Menu.Menus' ) ; $ menu = $ this -> Menus -> get ( $ id ) ; if ( $ menu -> handler === 'Menu' && $ this -> Menus -> delete ( $ menu ) ) { $ this -> Flash -> success ( __d ( 'menu' , 'Menu has been successfully deleted!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'menu' , 'Menu could not be deleted, please try again' ) ) ; } $ this -> title ( __d ( 'menu' , 'Delete Menu' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Removes the given menu by ID . |
48,070 | public function url ( $ url ) { if ( is_string ( $ url ) ) { $ url = $ this -> localePrefix ( $ url ) ; } try { $ url = Router :: url ( $ url , true ) ; } catch ( \ Exception $ ex ) { $ url = '' ; } return $ url ; } | Returns a safe URL string for later use with HtmlHelper . |
48,071 | public function isActive ( EntityInterface $ item ) { if ( $ item -> has ( 'activation' ) && is_callable ( $ item -> get ( 'activation' ) ) ) { $ callable = $ item -> get ( 'activation' ) ; return $ callable ( $ this -> _View -> request , $ item ) ; } $ itemUrl = $ this -> sanitize ( $ item -> get ( 'url' ) ) ; if ( ! str_starts_with ( $ itemUrl , '/' ) ) { return false ; } switch ( $ item -> get ( 'activation' ) ) { case 'any' : return $ this -> _requestMatches ( $ item -> get ( 'active' ) ) ; case 'none' : return ! $ this -> _requestMatches ( $ item -> get ( 'active' ) ) ; case 'php' : return php_eval ( $ item -> get ( 'active' ) , [ 'view' , & $ this -> _View , 'item' , & $ item , ] ) === true ; case 'auto' : default : static $ requestUri = null ; static $ requestUrl = null ; if ( $ requestUri === null ) { $ requestUri = urldecode ( env ( 'REQUEST_URI' ) ) ; $ requestUrl = str_replace ( '//' , '/' , '/' . urldecode ( $ this -> _View -> request -> url ) . '/' ) ; } $ isInternal = $ itemUrl !== '/' && str_ends_with ( $ itemUrl , str_replace_once ( $ this -> baseUrl ( ) , '' , $ requestUri ) ) ; $ isIndex = $ itemUrl === '/' && $ this -> _View -> request -> isHome ( ) ; $ isExact = str_replace ( '//' , '/' , "{$itemUrl}/" ) === $ requestUrl || $ itemUrl == $ requestUri ; if ( $ this -> config ( 'breadcrumbGuessing' ) ) { return ( $ isInternal || $ isIndex || $ isExact || in_array ( $ itemUrl , $ this -> _crumbs ( ) ) ) ; } return ( $ isInternal || $ isIndex || $ isExact ) ; } } | Checks if the given menu link should be marked as active . |
48,072 | public function sanitize ( $ url ) { try { $ url = Router :: url ( $ url ) ; } catch ( \ Exception $ ex ) { return '' ; } if ( ! str_starts_with ( $ url , '/' ) ) { return $ url ; } if ( str_starts_with ( $ url , $ this -> baseUrl ( ) ) ) { $ url = str_replace_once ( $ this -> baseUrl ( ) , '' , $ url ) ; } return $ this -> localePrefix ( $ url ) ; } | Sanitizes the given URL by making sure it s suitable for menu links . |
48,073 | public function localePrefix ( $ url ) { if ( option ( 'url_locale_prefix' ) && str_starts_with ( $ url , '/' ) && ! preg_match ( '/^\/' . $ this -> _localesPattern ( ) . '/' , $ url ) ) { $ url = '/' . I18n :: locale ( ) . $ url ; } return $ url ; } | Prepends language code to the given URL if the url_locale_prefix directive is enabled . |
48,074 | public function baseUrl ( ) { static $ base = null ; if ( $ base === null ) { $ base = $ this -> _View -> request -> base ; } return $ base ; } | Calculates site s base URL . |
48,075 | protected function _crumbs ( ) { static $ crumbs = null ; if ( $ crumbs === null ) { $ crumbs = BreadcrumbRegistry :: getUrls ( ) ; foreach ( $ crumbs as & $ crumb ) { $ crumb = $ this -> sanitize ( $ crumb ) ; } } return $ crumbs ; } | Gets a list of all URLs present in current crumbs stack . |
48,076 | protected function _requestMatches ( $ patterns ) { if ( empty ( $ patterns ) ) { return false ; } $ request = $ this -> _View -> request ; $ path = '/' . urldecode ( $ request -> url ) ; $ patterns = explode ( "\n" , $ patterns ) ; foreach ( $ patterns as & $ p ) { $ p = $ this -> _View -> Url -> build ( '/' ) . $ p ; $ p = str_replace ( '//' , '/' , $ p ) ; $ p = str_replace ( $ request -> base , '' , $ p ) ; $ p = $ this -> localePrefix ( $ p ) ; } $ patterns = implode ( "\n" , $ patterns ) ; $ toReplace = [ '/(\r\n?|\n)/' , '/\\\\\*/' , '/(^|\|)\/($|\|)/' ] ; $ replacements = [ '|' , '.*' , '\1' . preg_quote ( $ this -> _View -> Url -> build ( '/' ) , '/' ) . '\2' ] ; $ patternsQuoted = preg_quote ( $ patterns , '/' ) ; $ patterns = '/^(' . preg_replace ( $ toReplace , $ replacements , $ patternsQuoted ) . ')$/' ; return ( bool ) preg_match ( $ patterns , $ path ) ; } | Check if current request path matches any pattern in a set of patterns . |
48,077 | protected function _localesPattern ( ) { $ cacheKey = '_localesPattern' ; $ cache = static :: cache ( $ cacheKey ) ; if ( $ cache ) { return $ cache ; } $ pattern = '(' . implode ( '|' , array_map ( 'preg_quote' , array_keys ( quickapps ( 'languages' ) ) ) ) . ')' ; return static :: cache ( $ cacheKey , $ pattern ) ; } | Returns a regular expression that is used to verify if an URL starts or not with a language prefix . |
48,078 | public function composer ( $ full = false ) { $ cacheKey = "composer({$this->_packageName}, {$full})" ; if ( $ cache = static :: cache ( $ cacheKey ) ) { return $ cache ; } $ jsonPath = normalizePath ( $ this -> path ( ) . '/composer.json' ) ; if ( ! is_readable ( $ jsonPath ) ) { return [ ] ; } $ json = json_decode ( file_get_contents ( $ jsonPath ) , true ) ; if ( empty ( $ json ) ) { return [ ] ; } if ( $ full ) { $ json = Hash :: merge ( JsonSchema :: $ schema , $ json ) ; } return static :: cache ( $ cacheKey , $ json ) ; } | Gets composer json information for this package . |
48,079 | public static function getUrls ( ) { $ urls = [ ] ; foreach ( static :: $ _crumbs as $ crumb ) { if ( ! empty ( $ crumb [ 'url' ] ) ) { $ urls [ ] = $ crumb [ 'url' ] ; } elseif ( is_object ( $ crumb ) ) { $ urls [ ] = $ crumb -> url ; } } return $ urls ; } | Gets a list of all URLs . |
48,080 | public function beforeSave ( Event $ event , $ entity , $ options = [ ] ) { if ( $ this -> _table -> hasField ( $ this -> config ( 'createdByField' ) ) || $ this -> _table -> hasField ( $ this -> config ( 'modifiedByField' ) ) ) { $ userId = $ this -> _getUserId ( ) ; if ( $ userId > 0 ) { $ entity -> set ( $ this -> config ( 'modifiedByField' ) , $ userId ) ; if ( $ entity -> isNew ( ) ) { $ entity -> set ( $ this -> config ( 'createdByField' ) , $ userId ) ; } } } return true ; } | Run before a model is saved . |
48,081 | protected function _getUserId ( ) { $ callable = $ this -> config ( 'idCallable' ) ; $ id = 0 ; if ( is_string ( $ callable ) ) { $ session = Session :: create ( ) ; $ id = $ session -> read ( $ callable ) ; } elseif ( is_callable ( $ callable ) ) { $ id = $ callable ( ) ; } return ( int ) $ id ; } | Gets current User s ID . |
48,082 | public function delete ( $ pluginName ) { $ plugin = plugin ( $ pluginName ) ; $ task = ( bool ) WebShellDispatcher :: run ( "Installer.plugins uninstall -p {$plugin->name}" ) ; if ( $ task ) { $ this -> Flash -> success ( __d ( 'system' , 'Plugin was successfully removed!' ) ) ; } else { $ this -> Flash -> set ( __d ( 'system' , 'Plugins could not be removed' ) , [ 'element' => 'System.installer_errors' , 'params' => [ 'errors' => WebShellDispatcher :: output ( ) ] , ] ) ; } $ this -> title ( __d ( 'system' , 'Uninstall Plugin' ) ) ; header ( 'Location:' . $ this -> referer ( ) ) ; exit ( ) ; } | Uninstalls the given plugin . |
48,083 | public function index ( ) { $ this -> loadModel ( 'Block.Blocks' ) ; if ( $ this -> request -> isPost ( ) ) { if ( $ this -> _reorder ( ) ) { $ this -> Flash -> success ( __d ( 'block' , 'Blocks ordering updated!' ) ) ; } $ this -> redirect ( [ 'plugin' => 'Block' , 'controller' => 'manage' , 'action' => 'index' ] ) ; } $ front = $ this -> Blocks -> inFrontTheme ( ) ; $ back = $ this -> Blocks -> inBackTheme ( ) ; $ unused = $ this -> Blocks -> unused ( ) ; $ this -> set ( compact ( 'front' , 'back' , 'unused' ) ) ; $ this -> title ( __d ( 'block' , 'Site Blocks' ) ) ; $ this -> Breadcrumb -> push ( '/admin/system/structure' ) -> push ( __d ( 'block' , 'Manage Blocks' ) , '#' ) ; } | Shows a list of all the blocks & widgets . |
48,084 | public function add ( ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ block = $ this -> Blocks -> newEntity ( ) ; $ block -> set ( 'region' , [ ] ) ; if ( $ this -> request -> data ( ) ) { $ block = $ this -> _patchEntity ( $ block ) ; if ( ! $ block -> errors ( ) ) { if ( $ this -> Blocks -> save ( $ block ) ) { $ this -> Flash -> success ( __d ( 'block' , 'Block created.' ) ) ; $ this -> redirect ( [ 'plugin' => 'Block' , 'controller' => 'manage' , 'action' => 'edit' , $ block -> id ] ) ; } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be created, please check your information.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be created, please check your information.' ) ) ; } } $ this -> _setLanguages ( ) ; $ this -> _setRoles ( ) ; $ this -> _setRegions ( ) ; $ this -> set ( 'block' , $ block ) ; $ this -> title ( __d ( 'block' , 'Create New Block' ) ) ; $ this -> Breadcrumb -> push ( '/admin/system/structure' ) -> push ( __d ( 'block' , 'Manage Blocks' ) , [ 'plugin' => 'Block' , 'controller' => 'manage' , 'action' => 'index' ] ) -> push ( __d ( 'block' , 'Create New Block' ) , '#' ) ; } | Creates a new custom block . |
48,085 | public function delete ( $ id ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ block = $ this -> Blocks -> find ( ) -> where ( [ 'id' => $ id ] ) -> first ( ) ; if ( $ block && ( $ block -> handler == 'Block' || ! empty ( $ block -> copy_id ) ) ) { if ( $ this -> Blocks -> delete ( $ block ) ) { $ this -> Flash -> success ( __d ( 'block' , 'Block was successfully removed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be removed' ) ) ; } } else { $ this -> Flash -> warning ( __d ( 'block' , 'Block not found!' ) ) ; } $ this -> title ( __d ( 'block' , 'Delete Block' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } | Deletes the given block by ID . |
48,086 | protected function _reorder ( ) { if ( ! empty ( $ this -> request -> data [ 'regions' ] ) ) { foreach ( $ this -> request -> data [ 'regions' ] as $ theme => $ regions ) { foreach ( $ regions as $ region => $ ids ) { $ ordering = 0 ; foreach ( $ ids as $ id ) { $ blockRegion = $ this -> Blocks -> BlockRegions -> newEntity ( [ 'id' => $ id , 'theme' => $ theme , 'region' => $ region , 'ordering' => $ ordering ] ) ; $ blockRegion -> isNew ( false ) ; $ this -> Blocks -> BlockRegions -> save ( $ blockRegion ) ; $ ordering ++ ; } } } return true ; } return false ; } | Reorders blocks based on the order provided via POST . |
48,087 | protected function _setRoles ( ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ roles = $ this -> Blocks -> Roles -> find ( 'list' ) ; $ this -> set ( 'roles' , $ roles ) ; } | Sets roles variable for later use in FormHelper . |
48,088 | protected function _setRegions ( $ block = null ) { $ regions = plugin ( ) -> filter ( function ( $ plugin ) { return $ plugin -> isTheme ; } ) -> map ( function ( $ theme ) use ( $ block ) { $ value = '' ; if ( $ block !== null && $ block -> has ( 'region' ) ) { foreach ( $ block -> region as $ blockRegion ) { if ( $ blockRegion -> theme == $ theme -> name ) { $ value = $ blockRegion -> region ; break ; } } } return [ 'theme_machine_name' => $ theme -> name , 'theme_human_name' => $ theme -> humanName , 'description' => $ theme -> composer [ 'description' ] , 'regions' => ( array ) $ theme -> composer [ 'extra' ] [ 'regions' ] , 'value' => $ value , ] ; } ) ; $ this -> set ( 'regions' , $ regions ) ; } | Sets regions variable for later use in FormHelper . |
48,089 | protected function _patchEntity ( $ block ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ data = [ 'region' => [ ] ] ; foreach ( $ this -> request -> data ( ) as $ column => $ value ) { if ( $ column == 'region' ) { foreach ( $ value as $ theme => $ region ) { $ tmp = [ 'theme' => $ theme , 'region' => $ region ] ; foreach ( ( array ) $ block -> region as $ blockRegion ) { if ( $ blockRegion -> theme == $ theme ) { $ tmp [ 'id' ] = $ blockRegion -> id ; break ; } } $ data [ $ column ] [ ] = $ tmp ; } } else { $ data [ $ column ] = $ value ; } } if ( $ block -> isNew ( ) ) { $ data [ 'handler' ] = 'Block\Widget\CustomBlockWidget' ; $ block -> set ( 'handler' , 'Block\Widget\CustomBlockWidget' ) ; } $ validator = $ block -> isCustom ( ) ? 'custom' : 'widget' ; return $ this -> Blocks -> patchEntity ( $ block , $ data , [ 'validate' => $ validator , 'entity' => $ block ] ) ; } | Prepares incoming data from Form s POST and patches the given entity . |
48,090 | public function beforeFilter ( Event $ event ) { $ this -> _controller = $ event -> subject ( ) ; $ this -> _controller -> helpers [ 'Breadcrumb' ] = [ 'className' => 'Menu\View\Helper\BreadcrumbHelper' ] ; } | Initializes BreadcrumbComponent for use in the controller . |
48,091 | protected function _urlChunk ( $ url = null ) { if ( empty ( $ url ) ) { $ url = '/' . $ this -> _controller -> request -> url ; } $ cacheKey = 'urlChunk_' . md5 ( $ url ) ; $ cache = static :: cache ( $ cacheKey ) ; if ( $ cache !== null ) { return $ cache ; } $ parsedURL = Router :: parse ( $ url ) ; $ out = [ $ url ] ; $ passArguments = [ ] ; if ( ! empty ( $ parsedURL [ '?' ] ) ) { unset ( $ parsedURL [ '?' ] ) ; } if ( ! empty ( $ parsedURL [ 'pass' ] ) ) { $ passArguments = $ parsedURL [ 'pass' ] ; $ parsedURL [ 'pass' ] = null ; $ parsedURL = array_merge ( $ parsedURL , $ passArguments ) ; } if ( $ parsedURL [ 'action' ] === 'index' ) { $ parsedURL [ 'action' ] = null ; $ out [ ] = Router :: url ( $ parsedURL ) ; } if ( ! empty ( $ parsedURL [ 'plugin' ] ) && strtolower ( $ parsedURL [ 'controller' ] ) === strtolower ( $ parsedURL [ 'plugin' ] ) ) { $ parsedURL [ 'plugin' ] = null ; $ out [ ] = Router :: url ( $ parsedURL ) ; } foreach ( array_reverse ( $ passArguments ) as $ pass ) { unset ( $ parsedURL [ array_search ( $ pass , $ parsedURL ) ] ) ; $ out [ ] = Router :: url ( $ parsedURL ) ; } $ out = array_map ( function ( $ value ) { if ( str_starts_with ( $ value , $ this -> _controller -> request -> base ) ) { return str_replace_once ( $ this -> _controller -> request -> base , '' , $ value ) ; } return $ value ; } , $ out ) ; return static :: cache ( $ cacheKey , array_unique ( $ out ) ) ; } | Returns possible URL combinations for the given URL or current request s URL . |
48,092 | public static function formatter ( $ view , $ field ) { switch ( $ field -> viewModeSettings [ 'formatter' ] ) { case 'link' : $ out = $ view -> element ( 'Field.FileField/display_link' , compact ( 'field' ) ) ; break ; case 'table' : $ out = $ view -> element ( 'Field.FileField/display_table' , compact ( 'field' ) ) ; break ; case 'url' : default : $ out = $ view -> element ( 'Field.FileField/display_url' , compact ( 'field' ) ) ; break ; } return $ out ; } | Renders the given custom field . |
48,093 | public static function fileIcon ( $ mime , $ iconsDirectory = false ) { if ( ! $ iconsDirectory ) { $ iconsDirectory = Plugin :: path ( 'Field' ) . 'webroot/img/file-icons/' ; } $ dashedMime = strtr ( $ mime , [ '/' => '-' ] ) ; if ( is_readable ( "{$iconsDirectory}{$dashedMime}.png" ) ) { return "{$dashedMime}.png" ; } $ genericMime = ( string ) static :: fileIconMap ( $ mime ) ; if ( $ genericMime && is_readable ( "{$iconsDirectory}{$genericMime}.png" ) ) { return "{$genericMime}.png" ; } if ( preg_match ( '/^(audio|image|text|video)\//' , $ mime , $ matches ) ) { if ( is_readable ( "{$iconsDirectory}{$matches[1]}-x-generic.png" ) ) { return "{$matches[1]}-x-generic.png" ; } } if ( is_readable ( "{$iconsDirectory}/application-octet-stream.png" ) ) { return 'application-octet-stream.png' ; } return false ; } | Creates a path to the icon for a file mime . |
48,094 | public static function fileIconMap ( $ mime ) { foreach ( FileIconMap :: $ map as $ icon => $ mimeList ) { if ( in_array ( $ mime , $ mimeList ) ) { return $ icon ; } } return false ; } | Determine the generic icon MIME package based on a file s MIME type . |
48,095 | public static function ext ( $ fileName ) { if ( strpos ( $ fileName , '.' ) === false ) { return '' ; } return strtolower ( substr ( $ fileName , strrpos ( $ fileName , '.' ) + 1 , strlen ( $ fileName ) ) ) ; } | Get file extension . |
48,096 | public static function match ( $ version , $ constraints = null ) { if ( is_string ( $ version ) && empty ( $ version ) ) { return false ; } if ( empty ( $ constraints ) || $ version == $ constraints ) { return true ; } $ parser = new VersionParser ( ) ; $ modifierRegex = '[\-\@]dev(\#\w+)?' ; $ constraints = preg_replace ( '{' . $ modifierRegex . '$}i' , '' , $ constraints ) ; $ version = $ parser -> normalize ( $ version ) ; $ version = preg_replace ( '{' . $ modifierRegex . '$}i' , '' , $ version ) ; if ( empty ( $ constraints ) || $ version == $ constraints ) { return true ; } try { $ pkgConstraint = new VersionConstraint ( '==' , $ version ) ; $ constraintObjects = $ parser -> parseConstraints ( $ constraints ) ; return $ constraintObjects -> matches ( $ pkgConstraint ) ; } catch ( \ Exception $ ex ) { return false ; } } | Check whether a version matches the given constraint . |
48,097 | public function toPHP ( $ value , Driver $ driver ) { if ( $ this -> _isSerialized ( $ value ) ) { $ value = unserialize ( $ value ) ; } return $ value ; } | Deserialize the stored information if it was serialized before . |
48,098 | public function shortcodeBlock ( Event $ event , array $ atts , $ content , $ tag ) { $ out = '' ; if ( isset ( $ atts [ 0 ] ) ) { $ id = intval ( $ atts [ 0 ] ) ; try { $ block = TableRegistry :: get ( 'Block.Blocks' ) -> get ( $ id ) ; $ out = $ event -> subject ( ) -> render ( $ block ) ; } catch ( \ Exception $ ex ) { $ out = ! Configure :: read ( 'debug' ) ? '' : "<!-- block #{$id} not found ; } } return $ out ; } | Implements the block shortcode . |
48,099 | public function edit ( View $ view ) { $ handler = $ this -> get ( 'metadata' ) -> get ( 'handler' ) ; if ( class_exists ( $ handler ) ) { $ handler = new $ handler ( ) ; return $ handler -> edit ( $ this , $ view ) ; } return '' ; } | Renders field in edit mode . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.