idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
53,600
|
private function Error ( $ error ) { if ( $ this -> dev ) { $ this -> log [ ] = 'Error: ' . $ error ; } $ this -> errors [ ] = $ error ; }
|
Set an error
|
53,601
|
public function getErrors ( $ str = FALSE ) { $ errors = $ this -> errors ; $ this -> resetErrors ( ) ; if ( $ str ) { return implode ( '<br />' , $ errors ) ; } else { return $ errors ; } }
|
Return the errors
|
53,602
|
public static function Output ( $ status , $ msg , $ nl = TRUE , $ email = FALSE ) { $ status = strtoupper ( $ status ) ; if ( is_array ( $ msg ) || is_object ( $ msg ) ) { $ msg = Parser :: pre ( $ msg , 0 , TRUE , FALSE ) ; } echo '[' . date ( 'Y-m-d H:i:s' ) . '][' . $ status . '] ' . $ msg . ( $ nl ? "\n" : NULL ) ; if ( $ email ) { return static :: emailAdmin ( $ status , $ msg ) ; } return TRUE ; }
|
Output a log entry
|
53,603
|
protected function line ( $ text ) { if ( $ this -> console ) { $ this -> console -> line ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> line ( $ text ) ; } }
|
Shortcut method to line method
|
53,604
|
protected function info ( $ text ) { if ( $ this -> console ) { $ this -> console -> info ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> info ( $ text ) ; } }
|
Shortcut method to add logging info
|
53,605
|
protected function comment ( $ text ) { if ( $ this -> console ) { $ this -> console -> comment ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> comment ( $ text ) ; } }
|
Shortcut method to comment method
|
53,606
|
protected function error ( $ text ) { if ( $ this -> console ) { $ this -> console -> error ( $ text ) ; } if ( $ this -> logger ) { $ this -> logger -> error ( $ text ) ; } }
|
Shortcut method to add logging error
|
53,607
|
protected function table ( $ headers , $ rows ) { if ( $ this -> console instanceof Command ) { $ this -> console -> table ( $ headers , $ rows ) ; } }
|
Output a table to the console
|
53,608
|
protected function progressBar ( $ count ) { if ( $ this -> console ) { return $ this -> console -> getOutput ( ) -> createProgressBar ( $ count ) ; } else { return new NullProgressBar ; } }
|
Create a progress bar
|
53,609
|
protected static function mustBeStringOrScalar ( $ arg , $ arg_name = null ) { if ( ! is_scalar ( $ arg ) && ! ( is_object ( $ arg ) && method_exists ( $ arg , '__toString' ) ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive scalar PHP type or object ' . 'having `__toString()` method' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is string - like or scalar type .
|
53,610
|
protected static function mustBeString ( $ arg , $ arg_name = null ) { if ( ! is_string ( $ arg ) && ! ( is_object ( $ arg ) && method_exists ( $ arg , '__toString' ) ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive string PHP type or object ' . 'having `__toString()` method' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is string - like type .
|
53,611
|
protected static function mustBeInteger ( $ arg , $ arg_name = null ) { if ( ! is_integer ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive integer PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } if ( is_object ( $ arg ) && ! $ arg -> decimal -> zero ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be an object \Malenki\Bah\N containing integer value' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is integer - like type .
|
53,612
|
protected static function mustBeFloat ( $ arg , $ arg_name = null ) { if ( ! is_float ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive float PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is float - like type .
|
53,613
|
protected static function mustBeDouble ( $ arg , $ arg_name = null ) { if ( ! is_double ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive double PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is double - like type .
|
53,614
|
protected static function mustBeNumeric ( $ arg , $ arg_name = null ) { if ( ! is_numeric ( $ arg ) && ! ( $ arg instanceof N ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be a primitive numeric PHP type or ' . 'object \Malenki\Bah\N' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether given value is numeric - like type .
|
53,615
|
protected static function mustBeArray ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive integer indexed array PHP type or ' . 'object \Malenki\Bah\A' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $ arg instanceof A ) ) { throw new \ InvalidArgumentException ( $ msg ) ; } if ( is_array ( $ arg ) ) { foreach ( array_keys ( $ arg ) as $ ak ) { if ( ! is_integer ( $ ak ) ) { throw new \ InvalidArgumentException ( $ msg ) ; } } } }
|
Checks whether given value is an array - like type .
|
53,616
|
protected static function mustBeHash ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive named indexed array PHP type or ' . 'object \Malenki\Bah\H' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $ arg instanceof H ) ) { throw new \ InvalidArgumentException ( $ msg ) ; } if ( is_array ( $ arg ) ) { foreach ( array_keys ( $ arg ) as $ ak ) { if ( ! is_string ( $ ak ) ) { throw new \ InvalidArgumentException ( $ msg ) ; } } } }
|
Checks whether given value is a hash - like type .
|
53,617
|
protected static function mustBeArrayOrHash ( $ arg , $ arg_name = null ) { $ msg = sprintf ( '%s must be a primitive named indexed array PHP type or ' . '\Malenki\Bah\A or \Malenki\Bah\H or \SplFixedArray ' . ' or \ArrayIterator' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ; if ( ! is_array ( $ arg ) && ! ( $ arg instanceof H ) && ! ( $ arg instanceof A ) && ! ( $ arg instanceof \ SplFixedArray ) && ! ( $ arg instanceof \ ArrayIterator ) ) { throw new \ InvalidArgumentException ( $ msg ) ; } }
|
Checks whether given value is an array - like or hash - like type .
|
53,618
|
protected static function mustBeCallable ( $ arg , $ arg_name = null ) { if ( ! is_callable ( $ arg ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s must be callable!' , is_null ( $ arg_name ) ? 'Argument' : $ arg_name ) ) ; } }
|
Checks whether the given argument is callable .
|
53,619
|
public function view ( $ viewPath ) { if ( is_a ( $ viewPath , ViewInterface :: class ) ) { $ this -> view_path = $ viewPath ; return $ this ; } elseif ( is_string ( $ viewPath ) ) { $ this -> view_path = $ this -> findView ( $ viewPath ) ; if ( isset ( $ this -> parent ) && $ this -> view_path === false ) { return $ this -> parent -> view ( $ viewPath ) ; } else { parent :: view ( $ this -> view_path ) ; return $ this ; } } }
|
Set current view for rendering .
|
53,620
|
public function createSlug ( $ data , array $ unique = array ( ) ) { $ slug = sanitize_title ( $ data ) ; $ next = 1 ; while ( in_array ( $ slug , $ unique ) ) { $ slug = sanitize_title ( $ data . ' ' . $ next ++ ) ; } return $ slug ; }
|
Generate a slug from the given field .
|
53,621
|
public function getDatabases ( ) { if ( $ this -> databases === FALSE ) { if ( isset ( \ Sonic \ Sonic :: $ resources [ 'db' ] ) ) { foreach ( \ Sonic \ Sonic :: $ resources [ 'db' ] as $ key => $ db ) { $ this -> databases [ $ key ] = $ db -> getDatabaseName ( ) ; } } } return $ this -> databases ; }
|
Return an array of databases
|
53,622
|
public function getTables ( $ db ) { if ( ! isset ( $ this -> tables [ $ db ] ) ) { $ query = $ this -> db -> query ( 'SHOW TABLES FROM ' . $ db ) ; $ query -> setFetchMode ( \ PDO :: FETCH_COLUMN , 0 ) ; $ this -> tables [ $ db ] = $ query -> fetchAll ( ) ; } return $ this -> tables [ $ db ] ; }
|
Return an array of database tables
|
53,623
|
public function getColumns ( $ db , $ table ) { if ( ! isset ( $ this -> columns [ $ db ] [ $ table ] ) ) { $ this -> columns [ $ db ] [ $ table ] = $ this -> db -> query ( 'SHOW COLUMNS FROM ' . $ db . '.' . $ table ) -> fetchAll ( \ PDO :: FETCH_NUM ) ; } return $ this -> columns [ $ db ] [ $ table ] ; }
|
Return an array of table columns
|
53,624
|
public function getRelations ( $ db , $ table ) { if ( ! isset ( $ this -> relations [ $ db ] [ $ table ] ) ) { $ this -> relations [ $ db ] [ $ table ] = array ( ) ; $ query = $ this -> db -> query ( 'SHOW CREATE TABLE ' . $ db . '.' . $ table ) ; $ sql = $ query -> fetchColumn ( 1 ) ; foreach ( explode ( "\n" , $ sql ) as $ line ) { $ line = trim ( $ line ) ; if ( strpos ( $ line , 'CONSTRAINT' ) === 0 ) { $ pattern = array ( ) ; preg_match ( '/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/' , $ line , $ pattern ) ; $ this -> relations [ $ db ] [ $ table ] [ ] = array ( 'attribute' => $ pattern [ 1 ] , 'table' => $ pattern [ 2 ] , 'column' => $ pattern [ 3 ] ) ; } } } return $ this -> relations [ $ db ] [ $ table ] ; }
|
Return an array of foreign key constraints columns
|
53,625
|
public static function mergeQuery ( $ url , array $ query ) { if ( ! $ query ) { return $ url ; } $ queryString = http_build_query ( $ query ) ; $ qPos = strpos ( $ url , '?' ) ; $ hashPos = strpos ( $ url , '#' ) ; $ pos = strlen ( $ url ) ; $ hasQuery = $ qPos !== false && ( $ qPos < $ hashPos || $ hashPos === false ) ; if ( $ qPos || $ hashPos ) { $ pos = $ hasQuery ? $ qPos + 1 : $ hashPos ; } $ prefix = substr ( $ url , 0 , $ pos ) ; $ suffix = substr ( $ url , $ pos ) ; return sprintf ( '%s%s%s%s%s' , $ prefix , $ hasQuery ? '' : '?' , $ queryString , $ hasQuery ? '&' : '' , $ suffix ) ; }
|
Merges the specified query into the specified URL which may or may not already contain a query component .
|
53,626
|
protected function templateToString ( $ template , array $ data ) { $ templateFullName = $ this -> getTemplateFullName ( $ template ) ; if ( ! is_file ( $ templateFullName ) ) { throw new RuntimeException ( "View cannot render `$template` because the template does not exist" ) ; } $ fullData = array_merge ( $ this -> attributes , $ data ) ; $ this -> levelStartObcache = ob_get_level ( ) ; $ this -> startSection ( $ this -> courentSection ) ; $ this -> protectedIncludeScope ( $ templateFullName , $ fullData ) ; $ output = $ this -> endSection ( true ) ; $ this -> sectionContent [ self :: CONTENT ] = $ this -> sectionContent [ self :: C_CONTENT ] ; unset ( $ this -> sectionContent [ self :: C_CONTENT ] ) ; while ( ob_get_level ( ) > $ this -> levelStartObcache ) { ob_end_clean ( ) ; } if ( ! empty ( $ this -> layout ) ) { $ layout = $ this -> layout ; $ this -> layout = '' ; return $ this -> templateToString ( $ layout , $ fullData ) ; } return $ output ; }
|
Retourne le rendu du template sous forme de chaine
|
53,627
|
public function setEmail ( $ email ) { $ this -> email = $ email ; $ this -> referenceId = null ; $ this -> executed = false ; return $ this ; }
|
Sets email of the user
|
53,628
|
public function setReferenceId ( $ referenceId ) { $ this -> referenceId = $ referenceId ; $ this -> email = null ; $ this -> executed = false ; return $ this ; }
|
Sets reference ID for deletion
|
53,629
|
public static function createInstance ( $ driver , $ options , $ prefix = '' ) { if ( ! in_array ( $ driver , self :: $ _validDrivers ) ) { throw new \ Exception ( "Driver '{$driver}' not implemented" ) ; } $ class = __NAMESPACE__ . '\\Driver\\' . $ driver ; $ driver = new $ class ; $ driver -> setOptions ( $ options ) -> setPrefix ( $ prefix ) ; return new Mcache ( $ driver ) ; }
|
Create new instance of G4 \ Mcache \ Mcache
|
53,630
|
public function setInherited ( $ inherited ) { $ this -> inherited = ( bool ) $ inherited ; if ( $ inherited ) { if ( ! $ this -> reflectionModel -> isRoot ( ) ) { $ rootRepo = Container :: get ( $ this -> reflectionModel -> getRoot ( ) -> getName ( ) ) ; $ this -> rootConfig = $ rootRepo -> getConfig ( ) ; } $ this -> table = $ this -> rootConfig -> getTable ( ) ; } return $ this ; }
|
Enables Repo inheritance allowing multiple repos to share one storage table You will need to call setRootRepo on all the child repos .
|
53,631
|
public function assertModel ( AbstractModel $ model ) { if ( ! $ this -> isModel ( $ model ) ) { throw new InvalidArgumentException ( sprintf ( 'Model must be instance of %s, but was %s' , $ this -> getRootConfig ( ) -> getModelClass ( ) , get_class ( $ model ) ) ) ; } }
|
Check if a model belongs to this repo . Child classes are also accepted
|
53,632
|
public function addHost ( Host $ host ) { if ( empty ( $ host ) ) return $ this ; $ this -> _host_list [ "{$host->name}:{$host->port}" ] = $ host ; return $ this ; }
|
adds a host to the hostlist
|
53,633
|
public function checkSocket ( $ socket ) { $ read = [ $ socket ] ; if ( count ( $ this -> client ) > 0 ) { for ( $ i = 0 ; $ i < $ this -> max_clients ; $ i ++ ) { if ( isset ( $ this -> client [ $ i ] ) && $ this -> client [ $ i ] [ 'sock' ] != null ) { $ read [ $ i + 1 ] = $ this -> client [ $ i ] [ 'sock' ] ; } } } return $ read ; }
|
adds the socket to listening sockets
|
53,634
|
public function checkClient ( ) { if ( in_array ( $ this -> _socket_http , $ this -> read ) ) { for ( $ i = 0 ; $ i < $ this -> max_clients ; $ i ++ ) { if ( isset ( $ this -> client [ $ i ] ) && $ this -> client [ $ i ] [ 'sock' ] == null ) { $ this -> client [ $ i ] [ 'sock' ] = @ socket_accept ( $ this -> _socket_http ) ; break ; } elseif ( $ i == $ this -> max_clients - 1 ) { } else { $ this -> client [ ] = [ 'sock' => @ socket_accept ( $ this -> _socket_http ) ] ; break ; } } if ( -- $ this -> ready <= 0 ) { return false ; } } return true ; }
|
checks if there are clients accessing the specific port of the socket
|
53,635
|
public function getError ( ) { for ( $ i = 0 , $ c = count ( $ this -> read ) ; $ i < $ c ; $ i ++ ) { if ( ! $ this -> read [ $ i ] ) continue ; $ this -> error [ ] = socket_last_error ( $ this -> read [ $ i ] [ 'sock' ] ) ; } }
|
gets error and appends them to the error array
|
53,636
|
public function start ( ) { $ this -> _socket_http = socket_create ( AF_INET , SOCK_STREAM , IPPROTO_IP ) ; if ( ! $ this -> _socket_http ) { throw new Exception ( "Unable to create socket\n" ) ; } if ( ! socket_bind ( $ this -> _socket_http , self :: SERVER_IP , self :: LISTENING_PORT ) ) { throw new Exception ( 'Could not bind address and port' ) ; } if ( ! socket_listen ( $ this -> _socket_http ) ) { throw new Exception ( 'Could not listen to main socket!' ) ; } while ( true ) { $ this -> read = $ this -> checkSocket ( $ this -> _socket_http ) ; $ this -> ready = socket_select ( $ this -> read , $ this -> write , $ this -> expect , null ) ; if ( $ this -> ready === false ) { $ this -> getError ( ) ; } if ( ! $ this -> checkClient ( ) || empty ( $ this -> client ) ) { continue ; } $ this -> execute ( ) ; } $ this -> close ( $ this -> _socket_http ) ; }
|
now we open an endless loop
|
53,637
|
public function execute ( ) { foreach ( $ this -> client as $ key => $ client ) { if ( ! in_array ( $ client [ 'sock' ] , $ this -> read ) ) { $ this -> close ( $ client [ 'sock' ] ) ; unset ( $ this -> client [ $ key ] ) ; } $ input = socket_read ( $ client [ 'sock' ] , 1024 ) ; if ( $ input == null ) { unset ( $ this -> client [ $ key ] ) ; } $ n = trim ( $ input ) ; switch ( true ) { case $ n === 'exit' : $ this -> close ( $ client [ 'sock' ] ) ; break ; default : socket_write ( $ client [ 'sock' ] , $ this -> getResponse ( $ input ) ) ; break ; } } }
|
here is where we handle the input and the types of input - > read and writes from the stream
|
53,638
|
public function init ( $ setting = array ( ) ) { if ( ! is_array ( $ setting ) || count ( $ setting ) == 0 ) return $ this ; foreach ( $ setting as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = ( string ) $ value ; } } return $ this ; }
|
initializes the server variables
|
53,639
|
public function format ( $ newFormat = null ) { if ( $ newFormat === null ) { return $ this -> format ; } $ this -> format = $ newFormat ; return $ this ; }
|
Format the date or return its format .
|
53,640
|
public function next ( ) { $ this -> pointerAtStart = false ; $ this -> pointerAtEnd = next ( $ this -> stream ) === false ; }
|
go to next char in stream
|
53,641
|
public function previous ( ) { $ this -> pointerAtEnd = false ; $ this -> pointerAtStart = prev ( $ this -> stream ) === false ; }
|
go to previous char of stream
|
53,642
|
public function ignoreWhitespace ( ) { ignoreWhitespace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isWhiteSpace ( ) ) { $ this -> next ( ) ; goto ignoreWhitespace ; } }
|
ignore chars in stream while it is white space
|
53,643
|
public function ignoreHorizontalSpace ( ) { ignoreHorizontalSpace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isHorizontalSpace ( ) ) { $ this -> next ( ) ; goto ignoreHorizontalSpace ; } }
|
ignore chars in stream while it is horizontal space
|
53,644
|
public function ignoreVerticalSpace ( ) { ignoreHorizontalSpace : if ( ! $ this -> isEnd ( ) && $ this -> currentAscii ( ) -> isVerticalSpace ( ) ) { $ this -> next ( ) ; goto ignoreHorizontalSpace ; } }
|
ignore chars in stream while it is vertical space
|
53,645
|
public static function parseURL ( array & $ args , $ leaveDefaultLocale = true ) { foreach ( self :: $ locales as $ locale ) { if ( ( $ key = array_search ( $ locale , $ args ) ) === 0 ) { self :: current ( $ locale ) ; if ( $ leaveDefaultLocale || $ locale != self :: DEF ) { unset ( $ args [ $ key ] ) ; $ args = array_values ( $ args ) ; } return true ; } } self :: current ( self :: DEF ) ; return false ; }
|
Parse URL arguments
|
53,646
|
public function optimize ( $ table = null ) { $ table = empty ( $ table ) ? $ this -> _tableName : $ table ; $ this -> _query ( "OPTIMIZE TABLE " . $ table ) ; return $ this ; }
|
Optimize table query
|
53,647
|
public function repair ( $ table = null ) { $ table = empty ( $ table ) ? $ this -> _tableName : $ table ; $ this -> _query ( "REPAIR TABLE " . $ table ) ; return $ this ; }
|
Repair table query
|
53,648
|
public function compile ( $ tplName , $ tplFile , $ outputtype , $ trusted , $ userModifiers = array ( ) , $ userFunctions = array ( ) ) { $ this -> _sourceFile = $ tplFile ; $ this -> outputType = $ outputtype ; $ cachefile = $ this -> config -> cachePath . dirname ( $ tplName ) . '/' . $ this -> outputType . ( $ trusted ? '_t' : '' ) . '_' . basename ( $ tplName ) ; $ this -> trusted = $ trusted ; $ md5 = md5 ( $ tplFile . '_' . $ this -> outputType . ( $ this -> trusted ? '_t' : '' ) ) ; if ( ! file_exists ( $ this -> _sourceFile ) ) { $ this -> doError0 ( 'errors.tpl.not.found' ) ; } $ this -> compileString ( file_get_contents ( $ this -> _sourceFile ) , $ cachefile , $ userModifiers , $ userFunctions , $ md5 ) ; return true ; }
|
Launch the compilation of a template .
|
53,649
|
public function presentPublishedDays ( ) { $ todaysDate = time ( ) ; $ postDate = strtotime ( $ this -> post_date ) ; $ diff = abs ( $ todaysDate - $ postDate ) ; $ years = floor ( $ diff / ( 365 * 60 * 60 * 24 ) ) ; $ months = floor ( ( $ diff - $ years * 365 * 60 * 60 * 24 ) / ( 30 * 60 * 60 * 24 ) ) ; $ days = floor ( ( $ diff - $ years * 365 * 60 * 60 * 24 - $ months * 30 * 60 * 60 * 24 ) / ( 60 * 60 * 24 ) ) ; return ( int ) $ days ; }
|
Return how many day was published
|
53,650
|
public function presentCategories ( ) { $ args = array ( 'fields' => 'all' , 'orderby' => 'name' , 'order' => 'ASC' ) ; $ categories = wp_get_post_categories ( $ this -> ID , $ args ) ; if ( count ( $ categories ) == 0 || ! $ categories ) { return null ; } $ cats = array ( ) ; foreach ( $ categories as $ c ) { $ c -> permalink = get_category_link ( $ c -> term_id ) ; $ cats [ ] = $ c ; } return Collection :: make ( $ cats ) ; }
|
Return an array of object with the categories of the post
|
53,651
|
public function presentTags ( ) { $ args = array ( 'fields' => 'all' , 'orderby' => 'name' , 'order' => 'ASC' ) ; $ tags = wp_get_post_tags ( $ this -> ID , $ args ) ; if ( count ( $ tags ) == 0 || ! $ tags ) { return null ; } $ postTags = array ( ) ; foreach ( $ tags as $ t ) { $ t -> permalink = get_tag_link ( $ t -> term_id ) ; $ postTags [ ] = $ t ; } return Collection :: make ( $ postTags ) ; }
|
Return an array of object with the tags of the post
|
53,652
|
public function terms ( $ taxonomy = 'post_tag' ) { $ postTerms = wp_get_post_terms ( $ this -> ID , $ taxonomy ) ; $ cats = array ( ) ; foreach ( $ postTerms as $ c ) { $ c -> permalink = get_term_link ( $ c , $ c -> taxonomy ) ; $ cats [ ] = $ c ; } return Collection :: make ( $ cats ) ; }
|
Return a collection of post taxonomies terms
|
53,653
|
public function taxonomies ( $ taxName = null ) { $ thisTax = ( $ taxName ) ? $ taxName : $ this -> categoryTax ; $ taxonomies = wp_get_object_terms ( $ this -> ID , $ thisTax ) ; if ( ! $ taxonomies || empty ( $ taxonomies ) ) { return null ; } $ tax = array ( ) ; foreach ( $ taxonomies as $ t ) { $ t -> permalink = get_term_link ( $ t -> slug , $ thisTax ) ; $ tax [ ] = $ t ; } return Collection :: make ( $ tax ) ; }
|
Return a collection of post taxonomies
|
53,654
|
public function gallery ( $ size = 'thumbnail' , $ format = 'array' , $ limit = - 1 ) { $ images = get_posts ( array ( 'post_parent' => $ this -> ID , 'post_type' => 'attachment' , 'numberposts' => $ limit , 'post_status' => null , 'post_mime_type' => 'image' , 'orderby' => 'menu_order' , 'order' => 'ASC' , ) ) ; if ( ! $ images || count ( $ images ) == 0 ) { return null ; } $ return = array ( ) ; foreach ( $ images as $ image ) { if ( $ format == 'array' ) { $ img = wp_get_attachment_image_src ( $ image -> ID , $ size , false ) ; $ i = array ( ) ; $ i [ 'url' ] = $ img [ 0 ] ; $ i [ 'width' ] = $ img [ 1 ] ; $ i [ 'height' ] = $ img [ 2 ] ; $ i [ 'resized' ] = $ img [ 3 ] ; $ i [ 'title' ] = $ image -> post_title ; $ return [ ] = $ i ; } else if ( $ format == 'html' ) { $ return [ ] = wp_get_attachment_image ( $ image -> ID , $ size , false ) ; } } return Collection :: make ( $ return ) ; }
|
Return the imagens on post gallery with certain format
|
53,655
|
public function author ( $ optionalPresenter = null ) { if ( $ optionalPresenter && $ optionalPresenter instanceof PresenterInterface ) { return new $ optionalPresenter ( $ this -> wpo , $ this -> isMainQuery ) ; } return new AuthorPresenter ( $ this -> wpo , $ this -> isMainQuery ) ; }
|
Return an instance of AuthorPresenter
|
53,656
|
public function meta ( $ metaKey = '' , $ single = true ) { $ meta_values = get_post_meta ( $ this -> ID , $ metaKey , $ single ) ; return $ meta_values ; }
|
Return the post meta
|
53,657
|
public function presentPostType ( ) { global $ wp_rewrite ; $ postType = get_post_type_object ( get_post_type ( $ this -> ID ) ) ; if ( ! $ postType ) { return null ; } if ( get_option ( 'permalink_structure' ) && is_array ( $ postType -> rewrite ) ) { $ slug = $ postType -> rewrite [ 'slug' ] ; if ( $ postType -> rewrite [ 'with_front' ] ) { $ structure = $ wp_rewrite -> front . $ slug ; } else { $ structure = $ wp_rewrite -> root . $ slug ; } $ link = url ( user_trailingslashit ( $ structure , 'post_type_archive' ) ) ; } else { $ slug = ( isset ( $ postType -> slug ) && $ postType -> slug ) ? $ postType -> slug : $ postType -> name ; $ link = url ( '?post_type=' . $ slug ) ; } $ postType -> permalink = $ link ; return $ postType ; }
|
Return the post type as object
|
53,658
|
public function MetaTags ( & $ tags ) { $ MetaMarkup = array ( ) ; $ owner = $ this -> owner ; $ tagTypes = array ( 'TagTitle' , 'MetaTagCharset' , 'MetaTagGenerator' , 'MetaTagDescription' , 'MetaTagRobots' , 'MetaTagResponsive' , 'MetaTagTwitter' , 'SchemaTagWebsite' , 'SchemaTagBreadcrumbs' , 'SchemaTagContactPoints' , 'SchemaTagLocalBusiness' ) ; foreach ( $ tagTypes as $ tagType ) { if ( $ owner -> { $ tagType } ) { $ MetaMarkup [ ] = $ owner -> { $ tagType } ; } } if ( Permission :: check ( 'CMS_ACCESS_CMSMain' ) && in_array ( 'CMSPreviewable' , class_implements ( $ owner ) ) && ! $ owner instanceof ErrorPage && $ owner -> ID > 0 ) { $ MetaMarkup [ ] = MetaHelper :: MetaTag ( 'x-page-id' , $ owner -> ID ) ; $ MetaMarkup [ ] = MetaHelper :: MetaTag ( 'x-cms-edit-link' , $ owner -> CMSEditLink ( ) ) ; Requirements :: customScript ( file_get_contents ( BASE_PATH . '/' . BETTERMETA_DIR . '/js/cmseditshortcut.js' ) ) ; } $ tags = implode ( "\n" , $ MetaMarkup ) ; }
|
Extension hook to change all tags
|
53,659
|
public function setFlash ( $ key , $ value ) { $ this -> session -> getFlashBag ( ) -> set ( $ key , $ value ) ; return $ this ; }
|
Set a flash message
|
53,660
|
public function addFlash ( $ key , $ value ) { $ this -> session -> getFlashBag ( ) -> add ( $ key , $ value ) ; return $ this ; }
|
Add a flash message
|
53,661
|
protected function renderContent ( ) { foreach ( $ this -> httpEquivs as $ name => $ content ) echo CHtml :: metaTag ( $ content , null , $ name ) ; if ( $ this -> _title !== null ) echo CHtml :: tag ( 'title' , array ( ) , is_array ( $ this -> _title ) ? implode ( $ this -> titleSeparator , $ this -> _title ) : $ this -> _title ) ; if ( $ this -> _description !== null ) echo CHtml :: metaTag ( $ this -> _description , 'description' ) ; if ( $ this -> _keywords !== null ) echo CHtml :: metaTag ( $ this -> _keywords , 'keywords' ) ; foreach ( $ this -> _properties as $ name => $ content ) echo CHtml :: tag ( 'meta' , array ( 'property' => $ name , 'content' => $ content ) ) ; if ( $ this -> _canonical !== null ) echo CHtml :: linkTag ( 'canonical' , null , $ this -> _canonical ) ; }
|
Renders the widget content .
|
53,662
|
private function getControllerMethods ( $ controller ) { if ( ! \ Sonic \ Sonic :: _classExists ( __NAMESPACE__ . '\\' . $ controller ) ) { return array ( ) ; } $ actions = array ( ) ; $ reflection = new \ ReflectionClass ( __NAMESPACE__ . '\\' . $ controller ) ; $ className = $ reflection -> getName ( ) ; foreach ( $ reflection -> getMethods ( ) as $ method ) { if ( $ method -> getDeclaringClass ( ) -> getName ( ) != $ className ) { continue ; } if ( ! $ method -> isPublic ( ) ) { continue ; } if ( substr ( $ method -> getName ( ) , 0 , 2 ) == '__' ) { continue ; } $ name = $ method -> getName ( ) ; $ comment = new \ Sonic \ Model \ Tools \ Comment ( $ method -> getDocComment ( ) ) ; if ( $ comment -> hasTag ( 'ignore' ) ) { continue ; } $ actions [ $ name ] = array ( 'description' => $ comment -> getShortDescription ( ) , 'notes' => $ comment -> getLongDescription ( ) , 'url' => URL_ROOT . str_replace ( '\\' , '/' , strtolower ( $ controller ) ) . '/' . $ name , 'auth' => FALSE ) ; if ( $ comment -> hasTag ( 'authenticated' ) ) { $ actions [ $ name ] [ 'auth' ] = TRUE ; } $ params = $ comment -> getTags ( 'param' ) ; if ( $ params ) { foreach ( $ params as $ param ) { if ( ! preg_match ( '/^(\w+)\s+\$([\w\d]+)\s*(.*?)$/' , $ param , $ arr ) ) { continue ; } $ actions [ $ name ] [ 'param' ] [ ] = array ( 'type' => $ arr [ 1 ] , 'name' => $ arr [ 2 ] , 'description' => $ arr [ 3 ] ) ; } } } return $ actions ; }
|
Return controller methods using reflection
|
53,663
|
public function serializeBase64 ( SerializationVisitorInterface $ visitor , string $ data , array $ type ) { return $ visitor -> visitString ( base64_encode ( $ data ) , $ type ) ; }
|
Serializes the data to base64 .
|
53,664
|
public function deserializeBase64 ( DeserializationVisitorInterface $ visitor , $ base64 , array $ type ) : string { return ( string ) base64_decode ( $ visitor -> visitString ( $ base64 , $ type ) , true ) ; }
|
Deserializes the base64 string .
|
53,665
|
public function Connect ( $ dsn = FALSE , $ user = FALSE , $ pass = FALSE , $ options = FALSE ) { if ( ! $ this -> connected ) { $ this -> _dsn = $ dsn ? : $ this -> _dsn ; $ this -> _user = $ user ? : $ this -> _user ; $ this -> _pass = $ pass ? : $ this -> _pass ; $ this -> _options = $ options ? : $ this -> _options ; parent :: __construct ( $ this -> _dsn , $ this -> _user , $ this -> _pass , $ this -> _options ) ; $ this -> connected = TRUE ; } }
|
Connect to the database if not already done Will throw a PDOException is connection fails
|
53,666
|
public function setConnection ( $ dsn = FALSE , $ user = FALSE , $ pass = FALSE , $ options = FALSE ) { $ this -> _dsn = $ dsn ? : $ this -> _dsn ; $ this -> _user = $ user ? : $ this -> _user ; $ this -> _pass = $ pass ? : $ this -> _pass ; $ this -> _options = $ options ? : $ this -> _options ; }
|
Set connection details to the database Will throw a PDOException is connection fails
|
53,667
|
public static function genBindValues ( & $ query , $ arrWHERE ) { foreach ( $ arrWHERE as $ arrClause ) { if ( is_array ( $ arrClause [ 0 ] ) ) { self :: genBindValues ( $ query , $ arrClause ) ; } else { if ( is_array ( $ arrClause ) ) { if ( ! isset ( $ arrClause [ 2 ] ) || ( ! in_array ( $ arrClause [ 2 ] , array ( 'IN' , 'NOT IN' , 'IS' , 'IS NOT' , 'BETWEEN' ) ) && in_array ( $ arrClause [ 2 ] , self :: $ validComparison ) ) ) { $ query -> bindValue ( ':' . md5 ( $ arrClause [ 0 ] ) . '_' . md5 ( $ arrClause [ 1 ] ) , $ arrClause [ 1 ] ) ; } } } } }
|
Bind query values from where array
|
53,668
|
public function bindValues ( & $ query , $ params ) { foreach ( $ params as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! $ query -> bindValue ( $ key , $ value [ 0 ] , $ value [ 1 ] ) ) { return FALSE ; } } else { if ( ! $ query -> bindValue ( $ key , $ value ) ) { return FALSE ; } } } return TRUE ; }
|
Bind an array of parameters to the query
|
53,669
|
public function genClause ( $ strName , $ mixOptions , $ strDefault = FALSE , $ strSeparator = ', ' ) { $ strClause = NULL ; if ( isset ( $ mixOptions ) && $ mixOptions ) { $ strClause = $ strName . ' ' ; if ( is_array ( $ mixOptions ) && count ( $ mixOptions ) > 0 ) { $ strClause .= implode ( $ strSeparator , $ mixOptions ) ; } else { $ strClause .= $ mixOptions ; } } else if ( FALSE !== $ strDefault ) { $ strClause = $ strName . ' ' . $ strDefault ; } if ( NULL !== $ strClause ) { $ strClause .= ' ' ; } return $ strClause ; }
|
Generates a clause in an SQL statement
|
53,670
|
public function genQuery ( $ arrParams = array ( ) ) { $ strSQL = $ this -> genSQL ( $ arrParams ) ; $ query = $ this -> prepare ( $ strSQL ) ; if ( isset ( $ arrParams [ 'where' ] ) && is_array ( $ arrParams [ 'where' ] ) ) { $ this -> genBindValues ( $ query , $ arrParams [ 'where' ] ) ; } if ( isset ( $ arrParams [ 'having' ] ) && is_array ( $ arrParams [ 'having' ] ) ) { $ this -> genBindValues ( $ query , $ arrParams [ 'having' ] ) ; } if ( isset ( $ arrParams [ 'bind' ] ) && is_array ( $ arrParams [ 'bind' ] ) ) { if ( ! $ this -> bindValues ( $ query , $ arrParams [ 'bind' ] ) ) { return FALSE ; } } return $ query ; }
|
Returns a PDO query resource ready for execution
|
53,671
|
public function genUnionBindValues ( & $ query , $ args ) { foreach ( $ args as $ key => $ arg ) { if ( isset ( $ arg [ 'where' ] ) && is_array ( $ arg [ 'where' ] ) ) { $ this -> genBindValues ( $ query , $ arg [ 'where' ] ) ; } if ( isset ( $ arg [ 'having' ] ) && is_array ( $ arg [ 'having' ] ) ) { $ this -> genBindValues ( $ query , $ arg [ 'having' ] ) ; } } }
|
Bind values to a union query
|
53,672
|
public function getValue ( $ arrParams , $ fetchMode = \ PDO :: FETCH_BOTH ) { if ( ! $ this -> validateParams ( $ arrParams ) ) { return FALSE ; } $ arrParams [ 'limit' ] = '1' ; $ query = $ this -> genQuery ( $ arrParams ) ; $ query -> execute ( ) ; $ arrResult = $ query -> fetch ( $ fetchMode ) ; if ( is_array ( $ arrResult ) && count ( $ arrResult ) === 1 ) { return array_shift ( $ arrResult ) ; } else { return $ arrResult ; } }
|
Return a single value or row
|
53,673
|
public function getValues ( $ arrParams ) { if ( ! $ this -> validateParams ( $ arrParams ) ) { return FALSE ; } $ query = $ this -> genQuery ( $ arrParams ) ; $ query -> execute ( ) ; $ arrSelect = is_array ( $ arrParams [ 'select' ] ) ? $ arrParams [ 'select' ] : explode ( ',' , $ arrParams [ 'select' ] ) ; if ( count ( $ arrSelect ) === 1 && strpos ( $ arrSelect [ 0 ] , '*' ) === FALSE ) { $ query -> setFetchMode ( \ PDO :: FETCH_COLUMN , 0 ) ; } else { $ query -> setFetchMode ( \ PDO :: FETCH_ASSOC ) ; } $ arrResult = $ query -> fetchAll ( ) ; return $ arrResult ; }
|
Return all rows or array of single values
|
53,674
|
public function fetchAssocBySql ( $ strSQL , $ arrBindParams = array ( ) ) { $ query = $ this -> prepare ( $ strSQL ) ; if ( ! $ this -> bindValues ( $ query , $ arrBindParams ) ) { return FALSE ; } $ success = $ query -> execute ( ) ; if ( ! $ success ) { return FALSE ; } return $ query -> fetchAll ( 2 ) ; }
|
Get the query associate resultset with sql and bind params
|
53,675
|
public function addTransactionHook ( Db & $ db ) { $ dsn = $ db -> getDSN ( ) ; if ( $ dsn != $ this -> getDSN ( ) && ! isset ( $ this -> _transaction_hooks [ $ dsn ] ) ) { $ this -> _transaction_hooks [ $ dsn ] = & $ db ; return TRUE ; } return FALSE ; }
|
Add a transaction hook to commit and rollback another database at the same time as this database
|
53,676
|
public function commit ( ) { if ( -- $ this -> transactionCount === 0 ) { $ status = parent :: commit ( ) ; if ( $ this -> _transaction_hooks ) { if ( $ status ) { foreach ( $ this -> _transaction_hooks as $ dsn => & $ db ) { $ db -> commit ( ) ; } } $ this -> _transaction_hooks = array ( ) ; } return $ status ; } else { return FALSE ; } }
|
Commits a transaction as long as there are no other active transactions
|
53,677
|
public function rollBack ( ) { if ( -- $ this -> transactionCount === 0 ) { $ status = parent :: rollBack ( ) ; if ( $ this -> _transaction_hooks ) { foreach ( $ this -> _transaction_hooks as & $ db ) { $ db -> rollBack ( ) ; } $ this -> _transaction_hooks = array ( ) ; } return $ status ; } else { return FALSE ; } }
|
Rolls back a transaction and allows new transactions to begin
|
53,678
|
public function hasPermission ( $ module , $ action , User $ user = null ) { $ module = $ this -> service -> getModuleManager ( ) -> load ( $ module ) ; $ action = $ module -> getActionModel ( $ action ) ; return $ this -> hasActionPermission ( $ action , $ user ) ; }
|
Checks the permission for the given module and action name
|
53,679
|
private function getPermissionTable ( User $ user ) { $ userId = $ user -> getId ( ) ; if ( $ this -> permissionTable -> has ( $ userId ) ) { return $ this -> permissionTable -> get ( $ userId ) ; } $ guestGroup = GroupQuery :: create ( ) -> findOneByIsGuest ( true ) ; $ groups = GroupQuery :: create ( ) -> filterByUser ( $ user ) -> find ( ) ; $ userGroup = GroupQuery :: create ( ) -> filterByOwnerId ( ( $ userId ) ) -> findOne ( ) ; if ( $ userGroup ) { $ groups [ ] = $ userGroup ; } $ groups [ ] = $ guestGroup ; $ permissionTable = new Set ( ) ; foreach ( $ groups as $ group ) { foreach ( $ group -> getActions ( ) as $ action ) { $ permissionTable -> add ( $ action -> getId ( ) ) ; } } $ this -> permissionTable -> set ( $ userId , $ permissionTable ) ; return $ this -> permissionTable -> get ( $ userId ) ; }
|
Returns a set of allowed action ids
|
53,680
|
public static function pgQueryParams ( $ sql , $ params , $ suppress = false ) { $ db_handler = DatabaseHandler :: init ( ) ; return $ db_handler -> query ( $ sql , $ params , $ suppress ) ; }
|
Run a PostgreSQL statement with given parameters
|
53,681
|
public function removeListener ( $ eventName , $ listener ) { if ( ! isset ( $ this -> listeners [ $ eventName ] ) ) { return false ; } foreach ( $ this -> listeners [ $ eventName ] as $ i => $ callback ) { if ( $ listener === $ callback ) { unset ( $ this -> listeners [ $ eventName ] [ $ i ] ) ; } } if ( count ( $ this -> listeners [ $ eventName ] ) == 0 ) { unset ( $ this -> listeners [ $ eventName ] ) ; } }
|
Disconnects a listener for a given event name .
|
53,682
|
public function dispatch ( $ eventName , Event $ event ) { if ( ! $ this -> hasListeners ( $ eventName ) ) { return $ event ; } $ event -> setName ( $ eventName ) ; foreach ( $ this -> getListeners ( $ event -> getName ( ) ) as $ listener ) { call_user_func ( $ listener , $ event ) ; if ( $ event -> isPropagationStopped ( ) ) { break ; } } return $ event ; }
|
Dispatch all listeners of a given event .
|
53,683
|
public function dispatchUntil ( $ eventName , Event $ event ) { if ( $ event -> isProcessed ( ) ) { return $ event ; } if ( ! $ this -> hasListeners ( $ eventName ) ) { return $ event ; } $ event -> setName ( $ eventName ) ; foreach ( $ this -> getListeners ( $ event -> getName ( ) ) as $ listener ) { if ( call_user_func ( $ listener , $ event ) ) { $ event -> setProcessed ( true ) ; break ; } } return $ event ; }
|
Dispatch all listeners of a given event until one returns a non null value .
|
53,684
|
public function hasListeners ( $ eventName = '' ) { $ count = 0 ; if ( empty ( $ eventName ) ) { $ count = count ( $ this -> listeners ) ; } elseif ( isset ( $ this -> listeners [ $ eventName ] ) ) { $ count = count ( $ this -> listeners [ $ eventName ] ) ; } return ( boolean ) $ count ; }
|
Returns true if the given event name has some listeners .
|
53,685
|
public function redirect ( $ location , $ statusCode = 302 ) { $ this -> response -> setHeader ( 'Location' , $ location , true , $ statusCode ) ; return $ this ; }
|
Redirect user to the new url
|
53,686
|
public function render ( ) { $ args = func_get_args ( ) ; if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ tpl = array_shift ( $ args ) ; } else { $ tpl = get_class ( $ this ) ; $ paths = explode ( '\\' , $ tpl ) ; array_shift ( $ paths ) ; $ className = array_pop ( $ paths ) ; $ actionSuffix = 'Action' ; if ( substr ( $ className , strrpos ( $ className , $ actionSuffix ) ) === $ actionSuffix ) { $ basename = substr ( $ className , 0 , - strlen ( $ actionSuffix ) ) ; } else { $ basename = $ className ; } array_push ( $ paths , $ basename ) ; foreach ( $ paths as & $ path ) { $ path = Toolkit :: to_snake_case ( $ path ) ; } unset ( $ path ) ; $ tpl = implode ( DIRECTORY_SEPARATOR , $ paths ) ; } if ( isset ( $ args [ 0 ] ) && is_array ( $ args [ 0 ] ) ) { $ params = array_shift ( $ args ) ; } else { $ params = [ ] ; } if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ cacheId = array_shift ( $ args ) ; } else { $ cacheId = '' ; } return $ this -> view -> render ( $ tpl , $ params , $ cacheId ) ; }
|
Render a template and returns html
|
53,687
|
public function getClientIp ( ) : string { $ s = $ this -> server ( ) ; if ( array_key_exists ( 'HTTP_CLIENTIP' , $ s ) ) { if ( ! empty ( $ s [ 'HTTP_CLIENTIP' ] ) ) { return $ s [ 'HTTP_CLIENTIP' ] ; } } if ( array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ s ) && ! empty ( $ s [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ addresses = explode ( ',' , $ s [ 'HTTP_X_FORWARDED_FOR' ] ) ; while ( count ( $ addresses ) ) { $ ip = @ trim ( array_shift ( $ addresses ) ) ; if ( $ ip === '' ) { continue ; } if ( ! self :: isLanIp ( $ ip ) ) { return $ ip ; } } } return $ s [ 'REMOTE_ADDR' ] ; }
|
Gets the client side WAN ip address .
|
53,688
|
public function validateFile ( $ attribute , $ value ) { $ extension = $ value -> getClientOriginalExtension ( ) ; if ( $ extension !== 'csv' ) { $ this -> setCustomMessages ( [ $ attribute => trans ( 'File has invalid extension' ) ] ) ; $ this -> addFailure ( $ attribute , $ attribute , [ ] ) ; return false ; } return true ; }
|
validates csv file
|
53,689
|
public function inferMachineType ( $ aref , & $ type , & $ id ) { $ len = count ( $ aref ) ; if ( $ len == 0 ) { return false ; } $ type = str_replace ( '-' , '_' , array_shift ( $ aref ) ) ; if ( ! isset ( $ this -> machine_type_table [ $ type ] ) ) { return false ; } switch ( $ len ) { case 1 : $ id = null ; break ; case 2 : $ id = reset ( $ aref ) ; break ; default : $ id = $ aref ; } return true ; }
|
Infer type of referenced machine type using lookup table .
|
53,690
|
protected function createListing ( Smalldb $ smalldb , $ filters , $ filtering_flags = 0 ) : IListing { $ type = $ filters [ 'type' ] ; $ machine = $ this -> getMachine ( $ smalldb , $ type ) ; if ( $ machine === null ) { throw new InvalidArgumentException ( 'Machine type "' . $ type . '" not found.' ) ; } unset ( $ filters [ 'type' ] ) ; return $ machine -> createListing ( $ filters , $ filtering_flags ) ; }
|
Creates a listing using given filters .
|
53,691
|
protected function setBuildItems ( ) { $ crcy = Factory :: create ( $ this -> code ) ; $ refl = new \ ReflectionClass ( $ crcy ) ; $ fmt = $ refl -> getProperty ( 'displayFormat' ) ; $ fmt -> setAccessible ( true ) ; $ locale = $ refl -> getProperty ( 'locale' ) ; $ locale -> setAccessible ( true ) ; $ precision = $ refl -> getProperty ( 'precision' ) ; $ precision -> setAccessible ( true ) ; $ this -> buildItems = [ 'code' => $ this -> code , 'name' => $ crcy -> getName ( ) -> get ( ) , 'symbol' => $ crcy -> getSymbol ( ) -> get ( ) , 'displayFormat' => $ fmt -> getValue ( $ crcy ) -> get ( ) , 'locale' => $ locale -> getValue ( $ crcy ) -> get ( ) , 'precision' => $ precision -> getValue ( $ crcy ) -> get ( ) , 'value' => $ crcy ( ) ] ; }
|
Set up the build items that this builder will manage We don t need to do any complicated build routine so can set values here
|
53,692
|
public function activate ( Composer $ composer , IOInterface $ io ) { $ this -> composer = $ composer ; $ this -> io = $ io ; if ( isset ( $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-require' ] [ 'vendor-name' ] ) ) { $ this -> vendorName = $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-require' ] [ 'vendor-name' ] ; } else { $ this -> vendorName = 'yourpackage' ; } if ( isset ( $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-require' ] [ 'path-scheme' ] ) ) { $ this -> pathScheme = $ this -> composer -> getPackage ( ) -> getExtra ( ) [ 'auto-require' ] [ 'path-scheme' ] ; } else { $ this -> pathScheme = '{vendorName}/{vendorName}.{name}' ; } }
|
activate the composer plugins
|
53,693
|
public function autoRequirePackagesPreRequire ( PreCommandRunEvent $ event ) { if ( $ event -> getCommand ( ) == 'require' ) { $ companyPackages = [ ] ; $ commandPackages = $ event -> getInput ( ) -> getArgument ( 'packages' ) ; foreach ( $ commandPackages as $ package ) { $ companyPackages [ explode ( '=' , $ package ) [ 0 ] ] = $ package ; } $ repository = $ this -> composer -> getRepositoryManager ( ) ; foreach ( $ companyPackages as $ packageName => $ package ) { if ( $ repository -> findPackage ( $ packageName , '*' ) ) { unset ( $ companyPackages [ $ packageName ] ) ; } } foreach ( $ companyPackages as $ packageName => $ package ) { $ name = explode ( '/' , $ packageName ) [ 1 ] ; $ filledPathScheme = str_replace ( [ '{vendorName}' , '{name}' ] , [ $ this -> vendorName , $ name ] , $ this -> pathScheme ) ; $ url = 'git@github.com:' . $ filledPathScheme . '.git' ; $ repository -> addRepository ( $ repository -> createRepository ( 'vcs' , [ 'url' => $ url ] , $ packageName ) ) ; } } }
|
Method for the pre - command - run event
|
53,694
|
public function autoRequirePackagesPreUpdate ( Event $ event ) { $ companyPackages = [ ] ; $ packages = $ this -> composer -> getPackage ( ) -> getRequires ( ) ; foreach ( $ packages as $ packageName => $ package ) { if ( $ this -> startsWith ( $ packageName , $ this -> vendorName ) ) { $ companyPackages [ $ packageName ] = $ package ; } } $ repository = $ this -> composer -> getRepositoryManager ( ) ; foreach ( $ companyPackages as $ packageName => $ package ) { if ( $ repository -> findPackage ( $ packageName , '*' ) ) { unset ( $ companyPackages [ $ packageName ] ) ; } } foreach ( $ companyPackages as $ packageName => $ package ) { $ name = explode ( '/' , $ packageName ) [ 1 ] ; $ url = 'git@github.com:' . $ this -> vendorName . '/' . $ this -> vendorName . '.' . $ name . '.git' ; $ repository -> addRepository ( $ repository -> createRepository ( 'vcs' , [ 'url' => $ url ] , $ packageName ) ) ; } }
|
Method for the pre - update - cmd event
|
53,695
|
public function index ( ) { $ items = new $ this -> listClass ( ) ; $ this -> applyListFilters ( $ items ) ; $ items -> load ( ) ; $ this -> template -> vars [ $ this -> listTplVar ] = $ items ; if ( $ this -> pagedList ) { $ this -> template -> vars [ 'pagination' ] = [ 'page' => ( int ) ( isset ( $ _GET [ 'page' ] ) ? $ _GET [ 'page' ] : 0 ) , 'recordsPerPage' => $ items -> recordsPerPage , 'recordsCount' => $ items -> recordsCount , 'pagesCount' => $ items -> pagesCount , 'base_url' => '/' . $ this -> division . '/' . $ this -> module , ] ; } }
|
Action for list entities .
|
53,696
|
protected function applyListFilters ( ModelCollection $ items ) { return $ this -> pagedList ? $ items -> page ( isset ( $ _GET [ 'page' ] ) ? $ _GET [ 'page' ] : 0 , $ this -> recordsPerPage ) : $ items ; }
|
Apply additional criteria to list query .
|
53,697
|
protected function prepareEditorTpl ( $ id = null ) { $ mode = $ id === null ? 'create' : 'edit' ; $ item = new $ this -> itemClass ( ) ; if ( $ _POST ) { $ this -> save ( $ id , $ item ) ; return ; } $ this -> loadTemplate ( $ mode ) ; if ( $ mode == 'edit' ) { $ item -> load ( $ id ) ; } $ this -> initItem ( $ item , $ id ) ; if ( $ _POST ) { $ this -> fillWithUserValues ( $ item ) ; } $ this -> template -> vars [ 'mode' ] = $ mode ; $ this -> template -> vars [ $ this -> itemTplVar ] = $ item ; }
|
Prepare template for create & edit action .
|
53,698
|
public function input ( $ buffer , $ connection ) { if ( empty ( $ this -> seckey ) ) { $ this -> seckey = $ connection -> listener -> getHandler ( ) -> secKey ; } if ( ! $ connection -> hasAttribute ( $ this -> seckey ) ) { return $ this -> handshakeInput ( $ buffer , $ connection ) ; } return $ this -> streamInput ( $ buffer , $ connection ) ; }
|
parse http|websocket stream request packet
|
53,699
|
public function handshakeInput ( $ buffer , $ connection ) { $ len = parent :: input ( $ buffer , $ connection ) ; if ( ! $ len ) return 0 ; $ req = new HttpReqeust ( ) ; $ req -> loadRequest ( $ buffer ) ; if ( $ req -> headers -> get ( 'Connection' ) !== 'Upgrade' ) { throw new \ Exception ( "Bad Connection" , 412 ) ; } if ( $ req -> headers -> get ( 'Upgrade' ) !== 'websocket' ) { throw new \ Exception ( "Bad Upgrade" , 412 ) ; } $ seckey = $ req -> headers -> get ( 'Sec-Websocket-Key' ) ; if ( ! $ seckey || base64_encode ( base64_decode ( $ seckey ) ) !== $ seckey ) { throw new \ Exception ( "Bad Websocket-Key" , 412 ) ; } return $ len ; }
|
http handshake process
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.