idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
9,900
public function view ( ) { if ( $ this -> viewRequiresJqueryUI ( ) ) { $ this -> requireAsset ( 'jquery/ui' ) ; } $ this -> requireAsset ( 'css' , 'core/frontend/errors' ) ; if ( $ this -> displayCaptcha ) { $ this -> requireAsset ( 'css' , 'core/frontend/captcha' ) ; } }
and we have some block record things we need to check .
9,901
protected function questionVersioning ( $ data = [ ] ) { $ data += [ 'ignoreQuestionIDs' => '' , 'pendingDeleteIDs' => '' , ] ; $ db = Database :: connection ( ) ; $ oldBID = intval ( $ data [ 'bID' ] ) ; $ vals = [ intval ( $ data [ 'oldQsID' ] ) ] ; $ pendingQuestions = $ db -> getAll ( 'SELECT msqID FROM btFormQuestions WHERE bID=0 && questionSetId=?' , $ vals ) ; foreach ( $ pendingQuestions as $ pendingQuestion ) { $ vals = [ intval ( $ this -> bID ) , intval ( $ pendingQuestion [ 'msqID' ] ) ] ; $ db -> query ( 'DELETE FROM btFormQuestions WHERE bID=? AND msqID=?' , $ vals ) ; } $ vals = [ intval ( $ data [ 'bID' ] ) , intval ( $ data [ 'qsID' ] ) , intval ( $ data [ 'oldQsID' ] ) ] ; $ rs = $ db -> query ( 'UPDATE btFormQuestions SET bID=?, questionSetId=? WHERE bID=0 && questionSetId=?' , $ vals ) ; $ ignoreQuestionIDsDirty = explode ( ',' , $ data [ 'ignoreQuestionIDs' ] ) ; $ ignoreQuestionIDs = [ 0 ] ; foreach ( $ ignoreQuestionIDsDirty as $ msqID ) { $ ignoreQuestionIDs [ ] = intval ( $ msqID ) ; } $ ignoreQuestionIDstr = implode ( ',' , $ ignoreQuestionIDs ) ; $ pendingDeleteQIDsDirty = explode ( ',' , $ data [ 'pendingDeleteIDs' ] ) ; $ pendingDeleteQIDs = [ ] ; foreach ( $ pendingDeleteQIDsDirty as $ msqID ) { $ pendingDeleteQIDs [ ] = intval ( $ msqID ) ; } $ vals = [ $ this -> bID , intval ( $ data [ 'qsID' ] ) ] ; $ pendingDeleteQIDs = implode ( ',' , $ pendingDeleteQIDs ) ; $ unchangedQuestions = $ db -> query ( 'DELETE FROM btFormQuestions WHERE bID=? AND questionSetId=? AND msqID IN (' . $ pendingDeleteQIDs . ')' , $ vals ) ; }
Ties the new or edited questions to the new block number . New and edited questions are temporarily given bID = 0 until the block is saved ... painfully complicated .
9,902
public static function incrementParents ( $ cID ) { $ db = Loader :: db ( ) ; $ cParentID = $ db -> GetOne ( "select cParentID from Pages where cID = ?" , array ( $ cID ) ) ; $ q = "update Pages set cChildren = cChildren+1 where cID = ?" ; $ cpc = Page :: getByID ( $ cParentID ) ; $ cpc -> refreshCache ( ) ; $ r = $ db -> query ( $ q , array ( $ cParentID ) ) ; }
For a particular page ID grabs all the pages of this page and increments the cTotalChildren number for them .
9,903
public static function decrementParents ( $ cID ) { $ db = Loader :: db ( ) ; $ cParentID = $ db -> GetOne ( "select cParentID from Pages where cID = ?" , array ( $ cID ) ) ; $ cChildren = $ db -> GetOne ( "select cChildren from Pages where cID = ?" , array ( $ cParentID ) ) ; -- $ cChildren ; if ( $ cChildren < 0 ) { $ cChildren = 0 ; } $ q = "update Pages set cChildren = ? where cID = ?" ; $ cpc = Page :: getByID ( $ cParentID ) ; $ cpc -> refreshCache ( ) ; $ r = $ db -> query ( $ q , array ( $ cChildren , $ cParentID ) ) ; }
For a particular page ID grabs all the pages of this page and decrements the cTotalChildren number for them .
9,904
public static function getTotalPagesCreated ( $ date ) { $ db = Loader :: db ( ) ; $ num = $ db -> GetOne ( 'select count(Pages.cID) from Pages inner join Collections on Pages.cID = Collections.cID where cDateAdded >= ? and cDateAdded <= ? and siteTreeID > 0 and cIsTemplate = 0' , array ( $ date . ' 00:00:00' , $ date . ' 23:59:59' ) ) ; return $ num ; }
Returns the total number of pages created for a given date .
9,905
public static function create ( $ handle , $ name , Package $ package = null ) { $ result = new static ( ) ; $ result -> setGeolocatorHandle ( $ handle ) -> setGeolocatorName ( $ name ) -> setGeolocatorDescription ( '' ) -> setGeolocatorConfiguration ( [ ] ) -> setGeolocatorPackage ( $ package ) -> setIsActive ( false ) ; return $ result ; }
Create a new Geolocator instance .
9,906
public function getGeolocatorDisplayName ( $ format = 'html' ) { $ value = tc ( 'GeolocatorName' , $ this -> getGeolocatorName ( ) ) ; switch ( $ format ) { case 'html' : return h ( $ value ) ; case 'text' : default : return $ value ; } }
Get the Geolocator display name .
9,907
public function getGeolocatorDisplayDescription ( $ format = 'html' ) { $ value = tc ( 'GeolocatorDescription' , $ this -> getGeolocatorDescription ( ) ) ; switch ( $ format ) { case 'html' : return nl2br ( h ( $ value ) ) ; case 'text' : default : return $ value ; } }
Get the Geolocator display description .
9,908
public function getEntryAssociation ( Association $ association ) { $ id = $ association -> getId ( ) ; foreach ( $ this -> associations as $ entryAssociation ) { if ( $ entryAssociation -> getAssociation ( ) -> getId ( ) === $ id ) { return $ entryAssociation ; } } return null ; }
Get the EntryAssociation for a given association .
9,909
public function getFormElementPath ( ) { $ className = implode ( '' , array_slice ( explode ( '\\' , get_called_class ( ) ) , - 1 ) ) ; $ segment = substr ( $ className , 0 , strpos ( $ className , 'Style' ) ) ; $ element = uncamelcase ( $ segment ) ; $ env = Environment :: get ( ) ; return $ env -> getPath ( DIRNAME_ELEMENTS . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/' . $ element . '.php' ) ; }
Returns a path to an elements directory for this Style . Might not be used by all styles .
9,910
public function getByOccurrenceID ( $ occurrenceID , $ retrieveVersion = EventService :: EVENT_VERSION_APPROVED ) { if ( $ retrieveVersion == EventService :: EVENT_VERSION_RECENT ) { $ query = $ this -> entityManager -> createQuery ( 'select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID order by v.evDateAdded DESC' ) ; } else { $ query = $ this -> entityManager -> createQuery ( 'select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID and v.evIsApproved = 1' ) ; } $ query -> setMaxResults ( 1 ) ; $ query -> setParameter ( 'occurrenceID' , $ occurrenceID ) ; $ object = $ query -> getOneOrNullResult ( ) ; return $ object ; }
This code below retrieves based on the occurrence ID which can remain the same across versions .
9,911
public function noFollowHref ( $ input ) { return preg_replace_callback ( '/(?:<a(.*?href.*?)>)/i' , function ( $ matches ) { if ( strpos ( $ matches [ 1 ] , 'rel="nofollow"' ) === false ) { return '<a' . $ matches [ 1 ] . ' rel="nofollow">' ; } else { return $ matches [ 0 ] ; } } , $ input ) ; }
Takes in a string and adds rel = nofollow to any a tags that contain an href attribute .
9,912
public function finalizeScopes ( array $ scopes , $ grantType , ClientEntityInterface $ clientEntity , $ userIdentifier = null ) { $ app = Facade :: getFacadeApplication ( ) ; $ allowedScopes = $ app -> make ( 'config' ) -> get ( 'app.api.scopes' ) ; $ winnowed = [ ] ; foreach ( $ scopes as $ scope ) { if ( in_array ( $ scope -> getIdentifier ( ) , $ allowedScopes ) ) { $ winnowed [ ] = $ scope ; } } return $ winnowed ; }
Given a client grant type and optional user identifier validate the set of scopes requested are valid and optionally append additional scopes or remove requested scopes .
9,913
private function add ( $ param , $ requireInstall = false , callable $ callback = null ) { if ( is_array ( $ param ) ) { foreach ( $ param as $ item ) { $ this -> add ( $ item , $ requireInstall , $ callback ) ; } return null ; } if ( $ requireInstall && ! $ this -> installed ( ) ) { return null ; } $ command = is_string ( $ param ) ? $ this -> app -> make ( $ param ) : $ param ; if ( ! $ command || ! $ command instanceof SymfonyCommand ) { throw new \ InvalidArgumentException ( 'Invalid command provided.' ) ; } if ( $ callback ) { $ command = $ callback ( $ command ) ; if ( ! $ command ) { return null ; } } return $ this -> cli -> add ( $ command ) ; }
Add a class to the CLI application
9,914
private function installed ( ) { if ( $ this -> installed === null ) { $ this -> installed = $ this -> app -> isInstalled ( ) ; } return $ this -> installed ; }
Determine if the app is currently installed
9,915
public function registerClass ( $ alias , $ class ) { $ classSymbol = new ClassSymbol ( $ alias , $ class ) ; $ this -> classes [ $ alias ] = $ classSymbol ; $ aliasNamespace = $ classSymbol -> getAliasNamespace ( ) ; if ( ! in_array ( $ aliasNamespace , $ this -> aliasNamespaces , true ) ) { $ this -> aliasNamespaces [ ] = $ aliasNamespace ; } }
Register a class alias and store it in the classes array .
9,916
public function render ( $ eol = "\n" , $ padding = ' ' , $ methodFilter = null ) { $ lines = [ ] ; $ lines [ ] = '<?php' ; $ lines [ ] = '' ; $ lines [ ] = '// Generated on ' . date ( 'c' ) ; foreach ( $ this -> aliasNamespaces as $ namespace ) { $ lines [ ] = '' ; $ lines [ ] = rtrim ( "namespace {$namespace}" ) ; $ lines [ ] = '{' ; $ addNewline = false ; if ( $ namespace === '' ) { $ lines [ ] = "{$padding}die('Access Denied.');" ; $ addNewline = true ; } foreach ( $ this -> classes as $ class ) { if ( $ class -> getAliasNamespace ( ) === $ namespace ) { $ rendered_class = $ class -> render ( $ eol , $ padding , $ methodFilter ) ; if ( $ rendered_class !== '' ) { if ( $ addNewline === true ) { $ lines [ ] = '' ; } else { $ addNewline = true ; } $ lines [ ] = $ padding . str_replace ( $ eol , $ eol . $ padding , rtrim ( $ rendered_class ) ) ; } } } $ lines [ ] = '}' ; } $ lines [ ] = '' ; return implode ( $ eol , $ lines ) ; }
Render the classes .
9,917
public function required_password_upgrade ( ) { $ email = $ this -> post ( 'uEmail' ) ; $ token = $ this -> app -> make ( Token :: class ) ; $ this -> set ( 'token' , $ token ) ; if ( $ email ) { $ errorValidator = Core :: make ( 'helper/validation/error' ) ; $ userInfo = Core :: make ( 'Concrete\Core\User\UserInfoRepository' ) -> getByName ( Session :: get ( 'uPasswordResetUserName' ) ) ; try { if ( $ userInfo && $ email != $ userInfo -> getUserEmail ( ) ) { throw new \ Exception ( t ( sprintf ( 'Invalid email address %s provided resetting a password' , $ email ) ) ) ; } } catch ( \ Exception $ e ) { $ errorValidator -> add ( $ e ) ; } $ this -> forgot_password ( ) ; } else { $ this -> set ( 'authType' , $ this -> getAuthenticationType ( ) ) ; $ this -> set ( 'intro_msg' , Core :: make ( 'config/database' ) -> get ( 'concrete.password.reset.message' ) ) ; } }
Called when a user tries to log in after his password has been reset by Global Password Reset .
9,918
public function format ( $ mask , Entry $ entry ) { return $ this -> formatter -> format ( $ mask , function ( $ key ) use ( $ entry ) { if ( $ key === 'id' ) { return $ entry -> getID ( ) ; } $ attribute = $ entry -> getAttribute ( $ key ) ; if ( $ attribute ) { return $ attribute ; } $ association = $ entry -> getAssociation ( $ key ) ; if ( is_object ( $ association ) ) { return $ association -> getSelectedEntry ( ) -> getLabel ( ) ; } } ) ; }
Format a mask given an entry
9,919
public static function getByName ( $ blockName ) { if ( ! $ blockName ) { return ; } $ app = Application :: getFacadeApplication ( ) ; $ now = $ app -> make ( 'date' ) -> getOverridableNow ( ) ; $ db = Loader :: db ( ) ; $ sql = <<<'EOT'SELECT b.bID, cvb.arHandle, cvb.cIDFROM Blocks AS b INNER JOIN CollectionVersionBlocks AS cvb ON b.bID = cvb.bID INNER JOIN CollectionVersions AS cv ON cvb.cID = cv.cID AND cvb.cvID = cv.cvIDWHERE b.bName = ? AND cv.cvIsApproved = 1 AND (cv.cvPublishDate IS NULL or cv.cvPublishDate <= ?) AND (cv.cvPublishEndDate IS NULL or cv.cvPublishEndDate >= ?)ORDER BY cvb.cvID DESCLIMIT 1EOT ; $ vals = [ $ blockName , $ now , $ now ] ; $ row = $ db -> getRow ( $ sql , $ vals ) ; if ( $ row != false && isset ( $ row [ 'bID' ] ) && $ row [ 'bID' ] > 0 ) { return self :: getByID ( $ row [ 'bID' ] , Page :: getByID ( $ row [ 'cID' ] ) , $ row [ 'arHandle' ] ) ; } else { return new self ( ) ; } }
Get a block instance given its name .
9,920
public static function populateManually ( $ blockInfo , $ c , $ a ) { $ b = new self ( ) ; $ b -> setPropertiesFromArray ( $ blockInfo ) ; if ( is_object ( $ a ) ) { $ b -> a = $ a ; $ b -> arHandle = $ a -> getAreaHandle ( ) ; } else { if ( $ a != null ) { $ b -> arHandle = $ a ; } } $ b -> cID = $ c -> getCollectionID ( ) ; $ b -> c = $ c ; return $ b ; }
Initialize the instance by manually specifying the data .
9,921
public function getCollectionList ( ) { $ cArray = [ ] ; $ bID = $ this -> getBlockID ( ) ; if ( $ bID ) { $ db = Loader :: db ( ) ; $ q = 'select DISTINCT Pages.cID from CollectionVersionBlocks inner join Pages on (CollectionVersionBlocks.cID = Pages.cID) inner join CollectionVersions on (CollectionVersions.cID = Pages.cID) where CollectionVersionBlocks.bID = ?' ; $ r = $ db -> query ( $ q , [ $ bID ] ) ; if ( $ r ) { while ( $ row = $ r -> fetchRow ( ) ) { $ cArray [ ] = Page :: getByID ( $ row [ 'cID' ] , 'RECENT' ) ; } $ r -> free ( ) ; } } return $ cArray ; }
Gets a list of collections that include this block along with area name etc ... used in the block_details . php page in the admin control panel .
9,922
public function setBlockCollectionObject ( $ c ) { $ this -> c = $ c ; $ this -> cID = $ c ? $ c -> getCollectionID ( ) : null ; }
Set the collection instance containing the block .
9,923
public function setBlockAreaObject ( & $ a ) { $ this -> a = $ a ; $ this -> arHandle = $ a ? $ a -> getAreaHandle ( ) : null ; }
Set the area containing the block .
9,924
public function setAbsoluteBlockDisplayOrder ( $ do ) { $ db = Loader :: db ( ) ; $ cID = $ this -> getBlockCollectionID ( ) ; $ bID = $ this -> getBlockID ( ) ; $ arHandle = $ this -> getAreaHandle ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ cvID = $ c -> getVersionID ( ) ; $ q = 'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?' ; $ r = $ db -> query ( $ q , [ $ do , $ bID , $ cID , $ cvID , $ arHandle ] ) ; }
Set the absolute position of this block regardless other blocks in the same page & area .
9,925
public function isEditable ( ) { $ bv = new BlockView ( $ this ) ; $ path = $ bv -> getBlockPath ( FILENAME_BLOCK_EDIT ) ; if ( file_exists ( $ path . '/' . FILENAME_BLOCK_EDIT ) ) { return true ; } return false ; }
Does this block have an edit user interface?
9,926
public function deactivate ( ) { $ db = Loader :: db ( ) ; $ q = 'update Blocks set bIsActive = 0 where bID = ?' ; $ db -> query ( $ q , [ $ this -> getBlockID ( ) ] ) ; }
Deactivate the block .
9,927
public function activate ( ) { $ db = Loader :: db ( ) ; $ q = 'update Blocks set bIsActive = 1 where bID = ?' ; $ db -> query ( $ q , [ $ this -> getBlockID ( ) ] ) ; }
Activate the block .
9,928
public function isAlias ( $ c = null ) { if ( $ c ) { $ db = Loader :: db ( ) ; $ cID = $ c -> getCollectionID ( ) ; $ vo = $ c -> getVersionObject ( ) ; $ cvID = $ vo -> getVersionID ( ) ; $ q = 'select bID from CollectionVersionBlocks where bID = ? and cID=? and isOriginal = 0 and cvID = ?' ; $ r = $ db -> query ( $ q , [ $ this -> getBlockID ( ) , $ cID , $ cvID ] ) ; if ( $ r ) { return $ r -> numRows ( ) > 0 ; } } else { return isset ( $ this -> isOriginal ) ? ( ! $ this -> isOriginal ) : false ; } }
Check if this block instance is an alias .
9,929
public function getNumChildren ( ) { $ db = Loader :: db ( ) ; $ q = 'select count(*) as total from CollectionVersionBlocks where bID = ? and isOriginal = 0' ; $ total = $ db -> getOne ( $ q , [ $ this -> getBlockID ( ) ] ) ; return $ total ; }
Get the number of alias of this block .
9,930
public function isBlockInStack ( ) { $ co = $ this -> getBlockCollectionObject ( ) ; if ( is_object ( $ co ) ) { if ( $ co -> getPageTypeHandle ( ) == STACKS_PAGE_TYPE ) { return true ; } } return false ; }
Is this block inside a stack?
9,931
public function getCustomStyleSetID ( ) { $ db = Loader :: db ( ) ; if ( ! isset ( $ this -> issID ) ) { $ co = $ this -> getBlockCollectionObject ( ) ; $ arHandle = $ this -> getAreaHandle ( ) ; if ( $ arHandle ) { $ a = $ this -> getBlockAreaObject ( ) ; if ( $ a -> isGlobalArea ( ) ) { $ arHandle = STACKS_AREA_NAME ; } $ v = [ $ co -> getCollectionID ( ) , $ co -> getVersionID ( ) , $ arHandle , $ this -> getBlockID ( ) , ] ; $ this -> issID = ( int ) $ db -> GetOne ( 'select issID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?' , $ v ) ; } else { $ this -> issID = 0 ; } } return $ this -> issID ; }
Get the ID of the custom style set .
9,932
public function getCustomStyle ( $ force = false ) { if ( $ this -> getCustomStyleSetID ( ) > 0 || $ force ) { $ csr = StyleSet :: getByID ( $ this -> getCustomStyleSetID ( ) ) ; $ theme = $ this -> c -> getCollectionThemeObject ( ) ; switch ( $ this -> getBlockTypeHandle ( ) ) { case BLOCK_HANDLE_LAYOUT_PROXY : $ bs = new CoreAreaLayoutCustomStyle ( $ csr , $ this , $ theme ) ; break ; default : $ bs = new CustomStyle ( $ csr , $ this , $ theme ) ; break ; } return $ bs ; } }
Get the custom style object associated to this block .
9,933
public function setCustomStyleSet ( \ Concrete \ Core \ Entity \ StyleCustomizer \ Inline \ StyleSet $ set ) { $ db = Loader :: db ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ cvID = $ c -> getVersionID ( ) ; $ db -> Replace ( 'CollectionVersionBlockStyles' , [ 'cID' => $ this -> getBlockCollectionID ( ) , 'cvID' => $ cvID , 'arHandle' => $ this -> getAreaHandle ( ) , 'bID' => $ this -> getBlockID ( ) , 'issID' => $ set -> getID ( ) , ] , [ 'cID' , 'cvID' , 'bID' , 'arHandle' , ] , true ) ; $ this -> issID = ( int ) $ set -> getID ( ) ; }
Set the block custom styles .
9,934
public function resetCustomStyle ( ) { $ db = Loader :: db ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ cvID = $ c -> getVersionID ( ) ; $ db -> Execute ( 'delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?' , [ $ this -> getBlockCollectionID ( ) , $ cvID , $ this -> getAreaHandle ( ) , $ this -> getBlockID ( ) , ] ) ; $ this -> issID = 0 ; }
Remove the block custom styles .
9,935
public function getBlockCacheSettingsObject ( ) { if ( $ this -> cacheSettings === null ) { $ this -> cacheSettings = CacheSettings :: get ( $ this ) ; } return $ this -> cacheSettings ; }
Get the cache settings instance .
9,936
public function setCustomCacheSettings ( $ enabled , $ enabledOnPost , $ enabledForRegistered , $ lifetime ) { $ db = Loader :: db ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ cvID = $ c -> getVersionID ( ) ; $ enabled = ( bool ) $ enabled ; $ enabledOnPost = ( bool ) $ enabledOnPost ; $ enabledForRegistered = ( bool ) $ enabledForRegistered ; $ lifetime = ( int ) $ lifetime ; $ db -> Replace ( 'CollectionVersionBlocksCacheSettings' , [ 'cID' => $ this -> getBlockCollectionID ( ) , 'cvID' => $ cvID , 'arHandle' => $ this -> getAreaHandle ( ) , 'bID' => $ this -> getBlockID ( ) , 'btCacheBlockOutput' => ( int ) $ enabled , 'btCacheBlockOutputOnPost' => ( int ) $ enabledOnPost , 'btCacheBlockOutputForRegisteredUsers' => ( int ) $ enabledForRegistered , 'btCacheBlockOutputLifetime' => ( int ) $ lifetime , ] , [ 'cID' , 'cvID' , 'bID' , 'arHandle' , ] , true ) ; $ db -> update ( 'CollectionVersionBlocks' , [ 'cbOverrideBlockTypeCacheSettings' => 1 ] , [ 'cID' => $ this -> getBlockCollectionID ( ) , 'cvID' => $ cvID , 'arHandle' => $ this -> getAreaHandle ( ) , 'bID' => $ this -> getBlockID ( ) , ] ) ; }
Customize the cache settings overriding the values of the block type controller .
9,937
public function resetCustomCacheSettings ( ) { $ db = Loader :: db ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ cvID = $ c -> getVersionID ( ) ; $ db -> update ( 'CollectionVersionBlocks' , [ 'cbOverrideBlockTypeCacheSettings' => 0 ] , [ 'cID' => $ this -> getBlockCollectionID ( ) , 'cvID' => $ cvID , 'arHandle' => $ this -> getAreaHandle ( ) , 'bID' => $ this -> getBlockID ( ) , ] ) ; $ db -> delete ( 'CollectionVersionBlocksCacheSettings' , [ 'cID' => $ this -> getBlockCollectionID ( ) , 'cvID' => $ cvID , 'arHandle' => $ this -> getAreaHandle ( ) , 'bID' => $ this -> getBlockID ( ) , ] ) ; }
Reset the cache settings so that concrete5 will use the values of the block type controller .
9,938
public function setBlockCachedOutput ( $ content , $ lifetime , $ area ) { $ db = Loader :: db ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ btCachedBlockOutputExpires = strtotime ( '+5 years' ) ; if ( $ lifetime > 0 ) { $ btCachedBlockOutputExpires = time ( ) + $ lifetime ; } $ arHandle = $ this -> getAreaHandle ( ) ; $ cID = $ c -> getCollectionID ( ) ; $ cvID = $ c -> getVersionID ( ) ; if ( $ this -> isBlockInStack ( ) && is_object ( $ area ) ) { $ arHandle = $ area -> getAreaHandle ( ) ; $ cx = Page :: getCurrentPage ( ) ; $ cID = $ cx -> getCollectioniD ( ) ; $ cvID = $ cx -> getVersionID ( ) ; } if ( $ arHandle && $ cID && $ cvID ) { $ db -> Replace ( 'CollectionVersionBlocksOutputCache' , [ 'cID' => $ cID , 'cvID' => $ cvID , 'bID' => $ this -> getBlockID ( ) , 'arHandle' => $ arHandle , 'btCachedBlockOutput' => $ content , 'btCachedBlockOutputExpires' => $ btCachedBlockOutputExpires , ] , [ 'cID' , 'cvID' , 'arHandle' , 'bID' , ] , true ) ; } }
Set the output cache .
9,939
public function refreshBlockOutputCache ( ) { $ db = Loader :: db ( ) ; $ cID = $ this -> getBlockCollectionID ( ) ; $ bID = $ this -> getBlockID ( ) ; $ c = $ this -> getBlockCollectionObject ( ) ; $ v = [ $ c -> getCollectionID ( ) , $ c -> getVersionID ( ) , $ this -> getAreaHandle ( ) , $ bID ] ; $ db -> Execute ( 'update CollectionVersionBlocksOutputCache set btCachedBlockOutputExpires = 0 where cID = ? and cvID = ? and arHandle = ? and bID = ?' , $ v ) ; }
Mark the output cache as expired .
9,940
public function refreshBlockRecordCache ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ db -> executeQuery ( 'UPDATE Blocks SET btCachedBlockRecord = NULL WHERE bID = ?' , [ $ this -> getBlockID ( ) , ] ) ; }
Refreshes the block record cache
9,941
public function overrideAreaPermissions ( ) { if ( ! isset ( $ this -> cbOverrideAreaPermissions ) || ! $ this -> cbOverrideAreaPermissions ) { $ this -> cbOverrideAreaPermissions = 0 ; } return $ this -> cbOverrideAreaPermissions ; }
Area permissions are overridden?
9,942
public function revertToAreaPermissions ( ) { $ c = $ this -> getBlockCollectionObject ( ) ; $ db = Loader :: db ( ) ; $ v = [ $ c -> getCollectionID ( ) , $ c -> getVersionID ( ) , $ this -> getBlockID ( ) ] ; $ db -> query ( 'delete from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ?' , $ v ) ; $ v [ ] = $ this -> getAreaHandle ( ) ; $ db -> query ( 'update CollectionVersionBlocks set cbOverrideAreaPermissions = 0 where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?' , $ v ) ; }
Revert the permission of the object to the one of the area that contains the block .
9,943
public function ignorePageThemeGridFrameworkContainer ( ) { if ( $ this -> overrideBlockTypeContainerSettings ( ) ) { return ! $ this -> enableBlockContainer ( ) ; } $ controller = $ this -> getController ( ) ; return $ controller -> ignorePageThemeGridFrameworkContainer ( ) ; }
Should the view ignore the grid container?
9,944
public function overrideBlockTypeContainerSettings ( ) { if ( ! isset ( $ this -> cbOverrideBlockTypeContainerSettings ) || ! $ this -> cbOverrideBlockTypeContainerSettings ) { $ this -> cbOverrideBlockTypeContainerSettings = 0 ; } return $ this -> cbOverrideBlockTypeContainerSettings ; }
Should this instance override the grid container settings of the block controller?
9,945
public function getController ( ) { if ( Config :: get ( 'concrete.cache.blocks' ) && isset ( $ this -> instance ) && $ this -> instance -> cacheBlockRecord ( ) && is_object ( $ this -> instance -> getBlockControllerData ( ) ) ) { $ this -> instance -> __construct ( ) ; } else { $ bt = $ this -> getBlockTypeObject ( ) ; $ class = $ bt -> getBlockTypeClass ( ) ; $ app = Facade :: getFacadeApplication ( ) ; $ this -> instance = $ app -> build ( $ class , [ $ this ] ) ; } $ this -> instance -> setBlockObject ( $ this ) ; $ this -> instance -> setAreaObject ( $ this -> getBlockAreaObject ( ) ) ; return $ this -> instance ; }
Get the block type controller .
9,946
public function display ( $ view = 'view' ) { if ( $ this -> getBlockTypeID ( ) < 1 ) { return ; } $ bv = new BlockView ( $ this ) ; $ bv -> render ( $ view ) ; }
Render the block display .
9,947
public function update ( $ data ) { $ db = Loader :: db ( ) ; $ dh = Loader :: helper ( 'date' ) ; $ bDateModified = $ dh -> getOverridableNow ( ) ; $ bID = $ this -> getBlockID ( ) ; $ v = [ $ bDateModified , $ bID ] ; $ q = 'update Blocks set bDateModified = ? where bID = ?' ; $ r = $ db -> prepare ( $ q ) ; $ res = $ db -> execute ( $ r , $ v ) ; $ this -> refreshBlockOutputCache ( ) ; $ btID = $ this -> getBlockTypeID ( ) ; $ bt = BlockType :: getByID ( $ btID ) ; $ class = $ bt -> getBlockTypeClass ( ) ; $ app = Facade :: getFacadeApplication ( ) ; $ bc = $ app -> build ( $ class , [ $ this ] ) ; $ bc -> save ( $ data ) ; }
Updates fields common to every block .
9,948
public function updateBlockInformation ( $ data ) { $ db = Loader :: db ( ) ; $ dh = Loader :: helper ( 'date' ) ; $ dt = $ dh -> getOverridableNow ( ) ; $ bName = $ this -> getBlockName ( ) ; $ bFilename = $ this -> getBlockFilename ( ) ; if ( isset ( $ data [ 'bName' ] ) ) { $ bName = $ data [ 'bName' ] ; } if ( isset ( $ data [ 'bFilename' ] ) ) { $ bFilename = $ data [ 'bFilename' ] ; } $ v = [ $ bName , $ bFilename , $ dt , $ this -> getBlockID ( ) ] ; $ q = 'update Blocks set bName = ?, bFilename = ?, bDateModified = ? where bID = ?' ; $ r = $ db -> prepare ( $ q ) ; $ res = $ db -> execute ( $ r , $ v ) ; $ this -> refreshBlockOutputCache ( ) ; }
Update the block information like its block filename and block name .
9,949
public function alias ( $ c ) { $ app = Application :: getFacadeApplication ( ) ; $ cloner = $ app -> make ( Cloner :: class ) ; $ cloner -> cloneBlock ( $ this , $ c ) ; }
Create an alias of the block attached to this collection within the CollectionVersionBlocks table . Additionally this command grabs the permissions from the original record in the CollectionVersionBlocks table and attaches them to the new one .
9,950
public function export ( $ node , $ exportType = 'full' ) { if ( ! $ this -> isAliasOfMasterCollection ( ) || ( ( $ this -> c instanceof Page ) && $ this -> c -> isMasterCollection ( ) ) ) { $ blockNode = $ node -> addChild ( 'block' ) ; $ blockNode -> addAttribute ( 'type' , $ this -> getBlockTypeHandle ( ) ) ; $ blockNode -> addAttribute ( 'name' , $ this -> getBlockName ( ) ) ; if ( $ this -> getBlockFilename ( ) != '' ) { $ blockNode -> addAttribute ( 'custom-template' , $ this -> getBlockFilename ( ) ) ; } if ( $ this -> overrideBlockTypeContainerSettings ( ) ) { $ blockNode -> addAttribute ( 'custom-container-settings' , $ this -> enableBlockContainer ( ) ? 1 : 0 ) ; } if ( ( $ this -> c instanceof Page ) && $ this -> c -> isMasterCollection ( ) ) { $ mcBlockID = Loader :: helper ( 'validation/identifier' ) -> getString ( 8 ) ; ContentExporter :: addMasterCollectionBlockID ( $ this , $ mcBlockID ) ; $ blockNode -> addAttribute ( 'mc-block-id' , $ mcBlockID ) ; } if ( $ exportType == 'full' ) { $ style = $ this -> getCustomStyle ( ) ; if ( is_object ( $ style ) ) { $ set = $ style -> getStyleSet ( ) ; $ set -> export ( $ blockNode ) ; } if ( $ this -> overrideBlockTypeCacheSettings ( ) ) { $ settings = $ this -> getBlockCacheSettingsObject ( ) ; $ blockNode [ 'cache-output' ] = $ settings -> cacheBlockOutput ( ) ; $ blockNode [ 'cache-output-lifetime' ] = $ settings -> getBlockOutputCacheLifetime ( ) ; $ blockNode [ 'cache-output-on-post' ] = $ settings -> cacheBlockOutputOnPost ( ) ; $ blockNode [ 'cache-output-for-registered-users' ] = $ settings -> cacheBlockOutputForRegisteredUsers ( ) ; } $ bc = $ this -> getController ( ) ; $ bc -> export ( $ blockNode ) ; } } else { $ blockNode = $ node -> addChild ( 'block' ) ; $ blockNode -> addAttribute ( 'mc-block-id' , ContentExporter :: getMasterCollectionTemporaryBlockID ( $ this ) ) ; } }
Export the data associated to this block to an XML node .
9,951
public function queueForDefaultsUpdate ( $ data , $ queue , $ includeThisBlock = true ) { $ blocks = [ ] ; $ db = \ Database :: connection ( ) ; $ rows = $ db -> GetAll ( 'select cID, max(cvID) as cvID, cbRelationID from CollectionVersionBlocks where cbRelationID = ? group by cID order by cID' , [ $ this -> getBlockRelationID ( ) ] ) ; $ oc = $ this -> getBlockCollectionObject ( ) ; $ ocID = $ oc -> getCollectionID ( ) ; $ ocvID = $ oc -> getVersionID ( ) ; foreach ( $ rows as $ row ) { $ row2 = $ db -> GetRow ( 'select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and cbRelationID = ?' , [ $ row [ 'cID' ] , $ row [ 'cvID' ] , $ row [ 'cbRelationID' ] , ] ) ; if ( $ includeThisBlock || ( $ row [ 'cID' ] != $ ocID || $ row [ 'cvID' ] != $ ocvID || $ row2 [ 'arHandle' ] != $ this -> getAreaHandle ( ) || $ row2 [ 'bID' ] != $ this -> getBlockID ( ) ) ) { $ blocks [ ] = [ 'cID' => $ row [ 'cID' ] , 'cvID' => $ row [ 'cvID' ] , 'cbRelationID' => $ row [ 'cbRelationID' ] , 'bID' => $ row2 [ 'bID' ] , 'arHandle' => $ row2 [ 'arHandle' ] , 'data' => $ data , ] ; } } $ name = $ queue -> getName ( ) ; $ queue -> deleteQueue ( ) ; $ queue = Queue :: get ( $ name ) ; foreach ( $ blocks as $ block ) { $ queue -> send ( serialize ( $ block ) ) ; } return $ queue ; }
Populate the queue to be used to work on the block and it aliases .
9,952
public function refreshCache ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ cache = $ app -> make ( 'cache/request' ) ; if ( $ cache -> isEnabled ( ) ) { $ cache -> delete ( 'page/' . $ this -> getCollectionID ( ) ) ; } }
Clear the cache for this collection .
9,953
public static function get ( $ c , $ cvID ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ now = $ app -> make ( 'date' ) -> getOverridableNow ( ) ; $ cID = false ; if ( $ c instanceof \ Concrete \ Core \ Page \ Page ) { $ cID = $ c -> getCollectionPointerID ( ) ; } if ( ! $ cID ) { $ cID = $ c -> getCollectionID ( ) ; } $ v = array ( $ cID ) ; $ q = "select * from CollectionVersions where cID = ?" ; switch ( $ cvID ) { case 'ACTIVE' : $ q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1' ; $ v [ ] = $ now ; $ v [ ] = $ now ; break ; case 'SCHEDULED' : $ q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1' ; $ v [ ] = $ now ; break ; case 'RECENT' : $ q .= ' order by cvID desc limit 1' ; break ; case 'RECENT_UNAPPROVED' : $ q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1' ; break ; default : $ v [ ] = $ cvID ; $ q .= ' and cvID = ?' ; break ; } $ row = $ db -> fetchAssoc ( $ q , $ v ) ; $ cv = new static ( ) ; if ( $ row !== false ) { $ cv -> setPropertiesFromArray ( $ row ) ; } $ cv -> cID = $ c -> getCollectionID ( ) ; return $ cv ; }
Get a Version instance given the Collection and a version identifier .
9,954
public function isApprovedNow ( $ when = null ) { if ( ! $ this -> isApproved ( ) ) { return false ; } $ start = $ this -> getPublishDate ( ) ; $ end = $ this -> getPublishEndDate ( ) ; if ( ! $ start && ! $ end ) { return true ; } $ dh = Facade :: getFacadeApplication ( ) -> make ( 'date' ) ; if ( $ when ) { $ when = $ dh -> toDB ( $ when ) ; } if ( ! $ when ) { $ when = $ dh -> getOverridableNow ( ) ; } if ( $ start && $ start > $ when ) { return false ; } if ( $ end && $ end < $ when ) { return false ; } return true ; }
Is this version approved and in the publish interval?
9,955
public function isMostRecent ( ) { if ( ! isset ( $ this -> isMostRecent ) ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ cvID = $ db -> fetchColumn ( 'select cvID from CollectionVersions where cID = ? order by cvID desc' , array ( $ this -> cID ) ) ; $ this -> isMostRecent = ( $ cvID == $ this -> cvID ) ; } return $ this -> isMostRecent ; }
Is this the most recent version?
9,956
public function getCustomAreaStyles ( ) { if ( ! isset ( $ this -> customAreaStyles ) ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ r = $ db -> fetchAll ( 'select issID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?' , array ( $ this -> getCollectionID ( ) , $ this -> cvID , ) ) ; $ this -> customAreaStyles = array ( ) ; foreach ( $ r as $ styles ) { $ this -> customAreaStyles [ $ styles [ 'arHandle' ] ] = $ styles [ 'issID' ] ; } } return $ this -> customAreaStyles ; }
Get the custom area style IDs .
9,957
public function setComment ( $ comment ) { $ thisCVID = $ this -> getVersionID ( ) ; $ comment = ( $ comment != null ) ? $ comment : "Version {$thisCVID}" ; $ v = array ( $ comment , $ thisCVID , $ this -> cID , ) ; $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ q = "update CollectionVersions set cvComments = ? where cvID = ? and cID = ?" ; $ db -> executeQuery ( $ q , $ v ) ; $ this -> cvComments = $ comment ; }
Set the collection version comments .
9,958
public function createNew ( $ versionComments ) { $ app = Facade :: getFacadeApplication ( ) ; $ cloner = $ app -> make ( Cloner :: class ) ; $ clonerOptions = $ app -> build ( ClonerOptions :: class ) -> setCopyContents ( false ) -> setVersionComments ( $ versionComments ) ; $ myCollection = Page :: getByID ( $ this -> getCollectionID ( ) ) ; $ newVersion = $ cloner -> cloneCollectionVersion ( $ this , $ myCollection , $ clonerOptions ) ; return $ newVersion ; }
Create a new version for the same collection as this collection version .
9,959
public function discard ( ) { if ( $ this -> isNew ( ) ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ r = $ db -> executeQuery ( 'select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?' , array ( $ this -> cID , $ this -> cvID , ) ) ; while ( $ row = $ r -> fetch ( ) ) { $ cn = Page :: getByID ( $ row [ 'cRelationID' ] , $ row [ 'cvRelationID' ] ) ; $ cnp = new Permissions ( $ cn ) ; if ( $ cnp -> canApprovePageVersions ( ) ) { $ v = $ cn -> getVersionObject ( ) ; $ v -> delete ( ) ; $ db -> executeQuery ( 'delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?' , array ( $ this -> cID , $ this -> cvID , $ row [ 'cRelationID' ] , $ row [ 'cvRelationID' ] , ) ) ; } } $ this -> delete ( ) ; } $ this -> refreshCache ( ) ; }
Discard my most recent edit that is pending .
9,960
public function canDiscard ( ) { $ result = false ; if ( $ this -> isNew ( ) ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ total = $ db -> fetchColumn ( 'select count(cvID) from CollectionVersions where cID = ?' , array ( $ this -> cID , ) ) ; if ( $ total > 1 ) { $ result = true ; } } return $ result ; }
Check if this collection version can be discarded .
9,961
public function removeNewStatus ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ db -> executeQuery ( "update CollectionVersions set cvIsNew = 0 where cID = ? and cvID = ?" , array ( $ this -> cID , $ this -> cvID , ) ) ; $ this -> refreshCache ( ) ; }
Mark this collection version as not new .
9,962
public function deny ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ cvID = $ this -> cvID ; $ cID = $ this -> cID ; $ dh = $ app -> make ( 'helper/date' ) ; $ db -> executeQuery ( 'update Collections set cDateModified = ? where cID = ?' , array ( $ dh -> getOverridableNow ( ) , $ cID , ) ) ; $ v = array ( $ cID , ) ; $ q = "update CollectionVersions set cvIsApproved = 0 where cID = ?" ; $ db -> executeQuery ( $ q , $ v ) ; $ this -> cvIsApproved = 0 ; $ v2 = array ( $ cID , $ cvID , ) ; $ q2 = "update CollectionVersions set cvIsApproved = 0, cvApproverUID = 0 where cID = ? and cvID = ?" ; $ db -> executeQuery ( $ q2 , $ v2 ) ; $ this -> refreshCache ( ) ; }
Mark this collection version as not approved .
9,963
public function getSitemapGenerator ( ) { if ( $ this -> sitemapGenerator === null ) { $ this -> sitemapGenerator = $ this -> app -> make ( SitemapGenerator :: class ) ; } return $ this -> sitemapGenerator ; }
Get the SitemapGenerator instance to be used .
9,964
public function getOutputFilename ( ) { $ result = $ this -> outputFilename ; if ( $ result === '' ) { $ config = $ this -> app -> make ( 'config' ) ; $ relativeName = '/' . ltrim ( str_replace ( DIRECTORY_SEPARATOR , '/' , ( string ) $ config -> get ( 'concrete.sitemap_xml.file' ) ) , '/' ) ; if ( $ relativeName === '/' ) { $ relativeName = '/sitemap.xml' ; } $ result = rtrim ( DIR_BASE , '/' ) . $ relativeName ; } return $ result ; }
Get the path to the sitemap to be generated .
9,965
public function getSitemapUrl ( ) { $ outputFilename = $ this -> getOutputFilename ( ) ; if ( strpos ( $ outputFilename , DIR_BASE . '/' ) === 0 ) { $ result = ( string ) $ this -> getSitemapGenerator ( ) -> resolveUrl ( [ substr ( $ outputFilename , strlen ( DIR_BASE ) ) ] ) ; } else { $ result = '' ; } return $ result ; }
Get the URL of the sitemap corresponding to the output file name .
9,966
protected function getTemporaryDirectory ( ) { $ result = $ this -> temporaryDirectory ; if ( $ result === '' ) { $ fileHelper = $ this -> app -> make ( 'helper/file' ) ; $ temporaryDirectory = ( string ) $ fileHelper -> getTemporaryDirectory ( ) ; if ( $ temporaryDirectory === '' || ! $ this -> filesystem -> isDirectory ( $ temporaryDirectory ) ) { throw new UserMessageException ( t ( 'Unable to determine the temporary directory.' ) ) ; } $ this -> temporaryDirectory = $ temporaryDirectory ; } return $ this -> temporaryDirectory ; }
Get the temporary directory to be used during the sitemap generation .
9,967
public function getEntryDisplayName ( AssociationControl $ control , Entry $ entry ) { $ formatter = $ this -> getEntryFormatter ( ) ; $ name = null ; if ( $ mask = $ control -> getAssociationEntityLabelMask ( ) ) { $ name = $ formatter -> format ( $ mask , $ entry ) ; } $ name = $ entry -> getLabel ( ) ; if ( $ name = trim ( $ name ) ) { return $ name ; } return $ entry -> getID ( ) ; }
Get the display label for an entry
9,968
protected function getEntryFormatter ( ) { if ( ! $ this -> entryFormatter ) { $ this -> entryFormatter = Application :: getFacadeApplication ( ) -> make ( EntryFormatterInterface :: class ) ; } return $ this -> entryFormatter ; }
Get the entry formatter to use
9,969
public function getDriver ( ) { $ annotationDriver = new AnnotationDriver ( $ this -> app -> make ( 'orm/cachedAnnotationReader' ) , [ DIR_BASE_CORE . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES , ] ) ; return $ annotationDriver ; }
Get the AnnotationDriver
9,970
public static function getList ( $ sorted = false , $ activeOnly = false ) { $ list = [ ] ; $ db = Loader :: db ( ) ; $ q = $ db -> query ( 'SELECT * FROM AuthenticationTypes' . ( $ activeOnly ? ' WHERE authTypeIsEnabled=1 ' : '' ) . ' ORDER BY ' . ( $ sorted ? 'authTypeDisplayOrder' : 'authTypeID' ) ) ; while ( $ row = $ q -> fetchRow ( ) ) { $ list [ ] = self :: load ( $ row ) ; } return $ list ; }
Return a raw list of authentication types .
9,971
public static function load ( $ arr ) { $ extract = [ 'authTypeID' , 'authTypeName' , 'authTypeHandle' , 'authTypeDisplayOrder' , 'authTypeIsEnabled' , 'pkgID' , ] ; $ obj = new self ( ) ; foreach ( $ extract as $ key ) { if ( ! isset ( $ arr [ $ key ] ) ) { return false ; } $ obj -> { $ key } = $ arr [ $ key ] ; } $ obj -> loadController ( ) ; return $ obj ; }
Load an AuthenticationType from an array .
9,972
protected function loadController ( ) { $ env = Environment :: get ( ) ; $ r = $ env -> getRecord ( DIRNAME_AUTHENTICATION . '/' . $ this -> authTypeHandle . '/' . FILENAME_CONTROLLER ) ; $ prefix = $ r -> override ? true : $ this -> getPackageHandle ( ) ; $ authTypeHandle = Core :: make ( 'helper/text' ) -> camelcase ( $ this -> authTypeHandle ) ; $ class = core_class ( 'Authentication\\' . $ authTypeHandle . '\\Controller' , $ prefix ) ; $ this -> controller = Core :: make ( $ class , [ $ this ] ) ; }
Load the AuthenticationTypeController into the AuthenticationType .
9,973
public static function getByHandle ( $ atHandle ) { $ db = Loader :: db ( ) ; $ row = $ db -> GetRow ( 'SELECT * FROM AuthenticationTypes WHERE authTypeHandle=?' , [ $ atHandle ] ) ; if ( ! $ row ) { throw new Exception ( t ( 'Invalid Authentication Type Handle' ) ) ; } $ at = self :: load ( $ row ) ; return $ at ; }
Return loaded AuthenticationType with the given handle .
9,974
public static function getByID ( $ authTypeID ) { $ db = Loader :: db ( ) ; $ row = $ db -> GetRow ( 'SELECT * FROM AuthenticationTypes where authTypeID=?' , [ $ authTypeID ] ) ; if ( ! $ row ) { throw new Exception ( t ( 'Invalid Authentication Type ID' ) ) ; } $ at = self :: load ( $ row ) ; $ at -> loadController ( ) ; return $ at ; }
Return loaded AuthenticationType with the given ID .
9,975
public function setAuthenticationTypeName ( $ authTypeName ) { $ db = Loader :: db ( ) ; $ db -> Execute ( 'UPDATE AuthenticationTypes SET authTypeName=? WHERE authTypeID=?' , [ $ authTypeName , $ this -> getAuthenticationTypeID ( ) ] ) ; }
Update the name .
9,976
public function getAuthenticationTypeFilePath ( $ _file ) { $ f = $ this -> mapAuthenticationTypeFilePath ( $ _file ) ; if ( $ f -> exists ( ) ) { return $ f -> url ; } return false ; }
Return the path to a file .
9,977
public function renderForm ( $ element = 'form' , $ params = [ ] ) { $ this -> controller -> requireAsset ( 'javascript' , 'backstretch' ) ; $ form_element = $ this -> mapAuthenticationTypeFilePath ( $ element . '.php' ) ; if ( ! $ form_element -> exists ( ) ) { $ form_element = $ this -> mapAuthenticationTypeFilePath ( 'form.php' ) ; if ( method_exists ( $ this -> controller , 'form' ) ) { call_user_func_array ( [ $ this -> controller , 'form' ] , $ params ) ; } } ob_start ( ) ; if ( method_exists ( $ this -> controller , $ element ) ) { call_user_func_array ( [ $ this -> controller , $ element ] , $ params ) ; } else { $ this -> controller -> view ( ) ; } extract ( array_merge ( $ params , $ this -> controller -> getSets ( ) ) ) ; require $ form_element -> file ; $ out = ob_get_contents ( ) ; ob_end_clean ( ) ; echo $ out ; }
Render the login form for this authentication type .
9,978
public function renderHook ( ) { $ form_hook = $ this -> mapAuthenticationTypeFilePath ( 'hook.php' ) ; if ( method_exists ( $ this -> controller , 'hook' ) || $ form_hook -> exists ( ) ) { ob_start ( ) ; if ( method_exists ( $ this -> controller , 'hook' ) ) { $ this -> controller -> hook ( ) ; } if ( $ form_hook -> exists ( ) ) { $ controller = $ this -> controller ; extract ( $ this -> controller -> getSets ( ) ) ; require_once $ form_hook -> file ; } $ out = ob_get_contents ( ) ; ob_end_clean ( ) ; echo $ out ; } }
Render the hook form for saving the profile settings . All settings are expected to be saved by each individual authentication type .
9,979
public function renderHooked ( ) { $ form_hooked = $ this -> mapAuthenticationTypeFilePath ( 'hooked.php' ) ; if ( method_exists ( $ this -> controller , 'hooked' ) || $ form_hooked -> exists ( ) ) { ob_start ( ) ; if ( method_exists ( $ this -> controller , 'hooked' ) ) { $ this -> controller -> hooked ( ) ; } if ( $ form_hooked -> exists ( ) ) { $ controller = $ this -> controller ; extract ( $ this -> controller -> getSets ( ) ) ; require_once $ form_hooked -> file ; } $ out = ob_get_contents ( ) ; ob_end_clean ( ) ; echo $ out ; } }
Render the a form to be displayed when the authentication type is already hooked . All settings are expected to be saved by each individual authentication type .
9,980
public function isHooked ( $ user ) { $ result = null ; if ( is_callable ( [ $ this -> controller , 'getBindingForUser' ] ) ) { $ result = $ this -> controller -> getBindingForUser ( $ user ) !== null ; } else { $ result = null ; } return $ result ; }
Is this authentication type already hooked for a specific user?
9,981
public function save ( ) { $ em = Application :: getFacadeApplication ( ) -> make ( EntityManagerInterface :: class ) ; $ em -> persist ( $ this ) ; $ em -> flush ( ) ; }
Save this instance to the database .
9,982
public function getDriver ( ) { $ config = $ this -> config ; if ( $ this -> isLegacy ( ) ) { $ appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES ; $ reader = $ this -> app -> make ( 'orm/cachedSimpleAnnotationReader' ) ; } else { $ appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES ; $ reader = $ this -> app -> make ( 'orm/cachedAnnotationReader' ) ; } $ appDriverSettings = $ config -> get ( CONFIG_ORM_METADATA_APPLICATION ) ; $ xmlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_XML ; $ ymlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML ; if ( empty ( $ appDriverSettings ) && is_dir ( $ appEntityPath ) ) { return new AnnotationDriver ( $ reader , $ appEntityPath ) ; } else { if ( $ appDriverSettings === 'xml' ) { if ( is_dir ( $ xmlConfig ) ) { return new XmlDriver ( $ xmlConfig ) ; } else { return new AnnotationDriver ( $ reader , $ appEntityPath ) ; } } else { if ( $ appDriverSettings === 'yaml' || $ appDriverSettings === 'yml' ) { if ( is_dir ( $ ymlConfig ) ) { return new YamlDriver ( $ ymlConfig ) ; } else { return new AnnotationDriver ( $ reader , $ appEntityPath ) ; } } } } }
Return the correct MappingDriver base on the application config
9,983
public function isNativeCommandAvailable ( $ command ) { switch ( $ command ) { case 'zip' : case 'unzip' : break ; default : return false ; } if ( ! isset ( $ this -> availableNativeCommands [ $ command ] ) ) { $ this -> availableNativeCommands [ $ command ] = false ; if ( $ this -> functionInspector -> functionAvailable ( 'exec' ) ) { $ rc = 1 ; $ output = [ ] ; @ exec ( $ command . ' -v 2>&1' , $ output , $ rc ) ; if ( $ rc === 0 ) { $ stdOut = implode ( "\n" , $ output ) ; if ( stripos ( $ stdOut , 'info-zip' ) !== false || stripos ( $ stdOut , 'infozip' ) !== false ) { $ this -> availableNativeCommands [ $ command ] = true ; } } } } return $ this -> availableNativeCommands [ $ command ] ; }
Check if a native command is available .
9,984
public function unzip ( $ zipFile , $ destinationDirectory , array $ options = [ ] ) { $ fs = $ this -> getFilesystem ( ) ; $ normalized = @ realpath ( $ zipFile ) ; if ( $ normalized === false || ! $ fs -> isFile ( $ normalized ) ) { throw new Exception ( t ( 'Unable to find the ZIP file %s' , $ zipFile ) ) ; } $ zipFile = str_replace ( DIRECTORY_SEPARATOR , '/' , $ normalized ) ; $ normalized = @ realpath ( $ destinationDirectory ) ; if ( $ normalized === false || ! $ fs -> isDirectory ( $ normalized ) ) { throw new Exception ( t ( 'Unable to find the directory %s' , $ destinationDirectory ) ) ; } if ( ! $ fs -> isWritable ( $ normalized ) ) { throw new Exception ( t ( 'The directory "%s" is not writable' , $ destinationDirectory ) ) ; } $ destinationDirectory = str_replace ( DIRECTORY_SEPARATOR , '/' , $ normalized ) ; $ options += [ 'skipCheck' => false , ] ; if ( $ this -> mayUseNativeCommand ( 'unzip' ) ) { $ this -> unzipNative ( $ zipFile , $ destinationDirectory , $ options ) ; } else { $ this -> unzipPHP ( $ zipFile , $ destinationDirectory , $ options ) ; } }
Decompress a ZIP archive to a directory .
9,985
public function zip ( $ sourceDirectory , $ zipFile , array $ options = [ ] ) { $ fs = $ this -> getFilesystem ( ) ; $ normalized = @ realpath ( $ sourceDirectory ) ; if ( $ normalized === false || ! $ fs -> isDirectory ( $ normalized ) ) { throw new Exception ( t ( 'Unable to find the directory %s' , $ sourceDirectory ) ) ; } $ sourceDirectory = $ normalized ; $ zipFile = str_replace ( '/' , DIRECTORY_SEPARATOR , $ zipFile ) ; if ( $ fs -> exists ( $ zipFile ) ) { if ( $ fs -> isDirectory ( $ zipFile ) ) { throw new Exception ( t ( 'The specified path of the ZIP archive (%s) is a directory, not a file' , $ zipFile ) ) ; } $ options [ 'append' ] = isset ( $ options [ 'append' ] ) ? ( bool ) $ options [ 'append' ] : false ; if ( ! $ options [ 'append' ] ) { if ( @ $ fs -> delete ( [ $ zipFile ] ) === false ) { throw new Exception ( t ( 'Failed to delete file %s' , $ zipFile ) ) ; } } } else { $ options [ 'append' ] = false ; } $ options += [ 'includeDotFiles' => false , 'skipCheck' => false , 'level' => 9 , ] ; if ( $ this -> mayUseNativeCommand ( 'zip' ) ) { $ this -> zipNative ( $ sourceDirectory , $ zipFile , $ options ) ; } else { $ this -> zipPHP ( $ sourceDirectory , $ zipFile , $ options ) ; } }
Compress the contents of a directory to a ZIP archive .
9,986
public function listContents ( $ zipFile , array $ options = [ ] ) { $ fs = $ this -> getFilesystem ( ) ; if ( ! $ fs -> isFile ( $ zipFile ) ) { throw new Exception ( t ( 'Unable to find the ZIP file %s' , $ zipFile ) ) ; } $ options += [ 'skipCheck' => false , 'excludeDirs' => false , 'excludeFiles' => false , ] ; $ result = [ ] ; $ zip = new ZipArchive ( ) ; try { $ flags = 0 ; if ( ! $ options [ 'skipCheck' ] ) { $ flags |= ZipArchive :: CHECKCONS ; } $ zipErr = @ $ zip -> open ( $ zipFile , $ flags ) ; if ( $ zipErr !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , $ zipErr ) ) ; } for ( $ index = 0 ; $ index < $ zip -> numFiles ; ++ $ index ) { $ stat = @ $ zip -> statIndex ( $ index ) ; if ( $ stat === false ) { throw new Exception ( t ( 'Failed to retrieve the details of a ZIP archive entry.' ) ) ; } $ isDir = substr ( $ stat [ 'name' ] , - 1 ) === '/' || substr ( $ stat [ 'name' ] , - 1 ) === '\\' ; if ( $ isDir ) { if ( $ options [ 'excludeDirs' ] ) { continue ; } } else { if ( $ options [ 'excludeFiles' ] ) { continue ; } } $ item = [ 'type' => $ isDir ? 'D' : 'F' , 'date' => ( isset ( $ stat [ 'mtime' ] ) && $ stat [ 'mtime' ] ) ? DateTime :: createFromFormat ( 'U' , $ stat [ 'mtime' ] ) : null , ] ; if ( ! $ isDir ) { $ item += [ 'originalSize' => isset ( $ stat [ 'size' ] ) ? ( int ) $ stat [ 'size' ] : null , 'compressedSize' => isset ( $ stat [ 'comp_size' ] ) ? ( int ) $ stat [ 'comp_size' ] : null , ] ; } $ result [ trim ( $ stat [ 'name' ] , '/\\' ) ] = $ item ; } @ $ zip -> close ( ) ; $ zip = null ; } catch ( Exception $ x ) { if ( $ zip !== null ) { try { @ $ zip -> close ( ) ; } catch ( \ Exception $ foo ) { } $ zip = null ; } throw $ x ; } return $ result ; }
List the contents of a ZIP archive .
9,987
protected function unzipNative ( $ zipFile , $ destinationDirectory , array $ options ) { $ cmd = 'unzip' ; $ cmd .= ' -o' ; $ cmd .= ' -q' ; $ cmd .= ' ' . escapeshellarg ( str_replace ( '/' , DIRECTORY_SEPARATOR , $ zipFile ) ) ; $ cmd .= ' -d ' . escapeshellarg ( str_replace ( '/' , DIRECTORY_SEPARATOR , $ destinationDirectory ) ) ; $ rc = 1 ; $ output = [ ] ; @ exec ( $ cmd . ' 2>&1' , $ output , $ rc ) ; if ( $ rc !== 0 ) { $ error = trim ( implode ( "\n" , $ output ) ) ? : t ( 'Unknown error decompressing a ZIP archive' ) ; throw new Exception ( $ error ) ; } }
Decompress a ZIP archive to a directory using the native unzip command .
9,988
protected function unzipPHP ( $ zipFile , $ destinationDirectory , array $ options ) { if ( ! class_exists ( 'ZipArchive' ) ) { throw new Exception ( 'Unable to unzip files using ZipArchive. Please ensure the Zip extension is installed.' ) ; } $ zip = new ZipArchive ( ) ; try { $ flags = 0 ; if ( ! $ options [ 'skipCheck' ] ) { $ flags |= ZipArchive :: CHECKCONS ; } $ zipErr = @ $ zip -> open ( $ zipFile , $ flags ) ; if ( $ zipErr !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , $ zipErr ) ) ; } if ( @ $ zip -> extractTo ( $ destinationDirectory ) !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , ZipArchive :: ER_OK ) ) ; } @ $ zip -> close ( ) ; $ zip = null ; } catch ( Exception $ x ) { if ( $ zip !== null ) { try { @ $ zip -> close ( ) ; } catch ( \ Exception $ foo ) { } $ zip = null ; } throw $ x ; } }
Decompress a ZIP archive to a directory using the PHP functions .
9,989
protected function zipPHP ( $ sourceDirectory , $ zipFile , array $ options ) { if ( ! class_exists ( 'ZipArchive' ) ) { throw new Exception ( 'Unable to zip files using ZipArchive. Please ensure the Zip extension is installed.' ) ; } $ zip = new ZipArchive ( ) ; try { $ flags = ZipArchive :: CREATE ; if ( ! $ options [ 'skipCheck' ] ) { $ flags |= ZipArchive :: CHECKCONS ; } $ zipErr = @ $ zip -> open ( $ zipFile , $ flags ) ; if ( $ zipErr !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , $ zipErr ) ) ; } $ skipPathLength = strlen ( rtrim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ sourceDirectory ) , '/' ) ) + 1 ; $ contents = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ sourceDirectory ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ contents as $ item ) { switch ( $ item -> getFilename ( ) ) { case '.' : case '..' : break ; default : $ itemFullPath = $ item -> getRealPath ( ) ; $ itemRelPath = substr ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ itemFullPath ) , $ skipPathLength ) ; if ( $ options [ 'includeDotFiles' ] || ( strpos ( $ itemRelPath , '.' ) !== 0 && strpos ( $ itemRelPath , '/.' ) === false ) ) { if ( $ item -> isDir ( ) ) { $ added = @ $ zip -> addEmptyDir ( $ itemRelPath ) ; } else { $ added = @ $ zip -> addFile ( $ itemFullPath , $ itemRelPath ) ; } if ( $ added !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , ZipArchive :: ER_OK ) ) ; } } break ; } } if ( @ $ zip -> close ( ) !== true ) { throw new Exception ( $ this -> describeZipArchiveError ( $ zip , ZipArchive :: ER_OK ) ) ; } $ zip = null ; } catch ( Exception $ x ) { if ( $ zip !== null ) { try { @ $ zip -> close ( ) ; } catch ( \ Exception $ foo ) { } $ zip = null ; } @ $ this -> getFilesystem ( ) -> delete ( [ $ zipFile ] ) ; throw $ x ; } }
Compress the contents of a directory to a ZIP archive using the PHP functions .
9,990
protected function getFilenameForMutexKey ( $ mutexKey ) { $ mutexKeyString = ( is_string ( $ mutexKey ) || is_int ( $ mutexKey ) ) ? ( string ) $ mutexKey : '' ; if ( $ mutexKeyString === '' ) { throw new InvalidMutexKeyException ( $ mutexKey ) ; } if ( preg_match ( '/^[a-zA-Z0-9_\-]{1,50}$/' , $ mutexKeyString ) ) { $ filenameChunk = $ mutexKeyString ; } else { $ filenameChunk = sha1 ( $ mutexKeyString ) ; } return $ this -> temporaryDirectory . '/mutex-' . md5 ( DIR_APPLICATION ) . '-' . $ filenameChunk . '.lock' ; }
Get the full path of a temporary file that s unique for the concrete5 application and for the specified mutex key .
9,991
public function filterByTag ( $ tag = '' ) { $ db = Loader :: db ( ) ; $ this -> filter ( false , "( fv.fvTags like " . $ db -> qstr ( "%\n" . $ tag . "\n%" ) . " )" ) ; }
Filters by tag .
9,992
public function get ( $ itemsToGet = 0 , $ offset = 0 ) { $ files = array ( ) ; $ this -> createQuery ( ) ; $ r = parent :: get ( $ itemsToGet , $ offset ) ; foreach ( $ r as $ row ) { $ f = ConcreteFile :: getByID ( $ row [ 'fID' ] ) ; $ files [ ] = $ f ; } return $ files ; }
Returns an array of file objects based on current settings .
9,993
public function register ( $ plugin , $ name = null ) { if ( $ plugin instanceof Plugin ) { $ key = $ plugin -> getKey ( ) ; $ p = $ plugin ; } else { if ( ! $ name ) { throw new Exception ( t ( 'You must specify a plugin key and name.' ) ) ; } $ key = $ plugin ; $ p = new Plugin ( ) ; $ p -> setKey ( $ key ) ; $ p -> setName ( $ name ) ; } $ this -> plugins [ $ key ] = $ p ; }
Register a new plugin adding it to the list of available plugins .
9,994
public function load_starting ( ) { $ node = $ this -> loadNode ( ) ; $ r = array ( ) ; foreach ( $ node -> getChildNodes ( ) as $ childnode ) { $ json = $ childnode -> getTreeNodeJSON ( ) ; if ( $ json ) { $ r [ ] = $ json ; } } $ node = $ node -> getTreeNodeJSON ( ) ; $ node -> children = $ r ; return new JsonResponse ( [ $ node ] ) ; }
This endpoint is meant to be called when we are starting from a particular spot in the tree . It will include the current node and the children while normally loading the node will only return the children .
9,995
public function load ( ) { $ node = $ this -> loadNode ( ) ; $ r = array ( ) ; foreach ( $ node -> getChildNodes ( ) as $ childnode ) { $ json = $ childnode -> getTreeNodeJSON ( ) ; if ( $ json ) { $ r [ ] = $ json ; } } return new JsonResponse ( $ r ) ; }
Returns the child nodes of the current node .
9,996
public function process ( Request $ request , DelegateInterface $ frame ) { \ Concrete \ Core \ Http \ Request :: setInstance ( $ request ) ; $ this -> app -> instance ( 'Concrete\Core\Http\Request' , $ request ) ; return $ frame -> next ( $ request ) ; }
Apply the request instance to the request singleton
9,997
public function filterByAssignable ( ) { if ( Config :: get ( 'concrete.permissions.model' ) != 'simple' ) { $ excludeGroupIDs = [ GUEST_GROUP_ID , REGISTERED_GROUP_ID ] ; $ db = Loader :: db ( ) ; $ r = $ db -> executeQuery ( 'select gID from ' . $ db -> getDatabasePlatform ( ) -> quoteSingleIdentifier ( 'Groups' ) . ' where gID > ?' , [ REGISTERED_GROUP_ID ] ) ; while ( $ row = $ r -> FetchRow ( ) ) { $ g = Group :: getByID ( $ row [ 'gID' ] ) ; $ gp = new Permissions ( $ g ) ; if ( ! $ gp -> canAssignGroup ( ) ) { $ excludeGroupIDs [ ] = $ row [ 'gID' ] ; } } $ this -> query -> andWhere ( $ this -> query -> expr ( ) -> notIn ( 'g.gId' , array_map ( [ $ db , 'quote' ] , $ excludeGroupIDs ) ) ) ; } }
Only return groups the user has the ability to assign .
9,998
public function hasError ( ) { $ error = $ this -> getError ( ) ; if ( $ error instanceof ErrorList ) { return $ error -> has ( ) ; } if ( $ error instanceof Exception ) { return true ; } return ( string ) $ error !== '' ; }
Does this response contain an error?
9,999
public function getBaseJSONObject ( ) { $ o = new stdClass ( ) ; $ error = $ this -> getError ( ) ; if ( $ error instanceof Exception ) { $ o -> error = true ; $ o -> errors = [ $ error -> getMessage ( ) ] ; } elseif ( $ error instanceof ErrorList && $ error -> has ( ) ) { $ o -> error = true ; $ o -> errors = [ ] ; foreach ( $ error -> getList ( ) as $ e ) { $ o -> errors [ ] = ( string ) $ e ; } } else { $ error = ( string ) $ error ; if ( $ error !== '' ) { $ o -> error = true ; $ o -> errors = [ $ error ] ; } } $ o -> time = $ this -> getTime ( ) ; $ o -> message = $ this -> getMessage ( ) ; $ o -> title = $ this -> getTitle ( ) ; $ o -> redirectURL = ( string ) $ this -> getRedirectURL ( ) ; foreach ( $ this -> additionalData as $ key => $ value ) { $ o -> { $ key } = $ value ; } return $ o ; }
Get an stdClass instance containing the serialized data of this instance .