idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
0 | private function traceCLI ( array $ trace , $ label ) { foreach ( $ trace as $ k => $ v ) { $ func = $ loc = $ line = '' ; $ argsPresent = isset ( $ v [ 'args' ] ) && ! empty ( $ v [ 'args' ] ) ; self :: formatTraceLine ( $ v , $ func , $ loc , $ line ) ; $ this -> console -> write ( '<' . $ label . 'b>#' . $ k . ': </... | CLI output of the debug backtrace |
1 | private static function formatTraceLine ( array $ traceLine , & $ method , & $ file , & $ line ) { $ method = $ file = $ line = '' ; if ( isset ( $ traceLine [ 'class' ] ) ) { $ method = $ traceLine [ 'class' ] ; } if ( isset ( $ traceLine [ 'type' ] ) ) { $ method .= $ traceLine [ 'type' ] ; } if ( isset ( $ traceLine... | Formats the debug backtrace row |
2 | private function traceHTML ( array $ trace ) { ?> <table class="table" border="1"> <thead> <tr> <th>#</th> <th>Method</th> <th>Args</th> <th>File</th> <th>Line</th> </tr> ... | Echoes a HTML debug backtrace |
3 | public static function isValid ( string $ mediaType ) : bool { return ( bool ) preg_match ( self :: REGEX , trim ( $ mediaType ) ) ; } | Checks if the given string is a valid media type . |
4 | public static function fromExtension ( string $ extension ) : MediaType { if ( ! self :: isKnownExtension ( $ extension ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown extension "%s" given.' , $ extension ) ) ; } return new self ( self :: $ knownTypes [ strtolower ( $ extension ) ] ) ; } | Constructs a new media type object from the given extension . |
5 | private static function isCommandAvailable ( string $ command ) : bool { if ( ! is_callable ( 'shell_exec' ) || stripos ( ini_get ( 'disable_functions' ) , 'shell_exec' ) !== false ) { return false ; } $ result = null ; if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) != 'WIN' ) { $ result = @ shell_exec ( 'which ' . $ co... | Checks if the given command is callable on the command line . |
6 | private static function guessFromFileCommand ( string $ filename ) : string { $ result = 'application/octet-stream' ; if ( ! self :: isCommandAvailable ( 'file' ) ) { return $ result ; } $ info = trim ( shell_exec ( 'file -bi ' . escapeshellarg ( $ filename ) ) ) ; return $ info != '' ? $ info : $ result ; } | Uses the unix file command to guess the media type . |
7 | private static function guessFromFinfo ( string $ filename ) : string { $ result = 'application/octet-stream' ; if ( ! function_exists ( 'finfo_file' ) ) { return $ result ; } $ handle = finfo_open ( FILEINFO_MIME ) ; if ( $ handle === false ) { return $ result ; } $ info = finfo_file ( $ handle , $ filename ) ; finfo_... | Uses finfo_file to guess the media type . |
8 | public static function fromFile ( string $ filename , bool $ allowGuessByExtension ) : MediaType { $ result = 'application/octet-stream' ; if ( ! @ is_file ( $ filename ) || ! @ is_readable ( $ filename ) ) { return new self ( $ result ) ; } $ result = self :: guessFromFinfo ( $ filename ) ; if ( self :: isFallback ( $... | Constructs a new media type object for the given file name . |
9 | protected function getOutputResponse ( ServerRequestInterface $ request , ResponseInterface $ response ) : ResponseInterface { ob_start ( ) ; switch ( $ this -> determineOutputType ( ) ) { case self :: TYPE_JSON : $ this -> renderJSON ( $ request , $ response ) ; break ; case self :: TYPE_XML : $ this -> renderXML ( $ ... | Getting Output For Response |
10 | protected function setupRootNode ( ) { $ builder = new TreeBuilder ( ) ; $ this -> rootNode = $ builder -> root ( $ this -> getBundleName ( ) ) ; return $ this ; } | Sets up the root node of TreeBuilder . |
11 | protected function init ( ) { global $ wpdb ; $ this -> wpdb = $ wpdb ; $ this -> queryGrammar = new MySqlGrammar ( ) ; $ this -> postProcessor = new MySqlProcessor ( ) ; } | Method to be started |
12 | protected function getOrCreateType ( Index $ index , $ typeName ) { Assertion :: minLength ( $ typeName , 1 , 'Type name must be at least one char long' ) ; if ( ! empty ( $ this -> types [ $ index -> getName ( ) ] [ $ typeName ] ) ) { return $ this -> types [ $ index -> getName ( ) ] [ $ typeName ] ; } if ( ! $ this -... | Returns a elastic search type for specified index and type name . |
13 | protected function typeExists ( Index $ index , $ typeName ) { Assertion :: minLength ( $ typeName , 1 , 'Type name must be at least one char long' ) ; $ mapping = $ index -> getMapping ( ) ; return ! empty ( $ mapping [ $ index -> getName ( ) ] [ $ typeName ] ) ; } | Returns true if specified type exists in the index false otherwise . |
14 | protected function createType ( Index $ index , $ typeName ) { Assertion :: minLength ( $ typeName , 1 , 'Type name must be at least one char long' ) ; $ type = $ index -> getType ( $ typeName ) ; $ options = $ this -> mergeDefaultOptions ( ) ; $ mappingObject = new Mapping ( ) ; if ( ! empty ( $ options [ 'mapping' ] ... | Creates a new type with specified name in specified index . |
15 | public function getIndex ( $ indexName , array $ indexOptions = array ( ) , $ specials = null ) { $ indexName = strtolower ( $ indexName ) ; if ( empty ( $ this -> indexes [ $ indexName ] ) ) { $ client = $ this -> getClient ( ) ; $ this -> indexes [ $ indexName ] = $ client -> getIndex ( $ indexName ) ; if ( ! $ this ... | Provides an elasticsearch index to attach documents to . |
16 | protected function transcodeDataToDocument ( $ document , $ identifier ) { if ( ! $ document instanceof Document ) { if ( is_object ( $ document ) ) { if ( get_class ( $ document ) == 'stdClass' ) { $ document = ( array ) $ document ; } else { if ( $ document instanceof \ JsonSerializable ) { $ document = json_encode (... | Makes sure that the given data is an Elastica \ Document |
17 | public function removeDocuments ( array $ ids , $ index , $ type = '' ) { if ( empty ( $ type ) ) { $ type = $ this -> typeName ; } $ client = $ this -> getClient ( ) ; $ index = $ client -> getIndex ( $ index ) ; $ client -> deleteIds ( $ ids , $ index , $ type ) ; $ index -> refresh ( ) ; } | Removes a document from the index . |
18 | public function updateDocument ( $ id , $ data , $ indexName , $ typeName = '' ) { $ index = $ this -> getIndex ( $ indexName ) ; $ client = $ index -> getClient ( ) ; $ type = $ index -> getType ( empty ( $ typeName ) ? $ this -> typeName : $ typeName ) ; $ rawData = array ( 'doc' => $ this -> decorator -> normalizeVa... | Updates a elsaticsearch document . |
19 | public function normalizeError ( $ error ) { if ( $ error instanceof \ Exception ) { return new AdaptorException ( $ error -> getMessage ( ) , $ error -> getCode ( ) , $ error ) ; } return new AdaptorException ( sprintf ( 'An error accord: %s' , print_r ( $ error , true ) ) , AdaptorException :: UNKNOWN_ERROR ) ; } | determines if the risen error is of type Exception . |
20 | public function getDocument ( $ id , $ indexName , $ typeName = '' ) { $ index = $ this -> getIndex ( $ indexName ) ; $ type = $ index -> getType ( empty ( $ typeName ) ? $ this -> typeName : $ typeName ) ; $ data = $ this -> decorator -> denormalizeValue ( array ( $ id => $ type -> getDocument ( $ id ) -> getData ( ) ... | Fetches the requested document from the index . |
21 | public function getDocuments ( $ index , $ limit = 10 ) { Assertion :: isInstanceOf ( $ index , '\Elastica\Index' , 'The given index must be of type \Elastica\Index !' ) ; if ( empty ( $ limit ) ) { $ limit = self :: ALL_DOCUMENTS ; } $ search = new Search ( $ index -> getClient ( ) ) ; $ search -> addIndex ( $ index )... | Provides a list of all documents of the given index . |
22 | protected function extractData ( array $ data ) { $ converted = array ( ) ; foreach ( $ data as $ value ) { if ( $ value instanceof Result ) { $ converted [ $ value -> getId ( ) ] = $ value -> getData ( ) ; } } return $ converted ; } | Extracts information from a nested result set . |
23 | public function deleteIndex ( $ name ) { $ client = $ this -> getClient ( ) ; $ index = $ client -> getIndex ( $ name ) ; $ index -> close ( ) ; $ index -> delete ( ) ; } | Deletes the named index from the cluster . |
24 | public function deleteType ( $ indexName , $ typeName ) { $ client = $ this -> getClient ( ) ; $ index = $ client -> getIndex ( $ indexName ) ; $ type = $ index -> getType ( $ typeName ) ; return $ type -> delete ( ) ; } | Deletes the named type from a named index from the cluster . |
25 | public function getTypeCount ( $ indexName , $ typeName , $ query = '' ) { $ index = $ this -> getIndex ( $ indexName ) ; $ type = $ index -> getType ( $ typeName ) ; return $ type -> count ( $ query ) ; } | Does a count query on given type and index . |
26 | public function getTypeMapping ( $ indexName , $ typeName ) { $ index = $ this -> getIndex ( $ indexName ) ; $ type = $ index -> getType ( $ typeName ) ; return $ type -> getMapping ( ) ; } | Returns current mapping for the given type and index . |
27 | public function render ( \ Throwable $ e ) { list ( $ file , $ line ) = Util :: caller ( 0 ) ; $ title = 'CharcoalPHP: Exception List' ; if ( $ this -> clear_buffer ) { ob_clean ( ) ; } echo $ this -> _output ( $ e , $ title , $ file , $ line ) ; } | Render debug trace |
28 | public function getVideoFeed ( $ location = null ) { if ( $ location == null ) { $ uri = self :: VIDEO_URI ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( $ this -> getMajorProtocolVersion ( ) ) ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata... | Retrieves a feed of videos . |
29 | public function getVideoEntry ( $ videoId = null , $ location = null , $ fullEntry = false ) { if ( $ videoId !== null ) { if ( $ fullEntry ) { return $ this -> getFullVideoEntry ( $ videoId ) ; } else { $ uri = self :: VIDEO_URI . "/" . $ videoId ; } } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ loc... | Retrieves a specific video entry . |
30 | public function getFullVideoEntry ( $ videoId ) { $ uri = self :: USER_URI . "/default/" . self :: UPLOADS_URI_SUFFIX . "/$videoId" ; return parent :: getEntry ( $ uri , 'Zend_Gdata_YouTube_VideoEntry' ) ; } | Retrieves a video entry from the user s upload feed . |
31 | public function getMostViewedVideoFeed ( $ location = null ) { $ standardFeedUri = self :: STANDARD_MOST_VIEWED_URI ; if ( $ this -> getMajorProtocolVersion ( ) == 2 ) { $ standardFeedUri = self :: STANDARD_MOST_VIEWED_URI_V2 ; } if ( $ location == null ) { $ uri = $ standardFeedUri ; } else if ( $ location instanceof ... | Retrieves a feed of the most viewed videos . |
32 | public function getRecentlyFeaturedVideoFeed ( $ location = null ) { $ standardFeedUri = self :: STANDARD_RECENTLY_FEATURED_URI ; if ( $ this -> getMajorProtocolVersion ( ) == 2 ) { $ standardFeedUri = self :: STANDARD_RECENTLY_FEATURED_URI_V2 ; } if ( $ location == null ) { $ uri = $ standardFeedUri ; } else if ( $ lo... | Retrieves a feed of recently featured videos . |
33 | public function getPlaylistListFeed ( $ user = null , $ location = null ) { if ( $ user !== null ) { $ uri = self :: USER_URI . '/' . $ user . '/playlists' ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( $ this -> getMajorProtocolVersion ( ) ) ; } else { $ uri = $ location ;... | Retrieves a feed which lists a user s playlist |
34 | public function getPlaylistVideoFeed ( $ location ) { if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( $ this -> getMajorProtocolVersion ( ) ) ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_YouTube_PlaylistVideoFeed' ) ; } | Retrieves a feed of videos in a particular playlist |
35 | public function getUserProfile ( $ user = null , $ location = null ) { if ( $ user !== null ) { $ uri = self :: USER_URI . '/' . $ user ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( $ this -> getMajorProtocolVersion ( ) ) ; } else { $ uri = $ location ; } return parent :: ... | Retrieves a user s profile as an entry |
36 | public static function parseFormUploadTokenResponse ( $ response ) { @ ini_set ( 'track_errors' , 1 ) ; $ doc = new DOMDocument ( ) ; $ doc = @ Zend_Xml_Security :: scan ( $ response , $ doc ) ; @ ini_restore ( 'track_errors' ) ; if ( ! $ doc ) { require_once 'Zend/Gdata/App/Exception.php' ; throw new Zend_Gdata_App_Ex... | Helper function for parsing a YouTube token response |
37 | public function getFormUploadToken ( $ videoEntry , $ url = 'https://gdata.youtube.com/action/GetUploadToken' ) { if ( $ url != null && is_string ( $ url ) ) { $ response = $ this -> post ( $ videoEntry , $ url ) ; return self :: parseFormUploadTokenResponse ( $ response -> getBody ( ) ) ; } else { require_once 'Zend/G... | Retrieves a YouTube token |
38 | public function getActivityForUser ( $ username ) { if ( $ this -> getMajorProtocolVersion ( ) == 1 ) { require_once 'Zend/Gdata/App/VersionException.php' ; throw new Zend_Gdata_App_VersionException ( 'User activity feeds ' . 'are not available in API version 1.' ) ; } $ uri = null ; if ( $ username instanceof Zend_Gda... | Retrieves the activity feed for users |
39 | public function sendVideoMessage ( $ body , $ videoEntry = null , $ videoId = null , $ recipientUserName ) { if ( ! $ videoId && ! $ videoEntry ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Expecting either a valid videoID or a videoEntry object in... | Send a video message . |
40 | public function replyToCommentEntry ( $ commentEntry , $ commentText ) { $ newComment = $ this -> newCommentEntry ( ) ; $ newComment -> content = $ this -> newContent ( ) -> setText ( $ commentText ) ; $ commentId = $ commentEntry -> getId ( ) ; $ commentIdArray = explode ( ':' , $ commentId ) ; $ inReplyToLinkHref = s... | Post a comment in reply to an existing comment |
41 | protected function signRequest ( HttpRequest $ request , $ username , $ timestamp , $ secretKey ) { $ message = $ username . $ timestamp . $ this -> getRequestMessage ( $ request ) ; return $ this -> algorithm -> sign ( $ message , $ secretKey ) ; } | Create request signature |
42 | public function regenerate ( ) { $ this -> guid = self :: make ( $ this -> lowerCase , $ this -> wrap ) ; return $ this ; } | Regenerated Guid value |
43 | public static function make ( $ lowerCase = true , $ wrap = false ) { $ charid = strtoupper ( md5 ( uniqid ( rand ( ) , true ) ) ) ; $ hyphen = chr ( 45 ) ; $ uuid = ( $ wrap ? "{" : "" ) . substr ( $ charid , 0 , 8 ) . $ hyphen . substr ( $ charid , 8 , 4 ) . $ hyphen . substr ( $ charid , 12 , 4 ) . $ hyphen . substr... | Generates guid string |
44 | public function getElapsedTime ( $ format = false ) { $ elapsed = microtime ( true ) - $ this -> startTime ; if ( $ format && $ elapsed >= 1 ) { $ elapsed = gmdate ( "H:i:s" , $ elapsed ) ; } return $ elapsed ; } | Gets the total time elapsed since the timer started . |
45 | public function setOptions ( array $ options ) { foreach ( $ options as $ index => $ val ) { if ( property_exists ( $ this , $ index ) ) { $ this -> { $ index } = $ val ; } } return $ this ; } | Set the object options like property = > value |
46 | protected function _buildClassesNames ( $ names , array $ masks ) { if ( ! is_array ( $ names ) ) { $ names = array ( $ names ) ; } $ return_names = array ( ) ; foreach ( $ names as $ _name ) { foreach ( $ masks as $ _mask ) { $ return_names [ ] = sprintf ( $ _mask , TextHelper :: toCamelCase ( $ _name ) ) ; } } return... | Build the class name filling a set of masks |
47 | protected function _addNamespaces ( $ names , array $ namespaces , array & $ logs = array ( ) ) { if ( ! is_array ( $ names ) ) { $ names = array ( $ names ) ; } $ return_names = array ( ) ; foreach ( $ names as $ _name ) { foreach ( $ namespaces as $ _namespace ) { if ( CodeHelper :: namespaceExists ( $ _namespace ) )... | Add a set of namespaces to a list of class names |
48 | protected function _classesImplements ( $ names , array $ interfaces , $ must_implement_all = false , array & $ logs = array ( ) ) { if ( ! is_array ( $ names ) ) { $ names = array ( $ names ) ; } $ ok = false ; foreach ( $ names as $ _name ) { foreach ( $ interfaces as $ _interface ) { if ( interface_exists ( $ _inter... | Test if a set of class names implements a list of interfaces |
49 | protected function _classesExtends ( $ names , array $ classes , array & $ logs = array ( ) ) { if ( ! is_array ( $ names ) ) { $ names = array ( $ names ) ; } foreach ( $ names as $ _name ) { foreach ( $ classes as $ _class ) { if ( class_exists ( $ _class ) ) { if ( CodeHelper :: extendsClass ( $ _name , $ _class ) )... | Test if a set of class names extends a list of classes |
50 | protected function _classesInNamespaces ( $ names , array $ namespaces , array & $ logs = array ( ) ) { if ( ! is_array ( $ names ) ) { $ names = array ( $ names ) ; } foreach ( $ names as $ _name ) { foreach ( $ namespaces as $ _namespace ) { if ( CodeHelper :: namespaceExists ( $ _namespace ) ) { $ tmp_namespace = rt... | Test if a classes names set is in a set of namespaces |
51 | public function get ( $ section , $ key ) { if ( ! isset ( $ this -> configValues [ $ section ] [ $ key ] ) ) { return false ; } return $ this -> configValues [ $ section ] [ $ key ] ; } | Haalt een config waarde op . False als deze niet ingesteld is . |
52 | public function getSection ( $ section ) { if ( ! isset ( $ this -> configValues [ $ section ] ) ) { return null ; } return $ this -> configValues [ $ section ] ; } | Return a config section |
53 | public function updateCMSFields ( FieldList $ fields ) { $ kapostRefID = $ this -> owner -> KapostRefID ; if ( ! empty ( $ kapostRefID ) ) { if ( CMSPageEditController :: has_extension ( 'KapostPageEditControllerExtension' ) ) { $ messageContent = _t ( 'KapostSiteTreeExtension.KAPOST_CONTENT_WARNING_RO' , '_This Page\'... | Updates the CMS fields adding the fields defined in this extension |
54 | public function select ( ) { $ this -> stmt [ 'action' ] = 'SELECT' ; if ( func_num_args ( ) !== 0 ) $ this -> stmt [ 'cols' ] = array_unique ( array_merge ( $ this -> stmt [ 'cols' ] , $ this -> buildArrayOfArgs ( func_get_args ( ) ) ) ) ; return $ this ; } | Specifies the number of database table columns to run select on . Accepts several args at once or can be called multiple times for appending field names . Can be chained with other calls . |
55 | public function order ( ) { $ this -> stmt [ 'order' ] = array_unique ( array_merge ( $ this -> stmt [ 'order' ] , $ this -> buildArrayOfArgs ( func_get_args ( ) ) ) ) ; return $ this ; } | Specifies the field to order by . Accepts several args at once or can be called multiple times for appending field names . Can be chained with other calls . |
56 | public function group ( ) { $ this -> stmt [ 'group' ] = array_unique ( array_merge ( $ this -> stmt [ 'group' ] , $ this -> buildArrayOfArgs ( func_get_args ( ) ) ) ) ; return $ this ; } | Specifies the field to group by . Accepts several args at once or can be called multiple times for appending field names . Can be chained with other calls . |
57 | public function insert ( $ data ) { $ this -> stmt [ 'action' ] = 'INSERT' ; $ this -> stmt [ 'cols' ] = array_merge ( $ this -> stmt [ 'cols' ] , $ data ) ; return $ this ; } | Specifies columns and their values to be inserted into a database . Can be chained with other calls . |
58 | public function update ( $ data ) { $ this -> stmt [ 'action' ] = 'UPDATE' ; $ this -> stmt [ 'cols' ] = array_merge ( $ this -> stmt [ 'cols' ] , $ data ) ; return $ this ; } | Specifies columns and their values to be updated into a database . Can be chained with other calls . |
59 | private function get_content ( ) { $ input_char = '' ; $ content = array ( ) ; $ space = false ; while ( isset ( $ this -> input [ $ this -> pos ] ) && $ this -> input [ $ this -> pos ] !== '<' ) { if ( $ this -> pos >= $ this -> input_length ) { return count ( $ content ) ? implode ( '' , $ content ) : array ( '' , 'T... | function to capture regular content between tags |
60 | private function get_contents_to ( $ name ) { if ( $ this -> pos === $ this -> input_length ) { return array ( '' , 'TK_EOF' ) ; } $ input_char = '' ; $ content = '' ; $ reg_array = array ( ) ; preg_match ( '#</' . preg_quote ( $ name , '#' ) . '\\s*>#im' , $ this -> input , $ reg_array , PREG_OFFSET_CAPTURE , $ this -... | get the full content of a script or style to pass to js_beautify |
61 | private function record_tag ( $ tag ) { if ( isset ( $ this -> tags [ $ tag . 'count' ] ) ) { $ this -> tags [ $ tag . 'count' ] ++ ; $ this -> tags [ $ tag . $ this -> tags [ $ tag . 'count' ] ] = $ this -> indent_level ; } else { $ this -> tags [ $ tag . 'count' ] = 1 ; $ this -> tags [ $ tag . $ this -> tags [ $ tag... | function to record a tag and its parent in this . tags Object |
62 | private function retrieve_tag ( $ tag ) { if ( isset ( $ this -> tags [ $ tag . 'count' ] ) ) { $ temp_parent = $ this -> tags [ 'parent' ] ; while ( $ temp_parent ) { if ( $ tag . $ this -> tags [ $ tag . 'count' ] === $ temp_parent ) { break ; } $ temp_parent = isset ( $ this -> tags [ $ temp_parent . 'parent' ] ) ? ... | function to retrieve the opening tag to the corresponding closer |
63 | private function get_comment ( $ start_pos ) { $ comment = '' ; $ delimiter = '>' ; $ matched = false ; $ this -> pos = $ start_pos ; $ input_char = $ this -> input [ $ this -> pos ] ; $ this -> pos ++ ; while ( $ this -> pos <= $ this -> input_length ) { $ comment .= $ input_char ; if ( $ comment [ strlen ( $ comment ... | function to return comment content in its entirety |
64 | private function get_unformatted ( $ delimiter , $ orig_tag = false ) { if ( $ orig_tag && strpos ( strtolower ( $ orig_tag ) , $ delimiter ) !== false ) { return '' ; } $ input_char = '' ; $ content = '' ; $ min_index = 0 ; $ space = true ; do { if ( $ this -> pos >= $ this -> input_length ) { return $ content ; } $ i... | function to return unformatted content in its entirety |
65 | private function get_token ( ) { if ( $ this -> last_token === 'TK_TAG_SCRIPT' || $ this -> last_token === 'TK_TAG_STYLE' ) { $ type = substr ( $ this -> last_token , 7 ) ; $ token = $ this -> get_contents_to ( $ type ) ; if ( ! is_string ( $ token ) ) { return $ token ; } return array ( $ token , 'TK_' . $ type ) ; } ... | initial handler for token - retrieval |
66 | protected function getMailer ( ) { $ transport = null ; if ( $ this -> configurationManager -> getSetting ( 'mailer.type' ) === 'sendmail' ) { $ transport = \ Swift_SendmailTransport :: newInstance ( $ this -> configurationManager -> getSetting ( 'mailer.sendmailCommand' ) ) ; } else if ( $ this -> configurationManager... | Returns the mailer object |
67 | public function sendMail ( $ recipient , $ subject , $ htmlBody , $ textBody = false ) { $ message = \ Swift_Message :: newInstance ( ) ; $ message -> setSubject ( $ subject ) ; $ fromEmail = $ this -> configurationManager -> getSetting ( 'mailer.sendFrom' ) ; $ fromName = $ this -> configurationManager -> getSetting (... | Sends a email |
68 | public static function setBaseUrl ( string $ url = "" ) : string { if ( $ url === "" || $ url === null ) { if ( self :: $ _baseUrl === "" ) throw new \ Exception ( "[MVQN\REST\ResClient] " . "'baseUrl' must be set by RestClient::baseUrl() before calling any RestClient methods!" ) ; } else { self :: $ _baseUrl = $ url ;... | Gets or sets the base URL to be used with all REST calls . |
69 | private static function curl ( string $ endpoint ) { $ baseUrl = self :: $ _baseUrl ; $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ baseUrl . $ endpoint ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_SSL_VER... | Creates a cURL session with the necessary options headers and endpoint to communicate with the UCRM Server . |
70 | public static function get ( string $ endpoint ) : array { $ curl = self :: curl ( $ endpoint ) ; $ response = curl_exec ( $ curl ) ; if ( ! $ response ) throw new \ Exception ( "[MVQN\REST\ResClient] The REST request failed with the following error(s): " . curl_error ( $ curl ) ) ; curl_close ( $ curl ) ; return json_... | Sends a HTTP GET Request to the specified endpoint of the base URL . |
71 | public static function post ( string $ endpoint , array $ data ) : array { $ curl = self :: curl ( $ endpoint ) ; curl_setopt ( $ curl , CURLOPT_POST , true ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , json_encode ( $ data , self :: JSON_OPTIONS ) ) ; $ response = curl_exec ( $ curl ) ; if ( ! $ response ) throw new... | Sends a HTTP POST Requests to the specified endpoint of the base URL . |
72 | public function itemsFilter ( $ params ) { if ( DEBUG_LOG_BITEMS ) { BLog :: addToLog ( '[BItems.' . $ this -> tableName . '] itemsFilter(' . var_export ( $ params , true ) . ')' ) ; } $ ids = $ this -> itemsFilterIds ( $ params ) ; if ( DEBUG_LOG_BITEMS ) { BLog :: addToLog ( '[BItems.' . $ this -> tableName . '] item... | Get Items by params |
73 | public function itemsFilterFirst ( $ params ) { $ params2 = $ params ; $ params2 [ 'limit' ] = 1 ; $ list = $ this -> itemsFilter ( $ params2 ) ; if ( empty ( $ list ) ) { return NULL ; } $ item = reset ( $ list ) ; return $ item ; } | Get First Item by params |
74 | public function itemsFilterSql ( $ params , & $ wh , & $ jn ) { $ wh = array ( ) ; $ jn = array ( ) ; if ( isset ( $ params [ 'exclude' ] ) && ( is_array ( $ params [ 'exclude' ] ) ) ) { $ wh [ ] = '(`' . $ this -> primaryKeyName . '` not in (' . implode ( ',' , $ params [ 'exclude' ] ) . '))' ; } return true ; } | Get items filter |
75 | public function itemsFilterHash ( $ params ) { $ itemshash = $ this -> tableName . ':list' ; if ( isset ( $ params [ 'exclude' ] ) && ( is_array ( $ params [ 'exclude' ] ) ) ) { $ itemshash .= ':exclude-' . implode ( '-' , $ params [ 'exclude' ] ) ; } if ( isset ( $ params [ 'orderby' ] ) && ( is_array ( $ params [ 'or... | Items list cache hash . |
76 | public function itemsDelete ( $ ids ) { $ db = BFactory :: getDBO ( ) ; if ( empty ( $ db ) ) { return false ; } $ qr = 'DELETE FROM `' . $ this -> tableName . '` WHERE (`' . $ this -> primaryKeyName . '` in (' . implode ( ',' , $ ids ) . '))' ; $ q = $ db -> Query ( $ qr ) ; if ( empty ( $ q ) ) { return false ; } ret... | Delete item from database |
77 | public function hitItem ( $ id ) { if ( empty ( $ this -> hitsKey ) ) { return false ; } $ db = BFactory :: getDBO ( ) ; if ( empty ( $ db ) ) { return false ; } $ qr = 'UPDATE `' . $ this -> tableName . '` SET `hits`=`hits`+1 WHERE (`' . $ this -> primaryKeyName . '`=' . $ id . ')' ; $ q = $ db -> Query ( $ qr ) ; if ... | Hit the item . |
78 | public function truncateAll ( ) { $ qr = 'truncate `' . $ this -> tableName . '`' ; $ db = BFactory :: getDBO ( ) ; if ( empty ( $ db ) ) { return false ; } $ q = $ db -> Query ( $ qr ) ; if ( empty ( $ q ) ) { return false ; } return true ; } | Delete all data in table . |
79 | public static function cygpath ( $ path ) { $ path = parent :: normalizePath ( $ path , '/' ) ; $ path = preg_replace ( '|^([a-z]):/|i' , '/cygdrive/$1/' , $ path , 1 ) ; return $ path ; } | Convert path into Cygwin - like style . |
80 | public function get ( $ conditions = [ ] , $ order_by = '' ) { if ( is_scalar ( $ conditions ) ) $ conditions = [ 'id' => $ conditions ] ; $ where = $ this -> _createWhere ( $ conditions ) ; $ order_by = $ this -> _createOrderBy ( $ order_by ) ; $ conditions = ! empty ( $ where ) ? array_values ( $ conditions ) : [ ] ;... | Retrieves data from the database . |
81 | public function delete ( $ conditions ) { if ( is_scalar ( $ conditions ) ) $ conditions = [ 'id' => $ conditions ] ; $ where = $ this -> _createWhere ( $ conditions ) ; return $ this -> _db -> delete ( $ this -> _table , "{$where}" , array_values ( $ conditions ) ) ; } | Deletes a table row in the database . |
82 | protected function _createWhere ( array $ conditions ) { $ where = [ ] ; foreach ( $ conditions as $ field => $ value ) { $ where [ ] = $ field . '=?' ; } $ where = implode ( ' AND ' , $ where ) ; if ( ! empty ( $ where ) ) $ where = 'WHERE ' . $ where ; return $ where ; } | Creates a where string of conditions to use in a SQL query . |
83 | protected function loadEntity ( $ key ) { $ content = $ this -> getFileManager ( ) -> read ( $ key ) ; if ( $ content ) { return unserialize ( $ content ) ; } return null ; } | Load an entity by key |
84 | protected function persist ( $ object ) { if ( ! $ object -> getId ( ) ) { $ object -> setId ( $ this -> getNextId ( ) ) ; } $ key = $ this -> getHash ( ) . $ object -> getId ( ) ; $ content = serialize ( $ object ) ; $ this -> getFileManager ( ) -> write ( $ key , $ content , true ) ; } | Save an object entity |
85 | protected function getNextId ( ) { $ keys = $ this -> getFileManager ( ) -> keys ( ) ; $ ids = array ( ) ; foreach ( $ keys as $ key ) { if ( preg_match ( '/^' . $ this -> getHash ( ) . '/' , $ key ) ) { $ ids [ ] = str_replace ( $ this -> getHash ( ) , '' , $ key ) ; } } if ( empty ( $ ids ) ) { return 1 ; } $ maxId =... | Get next ID for an object class |
86 | public function GetID ( $ MessageID ) { if ( Gdn :: Cache ( ) -> ActiveEnabled ( ) ) return self :: Messages ( $ MessageID ) ; else return parent :: GetID ( $ MessageID ) ; } | Returns a single message object for the specified id or FALSE if not found . |
87 | public function DefineLocation ( $ Message ) { $ Controller = GetValue ( 'Controller' , $ Message ) ; $ Application = GetValue ( 'Application' , $ Message ) ; $ Method = GetValue ( 'Method' , $ Message ) ; if ( in_array ( $ Controller , $ this -> _SpecialLocations ) ) { SetValue ( 'Location' , $ Message , $ Controller ... | Build the Message s Location property and add it . |
88 | public function GetEnabledLocations ( ) { $ Data = $ this -> SQL -> Select ( 'Application,Controller,Method' ) -> From ( 'Message' ) -> Where ( 'Enabled' , '1' ) -> GroupBy ( 'Application,Controller,Method' ) -> Get ( ) ; $ Locations = array ( ) ; foreach ( $ Data as $ Row ) { if ( in_array ( $ Row -> Controller , $ th... | Returns a distinct array of controllers that have enabled messages . |
89 | public function getMetaTags ( $ model ) { $ lang = Yii :: $ app -> language ; if ( Yii :: $ app -> id === 'app-backend' ) { $ lang = Yii :: $ app -> wavecms -> editedLanguage ; } return $ this -> andWhere ( [ 'model' => $ model , 'language' => $ lang ] ) ; } | Return array of meta tags |
90 | public function getAssetUrl ( $ raw = false ) { if ( $ this -> assetUrl === null ) { $ this -> assetUrl = Yii :: $ app -> assetManager -> publish ( $ this -> getBasePath ( ) . '/' . $ this -> distDir ) ; } return $ raw ? $ this -> assetUrl : $ this -> assetUrl [ 1 ] ; } | Get path to assets of theme . |
91 | protected function quote ( $ value ) { if ( is_string ( $ value ) || is_int ( $ value ) ) { $ escaped = $ this -> connector -> escape ( $ value ) ; return "'{$escaped}'" ; } elseif ( is_array ( $ value ) ) { $ buffer = array ( ) ; foreach ( $ value as $ i ) { array_push ( $ buffer , $ this -> quote ( $ i ) ) ; $ buffer... | This method quotes input data according to how MySQL woudl expect it . |
92 | public function setTable ( $ table ) { try { if ( empty ( $ table ) ) { throw new MySQLException ( "Invalid argument passed for table name" , 1 ) ; } } catch ( MySQLException $ MySQLExceptionObject ) { $ MySQLExceptionObject -> errorShow ( ) ; } $ this -> froms = $ table ; if ( ! isset ( $ this -> fields [ $ table ] ) ... | This method sets the table name to be selected |
93 | public function setFields ( $ table , $ fields = array ( "*" ) ) { try { if ( empty ( $ table ) ) { throw new MySQLException ( "Invalid argument passed for table name" , 1 ) ; } } catch ( MySQLException $ MySQLExceptionObject ) { $ MySQLExceptionObject -> errorShow ( ) ; } $ this -> froms = $ table ; $ this -> fields [... | This method sets the columns for a table to be selected |
94 | public function leftJoin ( $ table , $ condition , $ fields = array ( "*" ) ) { try { if ( empty ( $ table ) ) { throw new MySQLException ( "Invalid table argument $table passed for the leftJoin Clause" , 1 ) ; } if ( empty ( $ condition ) ) { throw new MySQLException ( "Invalid argument $condition passed for the leftJ... | This method builds query string for joining tables in query . |
95 | public function limit ( $ limit , $ page = 1 ) { try { if ( empty ( $ limit ) ) { throw new MySQLException ( "Empty argument passed for $limit in method limit()" , 1 ) ; } } catch ( MySQLException $ MySQLExceptionObject ) { $ MySQLExceptionObject -> errorShow ( ) ; } $ this -> limits = $ limit ; $ this -> offset = ( in... | This method sets the limit for the number of rows to return . |
96 | public function order ( $ order , $ direction = 'asc' ) { try { if ( empty ( $ order ) ) { throw new MySQLException ( "Empty value passed for parameter $order in order() method" , 1 ) ; } } catch ( MySQLException $ MySQLExceptionObject ) { $ MySQLExceptionObject -> errorShow ( ) ; } $ this -> orders = $ order ; $ this ... | This method sets the order in which to sort the query results . |
97 | public function where ( $ arguments ) { try { if ( is_float ( sizeof ( $ arguments ) / 2 ) ) { throw new MySQLException ( "No arguments passed for the where clause" ) ; } } catch ( MySQLException $ MySQLExceptionObject ) { $ MySQLExceptionObject -> errorShow ( ) ; } if ( sizeof ( $ arguments ) == 2 ) { $ arguments [ 0 ... | This method defines the where parameters of the query string . |
98 | protected function buildSelect ( ) { $ fields = array ( ) ; $ where = $ order = $ limit = $ join = "" ; $ template = "SELECT %s %s FROM %s %s %s %s %s" ; foreach ( $ this -> fields as $ table => $ tableFields ) { foreach ( $ tableFields as $ field => $ alias ) { if ( is_string ( $ field ) && $ field != 'COUNT(1)' ) { $... | This method builds a select query string . |
99 | protected function buildInsert ( $ data , $ set_timestamps ) { $ fields = array ( ) ; $ values = array ( ) ; $ template = "INSERT INTO %s (%s) VALUES (%s)" ; if ( $ set_timestamps ) $ data [ 'date_created' ] = date ( 'Y-m-d h:i:s' ) ; foreach ( $ data as $ field => $ value ) { $ fields [ ] = $ field ; $ values [ ] = $ ... | This method builds the query string for inserting one row of records into the database . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.