idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
59,800
|
public static function FindObjectByIntValue ( $ idValue , $ propName , $ listOfObjects ) { $ match = false ; foreach ( $ listOfObjects as $ obj ) { if ( intval ( $ obj -> $ propName ( ) ) === $ idValue ) { $ match = $ obj ; break ; } } return $ match ; }
|
Find an object in a list filtering by the id value of given property name of each object .
|
59,801
|
public static function FindObjectByStringValue ( $ filter , $ propName , $ listOfObjects , $ key = null ) { $ match = false ; if ( $ key === null ) { foreach ( $ listOfObjects as $ obj ) { if ( $ obj -> $ propName ( ) === $ filter ) { $ match = $ obj ; break ; } } } else { foreach ( $ listOfObjects as $ obj ) { if ( $ obj [ $ key ] -> $ propName ( ) === $ filter ) { $ match = $ obj [ $ key ] ; break ; } } } return $ match ; }
|
Find an object in a list filtering by the string value of one property name of each object .
|
59,802
|
public static function generateEllipsisAndTooltipMarkupFor ( $ textToTruncate , $ charLimit , $ placement ) { $ truncatedData = null ; if ( strlen ( $ textToTruncate ) > intval ( $ charLimit ) ) { $ truncatedData = array ( 'source' => $ textToTruncate , 'truncated' => substr ( $ textToTruncate , 0 , $ charLimit - 3 ) . '...' ) ; } else { $ truncatedData = array ( 'source' => $ textToTruncate , 'truncated' => '' ) ; } if ( trim ( $ truncatedData [ 'truncated' ] ) !== '' ) { echo $ truncatedData [ 'truncated' ] ; echo '<input type="hidden" class="ellipsis-tooltip" value="' . $ truncatedData [ 'source' ] . '" placement="' . $ placement . '" >' ; } else { echo $ truncatedData [ 'source' ] ; } }
|
Returns the truncated text based on the passed parameters at present the method generates the HTML markup as well which is needed for the tooltip to work properly .
|
59,803
|
public function loadConfig ( $ file ) { $ config = include $ file ; $ this -> path = $ config [ 'path' ] ; $ this -> compiled = $ config [ 'compiled' ] ; $ this -> forceCompile = $ config [ 'forceCompile' ] ; $ this -> skipCommentTags = $ config [ 'skipCommentTags' ] ; $ this -> source_filename_extension = $ config [ 'source_filename_extension' ] ; $ this -> dest_filename_extension = $ config [ 'dest_filename_extension' ] ; if ( ! is_dir ( $ this -> path ) ) { mkdir ( $ this -> path , 0777 , true ) ; } if ( ! is_dir ( $ this -> compiled ) ) { mkdir ( $ this -> compiled , 0777 , true ) ; } }
|
load config array into View from file
|
59,804
|
public static function jumpstart ( Event $ event ) { $ info = static :: questionnaire ( $ event ) ; $ files = new \ AppendIterator ( ) ; $ files -> append ( new RegexIterator ( new RecursiveDirectoryIterator ( '.' ) , static :: $ filePattern , RegexIterator :: GET_MATCH ) ) ; $ files -> append ( new RegexIterator ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( 'src' ) ) , static :: $ filePattern , RegexIterator :: GET_MATCH ) ) ; static :: updateFiles ( $ event , $ files , $ info ) ; static :: mergeConfig ( $ event , $ info ) ; }
|
Publish th plugin to the WordPress plugin repository
|
59,805
|
public static function mergeConfig ( Event $ event , array $ info ) { $ io = $ event -> getIO ( ) ; $ options = array ( "name" => $ info [ 'package' ] , "description" => $ info [ 'description' ] , "license" => $ info [ 'license' ] , "keywords" => array ( ) , "type" => "wordpress-plugin" , "authors" => array ( array ( "name" => $ info [ 'author' ] , "email" => $ info [ 'author_email' ] ) + ( ! empty ( $ info [ 'author_url' ] ) ? array ( "homepage" => $ info [ 'author_url' ] ) : array ( ) ) ) , "scripts" => array ( "publish" => "Jumpstart\\Deploy::publish" ) , "minimum-stability" => "dev" , "prefer-stable" => true , "require" => array ( "composer/installers" => "~1.0" , "mrgrain/jumpstart-battery" => "~1.0" ) , "require-dev" => array ( "mrgrain/jumpstart-deploy" => "@stable" ) , "autoload" => array ( "psr-4" => array ( $ info [ 'namespace' ] . "\\" => "src/" ) ) ) ; $ file = new JsonFile ( 'composer.json' ) ; $ json = $ file -> encode ( $ options ) ; $ writeFile = true ; $ io -> write ( 'Jumpstart has generated a composer.json file for you.' ) ; if ( $ io -> askConfirmation ( 'Do you want to check it before writing to disk? [yes]' . "\t" ) ) { $ writeFile = false ; $ io -> write ( $ json ) ; if ( $ io -> askConfirmation ( 'Write the generated composer.json to disk? [yes]' . "\t" ) ) { $ writeFile = true ; } } if ( $ writeFile ) { $ file -> write ( $ options ) ; } }
|
Merge the current config with the updated data
|
59,806
|
public static function updateFiles ( Event $ event , $ files , array $ info ) { $ io = $ event -> getIO ( ) ; if ( $ io -> askConfirmation ( 'Jumpstart will now update your files with the provided information. Okay? [yes]:' . "\t" ) ) { foreach ( $ files as $ file ) { $ file = array_pop ( $ file ) ; $ io -> write ( "\t" . $ file . "\t" , false ) ; $ io -> write ( static :: updateFile ( $ file , $ info ) ? 'OK' : 'Error' ) ; } if ( file_exists ( 'plugin.php' ) ) { rename ( 'plugin.php' , $ info [ 'plugin_slug' ] . '.php' ) ; } $ io -> write ( '' ) ; } }
|
Update the boilerplate files with the additional information
|
59,807
|
public static function questionnaire ( Event $ event ) { $ io = $ event -> getIO ( ) ; $ io -> write ( array ( PHP_EOL . PHP_EOL , 'Welcome to the Jumpstart Plugin generator' , PHP_EOL . PHP_EOL . PHP_EOL , 'This command will guide you through creating your basic plugin setup.' ) ) ; static :: $ package = $ io -> askAndValidate ( 'Package (<vendor>/<name>):' . "\t" , 'Jumpstart\\Init::validatePackage' ) ; static :: $ namespace = $ io -> askAndValidate ( 'PHP namespace (<vendor>\<name>) [' . static :: suggestNamespace ( static :: $ package ) . ']:' . "\t" , 'Jumpstart\\Init::validateNamespace' , null , static :: suggestNamespace ( static :: $ package ) ) ; static :: $ plugin_name = $ io -> ask ( 'Plugin Name [' . static :: suggestPluginName ( static :: $ package ) . ']:' . "\t" , static :: suggestPluginName ( static :: $ package ) ) ; static :: $ plugin_slug = $ io -> askAndValidate ( 'Plugin Slug [' . static :: suggestPluginSlug ( static :: $ plugin_name ) . ']:' . "\t" , 'Jumpstart\\Init::validateSlug' , null , static :: suggestPluginSlug ( static :: $ plugin_name ) ) ; static :: $ version = $ io -> askAndValidate ( 'Version (x.x.x) [1.0.0]:' . "\t" , 'Jumpstart\\Init::validateVersion' , null , '1.0.0' ) ; static :: $ description = $ io -> askAndValidate ( 'Description []:' . "\t" , 'Jumpstart\\Init::validateDescription' , null , '' ) ; static :: $ url = $ io -> askAndValidate ( 'URL []:' . "\t" , 'Jumpstart\\Init::validateURL' ) ; static :: $ author = $ io -> ask ( 'Author [' . static :: suggestAuthor ( ) . ']:' . "\t" , static :: suggestAuthor ( ) ) ; static :: $ author_email = $ io -> ask ( 'Author Email [' . static :: suggestAuthorEmail ( ) . ']:' . "\t" , static :: suggestAuthorEmail ( ) ) ; static :: $ author_url = $ io -> askAndValidate ( 'Author URL []:' . "\t" , 'Jumpstart\\Init::validateURL' ) ; static :: $ license = $ io -> ask ( 'License [' . static :: suggestLicense ( ) . ']:' . "\t" , static :: suggestLicense ( ) ) ; return array ( 'package' => static :: $ package , 'namespace' => static :: $ namespace , 'plugin_name' => static :: $ plugin_name , 'plugin_slug' => static :: $ plugin_slug , 'version' => static :: $ version , 'description' => static :: $ description , 'url' => static :: $ url , 'author' => static :: $ author , 'author_email' => static :: $ author_email , 'author_url' => static :: $ author_url , 'license' => static :: $ license , ) ; }
|
Collect information about the plugin
|
59,808
|
public function append ( $ newvalue ) : void { $ index = count ( ( array ) $ this ) ; $ this -> offsetSet ( $ index , $ newvalue ) ; }
|
Append any item to the form .
|
59,809
|
protected function afterCreation ( $ object , array $ definition ) { if ( isset ( $ definition [ 'methods' ] ) ) { $ this -> executeMethodBatch ( $ definition [ 'methods' ] , $ object ) ; } if ( ! isset ( $ definition [ 'skip' ] ) || ! $ definition [ 'skip' ] ) { $ this -> executeCommonBatch ( $ object ) ; } }
|
Things to do after an object created .
|
59,810
|
protected function executeCommonBatch ( $ object ) { $ commons = $ this -> getCommonMethods ( ) ; foreach ( $ commons as $ pair ) { $ tester = $ pair [ 0 ] ; $ runner = $ pair [ 1 ] ; if ( $ tester ( $ object , $ this ) ) { $ this -> executeMethod ( $ runner , $ object ) ; } } }
|
Execute common methods for all objects
|
59,811
|
protected function indentArray ( array $ elements ) { return self :: INDENTATION . \ str_replace ( PHP_EOL , PHP_EOL . self :: INDENTATION , \ implode ( PHP_EOL , $ elements ) ) ; }
|
Indent all elements in the supplied array . The array must contain either strings or objects that can be casted to strings .
|
59,812
|
private function parse ( $ uri ) { $ parts = parse_url ( $ uri ) ; if ( $ parts === false ) throw new \ InvalidArgumentException ( "The source URI `{$uri}` appears to be malformed" ) ; if ( ( $ parts [ 'scheme' ] ?? null ) === 'mailto' ) { if ( isset ( $ parts [ 'host' ] ) || isset ( $ parts [ 'user' ] ) || isset ( $ parts [ 'pass' ] ) || isset ( $ parts [ 'fragment' ] ) || isset ( $ parts [ 'query' ] ) || isset ( $ parts [ 'port' ] ) || empty ( $ parts [ 'path' ] ) || $ parts [ 'path' ] [ 0 ] === '/' ) throw new \ InvalidArgumentException ( "The source email address `{$uri}` appears to be malformed" ) ; $ parts = parse_url ( 'mailto://' . $ parts [ 'path' ] ) ; if ( $ parts === false ) throw new \ InvalidArgumentException ( "The source email address `{$uri}` appears to be malformed" ) ; } $ this -> fromArray ( $ parts ) ; }
|
Parse a URI into its component parts and set the properties
|
59,813
|
public static function encodePath ( $ path ) { $ path = preg_replace_callback ( '/(?:[^' . self :: CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/u' , __CLASS__ . '::urlEncodeChar' , $ path ) ; if ( empty ( $ path ) ) return null ; if ( $ path [ 0 ] !== '/' ) return $ path ; return '/' . ltrim ( $ path , '/' ) ; }
|
Encode the path
|
59,814
|
private function encodeQuery ( $ query , $ arg_separator = '&' ) { if ( ! empty ( $ query ) && strpos ( $ query , '?' ) === 0 ) $ query = substr ( $ query , 1 ) ; $ parts = explode ( $ arg_separator , $ query ) ; foreach ( $ parts as $ index => $ part ) { list ( $ key , $ value ) = $ this -> splitQueryValue ( $ part ) ; if ( $ value === null ) { $ parts [ $ index ] = $ this -> encodeQueryOrFragment ( $ key ) ; continue ; } $ parts [ $ index ] = sprintf ( '%s=%s' , $ this -> encodeQueryOrFragment ( $ key ) , $ this -> encodeQueryOrFragment ( $ value ) ) ; } return implode ( $ arg_separator , $ parts ) ; }
|
Encode a query string to ensure it is propertly encoded .
|
59,815
|
private function encodeFragment ( $ fragment ) { if ( ! empty ( $ fragment ) && $ fragment [ 0 ] === '#' ) $ fragment = '%23' . substr ( $ fragment , 1 ) ; return $ this -> encodeQueryOrFragment ( $ fragment ) ; }
|
Encodes a fragment value to ensure it is properly encoded .
|
59,816
|
public function validateAttribute ( $ model , $ attribute ) { if ( $ this -> targetClass !== null && $ model -> $ attribute instanceof $ this -> targetClass && ! empty ( $ model -> $ attribute -> isNewRecord ) ) { return ; } if ( $ model -> isRelationPopulated ( $ attribute ) ) { return ; } parent :: validateAttribute ( $ model , $ attribute ) ; }
|
Consider attribute value successfully validated if it is an instance of the given targetClass and this instance was just created
|
59,817
|
public static function Atio13 ( $ ri , $ di , $ utc1 , $ utc2 , $ dut1 , $ elong , $ phi , $ hm , $ xp , $ yp , $ phpa , $ tc , $ rh , $ wl , & $ aob , & $ zob , & $ hob , & $ dob , & $ rob ) { $ j ; $ astrom = new iauASTROM ( ) ; $ j = IAU :: Apio13 ( $ utc1 , $ utc2 , $ dut1 , $ elong , $ phi , $ hm , $ xp , $ yp , $ phpa , $ tc , $ rh , $ wl , $ astrom ) ; if ( $ j < 0 ) return $ j ; IAU :: Atioq ( $ ri , $ di , $ astrom , $ aob , $ zob , $ hob , $ dob , $ rob ) ; return $ j ; }
|
- - - - - - - - - - i a u A t i o 1 3 - - - - - - - - - -
|
59,818
|
public static function kernelAlias ( ) { if ( config ( 'alias.enable' ) ) { foreach ( array_get ( self :: $ aliases , 'kernel' ) as $ key => $ value ) { exception_if ( ( ! class_exists ( $ value ) && in_array ( $ key , self :: $ components ) ) , AliasedClassNotFoundException :: class , $ value , 'kernel' ) ; self :: set ( $ value , $ key ) ; } } }
|
Set aliases for kernel classes .
|
59,819
|
public static function appAlias ( ) { if ( config ( 'alias.enable' ) ) { foreach ( array_except ( self :: $ aliases , 'kernel' ) as $ array => $ aliases ) { foreach ( $ aliases as $ key => $ value ) { exception_if ( ! class_exists ( $ value ) , AliasedClassNotFoundException :: class , $ value , $ array ) ; self :: set ( $ value , $ key ) ; } } } }
|
Set aliases for app classes .
|
59,820
|
public static function update ( $ key , $ class ) { $ indexes = dot ( $ key ) ; self :: $ aliases [ $ indexes [ 0 ] ] = array_add ( self :: $ aliases [ $ indexes [ 0 ] ] , $ indexes [ 1 ] , $ class ) ; self :: $ aliases [ 'kernel' ] = config ( 'alias.kernel' ) ; Aliases :: set ( config ( 'alias.enable' ) , self :: $ aliases ) ; }
|
Update Aliases in alias file .
|
59,821
|
public static function clear ( $ key ) { self :: $ aliases [ $ key ] = [ ] ; self :: $ aliases [ 'kernel' ] = config ( 'alias.kernel' ) ; Aliases :: set ( config ( 'alias.enable' ) , self :: $ aliases ) ; }
|
Clear alias array .
|
59,822
|
public function readDirectory ( $ directory , $ recursive = true ) { if ( is_dir ( $ directory ) === false ) { return false ; } try { $ resource = opendir ( $ directory ) ; $ contents = array ( ) ; while ( false !== ( $ item = readdir ( $ resource ) ) ) { if ( in_array ( $ item , array ( '.' , '..' ) ) || substr ( $ item , 0 , 1 ) == '_' ) { continue ; } $ absoluteItem = $ directory . DIRECTORY_SEPARATOR . $ item ; if ( $ recursive === true && is_dir ( $ absoluteItem ) ) { $ contents [ $ item ] = $ this -> readDirectory ( $ absoluteItem , $ recursive ) ; } else { $ contents [ $ item ] = $ absoluteItem ; } } } catch ( \ Exception $ e ) { return false ; } return $ contents ; }
|
Reading the directory recursive
|
59,823
|
protected static function getFacadeClass ( ) { $ base = App :: make ( 'database.base' ) ; $ tables = Config :: get ( 'database.tables' ) ; return new LoginDispatcher ( $ base , $ tables ) ; }
|
get the login dispatcher facade
|
59,824
|
public function handleJoinCommand ( CommandEvent $ event , EventQueueInterface $ queue ) { $ params = $ event -> getCustomParams ( ) ; if ( ! $ params ) { $ this -> handleJoinHelp ( $ event , $ queue ) ; } else { $ channels = $ params [ 0 ] ; $ keys = isset ( $ params [ 1 ] ) ? $ params [ 1 ] : null ; $ queue -> ircJoin ( $ channels , $ keys ) ; } }
|
Handles a command to join a specified channel .
|
59,825
|
public function handlePartCommand ( CommandEvent $ event , EventQueueInterface $ queue ) { $ params = $ event -> getCustomParams ( ) ; if ( ! $ params ) { $ this -> handlePartHelp ( $ event , $ queue ) ; } else { $ channels = $ params [ 0 ] ; $ queue -> ircPart ( $ channels ) ; } }
|
Handles a command to part a specified channel .
|
59,826
|
public function index ( ) { $ packages = Packages :: all ( ) ; $ final_packages = [ ] ; foreach ( $ packages as $ package ) { $ sets = Setts :: get ( $ package ) ; if ( $ sets ) { $ final_packages [ $ package ] = Setts :: view ( $ package ) ; } } return view ( 'laralum_settings::index' , [ 'packages' => $ final_packages ] ) ; }
|
Display all the modules settings .
|
59,827
|
public function update ( Request $ request ) { $ this -> authorize ( 'update' , Settings :: class ) ; $ this -> validate ( $ request , [ 'appname' => 'required' , 'description' => 'required' , 'keywords' => 'required' , 'author' => 'required' , ] ) ; Settings :: first ( ) -> update ( [ 'appname' => $ request -> appname , 'description' => $ request -> description , 'keywords' => $ request -> keywords , 'author' => $ request -> author , ] ) ; return redirect ( ) -> route ( 'laralum::settings.index' , [ 'p' => 'Settings' ] ) -> with ( 'success' , __ ( 'laralum_settings::general.updated_settings' ) ) ; }
|
Update the general settings .
|
59,828
|
protected function buildMessage ( EmailEntity $ email ) { $ attachments = json_decode ( $ email -> getAttachments ( ) , true ) ? : [ ] ; $ attachments = array_map ( function ( $ attachment ) { if ( isset ( $ attachment [ 'content' ] ) ) { $ attachment [ 'data' ] = base64_decode ( Arr :: remove ( $ attachment , 'content' ) ) ; } if ( isset ( $ attachment [ 'name' ] ) ) { $ attachment [ 'filename' ] = Arr :: remove ( $ attachment , 'name' ) ; } if ( isset ( $ attachment [ 'type' ] ) ) { $ attachment [ 'contentType' ] = Arr :: remove ( $ attachment , 'type' ) ; } return attachment ; } , $ attachments ) ; if ( $ email -> getSenderName ( ) ) { $ from = "{$email->getSenderName()} <{$email->getSenderEmail()}>" ; } else { $ from = $ email -> getSenderEmail ( ) ; } if ( $ email -> getTemplateName ( ) ) { $ html = $ this -> templateService -> renderHbsForEmail ( $ email -> getTemplateName ( ) , $ email -> getTemplateData ( ) ? json_decode ( $ email -> getTemplateData ( ) , true ) : [ ] ) ; } else { $ html = $ email -> getMessage ( ) ; } $ message = [ 'html' => $ html , 'subject' => $ email -> getSubject ( ) , 'from' => $ from , 'to' => $ this -> filterThroughWhitelist ( $ email -> getRecipientEmail ( ) ) , 'attachments' => $ attachments , ] ; if ( $ email -> getHeaders ( ) ) { $ headers = [ ] ; foreach ( json_decode ( $ email -> getHeaders ( ) , true ) as $ key => $ value ) { $ headers [ "h:{$key}" ] = $ value ; } $ message [ 'headers' ] = $ headers ; } return $ message ; }
|
Build Mailgun compatible message array from email entity
|
59,829
|
public function render ( Framework $ framework , MenuEntry $ menuEntry ) { if ( ! $ menuEntry -> hasChildren ( ) ) { return '' ; } $ templatesManager = $ framework -> getInstance ( '\\Zepi\\Web\\General\\Manager\\TemplatesManager' ) ; $ htmlString = '' ; $ emptyChilds = array ( ) ; foreach ( $ menuEntry -> getChildren ( ) as $ child ) { if ( ! $ child -> hasChildren ( ) ) { $ emptyChilds [ ] = $ child ; } else { $ htmlString .= $ templatesManager -> renderTemplate ( '\\Zepi\\Web\\UserInterface\\Templates\\OverviewPageSection' , array ( 'menuEntry' => $ child ) ) ; } } $ htmlString = $ templatesManager -> renderTemplate ( '\\Zepi\\Web\\UserInterface\\Templates\\OverviewPageItems' , array ( 'children' => $ emptyChilds ) ) . $ htmlString ; return $ htmlString ; }
|
Renders a overview page for the given MenuEntry object
|
59,830
|
public function run ( ) { try { $ this -> command -> execute ( $ this -> console , $ this -> parser -> getArguments ( ) ) ; } catch ( \ Exception $ e ) { $ this -> writeException ( $ e ) ; if ( $ this -> exitOnException ) { exit ( $ e -> getCode ( ) ? : 1 ) ; } throw $ e ; } }
|
Parses input arguments and executes the Command
|
59,831
|
public function setContainer ( $ key , Placeholder \ HtmlClassContainer $ container ) { $ this -> registry -> setContainer ( $ key , $ container ) ; return $ this ; }
|
Set the container for an item in the registry .
|
59,832
|
public static function markup ( $ cost , $ total , $ round = false ) { if ( $ cost <= 0 ) { return ( float ) 0 ; } $ quotient = self :: div ( $ total , $ cost ) ; $ difference = self :: sub ( $ quotient , 1 ) ; $ product = self :: mul ( $ difference , 100 , $ round ) ; $ markup = $ round ? self :: round ( $ product ) : $ product ; return ( float ) $ markup ; }
|
Works out markup .
|
59,833
|
public static function margin ( $ cost , $ charge_out , $ round = false ) { if ( $ cost == $ charge_out ) { return ( float ) 0 ; } $ cost = self :: mul ( $ cost , - 1 ) ; $ numerator = self :: add ( $ cost , $ charge_out ) ; $ denominator = max ( abs ( $ cost ) , abs ( $ charge_out ) ) ; $ result = self :: div ( $ numerator , $ denominator ) ; $ product = self :: mul ( $ result , 100 ) ; $ margin = $ round ? self :: round ( $ product ) : $ product ; return ( float ) $ margin ; }
|
Works out margin .
|
59,834
|
public static function trim ( $ n ) { $ float = floatval ( $ n ) ; $ decimalPlaces = 0 ; while ( $ float != round ( $ float , $ decimalPlaces ) ) { $ decimalPlaces ++ ; } $ decimalPlaces = ( $ decimalPlaces < 2 ) ? 2 : $ decimalPlaces ; return number_format ( $ float , $ decimalPlaces , "." , "" ) ; }
|
Trims redundant trailing zeros
|
59,835
|
public function match ( string $ subject , $ flags = 0 , $ offset = 0 ) : int { $ this -> clean ( ) ; return preg_match ( $ this -> pattern , $ subject , $ this -> last_match , $ flags , $ offset ) ; }
|
Perform a regular expression match
|
59,836
|
public function replace ( $ replacement , $ subject , int $ limit = - 1 ) { $ this -> clean ( ) ; return preg_replace ( $ this -> pattern , $ replacement , $ subject , $ limit , $ this -> last_count ) ; }
|
Perform a regular expression search and replace
|
59,837
|
public function replaceCallback ( callable $ callback , $ subject , $ limit = - 1 , & $ count = null ) { $ this -> clean ( ) ; return preg_replace_callback ( $ this -> pattern , $ callback , $ subject , $ limit , $ count ) ; }
|
Perform a regular expression search and replace using a callback
|
59,838
|
public function each ( string $ subject , \ Closure $ closure , $ offset = 0 ) { if ( $ this -> matchAll ( $ subject , PREG_SET_ORDER , $ offset ) ) { foreach ( $ this -> getLastMatch ( ) as $ item ) { $ closure ( $ item ) ; } } }
|
Perform a global regular expression match and call function for everyone
|
59,839
|
public function getFileList ( $ config ) { if ( strpos ( $ config , ',' ) ) { return array_filter ( explode ( ',' , $ config ) ) ; } if ( ! $ this -> isAbsolutePath ( $ config ) ) { $ config = getcwd ( ) . '/' . $ config ; } if ( ! file_exists ( $ config ) ) { throw new InvalidArgumentException ( sprintf ( 'Configuration file "%s" does not exist.' , $ config ) ) ; } $ result = require $ config ; if ( $ result instanceof Config ) { return $ result -> getFilenames ( ) ; } if ( is_array ( $ result ) ) { return $ result ; } throw new InvalidArgumentException ( 'Config must return an array of filenames or a Config object.' ) ; }
|
Get a list of files in order .
|
59,840
|
public static function create ( $ request , array $ config = array ( ) ) { $ request = self :: getRequest ( $ request , isset ( $ config [ 'resolver' ] ) ? $ config [ 'resolver' ] : null ) ; if ( ! empty ( $ config [ 'adapter' ] [ 'class' ] ) ) { if ( ( $ info = self :: executeAdapter ( $ config [ 'adapter' ] [ 'class' ] , $ request , $ config ) ) ) { return $ info ; } } if ( ( $ info = self :: executeAdapter ( 'Embed\Adapters\File' , $ request , $ config ) ) ) { return $ info ; } $ adapter = 'Embed\\Adapters\\' . str_replace ( ' ' , '' , ucwords ( strtolower ( str_replace ( '-' , ' ' , $ request -> getDomain ( ) ) ) ) ) ; if ( class_exists ( $ adapter ) && ( $ info = self :: executeAdapter ( $ adapter , $ request , $ config ) ) ) { return $ info ; } if ( ( $ info = self :: executeAdapter ( 'Embed\Adapters\Webpage' , $ request , $ config ) ) ) { return $ info ; } if ( ! $ request -> isValid ( ) ) { throw new Exceptions \ InvalidUrlException ( "The url '{$request->getUrl()}' returns the http code '{$request->getHttpCode()}'" ) ; } throw new Exceptions \ InvalidUrlException ( "The url '{$request->getUrl()}' is not supported" ) ; }
|
Gets the info from an url
|
59,841
|
private static function executeAdapter ( $ adapter , Request $ request , array $ config = null ) { if ( ! in_array ( 'Embed\\Adapters\\AdapterInterface' , class_implements ( $ adapter ) ) ) { throw new \ InvalidArgumentException ( "The class '$adapter' must implements 'Embed\\Adapters\\AdapterInterface'" ) ; } if ( call_user_func ( [ $ adapter , 'check' ] , $ request ) ) { return new $ adapter ( $ request , $ config ) ; } return false ; }
|
Execute an adapter
|
59,842
|
private static function getRequest ( $ request , array $ config = null ) { if ( is_string ( $ request ) ) { return new Request ( $ request , isset ( $ config [ 'class' ] ) ? $ config [ 'class' ] : null , isset ( $ config [ 'config' ] ) ? $ config [ 'config' ] : [ ] ) ; } if ( ! ( $ request instanceof Request ) ) { throw new \ InvalidArgumentException ( "Embed::create only accepts instances of Embed\\Request or strings" ) ; } return $ request ; }
|
Init a request
|
59,843
|
public function getWebPathForResource ( Resource $ resource ) { $ relPath = Path :: makeRelative ( $ resource -> getRepositoryPath ( ) , $ this -> basePath ) ; return '/' . trim ( $ this -> mapping -> getWebPath ( ) . '/' . $ relPath , '/' ) ; }
|
Returns the install path of a resource in the target location .
|
59,844
|
public static function buildUrl ( $ parts ) { $ url = '' ; if ( isset ( $ parts [ 'scheme' ] ) ) { $ url .= $ parts [ 'scheme' ] . '://' ; } if ( isset ( $ parts [ 'user' ] ) ) { if ( isset ( $ parts [ 'pass' ] ) ) { $ url .= $ parts [ 'user' ] . ':' . $ parts [ 'pass' ] . '@' ; } else { $ url .= $ parts [ 'user' ] . '@' ; } } if ( isset ( $ parts [ 'host' ] ) ) { $ url .= $ parts [ 'host' ] ; } if ( isset ( $ parts [ 'port' ] ) ) { $ url .= ':' . $ parts [ 'port' ] ; } if ( isset ( $ parts [ 'path' ] ) ) { $ url .= $ parts [ 'path' ] ; } if ( isset ( $ parts [ 'query' ] ) ) { $ url .= '?' . $ parts [ 'query' ] ; } if ( isset ( $ parts [ 'fragment' ] ) ) { $ url .= '#' . $ parts [ 'fragment' ] ; } return $ url ; }
|
Build url from parts opposite of parse_url
|
59,845
|
public static function convertUtfUrl ( $ url ) { $ parts = ( array ) parse_url ( $ url ) ; if ( isset ( $ parts [ 'host' ] ) ) { if ( function_exists ( 'idn_to_ascii' ) ) { $ parts [ 'host' ] = idn_to_ascii ( $ parts [ 'host' ] ) ; } } if ( isset ( $ parts [ 'path' ] ) ) { $ parts [ 'path' ] = implode ( '/' , array_map ( 'urlencode' , explode ( '/' , $ parts [ 'path' ] ) ) ) ; } if ( isset ( $ parts [ 'query' ] ) ) { parse_str ( $ parts [ 'query' ] , $ query ) ; $ parts [ 'query' ] = http_build_query ( $ query ) ; } return self :: buildUrl ( $ parts ) ; }
|
Convert utf parts of urls
|
59,846
|
public function factory ( $ documentClass , DocumentIdentity $ identity = null ) { if ( ! isset ( $ this -> prototypes [ $ documentClass ] ) ) { $ document = new $ documentClass ( ) ; $ event = new DocumentEvent ( $ document ) ; $ this -> dispatcher -> dispatch ( IndexerEvents :: CREATE_DOCUMENT , $ event ) ; $ this -> prototypes [ $ documentClass ] = $ document ; } $ document = clone $ this -> prototypes [ $ documentClass ] ; $ document -> set ( '_document_class' , $ documentClass ) ; if ( $ identity ) { $ document -> setIdentity ( $ identity ) ; } return $ document ; }
|
Document factory .
|
59,847
|
public function beforePrepare ( Event $ event ) { $ operation = $ event [ 'command' ] -> getOperation ( ) ; $ client = $ event [ 'command' ] -> getClient ( ) ; if ( $ operation -> hasParam ( 'collection' ) === false ) return ; if ( is_null ( $ client -> getCollectionName ( ) ) ) return ; $ operation -> getParam ( 'collection' ) -> setDefault ( $ client -> getCollectionName ( ) ) ; $ operation -> getParam ( 'collection' ) -> setStatic ( true ) ; }
|
Inject the correct collection name for entity queries .
|
59,848
|
public function GetConfigurationFilePath ( $ fileName ) { return "APP_ROOT_DIR" . \ Puzzlout \ Framework \ Enums \ ApplicationFolderName :: AppsFolderName . \ Puzzlout \ Framework \ Helpers \ CommonHelper :: GetAppName ( ) . '/Config/' . $ fileName ; }
|
Builds the filePath to the configuration file .
|
59,849
|
public function ReturnFileContents ( $ nodeName ) { if ( file_exists ( $ this -> filePath ) ) { $ xml = new \ DOMDocument ; $ xml -> load ( $ this -> filePath ) ; return $ xml -> getElementsByTagName ( $ nodeName ) ; } return false ; }
|
Gets the content of a DOMDocument for a node name .
|
59,850
|
public function is_login ( $ table_name ) { $ user_info = $ this -> get_login_user_info ( $ table_name ) ; if ( $ user_info === false ) { return false ; } return true ; }
|
Check User Logging Status .
|
59,851
|
public function get_login_user_info ( $ table_name ) { $ user_info = $ this -> exdb -> session ( ) -> get ( 'user_info' ) ; if ( is_array ( @ $ user_info [ $ table_name ] ) ) { return $ user_info [ $ table_name ] ; } return false ; }
|
Get Login User Info .
|
59,852
|
public function preProcessMessage ( MessageInterface $ message ) { foreach ( $ this -> getProcessorStore ( ) -> getProcessors ( ) as $ processor ) { $ message = $ processor -> preProcessMessage ( $ message ) ; } return $ message ; }
|
PreProcess the message .
|
59,853
|
public function suck ( ) { if ( $ this -> endpoint instanceof PageableTallantoMethodInterface ) { $ this -> endpoint -> setPageNumber ( 1 ) -> setPageSize ( $ this -> maxPageSize ) ; } else { throw new \ Exception ( 'Tallanto pump works only with PageableTallantoMethodInterface endpoints.' ) ; } $ totalResult = [ ] ; do { $ suck = false ; $ this -> api -> execute ( $ this -> endpoint ) ; $ result = $ this -> endpoint -> getResult ( ) ; if ( is_array ( $ result ) ) { $ totalResult = array_merge ( $ totalResult , $ result ) ; if ( $ this -> endpoint instanceof PageableTallantoMethodInterface ) { $ suck = ( count ( $ totalResult ) != $ this -> endpoint -> getTotalItemsCount ( ) ) && ( $ this -> endpoint -> getTotalItemsCount ( ) > 0 ) ; if ( $ suck ) { $ this -> endpoint -> setPageNumber ( $ this -> endpoint -> getPageNumber ( ) + 1 ) ; } } } else { throw new ResponseDecodeException ( 'Expected array, got ' . gettype ( $ result ) ) ; } } while ( $ suck ) ; return $ totalResult ; }
|
Retrieves all items from the server for this endpoint .
|
59,854
|
public function save ( AggregateRoot $ aggregate ) { $ uncommitted = $ aggregate -> getChanges ( ) ; $ committedStream = $ this -> eventStore -> commit ( $ uncommitted ) ; if ( ! is_null ( $ this -> eventBus ) ) { $ this -> eventBus -> publish ( $ committedStream ) ; } if ( ! is_null ( $ this -> snapshotStore ) && $ this -> snapshottingPolicy -> shouldCreateSnapshot ( $ aggregate ) ) { $ this -> saveSnapshot ( $ aggregate ) ; } $ aggregate -> clearChanges ( ) ; return $ committedStream ; }
|
To store the updates made to an Aggregate we only need to commit the latest recorded events to the EventStore .
|
59,855
|
public function loadSnapshot ( Identity $ id ) { if ( is_null ( $ this -> snapshotStore ) ) { throw new \ Exception ( 'Unable to get snapshot; No store attached' ) ; } return $ this -> snapshotStore -> get ( $ id ) ; }
|
Load a aggregate snapshot from the storage
|
59,856
|
public function saveSnapshot ( AggregateRoot $ aggregate ) { if ( is_null ( $ this -> snapshotStore ) ) { throw new \ Exception ( 'Unable to create snapshot; No store attached' ) ; } if ( $ aggregate -> hasChanges ( ) ) { $ aggregate = $ aggregate :: reconstituteFrom ( new CommittedEvents ( $ aggregate -> getIdentity ( ) , $ aggregate -> getChanges ( ) -> getEvents ( ) ) ) ; } return $ this -> snapshotStore -> save ( $ aggregate ) ; }
|
Save the aggregate state as single snapshot instead of multiple history events
|
59,857
|
public function indexAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ version = $ request -> get ( 'version' ) ; $ mode = $ request -> get ( 'mode' , 'edit' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ elementtype = $ elementtypeService -> findElementtype ( $ id ) ; $ elementtypeStructure = $ elementtype -> getStructure ( ) ; $ rootNode = $ elementtypeStructure -> getRootNode ( ) ; $ type = $ elementtype -> getType ( ) ; $ children = [ ] ; $ rootDsId = '' ; $ rootType = 'root' ; if ( $ rootNode ) { $ rootDsId = $ rootNode -> getDsId ( ) ; $ rootType = $ rootNode -> getType ( ) ; $ children = $ elementtypeStructure -> getChildNodes ( $ rootNode -> getDsId ( ) ) ; } $ language = $ this -> getUser ( ) -> getInterfaceLanguage ( 'en' ) ; if ( ! $ language ) { $ language = 'en' ; } $ data = [ [ 'text' => $ elementtype -> getTitle ( $ language ) . ' [v' . $ elementtype -> getRevision ( ) . ', ' . $ elementtype -> getType ( ) . ']' , 'id' => md5 ( serialize ( $ rootNode ) ) , 'ds_id' => $ rootDsId , 'element_type_id' => $ elementtype -> getId ( ) , 'element_type_version' => $ elementtype -> getRevision ( ) , 'icon' => '/bundles/phlexibleelementtype/elementtypes/' . $ elementtype -> getIcon ( ) , 'cls' => 'p-elementtypes-type-' . $ type , 'leaf' => false , 'expanded' => true , 'type' => $ rootType , 'allowDrag' => ( $ type === Elementtype :: TYPE_REFERENCE ) , 'allowDrop' => $ mode === 'edit' , 'editable' => $ mode === 'edit' , 'properties' => [ 'root' => [ 'title' => $ elementtype -> getTitle ( $ language ) , 'reference_title' => $ elementtype -> getTitle ( $ language ) . ' [v' . $ elementtype -> getRevision ( ) . ']' , 'unique_id' => $ elementtype -> getUniqueId ( ) , 'icon' => $ elementtype -> getIcon ( ) , 'hide_children' => $ elementtype -> getHideChildren ( ) ? 'on' : '' , 'default_tab' => $ elementtype -> getDefaultTab ( ) , 'default_content_tab' => $ elementtype -> getDefaultContentTab ( ) , 'type' => $ type , 'template' => $ elementtype -> getTemplate ( ) , 'metaset' => $ elementtype -> getMetaSetId ( ) , 'comment' => $ elementtype -> getComment ( ) , ] , 'mappings' => $ elementtype -> getMappings ( ) , ] , 'children' => $ this -> recurseTree ( $ elementtypeStructure , $ children , $ language , $ mode , false , true ) , ] , ] ; return new JsonResponse ( $ data ) ; }
|
Return an Element Type Data Tree .
|
59,858
|
public function addInstance ( $ key , $ object = null ) { if ( \ is_object ( $ key ) ) { $ this -> storage -> instance ( \ get_class ( $ key ) , $ key ) ; } elseif ( \ is_object ( $ object ) ) { $ this -> storage -> instance ( $ key , $ object ) ; } else { throw new ContainerException ( 'An object instance must be passed' ) ; } }
|
Add a specific object instance to the container .
|
59,859
|
public function has ( $ key ) { return $ this -> storage -> hasObject ( $ key ) || $ this -> storage -> hasFactory ( $ key ) ; }
|
Check if a given key exists within this container either as an object or a factory .
|
59,860
|
public function get ( $ key ) { if ( ! \ is_string ( $ key ) || empty ( $ key ) ) { throw new ContainerException ( "$key must be a string" ) ; } if ( $ this -> storage -> hasStored ( $ key ) ) { return $ this -> storage -> getStored ( $ key ) ; } if ( $ this -> storage -> hasObject ( $ key ) ) { $ this -> storage -> store ( $ key , $ this -> storage -> getDefinition ( $ key ) ( $ this ) ) ; return $ this -> storage -> getStored ( $ key ) ; } if ( $ this -> storage -> hasFactory ( $ key ) ) { $ definition = $ this -> storage -> getFactory ( $ key ) ; return $ definition ( $ this ) ; } throw new NotFoundException ( "The key [$key] could not be found" ) ; }
|
Retrieves an object for a given key .
|
59,861
|
private function addToStack ( $ value ) { $ keys = \ array_keys ( $ this -> stack ) ; $ this -> stack [ \ end ( $ keys ) ] [ ] = $ value ; }
|
Adds a value the resolutions stack .
|
59,862
|
private function resolveFromContainer ( string $ className ) { if ( $ this -> has ( $ className ) ) { $ this -> addToStack ( $ this -> get ( $ className ) ) ; return true ; } return false ; }
|
Searches for a class name in the container and adds to resolutions if found .
|
59,863
|
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'config' ) [ 'mongoObjectMapper' ] ; $ client = self :: constructMongoClient ( @ $ config [ 'uri' ] , @ $ config [ 'options' ] ) ; $ mapperClass = 'MongoObject\Mapper' ; if ( isset ( $ config [ 'mapperClass' ] ) ) { $ mapperClass = $ config [ 'mapperClass' ] ; } return new $ mapperClass ( $ client -> selectDb ( $ config [ 'database' ] ) , @ $ config [ 'modelsNamespace' ] ) ; }
|
Create service - return new Mapper object
|
59,864
|
private static function constructMongoClient ( $ uri , $ options ) { if ( isset ( $ uri ) ) { if ( isset ( $ options ) ) { return new MongoClient ( $ uri , $ options ) ; } return new MongoClient ( $ uri ) ; } return new MongoClient ( ) ; }
|
Construct MongoClient object
|
59,865
|
public function load ( Repo $ repo ) { $ project = $ this -> client -> createProject ( $ this -> composerLoader -> getFile ( $ repo ) ) ; $ repo -> setDependencies ( $ project -> getDependencies ( ) ) ; return $ repo ; }
|
Load dependencies info
|
59,866
|
public function loadTranslationFileContent ( $ namespace , $ specificLocale ) { $ path = $ this -> buildPathFromNamespace ( $ namespace ) ; if ( $ path === false ) { return false ; } $ globalLocale = substr ( $ specificLocale , 0 , strpos ( $ specificLocale , '_' ) ) ; if ( $ globalLocale == '' ) { return false ; } $ specificFile = $ path . '/languages/' . $ specificLocale . '.zttf' ; $ globalFile = $ path . '/languages/' . $ globalLocale . '.zttf' ; $ content = $ this -> loadFileContent ( $ globalFile , $ specificFile ) ; return $ content ; }
|
Returns the content of the translation file if a translation file was found . Otherwise returns false .
|
59,867
|
protected function buildPathFromNamespace ( $ namespace ) { $ namespace = Framework :: prepareNamespace ( $ namespace ) ; $ moduleManager = $ this -> framework -> getModuleManager ( ) ; $ module = $ moduleManager -> getModule ( $ namespace ) ; if ( $ module === false ) { return false ; } return $ module -> getDirectory ( ) ; }
|
Returns the directory for the given module namespace
|
59,868
|
public static function getOdDoTableData ( $ table , $ col = "name" , $ id , $ timestamp = null , $ id2 = "id2" , $ od = "od" , $ do = "do" ) { DB :: connect ( ) ; return DB :: $ connection -> getOdDoTableData ( $ table , $ col , $ id , $ timestamp , $ id2 , $ od , $ do ) ; }
|
Funkcia vracia tabulkovu hodnotu akcie
|
59,869
|
public static function insert ( $ table , $ data = array ( ) , $ config = array ( ) ) { DB :: connect ( ) ; return DB :: $ connection -> insert ( $ table , $ data , $ config ) ; }
|
Funkcia vlozi data do tab skontroluje ci struktura je spravna snazi sa ju modifikovat
|
59,870
|
public function add ( EntityInterface $ user ) { if ( ! is_a ( $ user , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ user ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ user -> getName ( ) ) ) { throw new Exception ( 'Cannot add the user. Username is already in use.' ) ; } $ uuid = $ this -> accessControlManager -> addAccessEntity ( $ user ) ; if ( $ uuid === false ) { throw new Exception ( 'Cannot add the user. Internal software error.' ) ; } return $ user ; }
|
Adds the given user to the access entities
|
59,871
|
public function update ( EntityInterface $ user ) { if ( ! is_a ( $ user , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ user ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ user -> getUuid ( ) ) ) { throw new Exception ( 'Cannot update the user. User does not exist.' ) ; } return $ this -> accessControlManager -> updateAccessEntity ( $ user ) ; }
|
Updates the given user
|
59,872
|
public function delete ( EntityInterface $ user ) { if ( ! is_a ( $ user , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ user ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ user -> getUuid ( ) ) ) { throw new Exception ( 'Cannot delete the user. User does not exist.' ) ; } return $ this -> accessControlManager -> deleteAccessEntity ( $ user ) ; }
|
Deletes the user with the given uuid
|
59,873
|
public function hasUserForUuid ( $ uuid ) { if ( $ this -> accessControlManager -> hasAccessEntityForUuid ( self :: ACCESS_ENTITY_TYPE , $ uuid ) ) { return true ; } return false ; }
|
Returns true if the given uuid exists as access entity
|
59,874
|
public function hasUserForUsername ( $ username ) { if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ username ) ) { return true ; } return false ; }
|
Returns true if the given username exists as access entity
|
59,875
|
public function getUserForUsername ( $ username ) { if ( ! $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ username ) ) { return false ; } $ accessEntity = $ this -> accessControlManager -> getAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ username ) ; if ( $ accessEntity === false ) { return false ; } return $ accessEntity ; }
|
Returns the user object for the given username
|
59,876
|
public static function createFromDateInterval ( \ DateInterval $ interval ) { if ( $ interval instanceof DateInterval ) return $ interval ; $ ret = new DateInterval ( $ interval -> format ( 'P%yY%mM%dDT%hH%iM%sS' ) ) ; $ ret -> invert = $ interval -> invert ; return $ ret ; }
|
Create a DateInterval from an PHP Dateinterval
|
59,877
|
protected function convertToDateTime ( $ time ) { if ( $ time instanceof DateTime ) { return clone $ time ; } else if ( $ time instanceof \ DateTime ) { return new DateTime ( $ time -> format ( \ DateTime :: ISO8601 ) ) ; } else if ( is_numeric ( $ time ) ) { return new DateTime ( '@' . $ time ) ; } return new DateTime ( ( string ) $ time ) ; }
|
Convert to date - time
|
59,878
|
public function setDisplayIcon ( $ displayIcon ) { if ( empty ( $ displayIcon ) ) { $ displayIcon = array ( ) ; } else if ( $ displayIcon instanceof Traversable ) { $ displayIcon = ArrayUtils :: iteratorToArray ( $ displayIcon ) ; } else if ( ! is_array ( $ displayIcon ) ) { $ displayIcon = ( array ) $ displayIcon ; } $ this -> displayIcon = $ displayIcon ; return $ this ; }
|
Set display icon
|
59,879
|
public function setDisplayName ( $ displayName ) { if ( empty ( $ displayName ) ) { $ displayName = array ( ) ; } else if ( $ displayName instanceof Traversable ) { $ displayName = ArrayUtils :: iteratorToArray ( $ displayName ) ; } else if ( ! is_array ( $ displayName ) ) { $ displayName = ( array ) $ displayName ; } if ( ! isset ( $ displayName [ static :: FALLBACK_LOCALE ] ) ) { reset ( $ displayName ) ; $ key = key ( $ displayName ) ; $ displayName [ static :: FALLBACK_LOCALE ] = $ displayName [ $ key ] ; unset ( $ displayName [ $ key ] ) ; } $ this -> displayName = $ displayName ; return $ this ; }
|
Set display name
|
59,880
|
public function setDisplayDescription ( $ displayDescription ) { if ( empty ( $ displayDescription ) ) { $ displayDescription = array ( ) ; } else if ( $ displayDescription instanceof Traversable ) { $ displayDescription = ArrayUtils :: iteratorToArray ( $ displayDescription ) ; } else if ( ! is_array ( $ displayDescription ) ) { $ displayDescription = ( array ) $ displayDescription ; } if ( ! isset ( $ displayDescription [ static :: FALLBACK_LOCALE ] ) ) { reset ( $ displayDescription ) ; $ key = key ( $ displayDescription ) ; $ displayDescription [ static :: FALLBACK_LOCALE ] = $ displayDescription [ $ key ] ; unset ( $ displayDescription [ $ key ] ) ; } $ this -> displayDescription = $ displayDescription ; return $ this ; }
|
Set display description
|
59,881
|
public function getDisplayedIcon ( $ maxSize = self :: DEFAULT_ICON_SIZE ) { if ( empty ( $ this -> displayIcon ) ) { return null ; } $ foundSize = 0 ; $ foundIcon = null ; foreach ( $ this -> displayIcon as $ size => $ icon ) { if ( $ size >= $ foundSize && $ size <= $ maxSize ) { $ foundSize = $ size ; $ foundIcon = $ icon ; } } if ( ! empty ( $ foundIcon ) ) { $ replace = array ( '%version%' => '0' , '%reference%' => '-' , ) ; if ( ! empty ( $ this -> availableVersion ) ) { $ replace [ '%version%' ] = $ this -> availableVersion ; } else if ( ! empty ( $ this -> installedVersion ) ) { $ replace [ '%version%' ] = $ this -> installedVersion ; } if ( ! empty ( $ this -> availableReference ) ) { $ replace [ '%reference%' ] = $ this -> availableReference ; } else if ( ! empty ( $ this -> installedReference ) ) { $ replace [ '%reference%' ] = $ this -> installedReference ; } $ foundIcon = strtr ( $ foundIcon , $ replace ) ; } return $ foundIcon ; }
|
Get displayed icon
|
59,882
|
public function getDisplayedName ( $ locale = self :: FALLBACK_LOCALE ) { if ( ! empty ( $ this -> displayName [ $ locale ] ) ) { return $ this -> displayName [ $ locale ] ; } $ language = Locale :: getPrimaryLanguage ( $ locale ) ; if ( ! empty ( $ this -> displayName [ $ language ] ) ) { return $ this -> displayName [ $ language ] ; } if ( ! empty ( $ this -> displayName [ static :: FALLBACK_LOCALE ] ) ) { return $ this -> displayName [ static :: FALLBACK_LOCALE ] ; } if ( ! empty ( $ this -> description ) && strpos ( $ this -> description , "\n" ) ) { list ( $ name , $ description ) = explode ( "\n" , $ this -> description , 2 ) ; return $ name ; } return $ this -> name ; }
|
Get displayed name
|
59,883
|
public function getDisplayedDescription ( $ locale = self :: FALLBACK_LOCALE ) { if ( ! empty ( $ this -> displayDescription [ $ locale ] ) ) { return $ this -> displayDescription [ $ locale ] ; } $ language = Locale :: getPrimaryLanguage ( $ locale ) ; if ( ! empty ( $ this -> displayDescription [ $ language ] ) ) { return $ this -> displayDescription [ $ language ] ; } if ( ! empty ( $ this -> displayDescription [ static :: FALLBACK_LOCALE ] ) ) { return $ this -> displayDescription [ static :: FALLBACK_LOCALE ] ; } if ( ! empty ( $ this -> description ) && strpos ( $ this -> description , "\n" ) ) { list ( $ name , $ description ) = explode ( "\n" , $ this -> description , 2 ) ; return $ description ; } return $ this -> description ; }
|
Get displayed description
|
59,884
|
public function getDisplayedAuthors ( $ locale = self :: FALLBACK_LOCALE ) { $ result = array ( ) ; $ mapper = $ this -> getMapper ( ) ; foreach ( $ this -> authors as $ author ) { if ( $ mapper && ! empty ( $ author [ 'email' ] ) && ( $ user = $ mapper -> getUserByEmail ( $ author [ 'email' ] ) ) ) { $ insert = array ( 'name' => $ user -> displayName , 'url' => '/app/' . $ locale . '/user/view/' . rawurlencode ( $ user -> displayName ) , ) ; } else if ( ! empty ( $ author [ 'name' ] ) || ! empty ( $ author [ 'email' ] ) ) { $ insert = array ( 'name' => isset ( $ author [ 'name' ] ) ? $ author [ 'name' ] : strstr ( $ author [ 'email' ] , '@' , true ) , 'url' => isset ( $ author [ 'homepage' ] ) ? $ author [ 'homepage' ] : null , ) ; } else { continue ; } $ result [ ] = $ insert ; } return $ result ; }
|
Get displayed authors
|
59,885
|
public function getLicenseUris ( ) { $ result = array ( ) ; $ mapper = $ this -> getMapper ( ) ; $ licenseUrlPatterns = array ( '/^cc-(by-sa|by-nd|by-nc|by-nc-sa|by-nc-nd)-(\d+\.\d+)$/i' => function ( $ matches ) { return 'http://creativecommons.org/licenses/' . strtolower ( $ matches [ 1 ] ) . '/' . $ matches [ 2 ] ; } , '/^cc0-(\d+\.\d+)$/i' => 'http://creativecommons.org/publicdomain/zero/$1' , '/^Apache-(\d+\.\d+)$/i' => 'http://www.apache.org/licenses/LICENSE-$1' , '/^Artistic-(\d+)\.(\d+)$/i' => 'http://www.perlfoundation.org/artistic_license_$1_$2' , '/^GPL-(\d+\.\d+)\+?$/i' => 'http://www.gnu.org/licenses/gpl-$1-standalone.html' , '/^LGPL-(\d+\.\d+)\+?$/i' => 'http://www.gnu.org/licenses/lgpl-$1-standalone.html' , '/^MIT$/i' => 'http://opensource.org/licenses/MIT' , '/^proprietary/i' => '' , '/^([^\(].*)$/i' => function ( $ matches ) use ( $ mapper ) { static $ uris = array ( 'http://opensource.org/licenses/%s' , 'http://spdx.org/licenses/%s' ) ; if ( empty ( $ mapper ) ) { return '' ; } foreach ( $ uris as $ uriPattern ) { $ uri = vsprintf ( $ uriPattern , $ matches ) ; if ( $ mapper -> getHttpClient ( $ uri ) -> send ( ) -> isOk ( ) ) { return $ uri ; } } return '' ; } , ) ; foreach ( $ this -> license as $ license ) { foreach ( $ licenseUrlPatterns as $ pattern => $ replacement ) { $ count = 0 ; $ method = is_callable ( $ replacement ) ? 'preg_replace_callback' : 'preg_replace' ; $ uri = $ method ( $ pattern , $ replacement , $ license , 1 , $ count ) ; if ( $ count && $ uri ) { $ result [ $ license ] = $ uri ; continue 2 ; } } $ result [ $ license ] = '' ; } return $ result ; }
|
Get license uris
|
59,886
|
public function hasResource ( $ resource ) { if ( ! isset ( $ this -> resourcesCached [ $ resource ] ) ) { if ( isset ( $ this -> resources [ $ resource ] ) ) { $ this -> resourcesCached [ $ resource ] = $ this -> resources [ $ resource ] ; } else { $ found = false ; foreach ( $ this -> resources as $ resourceName ) { $ regex = str_replace ( array ( "\*" , "\?" ) , array ( '.*' , '.' ) , preg_quote ( $ resourceName ) ) ; if ( preg_match ( '/^' . $ regex . '$/is' , $ resource ) ) { $ found = true ; } } $ this -> resourcesCached [ $ resource ] = $ found ; } } return $ this -> resourcesCached [ $ resource ] ; }
|
Checking if this service handles given resource .
|
59,887
|
protected function getDefaultCommands ( ) { $ commands = parent :: getDefaultCommands ( ) ; foreach ( $ commands as $ command ) { if ( 'list' === $ command -> getName ( ) ) { if ( method_exists ( $ commands , 'setHidden' ) ) { $ command -> setHidden ( true ) ; } elseif ( method_exists ( $ command , 'setPrivate' ) ) { $ commands -> setPrivate ( true ) ; } } } return $ commands ; }
|
Override the default commands to hide the list command by default .
|
59,888
|
private function camelize ( Dispatcher $ dispatcher , $ actionName ) { $ dispatcher -> setActionName ( lcfirst ( Text :: camelize ( $ actionName ) ) ) ; return $ this ; }
|
Camelize action name
|
59,889
|
public function addBadgePercentage ( $ percentage , $ toolTipLabel = null , $ url = null ) { $ percentage = min ( 100 , max ( 0 , floor ( $ percentage ) ) ) ; $ color = AVH :: getPercentageColor ( $ percentage ) ; return $ this -> addBadge ( $ percentage . '%' , $ color , $ toolTipLabel , $ url ) ; }
|
Automatic percentage display
|
59,890
|
public function addBadges ( array $ badges ) { foreach ( $ badges as $ badge ) { if ( ! is_array ( $ badge ) ) { throw new \ Osf \ Exception \ ArchException ( 'Bad badges value' ) ; } call_user_func_array ( [ $ this , 'addBadge' ] , $ badge ) ; } return $ this ; }
|
Add further badges
|
59,891
|
protected function getBadgeHtml ( $ label , $ colorOrStatus = null , $ toolTipLabel = null , $ url = null ) { $ element = 'span' ; if ( $ colorOrStatus === null ) { $ color = 'black' ; } else if ( in_array ( $ colorOrStatus , AVH :: STATUS_LIST ) ) { Checkers :: checkStatus ( $ colorOrStatus , 'default' ) ; $ color = AVH :: STATUS_COLOR_LIST [ $ colorOrStatus ] ; } else { Checkers :: checkColor ( $ colorOrStatus ) ; $ color = $ colorOrStatus ; } $ attributes = [ 'class' => 'badge bg-' . $ color ] ; if ( $ toolTipLabel !== null ) { $ attributes [ 'data-toggle' ] = 'tooltip' ; $ attributes [ 'title' ] = $ toolTipLabel ; } if ( $ url ) { $ element = 'a' ; $ attributes [ 'href' ] = $ url ; } if ( strlen ( $ label ) > 30 ) { Checkers :: notice ( 'Badge label [' . $ label . '] is probably too long' ) ; } return Html :: buildHtmlElement ( $ element , $ attributes , $ label ) ; }
|
Build HTML code of a badge
|
59,892
|
protected function getBadgesHtml ( array $ badges = null ) { if ( $ badges === null ) { $ badges = $ this -> badges ; } $ html = '' ; foreach ( $ badges as $ badge ) { $ html .= $ this -> getBadgeHtml ( $ badge [ 0 ] , $ badge [ 1 ] , $ badge [ 2 ] , $ badge [ 3 ] ) ; } return $ html ; }
|
Build HTML code of badges
|
59,893
|
public function filter ( $ value ) { $ params = ( array ) $ this -> options [ 'callback_params' ] ; array_unshift ( $ params , $ value ) ; return call_user_func_array ( $ this -> options [ 'callback' ] , $ params ) ; }
|
Calls the filter per callback
|
59,894
|
public function getTab ( ) { $ this -> processMessage ( ) ; if ( $ this -> countAll === 0 && $ this -> hideEmpty ) { return ; } return '<span title="FileMailer"><svg><path style="fill:#' . ( $ this -> countNew > 0 ? 'E90D0D' : '348AD2' ) . '" d="m 0.9 4.5 6.6 7 c 0 0 0 0 0 0 0.2 0.1 0.3 0.2 0.4 0.2 0.1 0 0.3 -0 0.4 -0.2 l 0 -0 L 15.1 4.5 0.9 4.5 z M 0 5.4 0 15.6 4.8 10.5 0 5.4 z m 16 0 L 11.2 10.5 16 15.6 16 5.4 z M 5.7 11.4 0.9 16.5 l 14.2 0 -4.8 -5.1 -1 1.1 -0 0 -0 0 c -0.4 0.3 -0.8 0.5 -1.2 0.5 -0.4 0 -0.9 -0.2 -1.2 -0.5 l -0 -0 -0 -0 -1 -1.1 z" /></svg><span class="tracy-label">' . ( $ this -> countNew > 0 ? $ this -> countNew : NULL ) . '</span></span>' ; }
|
Returns HTML code for Tracy bar icon .
|
59,895
|
public function getPanel ( ) { if ( $ this -> countAll === 0 && $ this -> hideEmpty ) { return ; } $ this -> processMessage ( ) ; $ latte = new \ Latte \ Engine ; $ latte -> setTempDirectory ( $ this -> fileMailer -> getTempDirectory ( ) ) ; return $ latte -> renderToString ( __DIR__ . '/MailPanel.latte' , [ 'messages' => $ this -> messages , 'countNew' => $ this -> countNew , 'countAll' => $ this -> countAll , 'show' => $ this -> show , ] ) ; }
|
Returns HTML code of panel .
|
59,896
|
private function processMessage ( ) { if ( $ this -> processed ) { return ; } $ this -> processed = TRUE ; $ files = glob ( $ this -> fileMailer -> getTempDirectory ( ) . DIRECTORY_SEPARATOR . '*.' . FileMailer :: FILE_EXTENSION ) ; foreach ( $ files as $ path ) { $ cacheKey = basename ( $ path ) ; if ( $ this -> removeExpired ( $ path ) ) { $ this -> cache -> remove ( $ cacheKey ) ; continue ; } $ message = $ this -> cache -> load ( $ cacheKey ) ; if ( $ message === NULL ) { $ message = FileMailer :: mailParser ( file_get_contents ( $ path ) , $ cacheKey ) ; $ this -> cache -> save ( $ cacheKey , $ message ) ; } $ time = new DateTime ; if ( $ message -> date > $ time -> modify ( $ this -> newMessageTime ) ) { $ this -> countNew ++ ; } else { $ message -> isOld = TRUE ; } $ this -> countAll ++ ; $ this -> messages [ ] = $ message ; } usort ( $ this -> messages , function ( $ a1 , $ a2 ) { return $ a2 -> date -> getTimestamp ( ) - $ a1 -> date -> getTimestamp ( ) ; } ) ; }
|
Process all messages .
|
59,897
|
private function removeExpired ( $ path ) { if ( $ this -> autoremove ) { $ now = new DateTime ; $ file_date = new DateTime ( '@' . filemtime ( $ path ) ) ; $ file_date -> setTimezone ( $ now -> getTimezone ( ) ) ; $ remove_date = $ now -> modify ( $ this -> autoremove ) ; if ( $ file_date < $ remove_date ) { unlink ( $ path ) ; return TRUE ; } } return FALSE ; }
|
Auto removes email file when expired .
|
59,898
|
public function handleDownload ( $ filename , $ filehash ) { $ message = $ this -> cache -> load ( $ filename ) ; $ file = $ message -> attachments [ $ filehash ] ; header ( "Content-Type: $file->type; charset='UTF-8'" ) ; header ( "Content-Transfer-Encoding: base64" ) ; header ( "Content-Disposition: attachment; filename=\"$file->filename\"" ) ; header ( 'Content-Length: ' . strlen ( $ file -> data ) ) ; echo base64_decode ( $ file -> data ) ; exit ; }
|
Download attachment from file .
|
59,899
|
protected function getConnectedUserMediaPerimeter ( $ siteId ) { $ user = $ this -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; if ( $ user -> hasRole ( ContributionRoleInterface :: PLATFORM_ADMIN ) || $ user -> hasRole ( ContributionRoleInterface :: DEVELOPER ) ) { return null ; } $ userGroups = $ user -> getGroups ( ) ; $ folderIds = array ( ) ; foreach ( $ userGroups as $ group ) { if ( $ group -> hasRole ( MediaContributionRoleInterface :: MEDIA_CONTRIBUTOR ) && $ group -> getSite ( ) -> getSiteId ( ) == $ siteId ) { foreach ( $ group -> getPerimeter ( MediaFolderInterface :: ENTITY_TYPE ) -> getItems ( ) as $ path ) { foreach ( $ this -> get ( 'open_orchestra_media.repository.media_folder' ) -> findSubTreeByPath ( $ path ) as $ folder ) { $ folderIds [ $ folder -> getId ( ) ] = $ folder -> getId ( ) ; } } } } return $ folderIds ; }
|
Return folder ids included in the allowed perimeter to the user for media contribution
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.