idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
8,700
|
public function addArrayChild ( & $ parent , $ arr ) { $ num = 0 ; if ( ! empty ( $ arr ) && ! empty ( $ parent ) ) { foreach ( $ arr as $ node ) { $ this -> appChild ( $ parent , $ node , '' ) ; $ num ++ ; } } return $ num ; }
|
addArrayChild Adiciona a um DOMNode parent outros elementos passados em um array de DOMElements .
|
8,701
|
public function setKey ( $ key ) { $ this -> key = $ key ; if ( ! session ( ) -> has ( 'bzarzuela.filters' ) ) { session ( [ 'bzarzuela.filters' => [ $ key => [ ] ] ] ) ; } return $ this ; }
|
Sets a unique key to hold the filter form data in the session .
|
8,702
|
public function getFormData ( $ field = null ) { $ filters = session ( 'bzarzuela.filters' ) ; if ( isset ( $ filters [ $ this -> key ] [ 'form_data' ] ) ) { if ( ! is_null ( $ field ) ) { if ( ! isset ( $ filters [ $ this -> key ] [ 'form_data' ] [ $ field ] ) ) { return null ; } return $ filters [ $ this -> key ] [ 'form_data' ] [ $ field ] ; } return $ filters [ $ this -> key ] [ 'form_data' ] ; } if ( ! is_null ( $ field ) ) { return null ; } return [ ] ; }
|
Gets either the whole form data or just a field inside .
|
8,703
|
public function afterStep ( StepEvent $ event ) { $ color = $ this -> getResultColorCode ( $ event -> getResult ( ) ) ; $ capture = $ this -> captureAll || $ color == 'failed' ; if ( $ capture ) { try { $ screenshot = $ this -> driver -> getScreenshot ( ) ; if ( $ screenshot ) { $ date = new \ DateTime ( 'now' ) ; $ fileName = $ this -> screenShotPrefix . $ date -> format ( 'Y-m-d H.i.s' ) . '.png' ; $ file = $ this -> screenShotDirectory . DIRECTORY_SEPARATOR . $ fileName ; file_put_contents ( $ file , $ screenshot ) ; $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $ event -> getStep ( ) -> getText ( ) . '</a>' ) ; $ this -> screenShotMarkup .= sprintf ( '<img src="%s" />' , $ fileName ) ; $ this -> screenShotMarkup .= '</div>' ; } } catch ( \ Exception $ e ) { $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<em>Error while taking screenshot for ' . $ event -> getStep ( ) -> getText ( ) . ' : %s</em>' , htmlspecialchars ( $ e -> getMessage ( ) ) ) ; $ this -> screenShotMarkup .= '</div>' ; } } if ( $ this -> inBackground && $ this -> isBackgroundPrinted ) { return ; } if ( ! $ this -> inBackground && $ this -> inOutlineExample ) { $ this -> delayedStepEvents [ ] = $ event ; return ; } $ this -> printStep ( $ event -> getStep ( ) , $ event -> getResult ( ) , $ event -> getDefinition ( ) , $ event -> getSnippet ( ) , $ event -> getException ( ) ) ; $ this -> writeln ( $ this -> screenShotMarkup ) ; $ this -> screenShotMarkup = '' ; }
|
Listens to step . after event .
|
8,704
|
protected function importResource ( BaseConfig $ baseConfig ) { foreach ( $ baseConfig as $ key => $ value ) { if ( $ value instanceof BaseConfig ) { $ this -> importResource ( $ value ) ; } elseif ( is_string ( $ value ) ) { if ( $ key === self :: RESOURCES_KEY ) { $ resources = $ this -> clear ( $ baseConfig , $ this -> create ( $ value ) ) ; $ baseConfig -> merge ( $ resources ) ; $ baseConfig -> offsetUnset ( $ key ) ; } elseif ( substr_count ( $ value , self :: RESOURCES_VALUE ) ) { $ baseConfig [ $ key ] = $ this -> create ( substr ( $ value , strlen ( self :: RESOURCES_VALUE ) ) ) ; } elseif ( $ key === self :: MODULE_KEY ) { $ resources = $ this -> clear ( $ baseConfig , $ this -> moduleConfigCreate ( $ value ) ) ; $ baseConfig -> merge ( $ resources ) ; $ baseConfig -> offsetUnset ( $ key ) ; } elseif ( substr_count ( $ value , self :: MODULE_VALUE ) ) { $ baseConfig [ $ key ] = $ this -> moduleConfigCreate ( substr ( $ value , strlen ( self :: MODULE_VALUE ) ) ) ; } if ( substr_count ( $ value , self :: ENVIRONMENT ) ) { $ baseConfig [ $ key ] = str_replace ( self :: ENVIRONMENT , $ this -> environment , $ value ) ; } } } }
|
Import encountered files in the configuration
|
8,705
|
public function clear ( Config $ means , Config $ target ) { foreach ( $ target as $ key => $ value ) { if ( $ value instanceof BaseConfig && isset ( $ means [ $ key ] ) ) { $ this -> clear ( $ means [ $ key ] , $ value ) ; } else { if ( isset ( $ means [ $ key ] ) ) { $ target -> offsetUnset ( $ key ) ; } } } return new BaseConfig ( $ target -> toArray ( ) ) ; }
|
Delete variables that are already defined in the main configuration file
|
8,706
|
protected function moduleConfigCreate ( $ path ) { $ value = explode ( '::' , $ path ) ; $ ref = new ReflectionClass ( $ value [ 0 ] ) ; if ( $ ref -> hasConstant ( 'DIR' ) === false ) { throw new ConstantDirNotFoundException ( 'Not found constant DIR in class ' . $ value [ 0 ] ) ; } return $ this -> create ( $ value [ 0 ] :: DIR . $ ref -> getConstant ( $ value [ 1 ] ) ) ; }
|
Create a configuration of the module for further imports
|
8,707
|
public function put ( $ data , $ priority = \ Pheanstalk_PheanstalkInterface :: DEFAULT_PRIORITY , $ delay = \ Pheanstalk_PheanstalkInterface :: DEFAULT_DELAY , $ timeToRun = \ Pheanstalk_PheanstalkInterface :: DEFAULT_TTR ) { $ this -> pheanstalk -> put ( $ data , $ priority , $ delay , $ timeToRun ) ; return $ this ; }
|
Puts a task string into the current
|
8,708
|
public function getTab ( ) : string { return '<span title="Doctrine 2">' . '<svg viewBox="0 0 2048 2048"><path fill="#aaa" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280' . '-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128' . 'v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 ' . '325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103' . '-128t280-93.5 385-34.5z"></path></svg>' . '<span class="tracy-label">' . count ( $ this -> queries ) . ' queries' . ( $ this -> totalTime ? ' / ' . sprintf ( '%0.1f' , $ this -> totalTime * 1000 ) . ' ms' : '' ) . '</span>' . '</span>' ; }
|
Renders tab for Tracy Debug Bar .
|
8,709
|
public function getPanel ( ) : string { if ( empty ( $ this -> queries ) ) { return '' ; } $ params = $ this -> connection -> getParams ( ) ; $ host = ( $ params [ 'driver' ] === 'pdo_sqlite' && isset ( $ params [ 'path' ] ) ) ? 'path: ' . basename ( $ params [ 'path' ] ) : sprintf ( 'host: %s%s/%s' , $ this -> connection -> getHost ( ) , ( ( $ p = $ this -> connection -> getPort ( ) ) ? ':' . $ p : '' ) , $ this -> connection -> getDatabase ( ) ) ; return '<style> #nette-debug td.nette-Doctrine2Panel-sql { background: white !important} #nette-debug .nette-Doctrine2Panel-source { color: #BBB !important } #nette-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto } #tracy-debug td.nette-Doctrine2Panel-sql { background: white !important} #tracy-debug .nette-Doctrine2Panel-source { color: #BBB !important } #tracy-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>' . sprintf ( '<h1>Queries: %s%s, %s</h1>' , count ( $ this -> queries ) , ( $ this -> totalTime ? ', time: ' . sprintf ( '%0.3f' , $ this -> totalTime * 1000 ) . ' ms' : '' ) , $ host ) . '<div class="nette-inner tracy-inner nette-Doctrine2Panel">' . implode ( '<br>' , array_filter ( [ $ this -> renderPanelCacheStatistics ( ) , $ this -> renderPanelQueries ( ) ] ) ) . '</div>' ; }
|
Renders panel for Tracy Debug Bar .
|
8,710
|
private function renderPanelCacheStatistics ( ) : string { if ( empty ( $ this -> entityManager ) ) { return '' ; } $ config = $ this -> entityManager -> getConfiguration ( ) ; if ( ! $ config -> isSecondLevelCacheEnabled ( ) ) { return '' ; } $ loggerChain = $ config -> getSecondLevelCacheConfiguration ( ) -> getCacheLogger ( ) ; if ( ! $ loggerChain instanceof Doctrine \ ORM \ Cache \ Logging \ CacheLoggerChain ) { return '' ; } if ( ! $ statistics = $ loggerChain -> getLogger ( 'statistics' ) ) { return '' ; } return Dumper :: toHtml ( $ statistics , [ Dumper :: DEPTH => 5 ] ) ; }
|
Renders cache statistics .
|
8,711
|
private function renderPanelQueries ( ) : string { if ( empty ( $ this -> queries ) ) { return '' ; } $ s = '' ; foreach ( $ this -> queries as $ query ) { [ $ sql , $ params , $ time , $ types , $ source ] = $ query ; $ q = SqlDumper :: dump ( $ sql , $ params ) ; $ q .= $ source ? Helpers :: editorLink ( $ source [ 0 ] , $ source [ 1 ] ) : '' ; $ s .= '<tr><td>' . sprintf ( '%0.3f' , $ time * 1000 ) . '</td><td class="nette-Doctrine2Panel-sql">' . $ q . '</td></tr>' ; } return '<table><tr><th>ms</th><th>SQL Statement</th></tr>' . $ s . '</table>' ; }
|
Renders SQL queries .
|
8,712
|
public function setEntityManager ( EntityManager $ entityManager ) { $ this -> entityManager = $ entityManager ; $ this -> connection = $ entityManager -> getConnection ( ) ; $ bar = Debugger :: getBar ( ) ; $ bar -> addPanel ( $ this ) ; $ config = $ this -> connection -> getConfiguration ( ) ; $ logger = $ config -> getSQLLogger ( ) ; if ( $ logger instanceof Doctrine \ DBAL \ Logging \ LoggerChain ) { $ logger -> addLogger ( $ this ) ; } else { $ config -> setSQLLogger ( $ this ) ; } }
|
Sets entity manager .
|
8,713
|
public function show ( $ key ) { $ this -> authorize ( 'read' , Option :: class ) ; try { $ option = $ this -> optionRepo -> getOptions ( $ key ) ; return $ this -> respondWithSuccess ( $ option , new OptionTransformer ) ; } catch ( RepositoryValidationException $ e ) { return $ this -> respondWithError ( $ e -> getMessage ( ) ) ; } }
|
Display all options from selected category .
|
8,714
|
static function isValid ( $ value ) { if ( ! \ Poirot \ Std \ isStringify ( $ value ) ) throw new \ InvalidArgumentException ( sprintf ( 'Header value must be string; given: (%s).' , \ Poirot \ Std \ flatten ( $ value ) ) ) ; $ value = ( string ) $ value ; if ( preg_match ( "#(?:(?:(?<!\r)\n)|(?:\r(?!\n))|(?:\r\n(?![ \t])))#" , $ value ) ) { return false ; } if ( preg_match ( '/[^\x09\x0a\x0d\x20-\x7E\x80-\xFE]/' , $ value ) ) { return false ; } return true ; }
|
Validate a header value .
|
8,715
|
public function addPath ( $ relativePath ) { if ( ! $ relativePath || $ relativePath == '/' ) { return $ this ; } if ( $ relativePath [ 0 ] != '/' ) { $ relativePath = '/' . $ relativePath ; } return $ this -> setPath ( str_replace ( '//' , '/' , $ this -> getPath ( ) . $ relativePath ) ) ; }
|
Add a relative path to the currently set path
|
8,716
|
protected function validateParameterCount ( $ name , $ parameterAmount , array $ parameters ) { if ( count ( $ parameters ) !== $ parameterAmount ) { throw new ValidationException ( '"' . $ name . '" expects ' . $ parameterAmount . ' parameter.' ) ; } }
|
Throws an exception if the parameters don t fulfill the expected parameter count .
|
8,717
|
public function emergency ( string $ id , string $ message , int $ status = 400 ) { Log :: error ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => false , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
|
Create emergency response
|
8,718
|
public function notice ( string $ id , string $ message , int $ status = 400 ) { Log :: info ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => false , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
|
Create notice response
|
8,719
|
public function success ( string $ id , string $ message , int $ status = 200 ) { Log :: info ( $ id . ' : ' . $ message ) ; return response ( ) -> json ( [ 'success' => true , 'id' => $ id , 'message' => $ message ] , $ status ) ; }
|
Create success response
|
8,720
|
function setOption ( $ option , $ value ) { $ ret = true ; if ( array_key_exists ( $ option , $ this -> _options ) ) { $ this -> _options [ $ option ] = $ value ; } else { throw new InvalidArgumentException ( 'Unknown option ' . $ option ) ; } }
|
Sets run - time configuration options
|
8,721
|
function loadFile ( $ filename ) { if ( file_exists ( $ filename ) ) { if ( ( $ this -> content = @ file_get_contents ( $ filename ) ) === false ) { throw new BibtexException ( 'Could not open file ' . $ filename ) ; } else { $ this -> _pos = 0 ; $ this -> _oldpos = 0 ; return true ; } } else { throw new BibtexException ( 'Could not find file ' . $ filename ) ; } }
|
Reads a give BibTex File
|
8,722
|
function _checkEqualSign ( $ entry , $ position ) { $ ret = true ; $ length = strlen ( $ entry ) ; $ open = 0 ; for ( $ i = $ length - 1 ; $ i >= $ position ; $ i -- ) { $ precedingchar = substr ( $ entry , $ i - 1 , 1 ) ; $ char = substr ( $ entry , $ i , 1 ) ; if ( ( '{' == $ char ) && ( '\\' != $ precedingchar ) ) { $ open ++ ; } if ( ( '}' == $ char ) && ( '\\' != $ precedingchar ) ) { $ open -- ; } } if ( 0 != $ open ) { $ ret = false ; } if ( $ ret ) { $ entrycopy = trim ( $ entry ) ; $ lastchar = $ entrycopy { strlen ( $ entrycopy ) - 1 } ; if ( ',' == $ lastchar ) { $ lastchar = $ entrycopy { strlen ( $ entrycopy ) - 2 } ; } if ( '"' == $ lastchar ) { $ ret = false ; $ found = 0 ; for ( $ i = $ length ; $ i >= $ position ; $ i -- ) { $ precedingchar = substr ( $ entry , $ i - 1 , 1 ) ; $ char = substr ( $ entry , $ i , 1 ) ; if ( ( '"' == $ char ) && ( '\\' != $ precedingchar ) ) { $ found ++ ; } if ( 2 == $ found ) { $ ret = true ; break ; } } } } return $ ret ; }
|
Checking whether the position of the = is correct
|
8,723
|
function _checkAt ( $ entry ) { $ ret = false ; $ opening = array_keys ( $ this -> _delimiters ) ; $ closing = array_values ( $ this -> _delimiters ) ; if ( strrpos ( $ entry , '=' ) !== false ) { $ position = strrpos ( $ entry , '=' ) ; $ proceed = true ; if ( substr ( $ entry , $ position - 1 , 1 ) == '\\' ) { $ proceed = false ; } while ( ! $ proceed ) { $ substring = substr ( $ entry , 0 , $ position ) ; $ position = strrpos ( $ substring , '=' ) ; $ proceed = true ; if ( substr ( $ entry , $ position - 1 , 1 ) == '\\' ) { $ proceed = false ; } } $ value = trim ( substr ( $ entry , $ position + 1 ) ) ; $ open = 0 ; $ char = '' ; $ lastchar = '' ; for ( $ i = 0 ; $ i < strlen ( $ value ) ; $ i ++ ) { $ char = substr ( $ this -> content , $ i , 1 ) ; if ( in_array ( $ char , $ opening ) && ( '\\' != $ lastchar ) ) { $ open ++ ; } elseif ( in_array ( $ char , $ closing ) && ( '\\' != $ lastchar ) ) { $ open -- ; } $ lastchar = $ char ; } if ( $ open > 0 ) { $ ret = true ; } } return $ ret ; }
|
Checking whether an at is outside an entry
|
8,724
|
function _wordwrap ( $ entry ) { if ( ( '' != $ entry ) && ( is_string ( $ entry ) ) ) { $ entry = wordwrap ( $ entry , $ this -> _options [ 'wordWrapWidth' ] , $ this -> _options [ 'wordWrapBreak' ] , $ this -> _options [ 'wordWrapCut' ] ) ; } return $ entry ; }
|
Wordwrap an entry
|
8,725
|
function _determineCase ( $ word ) { $ ret = - 1 ; $ trimmedword = trim ( $ word ) ; if ( is_string ( $ word ) && ( strlen ( $ trimmedword ) > 0 ) ) { $ i = 0 ; $ found = false ; $ openbrace = 0 ; while ( ! $ found && ( $ i <= strlen ( $ word ) ) ) { $ letter = substr ( $ trimmedword , $ i , 1 ) ; $ ord = ord ( $ letter ) ; if ( $ ord == 123 ) { $ openbrace ++ ; } if ( $ ord == 125 ) { $ openbrace -- ; } if ( ( $ ord >= 65 ) && ( $ ord <= 90 ) && ( 0 == $ openbrace ) ) { $ ret = 1 ; $ found = true ; } elseif ( ( $ ord >= 97 ) && ( $ ord <= 122 ) && ( 0 == $ openbrace ) ) { $ ret = 0 ; $ found = true ; } else { $ i ++ ; } } } else { throw new BibtexException ( 'Could not determine case on word: ' . ( string ) $ word ) ; } return $ ret ; }
|
Case Determination according to the needs of BibTex
|
8,726
|
function _validateValue ( $ entry , $ wholeentry ) { if ( preg_match ( '/^{.*@.*}$/' , $ entry ) ) { $ this -> _generateWarning ( 'WARNING_AT_IN_BRACES' , $ entry , $ wholeentry ) ; } if ( preg_match ( '/^\".*\\".*\"$/' , $ entry ) ) { $ this -> _generateWarning ( 'WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES' , $ entry , $ wholeentry ) ; } $ open = 0 ; $ lastchar = '' ; $ char = '' ; for ( $ i = 0 ; $ i < strlen ( $ entry ) ; $ i ++ ) { $ char = substr ( $ entry , $ i , 1 ) ; if ( ( '{' == $ char ) && ( '\\' != $ lastchar ) ) { $ open ++ ; } if ( ( '}' == $ char ) && ( '\\' != $ lastchar ) ) { $ open -- ; } $ lastchar = $ char ; } if ( 0 != $ open ) { $ this -> _generateWarning ( 'WARNING_UNBALANCED_AMOUNT_OF_BRACES' , $ entry , $ wholeentry ) ; } }
|
Validation of a value
|
8,727
|
function _removeCurlyBraces ( $ value ) { $ beginningdels = array_keys ( $ this -> _delimiters ) ; $ firstchar = substr ( $ value , 0 , 1 ) ; $ lastchar = substr ( $ value , - 1 , 1 ) ; $ begin = '' ; $ end = '' ; while ( in_array ( $ firstchar , $ beginningdels ) ) { if ( $ lastchar == $ this -> _delimiters [ $ firstchar ] ) { $ begin .= $ firstchar ; $ end .= $ lastchar ; $ value = substr ( $ value , 1 , - 1 ) ; } else { break ; } $ firstchar = substr ( $ value , 0 , 1 ) ; $ lastchar = substr ( $ value , - 1 , 1 ) ; } $ pattern = '/([^\\\\]|^)?\{(.*?[^\\\\])\}/' ; $ replacement = '$1$2' ; $ value = preg_replace ( $ pattern , $ replacement , $ value ) ; $ value = $ begin . $ value . $ end ; return $ value ; }
|
Remove curly braces from entry
|
8,728
|
function _generateWarning ( $ type , $ entry , $ wholeentry = '' ) { $ warning [ 'warning' ] = $ type ; $ warning [ 'entry' ] = $ entry ; $ warning [ 'wholeentry' ] = $ wholeentry ; $ this -> warnings [ ] = $ warning ; }
|
Generates a warning
|
8,729
|
function _formatAuthor ( $ array ) { if ( ! array_key_exists ( 'von' , $ array ) ) { $ array [ 'von' ] = '' ; } else { $ array [ 'von' ] = trim ( $ array [ 'von' ] ) ; } if ( ! array_key_exists ( 'last' , $ array ) ) { $ array [ 'last' ] = '' ; } else { $ array [ 'last' ] = trim ( $ array [ 'last' ] ) ; } if ( ! array_key_exists ( 'jr' , $ array ) ) { $ array [ 'jr' ] = '' ; } else { $ array [ 'jr' ] = trim ( $ array [ 'jr' ] ) ; } if ( ! array_key_exists ( 'first' , $ array ) ) { $ array [ 'first' ] = '' ; } else { $ array [ 'first' ] = trim ( $ array [ 'first' ] ) ; } $ ret = $ this -> authorstring ; $ ret = str_replace ( "VON" , $ array [ 'von' ] , $ ret ) ; $ ret = str_replace ( "LAST" , $ array [ 'last' ] , $ ret ) ; $ ret = str_replace ( "JR," , $ array [ 'jr' ] , $ ret ) ; $ ret = str_replace ( "FIRST" , $ array [ 'first' ] , $ ret ) ; return trim ( print_r ( $ ret , 1 ) ) ; }
|
Returns the author formatted
|
8,730
|
function bibTex ( ) { $ bibtex = '' ; foreach ( $ this -> data as $ entry ) { $ bibtex .= '@' . strtolower ( $ entry [ 'entryType' ] ) . ' { ' . $ entry [ 'cite' ] . ",\n" ; foreach ( $ entry as $ key => $ val ) { if ( $ this -> _options [ 'wordWrapWidth' ] > 0 ) { $ val = $ this -> _wordWrap ( $ val ) ; } if ( ! in_array ( $ key , array ( 'cite' , 'entryType' , 'author' ) ) ) { $ bibtex .= "\t" . $ key . ' = {' . $ this -> _escape_tex ( $ val ) . "},\n" ; } } $ author = null ; if ( array_key_exists ( 'author' , $ entry ) ) { if ( $ this -> _options [ 'extractAuthors' ] ) { $ tmparray = array ( ) ; foreach ( $ entry [ 'author' ] as $ authorentry ) { $ tmparray [ ] = $ this -> _formatAuthor ( $ authorentry ) ; } $ author = join ( ' and ' , $ tmparray ) ; } else { $ author = $ entry [ 'author' ] ; } } else { $ author = '' ; } $ bibtex .= "\tauthor = {" . $ this -> _escape_tex ( $ author ) . "}\n" ; $ bibtex .= "}\n\n" ; } return $ bibtex ; }
|
Converts the stored BibTex entries to a BibTex String
|
8,731
|
function rtf ( ) { $ ret = "{\\rtf\n" ; foreach ( $ this -> data as $ entry ) { $ line = $ this -> rtfstring ; $ title = '' ; $ journal = '' ; $ year = '' ; $ authors = '' ; if ( array_key_exists ( 'title' , $ entry ) ) { $ title = $ this -> _unwrap ( $ entry [ 'title' ] ) ; } if ( array_key_exists ( 'journal' , $ entry ) ) { $ journal = $ this -> _unwrap ( $ entry [ 'journal' ] ) ; } if ( array_key_exists ( 'year' , $ entry ) ) { $ year = $ this -> _unwrap ( $ entry [ 'year' ] ) ; } if ( array_key_exists ( 'author' , $ entry ) ) { if ( $ this -> _options [ 'extractAuthors' ] ) { $ tmparray = array ( ) ; foreach ( $ entry [ 'author' ] as $ authorentry ) { $ tmparray [ ] = $ this -> _formatAuthor ( $ authorentry ) ; } $ authors = join ( ', ' , $ tmparray ) ; } else { $ authors = $ entry [ 'author' ] ; } } if ( ( '' != $ title ) || ( '' != $ journal ) || ( '' != $ year ) || ( '' != $ authors ) ) { $ line = str_replace ( "TITLE" , $ title , $ line ) ; $ line = str_replace ( "JOURNAL" , $ journal , $ line ) ; $ line = str_replace ( "YEAR" , $ year , $ line ) ; $ line = str_replace ( "AUTHORS" , $ authors , $ line ) ; $ line .= "\n\\par\n" ; $ ret .= $ line ; } else { $ this -> _generateWarning ( 'WARNING_LINE_WAS_NOT_CONVERTED' , '' , print_r ( $ entry , 1 ) ) ; } } $ ret .= '}' ; return $ ret ; }
|
Returns the stored data in RTF format
|
8,732
|
function _escape_tex ( $ tex ) { $ tex = str_replace ( "\\" , "\\\\" , $ tex ) ; $ tex = str_replace ( '#' , '\#' , $ tex ) ; $ tex = str_replace ( '$' , '\$' , $ tex ) ; $ tex = str_replace ( '%' , '\%' , $ tex ) ; $ tex = str_replace ( '^' , '\^' , $ tex ) ; $ tex = str_replace ( '&' , '\&' , $ tex ) ; $ tex = str_replace ( '_' , '\_' , $ tex ) ; $ tex = str_replace ( '{' , '\{' , $ tex ) ; $ tex = str_replace ( '}' , '\}' , $ tex ) ; return ( $ tex ) ; }
|
Returns a string with special TeX characters escaped .
|
8,733
|
public function getTokens ( $ string , & $ needle = 0 ) { $ exprTokenizer = new ExpressionTokenizer ( ) ; $ ret = array ( ) ; $ depth = 0 ; $ needle = 0 ; $ len = strlen ( $ string ) ; while ( $ needle < $ len ) { $ before = $ needle ; $ substr = substr ( $ string , $ needle ) ; if ( $ depth === 0 ) { if ( preg_match ( '/^([$@])\(/' , $ substr , $ m ) ) { $ needle += strlen ( $ m [ 0 ] ) ; $ ret [ ] = new Token ( Token :: EXPR_START , $ m [ 0 ] ) ; $ depth ++ ; } else { $ token = end ( $ ret ) ; if ( preg_match ( '/^\$\$\(/' , $ substr , $ m ) ) { $ value = substr ( $ m [ 0 ] , 1 ) ; $ needle += strlen ( $ m [ 0 ] ) ; } else { $ value = $ string { $ needle } ; $ needle += strlen ( $ value ) ; } if ( $ token && $ token -> match ( Token :: DATA ) ) { $ token -> value .= $ value ; unset ( $ token ) ; } else { $ ret [ ] = new Token ( Token :: DATA , $ value ) ; } } } else { $ ret = array_merge ( $ ret , $ exprTokenizer -> getTokens ( $ string , $ needle ) ) ; $ depth = 0 ; } if ( $ before === $ needle ) { throw new \ UnexpectedValueException ( "Unexpected input near token {$string{$needle}}, unsupported character" ) ; } } return $ ret ; }
|
Returns an array of tokens
|
8,734
|
public function indexAction ( ) { if ( $ this -> getRequest ( ) -> isAjax ( ) ) { try { $ this -> loadLayout ( null , false , false ) ; $ this -> getLayout ( ) -> getUpdate ( ) -> setCacheId ( null ) ; $ this -> getLayout ( ) -> getUpdate ( ) -> addHandle ( strtolower ( $ this -> getFullActionName ( ) ) . '_AJAX' ) ; } catch ( Exception $ e ) { Mage :: logException ( $ e ) ; $ this -> getResponse ( ) -> setHeader ( 'Content-Type' , 'application/json' ) ; $ this -> getResponse ( ) -> setBody ( Zend_Json :: encode ( [ 'error' => true , 'message' => $ e -> getMessage ( ) ] ) ) ; } } $ this -> loadLayout ( ) ; $ this -> renderLayout ( ) ; }
|
List existing records via a grid
|
8,735
|
public function viewAction ( ) { $ model = $ this -> loadModel ( ) ; if ( ! $ model -> getId ( ) ) { $ this -> _forward ( 'noroute' ) ; return ; } $ this -> loadLayout ( ) ; $ this -> renderLayout ( ) ; }
|
View existing record
|
8,736
|
public function widgetExist ( $ name ) { $ name = strtolower ( $ name ) ; return isset ( $ this -> dataStore [ 0 ] [ $ name ] ) ? $ this -> dataStore [ 0 ] [ $ name ] : false ; }
|
Checks if a widget exists
|
8,737
|
public function sendNotificationInMany ( $ subscriber , $ contentObject , $ comment , $ tpl = null ) { if ( is_null ( $ tpl ) ) { $ tpl = eZTemplate :: factory ( ) ; } $ tpl -> setVariable ( 'subscriber' , $ subscriber ) ; $ tpl -> setVariable ( 'contentobject' , $ contentObject ) ; $ tpl -> setVariable ( 'comment' , $ comment ) ; $ subject = $ tpl -> fetch ( $ this -> subjectTemplatePath ) ; $ body = $ tpl -> fetch ( $ this -> bodyTemplatePath ) ; $ this -> executeSending ( $ subject , $ body , $ subscriber ) ; }
|
send one notification with one comment by one comment Exception if error happens
|
8,738
|
public function sendNotificationInOne ( $ subscriber , $ contentObject , $ commentList = null , $ tpl = null ) { if ( is_null ( $ tpl ) ) { $ tpl = eZTemplate :: factory ( ) ; } $ tpl -> setVariable ( 'subscriber' , $ subscriber ) ; $ tpl -> setVariable ( 'contentobject' , $ contentObject ) ; if ( ! is_null ( $ commentList ) ) { $ tpl -> setVariable ( 'comment_list' , $ commentList ) ; } $ subject = $ tpl -> fetch ( $ this -> multiSubjectTemplatePath ) ; $ body = $ tpl -> fetch ( $ this -> multiBodyTemplatePath ) ; $ this -> executeSending ( $ subject , $ body , $ subscriber ) ; }
|
send notification with all comment in one notification Exception if error happens
|
8,739
|
public static function instance ( $ className = null ) { if ( is_null ( $ className ) ) { $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ className = $ ini -> variable ( 'NotificationSettings' , 'NotificationManagerClass' ) ; } if ( ! isset ( self :: $ instance ) ) { self :: $ instance = new $ className ( ) ; } return self :: $ instance ; }
|
create instance of the object
|
8,740
|
public static function create ( $ className = null ) { if ( is_null ( $ className ) ) { $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ className = $ ini -> variable ( 'NotificationSettings' , 'NotificationManagerClass' ) ; } return new $ className ( ) ; }
|
create instance of the object without using singleton
|
8,741
|
public function resources ( ) { $ options = Config :: get ( 'laravel-swagger::getResourceListOptions' ) ; $ excludedPath = Config :: get ( 'laravel-swagger::excludedPath' ) ; $ swagger = new Swagger ( $ this -> getPaths ( ) , $ excludedPath ) ; if ( Config :: get ( 'laravel-swagger::cache' ) ) { $ resourceList = Cache :: remember ( 'resourceList' , $ this -> getExpireAt ( ) , function ( ) use ( $ swagger , $ options ) { return $ swagger -> getResourceList ( $ options ) ; } ) ; } else { $ resourceList = $ swagger -> getResourceList ( $ options ) ; } return $ resourceList ; }
|
Show all available Resources
|
8,742
|
public function showResource ( $ name ) { $ options = Config :: get ( 'laravel-swagger::getResourceOptions' ) ; $ resourceName = "/" . str_replace ( "-" , "/" , $ name ) ; $ excludedPath = Config :: get ( 'laravel-swagger::excludedPath' ) ; $ swagger = new Swagger ( $ this -> getPaths ( ) , $ excludedPath ) ; if ( Config :: get ( 'laravel-swagger::cache' ) && Cache :: has ( 'resource_' . $ resourceName ) ) { $ resource = Cache :: get ( 'resource_' . $ resourceName ) ; } else { if ( ! in_array ( $ resourceName , $ swagger -> getResourceNames ( ) ) ) { App :: abort ( 404 , 'Resource not found' ) ; } if ( $ resourceName == '/petdemo' ) { $ options [ 'defaultBasePath' ] = route ( 'swagger-index' ) ; } $ resource = $ swagger -> getResource ( $ resourceName , $ options ) ; } if ( Config :: get ( 'laravel-swagger::cache' ) && ! Cache :: has ( 'resource_' . $ resourceName ) ) { Cache :: put ( 'resource_' . $ resourceName , $ resource , $ this -> getExpireAt ( ) ) ; } return $ resource ; }
|
Show an specific Resource
|
8,743
|
function save ( ) { $ fw = Base :: instance ( ) ; if ( $ this -> flag ) { if ( ! is_dir ( $ dir = $ fw -> get ( 'TEMP' ) ) ) mkdir ( $ dir , Base :: MODE , TRUE ) ; $ this -> count ++ ; $ fw -> write ( $ dir . '/' . $ fw -> hash ( $ fw -> get ( 'ROOT' ) . $ fw -> get ( 'BASE' ) ) . '.' . $ fw -> hash ( $ this -> file ) . '-' . $ this -> count . '.png' , $ this -> dump ( ) ) ; } return $ this ; }
|
Save current state
|
8,744
|
function restore ( $ state = 1 ) { $ fw = Base :: instance ( ) ; if ( $ this -> flag && is_file ( $ file = ( $ path = $ fw -> get ( 'TEMP' ) . $ fw -> hash ( $ fw -> get ( 'ROOT' ) . $ fw -> get ( 'BASE' ) ) . '.' . $ fw -> hash ( $ this -> file ) . '-' ) . $ state . '.png' ) ) { if ( is_resource ( $ this -> data ) ) imagedestroy ( $ this -> data ) ; $ this -> data = imagecreatefromstring ( $ fw -> read ( $ file ) ) ; imagesavealpha ( $ this -> data , TRUE ) ; foreach ( glob ( $ path . '*.png' , GLOB_NOSORT ) as $ match ) if ( preg_match ( '/-(\d+)\.png/' , $ match , $ parts ) && $ parts [ 1 ] > $ state ) @ unlink ( $ match ) ; $ this -> count = $ state ; } return $ this ; }
|
Revert to specified state
|
8,745
|
function calcular_valor_cubierto ( $ mesaId = null ) { if ( ! empty ( $ mesaId ) ) { $ this -> id = $ mesaId ; } $ cant_comensales = $ this -> field ( 'cant_comensales' ) ; $ precioCubierto = Configure :: read ( 'Restaurante.valorCubierto' ) ; $ valor_cubierto = 0 ; if ( $ precioCubierto > 0 ) { $ valor_cubierto = $ precioCubierto * $ cant_comensales ; } return $ valor_cubierto ; }
|
Funcion que calcula el precio del cubierto
|
8,746
|
function estaCobrada ( $ id = null , $ force_db = false ) { $ ret = false ; if ( ! empty ( $ id ) ) { $ this -> id = $ id ; } if ( ! empty ( $ this -> data [ $ this -> name ] [ 'estado_id' ] ) ) { $ ret = $ this -> data [ $ this -> name ] [ 'estado_id' ] == MESA_COBRADA ; } if ( $ force_db ) { $ ret = $ this -> find ( 'count' , array ( 'conditions' => array ( 'Mesa.estado_id' => MESA_COBRADA , 'Mesa.id' => $ this -> id , ) ) ) ; } return $ ret ; }
|
Dice si una mesa esta cobrada o no
|
8,747
|
function estaAbierta ( $ id = null ) { if ( ! empty ( $ id ) ) { $ this -> id = $ id ; } $ ret = $ this -> find ( 'count' , array ( 'conditions' => array ( 'Mesa.estado_id' => MESA_ABIERTA , 'Mesa.id' => $ this -> id , ) ) ) ; return ( $ ret > 0 ) ; }
|
Dice si una mesa esta abierta o no
|
8,748
|
function totalesDeMesasEntre ( $ fechaDesde = '' , $ fechaHasta = '' , $ conds = array ( ) ) { $ horarioCorte = Configure :: read ( 'Horario.corte_del_dia' ) ; if ( $ horarioCorte < 10 ) { $ horarioCorte = "0$horarioCorte" ; } $ sqlHorarioDeCorte = "DATE(SUBTIME(Mesa.checkin, '$horarioCorte:00:00'))" ; $ desde = empty ( $ fechaDesde ) ? date ( 'Y-m-d' , strtotime ( 'now' ) ) : $ fechaDesde ; $ hasta = empty ( $ fechaHasta ) ? date ( 'Y-m-d' , strtotime ( 'now' ) ) : $ fechaHasta ; $ defaultOrder = array ( ) ; $ defaultFields = array ( 'count(*) as "cant_mesas"' , 'sum(Mesa.cant_comensales) as "cant_cubiertos"' , 'sum(Mesa.subtotal) as "subtotal"' , 'sum(Mesa.total) as "total"' , 'sum(Mesa.total)/sum(Mesa.cant_comensales) as "promedio_cubiertos"' , "$sqlHorarioDeCorte as fecha" , ) ; $ defaultGroup = array ( "$sqlHorarioDeCorte" , ) ; if ( empty ( $ conds [ 'order' ] ) ) { $ defaultOrder = array ( "Mesa.checkin DESC" ) ; } $ defaultConditions = array ( 'Mesa.deleted' => '0' , "$sqlHorarioDeCorte BETWEEN '$desde' AND '$hasta'" ) ; $ ops = array ( 'fields' => $ defaultFields , 'conditions' => $ defaultConditions , 'group' => $ defaultGroup , 'order' => $ defaultOrder , ) ; $ ops = array_merge_recursive ( $ ops , $ conds ) ; $ mesas = $ this -> find ( 'all' , $ ops ) ; return $ mesas ; }
|
Me devuelve un listado agrupado por dia de mesas . Util para estadistica y contabilidad
|
8,749
|
public function changeRoomStateIfTodayInPeriod ( $ room , $ checkin , $ checkout ) { if ( ! is_array ( $ room ) && ( is_string ( $ room ) || is_int ( $ room ) ) ) { $ room = $ this -> Room -> findById ( $ room ) ; } $ today = date ( 'Y-m-d' ) ; if ( $ this -> hasRoomMesaInDate ( $ room , $ today ) ) { return $ this -> Room -> changeRoomState ( $ room , 2 ) ; } else { if ( $ room [ 'Room' ] [ 'room_state_id' ] != 4 ) { return $ this -> Room -> changeRoomState ( $ room , 1 ) ; } } }
|
change the room state if today is between period of Mesa for a given nombre_mesa_id or room object
|
8,750
|
public static function create ( ) { $ app = new CLIApplication ( 'Dachi' , Kernel :: getVersion ( true ) ) ; $ commands = array ( new \ Dachi \ Core \ Console \ Command \ TestCommand ( ) , new \ Dachi \ Core \ Console \ Command \ CreateCommand ( ) , new \ Dachi \ Core \ Console \ Command \ DocumentCommand ( ) , new \ Dachi \ Core \ Console \ Command \ RouteCommand ( ) , new \ Dachi \ Core \ Console \ Command \ ModulesCommand ( ) , new \ Dachi \ Core \ Console \ Command \ ConfigCommand ( ) , new \ Dachi \ Core \ Console \ Command \ AllCommand ( ) ) ; foreach ( $ commands as $ commandClass ) { $ app -> add ( $ commandClass ) ; } $ app -> run ( ) ; }
|
Create the CLI application
|
8,751
|
public function validateDocBlocks ( $ data ) { $ element = $ data -> getSubject ( ) ; $ docblock = $ data -> getDocblock ( ) ; $ type = substr ( get_class ( $ element ) , strrpos ( get_class ( $ element ) , '\\' ) + 1 , - 9 ) ; if ( $ docblock && $ docblock -> hasTag ( 'ignore' ) ) { return ; } $ validatorOptions = $ this -> loadConfiguration ( ) ; foreach ( array ( 'Deprecated' , 'Required' , $ type ) as $ validator ) { $ class = 'phpDocumentor\Plugin\Core\Parser\DocBlock\Validator\\' . $ validator . 'Validator' ; if ( class_exists ( $ class ) ) { $ val = new $ class ( $ element -> getName ( ) , $ docblock , $ element ) ; $ val -> setOptions ( $ validatorOptions ) ; $ val -> isValid ( $ element ) ; } } }
|
Checks all phpDocumentor whether they match the given rules .
|
8,752
|
public function pdo ( PDO $ pdo = null ) { if ( $ pdo ) { $ this -> pdo = $ pdo ; } return $ this -> pdo ; }
|
Get or set PDO instance
|
8,753
|
public function quoteIdentifier ( $ identifier ) { $ parts = explode ( "." , $ identifier ) ; if ( count ( $ parts ) > 1 ) { return $ this -> quoteIdentifier ( $ parts [ 0 ] ) . '.' . $ this -> quoteIdentifier ( $ parts [ 1 ] ) ; } return '`' . str_replace ( '`' , '``' , $ identifier ) . '`' ; }
|
Quote an identifier for MySQL query usage
|
8,754
|
public function merge ( $ query , array $ data ) { $ expression = "/(\\?)(?=(?:[^']|'[^']*')*$)/" ; $ callback = function ( ) use ( & $ data ) { if ( ! $ data ) { return '?' ; } return $ this -> quote ( array_shift ( $ data ) ) ; } ; return preg_replace_callback ( $ expression , $ callback , $ query ) ; }
|
Merge data into an SQL query with placeholders
|
8,755
|
public function query ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { $ statement = $ this -> pdo -> query ( $ query ) ; return new Result ( $ statement ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ exception , $ query ) ; } }
|
Run a query and return the result
|
8,756
|
public function fetch ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { $ statement = $ this -> pdo -> query ( $ query ) ; return new FetchedResult ( $ statement -> fetchAll ( PDO :: FETCH_ASSOC ) ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ exception , $ query ) ; } }
|
Run a query and eagerly fetch the result into memory
|
8,757
|
public function execute ( $ query , ... $ data ) { if ( $ data ) { $ query = $ this -> merge ( $ query , $ data ) ; } try { return $ this -> pdo -> exec ( $ query ) ; } catch ( PDOException $ exception ) { throw new QueryException ( $ exception , $ query ) ; } }
|
Execute a query and return the number of rows affected
|
8,758
|
public function insert ( $ table , array $ data = null ) { $ insert = $ this -> build ( ) -> insert ( $ table ) ; if ( $ data ) { return $ insert -> values ( $ data ) -> execute ( ) ; } return $ insert ; }
|
Insert data into a table
|
8,759
|
public function update ( $ table , array $ data = null , $ where = null ) { $ update = $ this -> build ( ) -> update ( $ table ) ; if ( $ data ) { $ update -> set ( $ data ) ; } if ( $ where ) { $ update -> where ( $ where ) ; } if ( $ data && $ where ) { return $ update -> execute ( ) ; } return $ update ; }
|
Update data in a table
|
8,760
|
public function delete ( $ table , $ where = null ) { $ delete = $ this -> build ( ) -> delete ( $ table ) ; if ( $ where ) { return $ delete -> where ( $ where ) -> execute ( ) ; } return $ delete ; }
|
Delete from a table
|
8,761
|
public function transaction ( callable $ closure ) { $ this -> start ( ) ; try { $ result = $ closure ( ) ; } catch ( \ Throwable $ e ) { $ this -> rollback ( ) ; throw $ e ; } $ this -> commit ( ) ; return $ result ; }
|
Run a closure inside a transaction
|
8,762
|
public function encrypt ( $ string ) { $ td = mcrypt_module_open ( $ this -> cypher , '' , $ this -> mode , '' ) ; $ iv = mcrypt_create_iv ( mcrypt_enc_get_iv_size ( $ td ) , mcrypt_RAND ) ; mcrypt_generic_init ( $ td , $ this -> key , $ iv ) ; $ encrypted = mcrypt_generic ( $ td , $ string ) ; mcrypt_generic_deinit ( $ td ) ; return $ iv . $ encrypted ; }
|
Encrypts a string
|
8,763
|
public function decrypt ( $ string ) { $ decrypted = "" ; $ td = mcrypt_module_open ( $ this -> cypher , '' , $ this -> mode , '' ) ; $ ivsize = mcrypt_enc_get_iv_size ( $ td ) ; $ iv = substr ( $ string , 0 , $ ivsize ) ; $ string = substr ( $ string , $ ivsize ) ; if ( $ iv ) { mcrypt_generic_init ( $ td , $ this -> key , $ iv ) ; $ decrypted = mdecrypt_generic ( $ td , $ string ) ; } return rtrim ( $ decrypted ) ; }
|
Decrypts a string
|
8,764
|
public function getCurrentLogFilePath ( ) { $ rotateTimeMark = "" ; if ( $ this -> rotateTimeFormat !== null ) { $ rotateTimeMark .= "-" . date ( $ this -> rotateTimeFormat ) ; } if ( is_callable ( $ this -> prefix ) ) { $ prefix = call_user_func_array ( $ this -> prefix , [ ] ) ; } else { $ prefix = $ this -> prefix ; } return $ this -> targetLogDir . '/log' . ( empty ( $ this -> prefix ) ? '' : "-" . $ prefix ) . $ rotateTimeMark . '.log' ; }
|
Sometime you may need to know where the log file is
|
8,765
|
public function print ( $ level , $ message , array $ context = array ( ) , $ enforceEndOfLine = true ) { if ( $ this -> shouldIgnoreThisLog ( $ level ) ) { return ; } $ msg = $ this -> generateLog ( $ level , $ message , $ context , $ enforceEndOfLine ) ; echo $ msg ; }
|
If you want to output log directly to STDOUT use this .
|
8,766
|
private static function _get_db ( ) : ? bbn \ db { if ( self :: $ db && self :: $ db -> check ( ) ) { return self :: $ db ; } return null ; }
|
Returns the database connection object .
|
8,767
|
private static function _get_databases ( ) : ? databases { if ( self :: check ( ) ) { if ( ! self :: $ databases_obj && ( $ db = self :: _get_db ( ) ) ) { self :: $ databases_obj = new databases ( $ db ) ; } return self :: $ databases_obj ; } return null ; }
|
Returns an instance of the appui \ database class .
|
8,768
|
private static function _insert ( array $ cfg ) : int { if ( isset ( $ cfg [ 'column' ] , $ cfg [ 'line' ] , $ cfg [ 'chrono' ] ) && self :: check ( ) && ( $ db = self :: _get_db ( ) ) ) { $ id = $ db -> last_id ( ) ; $ last = self :: $ db -> last ( ) ; $ last_params = self :: $ db -> last_params ; self :: disable ( ) ; if ( ! array_key_exists ( 'old' , $ cfg ) ) { $ cfg [ 'ref' ] = null ; $ cfg [ 'val' ] = null ; } else if ( bbn \ str :: is_uid ( $ cfg [ 'old' ] ) && self :: $ db -> count ( self :: $ table_uids , [ 'bbn_uid' => $ cfg [ 'old' ] ] ) ) { $ cfg [ 'ref' ] = $ cfg [ 'old' ] ; $ cfg [ 'val' ] = null ; } else { $ cfg [ 'ref' ] = null ; $ cfg [ 'val' ] = $ cfg [ 'old' ] ; } if ( $ res = $ db -> insert ( self :: $ table , [ 'opr' => $ cfg [ 'operation' ] , 'uid' => $ cfg [ 'line' ] , 'col' => $ cfg [ 'column' ] , 'val' => $ cfg [ 'val' ] , 'ref' => $ cfg [ 'ref' ] , 'tst' => self :: $ date ? : $ cfg [ 'chrono' ] , 'usr' => self :: $ user ] ) ) { $ db -> set_last_insert_id ( $ id ) ; } self :: $ db -> last_query = $ last ; self :: $ db -> last_params = $ last_params ; self :: enable ( ) ; return $ res ; } return 0 ; }
|
Adds a row in the history table
|
8,769
|
private static function _get_table_where ( string $ table ) : ? string { if ( bbn \ str :: check_name ( $ table ) && ( $ db = self :: _get_db ( ) ) && ( $ databases_obj = self :: _get_databases ( ) ) && ( $ model = $ databases_obj -> modelize ( $ table ) ) ) { $ col = $ db -> escape ( 'col' ) ; $ where_ar = [ ] ; foreach ( $ model [ 'fields' ] as $ k => $ f ) { if ( ! empty ( $ f [ 'id_option' ] ) ) { $ where_ar [ ] = $ col . ' = UNHEX("' . $ db -> escape_value ( $ f [ 'id_option' ] ) . '")' ; } } if ( \ count ( $ where_ar ) ) { return implode ( ' OR ' , $ where_ar ) ; } } return null ; }
|
Get a string for the WHERE in the query with all the columns selection
|
8,770
|
public static function get_id_column ( string $ column , string $ table ) : ? string { if ( ( $ db = self :: _get_db ( ) ) && ( $ full_table = $ db -> tfn ( $ table ) ) && ( $ databases_obj = self :: _get_databases ( ) ) ) { [ $ database , $ table ] = explode ( '.' , $ full_table ) ; return $ databases_obj -> column_id ( $ column , $ table , $ database , self :: $ db -> host ) ; } return false ; }
|
Returns the column s corresponding option s ID
|
8,771
|
public static function check ( ) : bool { return isset ( self :: $ user , self :: $ table , self :: $ db ) && self :: is_init ( ) && self :: _get_db ( ) ; }
|
Checks if all history parameters are set in order to read and write into history
|
8,772
|
public static function has_history ( bbn \ db $ db ) : bool { $ hash = $ db -> get_hash ( ) ; return \ in_array ( $ hash , self :: $ dbs , true ) ; }
|
Returns true if the given DB connection is configured for history
|
8,773
|
public static function set_column ( string $ column ) : void { if ( bbn \ str :: check_name ( $ column ) ) { self :: $ column = $ column ; } }
|
Sets the active column name
|
8,774
|
public static function set_admin_db ( string $ db_name ) : void { if ( bbn \ str :: check_name ( $ db_name ) ) { self :: $ admin_db = $ db_name ; self :: $ table = self :: $ admin_db . '.' . self :: $ prefix . 'history' ; } }
|
Sets the history table name
|
8,775
|
public static function set_user ( $ user ) : void { if ( bbn \ str :: is_uid ( $ user ) ) { self :: $ user = $ user ; } }
|
Sets the user ID that will be used to fill the user_id field
|
8,776
|
public function is_image ( $ path ) { if ( ! file_exists ( $ path ) || ! ( $ info = getimagesize ( $ path ) ) ) { return false ; } return ( bool ) preg_match ( "/^image\/(jpeg|png|gif)$/" , $ info [ 'mime' ] ) ; }
|
Detect if specified file is image
|
8,777
|
public function get_mime ( $ file ) { $ type = $ this -> get_content_type ( $ file ) ; if ( $ type ) { $ type = array_map ( 'trim' , explode ( ';' , $ type ) ) ; return $ type [ 0 ] ; } else { return '' ; } }
|
Return mime type
|
8,778
|
public function get_content_type ( $ path ) { if ( file_exists ( $ path ) ) { $ info = finfo_open ( FILEINFO_MIME ) ; $ type = finfo_file ( $ info , $ path ) ; finfo_close ( $ info ) ; return $ type ? : '' ; } else { return '' ; } }
|
Get content type
|
8,779
|
public function merge ( array $ metadata ) : array { $ tables = [ ] ; foreach ( $ metadata as $ entity ) { $ tables [ $ entity -> getTableName ( ) ] [ ] = $ entity ; } $ merged = [ ] ; foreach ( $ tables as $ table => $ metadata ) { if ( count ( $ metadata ) === 1 ) { $ merged [ ] = array_shift ( $ metadata ) ; continue ; } $ primary = $ this -> resolvePrimaryMetadata ( $ metadata ) ; foreach ( $ metadata as $ secondary ) { $ primary = $ this -> mergeMetadata ( $ primary , $ secondary ) ; } $ primary -> fieldMappings = $ this -> mappingCleanup ( $ primary -> fieldMappings ) ; $ primary -> associationMappings = $ this -> mappingCleanup ( $ primary -> associationMappings ) ; $ merged [ ] = $ primary ; } return $ merged ; }
|
Merges metadata of multiple doctrine entities .
|
8,780
|
public function init ( ) { $ args = $ this -> console -> arguments ; $ args -> parse ( ) ; if ( $ args -> defined ( 'hardstart' ) ) { $ this -> hardstart ( ) ; } if ( $ args -> defined ( 'daemon' ) ) { $ this -> daemonize ( ) ; } else if ( $ args -> defined ( 'foreground' ) ) { if ( $ args -> defined ( 'verbose' ) ) { $ this -> logger -> pushHandler ( new LogHandler ( ) ) ; } $ this -> start ( ) ; } else { $ this -> console -> pad ( ) -> green ( ) -> usage ( ) ; $ this -> end ( 0 ) ; } }
|
Parse console arguments and init the daemon
|
8,781
|
public function daemonize ( ) { $ pid = $ this -> fork ( ) ; $ this -> detach ( ) ; $ this -> pid = $ pid ; $ this -> start ( ) ; }
|
Start as a daemon forking main process and detaching it from terminal
|
8,782
|
public function url ( $ page ) { if ( $ page <= 0 ) { $ page = 1 ; } $ parameters = [ $ this -> pageName => $ page ] ; if ( count ( $ this -> query ) > 0 ) { $ parameters = array_merge ( $ this -> query , $ parameters ) ; } $ uri = Uri :: createFromString ( $ this -> path ) ; parse_str ( $ uri -> getQuery ( ) , $ queryParts ) ; return $ uri -> withQuery ( http_build_query ( $ parameters + $ queryParts ) ) -> withFragment ( $ this -> buildFragment ( ) ) -> __toString ( ) ; }
|
Get the URL for a given page number .
|
8,783
|
public function addClient ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Application \ API \ OAuth \ Client \ Client $ client ) { $ this -> clients [ ] = $ client ; return $ this ; }
|
Add client .
|
8,784
|
public function removeClient ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Application \ API \ OAuth \ Client \ Client $ client ) { return $ this -> clients -> removeElement ( $ client ) ; }
|
Remove client .
|
8,785
|
public function getLimits ( ) { $ totalPages = $ this -> getTotalPages ( ) ; $ this -> currentPage = ( $ this -> currentPage > $ totalPages ) ? $ totalPages : $ this -> currentPage ; $ dLimit = ( $ this -> currentPage - 1 ) * $ this -> itemsPerPage ; return array ( $ dLimit , $ this -> itemsPerPage ) ; }
|
Returns the offset ant length for limiting results to current page
|
8,786
|
public function post ( ... $ keys ) { if ( ! $ keys ) { return $ this -> request -> values ; } elseif ( count ( $ keys ) === 1 ) { return $ this -> request -> value ( $ keys [ 0 ] ) ; } $ values = [ ] ; foreach ( $ keys as $ key ) { $ values [ ] = $ this -> request -> value ( $ key ) ; } return $ values ; }
|
Get post value
|
8,787
|
public function initialize ( $ object ) { if ( ! is_object ( $ object ) ) { return ; } foreach ( $ this -> knownDependencies as $ interface => $ dependencyInfo ) { list ( $ setterMethod , $ serviceId ) = $ dependencyInfo ; if ( is_a ( $ object , $ interface ) ) { $ object -> $ setterMethod ( $ this -> container -> get ( $ serviceId ) ) ; } } }
|
Initializes object dependencies
|
8,788
|
public function getWorkspaces ( ) { return $ this -> getCachedProperty ( 'workspaces' , function ( ) { $ workspaces = [ ] ; $ items = $ this -> getDomElement ( ) -> getElementsByTagNameNS ( $ this -> ns ( ) , 'workspace' ) ; foreach ( $ items as $ item ) { $ workspaces [ ] = $ this -> getExtensions ( ) -> parseElement ( $ this , $ item ) ; } return $ workspaces ; } ) ; }
|
Return workspaces .
|
8,789
|
public function addWorkspace ( $ title ) { $ workspaces = $ this -> getWorkspaces ( ) ; $ workspace = $ this -> getExtensions ( ) -> createElement ( $ this , 'app:workspace' ) ; $ workspace -> addTitle ( $ title ) ; $ workspaces [ ] = $ workspace ; $ this -> setCachedProperty ( 'workspaces' , $ workspaces ) ; return $ workspace ; }
|
Add workspace to document .
|
8,790
|
public function getArticles ( $ articleNumber = null ) { $ requestData = new Get \ RequestData ( ) ; $ requestData -> setArticleNumber ( $ articleNumber ) ; $ request = new Get \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; }
|
Get the articles .
|
8,791
|
public function getArticle ( $ articleNumber ) { $ requestData = new Get \ RequestData ( ) ; $ requestData -> setArticleNumber ( $ articleNumber ) ; $ request = new Get \ Request ( $ requestData ) ; $ request -> setLimit ( 1 ) ; $ apiResponse = $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; $ articles = $ apiResponse -> getResponse ( ) -> getArticles ( ) ; return isset ( $ articles [ 0 ] ) ? $ articles [ 0 ] : null ; }
|
Get one article by article number .
|
8,792
|
public function getArticleNumberCheckoutURL ( $ articleNumber , Customer $ customer = null ) { $ article = $ this -> getArticle ( $ articleNumber ) ; if ( $ article === null ) { throw new \ OutOfBoundsException ( 'Article not found.' ) ; } return $ this -> getArticleCheckoutURL ( $ article , $ customer ) ; }
|
Get the checkout URL for an article .
|
8,793
|
protected function generateCheckoutURLForCustomer ( $ customerHash , $ articleNumber ) { return sprintf ( 'https://app.monsum.com/checkout/0/%s/%s/%s' , $ this -> transport -> getCredentials ( ) -> getAccountHash ( ) , $ customerHash , $ articleNumber ) ; }
|
Get the checkout URL of an article for a customer .
|
8,794
|
public function execute ( $ params = array ( ) ) { $ app = $ this -> router -> getAppInstance ( ) ; return $ app -> trigger ( "system.routing.route.execute" , function ( $ event ) { $ app = $ event -> props ( 'app' ) ; $ route = $ event -> props ( 'route' ) ; $ params = $ event -> props ( 'params' ) ; if ( count ( $ params ) == 0 ) { $ params = $ route -> getParams ( ) ; } $ callback = $ route -> getCallback ( ) ; if ( is_string ( $ callback ) ) { $ callback_comps = explode ( "#" , $ callback ) ; $ callback_object_class = $ callback_comps [ 0 ] ; $ callback_object_class = str_replace ( "." , "\\" , $ callback_object_class ) ; $ callback_object = new $ callback_object_class ( $ app ) ; $ callback_object_method = $ callback_comps [ 1 ] ; $ callback = array ( $ callback_object , $ callback_object_method ) ; } return call_user_func_array ( $ callback , $ params ) ; } , array ( 'app' => $ app , 'route' => $ this , 'params' => $ params ) ) ; }
|
Execute this route
|
8,795
|
public function eachRole ( array $ roles , callable $ callback ) { $ roles = array_flatten ( $ roles ) ; foreach ( $ roles as $ role ) { if ( $ role = $ this -> prepareRole ( $ role ) ) { $ callback ( $ role ) ; } } }
|
Calc each rote
|
8,796
|
public function writeTimedLog ( $ message , $ operation , array $ arguments = array ( ) ) { $ this -> write ( sprintf ( '%-66.66s .. ' , $ message ) ) ; $ timerStart = microtime ( true ) ; call_user_func_array ( $ operation , $ arguments ) ; $ this -> writeln ( sprintf ( '%8.3fs' , microtime ( true ) - $ timerStart ) ) ; }
|
Executes a callable piece of code and writes an entry to the log detailing how long it took .
|
8,797
|
public function write ( $ message , $ newline = false , $ type = 0 ) { $ messages = ( array ) $ message ; if ( $ this -> getLogger ( ) ) { foreach ( $ messages as $ message ) { $ this -> getLogger ( ) -> info ( $ this -> getFormatter ( ) -> format ( strip_tags ( $ message ) ) ) ; } } parent :: write ( $ messages , $ newline , $ type ) ; }
|
Write an entry to the console and to the provided logger .
|
8,798
|
protected function formatErrors ( string $ errors ) { $ errors = json_decode ( $ errors ) ; $ output = '' ; foreach ( $ errors as $ error ) foreach ( $ error as $ message ) $ output .= $ message . "\r\n" ; return $ output ; }
|
Must return string!!
|
8,799
|
public function hasFunctionAccess ( $ user , $ functionName , $ contentObject , $ languageCode , $ comment = null , $ scope = null , $ node = null ) { $ result = $ user -> hasAccessTo ( self :: $ moduleName , $ functionName ) ; if ( $ result [ 'accessWord' ] !== 'limited' ) { $ return = ( $ result [ 'accessWord' ] === 'yes' ) and ( $ scope !== 'personal' ) ; } else { foreach ( $ result [ 'policies' ] as $ limitationArray ) { $ return = true ; foreach ( $ limitationArray as $ limitationKey => $ limitation ) { $ resultItem = $ this -> checkPermission ( $ user , $ limitationKey , $ limitation , $ contentObject , $ languageCode , $ comment , $ scope , $ node ) ; ezDebugSetting :: writeNotice ( 'extension-ezcomments' , "Permission check result for function '$functionName' with limitation '$limitationKey': " . ( $ resultItem === true ? 'true' : 'false' ) , __METHOD__ ) ; $ return = ( $ return and $ resultItem ) ; } if ( $ return === true ) break ; } } return $ return ; }
|
check if the user has Acceess to the object with limitation of class section owner language nodes subtrees
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.