idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
241,000
protected function loadShortCodes ( ) { if ( $ config = $ this -> loadConfigFile ( 'shortcodes.php' ) ) { $ renderer = $ this -> renderer ; $ app = $ this -> app ; foreach ( $ config as $ shortcode => $ provider ) { add_shortcode ( $ shortcode , function ( $ attrs , $ content ) use ( $ app , $ provider , $ renderer ) {...
Load shortcodes from configuration files .
241,001
protected function loadOptionScreens ( ) { if ( function_exists ( 'acf_add_options_page' ) && ( $ config = $ this -> loadConfigFile ( 'option_screens.php' ) ) ) { foreach ( $ config as $ optionScreenConfig ) { acf_add_options_page ( $ optionScreenConfig ) ; } } return $ this ; }
Load custom option screens from configuration files .
241,002
protected function loadCliCommands ( ) { if ( defined ( 'WP_CLI' ) && WP_CLI && ( $ config = $ this -> loadConfigFile ( 'commands.php' ) ) ) { foreach ( $ config as $ command => $ className ) { \ WP_CLI :: add_command ( $ command , $ className ) ; } } return $ this ; }
Load custom WP CLI commands from configuration files .
241,003
protected function loadConfigFile ( $ file ) { $ path = $ this -> getConfigPath ( ) . '/' . $ file ; if ( file_exists ( $ path ) ) { $ config = include $ path ; return is_array ( $ config ) ? $ config : null ; } return null ; }
Load a config file from the config directory .
241,004
public static function isTimestamp ( $ string ) { if ( substr ( $ string , 0 , 5 ) == "/Date" ) { return true ; } try { new DateTime ( '@' . $ string ) ; } catch ( Exception $ e ) { return false ; } return true ; }
Determine if the string is a Unix Timestamp
241,005
public function setMaxExternalLastEdited ( array $ apidata ) { $ external_last_edited_key = $ this -> ExternalLastEditedKey ; if ( ! $ external_last_edited_key ) { user_error ( _t ( 'Consumer.ExternalLastEditedKeyNeeded' , 'Property ExternalLastEditedKey needs to be set before calling setMaxExternalLastEdited method' )...
Set the ExternalLastEdited to the maximum last edited date
241,006
protected function assignUsersToAssignment ( ) { $ assignment = fp_env ( 'ACACHA_FORGE_ASSIGNMENT' ) ; foreach ( $ this -> users as $ user ) { $ uri = str_replace ( '{assignment}' , $ assignment , config ( 'forge-publish.assign_user_to_assignment_uri' ) ) ; $ uri = str_replace ( '{user}' , $ user , $ uri ) ; $ url = co...
Assign users to assignment
241,007
protected function askForUsers ( ) { $ default = 0 ; $ users = $ this -> users ( ) ; $ user_names = array_merge ( [ 'Skip' ] , collect ( $ users ) -> pluck ( 'name' ) -> toArray ( ) ) ; $ selected_user_names = $ this -> choice ( 'Users?' , $ user_names , $ default , null , true ) ; if ( $ selected_user_names == 0 ) ret...
Ask for users .
241,008
public static function ipn ( ) { if ( ! count ( $ _POST ) ) { return false ; } if ( Config :: get ( 'paypal.production_mode' ) ) { $ endpoint = 'https://www.paypal.com/cgi-bin/webscr' ; } else { $ endpoint = 'https://www.sandbox.paypal.com/cgi-bin/webscr' ; } $ fields = http_build_query ( array ( 'cmd' => '_notify-vali...
Automatically verify Paypal IPN communications .
241,009
public function profile ( $ classname , $ methodname , $ methodargs , $ invocations = 1 ) { if ( class_exists ( $ classname ) != TRUE ) { throw new Exception ( "{$classname} doesn't exist" ) ; } $ method = new ReflectionMethod ( $ classname , $ methodname ) ; $ instance = NULL ; if ( ! $ method -> isStatic ( ) ) { $ cl...
Runs a method with the provided arguments and returns details about how long it took . Works with instance methods and static methods .
241,010
public function flush ( ) { if ( ! $ this -> hasConnection ( ) ) { return false ; } try { return $ this -> memcache -> flush ( ) ; } catch ( \ Exception $ e ) { } return false ; }
Flush all existing Cache
241,011
public function beforeFilter ( ) { if ( ! isset ( $ this -> _beforeFilters [ $ this -> _action ] ) ) { return false ; } foreach ( $ this -> _beforeFilters [ $ this -> _action ] as $ method ) { call_user_func ( $ method ) ; } }
Executes all the registered beforeFilters for the current action
241,012
public function afterFilter ( ) { if ( ! isset ( $ this -> _afterFilters [ $ this -> _action ] ) ) { return false ; } foreach ( $ this -> _afterFilters [ $ this -> _action ] as $ method ) { call_user_func ( $ method ) ; } }
Execute all the registered afterFilters for the current action
241,013
public final function getView ( $ id , $ view , & $ properties_cache = null , & $ view_cache = null , & $ persistent_view_cache = null ) { if ( isset ( $ view_cache [ $ view ] ) ) { return $ view_cache [ $ view ] ; } switch ( $ view ) { case 'url' : return $ this -> urlFormat ( $ id , $ this -> url_fmt , $ properties_c...
Get properties in given view .
241,014
protected function urlFormat ( $ id , $ url_fmt , $ properties_cache ) : string { if ( isset ( $ url_fmt ) ) { if ( $ properties_cache === null ) { return Utils :: filename_format ( $ url_fmt , array_combine ( $ this -> describeId ( ) , ( array ) $ id ) ) ; } else { return Utils :: filename_format ( $ url_fmt , $ prope...
Create URL using properties and given format .
241,015
protected function resolveMachineReference ( string $ reference_name , array $ properties_cache ) : Reference { if ( ! isset ( $ this -> references [ $ reference_name ] ) ) { throw new \ InvalidArgumentException ( 'Unknown reference: ' . $ reference_name ) ; } $ r = $ this -> references [ $ reference_name ] ; $ ref_mac...
Helper function to resolve reference to another machine .
241,016
public function isTransitionAllowed ( Reference $ ref , $ transition_name , $ state = null , & $ access_policy = null ) { if ( $ state === null ) { $ state = $ ref -> state ; } if ( $ transition_name == '' ) { $ access_policy = $ this -> read_access_policy ; return $ this -> checkAccessPolicy ( $ this -> read_access_po...
Returns true if transition can be invoked right now .
241,017
public function ref ( $ id ) : Reference { $ ref = new $ this -> reference_class ( $ this -> smalldb , $ this , $ id ) ; if ( $ this -> debug_logger ) { $ this -> debug_logger -> afterReferenceCreated ( null , $ ref ) ; } return $ ref ; }
Helper to create Reference to this machine .
241,018
public function hotRef ( $ properties ) : Reference { $ ref = $ this -> reference_class :: createPreheatedReference ( $ this -> smalldb , $ this , $ properties ) ; if ( $ this -> debug_logger ) { $ this -> debug_logger -> afterReferenceCreated ( null , $ ref , $ properties ) ; } return $ ref ; }
Create pre - heated reference using properties loaded from elsewhere .
241,019
public function performSelfCheck ( ) { $ results = [ ] ; $ results [ 'id' ] = $ this -> describeId ( ) ; $ results [ 'class' ] = get_class ( $ this ) ; $ results [ 'missing_methods' ] = [ ] ; $ results [ 'errors' ] = $ this -> errors ; foreach ( $ this -> describeAllMachineActions ( ) as $ a => $ action ) { foreach ( $...
Perform self - check .
241,020
public function findUnreachableStates ( ) : array { $ g = new Graph ( ) ; $ g -> indexNodeAttr ( 'unreachable' ) ; $ g -> createNode ( '' , [ 'unreachable' => false ] ) ; foreach ( $ this -> states as $ s => $ state ) { if ( $ s !== '' ) { $ g -> createNode ( $ s , [ 'unreachable' => true ] ) ; } } foreach ( $ this -> ...
Run DFS from not - exists state and return list of unreachable states .
241,021
private function exportDotRenderGroups ( $ groups , $ group_content , $ indent = "\t" ) { foreach ( $ groups as $ g => $ group ) { echo $ indent , "subgraph " , $ this -> exportDotIdentifier ( $ g , 'cluster_' ) , " {\n" ; if ( isset ( $ group [ 'label' ] ) ) { echo $ indent , "\t" , "label = \"" , addcslashes ( $ grou...
Recursively render groups in state machine diagram .
241,022
protected function exportDotRenderExtras ( $ debug_opts ) { if ( ! empty ( $ this -> state_diagram_extras ) ) { echo "\tsubgraph cluster_extras {\n" , "\t\tgraph [ margin = 10; ];\n" , "\t\tcolor=transparent;\n\n" ; foreach ( $ this -> state_diagram_extras as $ i => $ e ) { echo "\n\t# Extras " , str_replace ( "\n" , "...
Render extra diagram features .
241,023
protected function exportJsonAddExtras ( $ debug_opts , array $ machine_graph ) : array { if ( ! empty ( $ this -> state_diagram_extras_json ) ) { $ graph = $ this -> state_diagram_extras_json ; if ( ! isset ( $ graph [ 'layout' ] ) ) { $ graph [ 'layout' ] = 'row' ; $ graph [ 'layoutOptions' ] = [ 'align' => 'top' , ]...
Add extra diagram features into the diagram .
241,024
public function disconnect ( ) : void { if ( $ this -> dbconn -> inTransaction ( ) ) { $ this -> dbconn -> rollBack ( ) ; } $ this -> dbconn = null ; $ this -> is_connected = false ; }
Close the connection if it has been established .
241,025
public function beginTransaction ( ) : bool { if ( $ this -> dbconn -> inTransaction ( ) ) { throw new TransactionErrorException ( "A transaction has already been started." ) ; } try { return $ this -> dbconn -> beginTransaction ( ) ; } catch ( \ PDOException $ exception ) { throw new TransactionsNotSupportedException ...
Start a transaction .
241,026
public function toArray ( ) : ? array { if ( null === $ this -> stmt || false === $ this -> stmt ) { return null ; } return $ this -> stmt -> toArray ( ) ; }
Gets the results and a multidimensional array .
241,027
private static function clearName ( $ string , $ removeWords ) { $ string = str_replace ( ' ' , '-' , $ string ) ; $ string = preg_replace ( '/[^A-Za-z0-9\-]/' , '' , $ string ) ; foreach ( $ removeWords as $ word ) { $ string = str_replace ( $ word , '' , $ string ) ; } $ string = substr ( $ string , 0 , 29 ) ; return...
remove special chars and words from string
241,028
public function upload ( $ file = null ) { if ( empty ( $ file ) || ! is_array ( $ file ) ) return false ; $ this -> u_tmp_name = $ file [ 'tmp_name' ] ; $ this -> u_name = $ file [ 'name' ] ; $ this -> u_size = $ file [ 'size' ] ; $ this -> u_mime_type = $ file [ 'type' ] ; $ this -> u_error = isset ( $ file [ 'error'...
current upload process
241,029
private function _get_file_extension ( ) { if ( empty ( $ this -> u_mime_type ) ) return false ; $ tmp = explode ( '/' , $ this -> u_mime_type ) ; $ this -> file_extension = array_pop ( $ tmp ) ; unset ( $ tmp ) ; return true ; }
gets the suffix for the file that has been uploaded
241,030
private function rebuildAttrIndex ( string $ key ) { $ this -> index [ $ key ] = [ ] ; foreach ( $ this -> elements as $ id => $ element ) { if ( $ element instanceof $ this -> elementClassName ) { $ value = $ element -> getAttr ( $ key ) ; $ this -> index [ $ key ] [ $ value ] [ $ id ] = $ element ; } else { throw new...
Rebuild the entire index from provided elements .
241,031
public function removeElement ( AbstractElement $ element ) { $ id = $ element -> getId ( ) ; if ( ! isset ( $ this -> elements [ $ id ] ) ) { throw new MissingElementException ( "Element \"$id\" is not indexed." ) ; } unset ( $ this -> elements [ $ id ] ) ; $ indexedAttrs = array_intersect_key ( $ element -> getAttrib...
Remove element from index
241,032
public function update ( string $ key , $ oldValue , $ newValue , AbstractElement $ element ) { if ( ! isset ( $ this -> index [ $ key ] ) ) { throw new MissingAttrIndexException ( "Attribute index \"$key\" is not defined." ) ; } $ id = $ element -> getId ( ) ; if ( isset ( $ this -> index [ $ key ] [ $ oldValue ] [ $ ...
Update indices to match the changed attribute of the element
241,033
public function getElements ( string $ key , $ value ) : array { if ( ! isset ( $ this -> index [ $ key ] ) ) { throw new MissingAttrIndexException ( "Attribute index \"$key\" is not defined." ) ; } return $ this -> index [ $ key ] [ $ value ] ?? [ ] ; }
Get elements by the value of the attribute
241,034
public static function image ( $ src , $ alt = '' , $ options = [ ] ) { $ image_tag_tpl = '<img src="%s" alt="%s"%s />' ; $ cdnHost = Lb :: app ( ) -> getCdnHost ( ) ; if ( $ cdnHost ) { if ( ! ValidationHelper :: isUrl ( $ src ) ) { $ src = $ cdnHost . $ src ; } else { $ src = preg_replace ( '/^(http|https):\/\/.+?\//...
Generate image tag
241,035
public static function purify ( $ dirtyHtml ) { if ( self :: $ htmlPurifier && self :: $ htmlPurifier instanceof \ HTMLPurifier ) { $ purifier = self :: $ htmlPurifier ; } else { $ purifier = ( self :: $ htmlPurifier = new \ HTMLPurifier ( \ HTMLPurifier_Config :: createDefault ( ) ) ) ; } return $ purifier -> purify (...
Purify dirty html
241,036
public static function GetRequestToken ( OAuthConsumer $ consumer , $ scope , $ endpoint , $ applicationName , $ callbackUrl ) { $ signatureMethod = new OAuthSignatureMethod_HMAC_SHA1 ( ) ; $ params = array ( ) ; $ params [ 'scope' ] = $ scope ; if ( isset ( $ applicationName ) ) { $ params [ 'xoauth_displayname' ] = $...
Using the consumer and scope provided a request is made to the endpoint to generate an OAuth request token .
241,037
public static function GetAccessToken ( OAuthConsumer $ consumer , OAuthToken $ token , $ verifier , $ endpoint ) { $ signatureMethod = new OAuthSignatureMethod_HMAC_SHA1 ( ) ; $ params = array ( ) ; $ params [ 'oauth_verifier' ] = $ verifier ; $ request = OAuthRequest :: from_consumer_and_token ( $ consumer , $ token ...
Using the provided consumer and authorized request token a request is made to the endpoint to generate an OAuth access token .
241,038
private static function GetTokenFromUrl ( $ url ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; $ response = curl_exec ( $ ch ) ; $ hea...
Makes an HTTP request to the given URL and extracts the returned OAuth token .
241,039
public function init ( $ main_db , $ clone_db , $ table_list = null ) { try { if ( empty ( $ main_db ) && empty ( $ clone_db ) ) return false ; if ( ! $ this -> select_db ( ( string ) $ main_db ) ) { throw new DatabaseException ( 'Could not select Main Database ' . $ main_db ) ; } $ this -> clone_dbname = $ clone_db ; ...
starts the cloning process
241,040
public function clone_database ( $ main_db = null , $ clone_db = null ) { if ( empty ( $ this -> db ) ) { throw new DatabaseException ( 'Clone or Main database not connected' ) ; } if ( empty ( $ main_db ) || empty ( $ clone_db ) ) { throw new DatabaseException ( 'clone names havent been set' ) ; } $ sql = "SHOW CREATE...
clones the specific database
241,041
private function getPhotos ( Description $ description ) { return array_map ( function ( \ stdClass $ photoDescription ) { return $ this -> photoFactory -> create ( new Description ( $ photoDescription ) ) ; } , $ description -> getOptionalProperty ( 'items' , [ ] ) ) ; }
Get the venue photos .
241,042
public static function getString ( $ status = FALSE , $ tagStart = NULL , $ tagEnd = "\n" ) { $ arr = self :: get ( $ status ) ; $ str = '' ; foreach ( $ arr as $ msg ) { $ str .= $ tagStart . $ msg . $ tagEnd ; } return $ str ; }
Return messages as a string
241,043
public static function count ( $ status = FALSE ) { if ( $ status === FALSE ) { return count ( self :: $ messages ) ; } if ( isset ( self :: $ messages [ $ status ] ) ) { return count ( self :: $ messages [ $ status ] ) ; } else { return 0 ; } }
Return number of messages
241,044
public function getBasicDefinition ( $ class ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( "$class is not a valid class name" ) ; } $ definition = new Definition ( $ class , [ ] ) ; $ traits = $ this -> classUsesDeep ( $ class ) ; foreach ( $ traits as $ trait ) { switch ( $ trait ) { c...
Creates a basic service definition for the given class injecting the typical dependencies according with the traits the class uses .
241,045
function getLabel ( ) { if ( $ this -> filtername ) return $ this -> filtername ; $ className = explode ( '\\' , get_class ( $ this ) ) ; $ className = $ className [ count ( $ className ) - 1 ] ; return $ className . '.*' ; }
Label Used To Register Our Filter
241,046
protected function _getDataFromBucket ( $ in , & $ consumed ) { $ data = '' ; while ( $ bucket = stream_bucket_make_writeable ( $ in ) ) { $ data .= $ bucket -> data ; $ consumed += $ bucket -> datalen ; } return $ data ; }
Read Data From Bucket
241,047
protected function _writeBackDataOut ( $ out , $ data ) { $ buck = stream_bucket_new ( $ this -> bufferHandle , '' ) ; if ( false === $ buck ) return PSFS_ERR_FATAL ; $ buck -> data = $ data ; stream_bucket_append ( $ out , $ buck ) ; return PSFS_PASS_ON ; }
Write Back Filtered Data On Out Bucket
241,048
public function authPubkey ( $ session , $ username , $ pubkey , $ privkey , $ passphrase ) { return ssh2_auth_pubkey_file ( $ session , $ username , $ pubkey , $ privkey , $ passphrase ) ; }
Facade for ssh2_auth_pubkey_file .
241,049
public function scpSend ( $ session , $ local_file , $ remote_file , $ create_mode = 0644 ) { return ssh2_scp_send ( $ session , $ local_file , $ remote_file , $ create_mode ) ; }
Facade for ssh2_scp_send .
241,050
public function load ( $ packageName ) { if ( $ this -> loadedModules -> has ( $ packageName ) ) { return $ this -> loadedModules -> get ( $ packageName ) ; } if ( ! $ this -> installedModules -> has ( $ packageName ) ) { throw new ModuleException ( sprintf ( 'Module (%s) does not exist.' , $ packageName ) , 500 ) ; } ...
Loads a module and returns the associated class or returns if already loaded
241,051
public static function buildDescription ( ) { if ( DescriptionRegistry :: hasDescription ( __CLASS__ ) ) return DescriptionRegistry :: getDescription ( __CLASS__ ) ; $ desc = new Description ( 'String' , NativeType :: STRING , false ) ; DescriptionRegistry :: registerDescriptionFor ( __CLASS__ , $ desc ) ; return $ des...
The description is cached in the internal description property
241,052
protected function setLastRow ( BlockInterface $ block , BlockInterface $ row ) { if ( ! BlockUtil :: isBlockType ( $ row , PanelRowSpacerType :: class ) ) { $ block -> setAttribute ( 'last_row' , $ row -> getName ( ) ) ; } }
Set the last row .
241,053
protected function getLastRow ( BlockInterface $ block ) { if ( $ block -> hasAttribute ( 'last_row' ) ) { $ row = $ block -> get ( $ block -> getAttribute ( 'last_row' ) ) ; if ( \ count ( $ row ) < $ row -> getOption ( 'column' ) ) { return $ row ; } } $ rowName = BlockUtil :: createUniqueName ( ) ; $ block -> add ( ...
Get the last row .
241,054
static function execute ( Base $ base ) { self :: $ _base = $ base ; $ request = isset ( $ _REQUEST [ 'route' ] ) ? $ _REQUEST [ 'route' ] : '/' ; if ( strpos ( $ request , '?' ) > 0 ) { $ split = explode ( '?' , $ request ) ; $ request = $ split [ 0 ] ; } self :: $ _attr = array_slice ( explode ( '/' , trim ( $ reques...
Executes the router
241,055
private static function _run ( $ request ) { $ matched_route = false ; $ request = '/' . $ request ; $ request = rtrim ( $ request , '/' ) . '/' ; $ request = str_replace ( "//" , "/" , $ request ) ; ksort ( self :: $ _routes ) ; foreach ( self :: $ _routes as $ priority => $ routes ) { foreach ( $ routes as $ source =...
Tries to match one of the URL routes to the current URL otherwise execute the default function . Sets the callback that needs to be returned
241,056
private static function _set_callback ( $ destination ) { if ( is_callable ( $ destination ) ) { self :: $ callback = array ( $ destination , self :: $ _attr ) ; } else { $ result = explode ( '/' , trim ( $ destination , '/' ) ) ; $ controller = ( $ result [ 0 ] == "" ) ? configItem ( 'site' ) [ 'default_controller' ] ...
Sets the callback as an array containing Controller Method & Parameters
241,057
function __toArray ( ) { $ params = __ ( new HydrateGetters ( $ this ) ) -> setExcludeNullValues ( ) ; $ params = StdTravers :: of ( $ params ) -> toArray ( null , true ) ; return $ params ; }
Get Grant Request Params As Array
241,058
public function run ( $ workload , TaskWrapper $ task ) { $ result = false ; $ this -> id = $ task -> getId ( ) ; $ this -> name = $ task -> getName ( ) ; try { if ( false !== $ this -> beforeRun ( $ workload , $ task ) ) { $ result = $ this -> doRun ( $ workload , $ task ) ; $ this -> afterRun ( $ result ) ; } } catch...
do the job
241,059
public function filter ( $ value ) { $ value = strtr ( $ value , $ this -> transliteration ) ; if ( $ this -> transformCase ) { $ value = mb_convert_case ( $ value , MB_CASE_LOWER , 'utf8' ) ; } if ( $ this -> transformPunctuation ) { $ value = strtr ( $ value , $ this -> punctuation ) ; } return $ value ; }
Normalise the input string
241,060
public function setTransliterationReplacements ( $ replacements ) { if ( ! is_array ( $ replacements ) ) { throw new \ Thin \ Exception ( __METHOD__ . ': method expects a keyed array as argument.' , 500 ) ; } foreach ( $ replacements as $ key => $ value ) { $ this -> transliteration [ $ key ] = $ value ; } return $ thi...
Set transliteration replacement values .
241,061
public function setPunctuationReplacements ( $ replacements ) { if ( ! is_array ( $ replacements ) ) { throw new \ Thin \ Exception ( __METHOD__ . ': method expects a keyed array as argument.' , 500 ) ; } foreach ( $ replacements as $ key => $ value ) { $ this -> punctuation [ $ key ] = $ value ; } return $ this ; }
Set punctuation replacement values .
241,062
public function getArrayCopy ( ) : array { $ values = get_object_vars ( $ this ) ; foreach ( $ values as $ property => $ value ) { if ( is_object ( $ value ) ) { unset ( $ values [ $ property ] ) ; } } return $ values ; }
Gets an array copy
241,063
public function exchangeArray ( $ data ) { foreach ( $ data as $ property => $ value ) { if ( isset ( $ this -> $ property ) ) { $ method = 'set' . ucfirst ( $ property ) ; $ this -> $ method ( $ value ) ; } } }
Maps the specified data to the properties of this object
241,064
public function callAction ( ) { if ( $ this -> checkAuthenticated ( ) ) { $ this -> view -> assign ( 'user' , $ this -> user ) ; parent :: callAction ( ) ; } }
Call controller action method
241,065
public static function getMetadataByContent ( ezpContent $ content ) { $ aMetadata = array ( 'objectName' => $ content -> name , 'classIdentifier' => $ content -> classIdentifier , 'datePublished' => ( int ) $ content -> datePublished , 'dateModified' => ( int ) $ content -> dateModified , 'objectRemoteId' => $ content...
Returns metadata for given content as array
241,066
public static function getMetadataByLocation ( ezpContentLocation $ location ) { $ url = $ location -> url_alias ; eZURI :: transformURI ( $ url , false , 'full' ) ; $ aMetadata = array ( 'nodeId' => ( int ) $ location -> node_id , 'nodeRemoteId' => $ location -> remote_id , 'fullUrl' => $ url ) ; return $ aMetadata ; ...
Returns metadata for given content location as array
241,067
public static function getLocationsByContent ( ezpContent $ content ) { $ aReturnLocations = array ( ) ; $ assignedNodes = $ content -> assigned_nodes ; foreach ( $ assignedNodes as $ node ) { $ location = ezpContentLocation :: fromNode ( $ node ) ; $ locationData = self :: getMetadataByLocation ( $ location ) ; $ loca...
Returns all locations for provided content as array .
241,068
public static function getFieldsByContent ( ezpContent $ content ) { $ aReturnFields = array ( ) ; foreach ( $ content -> fields as $ name => $ field ) { $ aReturnFields [ $ name ] = self :: attributeOutputData ( $ field ) ; } return $ aReturnFields ; }
Returns all fields for provided content
241,069
public static function attributeOutputData ( ezpContentField $ field ) { switch ( $ field -> data_type_string ) { case 'ezxmltext' : $ html = $ field -> content -> attribute ( 'output' ) -> attribute ( 'output_text' ) ; $ attributeValue = array ( strip_tags ( $ html ) ) ; break ; case 'ezimage' : $ strRepImage = $ fiel...
Transforms an ezpContentField in an array representation
241,070
public static function getChildrenList ( ezpContentCriteria $ c , ezpRestRequest $ currentRequest , array $ responseGroups = array ( ) ) { $ aRetData = array ( ) ; $ aChildren = ezpContentRepository :: query ( $ c ) ; foreach ( $ aChildren as $ childNode ) { $ childEntry = self :: getMetadataByContent ( $ childNode ) ;...
Returns all children node data based on the provided criteria object
241,071
public static function authQueryString ( $ authKey , $ accessToken , $ request = null ) { return HashHelper :: hash ( $ request ? $ request -> getParam ( $ authKey ) : Lb :: app ( ) -> getParam ( $ authKey ) ) == $ accessToken ; }
Query String Authentication
241,072
public function toMessage ( ) { $ m = new Message ( array ( $ this -> getRequestId ( ) , $ this -> getActionName ( ) , ) ) ; $ m -> append ( $ this -> getParameters ( ) ) ; return $ m ; }
Create a new Message from this StorageStatus .
241,073
public static function msgfmt ( $ po , $ mo = null ) { $ stringset = Po :: fromFile ( $ po ) ; if ( $ mo === null ) { $ mo = substr ( $ po , 0 , - 3 ) . '.mo' ; } Mo :: toFile ( $ stringset , $ mo ) ; }
Read a po file and store a mo file . If no MO filename is given one will be generated from the PO filename .
241,074
public static function msgunfmt ( $ mo , $ po = null ) { $ stringset = Mo :: fromFile ( $ mo ) ; if ( $ po === null ) { print Po :: toString ( $ stringset ) ; } else { Po :: toFile ( $ stringset , $ po ) ; } }
Reads a mo file and stores the po file . If no PO file was given only displays what would be the result .
241,075
public function have_pages ( ) { $ this -> setup ( ) ; $ offset = $ this -> get_query_offset ( ) ; return ( bool ) ( $ offset < $ this -> total_posts ) ; }
Indicates if we have posts to process
241,076
protected function count_posts ( ) { global $ wpdb ; $ query = $ this -> get_count_query ( ) ; $ this -> total_posts = $ wpdb -> get_var ( $ query ) ; }
Counts the total number of posts that match the restrictions not including pagination .
241,077
protected function getCurrentTaxonomy ( ) { if ( ! isset ( $ this -> args [ 'taxonomies' ] ) || empty ( $ this -> args [ 'taxonomies' ] ) ) { $ this -> args [ 'taxonomies' ] = $ this -> getDefaultTaxonomies ( ) ; } foreach ( $ this -> args [ 'taxonomies' ] as $ tax ) { if ( $ tax = get_term_by ( 'slug' , get_query_var ...
Find a custom taxonomy
241,078
protected function getOverloaded ( $ postType ) { if ( ! isset ( $ this -> args [ 'overload' ] [ $ postType ] ) ) { return null ; } return $ this -> args [ 'overload' ] [ $ postType ] ; }
return the fake post type
241,079
private function validate ( $ method ) { $ actionMethod = $ method . 'Method' ; $ ref = new \ ReflectionClass ( $ this -> manager ) ; if ( null === $ this -> $ actionMethod || ! $ ref -> hasMethod ( $ this -> $ actionMethod ) ) { throw new \ RuntimeException ( sprintf ( 'The "%s" method for "%s" adapter is does not sup...
Validate the adapter method .
241,080
public function validateObject ( $ instance ) { if ( null !== $ this -> validator ) { $ violations = $ this -> validator -> validate ( $ instance ) ; if ( ! empty ( $ violations ) ) { throw new ValidationException ( $ violations ) ; } } }
Validate the object instance .
241,081
public static function relationFromField ( $ fieldName , $ method = null ) { if ( $ method ) return $ method ; if ( substr ( $ fieldName , - 3 ) == '_id' ) { return substr ( $ fieldName , 0 , - 3 ) ; } if ( substr ( $ fieldName , - 4 ) == '_ids' ) { return substr ( $ fieldName , 0 , - 4 ) . 's' ; } return $ fieldName ;...
Consider this as a bit of magic This method will return a guessed method name which is used from the relation Since there is no way in Eloquent to read the relations from a model we have to work with what we get
241,082
public static function factory ( $ config = array ( ) ) { $ required = array ( 'base_url' ) ; $ config = Collection :: fromConfig ( $ config , array ( ) , $ required ) ; $ client = new self ( $ config -> get ( 'base_url' ) ) ; $ cookiePlugin = new CookiePlugin ( new ArrayCookieJar ( ) ) ; $ client -> addSubscriber ( $ ...
Factory method to create a new MediawikiApiClient
241,083
public static function factory ( array $ dbConfig ) : DbItf { static $ instances = [ ] ; $ key = md5 ( json_encode ( $ dbConfig ) ) ; if ( isset ( $ instances [ $ key ] ) ) { return $ instances [ $ key ] ; } switch ( $ dbConfig [ DbItf :: DB_CFG_DRIVER ] ) { case DbItf :: DB_DRIVER_MYSQL : $ instances [ $ key ] = new M...
Database factory .
241,084
public function calculateChangeSet ( ) { if ( false === $ this -> isDirty ( ) ) { return [ ] ; } return [ 'old' => empty ( $ this -> original ) ? null : $ this -> original , 'new' => empty ( $ this -> models ) ? null : $ this -> models , ] ; }
Calculates the change set of this collection .
241,085
public function has ( AbstractModel $ model ) { $ key = $ model -> getCompositeKey ( ) ; return isset ( $ this -> models [ $ key ] ) ; }
Determines if the Model is included in the collection .
241,086
public function push ( AbstractModel $ model ) { $ this -> validateAdd ( $ model ) ; if ( true === $ this -> willAdd ( $ model ) ) { return $ this ; } if ( true === $ this -> willRemove ( $ model ) ) { $ this -> evict ( 'removed' , $ model ) ; $ this -> set ( 'models' , $ model ) ; return $ this ; } if ( true === $ thi...
Pushes a Model into the collection .
241,087
public function rollback ( ) { $ this -> models = $ this -> original ; $ this -> added = [ ] ; $ this -> removed = [ ] ; return $ this ; }
Rollsback the collection it it s original state .
241,088
public function willAdd ( AbstractModel $ model ) { $ key = $ model -> getCompositeKey ( ) ; return isset ( $ this -> added [ $ key ] ) ; }
Determines if the model is scheduled for addition to the collection .
241,089
public function willRemove ( AbstractModel $ model ) { $ key = $ model -> getCompositeKey ( ) ; return isset ( $ this -> removed [ $ key ] ) ; }
Determines if the model is scheduled for removal from the collection .
241,090
protected function add ( AbstractModel $ model ) { if ( true === $ this -> has ( $ model ) ) { return $ this ; } $ this -> validateAdd ( $ model ) ; if ( true === $ model -> getState ( ) -> is ( 'empty' ) ) { $ this -> loaded = false ; } $ key = $ model -> getCompositeKey ( ) ; $ this -> models [ $ key ] = $ model ; $ ...
Adds an model to this collection . Is used during initial collection construction .
241,091
protected function hasOriginal ( AbstractModel $ model ) { $ key = $ model -> getCompositeKey ( ) ; return isset ( $ this -> original [ $ key ] ) ; }
Determines if the model is included in the original set .
241,092
public function resolvePlatform ( EventManager $ eventManager ) { $ eventManager -> attachSubscriber ( new ConnectionAttemptSubscriber ( ) ) ; if ( ! $ this -> connectionManager instanceof ConnectionInterface ) { throw new RuntimeException ( 'Connection must implement \ConnectionInterface' ) ; } $ reflector = new \ Ref...
Resolve provided connection s platform .
241,093
private function getPlatformProvider ( $ platform = [ ] , EventManager $ eventManager ) { if ( is_null ( $ platform ) ) { return false ; } $ platformId = key ( $ platform ) ; $ platform = current ( $ platform ) ; if ( ! isset ( $ platform [ 'provider' ] ) ) { $ this -> connectionFailed = ':noPlatform' ; return false ; ...
Resolves a connector s provider and returns it s object .
241,094
public function encode ( $ numbers ) { $ chars = [ ] ; $ alphabet = $ this -> alphabet ; foreach ( $ numbers as $ number ) { if ( isset ( $ alphabet [ $ number ] ) ) { $ chars [ ] = $ alphabet [ $ number ] ; } else { throw new InvalidBase64Input ( $ number ) ; } } return implode ( '' , $ chars ) ; }
Encodes a block of numbers to a base64 - string
241,095
public function decode ( $ based ) { if ( ! is_array ( $ based ) ) { $ based = str_split ( $ based ) ; } $ numbers = [ ] ; $ char2int = $ this -> char2int ; foreach ( $ based as $ char ) { if ( isset ( $ char2int [ $ char ] ) ) { $ numbers [ ] = $ char2int [ $ char ] ; } else { throw new InvalidBase64 ( $ based ) ; } }...
Decodes a base64 - string to a block of numbers
241,096
public function parseLog ( $ log ) { $ commits = $ tags = [ ] ; for ( $ i = 0 , $ lines = count ( $ log ) ; $ i < $ lines ; $ i ++ ) { $ tmp = explode ( ': ' , $ log [ $ i ] ) ; $ tmp = array_map ( 'trim' , $ tmp ) ; if ( $ tmp [ 0 ] == 'changeset' ) { $ commit = $ tmp [ 1 ] ; } if ( $ tmp [ 0 ] == 'user' ) { $ email =...
Parse the log provided as a string
241,097
public function extractAuthor ( $ string ) { preg_match_all ( '/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i' , $ string , $ matches ) ; $ string = str_replace ( $ matches [ 0 ] , '' , $ string ) ; $ string = str_replace ( [ '<' , '>' , '()' ] , '' , $ string ) ; $ string = trim ( $ string ) ; return empty ( $ string ) ? 'Unkno...
Extract the Author name from the string remove emails if they exist
241,098
public function save ( $ savePath , $ imageQuality = 95 ) { if ( ! $ this -> imageResized ) { $ this -> imageResized = $ this -> image ; } $ extension = Inflector :: lower ( File :: extension ( $ savePath ) ) ; switch ( $ extension ) { case 'jpg' : case 'jpeg' : if ( imagetypes ( ) & IMG_JPG ) { imagejpeg ( $ this -> i...
Save the image based on its file type .
241,099
private function get_dimensions ( $ newWidth , $ newHeight , $ option ) { switch ( $ option ) { case 'exact' : $ optimalWidth = $ newWidth ; $ optimalHeight = $ newHeight ; break ; case 'portrait' : $ optimalWidth = $ this -> getSizeByFixedHeight ( $ newHeight ) ; $ optimalHeight = $ newHeight ; break ; case 'landscape...
Return the image dimensions based on the option that was chosen .