idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
24,700 | public function passive ( bool $ passive ) { if ( ! @ ftp_pasv ( $ this -> ftp , $ passive ) ) { throw new Exception ( sprintf ( "Cannot switch to passive = %s" , $ passive ? "true" : "false" ) ) ; } return $ this ; } | Switch to active or passive mode . |
24,701 | public function fput ( string $ remoteFile , $ handle , int $ resumePos = 0 ) { if ( ! @ ftp_fput ( $ this -> ftp , $ remoteFile , $ handle , FTP_BINARY , $ resumePos ) ) { throw new Exception ( sprintf ( "Cannot copy data from file handle to %s" , $ remoteFile ) ) ; } return $ this ; } | Read directly from file and put data on ftp - server . |
24,702 | public function delete ( string $ remoteFile ) { if ( ! @ ftp_delete ( $ this -> ftp , $ remoteFile ) ) { throw new Exception ( sprintf ( "Cannot delete file %s" , $ remoteFile ) ) ; } return $ this ; } | Delete a file from ftp - server . |
24,703 | public function getSize ( string $ remoteFile ) { $ size = @ ftp_size ( $ this -> ftp , $ remoteFile ) ; if ( $ size == - 1 ) { throw new Exception ( "Cannot get file size" ) ; } return $ size ; } | Get size of file on ftp - server . |
24,704 | public function getModifiedTimestamp ( string $ remoteFile , int $ attempts = 1 , int $ sleepBetweenAttempts = 5 ) { $ timestamp = @ ftp_mdtm ( $ this -> ftp , $ remoteFile ) ; if ( $ timestamp < 0 ) { if ( -- $ attempts > 0 ) { sleep ( $ sleepBetweenAttempts ) ; return $ this -> getModifiedTimestamp ( $ remoteFile , $ attempts , $ sleepBetweenAttempts ) ; } throw new Exception ( "Cannot get file modification timestamp" ) ; } return $ timestamp ; } | Get timestamp of last modification of file on ftp - server . |
24,705 | public static function all ( string $ routeStr , array $ info ) { $ methods = Request :: getValidMethods ( ) ; self :: create ( $ methods , $ routeStr , $ info ) ; } | Creates a route that listens to all supported . |
24,706 | public static function create ( array $ methods , string $ routeStr , array $ info ) { $ middlewareList = isset ( $ info [ 'middleware' ] ) ? ( array ) $ info [ 'middleware' ] : [ ] ; array_walk_recursive ( self :: $ middlewareGroupStack , function ( $ middleware ) use ( & $ middlewareList ) { $ middlewareList [ ] = $ middleware ; } ) ; $ route = new self ( ) ; $ route -> setMethods ( $ methods ) ; $ route -> setAction ( isset ( $ info [ 'action' ] ) ? $ info [ 'action' ] : 'index' ) ; $ route -> setAlias ( isset ( $ info [ 'alias' ] ) ? $ info [ 'alias' ] : '' ) ; $ route -> setMiddlewareList ( $ middlewareList ) ; $ route -> setControllerName ( $ info [ 'controller' ] ) ; $ route -> setMethods ( $ methods ) ; $ route -> setRouteStr ( $ routeStr ) ; Map :: addRoute ( $ route ) ; } | Build a new route and add it to the Map . |
24,707 | public static function delete ( string $ routeStr , array $ info ) { self :: create ( [ Request :: METHOD_DELETE ] , $ routeStr , $ info ) ; } | Creates a route that listens to DELETE http method . |
24,708 | public static function get ( string $ routeStr , array $ info ) { self :: create ( [ Request :: METHOD_GET ] , $ routeStr , $ info ) ; } | Creates a route that listens to GET http method . |
24,709 | public static function group ( string $ prefix , Closure $ closure , $ middleware = [ ] ) { $ prefix = trim ( $ prefix , self :: SEPARATOR ) ; if ( $ prefix ) { self :: $ prefixGroupStack [ ] = $ prefix ; } if ( $ middleware ) { self :: $ middlewareGroupStack [ ] = $ middleware ; } $ closure ( ) ; if ( $ prefix ) { array_pop ( self :: $ prefixGroupStack ) ; } if ( $ middleware ) { array_pop ( self :: $ middlewareGroupStack ) ; } } | Creates a route group . |
24,710 | public static function post ( string $ routeStr , array $ info ) { self :: create ( [ Request :: METHOD_POST ] , $ routeStr , $ info ) ; } | Creates a route that listens to POST http method . |
24,711 | public static function patch ( string $ routeStr , array $ info ) { self :: create ( [ Request :: METHOD_PATCH ] , $ routeStr , $ info ) ; } | Creates a route that listens to PATCH http method . |
24,712 | public static function put ( string $ routeStr , array $ info ) { self :: create ( [ Request :: METHOD_PUT ] , $ routeStr , $ info ) ; } | Creates a route that listens to PUT http method . |
24,713 | public function addLogin ( $ login ) { if ( ! isset ( $ this -> logins [ $ login ] ) ) { $ this -> logins [ $ login ] = true ; $ this -> dispatcher -> dispatch ( self :: EVENT_NEW_USER , [ $ this , $ login ] ) ; } } | Add user to the group . |
24,714 | public function removeLogin ( $ login ) { if ( isset ( $ this -> logins [ $ login ] ) ) { unset ( $ this -> logins [ $ login ] ) ; $ this -> dispatcher -> dispatch ( self :: EVENT_REMOVE_USER , [ $ this , $ login ] ) ; } if ( ! $ this -> isPersistent ( ) && empty ( $ this -> logins ) ) { $ this -> dispatcher -> dispatch ( self :: EVENT_DESTROY , [ $ this , $ login ] ) ; } } | Remove user from the group . |
24,715 | public function add ( array $ data ) { try { $ document = ( new Visitor ( $ data ) ) -> toArray ( ) ; $ this -> collection -> insert ( $ document , [ 'w' => true ] ) ; return new \ MongoId ( $ document [ '_id' ] ) ; } catch ( \ MongoCursorException $ e ) { throw new MongoMapperException ( $ e -> getMessage ( ) ) ; } catch ( \ MongoException $ e ) { throw new MongoMapperException ( $ e -> getMessage ( ) ) ; } } | Add records to collection |
24,716 | public function buildXML ( array $ data , $ startElement = 'data' ) { if ( ! \ is_array ( $ data ) ) { $ err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__ ; \ trigger_error ( $ err ) ; return false ; } $ xml = new \ XmlWriter ( ) ; $ xml -> openMemory ( ) ; $ xml -> startDocument ( $ this -> version , $ this -> encoding ) ; $ xml -> startElement ( $ startElement ) ; $ data = $ this -> writeAttr ( $ xml , $ data ) ; $ this -> writeEl ( $ xml , $ data ) ; $ xml -> endElement ( ) ; return $ xml -> outputMemory ( true ) ; } | Build an XML Data Set |
24,717 | protected function writeEl ( XMLWriter $ xml , $ data ) { foreach ( $ data as $ key => $ value ) { if ( \ is_array ( $ value ) && ! $ this -> isAssoc ( $ value ) ) { foreach ( $ value as $ itemValue ) { if ( \ is_array ( $ itemValue ) ) { $ xml -> startElement ( $ key ) ; $ itemValue = $ this -> writeAttr ( $ xml , $ itemValue ) ; $ this -> writeEl ( $ xml , $ itemValue ) ; $ xml -> endElement ( ) ; } else { $ itemValue = $ this -> writeAttr ( $ xml , $ itemValue ) ; $ xml -> writeElement ( $ key , "$itemValue" ) ; } } } else if ( \ is_array ( $ value ) ) { $ xml -> startElement ( $ key ) ; $ value = $ this -> writeAttr ( $ xml , $ value ) ; $ this -> writeEl ( $ xml , $ value ) ; $ xml -> endElement ( ) ; } else { $ value = $ this -> writeAttr ( $ xml , $ value ) ; $ xml -> writeElement ( $ key , "$value" ) ; } } } | Write XML as per Associative Array |
24,718 | protected function _getActiveMenuPattern ( $ level = 0 , $ urlInfo = null ) { if ( empty ( $ urlInfo ) || ! is_array ( $ urlInfo ) ) { return false ; } $ level = ( int ) $ level ; extract ( $ urlInfo ) ; if ( ( $ level < 0 ) || ( $ level > 2 ) ) { $ level = 0 ; } if ( $ level > 1 ) { $ action = 'index' ; } if ( $ level == 0 ) { $ userPrefix = $ this -> Session -> read ( 'Auth.User.prefix' ) ; if ( empty ( $ prefix ) && ! empty ( $ userPrefix ) ) { $ prefix = $ userPrefix ; } } $ url = compact ( 'controller' , 'action' , 'plugin' , 'prefix' ) ; if ( ! empty ( $ prefix ) ) { $ url [ $ prefix ] = true ; } $ href = $ this -> url ( $ url ) ; $ href = preg_quote ( $ href , '/' ) ; if ( ! empty ( $ pass ) || ! empty ( $ named ) ) { if ( ( ( ( $ level == 0 ) && ( mb_stripos ( $ action , 'index' ) === false ) ) || ( $ level == 2 ) ) && ( $ href !== '\/' ) ) { $ href .= '\/?.*' ; } } $ activePattern = '/<a\s+href=\"' . $ href . '\".*>/iu' ; return $ activePattern ; } | Return pattern for PCRE of active menu item . |
24,719 | protected function _getActiveMenuPatterns ( $ urlInfo = null ) { $ deepLevelsActivePattern = $ this -> _getDeepLevelsActiveMenuPattern ( ) ; $ activePatterns = [ ] ; for ( $ activePatternLevel = 0 ; $ activePatternLevel <= $ deepLevelsActivePattern ; $ activePatternLevel ++ ) { $ activePatterns [ ] = $ this -> _getActiveMenuPattern ( $ activePatternLevel , $ urlInfo ) ; } return $ activePatterns ; } | Return Array of pattern for PCRE of active menu item . |
24,720 | protected function _prepareIconList ( array & $ iconList ) { if ( empty ( $ iconList ) || ! is_array ( $ iconList ) ) { return ; } foreach ( $ iconList as $ i => & $ iconListItem ) { if ( is_array ( $ iconListItem ) && isAssoc ( $ iconListItem ) ) { foreach ( $ iconListItem as $ topMenu => $ subMenu ) { $ subMenuList = '' ; foreach ( $ subMenu as $ subMenuItem ) { $ subMenuClass = null ; if ( $ subMenuItem === 'divider' ) { $ subMenuItem = '' ; $ subMenuClass = 'divider' ; } $ subMenuList .= $ this -> Html -> tag ( 'li' , $ subMenuItem , [ 'class' => $ subMenuClass ] ) ; } $ topMenuItem = $ topMenu . $ this -> Html -> tag ( 'ul' , $ subMenuList , [ 'class' => 'dropdown-menu' ] ) ; } $ iconListItem = $ topMenuItem ; } } } | Prepare a list of the icons main menu by adding a drop - down element for sub - menu item . |
24,721 | protected function _parseCurrentUrl ( ) { $ prefix = $ this -> request -> param ( 'prefix' ) ; $ plugin = $ this -> request -> param ( 'plugin' ) ; $ controller = $ this -> request -> param ( 'controller' ) ; $ action = $ this -> request -> param ( 'action' ) ; $ named = $ this -> request -> param ( 'named' ) ; $ pass = $ this -> request -> param ( 'pass' ) ; $ named = ( ! empty ( $ named ) ? true : false ) ; $ pass = ( ! empty ( $ pass ) ? true : false ) ; $ result = compact ( 'prefix' , 'plugin' , 'controller' , 'action' , 'named' , 'pass' ) ; return $ result ; } | Return array information of current URL . |
24,722 | public function getMenuList ( $ iconList = null ) { $ activeMenuUrl = $ this -> _View -> get ( 'activeMenuUrl' ) ; $ urlInfo = $ this -> _parseCurrentUrl ( ) ; if ( ! empty ( $ activeMenuUrl ) && is_array ( $ activeMenuUrl ) ) { $ urlInfo = $ activeMenuUrl + $ urlInfo ; } $ activePatterns = $ this -> _getActiveMenuPatterns ( $ urlInfo ) ; $ deepLevelsActivePattern = $ this -> _getDeepLevelsActiveMenuPattern ( ) ; $ activeMenu = [ ] ; $ menuList = '' ; $ cachePath = null ; if ( empty ( $ iconList ) || ! is_array ( $ iconList ) ) { return $ menuList ; } $ this -> _prepareIconList ( $ iconList ) ; $ dataStr = serialize ( $ iconList + $ urlInfo ) . '_' . $ this -> _currUIlang ; $ cachePath = 'MenuList.' . md5 ( $ dataStr ) ; $ cached = Cache :: read ( $ cachePath , CAKE_THEME_CACHE_KEY_HELPERS ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } foreach ( $ iconList as $ i => $ iconListItem ) { for ( $ activePatternLevel = 0 ; $ activePatternLevel <= $ deepLevelsActivePattern ; $ activePatternLevel ++ ) { if ( ! $ activePatterns [ $ activePatternLevel ] ) { continue ; } if ( preg_match ( $ activePatterns [ $ activePatternLevel ] , $ iconListItem ) ) { $ activeMenu [ $ activePatternLevel ] [ ] = $ i ; } } } for ( $ activePatternLevel = 0 ; $ activePatternLevel <= $ deepLevelsActivePattern ; $ activePatternLevel ++ ) { if ( isset ( $ activeMenu [ $ activePatternLevel ] ) && ! empty ( $ activeMenu [ $ activePatternLevel ] ) ) { break ; } } foreach ( $ iconList as $ i => $ iconListItem ) { $ iconListItemClass = null ; if ( isset ( $ activeMenu [ $ activePatternLevel ] ) && in_array ( $ i , $ activeMenu [ $ activePatternLevel ] ) ) { $ iconListItemClass = 'active' ; } $ menuList .= $ this -> Html -> tag ( 'li' , $ iconListItem , [ 'class' => $ iconListItemClass ] ) ; } if ( ! empty ( $ menuList ) ) { $ menuList = $ this -> Html -> tag ( 'ul' , $ menuList , [ 'class' => 'nav navbar-nav navbar-right' ] ) ; } Cache :: write ( $ cachePath , $ menuList , CAKE_THEME_CACHE_KEY_HELPERS ) ; return $ menuList ; } | Return HTML element of main menu . For mark menu item as active define view variable activeMenuUrl as array with URL contained in this menu item . |
24,723 | public function yesNo ( $ data = null ) { if ( ( bool ) $ data ) { $ result = $ this -> _getOptionsForElem ( 'yesNo.yes' ) ; } else { $ result = $ this -> _getOptionsForElem ( 'yesNo.no' ) ; } return $ result ; } | Return text Yes or No for target data . |
24,724 | public function popupModalLink ( $ title = null , $ url = null , $ options = [ ] ) { $ optionsDefault = $ this -> _getOptionsForElem ( 'popupModalLink' ) ; return $ this -> _createLink ( 'modal-popover' , $ title , $ url , $ options , $ optionsDefault ) ; } | Return popover and modal link . |
24,725 | public function confirmLink ( $ title = null , $ url = null , $ options = [ ] ) { $ optionsDefault = $ this -> _getOptionsConfirmLink ( ) ; return $ this -> _createLink ( null , $ title , $ url , $ options , $ optionsDefault ) ; } | Return link with confirmation dialog . |
24,726 | public function confirmPostLink ( $ title = null , $ url = null , $ options = [ ] ) { if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ optionsDefault = $ this -> _getOptionsConfirmLink ( ) ; $ optionsDefault [ 'role' ] = 'post-link' ; return $ this -> ExtBs3Form -> postLink ( $ title , $ url , $ options + $ optionsDefault ) ; } | Return link with confirmation dialog used POST request . |
24,727 | protected function _createLink ( $ toggle = null , $ title = null , $ url = null , $ options = [ ] , $ optionsDefault = [ ] ) { if ( empty ( $ options ) ) { $ options = [ ] ; } if ( empty ( $ optionsDefault ) ) { $ optionsDefault = [ ] ; } if ( ! empty ( $ toggle ) ) { $ options [ 'data-toggle' ] = $ toggle ; } if ( ! empty ( $ optionsDefault ) ) { $ options += $ optionsDefault ; } return $ this -> Html -> link ( $ title , $ url , $ options ) ; } | Return link used with data - toggle attribute . |
24,728 | public function ajaxLink ( $ title , $ url = null , $ options = [ ] ) { return $ this -> _createLink ( 'ajax' , $ title , $ url , $ options ) ; } | Return link used AJAX request . |
24,729 | public function requestOnlyLink ( $ title , $ url = null , $ options = [ ] ) { return $ this -> _createLink ( 'request-only' , $ title , $ url , $ options ) ; } | Return link used AJAX request without render result . |
24,730 | public function pjaxLink ( $ title , $ url = null , $ options = [ ] ) { return $ this -> _createLink ( 'pjax' , $ title , $ url , $ options ) ; } | Return link used PJAX request . |
24,731 | public function lightboxLink ( $ title , $ url = null , $ options = [ ] ) { return $ this -> _createLink ( 'lightbox' , $ title , $ url , $ options ) ; } | Return link used Lightbox for Bootstrap . |
24,732 | public function paginationSortPjax ( $ key = null , $ title = null , $ options = [ ] ) { if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ optionsDefault = $ this -> _getOptionsForElem ( 'paginationSortPjax.linkOpt' ) ; if ( $ this -> request -> is ( 'modal' ) ) { $ optionsDefault [ 'data-toggle' ] = 'modal' ; } $ sortKey = $ this -> Paginator -> sortKey ( ) ; if ( ! empty ( $ sortKey ) && ( $ key === $ sortKey ) ) { $ sortDir = $ this -> Paginator -> sortDir ( ) ; if ( $ sortDir === 'asc' ) { $ dirIcon = $ this -> _getOptionsForElem ( 'paginationSortPjax.iconDir.asc' ) ; } else { $ dirIcon = $ this -> _getOptionsForElem ( 'paginationSortPjax.iconDir.desc' ) ; } $ title .= $ dirIcon ; $ options [ 'escape' ] = false ; } return $ this -> Paginator -> sort ( $ key , $ title , $ options + $ optionsDefault ) ; } | Generates a sorting link used PJAX request . Sets named parameters for the sort and direction . Handles direction switching automatically . |
24,733 | public function progressSseLink ( $ title , $ url = null , $ options = [ ] ) { return $ this -> _createLink ( 'progress-sse' , $ title , $ url , $ options ) ; } | Return link used AJAX request and show progress bar of execution task from queue . |
24,734 | protected function _getClassForElement ( $ elementClass = null ) { $ elementClass = mb_strtolower ( ( string ) $ elementClass ) ; $ cachePath = 'ClassForElem.' . md5 ( $ elementClass ) ; $ cached = Cache :: read ( $ cachePath , CAKE_THEME_CACHE_KEY_HELPERS ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ result = '' ; if ( empty ( $ elementClass ) ) { return $ result ; } if ( mb_strpos ( $ elementClass , 'fa-' ) !== false ) { $ elemList = [ ] ; $ elemPrefixes = $ this -> _getListIconPrefixes ( ) ; $ elemPrefix = ( string ) $ this -> _config [ 'defaultIconPrefix' ] ; $ elemSizes = $ this -> _getListIconSizes ( ) ; $ elemSize = ( string ) $ this -> _config [ 'defaultIconSize' ] ; } elseif ( mb_strpos ( $ elementClass , 'btn-' ) !== false ) { $ elemList = $ this -> _getListButtons ( ) ; $ elemPrefixes = $ this -> _getListButtonPrefixes ( ) ; $ elemPrefix = ( string ) $ this -> _config [ 'defaultBtnPrefix' ] ; $ elemSizes = $ this -> _getListButtonSizes ( ) ; $ elemSize = ( string ) $ this -> _config [ 'defaultBtnSize' ] ; } else { return $ result ; } $ aElem = explode ( ' ' , $ elementClass , 5 ) ; $ aClass = [ ] ; foreach ( $ aElem as $ elemItem ) { if ( empty ( $ elemItem ) ) { continue ; } if ( in_array ( $ elemItem , $ elemSizes ) ) { $ elemSize = $ elemItem ; } elseif ( in_array ( $ elemItem , $ elemPrefixes ) ) { $ elemPrefix = $ elemItem ; } elseif ( empty ( $ elemList ) || ( ! empty ( $ elemList ) && in_array ( $ elemItem , $ elemList ) ) ) { $ aClass [ ] = $ elemItem ; } } if ( ! empty ( $ elemList ) && empty ( $ aClass ) ) { return $ result ; } if ( ! empty ( $ elemPrefix ) ) { array_unshift ( $ aClass , $ elemPrefix ) ; } if ( ! empty ( $ elemSize ) ) { array_push ( $ aClass , $ elemSize ) ; } $ aClass = array_unique ( $ aClass ) ; $ result = implode ( ' ' , $ aClass ) ; Cache :: write ( $ cachePath , $ result , CAKE_THEME_CACHE_KEY_HELPERS ) ; return $ result ; } | Return class name for icon or button . Exclude base class fa or btn and add class of size if need . |
24,735 | public function getBtnClass ( $ btn = null ) { $ btnClass = $ this -> _getClassForElement ( $ btn ) ; if ( ! empty ( $ btnClass ) ) { $ result = $ btnClass ; } else { $ result = $ this -> _getClassForElement ( 'btn-default' ) ; } return $ result ; } | Return class for button element |
24,736 | public function iconTag ( $ icon = null , $ options = [ ] ) { $ icon = mb_strtolower ( ( string ) $ icon ) ; $ dataStr = serialize ( compact ( 'icon' , 'options' ) ) . '_' . $ this -> _currUIlang ; $ cachePath = 'iconTag.' . md5 ( $ dataStr ) ; $ cached = Cache :: read ( $ cachePath , CAKE_THEME_CACHE_KEY_HELPERS ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ result = '' ; if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ iconClass = $ this -> _getClassForElement ( $ icon ) ; if ( empty ( $ iconClass ) ) { return $ result ; } $ options [ 'class' ] = $ iconClass ; $ result = $ this -> Html -> tag ( 'span' , '' , $ options ) ; Cache :: write ( $ cachePath , $ result , CAKE_THEME_CACHE_KEY_HELPERS ) ; return $ result ; } | Return HTML element of icon |
24,737 | public function buttonLink ( $ icon = null , $ btn = null , $ url = null , $ options = [ ] ) { $ result = '' ; if ( empty ( $ icon ) ) { return $ result ; } $ title = '' ; if ( $ icon === strip_tags ( $ icon ) ) { if ( $ this -> _getClassForElement ( $ icon ) ) { $ icon .= ' fa-fw' ; } $ title = $ this -> iconTag ( $ icon ) ; } if ( empty ( $ title ) ) { $ title = $ icon ; } $ button = $ this -> getBtnClass ( $ btn ) ; if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ options [ 'class' ] = $ button . ( isset ( $ options [ 'class' ] ) ? ' ' . $ options [ 'class' ] : '' ) ; $ optionsDefault = [ 'escape' => false , ] ; if ( isset ( $ options [ 'title' ] ) ) { $ optionsDefault [ 'data-toggle' ] = 'title' ; } $ postLink = $ this -> _processActionTypeOpt ( $ options ) ; if ( $ postLink ) { if ( ! isset ( $ options [ 'block' ] ) ) { $ options [ 'block' ] = 'confirm-form' ; } $ result = $ this -> ExtBs3Form -> postLink ( $ title , $ url , $ options + $ optionsDefault ) ; } else { $ result = $ this -> Html -> link ( $ title , $ url , $ options + $ optionsDefault ) ; } return $ result ; } | Return HTML element of button by link |
24,738 | public function button ( $ icon = null , $ btn = null , $ options = [ ] ) { $ result = '' ; if ( empty ( $ icon ) ) { return $ result ; } $ title = '' ; if ( $ icon === strip_tags ( $ icon ) ) { if ( $ this -> _getClassForElement ( $ icon ) ) { $ icon .= ' fa-fw' ; } $ title = $ this -> iconTag ( $ icon ) ; } if ( empty ( $ title ) ) { $ title = $ icon ; } $ button = $ this -> getBtnClass ( $ btn ) ; if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ options [ 'class' ] = $ button . ( isset ( $ options [ 'class' ] ) ? ' ' . $ options [ 'class' ] : '' ) ; $ optionsDefault = [ 'escape' => false , 'type' => 'button' , ] ; if ( isset ( $ options [ 'title' ] ) ) { $ optionsDefault [ 'data-toggle' ] = 'title' ; } $ result = $ this -> ExtBs3Form -> button ( $ title , $ options + $ optionsDefault ) ; return $ result ; } | Return HTML element of button |
24,739 | public function addUserPrefixUrl ( $ url = null ) { if ( empty ( $ url ) ) { return $ url ; } $ userPrefix = $ this -> Session -> read ( 'Auth.User.prefix' ) ; if ( empty ( $ userPrefix ) ) { return $ url ; } if ( ! is_array ( $ url ) ) { if ( ( $ url === '/' ) || ( stripos ( $ url , '/' ) === false ) ) { return $ url ; } $ url = Router :: parse ( $ url ) ; } if ( isset ( $ url [ 'prefix' ] ) && ( $ url [ 'prefix' ] === false ) ) { $ url [ $ userPrefix ] = false ; if ( isset ( $ url [ 'prefix' ] ) ) { unset ( $ url [ 'prefix' ] ) ; } return $ url ; } $ url [ $ userPrefix ] = true ; return $ url ; } | Return URL with user role prefix For disable use user prefix add to url array key prefix with value false . |
24,740 | public function menuItemLabel ( $ title = null ) { $ result = '' ; if ( empty ( $ title ) ) { return $ result ; } $ result = $ this -> Html -> tag ( 'span' , $ title , [ 'class' => 'menu-item-label visible-xs-inline' ] ) ; return $ result ; } | Return HTML element of menu item label |
24,741 | public function menuItemLink ( $ icon = null , $ title = null , $ url = null , $ options = [ ] , $ badgeNumber = 0 ) { $ result = '' ; if ( empty ( $ icon ) || empty ( $ title ) ) { return $ result ; } $ caret = '' ; if ( empty ( $ options ) || ! is_array ( $ options ) ) { $ options = [ ] ; } $ options [ 'escape' ] = false ; $ options [ 'title' ] = $ title ; $ badgeNumber = ( int ) $ badgeNumber ; if ( empty ( $ url ) ) { $ url = '#' ; $ caret = $ this -> Html -> tag ( 'span' , '' , [ 'class' => 'caret' ] ) ; $ options += [ 'class' => 'dropdown-toggle' , 'data-toggle' => 'dropdown' , 'role' => 'button' , 'aria-haspopup' => 'true' , 'aria-expanded' => 'false' ] ; } else { $ url = $ this -> addUserPrefixUrl ( $ url ) ; } if ( $ this -> _getClassForElement ( $ icon ) ) { $ icon .= ' fa-fw' ; } $ iconTag = $ this -> iconTag ( $ icon ) . $ this -> menuItemLabel ( $ title ) . $ caret ; if ( $ badgeNumber > 0 ) { $ iconTag .= ' ' . $ this -> Html -> tag ( 'span' , $ this -> Number -> format ( $ badgeNumber , [ 'thousands' => ' ' , 'before' => '' , 'places' => 0 ] ) , [ 'class' => 'badge' ] ) ; } if ( ! isset ( $ options [ 'data-toggle' ] ) ) { $ options [ 'data-toggle' ] = 'tooltip' ; } $ result = $ this -> Html -> link ( $ iconTag , $ url , $ options ) ; return $ result ; } | Return HTML element of menu item |
24,742 | public function menuActionLink ( $ icon = null , $ titleText = null , $ url = null , $ options = [ ] ) { $ result = '' ; if ( empty ( $ icon ) ) { return $ result ; } if ( $ this -> _getClassForElement ( $ icon ) ) { $ icon .= ' fa-fw' ; } $ iconClass = $ this -> _getClassForElement ( $ icon ) ; if ( empty ( $ iconClass ) ) { return $ result ; } $ title = $ this -> Html -> tag ( 'span' , '' , [ 'class' => $ iconClass ] ) ; if ( ! empty ( $ titleText ) ) { $ title .= $ this -> Html -> tag ( 'span' , $ titleText , [ 'class' => 'menu-item-label' ] ) ; } if ( empty ( $ options ) ) { $ options = [ ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ $ options ] ; } $ optionsDefault = [ 'escape' => false , ] ; if ( isset ( $ options [ 'title' ] ) ) { $ optionsDefault [ 'data-toggle' ] = 'title' ; } $ url = $ this -> addUserPrefixUrl ( $ url ) ; $ postLink = $ this -> _processActionTypeOpt ( $ options ) ; if ( $ postLink ) { $ result = $ this -> ExtBs3Form -> postLink ( $ title , $ url , $ options + $ optionsDefault ) ; } else { $ result = $ this -> Html -> link ( $ title , $ url , $ options + $ optionsDefault ) ; } return $ result ; } | Return HTML element of item for page header menu |
24,743 | public function timeAgo ( $ time = null , $ format = null ) { if ( empty ( $ time ) ) { $ time = time ( ) ; } if ( empty ( $ format ) ) { $ format = '%x %X' ; } $ result = $ this -> Html -> tag ( 'time' , $ this -> Time -> i18nFormat ( $ time , $ format ) , [ 'data-toggle' => 'timeago' , 'datetime' => date ( 'c' , $ this -> Time -> fromString ( $ time ) ) , 'class' => 'help' ] ) ; return $ result ; } | Return HTML element of time ago |
24,744 | public function getIconForExtension ( $ extension = null ) { $ extension = mb_strtolower ( ( string ) $ extension ) ; $ cachePath = 'IconForExtension.' . md5 ( $ extension ) ; $ cached = Cache :: read ( $ cachePath , CAKE_THEME_CACHE_KEY_HELPERS ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ result = 'far fa-file' ; if ( empty ( $ extension ) ) { Cache :: write ( $ cachePath , $ result , CAKE_THEME_CACHE_KEY_HELPERS ) ; return $ result ; } $ extensions = [ 'far fa-file-archive' => [ 'zip' , 'rar' , '7z' ] , 'far fa-file-word' => [ 'doc' , 'docx' ] , 'far fa-file-code' => [ 'htm' , 'html' , 'xml' , 'js' ] , 'far fa-file-image' => [ 'jpg' , 'jpeg' , 'png' , 'gif' ] , 'far fa-file-pdf' => [ 'pdf' ] , 'far fa-file-video' => [ 'avi' , 'mp4' ] , 'far fa-file-powerpoint' => [ 'ppt' , 'pptx' ] , 'far fa-file-audio' => [ 'mp3' , 'wav' , 'flac' ] , 'far fa-file-excel' => [ 'xls' , 'xlsx' ] , 'far fa-file-alt' => [ 'txt' ] , ] ; foreach ( $ extensions as $ icon => $ extensionsList ) { if ( in_array ( $ extension , $ extensionsList ) ) { $ result = $ icon ; break ; } } Cache :: write ( $ cachePath , $ result , CAKE_THEME_CACHE_KEY_HELPERS ) ; return $ result ; } | Return icon for file from extension . |
24,745 | public function truncateText ( $ text = null , $ length = 0 ) { $ result = '' ; if ( empty ( $ text ) ) { return $ result ; } $ text = ( string ) $ text ; $ length = ( int ) $ length ; if ( $ length <= 0 ) { $ length = 50 ; } if ( ( $ text === h ( $ text ) ) && ( mb_strlen ( $ text ) <= $ length ) ) { return $ text ; } $ truncateOpt = $ this -> _getOptionsForElem ( 'truncateText.truncateOpt' ) ; $ tuncatedText = $ this -> Text -> truncate ( $ text , $ length , $ truncateOpt ) ; if ( $ tuncatedText === $ text ) { return $ tuncatedText ; } $ result = $ this -> Html -> div ( 'collapse-text-truncated' , $ tuncatedText ) ; $ result .= $ this -> Html -> div ( 'collapse-text-original' , $ text . $ this -> _getOptionsForElem ( 'truncateText.collapseLink' ) ) ; $ result = $ this -> Html -> div ( 'collapse-text-expanded' , $ result ) ; return $ result ; } | Return truncated text with button expand and roll up . |
24,746 | public function getFormOptions ( $ options = [ ] ) { if ( empty ( $ options ) || ! is_array ( $ options ) ) { $ options = [ ] ; } $ optionsDefault = $ this -> _getOptionsForElem ( 'form' ) ; $ result = $ optionsDefault + $ options ; return $ result ; } | Return array of options for HTML Form element . |
24,747 | protected function _getLangForNumberText ( $ langCode = null ) { if ( ! is_object ( $ this -> _NumberTextLib ) ) { return false ; } $ cachePath = 'lang_code_number_lib_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_THEME_CACHE_KEY_LANG_CODE ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ langNumb = $ this -> _Language -> getLangForNumberText ( $ langCode ) ; $ result = $ this -> _NumberTextLib -> setLang ( $ langNumb ) ; Cache :: write ( $ cachePath , $ result , CAKE_THEME_CACHE_KEY_LANG_CODE ) ; return $ result ; } | Return language name for library Tools . NumberText . |
24,748 | public function numberText ( $ number = null , $ langCode = null ) { if ( ! is_object ( $ this -> _NumberTextLib ) ) { return false ; } $ langNumb = $ this -> _getLangForNumberText ( $ langCode ) ; return $ this -> _NumberTextLib -> numberText ( $ number , $ langNumb ) ; } | Return number as text . |
24,749 | public function barState ( $ stateData = null ) { $ result = '' ; if ( ! is_array ( $ stateData ) ) { $ stateData = [ ] ; } if ( empty ( $ stateData ) ) { $ stateData = [ [ 'stateName' => $ this -> showEmpty ( null ) , 'stateId' => null , 'amount' => 0 , 'stateUrl' => null , ] ] ; } $ totalAmount = Hash :: apply ( $ stateData , '{n}.amount' , 'array_sum' ) ; $ percSum = 0 ; $ countState = count ( $ stateData ) ; foreach ( $ stateData as $ i => $ stateItem ) { $ class = 'progress-bar' ; if ( isset ( $ stateItem [ 'class' ] ) && ! empty ( $ stateItem [ 'class' ] ) ) { $ class .= ' ' . $ stateItem [ 'class' ] ; } if ( $ totalAmount > 0 ) { $ perc = round ( $ stateItem [ 'amount' ] / $ totalAmount * 100 , 2 ) ; } else { $ perc = 100 ; } $ percRound = round ( $ perc ) ; if ( $ percSum + $ percRound > 100 ) { $ percRound = 100 - $ percSum ; } else { if ( $ i == $ countState - 1 ) { $ percRound = 100 - $ percSum ; } } $ percSum += $ percRound ; $ stateName = $ stateItem [ 'stateName' ] ; $ progressBar = $ this -> Html -> div ( $ class , $ stateName , [ 'role' => 'progressbar' , 'style' => 'width:' . $ percRound . '%' , 'title' => $ stateName . ': ' . $ this -> Number -> format ( $ stateItem [ 'amount' ] , [ 'thousands' => ' ' , 'before' => '' , 'places' => 0 ] ) . ' (' . $ perc . '%)' , 'data-toggle' => 'tooltip' ] ) ; if ( isset ( $ stateItem [ 'stateUrl' ] ) && ! empty ( $ stateItem [ 'stateUrl' ] ) ) { $ progressBar = $ this -> Html -> link ( $ progressBar , $ stateItem [ 'stateUrl' ] , [ 'target' => '_blank' , 'escape' => false ] ) ; } $ result .= $ progressBar ; } $ result = $ this -> Html -> div ( 'progress' , $ result ) ; return $ result ; } | Return bar of state . |
24,750 | public function listLastInfo ( $ lastInfo = null , $ labelList = null , $ controllerName = null , $ actionName = null , $ linkOptions = [ ] , $ length = 0 ) { if ( ! is_array ( $ lastInfo ) ) { $ lastInfo = [ ] ; } if ( empty ( $ labelList ) && ! empty ( $ controllerName ) ) { $ labelList = Inflector :: humanize ( Inflector :: underscore ( $ controllerName ) ) ; } if ( empty ( $ actionName ) ) { $ actionName = 'view' ; } $ lastInfoList = '' ; if ( ! empty ( $ labelList ) ) { $ lastInfoList .= $ this -> Html -> tag ( 'dt' , $ labelList . ':' ) ; } if ( ! empty ( $ lastInfo ) ) { $ lastInfoListData = [ ] ; foreach ( $ lastInfo as $ lastInfoItem ) { $ label = $ this -> truncateText ( h ( $ lastInfoItem [ 'label' ] ) , $ length ) ; if ( ! empty ( $ controllerName ) && ! empty ( $ lastInfoItem [ 'id' ] ) ) { $ url = $ this -> addUserPrefixUrl ( [ 'controller' => $ controllerName , 'action' => $ actionName , $ lastInfoItem [ 'id' ] ] ) ; $ label = $ this -> popupModalLink ( $ label , $ url , $ linkOptions ) ; } $ lastInfoListData [ ] = $ label . ' (' . $ this -> timeAgo ( $ lastInfoItem [ 'modified' ] ) . ')' ; } $ lastInfoListItem = $ this -> Html -> nestedList ( $ lastInfoListData , null , null , 'ol' ) ; } else { $ lastInfoListItem = $ this -> showEmpty ( null ) ; } $ lastInfoList .= $ this -> Html -> tag ( 'dd' , $ lastInfoListItem ) ; $ result = $ this -> Html -> tag ( 'dl' , $ lastInfoList , [ 'class' => 'dl-horizontal' ] ) ; return $ result ; } | Return list of last changed data . |
24,751 | public function buttonsMove ( $ url = null , $ useDrag = true , $ glue = '' , $ useGroup = false ) { $ result = '' ; if ( empty ( $ url ) || ! is_array ( $ url ) ) { return $ result ; } $ actions = [ ] ; if ( $ useDrag ) { $ actions [ ] = $ this -> _getOptionsForElem ( 'buttonsMove.btnDrag' ) ; } $ buttons = $ this -> _getOptionsForElem ( 'buttonsMove.btnsMove' ) ; foreach ( $ buttons as $ button ) { $ actions [ ] = $ this -> buttonLink ( $ button [ 'icon' ] , 'btn-info' , array_merge ( $ button [ 'url' ] , $ url ) , [ 'title' => $ button [ 'title' ] , 'data-toggle' => 'move' ] ) ; } $ result = implode ( $ glue , $ actions ) ; if ( empty ( $ glue ) && $ useGroup ) { $ result = $ this -> Html -> div ( 'btn-group' , $ result , [ 'role' => 'group' ] ) ; } return $ result ; } | Return buttons for moving items . |
24,752 | public function buttonLoadMore ( $ targetSelector = null ) { $ result = '' ; if ( empty ( $ targetSelector ) ) { $ targetSelector = 'table tbody' ; } $ hasNext = $ this -> Paginator -> hasNext ( ) ; if ( ! $ hasNext ) { $ paginatorParams = $ this -> Paginator -> params ( ) ; $ count = ( int ) Hash :: get ( $ paginatorParams , 'count' ) ; $ records = __dn ( 'view_extension' , 'record' , 'records' , $ count ) ; $ result = $ this -> Html -> div ( 'load-more' , $ this -> Html -> para ( 'small' , $ this -> Paginator -> counter ( __d ( 'view_extension' , 'Showing {:count} %s' , $ records ) ) ) ) ; return $ result ; } $ urlPaginator = [ ] ; if ( isset ( $ this -> Paginator -> options [ 'url' ] ) ) { $ urlPaginator = ( array ) $ this -> Paginator -> options [ 'url' ] ; } $ paginatorParams = $ this -> Paginator -> params ( ) ; $ count = ( int ) Hash :: get ( $ paginatorParams , 'count' ) ; $ page = ( int ) Hash :: get ( $ paginatorParams , 'page' ) ; $ limit = ( int ) Hash :: get ( $ paginatorParams , 'limit' ) ; $ urlLoadMore = $ this -> Paginator -> url ( [ 'page' => $ page + 1 , 'show' => 'list' ] , true ) ; $ urlLoadMore = array_merge ( $ urlPaginator , $ urlLoadMore ) ; $ btnClass = $ this -> getBtnClass ( 'btn-default btn-sm' ) ; $ btnClass .= ' btn-block' ; $ startRecord = 0 ; if ( $ count >= 1 ) { $ startRecord = ( ( $ page - 1 ) * $ limit ) + 1 ; } $ endRecord = $ startRecord + $ limit - 1 ; $ records = __dn ( 'view_extension' , 'record' , 'records' , $ endRecord ) ; $ result = $ this -> Html -> div ( 'load-more' , $ this -> Html -> para ( 'small' , $ this -> Paginator -> counter ( __d ( 'view_extension' , 'Current loaded page {:page} of {:pages}, showing {:end} %s of {:count} total' , $ records ) ) ) . $ this -> Html -> link ( $ this -> _getOptionsForElem ( 'loadMore.linkTitle' ) , $ urlLoadMore , [ 'class' => $ btnClass . ' hidden-print' , 'data-target-selector' => $ targetSelector , ] + $ this -> _getOptionsForElem ( 'loadMore.linkOpt' ) ) ) ; return $ result ; } | Return controls of pagination as button Load more . |
24,753 | public function buttonsPaging ( $ targetSelector = null , $ showCounterInfo = true , $ useShowList = true , $ useGoToPage = true , $ useChangeNumLines = true ) { $ showType = ( string ) $ this -> request -> param ( 'named.show' ) ; if ( mb_stripos ( $ showType , 'list' ) === 0 ) { $ result = $ this -> buttonLoadMore ( $ targetSelector ) ; } else { $ result = $ this -> barPaging ( $ showCounterInfo , $ useShowList , $ useGoToPage , $ useChangeNumLines ) ; } return $ result ; } | Return controls of pagination depending on the state of the named parameter show |
24,754 | public function menuHeaderPage ( $ headerMenuActions = null ) { $ result = '' ; if ( empty ( $ headerMenuActions ) ) { return $ result ; } if ( ! is_array ( $ headerMenuActions ) ) { $ headerMenuActions = [ $ headerMenuActions ] ; } $ headerMenuActionsPrep = '' ; foreach ( $ headerMenuActions as $ action ) { $ actionOptions = [ ] ; if ( ! is_array ( $ action ) ) { if ( $ action === 'divider' ) { $ action = '' ; $ actionOptions = [ 'class' => 'divider' ] ; } $ headerMenuActionsPrep .= $ this -> Html -> tag ( 'li' , $ action , $ actionOptions ) ; } elseif ( is_array ( $ action ) ) { $ actionSize = count ( $ action ) ; if ( $ actionSize == 1 ) { $ actionLabal = array_shift ( $ action ) ; if ( empty ( $ actionLabal ) ) { continue ; } $ headerMenuActionsPrep .= $ this -> Html -> tag ( 'li' , $ actionLabal ) ; } elseif ( $ actionSize == 2 ) { $ actionLabal = array_shift ( $ action ) ; if ( empty ( $ actionLabal ) ) { continue ; } $ actionOptions = array_shift ( $ action ) ; if ( ! is_array ( $ actionOptions ) ) { $ actionOptions = [ ] ; } $ headerMenuActionsPrep .= $ this -> Html -> tag ( 'li' , $ actionLabal , $ actionOptions ) ; } elseif ( ( $ actionSize >= 3 ) && ( $ actionSize <= 4 ) ) { $ action = call_user_func_array ( [ $ this , 'menuActionLink' ] , $ action ) ; $ headerMenuActionsPrep .= $ this -> Html -> tag ( 'li' , $ action , $ actionOptions ) ; } } } if ( empty ( $ headerMenuActionsPrep ) ) { return $ result ; } $ result = $ this -> Html -> div ( 'btn-group page-header-menu hidden-print' , $ this -> _getOptionsForElem ( 'btnHeaderMenu' ) . $ this -> Html -> tag ( 'ul' , $ headerMenuActionsPrep , [ 'class' => 'dropdown-menu' , 'aria-labelledby' => 'pageHeaderMenu' ] ) ) ; return $ result ; } | Return menu for header of page . |
24,755 | public function headerPage ( $ pageHeader = null , $ headerMenuActions = null ) { $ result = '' ; if ( empty ( $ pageHeader ) ) { return $ result ; } $ pageHeader = ( string ) $ pageHeader ; $ pageHeader .= $ this -> menuHeaderPage ( $ headerMenuActions ) ; return $ this -> Html -> div ( 'page-header well' , $ this -> Html -> tag ( 'h2' , $ pageHeader , [ 'class' => 'header' ] ) ) ; } | Return header of page . |
24,756 | public function collapsibleList ( $ listData = [ ] , $ showLimit = 10 , $ listClass = 'list-unstyled' , $ listTag = 'ul' ) { $ result = '' ; if ( empty ( $ listData ) ) { return $ result ; } $ showLimit = ( int ) $ showLimit ; if ( $ showLimit < 1 ) { return $ result ; } if ( ! empty ( $ listClass ) ) { $ listClass = ' ' . $ listClass ; } $ tagsAllowed = [ 'ul' , 'ol' ] ; if ( ! in_array ( $ listTag , $ tagsAllowed ) ) { $ listTag = 'ul' ; } $ listDataShown = array_slice ( $ listData , 0 , $ showLimit ) ; $ result = $ this -> Html -> nestedList ( $ listDataShown , [ 'class' => 'list-collapsible-compact' . $ listClass ] , [ ] , $ listTag ) ; if ( count ( $ listData ) <= $ showLimit ) { return $ result ; } $ listId = uniqid ( 'collapsible-list-' ) ; $ listDataHidden = array_slice ( $ listData , $ showLimit ) ; $ result .= $ this -> Html -> nestedList ( $ listDataHidden , [ 'class' => 'list-collapsible-compact collapse' . $ listClass , 'id' => $ listId ] , [ ] , $ listTag ) . $ this -> button ( 'fas fa-angle-double-down' , 'btn-default' , [ 'class' => 'top-buffer hide-popup' , 'title' => __d ( 'view_extension' , 'Show or hide full list' ) , 'data-toggle' => 'collapse' , 'data-target' => '#' . $ listId , 'aria-expanded' => 'false' , 'data-toggle-icons' => 'fa-angle-double-down,fa-angle-double-up' ] ) ; return $ result ; } | Return collapsible list . |
24,757 | public function addBreadCrumbs ( $ breadCrumbs = null ) { if ( empty ( $ breadCrumbs ) || ! is_array ( $ breadCrumbs ) ) { return ; } foreach ( $ breadCrumbs as $ breadCrumbInfo ) { if ( empty ( $ breadCrumbInfo ) ) { continue ; } $ link = null ; if ( is_array ( $ breadCrumbInfo ) ) { $ name = array_shift ( $ breadCrumbInfo ) ; $ link = array_shift ( $ breadCrumbInfo ) ; } else { $ name = $ breadCrumbInfo ; } if ( empty ( $ name ) ) { continue ; } $ this -> Html -> addCrumb ( h ( $ name ) , $ link ) ; } } | Adds a links to the breadcrumbs array . |
24,758 | public function byOrganizationWithYear ( $ id ) { $ periods = $ this -> DB -> connection ( $ this -> databaseConnectionName ) -> table ( 'ACCT_Period As p' ) -> join ( 'ACCT_Fiscal_Year AS f' , 'f.id' , '=' , 'p.fiscal_year_id' ) -> where ( 'p.organization_id' , '=' , $ id ) -> get ( array ( 'p.id' , 'p.month' , 'f.year' ) ) ; return new Collection ( $ periods ) ; } | Retrieve periods by organization with its year |
24,759 | public function lastPeriodbyOrganizationAndByFiscalYear ( $ organizationId , $ fiscalYearId ) { $ Period = $ this -> Period -> selectRaw ( 'id, end_date, max(month) as month' ) -> where ( 'organization_id' , '=' , $ organizationId ) -> where ( 'fiscal_year_id' , '=' , $ fiscalYearId ) -> orderBy ( 'month' , 'desc' ) -> groupBy ( array ( 'id' , 'end_date' ) ) -> first ( ) ; return $ Period ; } | Get last period by organization and by fiscal year |
24,760 | public function create ( array $ data ) { $ Period = new Period ( ) ; $ Period -> setConnection ( $ this -> databaseConnectionName ) ; $ Period -> fill ( $ data ) -> save ( ) ; return $ Period ; } | Create a new period |
24,761 | public function update ( array $ data , $ Period = null ) { if ( empty ( $ Period ) ) { $ Period = $ this -> byId ( $ data [ 'id' ] ) ; } foreach ( $ data as $ key => $ value ) { $ Period -> $ key = $ value ; } return $ Period -> save ( ) ; } | Update an existing period |
24,762 | private function setModificationDate ( array $ ftpInfo ) { $ modDate = ! empty ( $ ftpInfo [ 'modify' ] ) ? DateTimeImmutable :: createFromFormat ( 'YmdHis' , $ ftpInfo [ 'modify' ] ) : false ; $ this -> modify = ! empty ( $ modDate ) ? $ modDate : new DateTimeImmutable ( ) ; } | Set modification date . |
24,763 | public function addIFrame ( $ src , $ windowWidth , $ windowHeight , $ thumb = "" , $ title = "" , $ caption = "" , $ width = "" , $ height = "" ) { $ this -> addXmlnukeObject ( XmlnukeMediaItem :: IFrameFactory ( $ src , $ windowWidth , $ windowHeight , $ thumb , $ title , $ caption , $ width , $ height ) ) ; } | Create an Media Item of IFrame type |
24,764 | public function buildAttrs ( array $ attrs = array ( ) ) { $ result = ' ' ; foreach ( $ attrs as $ key => $ param ) { $ param = ( array ) $ param ; if ( $ key === 'data' ) { $ result .= $ this -> _buildDataAttrs ( $ param ) ; continue ; } $ value = implode ( ' ' , $ param ) ; $ value = $ this -> _cleanValue ( $ value ) ; if ( $ key !== 'data' && $ attr = $ this -> _buildAttr ( $ key , $ value ) ) { $ result .= $ attr ; } } return trim ( $ result ) ; } | Build attributes . |
24,765 | protected function _buildAttr ( $ key , $ val ) { $ return = null ; if ( ! empty ( $ val ) || $ val === '0' || $ key === 'value' ) { $ return = ' ' . $ key . '="' . $ val . '"' ; } return $ return ; } | Build attribute . |
24,766 | protected function _buildDataAttrs ( array $ param = array ( ) ) { $ return = '' ; foreach ( $ param as $ data => $ val ) { $ dKey = 'data-' . trim ( $ data ) ; if ( is_object ( $ val ) ) { $ val = ( array ) $ val ; } if ( is_array ( $ val ) ) { $ val = str_replace ( '"' , '\'' , json_encode ( $ val ) ) ; $ return .= $ this -> _buildAttr ( $ dKey , $ val ) ; continue ; } $ return .= $ this -> _buildAttr ( $ dKey , $ val ) ; } return $ return ; } | Build html data attributes . |
24,767 | protected function _cleanAttrs ( array $ attrs = array ( ) ) { foreach ( $ attrs as $ key => $ val ) { if ( Arr :: in ( $ key , $ this -> _disallowAttr ) ) { unset ( $ attrs [ $ key ] ) ; } } return $ attrs ; } | Remove disallow attributes . |
24,768 | protected function _cleanValue ( $ value , $ trim = false ) { $ value = htmlspecialchars ( $ value , ENT_QUOTES , 'UTF-8' ) ; return ( $ trim ) ? trim ( $ value ) : $ value ; } | Clear attribute value |
24,769 | protected function _mergeAttr ( array $ attrs = array ( ) , $ val = null , $ key = 'class' ) { if ( Arr :: key ( $ key , $ attrs ) ) { $ attrs [ $ key ] .= ' ' . $ val ; } else { $ attrs [ $ key ] = $ val ; } return $ attrs ; } | Merge attributes by given key . |
24,770 | protected function createTabsMenu ( ManialinkInterface $ manialink , ParentItem $ rootItem , $ openId ) { $ tabsFrame = $ manialink -> getData ( 'tabs_frame' ) ; $ tabsFrame -> removeAllChildren ( ) ; $ this -> menuTabsFactory -> createTabsMenu ( $ manialink , $ tabsFrame , $ rootItem , [ $ this , 'callbackItemClick' ] , $ openId ) ; } | Create tabs level menu . |
24,771 | public function callbackClose ( ManialinkInterface $ manialink , $ login , $ params , $ args ) { $ this -> destroy ( $ manialink -> getUserGroup ( ) ) ; } | Callback when the close button is clicked . |
24,772 | public static function almostEqual ( $ a , $ b , $ epsilon = 0.0000000001 ) { $ diff = abs ( $ a - $ b ) ; if ( $ a === $ b ) { return true ; } elseif ( $ a === 0.0 || $ b === 0.0 || $ diff < self :: FLOAT_MIN ) { return $ diff < ( $ epsilon * self :: FLOAT_MIN ) ; } else { $ abs_a = abs ( $ a ) ; $ abs_b = abs ( $ b ) ; return $ diff / ( $ abs_a + $ abs_b ) < $ epsilon ; } } | Compare two float values for equality . |
24,773 | public function doCheckIn ( $ data , CheckInForm $ form ) { $ controller = $ form -> getController ( ) ; $ validator = CheckInValidator :: create ( ) ; $ result = $ validator -> validate ( $ data [ 'TicketCode' ] ) ; switch ( $ result [ 'Code' ] ) { case CheckInValidator :: MESSAGE_CHECK_OUT_SUCCESS : $ validator -> getAttendee ( ) -> checkOut ( ) ; break ; case CheckInValidator :: MESSAGE_CHECK_IN_SUCCESS : $ validator -> getAttendee ( ) -> checkIn ( ) ; break ; } $ form -> sessionMessage ( $ result [ 'Message' ] , strtolower ( $ result [ 'Type' ] ) , false ) ; $ this -> extend ( 'onAfterCheckIn' , $ response , $ form , $ result ) ; return $ response ? $ response : $ controller -> redirect ( $ controller -> Link ( ) ) ; } | Do the check in if all checks pass return a success |
24,774 | public function getLengthQueue ( $ jobType = null ) { $ jobType = ( string ) $ jobType ; $ queueLength = 0 ; $ pendingStats = $ this -> getPendingStats ( ) ; if ( empty ( $ pendingStats ) ) { return $ queueLength ; } foreach ( $ pendingStats as $ pendingStatsItem ) { if ( ( ! empty ( $ jobType ) && ( strcmp ( $ pendingStatsItem [ $ this -> alias ] [ 'jobtype' ] , $ jobType ) !== 0 ) ) || ( $ pendingStatsItem [ $ this -> alias ] [ 'status' ] !== 'NOT_STARTED' ) ) { continue ; } $ queueLength ++ ; } return $ queueLength ; } | Get length of job queue for not started task |
24,775 | public function getPendingJob ( $ jobType = null , $ includeFinished = false , $ timestamp = null ) { if ( empty ( $ jobType ) ) { return false ; } if ( empty ( $ timestamp ) || ( ! is_int ( $ timestamp ) || ! ctype_digit ( $ timestamp ) ) ) { $ timestamp = strtotime ( '-15 minute' ) ; } $ fetchedTime = date ( 'Y-m-d H:i:s' , $ timestamp ) ; $ fields = [ $ this -> alias . '.jobtype' , $ this -> alias . '.created' , $ this -> alias . '.status' , $ this -> alias . '.age' , $ this -> alias . '.fetched' , $ this -> alias . '.progress' , $ this -> alias . '.completed' , $ this -> alias . '.reference' , $ this -> alias . '.failed' , $ this -> alias . '.failure_message' ] ; $ conditions = [ 'OR' => [ [ $ this -> alias . '.notbefore > NOW()' , ] , [ $ this -> alias . '.fetched' => null , ] , [ 'AND' => [ $ this -> alias . '.fetched NOT' => null , $ this -> alias . '.fetched >' => $ fetchedTime , $ this -> alias . '.completed' => null , $ this -> alias . '.failed' => 0 , ] , ] ] , $ this -> alias . '.jobtype' => $ jobType , ] ; if ( $ includeFinished ) { $ conditions [ 'OR' ] [ ] = [ 'AND' => [ $ this -> alias . '.fetched NOT' => null , $ this -> alias . '.fetched >' => $ fetchedTime , $ this -> alias . '.completed' => null , $ this -> alias . '.failed >' => 0 , ] , ] ; $ conditions [ 'OR' ] [ ] = [ 'AND' => [ $ this -> alias . '.fetched NOT' => null , $ this -> alias . '.fetched >' => $ fetchedTime , $ this -> alias . '.completed NOT' => null , ] , ] ; } $ order = [ 'FIELD(' . $ this -> alias . '__status' . ', \'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\', \'FAILED\', \'COMPLETED\')' => 'ASC' , 'CAST(' . $ this -> alias . '__age AS SIGNED)' => 'DESC' , 'CASE WHEN ' . $ this -> alias . '__status' . ' IN(\'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\') THEN ' . $ this -> alias . '.id END ASC' , 'CASE WHEN ' . $ this -> alias . '__status' . ' IN(\'FAILED\', \'COMPLETED\') THEN ' . $ this -> alias . '.id END DESC' , ] ; return $ this -> find ( 'first' , compact ( 'fields' , 'conditions' , 'order' ) ) ; } | Return statistics about job still in the Database . |
24,776 | public function updateMessage ( $ id = null , $ message = null ) { if ( empty ( $ id ) || ! $ this -> exists ( $ id ) ) { return false ; } $ message = ( string ) $ message ; if ( empty ( $ message ) ) { $ message = null ; } $ this -> id = ( int ) $ id ; return ( bool ) $ this -> saveField ( 'failure_message' , $ message ) ; } | Update massage of job |
24,777 | public function updateTaskProgress ( $ id , & $ step , $ maxStep = 0 ) { if ( empty ( $ id ) || ! $ this -> exists ( $ id ) || ( $ maxStep < 1 ) || ( $ maxStep < $ step ) ) { return false ; } $ step ++ ; $ progress = $ step / $ maxStep ; return $ this -> updateProgress ( $ id , $ progress ) ; } | Update progress of job |
24,778 | public function updateTaskErrorMessage ( $ id = null , $ errorMessage = null , $ keepExistingMessage = false ) { if ( empty ( $ id ) || ! $ this -> exists ( $ id ) || empty ( $ errorMessage ) ) { return false ; } if ( $ keepExistingMessage ) { $ this -> id = $ id ; $ message = $ this -> field ( 'failure_message' ) ; if ( ! empty ( $ message ) ) { $ errorMessage = $ message . "\n" . $ errorMessage ; } } return $ this -> markJobFailed ( $ id , $ errorMessage ) ; } | Update error massage of job |
24,779 | public function deleteTasks ( $ data = null ) { if ( empty ( $ data ) || ! is_array ( $ data ) ) { return false ; } $ excludeFields = [ 'data' , 'failure_message' , 'workerkey' , ] ; $ data = array_diff_key ( $ data , array_flip ( $ excludeFields ) ) ; $ conditions = [ ] ; foreach ( $ data as $ field => $ value ) { $ conditions [ $ this -> alias . '.' . $ field ] = $ value ; } if ( empty ( $ conditions ) ) { return false ; } $ countTasks = $ this -> find ( 'count' , compact ( 'conditions' ) ) ; if ( ( $ countTasks == 0 ) || ! $ this -> deleteAll ( $ conditions ) ) { return false ; } return true ; } | Delete tasks by fields value |
24,780 | public function findConnection ( string $ name = null ) { if ( empty ( $ name ) ) { $ connection = \ reset ( $ this -> connections ) ; if ( $ connection === false ) return null ; } else { $ connection = ( $ this -> connections [ \ strtolower ( $ name ) ] ?? null ) ; } return $ connection ; } | Find a connection in the pool |
24,781 | public function addConnection ( PdoConnectionInterface $ connection ) { $ this -> connections [ \ strtolower ( $ connection -> getName ( ) ) ] = $ connection ; return $ connection ; } | Adds a Connection to the Pool |
24,782 | public static function register ( string $ guesser ) : void { if ( \ in_array ( MimeTypeGuesserContract :: class , \ class_implements ( $ guesser ) , true ) ) { \ array_unshift ( self :: $ guessers , $ guesser ) ; } throw new RuntimeException ( \ sprintf ( 'You guesser [%s] should implement the [\%s].' , $ guesser , MimeTypeGuesserContract :: class ) ) ; } | Registers a new mime type guesser . When guessing this guesser is preferred over previously registered ones . |
24,783 | public static function guess ( string $ guess ) : ? string { $ guessers = self :: getGuessers ( ) ; if ( \ count ( $ guessers ) === 0 ) { $ msg = 'Unable to guess the mime type as no guessers are available' ; if ( ! MimeTypeFileInfoGuesser :: isSupported ( ) ) { $ msg .= ' (Did you enable the php_fileinfo extension?).' ; } throw new \ LogicException ( $ msg ) ; } $ exception = null ; foreach ( $ guessers as $ guesser ) { try { $ mimeType = $ guesser :: guess ( $ guess ) ; } catch ( RuntimeException $ e ) { $ exception = $ e ; continue ; } if ( $ mimeType !== null ) { return $ mimeType ; } } if ( $ exception !== null ) { throw $ exception ; } return null ; } | Tries to guess the mime type . |
24,784 | private static function getGuessers ( ) : array { if ( ! self :: $ nativeGuessersLoaded ) { if ( MimeTypeFileExtensionGuesser :: isSupported ( ) ) { self :: $ guessers [ ] = MimeTypeFileExtensionGuesser :: class ; } if ( MimeTypeFileInfoGuesser :: isSupported ( ) ) { self :: $ guessers [ ] = MimeTypeFileInfoGuesser :: class ; } if ( MimeTypeFileBinaryGuesser :: isSupported ( ) ) { self :: $ guessers [ ] = MimeTypeFileBinaryGuesser :: class ; } self :: $ nativeGuessersLoaded = true ; } return self :: $ guessers ; } | Register all natively provided mime type guessers . |
24,785 | public static function get_block_template ( $ url ) { $ template = static :: get_template ( $ url ) ; $ template = str_replace ( '<a ' , '<span ' , $ template ) ; $ template = str_replace ( '</a>' , '</span>' , $ template ) ; $ template .= sprintf ( '<link rel="stylesheet" href="%1$s">' , esc_url_raw ( get_template_directory_uri ( ) . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/gutenberg-embed.min.css' ) ) ; $ template .= sprintf ( '<link rel="stylesheet" href="%1$s">' , esc_url_raw ( get_template_directory_uri ( ) . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/app.min.css' ) ) ; return static :: _strip_newlines ( apply_filters ( 'wp_oembed_blog_card_gutenberg_template' , $ template , $ url ) ) ; } | Render template for block editor |
24,786 | public static function get_pre_blog_card_template ( $ url ) { if ( ! $ url ) { return ; } if ( 0 === strpos ( $ url , home_url ( ) ) ) { $ target = '_self' ; } else { $ target = '_blank' ; } return static :: _strip_newlines ( sprintf ( '<div class="js-wp-oembed-blog-card"> <a class="js-wp-oembed-blog-card__link" href="%1$s" target="%2$s">%1$s</a> </div>' , esc_url ( $ url ) , esc_attr ( $ target ) ) ) ; } | Render pre blog card template |
24,787 | public static function combine ( $ part1 , $ part2 ) { if ( $ part1 && $ part2 ) { return sprintf ( "%s/%s" , rtrim ( $ part1 , '/' ) , ltrim ( $ part2 , '/' ) ) ; } throw new InvalidArgumentException ( "All parts must be filled" ) ; } | Combine path parts . |
24,788 | public static function getRoot ( $ rootForPath = null , $ rootHasDir = 'lib' ) { if ( ! $ rootForPath ) { $ includes = get_included_files ( ) ; $ rootForPath = $ includes [ 0 ] ; } $ rootForPath = rtrim ( $ rootForPath , DIRECTORY_SEPARATOR ) ; $ rootHasDir = ltrim ( $ rootHasDir , DIRECTORY_SEPARATOR ) ; while ( ! is_dir ( $ rootForPath . DIRECTORY_SEPARATOR . $ rootHasDir ) ) { $ rootForPath = dirname ( $ rootForPath ) ; if ( $ rootForPath == DIRECTORY_SEPARATOR ) { throw new Exception ( "Cannot determine root path." ) ; } } return $ rootForPath ; } | Get the project root path . |
24,789 | public static function purge ( $ path , $ fileFilterRegex = null , $ dirFilterRegex = null ) { Path :: validatePath ( $ path ) ; $ iterator = new RecursiveDirectoryIterator ( $ path , FilesystemIterator :: SKIP_DOTS ) ; $ iterator = new RecursiveIteratorIterator ( $ iterator , RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( ( array ) $ fileFilterRegex as $ regex ) { $ iterator = new FileRegexIterator ( $ iterator , $ regex ) ; } foreach ( ( array ) $ dirFilterRegex as $ regex ) { $ iterator = new DirectoryRegexIterator ( $ iterator , $ regex ) ; } foreach ( $ iterator as $ file ) { if ( $ file -> isDir ( ) ) { Path :: delete ( $ file -> getPathName ( ) ) ; continue ; } File :: delete ( $ file -> getPathname ( ) ) ; } } | Delete directory content . |
24,790 | public function getIp ( ) { $ keys = [ 'X_FORWARDED_FOR' , 'HTTP_X_FORWARDED_FOR' , 'CLIENT_IP' , 'REMOTE_ADDR' ] ; foreach ( $ keys as $ key ) { $ ip = $ this -> getServerParam ( $ key ) ; if ( ! $ ip ) { continue ; } $ ip = preg_replace ( '/,.*$/u' , '' , $ ip ) ; $ ip = trim ( $ ip ) ; return $ ip ; } return null ; } | Get request ip . |
24,791 | public function getRequestTargetWithParams ( $ params ) { $ target = $ this -> getFullPath ( ) ; if ( $ params ) { $ target .= '?' . http_build_query ( $ params ) ; } return $ target ; } | Get Request URI . |
24,792 | public function withHost ( $ host ) { $ uri = $ this -> getUri ( ) -> withHost ( $ host ) ; $ clone = $ this -> withUri ( $ uri ) ; return $ clone ; } | Returns an instance with the provided host . |
24,793 | protected static function getTempDir ( ) { $ name = tempnam ( sys_get_temp_dir ( ) , 'tmp' ) ; unlink ( $ name ) ; mkdir ( $ name , 0777 , true ) ; return $ name ; } | Returns a newly created temporary directory in the OS s temporary location . All the files and folders of the package are moved to this directory and packaged . |
24,794 | public function initRecords ( $ overrideExisting = true ) { if ( null !== $ this -> collRecords && ! $ overrideExisting ) { return ; } $ collectionClassName = RecordTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collRecords = new $ collectionClassName ; $ this -> collRecords -> setModel ( '\eXpansion\Bundle\LocalRecords\Model\Record' ) ; } | Initializes the collRecords collection . |
24,795 | public function getRecords ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collRecordsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRecords || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRecords ) { $ this -> initRecords ( ) ; } else { $ collRecords = RecordQuery :: create ( null , $ criteria ) -> filterByPlayer ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collRecordsPartial && count ( $ collRecords ) ) { $ this -> initRecords ( false ) ; foreach ( $ collRecords as $ obj ) { if ( false == $ this -> collRecords -> contains ( $ obj ) ) { $ this -> collRecords -> append ( $ obj ) ; } } $ this -> collRecordsPartial = true ; } return $ collRecords ; } if ( $ partial && $ this -> collRecords ) { foreach ( $ this -> collRecords as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collRecords [ ] = $ obj ; } } } $ this -> collRecords = $ collRecords ; $ this -> collRecordsPartial = false ; } } return $ this -> collRecords ; } | Gets an array of Record objects which contain a foreign key that references this object . |
24,796 | public function countRecords ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collRecordsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRecords || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRecords ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getRecords ( ) ) ; } $ query = RecordQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByPlayer ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collRecords ) ; } | Returns the number of related BaseRecord objects . |
24,797 | public function addRecord ( Record $ l ) { if ( $ this -> collRecords === null ) { $ this -> initRecords ( ) ; $ this -> collRecordsPartial = true ; } if ( ! $ this -> collRecords -> contains ( $ l ) ) { $ this -> doAddRecord ( $ l ) ; if ( $ this -> recordsScheduledForDeletion and $ this -> recordsScheduledForDeletion -> contains ( $ l ) ) { $ this -> recordsScheduledForDeletion -> remove ( $ this -> recordsScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; } | Method called to associate a Record object to this object through the Record foreign key attribute . |
24,798 | public function byIds ( array $ ids , $ databaseConnectionName = null ) { if ( empty ( $ databaseConnectionName ) ) { $ databaseConnectionName = $ this -> databaseConnectionName ; } return $ this -> Account -> setConnection ( $ databaseConnectionName ) -> whereIn ( 'id' , $ ids ) -> get ( ) ; } | Get an account by ID s |
24,799 | public function byOrganizationAndByKey ( $ organizationId , $ key ) { if ( empty ( $ databaseConnectionName ) ) { $ databaseConnectionName = $ this -> databaseConnectionName ; } return $ this -> Account -> setConnection ( $ databaseConnectionName ) -> where ( 'organization_id' , '=' , $ organizationId ) -> where ( 'key' , '=' , $ key ) -> get ( ) ; } | Retrieve accounts by organization and by key |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.