idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
19,500 | public static function snakeCase ( $ value ) { $ key = $ value ; if ( isset ( static :: $ snakeCache [ $ key ] ) ) { return static :: $ snakeCache [ $ key ] ; } $ value = preg_replace ( '/\s+/' , '' , ucwords ( $ value ) ) ; $ value = str_replace ( '-' , '_' , $ value ) ; $ value = static :: normalizeScreamingCase ( $ value ) ; return static :: $ snakeCache [ $ key ] = strtolower ( preg_replace ( '~(?<=\\w)([A-Z])~' , '_$1' , $ value ) ) ; } | Convert a value to snake_case . |
19,501 | public static function kebabCase ( $ value ) { $ key = $ value ; if ( isset ( static :: $ kebabCache [ $ key ] ) ) { return static :: $ kebabCache [ $ key ] ; } $ value = preg_replace ( '/\s+/' , '' , ucwords ( $ value ) ) ; $ value = str_replace ( '_' , '-' , $ value ) ; $ value = static :: normalizeScreamingCase ( $ value ) ; return static :: $ kebabCache [ $ key ] = strtolower ( preg_replace ( '~(?<=\\w)([A-Z])~' , '-$1' , $ value ) ) ; } | Convert a value to kebab - case . |
19,502 | public static function pascalCase ( $ value ) { if ( isset ( static :: $ pascalCache [ $ value ] ) ) { return static :: $ pascalCache [ $ value ] ; } $ value = static :: normalizeScreamingCase ( $ value ) ; return static :: $ pascalCache [ $ value ] = str_replace ( ' ' , '' , ucwords ( str_replace ( [ '-' , '_' ] , ' ' , $ value ) ) ) ; } | Convert a value to PascalCase . |
19,503 | public static function camelCase ( $ value ) { if ( isset ( static :: $ camelCache [ $ value ] ) ) { return static :: $ camelCache [ $ value ] ; } return static :: $ camelCache [ $ value ] = lcfirst ( static :: pascalCase ( $ value ) ) ; } | Convert a value to camelCase . |
19,504 | public function dispatchAction ( ) { $ category = $ this -> _getPublishedCategoryByUri ( $ this -> uri ) ; FrontController :: getInstance ( ) -> getView ( ) -> category = $ category ; $ cacheKey = 'category-html-' . $ category -> id ; $ bufferingAllowed = $ this -> _bufferingAllowed ( ) ; if ( $ bufferingAllowed && ( null !== $ html = \ App \ Registry :: $ cache -> load ( $ cacheKey ) ) ) { $ this -> getResponse ( ) -> setHeader ( 'X-Cache' , 'HIT' ) ; return $ this -> _decorateHtmlWithEditButton ( $ html , $ category ) ; } $ this -> getResponse ( ) -> setHeader ( 'X-Cache' , 'MISS' ) ; $ this -> view -> category = $ category ; $ html = \ Mmi \ Mvc \ ActionHelper :: getInstance ( ) -> forward ( $ this -> _prepareForwardRequest ( $ category ) ) ; if ( ! $ bufferingAllowed || 0 == $ cacheLifetime = $ this -> _getCategoryCacheLifetime ( $ category ) ) { return $ this -> _decorateHtmlWithEditButton ( $ html , $ category ) ; } \ App \ Registry :: $ cache -> save ( $ html , $ cacheKey , $ cacheLifetime ) ; return $ this -> _decorateHtmlWithEditButton ( $ html , $ category ) ; } | Akcja dispatchera kategorii |
19,505 | protected function _prepareForwardRequest ( \ Cms \ Orm \ CmsCategoryRecord $ category ) { $ request = clone $ this -> getRequest ( ) ; $ request -> setModuleName ( 'cms' ) -> setControllerName ( 'category' ) -> setActionName ( 'article' ) ; if ( $ category -> mvcParams ) { $ mvcParams = [ ] ; parse_str ( $ category -> mvcParams , $ mvcParams ) ; return $ request -> setParams ( $ mvcParams ) ; } if ( ! $ category -> getJoined ( 'cms_category_type' ) -> mvcParams ) { return $ request ; } $ mvcParams = [ ] ; parse_str ( $ category -> getJoined ( 'cms_category_type' ) -> mvcParams , $ mvcParams ) ; return $ request -> setParams ( $ mvcParams ) ; } | Pobiera request do przekierowania |
19,506 | protected function _decorateHtmlWithEditButton ( $ html , \ Cms \ Orm \ CmsCategoryRecord $ category ) { if ( ! $ this -> _hasRedactorRole ( ) ) { return $ html ; } return str_replace ( '</body>' , \ Mmi \ Mvc \ ActionHelper :: getInstance ( ) -> action ( new \ Mmi \ Http \ Request ( [ 'module' => 'cms' , 'controller' => 'category' , 'action' => 'editButton' , 'originalId' => $ category -> cmsCategoryOriginalId , 'categoryId' => $ category -> id ] ) ) . '</body>' , $ html ) ; } | Pobiera request do renderowania akcji |
19,507 | protected function _getCategoryCacheLifetime ( \ Cms \ Orm \ CmsCategoryRecord $ category ) { $ cacheLifetime = ( null !== $ category -> cacheLifetime ) ? $ category -> cacheLifetime : ( ( null !== $ category -> getJoined ( 'cms_category_type' ) -> cacheLifetime ) ? $ category -> getJoined ( 'cms_category_type' ) -> cacheLifetime : Orm \ CmsCategoryRecord :: DEFAULT_CACHE_LIFETIME ) ; if ( 0 == $ cacheLifetime ) { return 0 ; } foreach ( $ category -> getWidgetModel ( ) -> getWidgetRelations ( ) as $ widgetRelation ) { if ( 0 == $ widgetCacheLifetime = $ widgetRelation -> getWidgetRecord ( ) -> cacheLifetime ) { return 0 ; } $ cacheLifetime = ( $ cacheLifetime > $ widgetCacheLifetime ) ? $ widgetCacheLifetime : $ cacheLifetime ; } return $ cacheLifetime ; } | Zwraca czas buforowania kategorii |
19,508 | protected function _bufferingAllowed ( ) { if ( \ App \ Registry :: $ config -> category instanceof \ Cms \ Config \ CategoryConfig && \ App \ Registry :: $ config -> category -> bufferingAllowedClass ) { $ class = \ App \ Registry :: $ config -> category -> bufferingAllowedClass ; $ buffering = new $ class ( $ this -> _request ) ; } else { $ buffering = new \ Cms \ Model \ CategoryBuffering ( $ this -> _request ) ; } return $ buffering -> isAllowed ( ) ; } | Czy buforowanie dozwolone |
19,509 | public function filePutsContent ( $ path , $ content ) { if ( @ file_put_contents ( $ path , $ content ) === false ) { throw new \ RuntimeException ( sprintf ( "Could't puts content %s" , $ path ) ) ; } chmod ( $ path , 0777 ) ; } | Puts content into file |
19,510 | public function ifDirDoesNotExistCreate ( $ directory , $ recursive = false ) { if ( $ this -> isDir ( $ directory ) === false ) { $ this -> mkdir ( $ directory , $ recursive ) ; return true ; } else { return false ; } } | Create dir if not exist |
19,511 | function get_rules ( $ nt ) { $ rules = array ( ) ; if ( isset ( $ this -> ntindex [ $ nt ] ) ) { foreach ( $ this -> ntindex [ $ nt ] as $ i ) { $ rules [ $ i ] = $ this -> rules [ $ i ] ; } } return $ rules ; } | Get rules by non - terminal left hand side |
19,512 | function follow_set ( $ s ) { if ( ! isset ( $ this -> follows [ $ s ] ) ) { $ type = $ this -> is_terminal ( $ s ) ? 'terminal' : 'non-terminal' ; trigger_error ( "No follow set for $type $s" , E_USER_WARNING ) ; return array ( ) ; } return $ this -> follows [ $ s ] ; } | Get FOLLOW set for a single given symbol |
19,513 | public function extract ( callable $ callback = null ) { if ( $ callback === null ) { $ result = $ this -> result -> toArray ( ) ; } else { $ result = $ callback ( $ this -> result -> toArray ( ) ) ; } return $ result ; } | Extract result data to array |
19,514 | public function getTraceAsString ( ) { $ lines = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> trace ) ; $ i ++ ) { $ a = $ this -> trace [ $ i ] ; $ call = "{$a['function']}()" ; if ( isset ( $ a [ 'class' ] ) ) { $ call = "{$a['class']}{$a['type']}$call" ; } $ lines [ ] = "#$i {$a['file']}({$a['line']}): $call" ; } $ lines [ ] = "#$i {main}" ; return implode ( "\n" , $ lines ) ; } | Get backtrace from where error was raised as string as per built - in Exception class |
19,515 | public function raise ( ) { if ( PLUG_ERROR_LOGGING & $ this -> type ) { $ logfile = defined ( 'PLUG_ERROR_LOG' ) ? PLUG_ERROR_LOG : '' ; $ logged = self :: log ( call_user_func ( self :: $ logfunc , $ this ) , $ logfile ) ; } if ( PLUG_ERROR_REPORTING & $ this -> type || $ this -> type === E_USER_INTERNAL ) { $ this -> id = self :: $ i ++ ; self :: $ stack [ $ this -> type ] [ $ this -> id ] = $ this ; if ( PLUG_CLI ) { self :: log ( call_user_func ( self :: $ logfunc , $ this ) , STDERR ) ; } } $ fatal = E_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR ; if ( $ this -> type & $ fatal ) { call_user_func ( self :: $ deathfunc , $ this ) ; } } | Dispatch this error |
19,516 | private static function death ( PLUGError $ Err ) { if ( PLUG_CLI ) { $ logfile = ini_get ( 'error_log' ) ; if ( $ logfile ) { PLUGCli :: stdout ( "Error, %s exiting %s\n" , $ Err -> getMessage ( ) , $ Err -> code ) ; } } else { PLUG :: dump_errors ( ) ; } exit ( $ Err -> code ) ; } | Default script exit handler |
19,517 | static function log ( $ logline , $ out = '' ) { if ( is_resource ( $ out ) && fwrite ( $ out , "$logline\n" ) ) { return true ; } else if ( $ out && error_log ( "$logline\n" , 3 , $ out ) ) { return $ out ; } else if ( error_log ( $ logline , 0 ) ) { $ out = ini_get ( 'error_log' ) ; return $ out ? $ out : true ; } else { return false ; } } | Log an error string . |
19,518 | static function display ( PLUGError $ Err ) { $ html = ini_get ( 'html_errors' ) ; if ( $ html ) { $ s = '<div class="error"><strong>%s:</strong> %s. in <strong>%s</strong> on line <strong>%u</strong></div>' ; } else { $ s = "\n%s: %s. in %s on line %u" ; } $ args = array ( $ s , $ Err -> getTypeString ( ) , $ Err -> getMessage ( ) , $ Err -> getFile ( ) , $ Err -> getLine ( ) ) ; if ( ! PLUG :: is_compiled ( ) ) { $ args [ 0 ] .= $ html ? "\n<pre>%s</pre>" : "\n%s" ; $ args [ ] = $ Err -> getTraceAsString ( ) ; } return call_user_func_array ( 'sprintf' , $ args ) ; } | Default error formatting function |
19,519 | public function clear ( ) { unset ( self :: $ stack [ $ this -> type ] [ $ this -> id ] ) ; if ( empty ( self :: $ stack [ $ this -> type ] ) ) { unset ( self :: $ stack [ $ this -> type ] ) ; } $ this -> id = null ; } | Clear this error |
19,520 | static function get_errors ( $ emask = null ) { $ all = array ( ) ; foreach ( self :: $ stack as $ type => $ errs ) { if ( $ emask === null || $ type & $ emask ) { foreach ( $ errs as $ Err ) { $ all [ ] = $ Err ; } } } return $ all ; } | Get all raised errors of specific types |
19,521 | static function & get_reference ( $ type , $ id ) { if ( empty ( self :: $ stack [ $ type ] [ $ id ] ) ) { $ null = null ; return $ null ; } else { return self :: $ stack [ $ type ] [ $ id ] ; } } | Get a reference to an error instance . |
19,522 | static function is_error ( $ emask = null ) { if ( $ emask === null ) { return ( bool ) self :: get_global_level ( ) ; } else { return ( bool ) ( self :: get_global_level ( ) & $ emask ) ; } } | Test whether errors of a certain type have been raised system wide |
19,523 | static function get_global_level ( ) { $ e = 0 ; $ types = array_keys ( self :: $ stack ) ; foreach ( $ types as $ t ) { $ e |= $ t ; } return $ e ; } | get system wide level of errors |
19,524 | private function isFirstLevelIsDto ( \ JSONSchema \ Structure \ Schema $ schema ) { $ isFirstLevelIsDto = false ; foreach ( $ schema -> getProperties ( ) as $ propertie ) { if ( in_array ( $ propertie -> getType ( ) , array ( 'object' , 'array' ) ) === false ) { $ isFirstLevelIsDto = true ; } } return $ isFirstLevelIsDto ; } | Is there is only array or object at the first level its not considered as a metadata but as a collection of it |
19,525 | private function hydrateItems ( $ daddyName , array $ items , MetadataDataObjectJson $ metadata , MetaDataCollection $ mainCollection ) { $ mergeArray = true ; if ( $ mergeArray === true && $ this -> itemsAreAllOfType ( $ items , array ( 'object' ) ) === true ) { $ metadata -> appendRelation ( $ this -> hydrateMetaDataRelationColumn ( $ daddyName , $ this -> mergeItems ( $ items ) , $ metadata , $ mainCollection ) ) ; } else { $ specialProperties = array ( ) ; foreach ( $ items as $ propName => $ item ) { if ( in_array ( $ item -> getType ( ) , array ( 'object' , 'array' ) ) === false ) { $ specialProperties [ $ propName ] = $ item ; continue ; } $ metadata -> appendRelation ( $ this -> hydrateMetaDataRelationColumn ( $ daddyName , $ item -> getProperties ( ) , $ metadata , $ mainCollection ) ) ; } } return $ metadata ; } | Items is considered as relation |
19,526 | private function hydrateProperties ( array $ properties , MetadataDataObjectJson $ metadata , MetaDataCollection $ mainCollection ) { $ specialProperties = array ( ) ; foreach ( $ properties as $ propName => $ propertie ) { if ( false === ( $ propertie instanceof \ JSONSchema \ Structure \ Property ) ) { throw new \ Exception ( '$propertie is not an instance of Property' ) ; } if ( in_array ( $ propertie -> getType ( ) , array ( 'object' , 'array' ) ) === true ) { $ specialProperties [ $ propName ] = $ propertie ; continue ; } $ column = new MetaDataColumn ( ) ; $ column -> setNullable ( ! $ propertie -> getRequired ( ) ) ; $ column -> setName ( $ propertie -> getName ( ) ) ; $ column -> setType ( $ propertie -> getType ( ) ) ; $ metadata -> appendColumn ( $ column ) ; } if ( $ specialProperties !== array ( ) ) { foreach ( $ specialProperties as $ prop ) { $ metadata -> appendRelation ( $ this -> hydrateMetaDataRelationColumn ( $ prop -> getName ( ) , $ prop -> getProperties ( ) , $ metadata , $ mainCollection ) ) ; } } return $ metadata ; } | Properties is considered as column |
19,527 | public function getMetadataFor ( $ tableName , array $ parentName = array ( ) ) { $ avaibleData = array ( ) ; foreach ( $ this -> getAllMetadata ( ) as $ metadata ) { $ avaibleData [ ] = $ metadata -> getName ( ) ; if ( $ metadata -> getName ( ) === $ tableName ) { return $ metadata ; } } throw new \ Exception ( sprintf ( '"%s" not found in "%s"' , $ tableName , implode ( ', ' , $ avaibleData ) ) ) ; } | Get particularie metadata from jsin |
19,528 | public static function pushEmail ( $ name , $ to , array $ params = [ ] , $ fromName = null , $ replyTo = null , $ subject = null , $ sendAfter = null , array $ attachments = [ ] ) { if ( null === ( $ def = Orm \ CmsMailDefinitionQuery :: langByName ( $ name ) -> findFirst ( ) ) ) { return false ; } $ email = new \ Mmi \ Validator \ EmailAddressList ; if ( ! $ email -> isValid ( $ to ) ) { return false ; } $ mail = new Orm \ CmsMailRecord ; $ mail -> cmsMailDefinitionId = $ def -> id ; $ mail -> to = $ to ; $ mail -> fromName = $ fromName ? $ fromName : $ def -> fromName ; $ mail -> replyTo = $ replyTo ? $ replyTo : $ def -> replyTo ; $ mail -> subject = $ subject ? $ subject : $ def -> subject ; $ mail -> dateSendAfter = $ sendAfter ? $ sendAfter : date ( 'Y-m-d H:i:s' ) ; $ files = [ ] ; foreach ( $ attachments as $ fileName => $ filePath ) { if ( ! file_exists ( $ filePath ) ) { continue ; } $ files [ $ fileName ] = ( $ filePath ) ; } $ mail -> attachements = serialize ( $ files ) ; $ view = \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) ; foreach ( $ params as $ key => $ value ) { $ view -> $ key = $ value ; } $ mail -> message = $ view -> renderDirectly ( $ def -> message ) ; $ mail -> subject = $ view -> renderDirectly ( $ mail -> subject ) ; $ mail -> dateAdd = date ( 'Y-m-d H:i:s' ) ; return $ mail -> save ( ) ; } | Dodaje email do kolejki |
19,529 | public static function getMultioptions ( ) { $ rows = ( new Orm \ CmsMailServerQuery ) -> whereActive ( ) -> equals ( 1 ) -> find ( ) ; $ pairs = [ ] ; foreach ( $ rows as $ row ) { $ pairs [ $ row -> id ] = $ row -> address . ':' . $ row -> port . ' (' . $ row -> username . ')' ; } return $ pairs ; } | Pobiera aktywne serwery do listy |
19,530 | protected function _compileComments ( $ value ) { $ pattern = sprintf ( '/%s--(.*?)--%s/s' , $ this -> _escapedTags [ 0 ] , $ this -> _escapedTags [ 1 ] ) ; return preg_replace ( $ pattern , '<?php /*$1*/ ?> ' , $ value ) ; } | Compile Sword comments into valid PHP . |
19,531 | protected function _compileEchos ( $ value ) { foreach ( $ this -> _getEchoMethods ( ) as $ method => $ length ) { $ value = $ this -> $ method ( $ value ) ; } return $ value ; } | Compile Sword echos into valid PHP . |
19,532 | protected function _getEchoMethods ( ) { $ methods = [ '_compileRawEchos' => strlen ( stripcslashes ( $ this -> _rawTags [ 0 ] ) ) , '_compileEscapedEchos' => strlen ( stripcslashes ( $ this -> _escapedTags [ 0 ] ) ) , ] ; uksort ( $ methods , static function ( $ method1 , $ method2 ) use ( $ methods ) { if ( $ methods [ $ method1 ] > $ methods [ $ method2 ] ) { return - 1 ; } if ( $ methods [ $ method1 ] < $ methods [ $ method2 ] ) { return 1 ; } if ( $ method1 === '_compileRawEchos' ) { return - 1 ; } if ( $ method2 === '_compileRawEchos' ) { return 1 ; } if ( $ method1 === '_compileEscapedEchos' ) { return - 1 ; } if ( $ method2 === '_compileEscapedEchos' ) { return 1 ; } return 0 ; } ) ; return $ methods ; } | Get the echo methods in the proper order for compilation . |
19,533 | protected function _compile_allow ( $ expression ) { $ parts = explode ( ',' , substr ( $ expression , 1 , - 1 ) ) ; $ expr = $ this -> compileString ( $ parts [ 1 ] ) ; return "<?php if (\$di->authorization->isAllowed($parts[0])): ?>$expr<?php endif ?>" ; } | Compile the allow statements into valid PHP . |
19,534 | protected function _compile_asset ( $ expression ) { if ( strcspn ( $ expression , '$\'"' ) === strlen ( $ expression ) ) { $ expression = '(\'' . trim ( $ expression , '()' ) . '\')' ; } return asset ( substr ( $ expression , 2 , - 2 ) ) ; } | Compile the Asset statements into valid PHP . |
19,535 | public function importFileAction ( ) { $ this -> getResponse ( ) -> setTypePlain ( ) ; $ endpoint = base64_decode ( $ this -> url ) . '/?module=cms&controller=connector&name=' . $ this -> name . '&action=' ; try { $ data = json_decode ( file_get_contents ( $ endpoint . 'exportFileMeta' ) , true ) ; } catch ( \ Exception $ e ) { return 'ERR' ; } if ( null === $ file = ( new Model \ ConnectorModel ) -> importFileMeta ( $ data ) ) { return 'META ERROR' ; } try { mkdir ( dirname ( $ file -> getRealPath ( ) ) , 0777 , true ) ; } catch ( \ Exception $ e ) { } try { file_put_contents ( $ file -> getRealPath ( ) , file_get_contents ( $ endpoint . 'exportFileBinary' ) ) ; } catch ( \ Exception $ e ) { die ( $ e -> getMessage ( ) ) ; return 'BIN ERROR' ; } return 'OK' ; } | Importuje plik na podstawie nazwy |
19,536 | public function exportFileBinaryAction ( ) { $ this -> getResponse ( ) -> setType ( 'application/octet-stream' ) -> send ( ) ; if ( null === $ file = ( new Orm \ CmsFileQuery ) -> whereName ( ) -> equals ( $ this -> name ) -> findFirst ( ) ) { throw new \ Mmi \ Mvc \ MvcNotFoundException ( 'File not found' ) ; } if ( $ file -> size > self :: MAX_FILE_SIZE ) { throw new \ Mmi \ Mvc \ MvcForbiddenException ( 'File to large' ) ; } readfile ( $ file -> getRealPath ( ) ) ; exit ; } | Eksportuje binarium pliku |
19,537 | public function exportFileMetaAction ( ) { if ( null === $ files = ( new Orm \ CmsFileQuery ) -> whereName ( ) -> equals ( $ this -> name ) -> find ( ) ) { throw new \ Mmi \ Mvc \ MvcNotFoundException ( 'File not found' ) ; } $ data = [ ] ; foreach ( $ files as $ file ) { $ file -> data = ( $ file -> data && ( $ file -> data instanceof \ Mmi \ DataObject ) ) ? json_encode ( $ file -> data -> toArray ( ) ) : null ; $ data [ ] = $ file -> toArray ( ) ; } return json_encode ( $ data ) ; } | Eksportuje meta pliku |
19,538 | public static function add ( $ operation = null , array $ data = [ ] ) { \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> info ( 'Legacy log: ' . $ operation ) ; \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> warning ( '\Cms\Log\Model deprecated, use MMi PSR logger instead' ) ; } | Dodaje zdarzenie do logu |
19,539 | public function create ( $ projectId , $ taskId , array $ params = array ( ) ) { $ defaults = array ( 'text' => null , 'user_id' => null , 'user_email' => null ) ; $ params = array_filter ( array_merge ( $ defaults , $ params ) ) ; $ data = array ( 'comment' => $ params ) ; $ path = '/projects/' . urlencode ( $ projectId ) . '/tasks/' . urlencode ( $ taskId ) . '/comments.json' ; return $ this -> post ( $ path , $ data ) ; } | Create a new comment on a task |
19,540 | public function getFilterValue ( $ param = null ) { foreach ( $ this -> _grid -> getState ( ) -> getFilters ( ) as $ filter ) { if ( $ filter -> getTableName ( ) . '.' . $ filter -> getField ( ) == $ this -> getName ( ) ) { return $ filter -> getValue ( ) ; } if ( ! $ filter -> getTableName ( ) && $ filter -> getField ( ) == $ this -> getName ( ) ) { $ valueObj = json_decode ( $ filter -> getValue ( ) ) ; if ( null !== $ param && is_object ( $ valueObj ) && property_exists ( $ valueObj , $ param ) ) { return $ valueObj -> { $ param } ; } return $ filter -> getValue ( ) ; } } } | Zwraca filtr dla pola |
19,541 | public function isFieldInRecord ( ) { if ( strpos ( $ this -> getName ( ) , '.' ) ) { return true ; } return property_exists ( $ this -> _grid -> getQuery ( ) -> getRecordName ( ) , $ this -> getName ( ) ) ; } | Sprawdza istnienie pola w rekordzie |
19,542 | public function getOrderMethod ( ) { foreach ( $ this -> _grid -> getState ( ) -> getOrder ( ) as $ order ) { if ( $ order -> getTableName ( ) ) { if ( $ order -> getTableName ( ) . '.' . $ order -> getField ( ) == $ this -> getName ( ) ) { return $ order -> getMethod ( ) ; } } else { if ( $ order -> getField ( ) == $ this -> getName ( ) ) { return $ order -> getMethod ( ) ; } } } } | Zwraca sortowanie dla pola |
19,543 | public function augment ( SubscriptionNotification $ notification ) { $ this -> in = $ notification -> in ; $ this -> out = $ notification -> out ; } | Augments this instance with data from the notification |
19,544 | private function _generateJs ( $ treeId ) { $ id = $ this -> getOption ( 'id' ) ; $ treeClearId = $ treeId . '_clear' ; $ view = \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) ; $ view -> headScript ( ) -> appendScript ( "$(document).ready(function () { $('#$treeId').jstree({ 'core': { 'themes': { 'name': 'default', 'variant': 'small', 'responsive' : true, 'stripes' : true }, 'multiple': " . ( $ this -> getOption ( 'multiple' ) ? 'true' : 'false' ) . ", 'expand_selected_onload': true, 'check_callback' : false } }) .on('changed.jstree', function (e, data) { var selectedStr = ''; if (0 in data.selected) { selectedStr = data.selected[0]; } for (idx = 1, len = data.selected.length; idx < len; ++idx) { selectedStr = selectedStr.concat(';' + data.selected[idx]) } $('#$id').val(selectedStr); }); $('#$treeClearId').click(function () { $('#$id').val(''); $('#$treeId').jstree('deselect_all'); }); }); " ) ; } | Generuje JS do odpalenia drzewka |
19,545 | public function postDispatch ( \ Mmi \ Http \ Request $ request ) { $ view = \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) ; $ base = $ view -> baseUrl ; $ view -> domain = \ App \ Registry :: $ config -> host ; $ view -> languages = \ App \ Registry :: $ config -> languages ; $ jsRequest = $ request -> toArray ( ) ; $ jsRequest [ 'baseUrl' ] = $ base ; $ jsRequest [ 'locale' ] = \ App \ Registry :: $ translate -> getLocale ( ) ; unset ( $ jsRequest [ 'controller' ] ) ; unset ( $ jsRequest [ 'action' ] ) ; $ view -> headScript ( ) -> prependScript ( 'var request = ' . json_encode ( $ jsRequest ) ) ; } | Wykonywana po dispatcherze |
19,546 | protected function _setLoginRequest ( \ Mmi \ Http \ Request $ request , $ preferAdmin ) { if ( false === $ preferAdmin && \ App \ Registry :: $ acl -> isRoleAllowed ( 'guest' , 'cms:user:login' ) ) { return $ request -> setModuleName ( 'cms' ) -> setControllerName ( 'user' ) -> setActionName ( 'login' ) ; } return $ request -> setModuleName ( 'cmsAdmin' ) -> setControllerName ( 'index' ) -> setActionName ( 'login' ) ; } | Ustawia request na logowanie admina |
19,547 | public function createTagRelation ( $ tag ) { $ filteredTag = ( new \ Mmi \ Filter \ Input ) -> filter ( $ tag ) ; if ( null === $ tagRecord = ( new CmsTagQuery ) -> whereTag ( ) -> equals ( $ filteredTag ) -> findFirst ( ) ) { $ tagRecord = new CmsTagRecord ; $ tagRecord -> tag = $ filteredTag ; $ tagRecord -> save ( ) ; } if ( null !== ( new CmsTagRelationQuery ) -> whereCmsTagId ( ) -> equals ( $ tagRecord -> id ) -> andFieldObject ( ) -> equals ( $ this -> _object ) -> andFieldObjectId ( ) -> equals ( $ this -> _objectId ) -> findFirst ( ) ) { return ; } $ newRelationRecord = new CmsTagRelationRecord ; $ newRelationRecord -> cmsTagId = $ tagRecord -> id ; $ newRelationRecord -> object = $ this -> _object ; $ newRelationRecord -> objectId = $ this -> _objectId ; $ newRelationRecord -> save ( ) ; } | Taguje tagiem po nazwie |
19,548 | public function installRoles ( ) { $ this -> _roleService = new erdiko \ users \ models \ Role ( ) ; $ results = array ( "successes" => array ( ) , "failures" => array ( ) , ) ; foreach ( $ this -> _rolesArray as $ role ) { $ createResult = false ; try { $ createResult = ( boolean ) $ this -> _roleService -> create ( $ role ) ; } catch ( \ Exception $ e ) { } if ( true !== $ createResult ) { $ results [ "failures" ] [ ] = $ role ; } else { $ results [ "successes" ] [ ] = $ role ; } } return $ results ; } | loop through the roles array and create records |
19,549 | public function installUsers ( ) { $ this -> _userService = new erdiko \ users \ models \ User ( ) ; $ results = array ( "successes" => array ( ) , "failures" => array ( ) , ) ; foreach ( $ this -> _usersArray as $ user ) { $ user [ "role" ] = $ this -> _getRole ( $ user [ "role" ] ) -> getId ( ) ; $ createResult = ( boolean ) $ this -> _userService -> createUser ( $ user ) ; unset ( $ user [ "password" ] ) ; if ( true !== $ createResult ) { $ results [ "failures" ] [ ] = $ user ; } else { $ results [ "successes" ] [ ] = $ user ; } } return $ results ; } | loop through the users array and create records |
19,550 | public function isAllowed ( $ permission = null , $ role = null ) { if ( $ permission && strpos ( $ permission , '/' ) !== false ) { list ( $ controllerClassName , $ action ) = $ this -> inferControllerAction ( $ permission ) ; $ controllerClassName = $ this -> alias -> resolveNS ( $ controllerClassName ) ; if ( ! isset ( $ this -> _acl [ $ controllerClassName ] ) ) { $ controllerInstance = new $ controllerClassName ; $ this -> _acl [ $ controllerClassName ] = $ controllerInstance -> getAcl ( ) ; } } else { $ controllerInstance = $ this -> dispatcher -> getControllerInstance ( ) ; $ controllerClassName = get_class ( $ controllerInstance ) ; $ action = $ permission ? lcfirst ( Text :: camelize ( $ permission ) ) : $ this -> dispatcher -> getAction ( ) ; if ( ! isset ( $ this -> _acl [ $ controllerClassName ] ) ) { $ this -> _acl [ $ controllerClassName ] = $ controllerInstance -> getAcl ( ) ; } } $ acl = $ this -> _acl [ $ controllerClassName ] ; $ role = $ role ? : $ this -> identity -> getRole ( ) ; if ( strpos ( $ role , ',' ) === false ) { return $ this -> isAclAllow ( $ acl , $ role , $ action ) ; } else { foreach ( explode ( $ role , ',' ) as $ r ) { if ( $ this -> isAclAllow ( $ acl , $ r , $ action ) ) { return true ; } } return false ; } } | Check whether a user is allowed to access a permission |
19,551 | public function withRedirectUrls ( $ redirects ) { if ( isset ( $ redirects [ 'success' ] ) ) { $ this -> returnUrlSuccess = $ redirects [ 'success' ] ; } if ( isset ( $ redirects [ 'cancel' ] ) ) { $ this -> returnUrlCancel = $ redirects [ 'cancel' ] ; } if ( isset ( $ redirects [ 'back' ] ) ) { $ this -> returnUrlBack = $ redirects [ 'back' ] ; } return $ this ; } | Sets the redirect urls on the request |
19,552 | public function resizeCropCenter ( $ width , $ height ) { $ _width = $ this -> do_getWidth ( ) ; $ _height = $ this -> do_getHeight ( ) ; if ( $ _width / $ _height > $ width / $ height ) { $ crop_height = $ _height ; $ crop_width = $ width * $ crop_height / $ height ; $ offsetX = ( $ _width - $ crop_width ) / 2 ; $ offsetY = 0 ; } else { $ crop_width = $ _width ; $ crop_height = $ height * $ crop_width / $ width ; $ offsetY = ( $ _height - $ crop_height ) / 2 ; $ offsetX = 0 ; } $ this -> crop ( $ crop_width , $ crop_height , $ offsetX , $ offsetY ) ; $ this -> scale ( $ width / $ crop_width ) ; return $ this ; } | Resize the image by a given width and height |
19,553 | public function scale ( $ ratio ) { $ _width = ( int ) $ this -> do_getWidth ( ) ; $ _height = ( int ) $ this -> do_getHeight ( ) ; if ( $ ratio === 1 ) { return $ this ; } $ width = ( int ) ( $ _width * $ ratio ) ; $ height = ( int ) ( $ _height * $ ratio ) ; $ this -> do_resize ( $ width , $ height ) ; return $ this ; } | Scale the image by a given ratio |
19,554 | public function scaleFixedHeight ( $ height ) { $ _width = $ this -> do_getWidth ( ) ; $ _height = $ this -> do_getHeight ( ) ; $ width = ( int ) ( $ _width * $ height / $ _height ) ; $ this -> do_resize ( $ width , $ height ) ; return $ this ; } | Scale the image by a given height |
19,555 | public static function validatePascalCase ( $ string ) { if ( SetupHelper :: getPascalCase ( $ string ) === $ string ) { return ( string ) $ string ; } throw new InvalidArgumentException ( sprintf ( 'Provided string "%1$s" was not in PascalCase.' , $ string ) ) ; } | Verify that a string is in PascalCase or throw an Exception . |
19,556 | public static function validateLowerCase ( $ string ) { if ( SetupHelper :: getLowerCase ( $ string ) === $ string ) { return ( string ) $ string ; } throw new InvalidArgumentException ( sprintf ( 'Provided string "%1$s" was not in lowercase.' , $ string ) ) ; } | Verify that a string is in lowercase or throw an Exception . |
19,557 | public static function validateTrimmed ( $ string ) { if ( SetupHelper :: trim ( $ string ) === $ string ) { return ( string ) $ string ; } throw new InvalidArgumentException ( sprintf ( 'Provided string "%1$s" was not trimmed.' , $ string ) ) ; } | Verify that a string is trimmed or throw an Exception . |
19,558 | public static function validateEmail ( $ string ) { if ( filter_var ( $ string , FILTER_VALIDATE_EMAIL ) ) { return ( string ) $ string ; } throw new InvalidArgumentException ( sprintf ( 'Provided string "%1$s" was not a valid email.' , $ string ) ) ; } | Verify that a string is an email or throw an Exception . |
19,559 | public static function validateURL ( $ string ) { if ( filter_var ( $ string , FILTER_VALIDATE_URL ) ) { return ( string ) $ string ; } throw new InvalidArgumentException ( sprintf ( 'Provided string "%1$s" was not a valid URL.' , $ string ) ) ; } | Verify that a string is a URL or throw an Exception . |
19,560 | public function getUserRole ( ) { return isset ( $ _SESSION [ $ this -> config -> roleSessionVar ] ) ? $ _SESSION [ $ this -> config -> roleSessionVar ] : $ this -> config -> defaultRole ; } | Get user role |
19,561 | public function read ( Config $ source ) { $ path = $ source -> getPath ( ) ; $ sourceData = ( object ) [ 'baseurl' => $ source -> baseurl , 'path' => str_replace ( realpath ( $ source -> getRoot ( ) ) . Consts :: DS , '' , $ path ) , 'files' => [ ] , ] ; try { $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ path ) ; } catch ( \ Exception $ e ) { return $ sourceData ; } $ dir = opendir ( $ path ) ; $ config = $ this -> config ; while ( $ file = readdir ( $ dir ) ) { if ( $ file != '.' && $ file != '..' && is_file ( $ path . $ file ) ) { $ file = new File ( $ path . $ file ) ; if ( $ file -> isGoodFile ( $ source ) ) { $ item = [ 'file' => $ file -> getPathByRoot ( $ source ) , ] ; if ( $ config -> createThumb || ! $ file -> isImage ( ) ) { $ item [ 'thumb' ] = Image :: getThumb ( $ file , $ source ) -> getPathByRoot ( $ source ) ; } $ item [ 'changed' ] = date ( $ config -> datetimeFormat , $ file -> getTime ( ) ) ; $ item [ 'size' ] = Helper :: humanFileSize ( $ file -> getSize ( ) ) ; $ item [ 'isImage' ] = $ file -> isImage ( ) ; $ sourceData -> files [ ] = $ item ; } } } return $ sourceData ; } | Read folder and retrun filelist |
19,562 | public function getSource ( ) { $ source = $ this -> config -> getSource ( $ this -> request -> source ) ; if ( ! $ source ) { throw new \ Exception ( 'Source not found' , Consts :: ERROR_CODE_NOT_EXISTS ) ; } return $ source ; } | Return current source |
19,563 | protected function createBaseRequest ( $ relativeUrl ) { $ baseUrl = $ this -> getBaseUrl ( false ) ; $ request = new \ Zend \ Http \ Request ( ) ; $ request -> setUri ( $ baseUrl . $ relativeUrl ) ; $ request -> setMethod ( \ Zend \ Http \ Request :: METHOD_POST ) ; $ request -> getHeaders ( ) -> addHeaders ( array ( 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' , 'Accept-Encoding' => 'identity' ) ) ; $ this -> addDefaultParameters ( $ request ) ; return $ request ; } | Creates a basic HTTP request |
19,564 | protected function addDefaultParameters ( & $ request ) { $ defaultParameters = array ( 'all' => 1 , 'dir' => 'ASC' , 'start' => 0 , 'limit' => 999999999 ) ; foreach ( $ defaultParameters as $ name => $ value ) $ request -> getPost ( ) -> set ( $ name , $ value ) ; } | Adds default parameters to the request such as sorting |
19,565 | public function ask ( MetaDataSource $ metadataSource , $ choice = null ) { $ metaDataCollection = $ this -> getMetadataDao ( $ metadataSource ) -> getAllMetadata ( ) ; $ responseCollection = new PredefinedResponseCollection ( ) ; foreach ( $ metaDataCollection as $ metaData ) { $ response = new PredefinedResponse ( $ metaData -> getOriginalName ( ) , $ metaData -> getOriginalName ( ) , $ metaData ) ; $ response -> setAdditionalData ( array ( 'source' => $ metadataSource -> getUniqueName ( ) ) ) ; $ responseCollection -> append ( $ response ) ; } $ question = new QuestionWithPredefinedResponse ( "Select Metadata" , self :: QUESTION_KEY , $ responseCollection ) ; $ question -> setPreselectedResponse ( $ choice ) ; $ question -> setShutdownWithoutResponse ( true ) ; return $ this -> context -> askCollection ( $ question ) ; } | Ask wich metadata you want to use |
19,566 | public function getNodeData ( $ uuid ) { $ request = new client \ Request ( '/api/idnode/load' , array ( 'uuid' => $ uuid , 'meta' => 0 ) ) ; $ response = $ this -> _client -> getResponse ( $ request ) ; $ content = json_decode ( $ response -> getContent ( ) ) ; if ( count ( $ content -> entries ) > 0 ) return $ content -> entries [ 0 ] ; else return null ; } | Returns data about a node such as the class name |
19,567 | public function createNetwork ( $ network ) { $ request = new client \ Request ( '/api/mpegts/network/create' , array ( 'class' => $ network -> getClassName ( ) , 'conf' => json_encode ( $ network ) ) ) ; $ this -> _client -> getResponse ( $ request ) ; } | Creates the specified network |
19,568 | public function getNetwork ( $ name ) { $ networks = $ this -> getNetworks ( ) ; foreach ( $ networks as $ network ) if ( $ network -> networkname === $ name ) return $ network ; return null ; } | Returns the network with the specified name or null if not found |
19,569 | public function createMultiplex ( $ network , $ multiplex ) { $ request = new client \ Request ( '/api/mpegts/network/mux_create' , array ( 'uuid' => $ network -> uuid , 'conf' => json_encode ( $ multiplex ) ) ) ; $ this -> _client -> getResponse ( $ request ) ; } | Creates the specified multiplex on the specified network |
19,570 | public function getChannels ( $ filter = null ) { $ channels = array ( ) ; $ request = new client \ Request ( '/api/channel/grid' ) ; if ( $ filter ) $ request -> setFilter ( $ filter ) ; $ response = $ this -> _client -> getResponse ( $ request ) ; $ rawContent = $ response -> getContent ( ) ; $ content = json_decode ( $ rawContent ) ; foreach ( $ content -> entries as $ entry ) $ channels [ ] = model \ Channel :: fromRawEntry ( $ entry ) ; return $ channels ; } | Returns the list of channels |
19,571 | public function getServices ( $ filter = null ) { $ services = array ( ) ; $ request = new client \ Request ( '/api/mpegts/service/grid' ) ; if ( $ filter ) $ request -> setFilter ( $ filter ) ; $ response = $ this -> _client -> getResponse ( $ request ) ; $ rawContent = $ response -> getContent ( ) ; $ content = json_decode ( $ rawContent ) ; foreach ( $ content -> entries as $ entry ) $ services [ ] = model \ Service :: fromRawEntry ( $ entry ) ; return $ services ; } | Returns the list of services |
19,572 | private function generateCometPollBoxId ( ) { $ request = new client \ Request ( '/comet/poll' ) ; $ response = $ this -> _client -> getResponse ( $ request ) ; $ content = json_decode ( $ response -> getContent ( ) ) ; $ boxId = $ content -> boxid ; return new BoxId ( $ boxId ) ; } | Requests and returns a new boxid from the comet poll API |
19,573 | private function ensureValidBoxId ( $ class ) { if ( ! array_key_exists ( $ class , $ this -> _boxIds ) || $ this -> _boxIds [ $ class ] -> getAge ( ) > self :: MAXIMUM_BOXID_AGE ) $ this -> _boxIds [ $ class ] = $ this -> generateCometPollBoxId ( ) ; } | Ensures that the specifeid class has a valid box ID defined |
19,574 | static public function create ( ) { $ t = new static ( ) ; $ t -> registerService ( new Service \ Youtube ( ) ) ; $ t -> registerService ( new Service \ Dailymotion ( ) ) ; $ t -> registerService ( new Service \ Vimeo ( ) ) ; $ t -> registerService ( new Service \ Spotify ( ) ) ; $ t -> registerService ( new Service \ SoundCloud ( ) ) ; return $ t ; } | Create a TubeLink instance with all services registered . |
19,575 | public function switchCommand ( $ target = '' ) { if ( $ target === '' && $ values = $ this -> arguments -> getValues ( ) ) { $ target = $ values [ 0 ] ; } if ( $ target === '' ) { $ target = $ this -> arguments -> getOption ( 'env' ) ; } $ candidates = [ ] ; foreach ( $ this -> _getEnvTypes ( ) as $ file ) { if ( strpos ( $ file , $ target ) === 0 ) { $ candidates [ ] = $ file ; } } if ( count ( $ candidates ) !== 1 ) { return $ this -> console -> error ( [ 'can not one file: :env' , 'env' => implode ( ',' , $ candidates ) ] ) ; } $ target = $ candidates [ 0 ] ; $ glob = '@root/.env[._-]' . $ target ; $ files = $ this -> filesystem -> glob ( $ glob ) ; if ( $ files ) { $ file = $ files [ 0 ] ; $ this -> filesystem -> fileCopy ( $ file , '@root/.env' , true ) ; if ( file_exists ( $ file . '.php' ) ) { $ this -> filesystem -> fileDelete ( $ file . '.php' ) ; } $ this -> console -> writeLn ( [ 'copy `:src` to `:dst` success.' , 'src' => basename ( $ file ) , 'dst' => '.env' ] ) ; return 0 ; } else { return $ this -> console -> error ( [ 'dotenv file `:file` is not exists' , 'file' => $ glob ] ) ; } } | switch . env |
19,576 | public function cacheCommand ( ) { $ file = $ this -> alias -> resolve ( '@root/.env' ) ; if ( ! file_exists ( $ file ) ) { return $ this -> console -> writeLn ( [ '`:file` dotenv file is not exists' , 'file' => $ file ] ) ; } $ data = ( new Dotenv ( ) ) -> parse ( file ( $ file , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ) ; $ content = '<?php' . PHP_EOL . 'return ' . var_export ( $ data , true ) . ';' . PHP_EOL ; $ this -> filesystem -> filePut ( '@root/.env.php' , $ content ) ; return 0 ; } | parse . env file and save to . env . php |
19,577 | public function inspectCommand ( ) { $ file = $ this -> alias -> resolve ( '@root/.env' ) ; if ( ! file_exists ( $ file ) ) { return $ this -> console -> writeLn ( [ '`:file` dotenv file is not exists' , 'file' => $ file ] ) ; } $ data = ( new Dotenv ( ) ) -> parse ( file ( $ file , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ) ; $ this -> console -> write ( json_encode ( $ data , JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ) ; return 0 ; } | show parsed . env file as json string |
19,578 | public function beforeSave ( ) { foreach ( $ this -> _cmsAttributeElements as $ attributeId => $ element ) { $ attribute = $ this -> _findAttributeById ( $ attributeId ) ; if ( null !== $ attribute && $ attribute -> getJoined ( 'cms_attribute_relation' ) -> isMaterialized ( ) ) { $ this -> getRecord ( ) -> { $ attribute -> key } = $ element -> getValue ( ) ; } } } | Ustawia w rekordzie zmaterializowane atrybuty |
19,579 | private function _parseClassWithOptions ( $ classWithOptions ) { $ config = explode ( ':' , $ classWithOptions ) ; $ class = array_shift ( $ config ) ; return ( new \ Mmi \ OptionObject ) -> setClass ( $ class ) -> setConfig ( $ config ) ; } | Parsowanie nazwy klasy wraz z opcjami |
19,580 | public function completeCommand ( ) { $ arguments = array_slice ( $ GLOBALS [ 'argv' ] , 3 ) ; $ position = ( int ) $ arguments [ 0 ] ; $ arguments = array_slice ( $ arguments , 1 ) ; $ count = count ( $ arguments ) ; $ controller = null ; if ( $ count > 1 ) { $ controller = $ arguments [ 1 ] ; } $ command = null ; if ( $ count > 2 ) { $ command = $ arguments [ 2 ] ; if ( $ command !== '' && $ command [ 0 ] === '-' ) { $ command = 'default' ; } } $ previous = $ position > 0 ? $ arguments [ $ position - 1 ] : null ; $ current = isset ( $ arguments [ $ position ] ) ? $ arguments [ $ position ] : '' ; if ( $ position === 1 ) { $ words = $ this -> _getControllers ( ) ; } elseif ( $ current !== '' && $ current [ 0 ] === '-' ) { $ words = $ this -> _getArgumentNames ( $ controller , $ command ) ; } elseif ( $ position === 2 ) { $ words = $ this -> _getCommands ( $ controller ) ; } else { $ words = $ this -> _getArgumentValues ( $ controller , $ command , $ previous ) ; } $ this -> console -> writeLn ( implode ( ' ' , $ this -> _filterWords ( $ words , $ current ) ) ) ; return 0 ; } | complete for bash |
19,581 | public function installCommand ( ) { $ content = <<<'EOT'#!/bin/bash_manacli(){ COMPREPLY=( $(./manacli.php bash_completion complete $COMP_CWORD "${COMP_WORDS[@]}") ) return 0;}complete -F _manacli manacliEOT ; $ file = '/etc/bash_completion.d/manacli' ; if ( DIRECTORY_SEPARATOR === '\\' ) { return $ this -> console -> error ( 'Windows system is not support bash completion!' ) ; } try { $ this -> filesystem -> filePut ( $ file , PHP_EOL === '\n' ? $ content : str_replace ( "\r" , '' , $ content ) ) ; $ this -> filesystem -> chmod ( $ file , 0755 ) ; } catch ( \ Exception $ e ) { return $ this -> console -> error ( 'write bash completion script failed: ' . $ e -> getMessage ( ) ) ; } $ this -> console -> writeLn ( 'install bash completion script successfully' ) ; $ this -> console -> writeLn ( "please execute `source $file` command to become effective" ) ; return 0 ; } | install bash completion script |
19,582 | public function setTables ( ) { foreach ( $ this -> data [ 'tables' ] as $ alias => $ model ) { $ this -> builder -> addFrom ( $ model , $ alias ) ; } return null ; } | Setup tables to Builder |
19,583 | public function setOrder ( ) { $ order = [ ] ; foreach ( $ this -> data [ 'order' ] as $ alias => $ params ) { $ order = array_flip ( $ order ) ; if ( empty ( $ params ) === false ) { foreach ( $ params as $ field => $ sort ) { $ order [ ] = $ alias . '.' . $ field . ' ' . $ sort ; } } } $ this -> builder -> orderBy ( $ order ) ; return null ; } | Setup orders positions to Builder |
19,584 | public function setGroup ( ) { $ group = [ ] ; foreach ( $ this -> data [ 'group' ] as $ table => $ params ) { $ params = array_flip ( $ params ) ; if ( empty ( $ params ) === false ) { foreach ( $ params as $ field ) { $ group [ ] = $ table . '.' . $ field ; } } } $ this -> builder -> groupBy ( $ group ) ; return null ; } | Setup group positions to builder |
19,585 | public function setWhere ( ) { $ index = 0 ; foreach ( $ this -> data [ 'where' ] as $ alias => $ fields ) { foreach ( $ fields as $ field => $ type ) { $ this -> expressionRun ( $ alias , $ field , $ type , $ index ) ; ++ $ index ; } } return null ; } | Setup where filter |
19,586 | private function expressionRun ( $ table , $ field , $ type , $ index ) { if ( $ type === Column :: TYPE_TEXT ) { $ query = "MATCH(" . $ table . "." . $ field . ") AGAINST (:query:)" ; } else { $ query = $ table . "." . $ field . " LIKE :query:" ; } if ( $ index > 0 ) { $ this -> builder -> orWhere ( $ query , $ this -> ftFilter ( $ type ) ) ; } else { $ this -> builder -> where ( $ query , $ this -> ftFilter ( $ type ) ) ; } return null ; } | Where condition customizer |
19,587 | public function loop ( $ hydratorset = null , $ callback = null ) { try { $ this -> data = $ this -> searcher -> getFields ( ) ; foreach ( $ this -> data as $ key => $ values ) { if ( empty ( $ values ) === false ) { $ this -> { 'set' . ucfirst ( $ key ) } ( ) ; } } return $ this -> setResult ( $ hydratorset , $ callback ) ; } catch ( ExceptionFactory $ e ) { echo $ e -> getMessage ( ) ; } } | Build query chain |
19,588 | protected function ftFilter ( $ type ) { if ( $ type === Column :: TYPE_TEXT ) { return array_map ( function ( $ v ) { return trim ( $ v , '%' ) ; } , $ this -> searcher -> query ) ; } return $ this -> searcher -> query ; } | Prepare query data to fulltext search |
19,589 | protected function setResult ( $ hydratorset = null , $ callback = null ) { $ res = $ this -> builder -> getQuery ( ) -> execute ( ) ; $ call = "Searcher\\Searcher\\Hydrators\\" . ucfirst ( $ hydratorset ) . "Hydrator" ; if ( $ res -> valid ( ) === true ) { if ( class_exists ( $ call ) === true ) { $ res = ( new $ call ( $ res ) ) -> extract ( $ callback ) ; } return $ res ; } return null ; } | Setup output result |
19,590 | public function addImprintElement ( $ type , $ name , $ label = null , $ options = [ ] ) { $ imprint = $ this -> getOption ( 'imprint' ) ; if ( null === $ imprint ) { $ imprint = [ ] ; } $ imprint [ ] = [ 'type' => $ type , 'name' => $ name , 'label' => ( $ label ? : $ name ) , 'options' => $ options ] ; return $ this -> setOption ( 'imprint' , $ imprint ) ; } | Dodaje pole do metryczki |
19,591 | protected function _beforeRender ( ) { $ this -> _id = $ this -> getOption ( 'id' ) ; if ( $ this -> _form -> hasRecord ( ) ) { $ this -> _object = $ this -> _form -> getFileObjectName ( ) ; $ this -> _objectId = $ this -> _form -> getRecord ( ) -> getPk ( ) ; } if ( $ this -> getOption ( 'object' ) ) { $ this -> _object = $ this -> getOption ( 'object' ) ; } $ this -> _tempObject = 'tmp-' . $ this -> _object ; $ this -> _createTempFiles ( ) ; return $ this ; } | Przygotowanie danych przed renderingiem pola formularza |
19,592 | protected function _readMetaData ( $ model ) { $ modelName = is_string ( $ model ) ? $ model : get_class ( $ model ) ; if ( ! isset ( $ this -> _metadata [ $ modelName ] ) ) { $ data = $ this -> read ( $ modelName ) ; if ( $ data !== false ) { $ this -> _metadata [ $ modelName ] = $ data ; } else { $ modelInstance = is_string ( $ model ) ? new $ model : $ model ; $ data = $ this -> _di -> getShared ( $ modelInstance -> getDb ( true ) ) -> getMetadata ( $ modelInstance -> getSource ( true ) ) ; $ this -> _metadata [ $ modelName ] = $ data ; $ this -> write ( $ modelName , $ data ) ; } } return $ this -> _metadata [ $ modelName ] ; } | Reads the complete meta - data for certain model |
19,593 | static function parse_string ( $ src , $ unicode = true , $ parser = __CLASS__ , $ lexer = 'JTokenizer' ) { $ Tokenizer = new $ lexer ( false , $ unicode ) ; $ tokens = $ Tokenizer -> get_all_tokens ( $ src ) ; unset ( $ src ) ; $ Parser = new $ parser ; return $ Parser -> parse ( $ tokens ) ; } | Parse a JavaScript string according to specific parser class |
19,594 | public function set ( $ property , $ value ) { $ defaultCurrentValue = [ ] ; $ data = $ this -> session -> get ( $ this -> _name , $ defaultCurrentValue ) ; $ data [ $ property ] = $ value ; $ this -> session -> set ( $ this -> _name , $ data ) ; } | Sets a value in the session bag |
19,595 | public function get ( $ property = null , $ default = null ) { $ defaultCurrentValue = [ ] ; $ data = $ this -> session -> get ( $ this -> _name , $ defaultCurrentValue ) ; if ( $ property === null ) { return $ data ; } else { return isset ( $ data [ $ property ] ) ? $ data [ $ property ] : $ default ; } } | Obtains a value from the session bag optionally setting a default value |
19,596 | public function has ( $ property ) { $ defaultCurrentValue = [ ] ; $ data = $ this -> session -> get ( $ this -> _name , $ defaultCurrentValue ) ; return isset ( $ data [ $ property ] ) ; } | Check whether a property is defined in the internal bag |
19,597 | protected function getTargetPath ( $ pathname ) { $ filesystem = new Filesystem ( ) ; $ templatesFolder = $ this -> getConfigKey ( 'Folders' , 'templates' ) ; $ folderDiff = '/' . $ filesystem -> findShortestPath ( SetupHelper :: getRootFolder ( ) , $ templatesFolder ) ; return ( string ) $ this -> removeTemplateExtension ( str_replace ( $ folderDiff , '' , $ pathname ) ) ; } | Get the target path for a rendered file from a template file . |
19,598 | public function wakeByInterfaces ( array $ directories , $ interfaceNames ) { $ classCollection = $ this -> awake ( $ directories ) ; $ classes = array ( ) ; foreach ( $ classCollection as $ className ) { $ reflectionClass = new ReflectionClass ( $ className ) ; $ interfaces = $ reflectionClass -> getInterfaces ( ) ; if ( is_array ( $ interfaces ) === true && isset ( $ interfaces [ $ interfaceNames ] ) === true ) { $ class = str_replace ( '\\' , '' , strrchr ( $ className , '\\' ) ) ; $ classes [ $ class ] = $ className ; } } return $ classes ; } | Awake classes by interface |
19,599 | private function awake ( array $ directories ) { $ includedFiles = array ( ) ; self :: $ included = array_merge ( self :: $ included , get_included_files ( ) ) ; foreach ( $ directories as $ directorie ) { $ iterator = new \ RegexIterator ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directorie , \ FilesystemIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: LEAVES_ONLY ) , '/^.+' . preg_quote ( '.php' ) . '$/i' , \ RecursiveRegexIterator :: GET_MATCH ) ; foreach ( $ iterator as $ file ) { $ sourceFile = realpath ( $ file [ 0 ] ) ; if ( in_array ( $ sourceFile , self :: $ included ) === false ) { require_once $ sourceFile ; } self :: $ included [ ] = $ sourceFile ; $ includedFiles [ ] = $ sourceFile ; } } $ classes = array ( ) ; $ declared = get_declared_classes ( ) ; foreach ( $ declared as $ className ) { $ rc = new \ ReflectionClass ( $ className ) ; $ sourceFile = $ rc -> getFileName ( ) ; if ( in_array ( $ sourceFile , $ includedFiles ) === true ) { $ classes [ ] = $ className ; } } return $ classes ; } | Find classes on directory |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.