idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
7,900
public function getContent ( ) { $ this -> tagName = 'rect' ; $ this -> addAttribute ( 'x' , $ this -> x ) ; $ this -> addAttribute ( 'y' , $ this -> y ) ; $ this -> addAttribute ( 'width' , $ this -> width ) ; $ this -> addAttribute ( 'height' , $ this -> height ) ; $ this -> addAttribute ( 'fill' , $ this -> color ) ...
stroke = black stroke - width = 3
7,901
public function ReviewItemsViewable ( ) { $ reviewItems = $ this -> ReviewItems ( ) ; if ( ! $ reviewItems ) { return ; } $ result = array ( ) ; foreach ( $ reviewItems as $ page ) { if ( $ page && $ page -> _canView && ! $ page -> _canEdit ) { $ result [ ] = $ page ; } } return new ArrayList ( $ result ) ; }
Items the user may have previously reviewed but are no longer editable by them .
7,902
public function ReviewItemsEditable ( ) { $ reviewItems = $ this -> ReviewItems ( ) ; if ( ! $ reviewItems ) { return ; } $ result = array ( ) ; foreach ( $ reviewItems as $ page ) { if ( $ page && $ page -> _canEdit ) { $ result [ ] = $ page ; } } $ result = new ArrayList ( $ result ) ; $ result = $ result -> sort ( a...
Items the user the user can review and approve
7,903
public function canReview ( $ member , $ record ) { $ extended = $ this -> extendedCan ( __FUNCTION__ , $ member ) ; if ( $ extended !== null ) return $ extended ; if ( ! class_exists ( 'FrontEndWorkflowController' ) ) { return false ; } if ( ! $ this -> WorkflowDefinitionID ) { return false ; } if ( $ record && ! $ re...
Check whether the member can review submissions or not
7,904
public function createLocationFilter ( $ node ) { $ allow = $ this -> extend ( 'filterCreateLocations' , $ node ) ; if ( count ( $ allow ) == 0 ) { return true ; } return min ( $ allow ) > 0 ; }
Callback to handle filtering of the selection tree that users can create in .
7,905
public function NewObject ( ) { $ id = ( int ) $ this -> request -> requestVar ( 'new' ) ; if ( $ id ) { $ item = DataObject :: get_by_id ( $ this -> CreateType , $ id ) ; if ( ! $ item ) { $ item = Versioned :: get_by_stage ( $ this -> CreateType , 'Stage' ) -> byID ( $ id ) ; } return $ item ; } return null ; }
Return the new object if set in the URL
7,906
public function doReview ( $ data ) { $ id = isset ( $ data [ 'ID' ] ) ? ( int ) $ data [ 'ID' ] : null ; if ( ! $ id ) { user_error ( 'Invalid ID passed for review action' ) ; $ this -> redirectBack ( ) ; } return $ this -> owner -> redirect ( Controller :: join_links ( $ this -> owner -> Link ( 'review' ) , $ id ) ) ...
Redirect to the page to review
7,907
public function objectExists ( ) { if ( $ this -> data ( ) -> useObjectExistsHandling ( ) ) { return singleton ( $ this -> CreateType ) -> objectExists ( $ this -> request -> postVars ( ) , $ this -> pid ) ; } }
checks to see if the object being created already exists and if so returns it
7,908
function createMacroInstance ( $ tagName ) { $ propsClass = $ tagName . 'Properties' ; $ path = $ this -> findMacroFile ( $ tagName ) ; $ com = new MacroCall ; $ com -> propsClass = $ propsClass ; $ com -> templateUrl = $ path ; return $ com ; }
Loads and compiles the macro or retrieves it from the cache .
7,909
public function render ( ) { if ( array_key_exists ( $ this -> formType , $ this -> formsType ) ) { $ this -> form = new $ this -> formsType [ $ this -> formType ] ( $ this -> idName , $ this -> elements , $ this -> method , $ this -> action ) ; } return $ this -> form -> render ( ) ; }
Renderiza el formulario
7,910
public function GetLoginApiForAdmin ( string $ loginId = NULL , string $ langId = NULL ) { if ( GnUtil :: IsNullOrEmpty ( $ langId ) ) { $ langId = GnSettings :: $ CurrentLangId ; } $ loginApi = new Modules \ GnLoginApiAdmin ( $ this , NULL , $ loginId , $ langId ) ; return $ loginApi ; }
Get the GnLoginApi used for mashup - admin calls .
7,911
public function GetLoginApiForEndUser ( string $ appKey = NULL , string $ loginId = NULL , string $ langId = NULL ) { if ( GnUtil :: IsNullOrEmpty ( $ langId ) ) { $ langId = GnSettings :: $ CurrentLangId ; } $ loginApi = new Modules \ GnLoginApiEndUser ( $ this , $ appKey , $ loginId , $ langId ) ; return $ loginApi ;...
The GnLoginApi used for end - user API calls .
7,912
protected function generateSeo ( CmsModel \ SeoSubjectInterface $ subject ) { $ seo = $ this -> seoRepository -> createNew ( ) ; if ( 0 < strlen ( $ name = $ this -> objectToString ( $ subject ) ) ) { $ seo -> setTitle ( $ name . ' seo title' ) -> setDescription ( $ name . ' seo description' ) ; } else { $ seo -> setTi...
Generates seo to the given subject .
7,913
protected function objectToString ( $ object ) { $ r = new \ ReflectionClass ( get_class ( $ object ) ) ; if ( $ r -> hasMethod ( '__toString' ) ) { return ( string ) $ object ; } foreach ( [ 'getName' , 'getTitle' ] as $ getter ) { if ( $ r -> hasMethod ( $ getter ) ) { try { return $ object -> { $ getter } ( ) ; } ca...
Returns the string representation of the given object .
7,914
private function getDefaultGenerator ( ) { foreach ( self :: $ defaultGenerators as $ generator ) { $ generator = new $ generator ( ) ; if ( $ generator -> isSupported ( ) ) { return $ generator ; } } throw new GeneratorException ( 'Default secure random byte generators are not supported by the system' ) ; }
Returns the first supported default secure random byte generator .
7,915
public function getBytes ( $ count ) { $ count = ( int ) $ count ; if ( $ count < 0 ) { throw new \ InvalidArgumentException ( 'Number of bytes must be 0 or more' ) ; } return $ this -> generator -> getBytes ( $ count ) ; }
Returns a number of random bytes .
7,916
public function getArray ( array $ array , $ count ) { $ count = ( int ) $ count ; $ size = count ( $ array ) ; if ( $ this -> isOutOfBounds ( $ count , 0 , $ size ) ) { throw new \ InvalidArgumentException ( 'Invalid number of elements' ) ; } $ result = [ ] ; $ keys = array_keys ( $ array ) ; for ( $ i = 0 ; $ i < $ c...
Returns a number of randomly selected elements from the array .
7,917
public function choose ( array $ array ) { if ( count ( $ array ) < 1 ) { throw new \ InvalidArgumentException ( 'Array must have at least one value' ) ; } $ result = array_slice ( $ array , $ this -> generator -> getNumber ( 0 , count ( $ array ) - 1 ) , 1 ) ; return current ( $ result ) ; }
Returns one randomly selected value from the array .
7,918
public function getSequence ( $ choices , $ length ) { $ length = ( int ) $ length ; if ( $ length < 0 ) { throw new \ InvalidArgumentException ( 'Invalid sequence length' ) ; } if ( is_array ( $ choices ) ) { return $ this -> getSequenceValues ( array_values ( $ choices ) , $ length ) ; } return implode ( $ this -> ge...
Returns a random sequence of values .
7,919
private function getSequenceValues ( array $ values , $ length ) { if ( $ length < 1 ) { return [ ] ; } if ( count ( $ values ) < 1 ) { throw new \ InvalidArgumentException ( 'Cannot generate sequence from empty value set' ) ; } $ size = count ( $ values ) ; $ result = [ ] ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { ...
Returns the selected list of values for the sequence .
7,920
public function getUuid ( ) { $ integers = array_values ( unpack ( 'n8' , $ this -> generator -> getBytes ( 16 ) ) ) ; $ integers [ 3 ] &= 0x0FFF ; $ integers [ 4 ] = $ integers [ 4 ] & 0x3FFF | 0x8000 ; return vsprintf ( '%04x%04x-%04x-4%03x-%04x-%04x%04x%04x' , $ integers ) ; }
Returns a random UUID version 4 identifier .
7,921
public static function newInstance ( ExecutableFinder $ finder , ResourceManager $ manager , $ inflatorBinaryName = null , $ deflatorBinaryName = null ) { $ inflator = $ inflatorBinaryName instanceof ProcessBuilderFactoryInterface ? $ inflatorBinaryName : self :: findABinary ( $ inflatorBinaryName , static :: getDefaul...
Returns a new instance of the invoked adapter
7,922
public function processHookFunction ( $ params , & $ smarty ) { $ hookName = $ this -> getParam ( $ params , 'name' ) ; $ module = intval ( $ this -> getParam ( $ params , 'module' , 0 ) ) ; $ moduleCode = $ this -> getParam ( $ params , 'modulecode' , "" ) ; $ type = $ smarty -> getTemplateDefinition ( ) -> getType ( ...
Generates the content of the hook
7,923
protected function moduleIncludeCompat ( $ params , & $ smarty ) { $ plugin = $ this -> getSmartyPluginModule ( ) ; $ params = array ( "location" => $ this -> getParam ( $ params , 'location' , null ) , "module" => $ this -> getParam ( $ params , 'modulecode' , null ) , "countvar" => $ this -> getParam ( $ params , 'co...
Call the plugin function module_include for backward compatibility .
7,924
protected function getSmartyPluginModule ( ) { if ( null === $ this -> smartyPluginModule ) { $ this -> smartyPluginModule = $ this -> dispatcher -> getContainer ( ) -> get ( "smarty.plugin.module" ) ; } return $ this -> smartyPluginModule ; }
get the smarty plugin Module
7,925
public function processHookBlock ( $ params , $ content , $ smarty , & $ repeat ) { $ hookName = $ this -> getParam ( $ params , 'name' ) ; $ module = intval ( $ this -> getParam ( $ params , 'module' , 0 ) ) ; $ fields = preg_replace ( '|[^a-zA-Z0-9,\-_]|' , '' , $ this -> getParam ( $ params , 'fields' , '' ) ) ; $ f...
Process the content of the hook block .
7,926
protected function checkEmptyHook ( $ params ) { $ hookName = $ this -> getParam ( $ params , 'rel' ) ; if ( null == $ hookName ) { throw new \ InvalidArgumentException ( $ this -> translator -> trans ( "Missing 'rel' parameter in ifhook/elsehook arguments" ) ) ; } if ( ! isset ( $ this -> hookResults [ $ hookName ] ) ...
Check if a hook has returned results . The hook should have been executed before or an InvalidArgumentException is thrown
7,927
protected function getArgumentsFromParams ( $ params ) { $ args = array ( ) ; $ excludes = array ( "name" , "before" , "separator" , "after" , "fields" ) ; if ( is_array ( $ params ) ) { foreach ( $ params as $ key => $ value ) { if ( ! in_array ( $ key , $ excludes ) ) { $ args [ $ key ] = $ value ; } } } return $ arg...
Clean the params of the params passed to the hook function or block to feed the arguments of the event with relevant arguments .
7,928
private function searchPageByRequestKey ( $ key ) { $ pageId = $ this -> getRequestParameter ( $ key ) ; if ( empty ( $ pageId ) ) { return null ; } return $ this -> getEntityManager ( ) -> find ( AbstractPage :: CN ( ) , $ pageId ) ; }
Try selecting abstract page by request parameter .
7,929
private function searchLocalizationByRequestKey ( $ key ) { $ localizationId = $ this -> getRequestInput ( ) -> get ( $ key ) ; if ( strpos ( $ localizationId , '_' ) !== false ) { $ localizationId = strstr ( $ localizationId , '_' , true ) ; } if ( empty ( $ localizationId ) ) { return null ; } return $ this -> getEnt...
Try selecting page localization by request parameter .
7,930
protected function getInitialPageLocalization ( ) { $ localization = null ; $ cookieBag = $ this -> container -> getRequest ( ) -> cookies ; if ( $ cookieBag -> has ( self :: INITIAL_PAGE_ID_COOKIE ) ) { $ localization = $ this -> getEntityManager ( ) -> find ( Localization :: CN ( ) , $ cookieBag -> get ( self :: INIT...
Get first page localization ID to show in the CMS .
7,931
protected function loadNodeMainData ( Localization $ localization ) { $ localeId = $ this -> getCurrentLocale ( ) -> getId ( ) ; $ isCurrentLocaleLocalization = ( $ localization -> getLocaleId ( ) === $ localeId ) ; $ page = $ localization -> getMaster ( ) ; $ nodeData = array ( 'id' => $ isCurrentLocaleLocalization ? ...
Loads main node data array
7,932
protected function checkLock ( $ createOnMiss = true ) { $ this -> isPostRequest ( ) ; $ user = $ this -> getCurrentUser ( ) ; if ( ! $ user ) { return ; } $ localization = $ this -> getPageLocalization ( ) ; if ( $ localization -> isLocked ( ) ) { $ lock = $ localization -> getLock ( ) ; if ( $ lock -> getUserName ( )...
Checks whether the page is locked by current user or not will throw an exception if no and update lock modified time if yes .
7,933
protected function unlockPage ( ) { $ this -> isPostRequest ( ) ; $ localization = $ this -> getPageLocalization ( ) ; if ( $ localization -> isLocked ( ) ) { $ lock = $ localization -> getLock ( ) ; $ entityManager = $ this -> getEntityManager ( ) ; $ localization -> setLock ( null ) ; $ entityManager -> remove ( $ lo...
Removes page lock if exists
7,934
protected function lockPage ( ) { $ this -> isPostRequest ( ) ; $ currentUser = $ this -> getCurrentUser ( ) ; if ( ! $ currentUser ) { return null ; } $ localization = $ this -> getPageLocalization ( ) ; $ force = $ this -> getRequestInput ( ) -> filter ( 'force' , false , false , FILTER_VALIDATE_BOOLEAN ) ; try { if ...
Sets page lock if no lock is found or if force is used ; will output current lock data if page locked by another user and force action is not allowed or not provided
7,935
protected function createLock ( ) { $ user = $ this -> getCurrentUser ( ) ; if ( ! $ user ) { throw new \ LogicException ( 'There is no user to attach the lock.' ) ; } $ localization = $ this -> getPageLocalization ( ) ; $ currentRevision = $ this -> getAuditReader ( ) -> getCurrentRevision ( $ localization :: CN ( ) ,...
Creates localization edit lock object .
7,936
protected function lockNestedSet ( $ entityNode ) { $ class = is_string ( $ entityNode ) ? $ entityNode : $ entityNode -> getNestedSetRepositoryClassName ( ) ; $ this -> getEntityManager ( ) -> getRepository ( $ class ) -> getNestedSetRepository ( ) -> lock ( ) ; }
Locks the nested set for entity .
7,937
protected function unlockNestedSet ( $ entityNode ) { $ class = is_string ( $ entityNode ) ? $ entityNode : $ entityNode -> getNestedSetRepositoryClassName ( ) ; $ this -> getEntityManager ( ) -> getRepository ( $ class ) -> getNestedSetRepository ( ) -> unlock ( ) ; }
Unlocks the nested set .
7,938
protected function getPageApplicationData ( PageApplicationInterface $ application ) { return array ( 'id' => $ application -> getId ( ) , 'title' => $ application -> getTitle ( ) , 'icon' => $ application -> getIcon ( ) , 'isDropTarget' => $ application -> getAllowChildren ( ) , 'childInsertPolicy' => $ application ->...
Gets page application configuration array for UI
7,939
public static function getByAddress ( $ address , $ hostname = null ) { $ addrLen = strlen ( $ address ) ; if ( $ addrLen === 4 ) { return new Inet4Address ( $ address , $ hostname ) ; } elseif ( $ addrLen == 16 ) { return new Inet6Address ( $ address , $ hostname ) ; } throw new UnknownHostException ( $ address ) ; }
Returns an InetAddress object given the raw IP address .
7,940
public function getHostname ( ) { if ( $ this -> hostname === null ) { $ hostname = @ gethostbyaddr ( $ this -> hostAddress ) ; if ( $ hostname === false ) { $ hostname = $ this -> hostAddress ; } $ this -> hostname = $ hostname ; } return $ this -> hostname ; }
Gets the host name for this IP address .
7,941
private function load ( $ type ) { $ index = $ this -> $ type ; if ( $ index ) { return ; } $ cache = $ this -> di -> get ( "cache" ) ; $ key = $ cache -> createKey ( __CLASS__ , $ type ) ; $ index = $ cache -> get ( $ key ) ; if ( is_null ( $ index ) || $ this -> ignoreCache ) { $ createMethod = "create$type" ; $ inde...
Create the index of all content into an array .
7,942
private function isInternalRoute ( $ filepath ) { foreach ( $ this -> internalRouteDirPattern as $ pattern ) { if ( preg_match ( $ pattern , $ filepath ) ) { return true ; } } $ filename = basename ( $ filepath ) ; foreach ( $ this -> internalRouteFilePattern as $ pattern ) { if ( preg_match ( $ pattern , $ filename ) ...
Check if a filename is to be marked as an internal route ..
7,943
private function createMeta ( ) { $ basepath = $ this -> config [ "basepath" ] ; $ filter = $ this -> config [ "textfilter-frontmatter" ] ; $ pattern = $ this -> config [ "meta" ] ; $ path = "$basepath/$pattern" ; $ textfilter = $ this -> di -> get ( "textFilter" ) ; $ index = [ ] ; foreach ( glob_recursive ( $ path ) ...
Generate an index for meta files .
7,944
private function getMetaForRoute ( $ route ) { $ base = dirname ( $ route ) ; return isset ( $ this -> meta [ $ base ] ) ? $ this -> meta [ $ base ] : [ ] ; }
Get a reference to meta data for specific route .
7,945
private function createBaseRouteToc ( $ route ) { $ toc = [ ] ; $ len = strlen ( $ route ) ; foreach ( $ this -> index as $ key => $ value ) { if ( substr ( $ key , 0 , $ len + 1 ) === "$route/" ) { if ( $ value [ "internal" ] === false && $ value [ "tocable" ] === true ) { $ toc [ $ key ] = $ value ; $ frontm = $ this...
Create a table of content for routes at particular level .
7,946
private function createAuthor ( ) { $ pattern = $ this -> config [ "author" ] ; $ index = [ ] ; $ matches = [ ] ; foreach ( $ this -> meta as $ key => $ entry ) { if ( preg_match ( $ pattern , $ key , $ matches ) ) { $ acronym = $ matches [ 1 ] ; $ index [ $ acronym ] = $ key ; $ this -> meta [ $ key ] [ "acronym" ] = ...
Generate a lookup index for authors that maps into the meta entry for the author .
7,947
private function loadAuthorDetails ( $ author ) { if ( is_array ( $ author ) && is_array ( array_values ( $ author ) [ 0 ] ) ) { return $ author ; } if ( ! is_array ( $ author ) ) { $ tmp = $ author ; $ author = [ ] ; $ author [ ] = $ tmp ; } $ authors = [ ] ; foreach ( $ author as $ acronym ) { if ( isset ( $ this -> ...
Load details for the author .
7,948
private function createCategory ( ) { $ pattern = $ this -> config [ "category" ] ; $ index = [ ] ; $ matches = [ ] ; foreach ( $ this -> meta as $ key => $ entry ) { if ( preg_match ( $ pattern , $ key , $ matches ) ) { $ catKey = $ matches [ 1 ] ; $ index [ $ catKey ] = $ key ; $ this -> meta [ $ key ] [ "key" ] = $ ...
Generate a lookup index for categories that maps into the meta entry for the category .
7,949
private function checkForMetaRoute ( $ route ) { $ this -> baseRoute = $ route ; $ this -> metaRoute = null ; if ( $ this -> mapRoute2IndexKey ( $ route ) ) { return $ route ; } $ pagination = $ this -> config [ "pagination" ] ; $ matches = [ ] ; $ pattern = "/(.*?)\/($pagination)\/(\d+)$/" ; if ( preg_match ( $ patter...
Check if currrent route is a supported meta route .
7,950
private function mapRoute2IndexKey ( $ route ) { $ route = rtrim ( $ route , "/" ) ; if ( key_exists ( $ route , $ this -> index ) ) { return $ route ; } elseif ( empty ( $ route ) && key_exists ( "index" , $ this -> index ) ) { return "index" ; } elseif ( key_exists ( $ route . "/index" , $ this -> index ) ) { return ...
Map the route to the correct key in the index .
7,951
private function mapRoute2Index ( $ route ) { $ routeIndex = $ this -> mapRoute2IndexKey ( $ route ) ; if ( $ routeIndex ) { return [ $ routeIndex , $ this -> index [ $ routeIndex ] ] ; } $ msg = t ( "The route '!ROUTE' does not exists in the index." , [ "!ROUTE" => $ route ] ) ; throw new \ Anax \ Exception \ NotFound...
Map the route to the correct entry in the index .
7,952
private function getView ( $ route , $ frontmatter , $ key ) { $ view = [ ] ; $ meta = $ this -> getMetaForRoute ( $ route ) ; if ( isset ( $ meta [ $ key ] ) ) { $ view = $ meta [ $ key ] ; } if ( isset ( $ frontmatter [ $ key ] ) ) { $ view = array_merge_recursive_distinct ( $ view , $ frontmatter [ $ key ] ) ; } ret...
Get view by mergin information from meta and frontmatter .
7,953
private function getViews ( $ route , $ frontmatter ) { $ views = $ this -> getView ( $ route , $ frontmatter , "views" , true ) ; if ( ! isset ( $ views [ "main" ] [ "template" ] ) ) { $ views [ "main" ] [ "template" ] = $ this -> config [ "template" ] ; } if ( ! isset ( $ views [ "main" ] [ "data" ] ) ) { $ views [ "...
Get details on extra views .
7,954
public function contentForRoute ( $ route = null ) { $ content = $ this -> contentForInternalRoute ( $ route ) ; if ( $ content -> internal === true ) { $ msg = t ( "The content '!ROUTE' does not exists as a public route." , [ "!ROUTE" => $ route ] ) ; throw new \ Anax \ Exception \ NotFoundException ( $ msg ) ; } retu...
Map url to content if such mapping can be done exclude internal routes .
7,955
public function unsetData ( $ key = null ) { if ( is_string ( $ key ) && 0 < strlen ( $ key ) ) { unset ( $ this -> data [ $ key ] ) ; } else { $ this -> data = [ ] ; } return $ this ; }
Unsets the data for the given key .
7,956
public function makeSchema ( ) : array { return [ Filter :: SH_MAP => $ this -> buildMap ( $ this -> entity ) , Filter :: SH_VALIDATES => $ this -> entity -> getProperty ( 'validates' , true ) ?? [ ] , Filter :: SH_SECURED => $ this -> entity -> getSecured ( ) , Filter :: SH_FILLABLE => $ this -> entity -> getFillable ...
Generate entity schema based on schema definitions .
7,957
public function setModificationTime ( \ DateTime $ time = null ) { if ( is_null ( $ time ) ) { $ time = new \ DateTime ( 'now' ) ; } $ this -> modificationTime = $ time ; }
Sets modification time
7,958
public function free ( ) { if ( ! is_null ( $ this -> nestedSetNode ) ) { $ this -> nestedSetNode -> free ( $ this ) ; $ this -> nestedSetNode = null ; } }
Free the node unsetting the pointers to other objects . MUST clear entity manager after doing this!
7,959
public function getRealFileName ( ) { $ path = $ this -> path -> getSystemPath ( ) ; $ pathParts = explode ( '/' , $ path ) ; return array_pop ( $ pathParts ) ; }
Returns the file filename in filesystem
7,960
public function getLocalization ( ) { $ data = parent :: getLocalization ( ) ; if ( empty ( $ data ) ) { $ data = $ this -> detectRequestPageLocalization ( ) ; $ this -> setLocalization ( $ data ) ; } return $ data ; }
Overriden with page detection from URL
7,961
public function validateFile ( File $ file , $ sourceFilePath = null ) { $ result = $ this -> checkList ( $ file -> getExtension ( ) ) ; if ( ! $ result ) { $ message = 'File extension "' . $ file -> getExtension ( ) . '" is not allowed' ; throw new Exception \ UploadFilterException ( self :: EXCEPTION_MESSAGE_KEY , $ ...
Validates file extension
7,962
public function init ( ) { $ state = Module :: CopyMovieGrifus ( ) -> getOption ( 'state' ) ; if ( 'active' === $ state || 'outdated' === $ state ) { add_action ( 'init' , [ $ this , 'set_language' ] ) ; if ( ! is_admin ( ) ) { $ this -> front ( ) ; } } }
Class initializer method .
7,963
public function front ( ) { add_action ( 'wp' , function ( ) { App :: id ( 'EFG' ) ; if ( App :: main ( ) -> is_single ( ) ) { $ this -> set_language ( ) ; $ this -> add_scripts ( ) ; $ this -> add_styles ( ) ; } } ) ; }
Front initializer method .
7,964
protected function add_scripts ( ) { $ js = Module :: CopyMovieGrifus ( ) -> getOption ( 'assets' , 'js' ) ; $ setting = $ js [ 'copyMovieGrifus' ] ; $ params = Module :: CopyMovieGrifus ( ) -> getControllerInstance ( 'Copy' ) -> getMovieInfo ( ) ; $ setting [ 'params' ] = array_merge ( $ setting [ 'params' ] , $ param...
Add scripts .
7,965
public function getCurrentMax ( ) { $ max = 0 ; foreach ( $ this -> array as $ node ) { $ max = max ( $ max , $ node -> getRightValue ( ) ) ; } return $ max ; }
Get the maximal value of interval index among the nodes
7,966
public function register ( Node \ NodeInterface $ node ) { if ( ! in_array ( $ node , $ this -> array , true ) ) { $ this -> array [ ] = $ node ; } }
Register the loaded node
7,967
public function isDatesValid ( ) { if ( $ this -> startDate >= $ this -> endDate ) { return false ; } return ( $ this -> endDate -> diff ( $ this -> startDate ) -> days > 0 ) ; }
Validates that start date is less than end date
7,968
final protected function getTransformedComparisonValue ( $ rawComparisonValue , Model $ model ) { $ columnSchema = $ model -> getRepositoryColumnSchemaForColumnReference ( $ this -> columnName ) ; if ( $ columnSchema != null ) { $ closure = $ columnSchema -> getTransformIntoModelData ( ) ; if ( $ closure !== null ) { $...
Converts the comparison value used in the constructor to one which can be compared against that returned by the relevant model .
7,969
public function run ( array $ args ) { foreach ( $ this -> calls as $ call ) { if ( $ call instanceof \ SuperClosure \ SerializableClosure ) $ call = $ call -> getClosure ( ) ; $ res = call_user_func_array ( $ call , array_merge ( [ $ this ] , $ args ) ) ; $ this -> executed ++ ; if ( $ res !== null ) return $ res ; if...
Execute the chain .
7,970
private function getActiveRoute ( $ route , $ routeIndex ) { if ( substr_compare ( $ route , "./" , 0 , 2 ) === 0 ) { $ route = dirname ( $ routeIndex ) . "/" . substr ( $ route , 2 ) ; } return $ route ; }
Support relative routes .
7,971
private function loadAndParseRoute ( $ route ) { $ meta = $ this -> getMetaForRoute ( $ route ) ; unset ( $ meta [ "__toc__" ] ) ; unset ( $ meta [ "views" ] ) ; list ( $ routeIndex , , $ filtered ) = $ this -> mapRoute2Content ( $ route ) ; $ filtered -> frontmatter = array_merge_recursive_distinct ( $ meta , $ filter...
Load view details for additional route merged with meta if any .
7,972
protected function getResponse ( $ offset = 0 , $ itemCountPerPage = 0 ) { $ id = md5 ( $ offset . $ itemCountPerPage ) ; if ( ! isset ( $ this -> responses [ $ id ] ) ) { $ query = new \ SolrDisMaxQuery ( ) ; $ this -> filter -> filter ( $ this -> params , $ query , $ this -> facets ) ; $ query -> setStart ( $ offset ...
Process query into server
7,973
public function connectToNSQLookupd ( $ addr ) { if ( $ this -> isStopped ) { throw new NsqException ( "consumer stopped" ) ; } $ addr = $ this -> formatAddress ( $ addr ) ; if ( isset ( $ this -> lookupdHTTPAddrs [ $ addr ] ) ) { return ; } $ this -> lookupdHTTPAddrs [ $ addr ] = [ ] ; yield $ this -> queryLookupd ( $...
ConnectToNSQLookupd adds an nsqlookupd address to the list for this Consumer instance . If it is the first to be added it initiates an Tick Timer to discover nsqd producers for the configured topic .
7,974
private function lookupdPollingTick ( ) { $ jitter = ( float ) rand ( ) / ( float ) getrandmax ( ) * NsqConfig :: getLookupdPollJitter ( ) * NsqConfig :: getLookupdPollInterval ( ) ; Timer :: after ( intval ( $ jitter ) + 1 , function ( ) { if ( $ this -> isStopped ) { return ; } Timer :: tick ( NsqConfig :: getLookupd...
an Tick Timer to discover nsqd producers for the configured topic .
7,975
public function disconnectFromNSQLookupd ( $ addr ) { $ addr = $ this -> formatAddress ( $ addr ) ; if ( ! isset ( $ this -> lookupdHTTPAddrs [ $ addr ] ) ) { throw new NsqException ( "not connected" ) ; } if ( count ( $ this -> lookupdHTTPAddrs ) === 1 ) { throw new NsqException ( "cannot disconnect from only remainin...
DisconnectFromNSQLookupd removes the specified nsqlookupd address from the list used for periodic discovery and close all nsqd connection discover from the address
7,976
public function connectToNSQD ( $ host , $ port ) { if ( $ this -> isStopped ) { throw new NsqException ( "consumer stopped" ) ; } $ addr = "$host:$port" ; if ( ! isset ( $ this -> nsqdTCPAddrsConnNum [ $ addr ] ) ) { $ this -> nsqdTCPAddrsConnNum [ $ addr ] = 0 ; } $ perNsqdMaxNum = $ this -> getMaxConnNumPerNsqd ( ) ...
ConnectToNSQD takes a nsqd address to connect directly to . It is recommended to use ConnectToNSQLookupd so that topics are discovered automatically . This method is useful when you want to connect to a single local instance .
7,977
public function disconnectFromNSQD ( $ host , $ port ) { $ key = "$host:$port" ; if ( ! isset ( $ this -> nsqdTCPAddrsConnNum [ $ key ] ) ) { throw new NsqException ( "not connected" ) ; } foreach ( $ this -> getConnections ( ) as $ conn ) { if ( $ conn -> getHost ( ) === $ host && $ conn -> getPort ( ) === $ port ) { ...
DisconnectFromNSQD closes the connection to and removes the specified nsqd address from the list
7,978
private function checkPageSize ( $ pageSize ) { if ( ! in_array ( $ pageSize , $ this -> availablePageSizes ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid pageSize, "%s" given. Available pageSize are %s.' , $ pageSize , implode ( ', ' , $ this -> availablePageSizes ) ) ) ; } }
Check if the pageSize property is valid
7,979
public function showOptionsForm ( ) : void { $ form = new Options \ Form ( $ this -> options , $ this -> ADMIN_FORM_ID ) ; $ form -> handleRequest ( ) ; $ form -> write ( ) ; }
Output admin options form
7,980
private function httpBuildQuery ( array $ data ) : string { $ queryString = http_build_query ( $ data , '' , '&' ) ; return $ this -> postProcessHttpQueryString ( $ queryString , $ data ) ; }
Wrapper for http_build_query
7,981
public function store ( Request $ request , Response $ response , $ localeId ) { $ response -> headers -> setCookie ( new Cookie ( $ this -> cookieName , $ localeId ) ) ; }
Store the detected locale .
7,982
public function getResponse ( ) { if ( $ this -> response ) return $ this -> response ; else return new \ Asgard \ Http \ Response ( $ this -> code ) ; }
Get the exception response .
7,983
public static function create ( $ belongsTo , $ type , $ data , $ attributes = [ ] ) { $ obj = new Task ( ) ; $ obj -> belongsTo = $ belongsTo ; $ obj -> type = $ type ; $ obj -> data = $ data ; $ obj -> additional = $ attributes ; $ obj -> save ( ) ; }
Create new task
7,984
protected function getConfirmation ( $ question , $ id = '0' , $ answer = true ) { $ request = $ this -> container -> getRequest ( ) ; $ confirmationPool = $ request -> get ( self :: CONFIRMATION_ANSWER_CONTEXT , array ( ) ) ; if ( isset ( $ confirmationPool [ $ id ] ) ) { $ userAnswer = filter_var ( $ confirmationPool...
Sends confirmation message to JavaScript or returns answer if already received
7,985
private function HandleCallQuota ( ) { if ( $ this -> _quota_LastCall == NULL ) { $ this -> _quota_LastCall = new \ DateTime ( ) ; $ this -> _quota_LastCall -> setTimestamp ( 0 ) ; } $ now = new \ DateTime ( ) ; $ secsFromLastCall = $ now -> getTimestamp ( ) - $ this -> _quota_LastCall -> getTimestamp ( ) ; if ( $ secs...
To avoid unneeded traffic to the server slow - down a bit . Server checks this anyway so to preserve the client s traffic avoid excessive usage .
7,986
protected function SimpleResultCall ( string $ actionName , $ request , string $ resultPropName , int $ cacheTtl = 0 ) { $ response = $ this -> ExecuteCall ( $ actionName , $ request , GnResponseType :: Json , FALSE , $ cacheTtl ) ; $ result = $ response -> { $ resultPropName } ; return $ result ; }
Call the server with a simple return - type in a named result - property .
7,987
public static function isPrefixed ( string $ data , string $ prefix , string $ separator = '' ) : bool { if ( $ separator !== '' ) { $ data = trim ( $ data , $ separator ) ; } return static :: substr ( $ data , 0 , static :: length ( $ prefix ) ) === $ prefix ; }
Is prefixed .
7,988
public static function stripPrefix ( string $ data , string $ prefix , string $ separator = '' ) : string { if ( $ data === '' ) { return $ data ; } if ( $ separator !== '' ) { $ data = ltrim ( $ data , $ separator ) ; } if ( static :: substr ( $ data , 0 , static :: length ( $ prefix ) ) === $ prefix ) { $ data = stat...
Strip prefix .
7,989
public static function forcePrefix ( string $ data , string $ prefix , string $ separator = '' ) : string { if ( $ data === '' ) { return $ data ; } if ( $ separator !== '' ) { $ data = trim ( $ data , $ separator ) ; } if ( static :: substr ( $ data , 0 , static :: length ( $ prefix ) ) !== $ prefix ) { if ( $ separat...
Force prefix .
7,990
public static function isSuffixed ( string $ data , string $ suffix , string $ separator = '' ) : bool { if ( $ separator !== '' ) { $ data = trim ( $ data , $ separator ) ; } return static :: substr ( $ data , - static :: length ( $ suffix ) ) === $ suffix ; }
Is suffixed .
7,991
public static function stripSuffix ( string $ data , string $ prefix , string $ separator = '' ) : string { if ( $ data === '' ) { return $ data ; } if ( $ separator !== '' ) { $ data = rtrim ( $ data , $ separator ) ; } if ( static :: substr ( $ data , - static :: length ( $ prefix ) ) === $ prefix ) { $ data = static...
Strip suffix .
7,992
public static function forceSuffix ( string $ data , string $ prefix , string $ separator = '' ) : string { if ( $ data === '' ) { return $ data ; } if ( $ separator !== '' ) { $ data = trim ( $ data , $ separator ) ; } if ( static :: substr ( $ data , - static :: length ( $ prefix ) ) !== $ prefix ) { if ( $ separator...
Force suffix .
7,993
public static function part ( string $ string , string $ separator , int $ index , string $ defaultValue = '' ) : string { if ( $ string !== '' ) { $ string = explode ( $ separator , $ string ) ; if ( isset ( $ string [ $ index ] ) ) { return $ string [ $ index ] ; } } return $ defaultValue ; }
Get part .
7,994
public static function csvFields ( string $ line , string $ delimiter = ',' ) : array { if ( trim ( $ line ) === '' ) { return [ ] ; } $ fields = [ ] ; $ parts = str_getcsv ( $ line , $ delimiter ) ; if ( $ parts !== null && count ( $ parts ) > 0 ) { foreach ( $ parts as $ part ) { $ part = trim ( $ part ) ; if ( subst...
Get CSV fields . Removes and .
7,995
public static function slug ( string $ string , string $ separator = '.' ) : string { $ slug = str_replace ( [ '-' , '_' , ' ' , '.' ] , $ separator , mb_strtolower ( $ string ) ) ; $ slug = preg_replace ( '/[^a-z0-9' . preg_quote ( $ separator ) . ']/' , '' , $ slug ) ; return $ slug ; }
Slug . Standard separator characters - _ . .
7,996
public static function explode ( string $ separator , string $ content , ? callable $ itemFunction = null ) : array { if ( $ separator === "\n" ) { $ content = str_replace ( "\r" , '' , $ content ) ; } $ items = explode ( $ separator , $ content ) ; if ( is_callable ( $ itemFunction ) ) { foreach ( $ items as $ index =...
Explode string into items .
7,997
public static function implode ( string $ separator , array $ items , ? callable $ itemFunction = null ) : string { if ( is_callable ( $ itemFunction ) ) { foreach ( $ items as $ index => $ item ) { $ items [ $ index ] = $ itemFunction ( $ item ) ; } } return implode ( $ separator , $ items ) ; }
Implode items into string .
7,998
public static function padLeft ( string $ string , int $ length , string $ filler = ' ' ) : string { while ( self :: length ( $ string ) <= ( $ length - self :: length ( $ filler ) ) ) { $ string = $ filler . $ string ; } return $ string ; }
Pad left .
7,999
public static function padRight ( string $ string , int $ length , string $ filler = ' ' ) : string { while ( self :: length ( $ string ) <= ( $ length - self :: length ( $ filler ) ) ) { $ string = $ string . $ filler ; } return $ string ; }
Pad right .