idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
22,700 | protected function getArgumentsString ( ) { $ arguments = array ( $ this -> getIdentifierArgumentString ( ) ) ; if ( $ this -> hasRelations ( ) ) { $ arguments [ ] = $ this -> getRelationArgumentsString ( ) ; } return implode ( ', ' , $ arguments ) ; } | Return comma separated Sahi DOM arguments . |
22,701 | protected function useOutputWalker ( Query $ query ) { if ( null === $ this -> useOutputWalkers ) { return false === ( bool ) $ query -> getHint ( Query :: HINT_CUSTOM_OUTPUT_WALKER ) ; } return $ this -> useOutputWalkers ; } | Determines whether to use an output walker for the query . |
22,702 | protected function appendTreeWalker ( Query $ query , $ walkerClass ) { $ hints = $ query -> getHint ( Query :: HINT_CUSTOM_TREE_WALKERS ) ; if ( false === $ hints ) { $ hints = [ ] ; } $ hints [ ] = $ walkerClass ; $ query -> setHint ( Query :: HINT_CUSTOM_TREE_WALKERS , $ hints ) ; } | Appends a custom tree walker to the tree walkers hint . |
22,703 | public function arrayToXml ( $ arrayData = [ ] ) { $ xml = '<?xml version="1.0" encoding="UTF-8"?>' ; $ xml .= '<root>' ; foreach ( $ arrayData as $ key => $ value ) { $ xml .= '<xml_data>' ; if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ xml .= "<$k>" ; $ xml .= "<![CDATA[$v]]>" ; $ xml .= "</$k>" ; } } else { $ xml .= "<$key>" ; $ xml .= "<![CDATA[$value]]>" ; $ xml .= "</$key>" ; } $ xml .= '</xml_data>' ; } $ xml .= '</root>' ; return $ xml ; } | function definition to convert array to xml send an array and get xml . |
22,704 | public function formatSQL ( $ sql = '' ) { $ reserveSqlKey = 'select|insert|update|delete|truncate|drop|create|add|except|percent|all|exec|plan|alter|execute|precision|and|exists|primary|any|exit|print|as|fetch|proc|asc|file|procedure|authorization|fillfactor|public|backup|for|raiserror|begin|foreign|read|between|freetext|readtext|break|freetexttable|reconfigure|browse|from|references|bulk|full|replication|by|function|restore|cascade|goto|restrict|case|grant|return|check|group|revoke|checkpoint|having|right|close|holdlock|rollback|clustered|identity|rowcount|coalesce|identity_insert|rowguidcol|collate|identitycol|rule|column|if|save|commit|in|schema|compute|index|select|constraint|inner|session_user|contains|insert|set|containstable|intersect|setuser|continue|into|shutdown|convert|is|some|create|join|statistics|cross|key|system_user|current|kill|table|current_date|left|textsize|current_time|like|then|current_timestamp|lineno|to|current_user|load|top|cursor|national|tran|database|nocheck|transaction|dbcc|nonclustered|trigger|deallocate|not|truncate|declare|null|tsequal|default|nullif|union|delete|of|unique|deny|off|update|desc|offsets|updatetext|disk|on|use|distinct|open|user|distributed|opendatasource|values|double|openquery|varying|drop|openrowset|view|dummy|openxml|waitfor|dump|option|when|else|or|where|end|order|while|errlvl|outer|with|escape|over|writetext|absolute|overlaps|action|pad|ada|partial|external|pascal|extract|position|allocate|false|prepare|first|preserve|float|are|prior|privileges|fortran|assertion|found|at|real|avg|get|global|relative|go|bit|bit_length|both|rows|hour|cascaded|scroll|immediate|second|cast|section|catalog|include|char|session|char_length|indicator|character|initially|character_length|size|input|smallint|insensitive|space|int|sql|collation|integer|sqlca|sqlcode|interval|sqlerror|connect|sqlstate|connection|sqlwarning|isolation|substring|constraints|sum|language|corresponding|last|temporary|count|leading|time|level|timestamp|timezone_hour|local|timezone_minute|lower|match|trailing|max|min|translate|date|minute|translation|day|module|trim|month|true|dec|names|decimal|natural|unknown|nchar|deferrable|next|upper|deferred|no|usage|none|using|describe|value|descriptor|diagnostics|numeric|varchar|disconnect|octet_length|domain|only|whenever|work|end-exec|write|year|output|zone|exception|free|admin|general|after|reads|aggregate|alias|recursive|grouping|ref|host|referencing|array|ignore|result|returns|before|role|binary|initialize|rollup|routine|blob|inout|row|boolean|savepoint|breadth|call|scope|search|iterate|large|sequence|class|lateral|sets|clob|less|completion|limit|specific|specifictype|localtime|constructor|localtimestamp|sqlexception|locator|cube|map|current_path|start|current_role|state|cycle|modifies|statement|data|modify|static|structure|terminate|than|nclob|depth|new|deref|destroy|treat|destructor|object|deterministic|old|under|dictionary|operation|unnest|ordinality|out|dynamic|each|parameter|variable|equals|parameters|every|without|path|postfix|prefix|preorder' ; $ list = explode ( '|' , $ reserveSqlKey ) ; foreach ( $ list as & $ verb ) { $ verb = '/\b' . preg_quote ( $ verb , '/' ) . '\b/' ; } $ regex_sign = [ '/\b' , '\b/' ] ; return str_replace ( $ regex_sign , '' , preg_replace ( $ list , array_map ( [ $ this , 'highlight_sql' , ] , $ list ) , strtolower ( $ sql ) ) ) ; } | Format the SQL Query . |
22,705 | public function displayHtmlTable ( $ aColList = [ ] ) { $ r = '' ; if ( count ( $ aColList ) > 0 ) { $ r .= '<table border="1">' ; $ r .= '<thead>' ; $ r .= '<tr>' ; foreach ( $ aColList [ 0 ] as $ k => $ v ) { $ r .= '<td>' . $ k . '</td>' ; } $ r .= '</tr>' ; $ r .= '</thead>' ; $ r .= '<tbody>' ; foreach ( $ aColList as $ record ) { $ r .= '<tr>' ; foreach ( $ record as $ data ) { $ r .= '<td>' . $ data . '</td>' ; } $ r .= '</tr>' ; } $ r .= '</tbody>' ; $ r .= '<table>' ; } else { $ r .= '<div class="no-results">No results found for query.</div>' ; } return $ r ; } | Get HTML Table with Data Send complete array data and get an HTML table with mysql data . |
22,706 | public function validate ( $ value , Constraint $ constraint ) { if ( ! $ value ) { return ; } $ fileHistory = $ this -> em -> getRepository ( 'JbFileUploaderBundle:FileHistory' ) -> find ( $ value ) ; if ( ! $ fileHistory ) { return ; } if ( ! $ fileHistory -> getUserId ( ) ) { return ; } $ token = $ this -> tokenStorage -> getToken ( ) ; if ( ! $ token ) { return $ this -> createViolation ( $ value , $ constraint ) ; } $ user = $ token -> getUser ( ) ; if ( ! $ user ) { return $ this -> createViolation ( $ value , $ constraint ) ; } if ( $ user -> getId ( ) !== $ fileHistory -> getUserId ( ) ) { return $ this -> createViolation ( $ value , $ constraint ) ; } return ; } | Validate that the submitted file is owned by the authenticated user |
22,707 | protected function createViolation ( $ value , Constraint $ constraint ) { $ this -> context -> buildViolation ( $ constraint -> message ) -> setParameter ( '%filename%' , $ value ) -> addViolation ( ) ; } | Create violation for validator |
22,708 | protected function getCropResolver ( $ endpoint ) { $ cropedResolver = $ this -> configuration -> getValue ( $ endpoint , 'croped_resolver' ) ; if ( ! $ cropedResolver ) { throw new JbFileUploaderException ( 'No croped_resolver configuration for endpoint ' . $ endpoint ) ; } return $ cropedResolver ; } | Get crop resolver configuration |
22,709 | private function loadAssetsFromConfig ( $ content , $ dir , $ type = null , $ isFromVendor = false , $ siteName = '' ) { $ newContent = $ content ; $ assetsConfig = $ dir . 'assets.config.php' ; if ( file_exists ( $ assetsConfig ) ) { $ files = include ( $ assetsConfig ) ; if ( ! empty ( $ files ) ) { foreach ( $ files as $ key => $ file ) { if ( empty ( $ type ) ) { $ cssToAdd = "\n" ; $ jsToLoad = "\n" ; if ( strtolower ( $ key ) == 'css' ) { foreach ( $ file as $ k => $ css ) { $ css = str_replace ( '/public' , '' , $ css ) ; $ css = $ this -> editFileName ( $ css , $ isFromVendor , $ siteName ) ; $ cssToAdd .= '<link href="' . $ css . '" media="screen" rel="stylesheet" type="text/css">' . "\n" ; } } elseif ( strtolower ( $ key ) == 'js' ) { foreach ( $ file as $ k => $ js ) { $ js = str_replace ( '/public' , '' , $ js ) ; $ js = $ this -> editFileName ( $ js , $ isFromVendor , $ siteName ) ; $ jsToLoad .= '<script type="text/javascript" src="' . $ js . '"></script>' . "\n" ; } } $ newContent = $ this -> createLink ( $ newContent , $ cssToAdd , $ jsToLoad ) ; } elseif ( $ type == 'css' ) { if ( strtolower ( $ key ) == 'css' ) { $ cssToAdd = "\n" ; foreach ( $ file as $ k => $ css ) { $ css = str_replace ( '/public' , '' , $ css ) ; $ css = $ this -> editFileName ( $ css , $ isFromVendor , $ siteName ) ; $ cssToAdd .= '<link href="' . $ css . '" media="screen" rel="stylesheet" type="text/css">' . "\n" ; } $ newContent = $ this -> createCssLink ( $ content , $ cssToAdd ) ; } } elseif ( $ type == 'js' ) { if ( strtolower ( $ key ) == 'js' ) { $ jsToLoad = "\n" ; foreach ( $ file as $ k => $ js ) { $ js = str_replace ( '/public' , '' , $ js ) ; $ js = $ this -> editFileName ( $ js , $ isFromVendor , $ siteName ) ; $ jsToLoad .= '<script type="text/javascript" src="' . $ js . '"></script>' . "\n" ; } $ newContent = $ this -> createJsLink ( $ content , $ jsToLoad ) ; } } } } } return $ newContent ; } | Function to get all the assets for the config to load if the bundle does nt exist |
22,710 | private function editFileName ( $ fileName , $ isFromVendor , $ siteName ) { if ( $ isFromVendor ) { $ pathInfo = explode ( '/' , $ fileName ) ; for ( $ i = 0 ; $ i <= sizeof ( $ pathInfo ) ; $ i ++ ) { if ( ! empty ( $ pathInfo [ 1 ] ) ) { if ( str_replace ( '-' , '' , ucwords ( $ pathInfo [ 1 ] , '-' ) ) == $ siteName ) { $ fileName = preg_replace ( '/' . $ pathInfo [ 1 ] . '/' , $ siteName , $ fileName , 1 ) ; } } } } return $ fileName ; } | Edit the filename only if site came from vendor to make the module name camel case Ex . melis - demo - cms turns into MelisDemoCms |
22,711 | public function form ( Fluent $ model ) { return $ this -> form -> of ( 'orchestra.install' , function ( FormGrid $ form ) use ( $ model ) { $ form -> fieldset ( \ trans ( 'orchestra/foundation::install.steps.account' ) , function ( Fieldset $ fieldset ) use ( $ model ) { $ this -> userForm ( $ fieldset , $ model ) ; } ) ; $ form -> fieldset ( \ trans ( 'orchestra/foundation::install.steps.application' ) , function ( Fieldset $ fieldset ) use ( $ model ) { $ this -> applicationForm ( $ fieldset , $ model ) ; } ) ; } ) ; } | Create form . |
22,712 | protected function applicationForm ( Fieldset $ fieldset , Fluent $ model ) : void { $ fieldset -> control ( 'text' , 'site_name' ) -> label ( \ trans ( 'orchestra/foundation::label.name' ) ) -> value ( \ data_get ( $ model , 'site.name' ) ) -> attributes ( [ 'autocomplete' => 'off' ] ) ; } | Application form section . |
22,713 | protected function userForm ( Fieldset $ fieldset , Fluent $ model ) : void { $ fieldset -> control ( 'input:email' , 'email' ) -> label ( \ trans ( 'orchestra/foundation::label.users.email' ) ) ; $ fieldset -> control ( 'password' , 'password' ) -> label ( \ trans ( 'orchestra/foundation::label.users.password' ) ) ; $ fieldset -> control ( 'text' , 'fullname' ) -> label ( \ trans ( 'orchestra/foundation::label.users.fullname' ) ) -> value ( 'Administrator' ) ; } | User form section . |
22,714 | protected function _renderInlineTag ( $ string ) { $ string = $ this -> engine -> inlineParser -> parse ( $ string ) ; $ string = ( ! $ this -> _firstLine ) ? " $string" : $ string ; $ this -> _firstLine = false ; return ( $ string ) ; } | Rendering of the text insed a paragraph . |
22,715 | public function setText ( $ text ) { $ this -> text = $ text ; $ this -> encodeManager -> setData ( $ text ) ; return $ this ; } | Set text to hide in QR Code |
22,716 | public function setForegroundColor ( $ foregroundColor ) { if ( is_null ( $ this -> frontColor ) ) { $ this -> frontColor = new Color ; } $ this -> frontColor -> setFromArray ( $ foregroundColor ) ; return $ this ; } | Set foreground color of the QR Code |
22,717 | public function setBackgroundColor ( $ backgroundColor ) { if ( is_null ( $ this -> backColor ) ) { $ this -> backColor = new Color ; } $ this -> backColor -> setFromArray ( $ backgroundColor ) ; return $ this ; } | Set background color of the QR Code |
22,718 | public function getModuleSize ( ) { if ( is_null ( $ this -> moduleSize ) ) { $ this -> moduleSize = $ this -> getImageFormat ( ) == "jpeg" ? 8 : 4 ; } return $ this -> moduleSize ; } | Return QR Code module size |
22,719 | private function autoVersionAndGetMaxDataBits ( $ codewordNumPlus , $ dataBitsTotal ) { $ i = 1 + 40 * $ this -> getEccCharacter ( ) ; $ j = $ i + 39 ; $ version = 1 ; while ( $ i <= $ j ) { $ maxDataBits = $ this -> getMaxDataBitsByIndexFormArray ( $ i ) ; if ( ( $ maxDataBits ) >= ( $ dataBitsTotal + $ codewordNumPlus [ $ version ] ) ) { $ this -> setVersion ( $ version ) ; return $ maxDataBits ; } $ i ++ ; $ version ++ ; } return 0 ; } | Auto version select and Get Max Data Bits |
22,720 | public static function remember ( $ key , $ seconds , Closure $ callback , $ initDir = '/' , $ basedir = 'cache' ) { $ debug = \ Bitrix \ Main \ Data \ Cache :: getShowCacheStat ( ) ; if ( $ seconds <= 0 ) { try { $ result = $ callback ( ) ; } catch ( AbortCacheException $ e ) { $ result = null ; } if ( $ debug ) { CacheDebugger :: track ( 'zero_ttl' , $ initDir , $ basedir , $ key , $ result ) ; } return $ result ; } $ obCache = new CPHPCache ( ) ; if ( $ obCache -> InitCache ( $ seconds , $ key , $ initDir , $ basedir ) ) { $ vars = $ obCache -> GetVars ( ) ; if ( $ debug ) { CacheDebugger :: track ( 'hits' , $ initDir , $ basedir , $ key , $ vars [ 'cache' ] ) ; } return $ vars [ 'cache' ] ; } $ obCache -> StartDataCache ( ) ; try { $ cache = $ callback ( ) ; $ obCache -> EndDataCache ( [ 'cache' => $ cache ] ) ; } catch ( AbortCacheException $ e ) { $ obCache -> AbortDataCache ( ) ; $ cache = null ; } if ( $ debug ) { CacheDebugger :: track ( 'misses' , $ initDir , $ basedir , $ key , $ cache ) ; } return $ cache ; } | Store closure s result in the cache for a given number of seconds . |
22,721 | public static function rememberForever ( $ key , Closure $ callback , $ initDir = '/' , $ basedir = 'cache' ) { return static :: remember ( $ key , 99999999 , $ callback , $ initDir , $ basedir ) ; } | Store closure s result in the cache for a long time . |
22,722 | public static function flushAll ( ) { $ GLOBALS [ "CACHE_MANAGER" ] -> cleanAll ( ) ; $ GLOBALS [ "stackCacheManager" ] -> cleanAll ( ) ; $ staticHtmlCache = StaticHtmlCache :: getInstance ( ) ; $ staticHtmlCache -> deleteAll ( ) ; BXClearCache ( true ) ; } | Flushes all bitrix cache . |
22,723 | public function getParam ( $ param ) { if ( isset ( $ this -> _parentConfig ) ) return ( $ this -> _parentConfig -> getParam ( $ param ) ) ; return ( isset ( $ this -> _params [ $ param ] ) ? $ this -> _params [ $ param ] : null ) ; } | Returns a specific configuration parameter . If a parent configuration object exists the parameter is asked to it . |
22,724 | public function titleToIdentifier ( $ depth , $ text ) { $ func = $ this -> getParam ( 'titleToIdFunction' ) ; if ( isset ( $ func ) ) { return ( $ func ( $ depth , $ text ) ) ; } $ text = htmlentities ( $ text , ENT_NOQUOTES , 'utf-8' ) ; $ text = preg_replace ( '#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#' , '\1' , $ text ) ; $ text = preg_replace ( '#&([A-za-z]{2})(?:lig);#' , '\1' , $ text ) ; $ text = preg_replace ( '#&([lr]s|sb|[lrb]d)(quo);#' , ' ' , $ text ) ; $ text = str_replace ( ' ' , ' ' , $ text ) ; $ text = preg_replace ( '#&[^;]+;#' , '' , $ text ) ; $ text = preg_replace ( "/[^a-zA-Z0-9_-]/" , ' ' , $ text ) ; $ text = str_replace ( ' ' , '-' , $ text ) ; $ text = preg_replace ( '/\s+/' , " " , $ text ) ; $ text = preg_replace ( '/-+/' , "-" , $ text ) ; $ text = trim ( $ text , '-' ) ; $ text = trim ( $ text ) ; $ text = empty ( $ text ) ? '-' : $ text ; return ( $ text ) ; } | Convert title string to a usable HTML identifier . |
22,725 | public function onStart ( $ text ) { if ( $ this -> getParam ( 'convertSmileys' ) ) $ text = Smiley :: convertSmileys ( $ text ) ; if ( $ this -> getParam ( 'convertSymbols' ) ) $ text = Smiley :: convertSymbols ( $ text ) ; $ func = $ this -> getParam ( 'preParseFunction' ) ; if ( isset ( $ func ) ) $ text = $ func ( $ text ) ; return ( $ text ) ; } | Method called for pre - parse processing . |
22,726 | public function onParse ( $ finalText ) { $ func = $ this -> getParam ( 'postParseFunction' ) ; if ( isset ( $ func ) ) $ finalText = $ func ( $ finalText ) ; if ( $ this -> getParam ( 'addFootnotes' ) ) { $ footnotes = $ this -> getFootnotes ( ) ; if ( ! empty ( $ footnotes ) ) $ finalText .= "\n" . $ footnotes ; } return ( $ finalText ) ; } | Method called for post - parse processing . |
22,727 | public function processLink ( $ url , $ tagName = '' ) { $ label = $ url = trim ( $ url ) ; $ targetBlank = $ this -> getParam ( 'targetBlank' ) ; $ nofollow = $ this -> getParam ( 'nofollow' ) ; if ( $ this -> getParam ( 'shortenLongUrl' ) && strlen ( $ label ) > 40 ) $ label = substr ( $ label , 0 , 40 ) . '...' ; if ( substr ( $ url , 0 , strlen ( 'javascript:' ) ) === 'javascript:' ) $ url = '#' ; else { if ( filter_var ( $ url , FILTER_VALIDATE_EMAIL ) ) { $ url = "mailto:$url" ; $ targetBlank = $ nofollow = false ; } else if ( substr ( $ url , 0 , strlen ( 'mailto:' ) ) === 'mailto:' ) { $ label = substr ( $ url , strlen ( 'mailto:' ) ) ; $ targetBlank = $ nofollow = false ; } $ func = $ this -> getParam ( 'urlProcessFunction' ) ; if ( isset ( $ func ) ) list ( $ url , $ label , $ targetBlank , $ nofollow ) = $ func ( $ url , $ label , $ targetBlank , $ nofollow ) ; } return ( array ( $ url , $ label , $ targetBlank , $ nofollow ) ) ; } | Links processing . |
22,728 | public function addTocEntry ( $ depth , $ title , $ identifier ) { if ( ! isset ( $ this -> _toc ) ) $ this -> _toc = array ( ) ; $ this -> _addTocSubEntry ( $ depth , $ depth , $ title , $ identifier , $ this -> _toc ) ; } | Add a TOC entry . |
22,729 | public function getToc ( $ raw = false ) { if ( $ raw === true ) return ( $ this -> _toc [ 'sub' ] ) ; $ html = "<b>On this page:</b>" . $ this -> _getRenderedToc ( $ this -> _toc [ 'sub' ] ) ; return ( $ html ) ; } | Returns the TOC content . By default the rendered HTML is returned but the raw TOC tree is available . |
22,730 | public function addFootnote ( $ text , $ label = null ) { if ( isset ( $ this -> _parentConfig ) ) return ( $ this -> _parentConfig -> addFootnote ( $ text , $ label ) ) ; if ( is_null ( $ label ) ) $ this -> _footnotes [ ] = $ text ; else $ this -> _footnotes [ ] = array ( 'label' => $ label , 'text' => $ text ) ; $ index = count ( $ this -> _footnotes ) ; return ( array ( 'id' => $ this -> getParam ( 'footnotesPrefix' ) . "-$index" , 'index' => $ index ) ) ; } | Add a footnote . |
22,731 | public function getFootnotes ( $ raw = false ) { if ( $ raw === true ) return ( $ this -> _footnotes ) ; if ( empty ( $ this -> _footnotes ) ) return ( null ) ; $ footnotes = '' ; $ index = 1 ; foreach ( $ this -> _footnotes as $ note ) { $ id = $ this -> getParam ( 'footnotesPrefix' ) . "-$index" ; $ noteHtml = "<p class=\"footnote\"><a href=\"#cite_ref-$id\" name=\"cite_note-$id\" id=\"cite_note-$id\">" ; if ( is_string ( $ note ) ) $ noteHtml .= "$index</a>. $note" ; else $ noteHtml .= htmlspecialchars ( $ note [ 'label' ] ) . "</a>. " . $ note [ 'text' ] ; $ noteHtml .= "</p>\n" ; $ footnotes .= $ noteHtml ; $ index ++ ; } $ footnotes = "<div class=\"footnotes\">\n$footnotes</div>\n" ; return ( $ footnotes ) ; } | Returns the footnotes content . By default the rendered HTML is returned but the raw list of footnotes is available . |
22,732 | private function _addTocSubEntry ( $ depth , $ level , $ title , $ identifier , & $ list ) { if ( ! isset ( $ list [ 'sub' ] ) ) $ list [ 'sub' ] = array ( ) ; $ offset = count ( $ list [ 'sub' ] ) ; if ( $ depth === 1 ) { $ list [ 'sub' ] [ $ offset ] = array ( 'id' => $ identifier , 'value' => $ title ) ; return ; } $ offset -- ; if ( ! isset ( $ list [ 'sub' ] [ $ offset ] ) ) $ list [ 'sub' ] [ $ offset ] = array ( ) ; $ this -> _addTocSubEntry ( $ depth - 1 , $ level , $ title , $ identifier , $ list [ 'sub' ] [ $ offset ] ) ; } | Add a sub - TOC entry . |
22,733 | private function key ( int $ length , string $ extraChars = '' ) : string { $ licenseKey = '' ; $ codeAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' . $ extraChars ; $ alphabetLength = strlen ( $ codeAlphabet ) ; $ log = log ( $ alphabetLength , 2 ) ; $ bytes = ( int ) ( $ log / 8 ) + 1 ; $ bits = ( int ) $ log + 1 ; $ filter = ( int ) ( 1 << $ bits ) - 1 ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { do { $ rnd = hexdec ( bin2hex ( openssl_random_pseudo_bytes ( $ bytes ) ) ) ; $ rnd = $ rnd & $ filter ; } while ( $ rnd >= $ alphabetLength ) ; $ licenseKey .= $ codeAlphabet [ $ rnd ] ; } return $ licenseKey ; } | Generates a new license key . |
22,734 | public function printStyles ( ) { foreach ( $ this -> styles as $ key => $ options ) { $ href = ( is_string ( $ options [ 'src' ] ) ) ? $ options [ 'src' ] : $ this -> getStyleLink ( $ key ) ; if ( $ options [ 'with_version' ] ) { $ href = call_user_func_array ( $ this -> assetInsertMethod , [ $ href , $ this -> assetVersion ] ) ; } echo "<link rel='stylesheet' href='" . $ href . "' type='text/css' media='" . $ options [ "media" ] . "' />\n" ; } } | Display links to loaded css files |
22,735 | public function enqueueStyle ( $ slug , $ src = false , $ media = 'all' , $ withVersion = true ) { $ this -> styles [ $ slug ] = [ 'src' => $ src , 'media' => $ media , 'with_version' => $ withVersion , ] ; } | Add css file to the loader |
22,736 | public function printInlineScript ( $ print = true ) { $ this -> scriptNonces [ ] = ( $ nonce = $ this -> newNonce ( ) ) ; if ( $ print ) { echo "<script type='text/javascript' nonce='" . $ nonce . "'>" . $ this -> scriptInline . "</script>\n" ; } else { return "<script type='text/javascript' nonce='" . $ nonce . "'>" . $ this -> scriptInline . "</script>\n" ; } } | Dispaly or return script balsie with all inline script loaded |
22,737 | public function printScript ( ) { foreach ( $ this -> scripts as $ key => $ options ) { $ src = ( is_string ( $ options [ 'src' ] ) ) ? $ options [ 'src' ] : $ this -> getScriptLink ( $ key ) ; if ( $ options [ 'with_version' ] ) { $ src = call_user_func_array ( $ this -> assetInsertMethod , [ $ src , $ this -> assetVersion ] ) ; } echo "<script type='text/javascript' src='$src'></script>\n" ; } $ this -> printInlineScript ( ) ; } | Display links to loaded javascripts files and loaded inline script |
22,738 | public function enqueueScript ( $ slug , $ src = false , $ withVersion = true ) { $ this -> scripts [ $ slug ] = [ 'src' => $ src , 'with_version' => $ withVersion , ] ; } | Add javascript file to the loader |
22,739 | public function get ( $ format = null ) { if ( ! is_null ( $ format ) ) $ this -> setFormat ( $ format ) ; ob_start ( ) ; call_user_func ( $ this -> getFunctionName ( ) , $ this -> getImage ( ) ) ; return ob_get_clean ( ) ; } | Create QR Code and return its content |
22,740 | public function save ( $ filename ) { $ this -> setFilename ( $ filename ) ; call_user_func_array ( $ this -> getFunctionName ( ) , [ $ this -> getImage ( ) , $ filename ] ) ; return $ filename ; } | Render the QR Code then save it to given file name |
22,741 | public function add ( SpecificationContract $ specification ) { $ this -> items -> put ( $ specification -> uid ( ) , $ specification ) ; return $ this ; } | Add requirement specification . |
22,742 | public function check ( ) : bool { return $ this -> installable = $ this -> items -> filter ( function ( $ specification ) { return $ specification -> check ( ) === false && $ specification -> optional ( ) === false ; } ) -> isEmpty ( ) ; } | Check all requirement . |
22,743 | private function getEtag ( ResourceObject $ ro , HttpCache $ httpCache = null ) : string { $ etag = $ httpCache instanceof HttpCache && $ httpCache -> etag ? $ this -> getEtagByPartialBody ( $ httpCache , $ ro ) : $ this -> getEtagByEitireView ( $ ro ) ; return ( string ) \ crc32 ( \ get_class ( $ ro ) . $ etag ) ; } | Return crc32 encoded Etag |
22,744 | public function onValidate ( ValidationEvent $ event ) { try { $ this -> validator -> validate ( $ event -> getType ( ) , $ event -> getFile ( ) , 'upload_validators' ) ; } catch ( JbFileUploaderValidationException $ e ) { throw new ValidationException ( $ e -> getMessage ( ) , null , $ e ) ; } } | Validate a submited file |
22,745 | public function encode ( $ data , $ ttl ) { $ expire = null ; if ( $ ttl !== null ) { $ expire = time ( ) + $ ttl ; } return serialize ( array ( $ data , $ expire ) ) ; } | Encodes some data to a string so it can be written to disk |
22,746 | private function setTemplatePath ( $ templatePath ) { $ return = false ; if ( is_string ( $ templatePath ) ) { if ( $ this -> checkTemplatePath ( $ templatePath ) === true ) { $ this -> templatePath [ ] = $ templatePath ; $ return = true ; } } else if ( is_array ( $ templatePath ) ) { foreach ( $ templatePath as $ path ) { if ( $ this -> checkTemplatePath ( $ path ) === true ) { $ this -> templatePath [ ] = $ path ; $ return = true ; } } } return $ return ; } | set the template - path or use the path from config |
22,747 | private function checkTemplatePath ( $ templatePath , $ exitOnError = true ) { if ( ! is_dir ( $ templatePath ) ) { if ( $ exitOnError === true ) { exit ( ) ; } return false ; } else { return true ; } } | check if the the template - directory exists |
22,748 | private function optimizer ( ) { $ optimizeOption = - 1 ; if ( $ this -> environment [ 'cache' ] === false ) { $ optimizeOption = 2 ; } switch ( $ optimizeOption ) { case - 1 : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_ALL ; break ; case 0 : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_NONE ; break ; case 2 : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_FOR ; break ; case 4 : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_RAW_FILTER ; break ; case 8 : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_VAR_ACCESS ; break ; default : $ nodeVisitorOptimizer = Twig_NodeVisitor_Optimizer :: OPTIMIZE_ALL ; break ; } $ optimizer = new Twig_Extension_Optimizer ( $ nodeVisitorOptimizer ) ; $ this -> twig -> addExtension ( $ optimizer ) ; } | optimize twig - output |
22,749 | public function render ( $ withHeader = true ) { if ( isset ( $ _GET [ 'twigDebug' ] ) && $ _GET [ 'twigDebug' ] == 1 ) { $ this -> debug ( ) ; } $ this -> template = $ this -> twig -> loadTemplate ( $ this -> filename ) ; if ( $ withHeader === true ) { header ( 'X-UA-Compatible: IE=edge,chrome=1' ) ; header ( 'Content-Type: text/html; charset=utf-8' ) ; } return $ this -> template -> render ( $ this -> data ) ; } | render the template |
22,750 | public function build ( ) { $ params = [ ] ; if ( $ this -> value !== null ) { $ op = ! is_null ( $ this -> operator ) ? $ this -> operator : '=' ; $ paramName = str_replace ( '.' , '_' , $ this -> key ) ; if ( $ op == 'BETWEEN' ) { $ sql = "{$this->key} $op ? AND ?" ; $ between = explode ( 'AND' , $ this -> value ) ; $ params [ ':dateFrom' ] = trim ( $ between [ 0 ] ) ; $ params [ ':dateTo' ] = trim ( $ between [ 1 ] ) ; } else { $ sql = "{$this->key} $op ?" ; $ params [ ":{$paramName}" ] = $ this -> value ; } } else { $ sql = $ sql = "{$this->key} IS NULL " ; } return [ $ sql , $ params ] ; } | Build function . |
22,751 | public function getFormat ( ) { switch ( true ) { case ( $ this -> encoder instanceof Base32Encoder ) : $ format = self :: FORMAT_BASE32 ; break ; case ( $ this -> encoder instanceof HexEncoder ) : $ format = self :: FORMAT_HEX ; break ; case ( $ this -> encoder instanceof RawEncoder ) : default : $ format = self :: FORMAT_RAW ; } return $ format ; } | Get the output format |
22,752 | public function setFormat ( $ format ) { switch ( $ format ) { case self :: FORMAT_BASE32 : $ this -> encoder = new Base32Encoder ( ) ; break ; case self :: FORMAT_HEX : $ this -> encoder = new HexEncoder ( ) ; break ; case self :: FORMAT_RAW : default : $ this -> encoder = new RawEncoder ( ) ; } return $ this ; } | Set the output format |
22,753 | public function setValue ( $ value , $ format = null ) { $ this -> value = $ this -> decode ( $ value , $ format ) ; } | Set the seed value optionally specifying an input format |
22,754 | private function decode ( $ seed , $ format = null ) { $ encoder = new RawEncoder ( ) ; if ( $ format === null ) { if ( preg_match ( '/^[0-9a-f]+$/i' , $ seed ) ) { $ encoder = new HexEncoder ( ) ; } elseif ( preg_match ( '/^[2-7a-z]+$/i' , $ seed ) ) { $ encoder = new Base32Encoder ( ) ; } } else { if ( $ format == self :: FORMAT_HEX ) { $ encoder = new HexEncoder ( ) ; } elseif ( $ format == self :: FORMAT_BASE32 ) { $ encoder = new Base32Encoder ( ) ; } } $ output = $ encoder -> decode ( $ seed ) ; return $ output ; } | Attempt to decode a seed value |
22,755 | private function encode ( $ seed , $ format = null ) { $ encoder = $ this -> encoder ; if ( $ format == self :: FORMAT_HEX ) { $ encoder = new HexEncoder ( ) ; } elseif ( $ format == self :: FORMAT_BASE32 ) { $ encoder = new Base32Encoder ( ) ; } elseif ( $ format == self :: FORMAT_RAW ) { $ encoder = new RawEncoder ( ) ; } $ output = $ encoder -> encode ( $ seed ) ; return $ output ; } | Attempt to encode a seed value |
22,756 | public function init_template_loader ( ) { $ loader_class = $ this -> hasConfigKey ( 'template' , 'custom_loader' ) ? $ this -> getConfigKey ( 'template' , 'custom_loader' ) : $ this -> get_default_template_loader_class ( ) ; $ filter_prefix = $ this -> hasConfigKey ( 'template' , 'filter_prefix' ) ? $ this -> getConfigKey ( 'template' , 'filter_prefix' ) : $ this -> get_default_filter_prefix ( ) ; $ template_dir = $ this -> hasConfigKey ( 'template' , 'template_directory' ) ? $ this -> getConfigKey ( 'template' , 'template_directory' ) : $ this -> get_default_template_directory ( ) ; $ view_dir = $ this -> hasConfigKey ( 'view' ) ? $ this -> get_directory_from_view ( $ this -> getConfigKey ( 'view' ) ) : $ this -> get_default_view_directory ( ) ; return new $ loader_class ( $ filter_prefix , $ template_dir , $ view_dir ) ; } | Initialize the template loader class . |
22,757 | private function prepare ( $ args ) { $ bindings = array ( ) ; if ( count ( $ args ) == 2 ) { $ bindings [ $ args [ 0 ] ] = $ args [ 1 ] ; } elseif ( is_array ( $ args [ 0 ] ) ) { $ bindings = $ args [ 0 ] ; } return $ bindings ; } | Prepares binding parameters . |
22,758 | private function replace ( $ bindings ) { $ search = array_keys ( $ bindings ) ; $ replace = array_values ( $ bindings ) ; foreach ( $ search as $ key => & $ value ) { $ value = $ this -> delimiters [ 0 ] . $ value . $ this -> delimiters [ 1 ] ; } array_walk_recursive ( $ this -> rules , function ( & $ value , $ key ) use ( $ search , $ replace ) { $ value = str_ireplace ( $ search , $ replace , $ value ) ; } ) ; } | Replaces binding occurrences . |
22,759 | public function registerJob ( string $ jobName , callable $ callback ) : bool { $ this -> callbacks [ $ jobName ] = $ callback ; $ this -> jobSocket -> subscribe ( $ jobName ) ; $ this -> replySocket -> send ( json_encode ( [ 'request' => 'register_job' , 'worker_id' => $ this -> workerId , 'job_name' => $ jobName ] ) ) ; $ response = $ this -> replySocket -> recv ( ) ; return ( $ response === 'ok' ) ; } | Registers a type of job the worker is able to do . |
22,760 | protected function createJobSocket ( ) { $ jobContext = new Context ( $ this -> loop ) ; $ this -> jobSocket = $ jobContext -> getSocket ( \ ZMQ :: SOCKET_SUB ) ; $ this -> jobSocket -> connect ( $ this -> config [ 'sockets' ] [ 'worker_job' ] ) ; $ this -> jobSocket -> on ( 'messages' , [ $ this , 'onJobMessage' ] ) ; } | Creates socket to receive jobs from server and registers corresponding callbacks . |
22,761 | protected function createReplySocket ( ) { $ replyContext = new \ ZMQContext ; $ this -> replySocket = $ replyContext -> getSocket ( \ ZMQ :: SOCKET_REQ ) ; $ this -> replySocket -> connect ( $ this -> config [ 'sockets' ] [ 'worker_reply' ] ) ; } | Creates socket used to reply to server . |
22,762 | public function onJobMessage ( array $ message ) : bool { $ jobName = $ message [ 0 ] ; $ jobId = $ message [ 1 ] ; $ workerId = $ message [ 2 ] ; $ payload = $ message [ 3 ] ; if ( $ workerId !== $ this -> workerId ) { return false ; } if ( ! isset ( $ this -> callbacks [ $ jobName ] ) ) { throw new WorkerException ( 'No callback found for requested job.' ) ; } $ this -> jobId = $ jobId ; $ this -> setState ( Worker :: WORKER_STATE_BUSY ) ; $ result = call_user_func ( $ this -> callbacks [ $ jobName ] , $ payload ) ; $ this -> onJobCompleted ( $ result ) ; $ this -> setState ( Worker :: WORKER_STATE_IDLE ) ; return true ; } | Handles job requests received from server . |
22,763 | protected function setState ( int $ state ) : bool { $ this -> workerState = $ state ; $ this -> replySocket -> send ( json_encode ( [ 'request' => 'change_state' , 'worker_id' => $ this -> workerId , 'state' => $ this -> workerState ] ) ) ; $ response = $ this -> replySocket -> recv ( ) ; return ( $ response === 'ok' ) ; } | Sets a new worker state and reports this state to server . |
22,764 | protected function onJobCompleted ( string $ result ) : bool { $ this -> replySocket -> send ( json_encode ( [ 'request' => 'job_completed' , 'worker_id' => $ this -> workerId , 'job_id' => $ this -> jobId , 'result' => $ result ] ) ) ; $ response = $ this -> replySocket -> recv ( ) ; $ this -> jobId = null ; return ( $ response === 'ok' ) ; } | Sends results of a job back to server . |
22,765 | protected function loadConfig ( ) { $ options = getopt ( 'c:' ) ; if ( ! isset ( $ options [ 'c' ] ) ) { throw new WorkerException ( 'No path to configuration provided.' ) ; } $ pathToConfig = $ options [ 'c' ] ; if ( ! file_exists ( $ pathToConfig ) ) { throw new WorkerException ( 'Config file not found.' ) ; } $ this -> config = require $ pathToConfig ; } | Loads configuration from config file passed in via argument . |
22,766 | public function run ( ) { try { $ this -> loop -> run ( ) ; } catch ( WorkerException $ e ) { $ this -> logger -> error ( 'Worker Error: ' . $ e -> getMessage ( ) ) ; } } | Run main loop and wait for jobs . |
22,767 | protected function handleGET ( ) { $ serviceName = $ this -> getOAuthServiceName ( ) ; if ( ! empty ( $ serviceName ) ) { $ service = ServiceManager :: getService ( $ serviceName ) ; $ serviceGroup = $ service -> getServiceTypeInfo ( ) -> getGroup ( ) ; if ( $ serviceGroup !== ServiceTypeGroups :: OAUTH ) { throw new BadRequestException ( 'Invalid login service provided. Please use an OAuth service.' ) ; } return $ service -> handleLogin ( $ this -> request -> getDriver ( ) ) ; } return Session :: getPublicInfo ( ) ; } | Gets basic user session data and performs OAuth login redirect . |
22,768 | protected function handlePOST ( ) { $ serviceName = $ this -> getOAuthServiceName ( ) ; if ( empty ( $ serviceName ) ) { $ credentials = [ 'email' => $ this -> getPayloadData ( 'email' ) , 'username' => $ this -> getPayloadData ( 'username' ) , 'password' => $ this -> getPayloadData ( 'password' ) , 'is_sys_admin' => false ] ; return $ this -> handleLogin ( $ credentials , boolval ( $ this -> getPayloadData ( 'remember_me' ) ) ) ; } $ service = ServiceManager :: getService ( $ serviceName ) ; $ serviceGroup = $ service -> getServiceTypeInfo ( ) -> getGroup ( ) ; switch ( $ serviceGroup ) { case ServiceTypeGroups :: LDAP : if ( config ( 'df.enable_windows_auth' , false ) === true && $ service -> getServiceTypeInfo ( ) -> getName ( ) === 'adldap' ) { $ username = array_get ( $ _SERVER , 'LOGON_USER' , array_get ( $ _SERVER , 'REMOTE_USER' ) ) ; if ( ! empty ( $ username ) ) { return $ service -> handleWindowsAuth ( $ username ) ; } } $ credentials = [ 'username' => $ this -> getPayloadData ( 'username' ) , 'password' => $ this -> getPayloadData ( 'password' ) ] ; return $ service -> handleLogin ( $ credentials , $ this -> getPayloadData ( 'remember_me' ) ) ; case ServiceTypeGroups :: OAUTH : $ oauthCallback = $ this -> request -> getParameterAsBool ( 'oauth_callback' ) ; if ( ! empty ( $ oauthCallback ) ) { return $ service -> handleOAuthCallback ( ) ; } else { return $ service -> handleLogin ( $ this -> request -> getDriver ( ) ) ; } default : throw new BadRequestException ( 'Invalid login service provided. Please use an OAuth or AD/Ldap service.' ) ; } } | Authenticates valid user . |
22,769 | protected function getOAuthServiceName ( ) { $ serviceName = $ this -> getPayloadData ( 'service' , $ this -> request -> getParameter ( 'service' ) ) ; if ( empty ( $ serviceName ) ) { $ state = $ this -> getPayloadData ( 'state' , $ this -> request -> getParameter ( 'state' ) ) ; if ( empty ( $ state ) ) { $ state = $ this -> getPayloadData ( 'oauth_token' , $ this -> request -> getParameter ( 'oauth_token' ) ) ; } if ( ! empty ( $ state ) ) { $ key = BaseOAuthService :: CACHE_KEY_PREFIX . $ state ; $ serviceName = \ Cache :: pull ( $ key ) ; } } return $ serviceName ; } | Retrieves OAuth service name from request param payload or using state identifier . |
22,770 | protected function handleLogin ( array $ credentials = [ ] , $ remember = false ) { $ loginAttribute = strtolower ( config ( 'df.login_attribute' , 'email' ) ) ; if ( $ loginAttribute === 'username' ) { $ username = array_get ( $ credentials , 'username' ) ; if ( empty ( $ username ) ) { throw new BadRequestException ( 'Login request is missing required username.' ) ; } unset ( $ credentials [ 'email' ] ) ; } else { $ email = array_get ( $ credentials , 'email' ) ; if ( empty ( $ email ) ) { throw new BadRequestException ( 'Login request is missing required email.' ) ; } unset ( $ credentials [ 'username' ] ) ; } $ password = array_get ( $ credentials , 'password' ) ; if ( empty ( $ password ) ) { throw new BadRequestException ( 'Login request is missing required password.' ) ; } $ credentials [ 'is_active' ] = 1 ; if ( ! class_exists ( '\DreamFactory\Core\User\Resources\System\User' ) ) { $ credentials [ 'is_sys_admin' ] = 1 ; } if ( Session :: authenticate ( $ credentials , $ remember , true , $ this -> getAppId ( ) ) ) { return Session :: getPublicInfo ( ) ; } else { throw new UnauthorizedException ( 'Invalid credentials supplied.' ) ; } } | Performs login . |
22,771 | public function prepareMiniTemplateConfig ( ) { $ pluginsFormat = array ( ) ; $ userSites = $ _SERVER [ 'DOCUMENT_ROOT' ] . '/../module/MelisSites' ; if ( file_exists ( $ userSites ) && is_dir ( $ userSites ) ) { $ sites = $ this -> getDir ( $ userSites ) ; if ( ! empty ( $ sites ) ) { foreach ( $ sites as $ key => $ val ) { $ publicFolder = $ userSites . DIRECTORY_SEPARATOR . $ val . DIRECTORY_SEPARATOR . 'public' ; $ miniTplPath = $ publicFolder . DIRECTORY_SEPARATOR . 'miniTemplatesTinyMce' ; if ( file_exists ( $ miniTplPath ) && is_dir ( $ miniTplPath ) ) { $ pluginsConfig = include __DIR__ . '/../config/plugins/MiniTemplatePlugin.config.php' ; if ( ! empty ( $ pluginsConfig ) ) { $ tpls = array_diff ( scandir ( $ miniTplPath ) , array ( '..' , '.' ) ) ; if ( ! empty ( $ tpls ) ) { $ pluginsConfig [ 'melis' ] [ 'subcategory' ] [ 'title' ] = $ val ; $ pluginsConfig [ 'melis' ] [ 'subcategory' ] [ 'id' ] = $ pluginsConfig [ 'melis' ] [ 'subcategory' ] [ 'id' ] . '_' . $ val ; foreach ( $ tpls as $ k => $ v ) { $ name = pathinfo ( $ v , PATHINFO_FILENAME ) ; $ postName = $ k . strtolower ( $ name ) ; $ content = $ miniTplPath . DIRECTORY_SEPARATOR . $ v ; $ pluginsConfig [ 'front' ] [ 'default' ] = file_get_contents ( $ content ) ; $ pluginsConfig [ 'melis' ] [ 'name' ] = $ name ; $ pluginsFormat [ 'plugins' ] [ 'MelisMiniTemplate' ] [ 'plugins' ] [ 'MiniTemplatePlugin_' . $ postName ] = $ pluginsConfig ; } } } } } } } return $ pluginsFormat ; } | Function to prepare the Mini Template config |
22,772 | private function extend ( array $ backup ) { $ preset = $ this -> presetStore -> getPreset ( $ this -> application , $ this -> version , $ this -> options ) ; return array_merge ( $ preset , $ backup ) ; } | Extend backup with preset . |
22,773 | public function prepareWhere ( $ whereObject ) { $ where = null ; $ params = [ ] ; if ( ! empty ( $ whereObject ) ) { $ arr = [ ] ; foreach ( $ whereObject as $ chunk ) { list ( $ wSQL , $ wParams ) = $ chunk -> build ( ) ; $ arr [ ] = $ wSQL ; foreach ( $ wParams as $ k => $ v ) { $ params [ ] = $ v ; } } $ this -> setWhere = ' WHERE ' . implode ( ' AND ' , $ arr ) ; if ( is_array ( $ this -> setParams ) and ! empty ( $ this -> setParams ) ) { $ this -> setParams = array_merge ( $ this -> setParams , $ params ) ; } else { $ this -> setParams = $ params ; } } else { $ this -> setWhere = null ; } return $ this ; } | PrepareWhere function . |
22,774 | public function prepareHaving ( $ havingObject ) { $ where = null ; $ params = [ ] ; if ( ! empty ( $ havingObject ) ) { $ arr = [ ] ; foreach ( $ havingObject as $ chunk ) { list ( $ wSQL , $ wParams ) = $ chunk -> build ( ) ; $ arr [ ] = $ wSQL ; foreach ( $ wParams as $ k => $ v ) { $ params [ ] = $ v ; } } $ this -> setHaving = ' HAVING ' . implode ( ' AND ' , $ arr ) ; if ( is_array ( $ this -> setParams ) and ! empty ( $ this -> setParams ) ) { $ this -> setParams = array_merge ( $ this -> setParams , $ params ) ; } else { $ this -> setParams = $ params ; } } else { $ this -> setHaving = null ; } return $ this ; } | PrepareHaving function . |
22,775 | public function prepareOrder ( $ order = null , $ sort = null ) { if ( $ order == null or $ sort == null ) { $ this -> setOrderBy = '' ; return $ this ; } if ( ! in_array ( $ sort , [ 'ASC' , 'DESC' ] ) ) { $ sort = 'DESC' ; } $ this -> setOrderBy = ' ORDER BY ' . $ order . ' ' . $ sort ; return $ this ; } | prepareOrder function . |
22,776 | public function prepareQuery ( $ query , $ params = false ) { if ( isset ( $ params ) and is_array ( $ params ) ) { $ this -> prepareParms ( $ params ) ; } if ( ! isset ( $ this -> setQuery ) ) { $ this -> setQuery = $ query . ' ' ; } else { $ this -> setQuery .= $ this -> getQuery ( ) . ' ' . $ query . ' ' ; } return $ this ; } | Undocumented function . |
22,777 | public function prepareParms ( $ params ) { if ( is_array ( $ params ) ) { foreach ( $ params as $ key => $ value ) { array_push ( $ this -> setParams , $ value ) ; } } else { array_push ( $ this -> setParams , $ params ) ; } } | PrepareParms function . |
22,778 | public function getQuery ( ) { $ sql = $ this -> setQuery ; $ sql .= $ this -> getWhere ( ) ; $ sql .= $ this -> getGroupBy ( ) ; $ sql .= $ this -> getOrderBy ( ) ; $ sql .= $ this -> getHaving ( ) ; $ sql .= $ this -> getLimit ( ) ; $ this -> setQuery = null ; $ this -> setWhere = null ; $ this -> setHaving = null ; $ this -> setOrderBy = null ; $ this -> setGroupBy = null ; $ this -> setLimit = null ; return str_replace ( ' ' , ' ' , $ sql ) ; } | GetQuery function . |
22,779 | public function getWhere ( ) { if ( ! isset ( $ this -> setWhere ) or empty ( $ this -> setWhere ) ) { $ this -> setWhere = null ; } return $ this -> setWhere ; } | GetWhere function . |
22,780 | public function getHaving ( ) { if ( ! isset ( $ this -> setHaving ) or empty ( $ this -> setHaving ) ) { $ this -> setHaving = null ; } return $ this -> setHaving ; } | GetHaving function . |
22,781 | public function prepareLimit ( $ limit , $ offset = null ) { if ( $ offset ) { $ this -> setLimit = ' LIMIT ' . $ limit . ', ' . $ offset . '' ; } else { $ this -> setLimit = ' LIMIT ' . $ limit . '' ; } return $ this ; } | PrepareLimit function . |
22,782 | public function findOneByAttributeIdAndValue ( $ attributeId , $ value ) { $ params = array ( MemberNames :: ATTRIBUTE_ID => $ attributeId , MemberNames :: VALUE => $ value ) ; $ this -> productMediaGalleryStmt -> execute ( $ params ) ; return $ this -> productMediaGalleryStmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; } | Load s the product media gallery with the passed attribute ID + value . |
22,783 | public static function preRenderWebformElement ( $ element ) { $ webform = ( $ element [ '#webform' ] instanceof WebformInterface ) ? $ element [ '#webform' ] : WebformEntity :: load ( $ element [ '#webform' ] ) ; if ( ! $ webform ) { return $ element ; } if ( $ webform -> access ( 'submission_create' ) ) { $ values = [ ] ; $ values [ 'data' ] = $ element [ '#default_data' ] ; if ( ! empty ( $ element [ '#entity' ] ) && $ element [ '#entity' ] instanceof EntityInterface ) { $ values [ 'entity_type' ] = $ element [ '#entity' ] -> getEntityTypeId ( ) ; $ values [ 'entity_id' ] = $ element [ '#entity' ] -> id ( ) ; } elseif ( ! empty ( $ element [ '#entity_type' ] ) && ! empty ( $ element [ '#entity_id' ] ) ) { $ values [ 'entity_type' ] = $ element [ '#entity_type' ] ; $ values [ 'entity_id' ] = $ element [ '#entity_id' ] ; } if ( ! empty ( $ element [ '#override' ] ) ) { $ new_settings = $ element [ '#override' ] ; $ webform -> setSettingsOverride ( $ new_settings ) ; $ values [ 'strawberryfield:override' ] = $ new_settings ; } $ element [ 'webform_build' ] = $ webform -> getSubmissionForm ( $ values ) ; if ( ! empty ( $ element [ '#action' ] ) ) { $ element [ 'webform_build' ] [ '#action' ] = $ element [ '#action' ] ; } } elseif ( $ webform -> getSetting ( 'form_access_denied' ) !== WebformInterface :: ACCESS_DENIED_DEFAULT ) { $ element [ 'webform_access_denied' ] = static :: buildAccessDenied ( $ webform ) ; } else { $ config = \ Drupal :: configFactory ( ) -> get ( 'webform.settings' ) ; $ renderer = \ Drupal :: service ( 'renderer' ) ; $ renderer -> addCacheableDependency ( $ element , $ config ) ; $ renderer -> addCacheableDependency ( $ element , $ webform ) ; } return $ element ; } | Webform element pre render callback . |
22,784 | public function generateAllAssets ( $ files , $ sitePath , $ siteName , $ isFromVendor ) { $ cssMinifier = new Minify \ CSS ( ) ; $ jsMinifier = new Minify \ JS ( ) ; if ( $ isFromVendor ) { $ bundleDir = $ sitePath . '/public/' ; $ sitePath = dirname ( $ sitePath ) ; } else { $ bundleDir = $ sitePath . '/' . $ siteName . '/public/' ; } $ messages = array ( ) ; if ( $ this -> checkDir ( $ bundleDir ) ) { if ( is_writable ( $ bundleDir ) ) { if ( ! empty ( $ files ) ) { foreach ( $ files as $ key => $ file ) { $ key = strtolower ( $ key ) ; if ( $ key == 'js' ) { $ messages [ 'error' ] = $ this -> createBundleFile ( $ jsMinifier , 'bundle.js' , $ file , $ sitePath , $ bundleDir ) ; } if ( $ key == 'css' ) { $ messages [ 'error' ] = $ this -> createBundleFile ( $ cssMinifier , 'bundle.css' , $ file , $ sitePath , $ bundleDir , false ) ; } } } } else { $ messages [ 'error' ] = array ( 'message' => $ bundleDir . ' is not writable.' , 'success' => false ) ; } } else { $ messages [ 'error' ] = array ( 'message' => $ bundleDir . ' does not exist.' , 'success' => false ) ; } return $ messages ; } | Function to generate all assets |
22,785 | private function createBundleFile ( $ minifier , $ fileName , $ files , $ sitePath , $ bundleDir , $ cleanCode = true ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ message = '' ; $ success = false ; if ( ! empty ( $ files ) ) { try { foreach ( $ files as $ key => $ file ) { if ( $ cleanCode ) { $ codeToAdd = $ this -> removeComments ( $ sitePath . $ file ) ; } else { $ codeToAdd = $ sitePath . $ file ; } $ minifier -> add ( $ codeToAdd ) ; } $ minifier -> minify ( $ bundleDir . $ fileName ) ; $ message = $ translator -> translate ( 'tr_front_minify_assets_compiled_successfully' ) ; $ success = true ; } catch ( \ Exception $ ex ) { $ message = wordwrap ( $ ex -> getMessage ( ) , 20 , "\n" , true ) ; } } else { $ success = true ; } return array ( 'message' => $ message , 'success' => $ success ) ; } | Function to create a bundle |
22,786 | public function minifyAssetsAction ( ) { $ request = $ this -> getRequest ( ) ; $ siteID = $ request -> getPost ( 'siteId' ) ; $ minifyAssets = $ this -> getServiceLocator ( ) -> get ( 'MinifyAssets' ) ; $ result = $ minifyAssets -> minifyAssets ( $ siteID ) ; $ title = 'Compiling assets' ; $ success = true ; $ message = '' ; if ( ! empty ( $ result [ 'results' ] ) ) { foreach ( $ result [ 'results' ] as $ key => $ val ) { if ( ! $ val [ 'success' ] ) { $ success = false ; $ message = $ val [ 'message' ] ; } } } return new JsonModel ( array ( 'title' => $ title , 'message' => wordwrap ( $ message , 20 , "\n" , true ) , 'success' => $ success , ) ) ; } | Function to minify assets |
22,787 | public function mergeEventListeners ( $ eventListeners ) { if ( $ eventListeners instanceof EventManagerInterface ) { $ eventListeners = $ eventListeners -> getEventListeners ( ) ; } foreach ( ( ( array ) $ eventListeners ) as $ eventName => $ listeners ) { $ queue = [ ] ; if ( isset ( $ this -> eventListeners [ $ eventName ] ) ) { $ innerListeners = clone $ this -> eventListeners [ $ eventName ] ; $ innerListeners -> setExtractFlags ( ListenerQueue :: EXTR_DATA ) ; foreach ( $ innerListeners as $ callback ) { $ queue [ ] = $ callback ; } } $ listeners = clone $ listeners ; $ listeners -> setExtractFlags ( ListenerQueue :: EXTR_BOTH ) ; foreach ( $ listeners as $ listener ) { if ( ! in_array ( $ listener [ 'data' ] , $ queue ) ) { $ this -> attach ( $ eventName , $ listener [ 'data' ] , $ listener [ 'priority' ] ) ; } } } return true ; } | Merge current events listeners with a given list . |
22,788 | public function attach ( $ event , $ callback , $ priority = 0 ) { if ( ! isset ( $ this -> eventListeners [ $ event ] ) ) { $ this -> clearListeners ( $ event ) ; } $ this -> eventListeners [ $ event ] -> insert ( $ callback , $ priority ) ; return true ; } | Attaches a listener to an event . |
22,789 | public function detach ( $ event , $ callback ) { if ( ! isset ( $ this -> eventListeners [ $ event ] ) || $ this -> eventListeners [ $ event ] -> isEmpty ( ) ) { return false ; } $ removed = false ; $ listeners = $ this -> eventListeners [ $ event ] ; $ newListeners = new ListenerQueue ( ) ; $ listeners -> setExtractFlags ( ListenerQueue :: EXTR_BOTH ) ; foreach ( $ listeners as $ item ) { if ( $ item [ 'data' ] === $ callback ) { $ removed = true ; continue ; } $ newListeners -> insert ( $ item [ 'data' ] , $ item [ 'priority' ] ) ; } $ listeners -> setExtractFlags ( ListenerQueue :: EXTR_DATA ) ; $ this -> eventListeners [ $ event ] = $ newListeners ; return $ removed ; } | Detaches a listener from an event . |
22,790 | public function toXML ( ) { $ namespace = 'tns' ; $ writer = new XMLWriter ( ) ; $ writer -> openMemory ( ) ; $ writer -> setIndent ( true ) ; $ writer -> setIndentString ( ' ' ) ; $ writer -> startElementNs ( $ namespace , $ this -> getRequestName ( ) , 'http://www.apis-it.hr/fin/2012/types/f73' ) ; $ writer -> writeAttribute ( 'Id' , uniqid ( ) ) ; $ writer -> startElementNs ( $ namespace , 'Zaglavlje' , null ) ; $ writer -> writeElementNs ( $ namespace , 'IdPoruke' , null , $ this -> generateUUID ( ) ) ; $ writer -> writeElementNs ( $ namespace , 'DatumVrijeme' , null , $ this -> generateDateTime ( ) ) ; $ writer -> endElement ( ) ; $ writer -> writeRaw ( $ this -> getRequest ( ) -> toXML ( ) ) ; $ writer -> endElement ( ) ; return $ writer -> outputMemory ( ) ; } | Set headers get specific request XML body and make request |
22,791 | public function addValue ( \ google \ protobuf \ EnumValueDescriptorProto $ value ) { if ( $ this -> value === null ) { $ this -> value = new \ Protobuf \ MessageCollection ( ) ; } $ this -> value -> add ( $ value ) ; } | Add a new element to value |
22,792 | public function register ( $ context = null ) { if ( null !== $ context ) { $ this -> add_context ( $ context ) ; } if ( ! $ this -> is_needed ( $ this -> context ) ) { return ; } \ add_shortcode ( $ this -> get_tag ( ) , [ $ this , 'render' ] ) ; } | Register the shortcode handler function with WordPress . |
22,793 | public function render ( $ atts , $ content = null , $ tag = null ) { $ atts = $ this -> atts_parser -> parse_atts ( $ atts , $ this -> get_tag ( ) ) ; $ this -> enqueue_dependencies ( $ this -> get_dependency_handles ( ) , $ atts ) ; return $ this -> render_view ( $ this -> get_view ( ) , $ this -> context , $ atts , $ content ) ; } | Render the shortcode . |
22,794 | protected function enqueue_dependencies ( $ handles , $ context = null ) { if ( null !== $ context ) { $ this -> add_context ( $ context ) ; } if ( ! $ this -> dependencies || count ( $ handles ) < 1 ) { return ; } foreach ( $ handles as $ handle ) { $ found = $ this -> dependencies -> enqueue_handle ( $ handle , $ this -> context , true ) ; if ( ! $ found ) { $ message = sprintf ( __ ( 'Could not enqueue dependency "%1$s" for shortcode "%2$s".' , 'bn-shortcodes' ) , $ handle , $ this -> get_tag ( ) ) ; trigger_error ( $ message , E_USER_WARNING ) ; } } } | Enqueue the dependencies that the shortcode needs . |
22,795 | public function do_this ( array $ atts = [ ] , $ content = null ) { return \ BrightNucleus \ Shortcode \ do_tag ( $ this -> get_tag ( ) , $ atts , $ content ) ; } | Execute this shortcode directly from code . |
22,796 | protected function prepareProductMediaGalleryAttributes ( ) { $ mediaGalleryAttribute = $ this -> getEavAttributeByAttributeCode ( MediaGalleryObserver :: ATTRIBUTE_CODE ) ; $ attributeId = $ mediaGalleryAttribute [ MemberNames :: ATTRIBUTE_ID ] ; $ disabled = 0 ; $ mediaType = 'image' ; $ image = $ this -> getValue ( ColumnKeys :: IMAGE_PATH_NEW ) ; return $ this -> initializeEntity ( array ( MemberNames :: ATTRIBUTE_ID => $ attributeId , MemberNames :: VALUE => $ image , MemberNames :: MEDIA_TYPE => $ mediaType , MemberNames :: DISABLED => $ disabled ) ) ; } | Prepare the product media gallery that has to be persisted . |
22,797 | protected function prepareProductMediaGalleryValueToEntityAttributes ( ) { return $ this -> initializeEntity ( array ( MemberNames :: VALUE_ID => $ this -> valueId , MemberNames :: ENTITY_ID => $ this -> parentId ) ) ; } | Prepare the product media gallery value to entity that has to be persisted . |
22,798 | public function getValidator ( $ alias ) { if ( array_key_exists ( $ alias , $ this -> validators ) ) { return $ this -> validators [ $ alias ] ; } throw new JbFileUploaderException ( 'Unknown validator ' . $ alias ) ; } | Get a validator by its alias |
22,799 | public function Alarm ( AlarmRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Maintenance/Alarm' , $ argument , [ '\Etcdserverpb\AlarmResponse' , 'decode' ] , $ metadata , $ options ) ; } | Alarm activates deactivates and queries alarms regarding cluster health . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.