idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
46,800
private function existCertificate ( ) { if ( isset ( $ this -> config [ 'certificate' ] ) ) { $ certificate = $ this -> config [ 'certificate' ] ; if ( ! file_exists ( $ certificate ) ) { $ this -> messageNoExistCertificate ( ) ; return false ; } return true ; } $ this -> messageNoExistCertificate ( ) ; return false ; ...
Check if the certificate file exist .
46,801
private function composeStreamSocket ( ) { $ ctx = stream_context_create ( ) ; $ certificate = $ this -> config [ 'certificate' ] ; stream_context_set_option ( $ ctx , 'ssl' , 'local_cert' , $ certificate ) ; if ( isset ( $ this -> config [ 'passPhrase' ] ) ) { $ passPhrase = $ this -> config [ 'passPhrase' ] ; if ( ! ...
Compose the stream socket
46,802
private function openConnectionAPNS ( $ ctx ) { $ fp = false ; try { $ fp = stream_socket_client ( $ this -> url , $ err , $ errstr , 60 , STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT , $ ctx ) ; stream_set_blocking ( $ fp , 0 ) ; if ( ! $ fp ) { $ response = [ 'success' => false , 'error' => "Failed to connect: $e...
Create the connection to APNS server If some error the error is stored in class feedback property . IF OKAY return connection
46,803
public function apnsFeedback ( ) { $ feedback_tokens = array ( ) ; if ( ! $ this -> existCertificate ( ) ) { return $ feedback_tokens ; } $ ctx = $ this -> composeStreamSocket ( ) ; try { $ apns = stream_socket_client ( $ this -> feedbackUrl , $ errcode , $ errstr , 60 , STREAM_CLIENT_CONNECT , $ ctx ) ; while ( ! feof...
Get the unregistered device tokens from the apns feedback . Connect to apn server in order to collect the tokens of the apps which were removed from the device .
46,804
private function updateCustomFeedbackValues ( $ apnsFeedback , $ feedback , $ deviceTokens ) { $ feedback [ 'failure' ] += count ( $ apnsFeedback [ 'apnsFeedback' ] ) ; $ apnsTokens = array_pluck ( $ apnsFeedback [ 'apnsFeedback' ] , 'devtoken' ) ; foreach ( $ deviceTokens as $ token ) { if ( in_array ( $ token , $ apn...
Update the success and failure values based on apple feedback
46,805
public function getUnregisteredDeviceTokens ( array $ devices_token ) { if ( $ this -> feedback && isset ( $ this -> feedback -> failure ) ) { $ unRegisteredTokens = $ devices_token ; foreach ( $ this -> feedback -> results as $ key => $ message ) { if ( ! isset ( $ message -> error ) ) { unset ( $ unRegisteredTokens [...
Provide the unregistered tokens of the sent notification .
46,806
protected function addRequestFields ( $ deviceTokens , $ message ) { $ params = $ this -> cleanConfigParams ( ) ; $ message = $ this -> buildMessage ( $ message ) ; return array_merge ( $ params , $ message , [ 'registration_ids' => $ deviceTokens ] ) ; }
Set the needed fields for the push notification
46,807
private function cleanConfigParams ( ) { $ paramsToBeRemoved = [ 'apiKey' ] ; return array_filter ( $ this -> config , function ( $ key ) use ( $ paramsToBeRemoved ) { return ! in_array ( $ key , $ paramsToBeRemoved ) ; } , ARRAY_FILTER_USE_KEY ) ; }
Clean the config params from unnecessary params no to make the notification too heavy .
46,808
public function remove ( Item $ item ) : void { foreach ( $ this -> list as $ key => $ itemToCheck ) { if ( $ itemToCheck === $ item ) { unset ( $ this -> list [ $ key ] ) ; break ; } } }
Remove item from list .
46,809
public function getFootprint ( ) : int { $ layerWidth = 0 ; $ layerLength = 0 ; foreach ( $ this -> items as $ item ) { $ layerWidth = max ( $ layerWidth , $ item -> getX ( ) + $ item -> getWidth ( ) ) ; $ layerLength = max ( $ layerLength , $ item -> getY ( ) + $ item -> getLength ( ) ) ; } return $ layerWidth * $ lay...
Calculate footprint area of this layer .
46,810
public function getStartDepth ( ) : int { $ startDepth = PHP_INT_MAX ; foreach ( $ this -> items as $ item ) { $ startDepth = min ( $ startDepth , $ item -> getZ ( ) ) ; } return $ startDepth ; }
Calculate start depth of this layer .
46,811
public function getDepth ( ) : int { $ layerDepth = 0 ; foreach ( $ this -> items as $ item ) { $ layerDepth = max ( $ layerDepth , $ item -> getZ ( ) + $ item -> getDepth ( ) ) ; } return $ layerDepth - $ this -> getStartDepth ( ) ; }
Calculate depth of this layer .
46,812
public function getItemWeight ( ) : int { if ( $ this -> itemWeight !== null ) { return $ this -> itemWeight ; } $ this -> itemWeight = 0 ; foreach ( $ this -> items as $ item ) { $ this -> itemWeight += $ item -> getItem ( ) -> getWeight ( ) ; } return $ this -> itemWeight ; }
Get packed weight of the items only .
46,813
public function getUsedWidth ( ) : int { $ maxWidth = 0 ; foreach ( $ this -> items as $ item ) { $ maxWidth = max ( $ maxWidth , $ item -> getX ( ) + $ item -> getWidth ( ) ) ; } return $ maxWidth ; }
Used width inside box for packing items .
46,814
public function getUsedLength ( ) : int { $ maxLength = 0 ; foreach ( $ this -> items as $ item ) { $ maxLength = max ( $ maxLength , $ item -> getY ( ) + $ item -> getLength ( ) ) ; } return $ maxLength ; }
Used length inside box for packing items .
46,815
public function getUsedDepth ( ) : int { $ maxDepth = 0 ; foreach ( $ this -> items as $ item ) { $ maxDepth = max ( $ maxDepth , $ item -> getZ ( ) + $ item -> getDepth ( ) ) ; } return $ maxDepth ; }
Used depth inside box for packing items .
46,816
public function getUsedVolume ( ) : int { $ volume = 0 ; foreach ( $ this -> items as $ item ) { $ volume += $ item -> getVolume ( ) ; } return $ volume ; }
Get used volume of the packed box .
46,817
public function pack ( ) : PackedBox { $ this -> logger -> debug ( "[EVALUATING BOX] {$this->box->getReference()}" , [ 'box' => $ this -> box ] ) ; while ( count ( $ this -> items ) > 0 ) { $ layerStartDepth = $ this -> getCurrentPackedDepth ( ) ; $ this -> packLayer ( $ layerStartDepth , $ this -> boxWidth , $ this ->...
Pack as many items as possible into specific given box .
46,818
public function stabiliseLayers ( ) : void { $ stabiliser = new LayerStabiliser ( ) ; $ this -> layers = $ stabiliser -> stabilise ( $ this -> layers ) ; }
During packing it is quite possible that layers have been created that aren t physically stable i . e . they overhang the ones below .
46,819
protected function tryAndStackItemsIntoSpace ( PackedLayer $ layer , ? PackedItem $ prevItem , ItemList $ nextItems , int $ maxWidth , int $ maxLength , int $ maxDepth , int $ x , int $ y , int $ z , int $ rowLength ) : void { while ( count ( $ this -> items ) > 0 && $ this -> checkNonDimensionalConstraints ( $ this ->...
Figure out if we can stack the next item vertically on top of this rather than side by side Used when we ve packed a tall item and have just put a shorter one next to it .
46,820
protected function checkConstraints ( Item $ itemToPack ) : bool { return $ this -> checkNonDimensionalConstraints ( $ itemToPack ) && $ this -> checkDimensionalConstraints ( $ itemToPack ) ; }
Check item generally fits into box .
46,821
protected function rebuildItemList ( ? Item $ currentItem = null ) : void { if ( count ( $ this -> items ) === 0 ) { $ this -> items = $ this -> skippedItems ; $ this -> skippedItems = new ItemList ( ) ; } if ( $ currentItem instanceof Item ) { $ this -> items -> insert ( $ currentItem ) ; } }
Reintegrate skipped items into main list .
46,822
protected function getPackedItemList ( ) : PackedItemList { $ packedItemList = new PackedItemList ( ) ; foreach ( $ this -> layers as $ layer ) { foreach ( $ layer -> getItems ( ) as $ packedItem ) { $ packedItemList -> insert ( $ packedItem ) ; } } return $ packedItemList ; }
Generate a single list of items packed .
46,823
protected function getCurrentPackedDepth ( ) : int { $ depth = 0 ; foreach ( $ this -> layers as $ layer ) { $ depth += $ layer -> getDepth ( ) ; } return $ depth ; }
Return the current packed depth .
46,824
public function getBestOrientation ( Item $ item , ? OrientatedItem $ prevItem , ItemList $ nextItems , bool $ isLastItem , int $ widthLeft , int $ lengthLeft , int $ depthLeft , int $ rowLength ) : ? OrientatedItem { $ possibleOrientations = $ this -> getPossibleOrientations ( $ item , $ prevItem , $ widthLeft , $ len...
Get the best orientation for an item .
46,825
public function getPossibleOrientations ( Item $ item , ? OrientatedItem $ prevItem , int $ widthLeft , int $ lengthLeft , int $ depthLeft ) : array { $ orientations = [ ] ; if ( $ prevItem && $ this -> isSameDimensions ( $ prevItem -> getItem ( ) , $ item ) ) { $ orientations [ ] = new OrientatedItem ( $ item , $ prev...
Find all possible orientations for an item .
46,826
protected function getStableOrientationsInEmptyBox ( Item $ item ) : array { $ orientationsInEmptyBox = $ this -> getPossibleOrientationsInEmptyBox ( $ item ) ; return array_filter ( $ orientationsInEmptyBox , function ( OrientatedItem $ orientation ) { return $ orientation -> isStable ( ) ; } ) ; }
Return the orientations for this item if it were to be placed into the box with nothing else .
46,827
protected function isSameDimensions ( Item $ itemA , Item $ itemB ) : bool { $ itemADimensions = [ $ itemA -> getWidth ( ) , $ itemA -> getLength ( ) , $ itemA -> getDepth ( ) ] ; $ itemBDimensions = [ $ itemB -> getWidth ( ) , $ itemB -> getLength ( ) , $ itemB -> getDepth ( ) ] ; sort ( $ itemADimensions ) ; sort ( $...
Compare two items to see if they have same dimensions .
46,828
protected function calculateAdditionalItemsPackedWithThisOrientation ( OrientatedItem $ prevItem , ItemList $ nextItems , int $ originalWidthLeft , int $ originalLengthLeft , int $ depthLeft , int $ currentRowLengthBeforePacking ) : int { $ packedCount = 0 ; $ currentRowLength = max ( $ prevItem -> getLength ( ) , $ cu...
Approximation of a forward - looking packing .
46,829
public function getWeightVariance ( ) : float { $ mean = $ this -> getMeanWeight ( ) ; $ weightVariance = 0 ; foreach ( $ this -> list as $ box ) { $ weightVariance += ( $ box -> getWeight ( ) - $ mean ) ** 2 ; } return round ( $ weightVariance / count ( $ this -> list ) , 1 ) ; }
Calculate the variance in weight between these boxes .
46,830
public function getVolumeUtilisation ( ) : float { $ itemVolume = 0 ; $ boxVolume = 0 ; foreach ( $ this as $ box ) { $ boxVolume += $ box -> getInnerVolume ( ) ; foreach ( $ box -> getItems ( ) as $ item ) { $ itemVolume += ( $ item -> getItem ( ) -> getWidth ( ) * $ item -> getItem ( ) -> getLength ( ) * $ item -> ge...
Get volume utilisation of the set of packed boxes .
46,831
public function redistributeWeight ( PackedBoxList $ originalBoxes ) : PackedBoxList { $ targetWeight = $ originalBoxes -> getMeanWeight ( ) ; $ this -> logger -> log ( LogLevel :: DEBUG , "repacking for weight distribution, weight variance {$originalBoxes->getWeightVariance()}, target weight {$targetWeight}" ) ; $ box...
Given a solution set of packed boxes repack them to achieve optimum weight distribution .
46,832
private function equaliseWeight ( PackedBox & $ boxA , PackedBox & $ boxB , float $ targetWeight ) : bool { $ anyIterationSuccessful = false ; if ( $ boxA -> getWeight ( ) > $ boxB -> getWeight ( ) ) { $ overWeightBox = $ boxA ; $ underWeightBox = $ boxB ; } else { $ overWeightBox = $ boxB ; $ underWeightBox = $ boxA ;...
Attempt to equalise weight distribution between 2 boxes .
46,833
private function doVolumeRepack ( iterable $ items ) : PackedBoxList { $ packer = new Packer ( ) ; $ packer -> setBoxes ( $ this -> boxes ) ; $ packer -> setItems ( $ items ) ; return $ packer -> doVolumePacking ( ) ; }
Do a volume repack of a set of items .
46,834
private function didRepackActuallyHelp ( PackedBox $ oldBoxA , PackedBox $ oldBoxB , PackedBox $ newBoxA , PackedBox $ newBoxB ) : bool { $ oldList = new PackedBoxList ( ) ; $ oldList -> insertFromArray ( [ $ oldBoxA , $ oldBoxB ] ) ; $ newList = new PackedBoxList ( ) ; $ newList -> insertFromArray ( [ $ newBoxA , $ ne...
Not every attempted repack is actually helpful - sometimes moving an item between two otherwise identical boxes or sometimes the box used for the now lighter set of items actually weighs more when empty causing an increase in total weight .
46,835
public function addItem ( Item $ item , int $ qty = 1 ) : void { for ( $ i = 0 ; $ i < $ qty ; ++ $ i ) { $ this -> items -> insert ( $ item ) ; } $ this -> logger -> log ( LogLevel :: INFO , "added {$qty} x {$item->getDescription()}" , [ 'item' => $ item ] ) ; }
Add item to be packed .
46,836
public function setItems ( iterable $ items ) : void { if ( $ items instanceof ItemList ) { $ this -> items = clone $ items ; } else { $ this -> items = new ItemList ( ) ; foreach ( $ items as $ item ) { $ this -> items -> insert ( $ item ) ; } } }
Set a list of items all at once .
46,837
public function addBox ( Box $ box ) : void { $ this -> boxes -> insert ( $ box ) ; $ this -> logger -> log ( LogLevel :: INFO , "added box {$box->getReference()}" , [ 'box' => $ box ] ) ; }
Add box size .
46,838
public function pack ( ) : PackedBoxList { $ packedBoxes = $ this -> doVolumePacking ( ) ; if ( $ packedBoxes -> count ( ) > 1 && $ packedBoxes -> count ( ) <= $ this -> maxBoxesToBalanceWeight ) { $ redistributor = new WeightRedistributor ( $ this -> boxes ) ; $ redistributor -> setLogger ( $ this -> logger ) ; $ pack...
Pack items into boxes .
46,839
public function doVolumePacking ( ) : PackedBoxList { $ packedBoxes = new PackedBoxList ( ) ; while ( $ this -> items -> count ( ) ) { $ packedBoxesIteration = [ ] ; foreach ( $ this -> boxes as $ box ) { $ volumePacker = new VolumePacker ( $ box , clone $ this -> items ) ; $ volumePacker -> setLogger ( $ this -> logge...
Pack items into boxes using the principle of largest volume item first .
46,840
public function has ( TypeConverterInterface $ converter ) : bool { $ serialized = $ this -> serialize ( $ converter ) ; if ( isset ( $ this -> converters [ $ serialized ] ) ) { return true ; } return false ; }
Returns true if the collection contains a type converter for a certain namespace and name
46,841
public function load ( InputInterface $ input ) : ConfigInterface { $ configFile = $ input -> getOption ( 'config' ) ; if ( ! $ configFile || ! $ this -> filesystem -> fileExists ( $ configFile ) ) { throw InvalidArgumentException :: invalidConfigFile ( ) ; } $ config = include $ configFile ; if ( ! $ config instanceof...
Attempts to load the configuration file returns it on success
46,842
public function debugLastSoapRequest ( ) : array { $ lastRequestInfo = $ this -> engine -> collectLastRequestInfo ( ) ; return [ 'request' => [ 'headers' => trim ( $ this -> soapClient -> __getLastRequestHeaders ( ) ) , 'body' => XmlFormatter :: format ( $ this -> soapClient -> __getLastRequest ( ) ) , ] , 'response' =...
Make it possible to debug the last request .
46,843
public function assemble ( ContextInterface $ context ) { $ class = $ context -> getClass ( ) ; $ property = $ context -> getProperty ( ) ; try { $ methodName = Normalizer :: generatePropertyMethod ( 'with' , $ property -> getName ( ) ) ; $ class -> removeMethod ( $ methodName ) ; $ lines = [ sprintf ( '$new = clone $t...
Assembles pieces of code .
46,844
protected function file ( $ name ) { $ path = PathHelper :: normalizePath ( $ this -> path . DIRECTORY_SEPARATOR . str_replace ( '.' , '/' , $ name ) . '.blade.php' ) ; return file_exists ( $ path ) ? file_get_contents ( $ path ) : '' ; }
Get the contents of one of the view with the given name .
46,845
public function anchors ( HTTPRequest $ request ) { $ id = ( int ) $ this -> getRequest ( ) -> param ( 'PageID' ) ; $ anchors = $ this -> getAnchorsInPage ( $ id ) ; return json_encode ( $ anchors ) ; }
Find all anchors available on the given page .
46,846
protected function getAnchorsInPage ( $ id ) { $ page = SiteTree :: get ( ) -> byID ( $ id ) ; if ( ! $ page || ! $ page -> canView ( ) ) { return [ ] ; } return $ page -> getAnchorsOnPage ( ) ; }
Get anchors in the given page ID .
46,847
public function getFilteredPages ( ) { $ pages = Versioned :: get_by_stage ( SiteTree :: class , 'Stage' ) ; $ pages = $ this -> applyDefaultFilters ( $ pages ) ; $ pages = $ pages -> filterByCallback ( function ( SiteTree $ page ) { return $ page -> isOnDraftOnly ( ) ; } ) ; return $ pages ; }
Filters out all pages who s status is set to Draft .
46,848
public function addtocampaign ( $ data , $ form ) { $ id = $ data [ 'ID' ] ; $ record = \ Page :: get ( ) -> byID ( $ id ) ; $ handler = AddToCampaignHandler :: create ( $ this , $ record ) ; $ results = $ handler -> addToCampaign ( $ record , $ data ) ; if ( is_null ( $ results ) ) { return null ; } if ( $ this -> get...
Action handler for adding pages to a campaign
46,849
public function getAbsoluteLiveLink ( $ includeStageEqualsLive = true ) { $ oldReadingMode = Versioned :: get_reading_mode ( ) ; Versioned :: set_stage ( Versioned :: LIVE ) ; $ live = Versioned :: get_one_by_stage ( self :: class , Versioned :: LIVE , array ( '"SiteTree"."ID"' => $ this -> ID ) ) ; if ( $ live ) { $ l...
Get the absolute URL for this page on the Live site .
46,850
public function duplicateWithChildren ( ) { $ clone = $ this -> duplicate ( ) ; $ children = $ this -> AllChildren ( ) ; if ( $ children ) { $ sort = 0 ; foreach ( $ children as $ child ) { $ childClone = method_exists ( $ child , 'duplicateWithChildren' ) ? $ child -> duplicateWithChildren ( ) : $ child -> duplicate (...
Duplicates each child of this node recursively and returns the top - level duplicate node .
46,851
public function duplicateAsChild ( $ id ) { $ newSiteTree = $ this -> duplicate ( ) ; $ newSiteTree -> ParentID = $ id ; $ newSiteTree -> Sort = 0 ; $ newSiteTree -> write ( ) ; }
Duplicate this node and its children as a child of the node with the given ID
46,852
public function getBreadcrumbItems ( $ maxDepth = 20 , $ stopAtPageType = false , $ showHidden = false ) { $ page = $ this ; $ pages = array ( ) ; while ( $ page && $ page -> exists ( ) && ( ! $ maxDepth || count ( $ pages ) < $ maxDepth ) && ( ! $ stopAtPageType || $ page -> ClassName != $ stopAtPageType ) ) { if ( $ ...
Returns a list of breadcrumbs for the current page .
46,853
public function setParent ( $ item ) { if ( is_object ( $ item ) ) { if ( ! $ item -> exists ( ) ) { $ item -> write ( ) ; } $ this -> setField ( "ParentID" , $ item -> ID ) ; } else { $ this -> setField ( "ParentID" , $ item ) ; } }
Make this page a child of another page .
46,854
public function getParent ( ) { $ parentID = $ this -> getField ( "ParentID" ) ; if ( $ parentID ) { return SiteTree :: get_by_id ( self :: class , $ parentID ) ; } return null ; }
Get the parent of this page .
46,855
public function NestedTitle ( $ level = 2 , $ separator = " - " ) { $ item = $ this ; $ parts = [ ] ; while ( $ item && $ level > 0 ) { $ parts [ ] = $ item -> Title ; $ item = $ item -> getParent ( ) ; $ level -- ; } return implode ( $ separator , array_reverse ( $ parts ) ) ; }
Return a string of the form parent - page or grandparent - parent - page using page titles
46,856
public function can ( $ perm , $ member = null , $ context = array ( ) ) { if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } if ( $ member && Permission :: checkMember ( $ member , "ADMIN" ) ) { return true ; } if ( is_string ( $ perm ) && method_exists ( $ this , 'can' . ucfirst ( $ perm ) ) ) { $ meth...
This function should return true if the current user can execute this action . It can be overloaded to customise the security model for an application .
46,857
public function canAddChildren ( $ member = null ) { if ( ! $ this -> isOnDraft ( ) ) { return false ; } if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } $ extended = $ this -> extendedCan ( 'canAddChildren' , $ member ) ; if ( $ extended !== null ) { return $ extended ; } if ( $ member && Permission :...
This function should return true if the current user can add children to this page . It can be overloaded to customise the security model for an application .
46,858
public function canView ( $ member = null ) { if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } $ extended = $ this -> extendedCan ( 'canView' , $ member ) ; if ( $ extended !== null ) { return $ extended ; } if ( $ member && Permission :: checkMember ( $ member , array ( "ADMIN" , "SITETREE_VIEW_ALL" )...
This function should return true if the current user can view this page . It can be overloaded to customise the security model for an application .
46,859
public function canCreate ( $ member = null , $ context = array ( ) ) { if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } $ parent = isset ( $ context [ 'Parent' ] ) ? $ context [ 'Parent' ] : null ; $ strictParentInstance = ( $ parent && $ parent instanceof SiteTree ) ; if ( $ strictParentInstance && !...
This function should return true if the current user can create new pages of this class regardless of class . It can be overloaded to customise the security model for an application .
46,860
public function collateDescendants ( $ condition , & $ collator ) { $ threshold = Config :: inst ( ) -> get ( Hierarchy :: class , 'node_threshold_leaf' ) ; if ( $ this -> numChildren ( ) > $ threshold ) { return false ; } $ children = $ this -> Children ( ) ; if ( $ children ) { foreach ( $ children as $ item ) { if (...
Collate selected descendants of this page .
46,861
public function MetaTags ( $ includeTitle = true ) { $ tags = [ ] ; $ tagsArray = $ this -> MetaComponents ( ) ; if ( ! $ includeTitle || strtolower ( $ includeTitle ) == 'false' ) { unset ( $ tagsArray [ 'title' ] ) ; } foreach ( $ tagsArray as $ tagProps ) { $ tag = array_merge ( [ 'tag' => 'meta' , 'attributes' => [...
Return the title description keywords and language metatags .
46,862
public function flushMemberCache ( $ memberIDs = null ) { $ cache = SiteTree :: singleton ( ) -> getCreatableChildrenCache ( ) ; if ( ! $ memberIDs ) { $ cache -> clear ( ) ; return ; } foreach ( $ memberIDs as $ memberID ) { $ key = $ this -> generateChildrenCacheKey ( $ memberID ) ; $ cache -> delete ( $ key ) ; } }
Flushes the member specific cache for creatable children
46,863
public function getStageURLSegment ( ) { $ stageRecord = Versioned :: get_one_by_stage ( self :: class , Versioned :: DRAFT , [ '"SiteTree"."ID"' => $ this -> ID ] ) ; return ( $ stageRecord ) ? $ stageRecord -> URLSegment : null ; }
Gets the URL segment for the latest draft version of this page .
46,864
public function getLiveURLSegment ( ) { $ liveRecord = Versioned :: get_one_by_stage ( self :: class , Versioned :: LIVE , [ '"SiteTree"."ID"' => $ this -> ID ] ) ; return ( $ liveRecord ) ? $ liveRecord -> URLSegment : null ; }
Gets the URL segment for the currently published version of this page .
46,865
public function BackLinkTracking ( ) { $ list = ArrayList :: create ( ) ; $ siteTreelinkTable = SiteTreeLink :: singleton ( ) -> baseTable ( ) ; $ parentClasses = $ this -> BackLinks ( ) -> exclude ( [ 'ParentClass' => null ] ) -> columnUnique ( 'ParentClass' ) ; foreach ( $ parentClasses as $ parentClass ) { $ joinCla...
Get the back - link tracking objects that link to this page
46,866
public function DependentPages ( $ includeVirtuals = true ) { if ( class_exists ( Subsite :: class ) ) { $ origDisableSubsiteFilter = Subsite :: $ disable_subsite_filter ; Subsite :: disable_subsite_filter ( true ) ; } $ items = ArrayList :: create ( ) ; if ( ! $ this -> isInDB ( ) ) { return $ items ; } if ( $ content...
Returns the pages that depend on this page . This includes virtual pages pages that link to it etc .
46,867
public function VirtualPages ( ) { $ pages = parent :: VirtualPages ( ) ; if ( $ pages instanceof DataList ) { return $ pages -> setDataQueryParam ( 'Subsite.filter' , false ) ; } return $ pages ; }
Return all virtual pages that link to this page .
46,868
public function onAfterRevertToLive ( ) { $ stageSelf = Versioned :: get_by_stage ( self :: class , Versioned :: DRAFT ) -> byID ( $ this -> ID ) ; $ stageSelf -> writeWithoutVersion ( ) ; foreach ( $ stageSelf -> DependentPages ( ) as $ page ) { $ page -> writeWithoutVersion ( ) ; } }
Update draft dependant pages
46,869
protected function isParentArchived ( ) { if ( $ parentID = $ this -> ParentID ) { $ parentPage = Versioned :: get_latest_version ( self :: class , $ parentID ) ; if ( ! $ parentPage || ! $ parentPage -> isOnDraft ( ) ) { return true ; } } return false ; }
Determine if this page references a parent which is archived and not available in stage
46,870
public function doRestoreToStage ( ) { $ this -> invokeWithExtensions ( 'onBeforeRestoreToStage' , $ this ) ; if ( $ this -> isParentArchived ( ) ) { $ this -> ParentID = 0 ; } $ this -> writeToStage ( Versioned :: DRAFT ) ; $ result = Versioned :: get_by_stage ( self :: class , Versioned :: DRAFT ) -> byID ( $ this ->...
Restore the content in the active copy of this SiteTree page to the stage site .
46,871
public function isNew ( ) { if ( empty ( $ this -> ID ) ) { return true ; } if ( is_numeric ( $ this -> ID ) ) { return false ; } return stripos ( $ this -> ID , 'new' ) === 0 ; }
Check if this page is new - that is if it has yet to have been written to the database .
46,872
public function defaultChild ( ) { $ default = $ this -> config ( ) -> get ( 'default_child' ) ; $ allowed = $ this -> allowedChildren ( ) ; if ( $ allowed ) { if ( ! $ default || ! in_array ( $ default , $ allowed ) ) { $ default = reset ( $ allowed ) ; } return $ default ; } return null ; }
Returns the class name of the default class for children of this page .
46,873
public function setMenuTitle ( $ value ) { if ( $ value == $ this -> getField ( "Title" ) ) { $ this -> setField ( "MenuTitle" , null ) ; } else { $ this -> setField ( "MenuTitle" , $ value ) ; } }
Set the menu title for this page .
46,874
public function CMSTreeClasses ( ) { $ classes = sprintf ( 'class-%s' , Convert :: raw2htmlid ( static :: class ) ) ; if ( $ this -> HasBrokenFile || $ this -> HasBrokenLink ) { $ classes .= " BrokenLink" ; } if ( ! $ this -> canAddChildren ( ) ) { $ classes .= " nochildren" ; } if ( ! $ this -> canEdit ( ) && ! $ this...
Return the CSS classes to apply to this node in the CMS tree .
46,875
public function getPageIconURL ( ) { $ icon = $ this -> config ( ) -> get ( 'icon' ) ; if ( ! $ icon ) { return null ; } if ( strpos ( $ icon , 'data:image/' ) !== false ) { return $ icon ; } $ iconResource = ModuleResourceLoader :: singleton ( ) -> resolveResource ( $ icon ) ; if ( $ iconResource instanceof ModuleReso...
Generate link to this page s icon
46,876
public function classDescription ( ) { $ base = in_array ( static :: class , [ Page :: class , self :: class ] ) ; if ( $ base ) { return $ this -> config ( ) -> get ( 'base_description' ) ; } return $ this -> config ( ) -> get ( 'description' ) ; }
Get description for this page type
46,877
public function provideI18nEntities ( ) { $ entities = parent :: provideI18nEntities ( ) ; $ description = $ this -> classDescription ( ) ; if ( $ description ) { $ entities [ static :: class . '.DESCRIPTION' ] = $ description ; } return $ entities ; }
Overloaded to also provide entities for Page class which is usually located in custom code hence textcollector picks it up for the wrong folder .
46,878
protected function updateDependentPages ( ) { if ( Versioned :: get_stage ( ) === Versioned :: LIVE ) { return ; } $ this -> flushCache ( ) ; foreach ( $ this -> DependentPages ( ) as $ page ) { $ page -> syncLinkTracking ( ) ; if ( $ page -> isChanged ( ) ) { $ page -> write ( ) ; } } }
Update dependant pages
46,879
protected function getExcludedURLSegments ( ) { $ excludes = [ ] ; foreach ( Director :: config ( ) -> get ( 'rules' ) as $ pattern => $ rule ) { $ route = explode ( '/' , $ pattern ) ; if ( ! empty ( $ route ) && strpos ( $ route [ 0 ] , '$' ) === false ) { $ excludes [ ] = strtolower ( $ route [ 0 ] ) ; } } foreach (...
Get the list of excluded root URL segments
46,880
public function getFilteredPages ( ) { $ pages = Versioned :: get_including_deleted ( SiteTree :: class ) ; $ pages = $ this -> applyDefaultFilters ( $ pages ) ; $ pages = $ pages -> filterByCallback ( function ( SiteTree $ page ) { return $ page -> isArchived ( ) ; } ) ; return $ pages ; }
Filters out all pages who s status is set to Deleted .
46,881
public function getOrphanedPages ( $ class = SiteTree :: class , $ filter = array ( ) , $ sort = null , $ join = null , $ limit = null ) { $ table = DataObject :: getSchema ( ) -> tableName ( $ class ) ; if ( empty ( $ filter ) ) { $ where = array ( ) ; } elseif ( is_array ( $ filter ) ) { $ where = $ filter ; } else {...
Gets all orphans from Stage and Live stages .
46,882
public function getVirtualFields ( ) { $ record = $ this -> CopyContentFrom ( ) ; if ( ! $ record || ! $ record -> exists ( ) ) { return array ( ) ; } $ fields = array_keys ( static :: getSchema ( ) -> fieldSpecs ( $ record ) ) ; $ nonVirtualFields = $ this -> getNonVirtualisedFields ( ) ; return array_diff ( $ fields ...
Generates the array of fields required for the page type .
46,883
public function isPublishable ( ) { if ( ! $ this -> CopyContentFrom ( ) || ! $ this -> CopyContentFrom ( ) -> ID ) { return false ; } if ( ! Versioned :: get_versionnumber_by_stage ( SiteTree :: class , 'Live' , $ this -> CopyContentFromID ) ) { return false ; } return true ; }
Returns true if is page is publishable by anyone at all Return false if the source page isn t published yet .
46,884
public function getCMSFields ( ) { $ this -> beforeUpdateCMSFields ( function ( FieldList $ fields ) { $ copyContentFromField = TreeDropdownField :: create ( 'CopyContentFromID' , _t ( self :: class . '.CHOOSE' , "Linked Page" ) , SiteTree :: class ) ; if ( $ virtualFields = $ this -> getVirtualFields ( ) ) { $ roTrans...
Generate the CMS fields from the fields from the original page .
46,885
public function getViewerTemplates ( $ suffix = '' ) { $ copy = $ this -> CopyContentFrom ( ) ; if ( $ copy && $ copy -> exists ( ) ) { return $ copy -> getViewerTemplates ( $ suffix ) ; } return parent :: getViewerTemplates ( $ suffix ) ; }
Use the target page s class name for fetching templates - as we need to take on its appearance
46,886
public function isFieldVirtualised ( $ field ) { $ ignore = $ this -> getNonVirtualisedFields ( ) ; if ( in_array ( $ field , $ ignore ) ) { return false ; } $ copied = $ this -> CopyContentFrom ( ) ; if ( ! $ copied || ! $ copied -> exists ( ) ) { return false ; } return $ copied -> hasField ( $ field ) ; }
Check if given field is virtualised
46,887
public function SiteTreeAsUL ( ) { $ treeClass = $ this -> config ( ) -> get ( 'tree_class' ) ; $ filter = $ this -> getSearchFilter ( ) ; DataObject :: singleton ( $ treeClass ) -> prepopulateTreeDataCache ( null , [ 'childrenMethod' => $ filter ? $ filter -> getChildrenMethod ( ) : 'AllChildrenIncludingDeleted' , 'nu...
Return the entire site tree as a nested set of ULs
46,888
protected function getTreeNodeCustomisations ( ) { $ rootTitle = $ this -> getCMSTreeTitle ( ) ; return function ( SiteTree $ node ) use ( $ rootTitle ) { return [ 'listViewLink' => $ this -> LinkListViewChildren ( $ node -> ID ) , 'rootTitle' => $ rootTitle , 'extraClass' => $ this -> getTreeNodeClasses ( $ node ) , '...
Get callback to determine template customisations for nodes
46,889
public function getTreeNodeClasses ( SiteTree $ node ) { $ classes = $ node -> CMSTreeClasses ( ) ; $ flags = $ node -> getStatusFlags ( ) ; if ( $ flags ) { $ statuses = array_keys ( $ flags ) ; foreach ( $ statuses as $ s ) { $ classes .= ' status-' . $ s ; } } $ filter = $ this -> getSearchFilter ( ) ; if ( $ filter...
Get extra CSS classes for a page s tree node
46,890
public function getSearchFieldSchema ( ) { $ schemaUrl = $ this -> Link ( 'schema/SearchForm' ) ; $ context = $ this -> getSearchContext ( ) ; $ params = $ this -> getRequest ( ) -> requestVar ( 'q' ) ? : [ ] ; $ context -> setSearchParams ( $ params ) ; $ placeholder = _t ( 'SilverStripe\\CMS\\Search\\SearchForm.FILTE...
Returns the search form schema for the current model
46,891
public function getSearchForm ( ) { $ dateFrom = DateField :: create ( 'Search__LastEditedFrom' , _t ( 'SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM' , 'From' ) ) -> setLocale ( Security :: getCurrentUser ( ) -> Locale ) ; $ dateTo = DateField :: create ( 'Search__LastEditedTo' , _t ( 'SilverStripe\\CMS\\Search...
Returns a Form for page searching for use in templates .
46,892
protected function getPageTypes ( ) { $ pageTypes = array ( ) ; foreach ( SiteTree :: page_type_classes ( ) as $ pageTypeClass ) { $ pageTypes [ $ pageTypeClass ] = SiteTree :: singleton ( $ pageTypeClass ) -> i18n_singular_name ( ) ; } asort ( $ pageTypes ) ; return $ pageTypes ; }
Returns a sorted array suitable for a dropdown with pagetypes and their translated name
46,893
public function getBreadcrumbsBackLink ( ) { $ breadcrumbs = $ this -> Breadcrumbs ( ) ; if ( $ breadcrumbs -> count ( ) < 2 ) { return $ this -> LinkPages ( ) ; } return $ breadcrumbs -> offsetGet ( $ breadcrumbs -> count ( ) - 2 ) -> Link ; }
Get back url for breadcrumbs
46,894
public function SiteTreeHints ( ) { $ classes = SiteTree :: page_type_classes ( ) ; $ memberID = Security :: getCurrentUser ( ) ? Security :: getCurrentUser ( ) -> ID : 0 ; $ cache = $ this -> getHintsCache ( ) ; $ cacheKey = $ this -> generateHintsCacheKey ( $ memberID ) ; $ json = $ cache -> get ( $ cacheKey ) ; if (...
Create serialized JSON string with site tree hints data to be injected into data - hints attribute of root node of jsTree .
46,895
public function PageTypes ( ) { $ classes = SiteTree :: page_type_classes ( ) ; $ result = new ArrayList ( ) ; foreach ( $ classes as $ class ) { $ instance = SiteTree :: singleton ( $ class ) ; if ( $ instance instanceof HiddenClass ) { continue ; } $ needPermissions = $ instance -> config ( ) -> get ( 'need_permissio...
Populates an array of classes in the CMS which allows the user to change the page type .
46,896
public function getRecord ( $ id , $ versionID = null ) { if ( ! $ id ) { return null ; } $ treeClass = $ this -> config ( ) -> get ( 'tree_class' ) ; if ( $ id instanceof $ treeClass ) { return $ id ; } if ( substr ( $ id , 0 , 3 ) == 'new' ) { return $ this -> getNewItem ( $ id ) ; } if ( ! is_numeric ( $ id ) ) { re...
Get a database record to be managed by the CMS .
46,897
protected function getArchiveWarningMessage ( $ record ) { $ defaultMessage = _t ( 'SilverStripe\\CMS\\Controllers\\CMSMain.ArchiveWarningWithChildren' , 'Warning: This page and all of its child pages will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?' ) ; if ( ! $ this -> config...
Build an archive warning message based on the page s children
46,898
protected function collateDescendants ( $ recordIDs , & $ collator ) { $ children = SiteTree :: get ( ) -> filter ( [ 'ParentID' => $ recordIDs ] ) -> column ( ) ; if ( $ children ) { foreach ( $ children as $ item ) { $ collator [ ] = $ item ; } $ this -> collateDescendants ( $ children , $ collator ) ; return true ; ...
Find IDs of all descendant pages for the provided ID lists .
46,899
public function childfilter ( $ request ) { $ parentID = $ request -> requestVar ( 'ParentID' ) ; $ parent = SiteTree :: get ( ) -> byID ( $ parentID ) ; if ( ! $ parent || ! $ parent -> exists ( ) ) { return $ this -> httpError ( 404 ) ; } $ classes = SiteTree :: page_type_classes ( ) ; $ disallowedChildren = array ( ...
Callback to request the list of page types allowed under a given page instance . Provides a slower but more precise response over SiteTreeHints