idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
54,000
public function deleteFiles ( ) { if ( $ this -> isAbsolute ( ) ) { if ( $ this -> isDir ( ) ) { return $ this -> deleteFilesAction ( $ this -> getPathname ( ) , false ) ; } else { throw new FileException ( 'Given path is a file and not a directory.' ) ; } } else { throw new FileException ( 'Given file path is not a absolute path.' ) ; } }
delete files of the current directory
54,001
public function deleteAllFiles ( ) { if ( $ this -> isAbsolute ( ) ) { if ( $ this -> isDir ( ) ) { return $ this -> deleteFilesAction ( $ this -> getPathname ( ) , true ) ; } else { throw new FileException ( 'Given path is a file and not a directory.' ) ; } } else { throw new FileException ( 'Given file path is not a absolute path.' ) ; } }
delete files of the current directory recursive
54,002
public function move ( $ pathname ) { if ( ! empty ( $ pathname ) ) { if ( $ pathname instanceof \ SplFileInfo ) { $ targetFile = $ pathname ; } else { $ targetFile = new File ( $ pathname ) ; } if ( $ this -> exists ( ) ) { if ( $ targetFile -> isDir ( ) ) { $ targetPathname = $ targetFile -> getPathname ( ) . self :: PATH_SEPARATOR . $ this -> getBasename ( ) ; if ( rename ( $ this -> getPathname ( ) , $ targetPathname ) ) { parent :: __construct ( $ targetPathname ) ; return true ; } } else { throw new FileException ( 'Move failed, target directory do not exist.' ) ; } } else { throw new FileException ( 'Move failed, source file or directory do not exist.' ) ; } } else { throw new FileException ( 'Move failed, because given filepath is empty.' ) ; } return false ; }
move file to a given directory
54,003
public function copy ( $ pathname ) { if ( ! empty ( $ pathname ) ) { if ( $ pathname instanceof \ SplFileInfo ) { $ targetFile = $ pathname ; } else { $ targetFile = new File ( $ pathname ) ; } if ( $ targetFile -> isDir ( ) ) { $ targetPathname = $ targetFile -> getPathname ( ) . self :: PATH_SEPARATOR . $ this -> getBasename ( ) ; if ( $ this -> isFile ( ) ) { if ( copy ( $ this -> getPathname ( ) , $ targetPathname ) ) { parent :: __construct ( $ targetPathname ) ; return true ; } } elseif ( $ this -> isDir ( ) ) { if ( $ this -> copyAction ( $ this -> getPathname ( ) , $ targetPathname , true ) ) { parent :: __construct ( $ targetPathname ) ; return true ; } } else { throw new FileException ( 'Copy failed, source file or directory do not exist.' ) ; } } else { throw new FileException ( 'Copy failed, target directory do not exist.' ) ; } } else { throw new FileException ( 'Copy failed, because given filepath is empty.' ) ; } return false ; }
copy file to a given directory
54,004
public function getOwnerName ( ) { $ userId = $ this -> getOwner ( ) ; if ( $ userId ) { $ userData = posix_getpwuid ( $ userId ) ; return ( ( isset ( $ userData [ 'name' ] ) ) ? $ userData [ 'name' ] : null ) ; } return false ; }
return user name of the file or directory
54,005
public function getGroupName ( ) { $ userId = $ this -> getGroup ( ) ; if ( $ userId ) { $ userData = posix_getgrgid ( $ userId ) ; return ( ( isset ( $ userData [ 'name' ] ) ) ? $ userData [ 'name' ] : null ) ; } return false ; }
return user group name of the file or directory
54,006
public function getSize ( ) { $ filePath = $ this -> getPathname ( ) ; $ size = - 1 ; $ isWin = ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) == 'WIN' ) ; $ execWorks = ( function_exists ( 'exec' ) && ! ini_get ( 'safe_mode' ) && exec ( 'echo EXEC' ) == 'EXEC' ) ; if ( $ isWin ) { if ( $ execWorks ) { $ cmd = "for %F in (\"$filePath\") do @echo %~zF" ; exec ( $ cmd , $ output ) ; if ( is_array ( $ output ) ) { $ result = trim ( implode ( "\n" , $ output ) ) ; if ( ctype_digit ( $ result ) ) { $ size = $ result ; } } } if ( class_exists ( 'COM' ) && $ size > - 1 ) { $ fsobj = new \ COM ( 'Scripting.FileSystemObject' ) ; $ file = $ fsobj -> GetFile ( $ filePath ) ; $ result = $ file -> Size ; if ( ctype_digit ( $ result ) ) { $ size = $ result ; } } } else { $ result = trim ( "stat -c%s $filePath" ) ; if ( ctype_digit ( $ result ) ) { $ size = $ result ; } } if ( $ size < 0 ) { $ size = filesize ( $ filePath ) ; } return $ size ; }
return file size in bytes
54,007
public function listAll ( ) { $ iterator = new \ FilesystemIterator ( $ this -> getAbsolutePath ( ) ) ; $ iterator -> setInfoClass ( get_class ( $ this ) ) ; return $ iterator ; }
returns files and directories
54,008
public function loadUnawareEntries ( ) { if ( ! $ this -> actionManager ) { return ; } $ unawareEntries = array ( ) ; foreach ( $ this -> coll as $ context => $ entries ) { foreach ( $ entries as $ entry ) { if ( $ entry instanceof EntryUnaware ) { $ unawareEntries [ $ entry -> getIdent ( ) ] = $ entry -> getIdent ( ) ; } } } if ( empty ( $ unawareEntries ) ) { return ; } $ components = $ this -> actionManager -> findComponents ( $ unawareEntries ) ; $ componentsIndexedByIdent = array ( ) ; foreach ( $ components as $ component ) { $ componentsIndexedByIdent [ $ component -> getHash ( ) ] = $ component ; } unset ( $ components ) ; $ nbComponentCreated = 0 ; foreach ( $ this -> coll as $ context => $ entries ) { foreach ( $ entries as $ entry ) { if ( $ entry instanceof EntryUnaware ) { $ ident = $ entry -> getIdent ( ) ; if ( array_key_exists ( $ ident , $ componentsIndexedByIdent ) ) { $ entry -> setSubject ( $ componentsIndexedByIdent [ $ ident ] ) ; } else { if ( $ entry -> isStrict ( ) ) { throw new \ Exception ( sprintf ( 'Component with ident "%s" is unknown' , $ entry -> getIdent ( ) ) ) ; } $ component = $ this -> actionManager -> createComponent ( $ entry -> getSubjectModel ( ) , $ entry -> getSubjectId ( ) , false ) ; $ nbComponentCreated ++ ; if ( ( $ nbComponentCreated % $ this -> batchSize ) == 0 ) { $ this -> actionManager -> flushComponents ( ) ; } if ( null === $ component ) { throw new \ Exception ( sprintf ( 'Component with ident "%s" cannot be created' , $ entry -> getIdent ( ) ) ) ; } $ entry -> setSubject ( $ component ) ; $ componentsIndexedByIdent [ $ component -> getHash ( ) ] = $ component ; } } } } if ( $ nbComponentCreated > 0 ) { $ this -> actionManager -> flushComponents ( ) ; } }
Load unaware entries instead of having 1 call by entry to fetch component you can add unaware entries . Component will be created or exception will be thrown if it does not exist
54,009
protected function getQuotedFormatString ( ) { $ validPattern = '%(\!?[2-5]\d\d(\,[2-5]\d\d)*)?(\<|\>)?(\{[^\}]*\})?[a-z]' ; $ pattern = preg_replace_callback ( '/(?<before>' . $ validPattern . '?)?(?<match>.+?)(?<after>' . $ validPattern . ')?/i' , function ( array $ matches ) { $ before = isset ( $ matches [ 'before' ] ) ? $ matches [ 'before' ] : '' ; $ after = isset ( $ matches [ 'after' ] ) ? $ matches [ 'after' ] : '' ; $ match = preg_quote ( $ matches [ 'match' ] , '/' ) ; return "{$before}{$match}{$after}" ; } , $ this -> format ) ; return $ pattern ; }
Quotes characters which are not included in log format directives and returns quoted format string .
54,010
protected function sortFilters ( ) { usort ( $ this -> filters , function ( FilterInterface $ a , FilterInterface $ b ) { $ a = $ a -> getPriority ( ) ; $ b = $ b -> getPriority ( ) ; if ( $ a == $ b ) { return 0 ; } return $ a < $ b ? - 1 : 1 ; } ) ; $ this -> sorted = true ; }
Sort filters by priority .
54,011
public function get ( $ namespace , $ index ) { if ( ! isset ( $ this -> storage [ $ namespace ] [ $ index ] ) ) { return null ; } return $ this -> storage [ $ namespace ] [ $ index ] ; }
Returns key from local storage
54,012
public function formatTime ( $ time ) { if ( $ this -> timeFormat === null || $ this -> timeFormat === false ) { return $ time ; } $ dateTime = new \ DateTime ( $ time ) ; if ( $ this -> timeFormat === true ) { return $ dateTime ; } return $ dateTime -> format ( $ this -> timeFormat ) ; }
Converts time to previously set format .
54,013
public function accept ( ) { $ file = $ this -> current ( ) ; if ( $ file -> getType ( ) == $ this -> getType ( ) ) { return true ; } return false ; }
filter iterator element
54,014
private function setSubject ( $ blockId ) : BaseBlock { $ block = $ this -> admin -> getObject ( $ blockId ) ; if ( ! $ block ) { throw $ this -> createNotFoundException ( sprintf ( 'Unable to find block with id %d' , $ blockId ) ) ; } $ this -> admin -> setSubject ( $ block ) ; return $ block ; }
Initialize the admin subject to contextualize checkAccess verification .
54,015
protected function _insertQueryTranslator ( $ query ) { $ v = $ query -> clause ( 'values' ) ; if ( count ( $ v -> values ( ) ) === 1 || $ v -> query ( ) ) { return $ query ; } $ newQuery = $ query -> getConnection ( ) -> newQuery ( ) ; $ cols = $ v -> columns ( ) ; $ placeholder = 0 ; $ replaceQuery = false ; foreach ( $ v -> values ( ) as $ k => $ val ) { $ fillLength = count ( $ cols ) - count ( $ val ) ; if ( $ fillLength > 0 ) { $ val = array_merge ( $ val , array_fill ( 0 , $ fillLength , null ) ) ; } foreach ( $ val as $ col => $ attr ) { if ( ! ( $ attr instanceof ExpressionInterface ) ) { $ val [ $ col ] = sprintf ( ':c%d' , $ placeholder ) ; $ placeholder ++ ; } } $ select = array_combine ( $ cols , $ val ) ; if ( $ k === 0 ) { $ replaceQuery = true ; $ newQuery -> select ( $ select ) -> from ( 'DUAL' ) ; continue ; } $ q = $ newQuery -> getConnection ( ) -> newQuery ( ) ; $ newQuery -> unionAll ( $ q -> select ( $ select ) -> from ( 'DUAL' ) ) ; } if ( $ replaceQuery ) { $ v -> query ( $ newQuery ) ; } return $ query ; }
Transforms an insert query that is meant to insert multiple rows at a time otherwise it leaves the query untouched .
54,016
public function writeLine ( $ string ) { $ string = rtrim ( $ string , "\n\r" ) . PHP_EOL ; if ( $ this -> getFileObject ( ) -> fwrite ( $ string ) === false ) { throw new FileWriterException ( 'write line to file failed.' ) ; } return $ this ; }
add string to file
54,017
public function getComponentDataResolver ( ) { if ( empty ( $ this -> componentDataResolver ) || ! $ this -> componentDataResolver instanceof ComponentDataResolverInterface ) { throw new \ Exception ( 'Component data resolver not set' ) ; } return $ this -> componentDataResolver ; }
Gets the component data resolver .
54,018
protected function resolveModelAndIdentifier ( $ model , $ identifier ) { $ resolve = new ResolveComponentModelIdentifier ( $ model , $ identifier ) ; return $ this -> getComponentDataResolver ( ) -> resolveComponentData ( $ resolve ) ; }
Resolves the model and identifier .
54,019
protected function getComponentFromResolvedComponentData ( ResolvedComponentData $ resolved ) { $ component = new $ this -> componentClass ( ) ; $ component -> setModel ( $ resolved -> getModel ( ) ) ; $ component -> setData ( $ resolved -> getData ( ) ) ; $ component -> setIdentifier ( $ resolved -> getIdentifier ( ) ) ; return $ component ; }
Creates a new component object from the resolved data .
54,020
public function registerParameters ( ContainerBuilder $ container , array $ config ) : void { $ container -> setParameter ( 'sonata.dashboard.block.class' , $ config [ 'class' ] [ 'block' ] ) ; $ container -> setParameter ( 'sonata.dashboard.dashboard.class' , $ config [ 'class' ] [ 'dashboard' ] ) ; $ container -> setParameter ( 'sonata.dashboard.admin.block.entity' , $ config [ 'class' ] [ 'block' ] ) ; $ container -> setParameter ( 'sonata.dashboard.admin.dashboard.entity' , $ config [ 'class' ] [ 'dashboard' ] ) ; $ container -> setParameter ( 'sonata.dashboard.admin.dashboard.templates.compose' , $ config [ 'templates' ] [ 'compose' ] ) ; $ container -> setParameter ( 'sonata.dashboard.admin.dashboard.templates.compose_container_show' , $ config [ 'templates' ] [ 'compose_container_show' ] ) ; $ container -> setParameter ( 'sonata.dashboard.admin.dashboard.templates.render' , $ config [ 'templates' ] [ 'render' ] ) ; $ container -> setParameter ( 'sonata.dashboard.default_container' , $ config [ 'default_container' ] ) ; }
Registers service parameters from bundle configuration .
54,021
protected function normalizeAbsolutePath ( AbsolutePathInterface $ path ) { return $ this -> factory ( ) -> createFromAtoms ( $ this -> normalizeAbsolutePathAtoms ( $ path -> atoms ( ) ) , true , false ) ; }
Normalize the supplied absolute path .
54,022
protected function normalizeRelativePath ( RelativePathInterface $ path ) { return $ this -> factory ( ) -> createFromAtoms ( $ this -> normalizeRelativePathAtoms ( $ path -> atoms ( ) ) , false , false ) ; }
Normalize the supplied relative path .
54,023
protected function normalizeAbsolutePathAtoms ( array $ atoms ) { $ resultingAtoms = array ( ) ; foreach ( $ atoms as $ atom ) { if ( AbstractPath :: PARENT_ATOM === $ atom ) { array_pop ( $ resultingAtoms ) ; } elseif ( AbstractPath :: SELF_ATOM !== $ atom ) { $ resultingAtoms [ ] = $ atom ; } } return $ resultingAtoms ; }
Normalize the supplied path atoms for an absolute path .
54,024
protected function normalizeRelativePathAtoms ( array $ atoms ) { $ resultingAtoms = array ( ) ; $ resultingAtomsCount = 0 ; $ numAtoms = count ( $ atoms ) ; for ( $ i = 0 ; $ i < $ numAtoms ; $ i ++ ) { if ( AbstractPath :: SELF_ATOM !== $ atoms [ $ i ] ) { $ resultingAtoms [ ] = $ atoms [ $ i ] ; $ resultingAtomsCount ++ ; } if ( $ resultingAtomsCount > 1 && AbstractPath :: PARENT_ATOM === $ resultingAtoms [ $ resultingAtomsCount - 1 ] && AbstractPath :: PARENT_ATOM !== $ resultingAtoms [ $ resultingAtomsCount - 2 ] ) { array_splice ( $ resultingAtoms , $ resultingAtomsCount - 2 , 2 ) ; $ resultingAtomsCount -= 2 ; } } if ( count ( $ resultingAtoms ) < 1 ) { $ resultingAtoms = array ( AbstractPath :: SELF_ATOM ) ; } return $ resultingAtoms ; }
Normalize the supplied path atoms for a relative path .
54,025
protected function findType ( $ foreignKey , $ remote ) { if ( $ remote ) { if ( $ this -> isBelongsToMany ( $ foreignKey ) ) { return 'belongsToMany' ; } if ( $ this -> isHasOne ( $ foreignKey ) ) { return 'hasOne' ; } return 'hasMany' ; } else { return 'belongsTo' ; } }
Try to determine the type of the relation .
54,026
protected function isBelongsToMany ( $ foreignKey ) { $ remote = $ this -> describes [ $ foreignKey -> TABLE_NAME ] ; $ count = 0 ; foreach ( $ remote as $ field ) { if ( $ field -> Key == 'PRI' ) { $ count ++ ; } } if ( $ count == 2 ) { return true ; } return false ; }
Many to many .
54,027
public static function showTables ( $ prefix ) { $ results = static :: select ( 'SHOW FULL TABLES' ) ; $ tables = [ ] ; $ views = [ ] ; $ first = '' ; foreach ( $ results as $ result ) { foreach ( $ result as $ value ) { $ first = $ value ; break ; } if ( ! empty ( $ prefix ) ) { if ( ! starts_with ( $ first , $ prefix ) ) { continue ; } } if ( $ result -> Table_type == 'VIEW' ) { $ views [ ] = $ first ; } else { $ tables [ ] = $ first ; } } return [ 'tables' => $ tables , 'views' => $ views ] ; }
Execute a SHOW TABLES query .
54,028
public function generateListFolderCriterion ( Location $ location , array $ excludeContentTypeIdentifiers = array ( ) , array $ languages = array ( ) ) { $ criteria = array ( ) ; $ criteria [ ] = new Criterion \ Visibility ( Criterion \ Visibility :: VISIBLE ) ; $ criteria [ ] = new Criterion \ ParentLocationId ( $ location -> id ) ; $ criteria [ ] = new Criterion \ LogicalNot ( new Criterion \ ContentTypeIdentifier ( $ excludeContentTypeIdentifiers ) ) ; $ criteria [ ] = new Criterion \ LanguageCode ( $ languages ) ; return new Criterion \ LogicalAnd ( $ criteria ) ; }
Generate criterion list to be used to list article .
54,029
public function generateSubContentCriterion ( Location $ location , array $ includedContentTypeIdentifiers = array ( ) , array $ languages = array ( ) ) { $ criteria = array ( ) ; $ criteria [ ] = new Criterion \ Visibility ( Criterion \ Visibility :: VISIBLE ) ; $ criteria [ ] = new Criterion \ ContentTypeIdentifier ( $ includedContentTypeIdentifiers ) ; $ criteria [ ] = new Criterion \ LanguageCode ( $ languages ) ; $ criteria [ ] = new Criterion \ ParentLocationId ( $ location -> id ) ; return new Criterion \ LogicalAnd ( $ criteria ) ; }
Generate criterion list to be used to list sub folder items .
54,030
public function generateContentTypeExcludeCriterion ( array $ excludeContentTypeIdentifiers ) { $ excludeCriterion = array ( ) ; foreach ( $ excludeContentTypeIdentifiers as $ contentTypeIdentifier ) { $ excludeCriterion [ ] = new Criterion \ LogicalNot ( new Criterion \ ContentTypeIdentifier ( $ contentTypeIdentifier ) ) ; } return new Criterion \ LogicalAnd ( $ excludeCriterion ) ; }
Generates an exclude criterion based on contentType identifiers .
54,031
public function generateLocationIdExcludeCriterion ( array $ excludeLocations ) { $ excludeCriterion = array ( ) ; foreach ( $ excludeLocations as $ location ) { if ( ! $ location instanceof Location ) { throw new InvalidArgumentType ( 'excludeLocations' , 'array of Location objects' ) ; } $ excludeCriterion [ ] = new Criterion \ LogicalNot ( new Criterion \ LocationId ( $ location -> id ) ) ; } return new Criterion \ LogicalAnd ( $ excludeCriterion ) ; }
Generates an exclude criterion based on locationIds .
54,032
public function generateListBlogPostCriterion ( Location $ location , array $ viewParameters , array $ languages = array ( ) ) { $ criteria = array ( ) ; $ criteria [ ] = new Criterion \ Visibility ( Criterion \ Visibility :: VISIBLE ) ; $ criteria [ ] = new Criterion \ Subtree ( $ location -> pathString ) ; $ criteria [ ] = new Criterion \ ContentTypeIdentifier ( array ( 'blog_post' ) ) ; $ criteria [ ] = new Criterion \ LanguageCode ( $ languages ) ; if ( ! empty ( $ viewParameters ) ) { if ( ! empty ( $ viewParameters [ 'month' ] ) && ! empty ( $ viewParameters [ 'year' ] ) ) { $ month = ( int ) $ viewParameters [ 'month' ] ; $ year = ( int ) $ viewParameters [ 'year' ] ; $ date = new DateTime ( "$year-$month-01" ) ; $ date -> setTime ( 00 , 00 , 00 ) ; $ criteria [ ] = new Criterion \ DateMetadata ( Criterion \ DateMetadata :: CREATED , Criterion \ Operator :: BETWEEN , array ( $ date -> getTimestamp ( ) , $ date -> add ( new DateInterval ( 'P1M' ) ) -> getTimestamp ( ) , ) ) ; } } return new Criterion \ LogicalAnd ( $ criteria ) ; }
Generate criterion list to be used to list blog_posts .
54,033
public function createFromDriveAndAtoms ( $ atoms , $ drive = null , $ isAbsolute = null , $ isAnchored = null , $ hasTrailingSeparator = null ) { if ( null === $ isAnchored ) { $ isAnchored = false ; } if ( null === $ isAbsolute ) { $ isAbsolute = null !== $ drive && ! $ isAnchored ; } if ( $ isAbsolute && $ isAnchored ) { throw new InvalidPathStateException ( 'Absolute Windows paths cannot be anchored.' ) ; } if ( $ isAbsolute ) { return new AbsoluteWindowsPath ( $ drive , $ atoms , $ hasTrailingSeparator ) ; } return new RelativeWindowsPath ( $ atoms , $ drive , $ isAnchored , $ hasTrailingSeparator ) ; }
Creates a new path instance from a set of path atoms and a drive specifier .
54,034
public function indexAction ( ) { $ footerContentId = $ this -> container -> getParameter ( 'ezdemo.footer.content_id' ) ; $ footerContent = $ this -> getRepository ( ) -> getContentService ( ) -> loadContent ( $ footerContentId ) ; $ response = new Response ( ) ; $ response -> setPublic ( ) ; $ response -> setSharedMaxAge ( 86400 ) ; $ response -> headers -> set ( 'X-Location-Id' , $ footerContent -> contentInfo -> mainLocationId ) ; $ response -> setVary ( 'X-User-Hash' ) ; return $ this -> render ( 'eZDemoBundle::page_footer.html.twig' , array ( 'content' => $ footerContent ) , $ response ) ; }
Footer main action .
54,035
public function start ( ) { $ tablesAndViews = $ this -> dataBase -> showTables ( $ this -> prefix ) ; $ this -> tables = $ tablesAndViews [ 'tables' ] ; $ this -> views = $ tablesAndViews [ 'views' ] ; $ this -> foreignKeys [ 'all' ] = $ this -> dataBase -> getAllForeignKeys ( ) ; $ this -> foreignKeys [ 'ordered' ] = $ this -> getAllForeignKeysOrderedByTable ( ) ; foreach ( $ this -> tables as $ key => $ table ) { $ this -> describes [ $ table ] = $ this -> dataBase -> describeTable ( $ table ) ; if ( $ this -> isManyToMany ( $ table , true ) ) { $ this -> junctionTables [ ] = $ table ; unset ( $ this -> tables [ $ key ] ) ; } } unset ( $ table ) ; foreach ( $ this -> tables as $ table ) { $ model = new Model ( ) ; $ model -> buildModel ( $ table , $ this -> baseModel , $ this -> describes , $ this -> foreignKeys , $ this -> namespace , $ this -> prefix ) ; $ model -> createModel ( ) ; $ result = $ this -> writeFile ( $ table , $ model ) ; echo 'file written: ' . $ result [ 'filename' ] . ' - ' . $ result [ 'result' ] . ' bytes' . BR ; flush ( ) ; } echo 'done' . BR ; }
This is where we start .
54,036
protected function isManyToMany ( $ table , $ checkForeignKey = true ) { $ describe = $ this -> dataBase -> describeTable ( $ table ) ; $ count = 0 ; foreach ( $ describe as $ field ) { if ( count ( $ describe ) < 3 ) { $ type = $ this -> parseType ( $ field -> Type ) ; if ( $ type [ 'type' ] == 'int' && $ field -> Key == 'PRI' ) { if ( $ checkForeignKey && $ this -> isForeignKey ( $ table , $ field -> Field ) ) { $ count ++ ; } if ( ! $ checkForeignKey ) { $ count ++ ; } } } } if ( $ count == 2 ) { return true ; } return false ; }
Detect many to many tables .
54,037
protected function writeFile ( $ table , $ model ) { $ filename = StringUtils :: prettifyTableName ( $ table , $ this -> prefix ) . '.php' ; if ( ! is_dir ( $ this -> path ) ) { $ oldUMask = umask ( 0 ) ; echo 'creating path: ' . $ this -> path . LF ; mkdir ( $ this -> path , 0777 , true ) ; umask ( $ oldUMask ) ; if ( ! is_dir ( $ this -> path ) ) { throw new Exception ( 'dir ' . $ this -> path . ' could not be created' ) ; } } $ result = file_put_contents ( $ this -> path . '/' . $ filename , $ model ) ; return [ 'filename' => $ this -> path . '/' . $ filename , 'result' => $ result ] ; }
Write the actual TableName . php file .
54,038
protected function getAllForeignKeysOrderedByTable ( ) { $ results = $ this -> dataBase -> getAllForeignKeys ( ) ; $ results = ArrayHelpers :: orderArrayByValue ( $ results , 'TABLE_NAME' ) ; return $ results ; }
Return an array with tables with arrays of foreign keys .
54,039
protected function isForeignKey ( $ table , $ field ) { foreach ( $ this -> foreignKeys [ 'all' ] as $ entry ) { if ( $ entry -> COLUMN_NAME == $ field && $ entry -> TABLE_NAME == $ table ) { return true ; } } return false ; }
Check if a given field in a table is a foreign key .
54,040
protected function isPrefix ( $ name ) { if ( empty ( $ this -> prefix ) ) { return true ; } return starts_with ( $ name , $ this -> prefix ) ; }
Check if the given name starts with the current prefix .
54,041
public function showFolderListAsideViewAction ( ContentView $ view ) { $ subContentCriteria = $ this -> get ( 'ezdemo.criteria_helper' ) -> generateSubContentCriterion ( $ view -> getLocation ( ) , $ this -> container -> getParameter ( 'ezdemo.folder.folder_tree.included_content_types' ) , $ this -> getConfigResolver ( ) -> getParameter ( 'languages' ) ) ; $ subContentQuery = new LocationQuery ( ) ; $ subContentQuery -> query = $ subContentCriteria ; $ subContentQuery -> sortClauses = array ( new SortClause \ ContentName ( ) , ) ; $ subContentQuery -> performCount = false ; $ searchService = $ this -> getRepository ( ) -> getSearchService ( ) ; $ subContent = $ searchService -> findLocations ( $ subContentQuery ) ; $ treeChildItems = array ( ) ; foreach ( $ subContent -> searchHits as $ hit ) { $ treeChildItems [ ] = $ hit -> valueObject ; } $ view -> addParameters ( [ 'treeChildItems' => $ treeChildItems ] ) ; return $ view ; }
Displays the sub folder if it exists .
54,042
public function showFolderListAction ( Request $ request , ContentView $ view ) { $ languages = $ this -> getConfigResolver ( ) -> getParameter ( 'languages' ) ; $ criteria = $ this -> get ( 'ezdemo.criteria_helper' ) -> generateListFolderCriterion ( $ view -> getLocation ( ) , $ this -> container -> getParameter ( 'ezdemo.folder.folder_view.excluded_content_types' ) , $ languages ) ; $ query = new LocationQuery ( ) ; $ query -> query = $ criteria ; $ query -> sortClauses = array ( new SortClause \ DatePublished ( ) , ) ; $ pager = new Pagerfanta ( new ContentSearchAdapter ( $ query , $ this -> getRepository ( ) -> getSearchService ( ) ) ) ; $ pager -> setMaxPerPage ( $ this -> container -> getParameter ( 'ezdemo.folder.folder_list.limit' ) ) ; $ pager -> setCurrentPage ( $ request -> get ( 'page' , 1 ) ) ; $ includedContentTypeIdentifiers = $ this -> container -> getParameter ( 'ezdemo.folder.folder_tree.included_content_types' ) ; $ subContentCriteria = $ this -> get ( 'ezdemo.criteria_helper' ) -> generateSubContentCriterion ( $ view -> getLocation ( ) , $ includedContentTypeIdentifiers , $ languages ) ; $ subContentQuery = new LocationQuery ( ) ; $ subContentQuery -> query = $ subContentCriteria ; $ subContentQuery -> sortClauses = array ( new SortClause \ ContentName ( ) , ) ; $ searchService = $ this -> getRepository ( ) -> getSearchService ( ) ; $ subContent = $ searchService -> findLocations ( $ subContentQuery ) ; $ treeItems = array ( ) ; foreach ( $ subContent -> searchHits as $ hit ) { $ treeItems [ ] = $ hit -> valueObject ; } $ view -> addParameters ( [ 'pagerFolder' => $ pager , 'treeItems' => $ treeItems ] ) ; return $ view ; }
Displays the list of article .
54,043
public function sendFeebackMessage ( Feedback $ feedback , $ feedbackEmailFrom , $ feedbackEmailTo ) { $ message = Swift_Message :: newInstance ( ) ; $ message -> setSubject ( $ this -> translator -> trans ( 'eZ Demobundle Feedback form' ) ) -> setFrom ( $ feedbackEmailFrom ) -> setTo ( $ feedbackEmailTo ) -> setBody ( $ this -> templating -> render ( 'eZDemoBundle:email:feedback_form.txt.twig' , array ( 'firstname' => $ feedback -> firstName , 'lastname' => $ feedback -> lastName , 'email' => $ feedback -> email , 'subject' => $ feedback -> subject , 'country' => $ feedback -> country , 'message' => $ feedback -> message , ) ) ) ; $ this -> mailer -> send ( $ message ) ; }
Sends an email based on a feedback form .
54,044
public function renderFeedBlockAction ( $ feedUrl , $ offset = 0 , $ limit = 5 ) { $ response = new Response ( ) ; try { $ response -> setSharedMaxAge ( $ this -> container -> getParameter ( 'ezdemo.cache.feed_reader_ttl' ) ) ; return $ this -> render ( 'eZDemoBundle:frontpage:feed_block.html.twig' , array ( 'feed' => ezcFeed :: parse ( $ feedUrl ) , 'offset' => $ offset , 'limit' => $ limit , ) , $ response ) ; } catch ( Exception $ e ) { $ this -> get ( 'logger' ) -> error ( "An exception has been raised when fetching RSS feed: {$e->getMessage()}" ) ; return $ response ; } }
Renders an RSS feed into HTML . Response is cached for 1 hour .
54,045
public static function indexArrayByValue ( $ input , $ value ) { $ output = [ ] ; foreach ( $ input as $ row ) { $ output [ $ row -> $ value ] = $ row ; } return $ output ; }
Reindex an existing array by a value from the array .
54,046
public function performApiRequest ( $ method , \ Payrexx \ Models \ Base $ model ) { $ params = $ model -> toArray ( $ method ) ; $ params [ 'ApiSignature' ] = base64_encode ( hash_hmac ( 'sha256' , http_build_query ( $ params , null , '&' ) , $ this -> apiSecret , true ) ) ; $ params [ 'instance' ] = $ this -> instance ; $ id = isset ( $ params [ 'id' ] ) ? $ params [ 'id' ] : 0 ; $ apiUrl = sprintf ( self :: API_URL_FORMAT , $ this -> apiBaseDomain , self :: VERSION , $ params [ 'model' ] , $ id ) ; $ response = $ this -> communicationHandler -> requestApi ( $ apiUrl , $ params , $ this -> getHttpMethod ( $ method ) ) ; $ convertedResponse = array ( ) ; if ( ! isset ( $ response [ 'body' ] [ 'data' ] ) || ! is_array ( $ response [ 'body' ] [ 'data' ] ) ) { if ( ! isset ( $ response [ 'body' ] [ 'message' ] ) ) { throw new \ Payrexx \ PayrexxException ( 'Payrexx PHP: Configuration is wrong! Check instance name and API secret' , $ response [ 'info' ] [ 'http_code' ] ) ; } throw new \ Payrexx \ PayrexxException ( $ response [ 'body' ] [ 'message' ] , $ response [ 'info' ] [ 'http_code' ] ) ; } foreach ( $ response [ 'body' ] [ 'data' ] as $ object ) { $ responseModel = $ model -> getResponseModel ( ) ; $ convertedResponse [ ] = $ responseModel -> fromArray ( $ object ) ; } if ( strpos ( $ method , 'One' ) !== false || strpos ( $ method , 'create' ) !== false ) { $ convertedResponse = current ( $ convertedResponse ) ; } return $ convertedResponse ; }
Perform a simple API request by method name and Request model .
54,047
protected function getHttpMethod ( $ method ) { if ( ! $ this -> methodAvailable ( $ method ) ) { throw new \ Payrexx \ PayrexxException ( 'Method ' . $ method . ' not implemented' ) ; } return self :: $ methods [ $ method ] ; }
Gets the HTTP method to use for a specific API method
54,048
public function atomAt ( $ index ) { $ atom = $ this -> atomAtDefault ( $ index ) ; if ( null === $ atom ) { throw new Exception \ UndefinedAtomException ( $ index ) ; } return $ atom ; }
Get a single path atom by index .
54,049
public function atomAtDefault ( $ index , $ default = null ) { $ atoms = $ this -> atoms ( ) ; if ( $ index < 0 ) { $ index = count ( $ atoms ) + $ index ; } if ( array_key_exists ( $ index , $ atoms ) ) { return $ atoms [ $ index ] ; } return $ default ; }
Get a single path atom by index falling back to a default if the index is undefined .
54,050
public function sliceAtoms ( $ index , $ length = null ) { $ atoms = $ this -> atoms ( ) ; if ( null === $ length ) { $ length = count ( $ atoms ) ; } return array_slice ( $ atoms , $ index , $ length ) ; }
Get a subset of the atoms of this path .
54,051
public function name ( ) { $ atoms = $ this -> atoms ( ) ; $ numAtoms = count ( $ atoms ) ; if ( $ numAtoms > 0 ) { return $ atoms [ $ numAtoms - 1 ] ; } return '' ; }
Get this path s name .
54,052
public function nameAtomAt ( $ index ) { $ atom = $ this -> nameAtomAtDefault ( $ index ) ; if ( null === $ atom ) { throw new Exception \ UndefinedAtomException ( $ index ) ; } return $ atom ; }
Get a single path name atom by index .
54,053
public function nameAtomAtDefault ( $ index , $ default = null ) { $ atoms = $ this -> nameAtoms ( ) ; if ( $ index < 0 ) { $ index = count ( $ atoms ) + $ index ; } if ( array_key_exists ( $ index , $ atoms ) ) { return $ atoms [ $ index ] ; } return $ default ; }
Get a single path name atom by index falling back to a default if the index is undefined .
54,054
public function sliceNameAtoms ( $ index , $ length = null ) { $ atoms = $ this -> nameAtoms ( ) ; if ( null === $ length ) { $ length = count ( $ atoms ) ; } return array_slice ( $ atoms , $ index , $ length ) ; }
Get a subset of this path s name atoms .
54,055
public function nameWithoutExtension ( ) { $ atoms = $ this -> nameAtoms ( ) ; if ( count ( $ atoms ) > 1 ) { array_pop ( $ atoms ) ; return implode ( static :: EXTENSION_SEPARATOR , $ atoms ) ; } return $ atoms [ 0 ] ; }
Get this path s name excluding the last extension .
54,056
public function nameSuffix ( ) { $ atoms = $ this -> nameAtoms ( ) ; if ( count ( $ atoms ) > 1 ) { array_shift ( $ atoms ) ; return implode ( static :: EXTENSION_SEPARATOR , $ atoms ) ; } return null ; }
Get all of this path s extensions .
54,057
public function extension ( ) { $ atoms = $ this -> nameAtoms ( ) ; $ numParts = count ( $ atoms ) ; if ( $ numParts > 1 ) { return $ atoms [ $ numParts - 1 ] ; } return null ; }
Get this path s last extension .
54,058
public function contains ( $ needle , $ caseSensitive = null ) { if ( '' === $ needle ) { return true ; } if ( null === $ caseSensitive ) { $ caseSensitive = false ; } if ( $ caseSensitive ) { return false !== mb_strpos ( $ this -> string ( ) , $ needle ) ; } return false !== mb_stripos ( $ this -> string ( ) , $ needle ) ; }
Determine if this path contains a substring .
54,059
public function endsWith ( $ needle , $ caseSensitive = null ) { if ( '' === $ needle ) { return true ; } if ( null === $ caseSensitive ) { $ caseSensitive = false ; } $ end = mb_substr ( $ this -> string ( ) , - mb_strlen ( $ needle ) ) ; if ( $ caseSensitive ) { return $ end === $ needle ; } return mb_strtolower ( $ end ) === mb_strtolower ( $ needle ) ; }
Determine if this path ends with a substring .
54,060
public function matches ( $ pattern , $ caseSensitive = null , $ flags = null ) { if ( null === $ caseSensitive ) { $ caseSensitive = false ; } if ( null === $ flags ) { $ flags = 0 ; } if ( ! $ caseSensitive ) { $ flags = $ flags | FNM_CASEFOLD ; } return fnmatch ( $ pattern , $ this -> string ( ) , $ flags ) ; }
Determine if this path matches a wildcard pattern .
54,061
public function matchesRegex ( $ pattern , array & $ matches = null , $ flags = null , $ offset = null ) { if ( null === $ flags ) { $ flags = 0 ; } if ( null === $ offset ) { $ offset = 0 ; } return 1 === preg_match ( $ pattern , $ this -> string ( ) , $ matches , $ flags , $ offset ) ; }
Determine if this path matches a regular expression .
54,062
public function nameContains ( $ needle , $ caseSensitive = null ) { if ( '' === $ needle ) { return true ; } if ( null === $ caseSensitive ) { $ caseSensitive = false ; } if ( $ caseSensitive ) { return false !== mb_strpos ( $ this -> name ( ) , $ needle ) ; } return false !== mb_stripos ( $ this -> name ( ) , $ needle ) ; }
Determine if this path s name contains a substring .
54,063
public function nameMatches ( $ pattern , $ caseSensitive = null , $ flags = null ) { if ( null === $ caseSensitive ) { $ caseSensitive = false ; } if ( null === $ flags ) { $ flags = 0 ; } if ( ! $ caseSensitive ) { $ flags = $ flags | FNM_CASEFOLD ; } return fnmatch ( $ pattern , $ this -> name ( ) , $ flags ) ; }
Determine if this path s name matches a wildcard pattern .
54,064
public function nameMatchesRegex ( $ pattern , array & $ matches = null , $ flags = null , $ offset = null ) { if ( null === $ flags ) { $ flags = 0 ; } if ( null === $ offset ) { $ offset = 0 ; } return 1 === preg_match ( $ pattern , $ this -> name ( ) , $ matches , $ flags , $ offset ) ; }
Determine if this path s name matches a regular expression .
54,065
public function parent ( $ numLevels = null ) { if ( null === $ numLevels ) { $ numLevels = 1 ; } return $ this -> createPath ( array_merge ( $ this -> atoms ( ) , array_fill ( 0 , $ numLevels , static :: PARENT_ATOM ) ) , $ this instanceof AbsolutePathInterface , false ) ; }
Get the parent of this path a specified number of levels up .
54,066
public function stripTrailingSlash ( ) { if ( ! $ this -> hasTrailingSeparator ( ) ) { return $ this ; } return $ this -> createPath ( $ this -> atoms ( ) , $ this instanceof AbsolutePathInterface , false ) ; }
Strips the trailing slash from this path .
54,067
public function joinAtomSequence ( $ atoms ) { if ( ! is_array ( $ atoms ) ) { $ atoms = iterator_to_array ( $ atoms ) ; } return $ this -> createPath ( array_merge ( $ this -> atoms ( ) , $ atoms ) , $ this instanceof AbsolutePathInterface , false ) ; }
Joins a sequence of atoms to this path .
54,068
public function joinTrailingSlash ( ) { if ( $ this -> hasTrailingSeparator ( ) ) { return $ this ; } return $ this -> createPath ( $ this -> atoms ( ) , $ this instanceof AbsolutePathInterface , true ) ; }
Adds a trailing slash to this path .
54,069
public function joinExtensionSequence ( $ extensions ) { if ( ! is_array ( $ extensions ) ) { $ extensions = iterator_to_array ( $ extensions ) ; } $ atoms = $ this -> nameAtoms ( ) ; if ( array ( '' , '' ) === $ atoms ) { array_pop ( $ atoms ) ; } return $ this -> replaceName ( implode ( static :: EXTENSION_SEPARATOR , array_merge ( $ atoms , $ extensions ) ) ) ; }
Joins a sequence of extensions to this path .
54,070
public function suffixName ( $ suffix ) { $ name = $ this -> name ( ) ; if ( static :: SELF_ATOM === $ name ) { return $ this -> replaceName ( $ suffix ) ; } return $ this -> replaceName ( $ name . $ suffix ) ; }
Suffixes this path s name with a supplied string .
54,071
public function prefixName ( $ prefix ) { $ name = $ this -> name ( ) ; if ( static :: SELF_ATOM === $ name ) { return $ this -> replaceName ( $ prefix ) ; } return $ this -> replaceName ( $ prefix . $ name ) ; }
Prefixes this path s name with a supplied string .
54,072
public function replace ( $ index , $ replacement , $ length = null ) { $ atoms = $ this -> atoms ( ) ; if ( ! is_array ( $ replacement ) ) { $ replacement = iterator_to_array ( $ replacement ) ; } if ( null === $ length ) { $ length = count ( $ atoms ) ; } array_splice ( $ atoms , $ index , $ length , $ replacement ) ; return $ this -> createPath ( $ atoms , $ this instanceof AbsolutePathInterface , false ) ; }
Replace a section of this path with the supplied atom sequence .
54,073
public function replaceName ( $ name ) { $ atoms = $ this -> atoms ( ) ; $ numAtoms = count ( $ atoms ) ; if ( $ numAtoms > 0 ) { if ( '' === $ name ) { array_pop ( $ atoms ) ; } else { $ atoms [ $ numAtoms - 1 ] = $ name ; } } elseif ( '' !== $ name ) { $ atoms [ ] = $ name ; } return $ this -> createPath ( $ atoms , $ this instanceof AbsolutePathInterface , false ) ; }
Replace this path s name .
54,074
public function replaceNameWithoutExtension ( $ nameWithoutExtension ) { $ atoms = $ this -> nameAtoms ( ) ; if ( count ( $ atoms ) < 2 ) { return $ this -> replaceName ( $ nameWithoutExtension ) ; } array_splice ( $ atoms , 0 , - 1 , array ( $ nameWithoutExtension ) ) ; return $ this -> replaceName ( implode ( self :: EXTENSION_SEPARATOR , $ atoms ) ) ; }
Replace this path s name but keep the last extension .
54,075
public function replaceNameSuffix ( $ nameSuffix ) { $ atoms = $ this -> nameAtoms ( ) ; if ( array ( '' , '' ) === $ atoms ) { if ( null === $ nameSuffix ) { return $ this ; } return $ this -> replaceName ( static :: EXTENSION_SEPARATOR . $ nameSuffix ) ; } $ numAtoms = count ( $ atoms ) ; if ( null === $ nameSuffix ) { $ replacement = array ( ) ; } else { $ replacement = array ( $ nameSuffix ) ; } array_splice ( $ atoms , 1 , count ( $ atoms ) , $ replacement ) ; return $ this -> replaceName ( implode ( self :: EXTENSION_SEPARATOR , $ atoms ) ) ; }
Replace all of this path s extensions .
54,076
public function replaceExtension ( $ extension ) { $ atoms = $ this -> nameAtoms ( ) ; if ( array ( '' , '' ) === $ atoms ) { if ( null === $ extension ) { return $ this ; } return $ this -> replaceName ( static :: EXTENSION_SEPARATOR . $ extension ) ; } $ numAtoms = count ( $ atoms ) ; if ( $ numAtoms > 1 ) { if ( null === $ extension ) { $ replacement = array ( ) ; } else { $ replacement = array ( $ extension ) ; } array_splice ( $ atoms , - 1 , $ numAtoms , $ replacement ) ; } elseif ( null !== $ extension ) { $ atoms [ ] = $ extension ; } return $ this -> replaceName ( implode ( self :: EXTENSION_SEPARATOR , $ atoms ) ) ; }
Replace this path s last extension .
54,077
public function replaceNameAtoms ( $ index , $ replacement , $ length = null ) { $ atoms = $ this -> nameAtoms ( ) ; if ( ! is_array ( $ replacement ) ) { $ replacement = iterator_to_array ( $ replacement ) ; } if ( null === $ length ) { $ length = count ( $ atoms ) ; } array_splice ( $ atoms , $ index , $ length , $ replacement ) ; return $ this -> replaceName ( implode ( self :: EXTENSION_SEPARATOR , $ atoms ) ) ; }
Replace a section of this path s name with the supplied name atom sequence .
54,078
public function pathFactory ( ) { if ( null === $ this -> pathFactory ) { $ this -> pathFactory = $ this -> createDefaultPathFactory ( ) ; } return $ this -> pathFactory ; }
Get the path factory .
54,079
public function setMailBody ( $ data , $ template_html = null , $ format = 'HTML' ) { if ( ! is_array ( $ data ) && $ template_html == null ) { if ( $ format == 'TEXT' ) { $ this -> isHTML = false ; return $ this -> textBody = $ data ; } return $ this -> htmlBody = $ data ; } elseif ( is_array ( $ data ) && $ template_html == null ) { return $ this -> htmlBody = implode ( '<br> ' , $ data ) ; } else { $ templatePath = ( $ this -> TemplateFolder ) ? $ this -> TemplateFolder . '/' . $ template_html : $ template_html ; if ( defined ( 'VIEWPATH' ) ) { $ views_path = VIEWPATH ; } else { $ views_path = APPPATH . 'views/' ; } if ( ! file_exists ( $ views_path . $ templatePath ) ) { log_message ( 'error' , 'setEmailBody() HTML template file not found: ' . $ template_html ) ; return $ this -> htmlBody = 'Template ' . ( $ template_html ) . ' not found.' ; } else { $ this -> htmlBody = $ this -> CI -> load -> view ( $ templatePath , '' , true ) ; if ( preg_match ( '/\.txt$/' , $ template_html ) ) { $ this -> textBody = $ this -> htmlBody ; } else { $ templateTextPath = preg_replace ( '/\.[html|php|htm]+$/' , '.txt' , $ templatePath ) ; if ( file_exists ( $ views_path . $ templateTextPath ) ) { $ this -> textBody = $ this -> CI -> load -> view ( $ templateTextPath , '' , true ) ; } } } $ data = ( is_array ( $ data ) ) ? $ data : array ( $ data ) ; $ data = array_merge ( $ data , $ this -> TemplateOptions ) ; if ( $ format == 'HTML' ) { foreach ( $ data as $ key => $ value ) { $ this -> htmlBody = str_replace ( "{" . $ key . "}" , "" . $ value . "" , $ this -> htmlBody ) ; $ this -> textBody = str_replace ( "{" . $ key . "}" , "" . $ value . "" , $ this -> textBody ) ; } } elseif ( $ format == 'TEXT' ) { $ this -> isHTML = false ; $ this -> textBody = @ vsprintf ( $ this -> textBody , $ data ) ; } } }
Set Mail Body configuration
54,080
public function sendMail ( $ subject = null , $ mailto = null , $ mailtoName = null ) { $ this -> setFrom ( $ this -> from_mail , $ this -> from_name ) ; $ this -> addReplyTo ( $ this -> replyto_mail , $ this -> replyto_name ) ; ( $ this -> setBcc ) ? $ this -> addBcc ( $ this -> mail_bcc ) : false ; ( $ this -> setCc ) ? $ this -> addCc ( $ this -> mail_cc ) : false ; if ( is_null ( $ mailto ) ) { $ this -> addAddress ( $ this -> replyto_mail , $ this -> replyto_name ) ; } else { ( is_array ( $ mailto ) ) ? $ this -> addAddress ( $ mailto [ 0 ] , $ mailto [ 1 ] ) : $ this -> addAddress ( $ mailto , $ mailtoName ) ; } $ this -> Subject = $ subject ; $ this -> WordWrap = 72 ; if ( ! $ this -> isHTML ) { $ this -> isHTML ( false ) ; $ this -> Body = $ this -> textBody ; } else { $ this -> msgHTML ( $ this -> htmlBody ) ; if ( $ this -> textBody ) { $ this -> AltBody = $ this -> formatHtml2Text ( $ this -> textBody ) ; } else { $ this -> AltBody = $ this -> formatHtml2Text ( $ this -> AltBody ) ; } } $ this -> local_debug ( ) ; if ( ! $ this -> send ( ) ) { log_message ( 'error' , 'PHPMailer Error : mail address . $ mailto ) ; return false ; } else { return true ; } }
sendMail with PHPMailer Library
54,081
public function getPlaceList ( Location $ location , $ contentTypes , $ languages = array ( ) ) { $ query = new Query ( ) ; $ query -> filter = new Criterion \ LogicalAnd ( array ( new Criterion \ ContentTypeIdentifier ( $ contentTypes ) , new Criterion \ Subtree ( $ location -> pathString ) , new Criterion \ LanguageCode ( $ languages ) , ) ) ; $ query -> performCount = false ; $ searchResults = $ this -> searchService -> findContentInfo ( $ query ) ; return $ this -> searchHelper -> buildListFromSearchResult ( $ searchResults ) ; }
Returns all places contained in a place_list .
54,082
public function getPlaceListSorted ( Location $ location , $ latitude , $ longitude , $ contentTypes , $ maxDist = null , $ sortClauses = array ( ) , $ languages = array ( ) ) { if ( $ maxDist === null ) { $ maxDist = $ this -> placeListMaxDist ; } $ query = new Query ( ) ; $ query -> filter = new Criterion \ LogicalAnd ( array ( new Criterion \ ContentTypeIdentifier ( $ contentTypes ) , new Criterion \ Subtree ( $ location -> pathString ) , new Criterion \ LanguageCode ( $ languages ) , new Criterion \ MapLocationDistance ( 'location' , Criterion \ Operator :: BETWEEN , array ( $ this -> placeListMinDist , $ maxDist , ) , $ latitude , $ longitude ) , ) ) ; $ query -> sortClauses = $ sortClauses ; $ query -> performCount = false ; $ searchResults = $ this -> searchService -> findContentInfo ( $ query ) ; return $ this -> searchHelper -> buildListFromSearchResult ( $ searchResults ) ; }
Returns all places contained in a place_list that are located between the range defined in the default configuration . A sort clause array can be provided in order to sort the results .
54,083
public function addField ( $ type , $ mandatory , $ defaultValue = '' , $ name = '' ) { $ this -> fields [ $ type ] = array ( 'name' => $ name , 'mandatory' => $ mandatory , 'defaultValue' => $ defaultValue , ) ; }
Define a new field of the payment page
54,084
public function showSearchResultsAction ( Request $ request ) { $ response = new Response ( ) ; $ searchText = '' ; $ searchCount = 0 ; $ simpleSearch = new SimpleSearch ( ) ; $ form = $ this -> createForm ( $ this -> get ( 'ezdemo.form.type.simple_search' ) , $ simpleSearch ) ; $ form -> handleRequest ( $ request ) ; $ pager = null ; if ( $ form -> isValid ( ) ) { $ searchHelper = $ this -> get ( 'ezdemo.search_helper' ) ; if ( ! empty ( $ simpleSearch -> searchText ) ) { $ searchText = $ simpleSearch -> searchText ; $ pager = $ searchHelper -> searchForPaginatedContent ( $ searchText , $ request -> get ( 'page' , 1 ) , $ this -> getConfigResolver ( ) -> getParameter ( 'languages' ) ) ; $ searchCount = $ pager -> getNbResults ( ) ; } } return $ this -> render ( 'eZDemoBundle:search:search.html.twig' , array ( 'searchText' => $ searchText , 'searchCount' => $ searchCount , 'pagerSearch' => $ pager , 'form' => $ form -> createView ( ) , ) , $ response ) ; }
Displays the simple search page .
54,085
public function searchBoxAction ( ) { $ response = new Response ( ) ; $ simpleSearch = new SimpleSearch ( ) ; $ form = $ this -> createForm ( $ this -> get ( 'ezdemo.form.type.simple_search' ) , $ simpleSearch ) ; return $ this -> render ( 'eZDemoBundle::page_header_searchbox.html.twig' , array ( 'form' => $ form -> createView ( ) , ) , $ response ) ; }
Displays the search box for the page header .
54,086
public function generateAction ( ) { $ extension = $ this -> params ( ) -> fromRoute ( 'extension' , QrCodeServiceInterface :: DEFAULT_EXTENSION ) ; $ content = $ this -> qrCodeService -> getQrCodeContent ( $ this -> params ( ) ) ; return $ this -> createResponse ( $ content , $ this -> qrCodeService -> generateContentType ( $ extension ) ) ; }
Generates the QR code and returns it as stream
54,087
protected function createResponse ( $ content , $ contentType ) { $ resp = new HttpResponse ( ) ; $ resp -> setStatusCode ( 200 ) -> setContent ( $ content ) ; $ resp -> getHeaders ( ) -> addHeaders ( array ( 'Content-Length' => strlen ( $ content ) , 'Content-Type' => $ contentType ) ) ; return $ resp ; }
Creates the response to be returned for a QR Code
54,088
public function renderImg ( $ message , $ extension = null , $ size = null , $ padding = null , $ attribs = array ( ) ) { if ( isset ( $ extension ) ) { if ( is_array ( $ extension ) ) { $ attribs = $ extension ; $ extension = null ; } elseif ( isset ( $ size ) ) { if ( is_array ( $ size ) ) { $ attribs = $ size ; $ size = null ; } elseif ( isset ( $ padding ) && is_array ( $ padding ) ) { $ attribs = $ padding ; $ padding = null ; } } } return $ this -> renderer -> render ( self :: IMG_TEMPLATE , array ( 'src' => $ this -> assembleRoute ( $ message , $ extension , $ size , $ padding ) , 'attribs' => $ attribs ) ) ; }
Renders a img tag pointing defined QR code
54,089
public function renderBase64Img ( $ message , $ extension = null , $ size = null , $ padding = null , $ attribs = array ( ) ) { if ( isset ( $ extension ) ) { if ( is_array ( $ extension ) ) { $ attribs = $ extension ; $ extension = null ; } elseif ( isset ( $ size ) ) { if ( is_array ( $ size ) ) { $ attribs = $ size ; $ size = null ; } elseif ( isset ( $ padding ) && is_array ( $ padding ) ) { $ attribs = $ padding ; $ padding = null ; } } } $ image = $ this -> qrCodeService -> getQrCodeContent ( $ message , $ extension , $ size , $ padding ) ; $ contentType = $ this -> qrCodeService -> generateContentType ( isset ( $ extension ) ? $ extension : QrCodeServiceInterface :: DEFAULT_EXTENSION ) ; return $ this -> renderer -> render ( self :: IMG_BASE64_TEMPLATE , array ( 'base64' => base64_encode ( $ image ) , 'contentType' => $ contentType , 'attribs' => $ attribs ) ) ; }
Renders a img tag with a base64 - encoded QR code
54,090
public function assembleRoute ( $ message , $ extension = null , $ size = null , $ padding = null ) { $ params = array ( 'message' => $ message ) ; if ( isset ( $ extension ) ) { $ params [ 'extension' ] = $ extension ; if ( isset ( $ size ) ) { $ params [ 'size' ] = $ size ; if ( isset ( $ padding ) ) { $ params [ 'padding' ] = $ padding ; } } } $ this -> routeOptions [ 'name' ] = 'acelaya-qrcode' ; return $ this -> router -> assemble ( $ params , $ this -> routeOptions ) ; }
Returns the assembled route as string
54,091
private function makeTableHeader ( $ type , $ header , $ colspan = 2 ) { if ( ! $ this -> bInitialized ) { $ header = $ this -> getVariableName ( ) . " (" . $ header . ")" ; $ this -> bInitialized = true ; } $ str_i = ( $ this -> bCollapsed ) ? "style=\"font-style:italic\" " : "" ; echo "<table cellspacing=2 cellpadding=3 class=\"dBug_" . $ type . "\"> <tr> <td " . $ str_i . "class=\"dBug_" . $ type . "Header\" colspan=" . $ colspan . " onClick='dBug_toggleTable(this)'>" . $ header . "</td> </tr>" ; }
create the main table header
54,092
private function checkType ( $ var ) { switch ( gettype ( $ var ) ) { case "resource" : $ this -> varIsResource ( $ var ) ; break ; case "object" : $ this -> varIsObject ( $ var ) ; break ; case "array" : $ this -> varIsArray ( $ var ) ; break ; case "NULL" : $ this -> varIsNULL ( ) ; break ; case "boolean" : $ this -> varIsBoolean ( $ var ) ; break ; default : $ var = ( $ var == "" ) ? "[empty string]" : $ var ; echo "<table cellspacing=0><tr>\n<td>" . $ var . "</td>\n</tr>\n</table>\n" ; break ; } }
check variable type
54,093
private function varIsObject ( $ var ) { $ var_ser = serialize ( $ var ) ; array_push ( $ this -> arrHistory , $ var_ser ) ; $ this -> makeTableHeader ( "object" , "object" ) ; if ( is_object ( $ var ) ) { $ arrObjVars = get_object_vars ( $ var ) ; foreach ( $ arrObjVars as $ key => $ value ) { $ value = ( ! is_object ( $ value ) && ! is_array ( $ value ) && trim ( $ value ) == "" ) ? "[empty string]" : $ value ; $ this -> makeTDHeader ( "object" , $ key ) ; if ( is_object ( $ value ) || is_array ( $ value ) ) { $ var_ser = serialize ( $ value ) ; if ( in_array ( $ var_ser , $ this -> arrHistory , TRUE ) ) { $ value = ( is_object ( $ value ) ) ? "*RECURSION* -> $" . get_class ( $ value ) : "*RECURSION*" ; } } if ( in_array ( gettype ( $ value ) , $ this -> arrType ) ) { $ this -> checkType ( $ value ) ; } else { echo $ value ; } echo $ this -> closeTDRow ( ) ; } $ arrObjMethods = get_class_methods ( get_class ( $ var ) ) ; foreach ( $ arrObjMethods as $ key => $ value ) { $ this -> makeTDHeader ( "object" , $ value ) ; echo "[function]" . $ this -> closeTDRow ( ) ; } } else { echo "<tr><td>" . $ this -> error ( "object" ) . $ this -> closeTDRow ( ) ; } array_pop ( $ this -> arrHistory ) ; echo "</table>" ; }
if variable is an object type
54,094
private function varIsResource ( $ var ) { $ this -> makeTableHeader ( "resourceC" , "resource" , 1 ) ; echo "<tr>\n<td>\n" ; switch ( get_resource_type ( $ var ) ) { case "fbsql result" : case "mssql result" : case "msql query" : case "pgsql result" : case "sybase-db result" : case "sybase-ct result" : case "mysql result" : $ db = current ( explode ( " " , get_resource_type ( $ var ) ) ) ; $ this -> varIsDBResource ( $ var , $ db ) ; break ; case "gd" : $ this -> varIsGDResource ( $ var ) ; break ; case "xml" : $ this -> varIsXmlResource ( $ var ) ; break ; default : echo get_resource_type ( $ var ) . $ this -> closeTDRow ( ) ; break ; } echo $ this -> closeTDRow ( ) . "</table>\n" ; }
if variable is a resource type
54,095
private function varIsDBResource ( $ var , $ db = "mysql" ) { if ( $ db == "pgsql" ) { $ db = "pg" ; } if ( $ db == "sybase-db" || $ db == "sybase-ct" ) { $ db = "sybase" ; } $ arrFields = [ "name" , "type" , "flags" ] ; $ numrows = call_user_func ( $ db . "_num_rows" , $ var ) ; $ numfields = call_user_func ( $ db . "_num_fields" , $ var ) ; $ this -> makeTableHeader ( "resource" , $ db . " result" , $ numfields + 1 ) ; echo "<tr><td class=\"dBug_resourceKey\">&nbsp;</td>" ; $ field = [ ] ; for ( $ i = 0 ; $ i < $ numfields ; $ i ++ ) { $ field_header = $ field_name = "" ; for ( $ j = 0 ; $ j < count ( $ arrFields ) ; $ j ++ ) { $ db_func = $ db . "_field_" . $ arrFields [ $ j ] ; if ( function_exists ( $ db_func ) ) { $ fheader = call_user_func ( $ db_func , $ var , $ i ) . " " ; if ( $ j == 0 ) { $ field_name = $ fheader ; } else { $ field_header .= $ fheader ; } } } $ field [ $ i ] = call_user_func ( $ db . "_fetch_field" , $ var , $ i ) ; echo "<td class=\"dBug_resourceKey\" title=\"" . $ field_header . "\">" . $ field_name . "</td>" ; } echo "</tr>" ; for ( $ i = 0 ; $ i < $ numrows ; $ i ++ ) { $ row = call_user_func ( $ db . "_fetch_array" , $ var , constant ( strtoupper ( $ db ) . "_ASSOC" ) ) ; echo "<tr>\n" ; echo "<td class=\"dBug_resourceKey\">" . ( $ i + 1 ) . "</td>" ; for ( $ k = 0 ; $ k < $ numfields ; $ k ++ ) { $ fieldrow = $ row [ ( $ field [ $ k ] -> name ) ] ; $ fieldrow = ( $ fieldrow == "" ) ? "[empty string]" : $ fieldrow ; echo "<td>" . $ fieldrow . "</td>\n" ; } echo "</tr>\n" ; } echo "</table>" ; if ( $ numrows > 0 ) { call_user_func ( $ db . "_data_seek" , $ var , 0 ) ; } }
if variable is a database resource type
54,096
public function listPlaceListAction ( Location $ location ) { $ placeHelper = $ this -> get ( 'ezdemo.place_helper' ) ; $ places = $ placeHelper -> getPlaceList ( $ location , $ this -> container -> getParameter ( 'ezdemo.places.place_list.content_types' ) , $ this -> getConfigResolver ( ) -> getParameter ( 'languages' ) ) ; return $ this -> render ( 'eZDemoBundle:parts/place:place_list.html.twig' , array ( 'places' => $ places ) ) ; }
Displays all the places contained in a place list .
54,097
public function listPlaceListSortedAction ( Location $ location , $ latitude , $ longitude , $ maxDist ) { if ( $ latitude == 'key_lat' || $ longitude == 'key_lon' || $ maxDist == 'key_dist' ) { throw $ this -> createNotFoundException ( 'Invalid parameters' ) ; } $ placeHelper = $ this -> get ( 'ezdemo.place_helper' ) ; $ languages = $ this -> getConfigResolver ( ) -> getParameter ( 'languages' ) ; $ language = ( ! empty ( $ languages ) ) ? $ languages [ 0 ] : null ; $ sortClauses = array ( new SortClause \ MapLocationDistance ( 'place' , 'location' , $ latitude , $ longitude , Query :: SORT_ASC , $ language ) , ) ; $ places = $ placeHelper -> getPlaceListSorted ( $ location , $ latitude , $ longitude , $ this -> container -> getParameter ( 'ezdemo.places.place_list.content_types' ) , $ maxDist , $ sortClauses , $ languages ) ; return $ this -> render ( 'eZDemoBundle:parts/place:place_list.html.twig' , array ( 'places' => $ places ) ) ; }
Displays all the places sorted by proximity contained in a place list The max distance of the places displayed can be modified in the default config .
54,098
public function createTemporaryPath ( $ prefix = null ) { if ( null === $ prefix ) { $ prefix = '' ; } return $ this -> createTemporaryDirectoryPath ( ) -> joinAtoms ( $ this -> isolator ( ) -> uniqid ( $ prefix , true ) ) ; }
Create a path representing a suitable for use as the location for a new temporary file or directory .
54,099
private function getMenuItems ( $ rootLocationId ) { $ rootLocation = $ this -> locationService -> loadLocation ( $ rootLocationId ) ; $ query = new LocationQuery ( ) ; $ query -> query = new Criterion \ LogicalAnd ( array ( new Criterion \ ContentTypeIdentifier ( $ this -> getTopMenuContentTypeIdentifierList ( ) ) , new Criterion \ Visibility ( Criterion \ Visibility :: VISIBLE ) , new Criterion \ Location \ Depth ( Criterion \ Operator :: BETWEEN , array ( $ rootLocation -> depth + 1 , $ rootLocation -> depth + 2 ) ) , new Criterion \ Subtree ( $ rootLocation -> pathString ) , new Criterion \ LanguageCode ( $ this -> configResolver -> getParameter ( 'languages' ) ) , ) ) ; $ query -> sortClauses = array ( new Query \ SortClause \ Location \ Path ( ) ) ; $ query -> performCount = false ; return $ this -> searchService -> findLocations ( $ query ) -> searchHits ; }
Queries the repository for menu items as locations filtered on the list in TopIdentifierList in menu . ini .