idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
22,300 | public function add ( $ name , Closure $ callback = null ) { try { $ path = $ this -> finder -> find ( $ name ) ; if ( isset ( $ this -> assets [ $ path ] ) ) { $ asset = $ this -> assets [ $ path ] ; } else { $ asset = $ this -> factory -> get ( 'asset' ) -> make ( $ path ) ; $ asset -> isRemote ( ) and $ asset -> raw ( ) ; } is_callable ( $ callback ) and call_user_func ( $ callback , $ asset ) ; return $ this -> assets [ $ path ] = $ asset ; } catch ( AssetNotFoundException $ e ) { $ this -> getLogger ( ) -> error ( sprintf ( 'Asset "%s" could not be found in "%s"' , $ name , $ this -> path ) ) ; return $ this -> factory -> get ( 'asset' ) -> make ( null ) ; } } | Find and add an asset to the directory . |
22,301 | public function javascript ( $ name , Closure $ callback = null ) { return $ this -> add ( $ name , function ( $ asset ) use ( $ callback ) { $ asset -> setGroup ( 'javascripts' ) ; is_callable ( $ callback ) and call_user_func ( $ callback , $ asset ) ; } ) ; } | Find and add a javascript asset to the directory . |
22,302 | public function directory ( $ path , Closure $ callback = null ) { try { $ path = $ this -> finder -> setWorkingDirectory ( $ path ) ; $ this -> directories [ $ path ] = new Directory ( $ this -> factory , $ this -> finder , $ path ) ; is_callable ( $ callback ) and call_user_func ( $ callback , $ this -> directories [ $ path ] ) ; $ this -> finder -> resetWorkingDirectory ( ) ; return $ this -> directories [ $ path ] ; } catch ( DirectoryNotFoundException $ e ) { $ this -> getLogger ( ) -> error ( sprintf ( 'Directory "%s" could not be found in "%s"' , $ path , $ this -> path ) ) ; return new Directory ( $ this -> factory , $ this -> finder , null ) ; } } | Change the working directory . |
22,303 | public function requireDirectory ( $ path = null ) { if ( ! is_null ( $ path ) ) { return $ this -> directory ( $ path ) -> requireDirectory ( ) ; } if ( $ iterator = $ this -> iterateDirectory ( $ this -> path ) ) { return $ this -> processRequire ( $ iterator ) ; } return $ this ; } | Require a directory . |
22,304 | public function requireTree ( $ path = null ) { if ( ! is_null ( $ path ) ) { return $ this -> directory ( $ path ) -> requireTree ( ) ; } if ( $ iterator = $ this -> recursivelyIterateDirectory ( $ this -> path ) ) { return $ this -> processRequire ( $ iterator ) ; } return $ this ; } | Require a directory tree . |
22,305 | protected function processRequire ( Iterator $ iterator ) { $ iterator = new SortingIterator ( $ iterator , 'strnatcasecmp' ) ; foreach ( $ iterator as $ file ) { if ( ! $ file -> isFile ( ) ) continue ; $ this -> add ( $ file -> getPathname ( ) ) ; } return $ this ; } | Process a require of either the directory or tree . |
22,306 | public function except ( $ assets ) { $ assets = array_flatten ( func_get_args ( ) ) ; $ directory = $ this ; $ this -> assets = $ this -> assets -> filter ( function ( $ asset ) use ( $ assets , $ directory ) { $ path = $ directory -> getPathRelativeToDirectory ( $ asset -> getRelativePath ( ) ) ; return ! in_array ( $ path , $ assets ) ; } ) ; return $ this ; } | Exclude an array of assets . |
22,307 | public function getPathRelativeToDirectory ( $ path ) { $ directoryLastSegment = substr ( $ this -> path , strrpos ( $ this -> path , '/' ) + 1 ) ; return trim ( preg_replace ( '/^' . $ directoryLastSegment . '/' , '' , $ path ) , '/' ) ; } | Get a path relative from the current directory s path . |
22,308 | public function rawOnEnvironment ( $ environment ) { $ this -> assets -> each ( function ( $ asset ) use ( $ environment ) { $ asset -> rawOnEnvironment ( $ environment ) ; } ) ; return $ this ; } | All assets within directory will be served raw on a given environment . |
22,309 | public function getAssets ( ) { $ assets = $ this -> assets ; $ this -> directories -> each ( function ( $ directory ) use ( & $ assets ) { $ assets = $ directory -> getAssets ( ) -> merge ( $ assets ) ; } ) ; $ this -> filters -> each ( function ( $ filter ) use ( & $ assets ) { $ assets -> each ( function ( $ asset ) use ( $ filter ) { $ asset -> apply ( $ filter ) ; } ) ; } ) ; return $ assets ; } | Get all the assets . |
22,310 | public function setType ( $ type ) { if ( ! in_array ( $ type , self :: $ supported ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid LinearGradient Gradient Type ""' , ( string ) $ type ) ) ; } $ this -> type = $ type ; } | Set LinearGradient type |
22,311 | public function getFullDatasPage ( $ id , $ type = '' ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ select -> join ( 'melis_cms_page_lang' , 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id' , array ( 'plang_lang_id' ) ) ; $ select -> join ( 'melis_cms_lang' , 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_page_style' , 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id' , array ( ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_style' , ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; if ( $ type == 'published' || $ type == '' ) $ select -> join ( 'melis_cms_page_published' , 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; if ( $ type == 'saved' ) $ select -> join ( 'melis_cms_page_saved' , 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; if ( $ type == '' ) { $ columns = $ this -> aliasColumnsFromTableDefinition ( 'MelisEngine\MelisPageColumns' , 's_' ) ; $ select -> join ( 'melis_cms_page_saved' , 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id' , $ columns , $ select :: JOIN_LEFT ) ; } $ select -> join ( 'melis_cms_page_seo' , 'melis_cms_page_seo.pseo_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> where ( 'tree_page_id = ' . $ id ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Gets full datas for a page from tree page saved paged published lang |
22,312 | public function getPageChildrenByidPage ( $ id , $ publishedOnly = 0 ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ select -> join ( 'melis_cms_page_lang' , 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id' , array ( 'plang_lang_id' ) ) ; $ select -> join ( 'melis_cms_lang' , 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_page_published' , 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_page_style' , 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id' , array ( ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_style' , ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; if ( $ publishedOnly == 1 ) $ select -> where ( 'melis_cms_page_published.page_status=1' ) ; if ( $ publishedOnly == 0 ) { $ columns = $ this -> aliasColumnsFromTableDefinition ( 'MelisEngine\MelisPageColumns' , 's_' ) ; $ select -> join ( 'melis_cms_page_saved' , 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id' , $ columns , $ select :: JOIN_LEFT ) ; } $ select -> join ( 'melis_cms_page_seo' , 'melis_cms_page_seo.pseo_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_page_default_urls' , 'melis_cms_page_default_urls.purl_page_id = melis_cms_page_tree.tree_page_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ select -> where ( 'tree_father_page_id = ' . $ id ) ; $ select -> order ( 'tree_page_order ASC' ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Gets the children of a page |
22,313 | public function getPagesBySearchValue ( $ value , $ type = '' ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( 'tree_page_id' ) ) ; if ( $ type == 'published' || $ type == '' ) { $ select -> join ( 'melis_cms_page_published' , 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id' , array ( ) , $ select :: JOIN_LEFT ) ; } if ( $ type == 'saved' ) { $ select -> join ( 'melis_cms_page_saved' , 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id' , array ( ) , $ select :: JOIN_LEFT ) ; } $ select -> join ( 'melis_cms_page_style' , 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id' , array ( ) , $ select :: JOIN_LEFT ) ; $ select -> join ( 'melis_cms_style' , ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; $ search = '%' . $ value . '%' ; $ select -> where -> NEST -> like ( 'page_name' , $ search ) -> or -> like ( 'melis_cms_page_tree.tree_page_id' , $ search ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | This function searches for page name or page id |
22,314 | public function getSortedTemplates ( ) { $ select = new Select ( 'melis_cms_template' ) ; $ select -> order ( 'tpl_zf2_website_folder ASC' ) ; $ select -> order ( 'tpl_name ASC' ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Retrieves the data from the Template table in alphabetical order |
22,315 | public function getOverlayCanvas ( $ file ) { $ canvas = new Canvas ( ) ; $ canvas -> fromFile ( Util :: getResourcePath ( 'Preset/' . $ file ) ) ; return $ canvas ; } | Get overlay canvas |
22,316 | public function & SetDisabledHeaders ( $ disabledHeaders ) { $ this -> disabledHeaders = [ ] ; $ args = func_get_args ( ) ; if ( count ( $ args ) === 1 && is_array ( $ args [ 0 ] ) ) $ args = $ args [ 0 ] ; foreach ( $ args as $ arg ) $ this -> disabledHeaders [ $ arg ] = TRUE ; return $ this ; } | Set disabled headers never sent except if there is rendered exception in development environment . |
22,317 | private function registerCommands ( ) { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> commands ( [ \ Brotzka \ TranslationManager \ Module \ Console \ Commands \ TranslationToDatabase :: class , \ Brotzka \ TranslationManager \ Module \ Console \ Commands \ TranslationToFile :: class ] ) ; } } | Registering artisan commands |
22,318 | public function Dump ( ) { $ environment = static :: GetEnvironment ( TRUE ) ; list ( $ sections , $ envSpecifics ) = $ this -> dumpSectionsInfo ( ) ; $ levelKey = '' ; $ basicData = [ ] ; $ sectionsData = [ ] ; foreach ( $ this -> data as $ key => & $ value ) { if ( is_object ( $ value ) || is_array ( $ value ) ) { if ( $ sectionsData ) $ sectionsData [ ] = '' ; $ sectionType = isset ( $ sections [ $ key ] ) ? $ sections [ $ key ] : 0 ; $ environmentSpecificSection = $ sectionType === 3 ; if ( $ sectionType ) { unset ( $ sections [ $ key ] ) ; $ sectionsData [ ] = ( $ environmentSpecificSection ? '[' . $ environment . ' > ' . $ key . ']' : '[' . $ key . ']' ) ; $ levelKey = '' ; } else { $ levelKey = ( string ) $ key ; } $ this -> dumpRecursive ( $ levelKey , $ value , $ sectionsData ) ; if ( $ environmentSpecificSection && isset ( $ envSpecifics [ $ key ] ) ) { foreach ( $ envSpecifics [ $ key ] as $ envName => $ sectionLines ) { if ( $ envName === $ environment ) continue ; $ sectionsData [ ] = '' ; foreach ( $ sectionLines as $ sectionLine ) $ sectionsData [ ] = $ sectionLine ; } } } else { $ basicData [ ] = $ key . ' = ' . $ this -> dumpScalarValue ( $ value ) ; } } $ result = '' ; if ( $ basicData ) $ result = implode ( PHP_EOL , $ basicData ) ; if ( $ sectionsData ) $ result .= PHP_EOL . PHP_EOL . implode ( PHP_EOL , $ sectionsData ) ; return $ result ; } | Dump configuration data in INI syntax with originally loaded sections and environment dependency support . This method try to load original INI file if exists and creates INI sections by original file . Or all data are rendered in plain structure without any section . If there is in original config file any section for different environment this method dumps that section content immediately after current environment section so all data for different environment stays there . |
22,319 | protected function dumpScalarValue ( $ value ) { if ( is_numeric ( $ value ) ) { return ( string ) $ value ; } else if ( is_bool ( $ value ) ) { return $ value ? 'true' : 'false' ; } else if ( $ value === NULL ) { return 'null' ; } else { static $ specialChars = [ '=' , '/' , '.' , '#' , '&' , '!' , '?' , '-' , '@' , "'" , '"' , '*' , '^' , '[' , ']' , '(' , ')' , '{' , '}' , '<' , '>' , '\n' , '\r' , ] ; $ valueStr = ( string ) $ value ; $ specialCharCaught = FALSE ; foreach ( $ specialChars as $ specialChar ) { if ( mb_strpos ( $ valueStr , $ specialChar ) ) { $ specialCharCaught = TRUE ; break ; } } if ( $ specialCharCaught ) { return '"' . addcslashes ( $ valueStr , '"' ) . '"' ; } else { return $ valueStr ; } } } | Dump any PHP scalar value into INI syntax by special local static configuration array . |
22,320 | public function initDefaultProperties ( ) { if ( isset ( $ this -> schema ) && $ this -> setPropertyDefaultValue ( $ this -> schema ) ) { $ this -> property_value = $ this -> schema -> default ; } } | Instantiate the property default value . |
22,321 | protected function gatherCollections ( ) { if ( ! is_null ( $ collection = $ this -> input -> getArgument ( 'collection' ) ) ) { if ( ! $ this -> environment -> has ( $ collection ) ) { $ this -> comment ( '[' . $ collection . '] Collection not found.' ) ; return array ( ) ; } $ this -> comment ( 'Gathering assets for collection...' ) ; $ collections = array ( $ collection => $ this -> environment -> collection ( $ collection ) ) ; } else { $ this -> comment ( 'Gathering all collections to build...' ) ; $ collections = $ this -> environment -> all ( ) ; } $ this -> line ( '' ) ; return $ collections ; } | Gather the collections to be built . |
22,322 | public function make ( $ path ) { $ absolutePath = $ this -> buildAbsolutePath ( $ path ) ; $ relativePath = $ this -> buildRelativePath ( $ absolutePath ) ; $ asset = new Asset ( $ this -> files , $ this -> factory , $ this -> appEnvironment , $ absolutePath , $ relativePath ) ; return $ asset -> setOrder ( $ this -> nextAssetOrder ( ) ) ; } | Make a new asset instance . |
22,323 | public function buildRelativePath ( $ path ) { if ( is_null ( $ path ) ) return $ path ; $ relativePath = str_replace ( array ( realpath ( $ this -> publicPath ) , '\\' ) , array ( '' , '/' ) , $ path ) ; if ( ! starts_with ( $ path , '//' ) and ! ( bool ) filter_var ( $ path , FILTER_VALIDATE_URL ) ) { $ relativePath = trim ( $ relativePath , '/' ) ; if ( trim ( str_replace ( '\\' , '/' , $ path ) , '/' ) == trim ( $ relativePath , '/' ) ) { $ path = pathinfo ( $ path ) ; $ relativePath = md5 ( $ path [ 'dirname' ] ) . '/' . $ path [ 'basename' ] ; } } return $ relativePath ; } | Build the relative path to an asset . |
22,324 | public static function & GetConfig ( $ appRootRelativePath ) { if ( ! isset ( self :: $ configsCache [ $ appRootRelativePath ] ) ) { $ app = self :: $ app ? : self :: $ app = & \ MvcCore \ Application :: GetInstance ( ) ; $ systemConfigClass = $ app -> GetConfigClass ( ) ; $ system = $ systemConfigClass :: GetSystemConfigPath ( ) === '/' . ltrim ( $ appRootRelativePath , '/' ) ; self :: $ configsCache [ $ appRootRelativePath ] = & self :: getConfigInstance ( $ appRootRelativePath , $ system ) ; } return self :: $ configsCache [ $ appRootRelativePath ] ; } | Get cached config INI file as stdClass es and array s placed relatively from application document root . |
22,325 | protected static function & getConfigInstance ( $ appRootRelativePath , $ systemConfig = FALSE ) { $ app = self :: $ app ? : self :: $ app = & \ MvcCore \ Application :: GetInstance ( ) ; $ appRoot = self :: $ appRoot ? : self :: $ appRoot = $ app -> GetRequest ( ) -> GetAppRoot ( ) ; $ fullPath = $ appRoot . '/' . str_replace ( '%appPath%' , $ app -> GetAppDir ( ) , ltrim ( $ appRootRelativePath , '/' ) ) ; if ( ! file_exists ( $ fullPath ) ) { $ result = FALSE ; } else { $ systemConfigClass = $ app -> GetConfigClass ( ) ; $ result = $ systemConfigClass :: CreateInstance ( ) ; if ( ! $ result -> Read ( $ fullPath , $ systemConfig ) ) $ result = FALSE ; } return $ result ; } | Try to load and parse config file by app root relative path . If config contains system data try to detect environment . |
22,326 | public function normalizeParams ( RequestHandler $ handler , $ params ) { if ( is_string ( $ params ) ) { $ params = array ( 'q' => $ params ) ; } elseif ( ! is_array ( $ params ) ) { $ params = ( array ) $ params ; } return array_merge ( $ handler -> getDefaultParams ( ) , $ params ) ; } | Normalizes and merges default params . |
22,327 | public static function CheckClassInterface ( $ testClassName , $ interfaceName , $ checkStaticMethods = FALSE , $ throwException = TRUE ) { $ result = FALSE ; $ errorMsg = '' ; $ interfaceName = trim ( $ interfaceName , '\\' ) ; $ testClassType = new \ ReflectionClass ( $ testClassName ) ; if ( in_array ( $ interfaceName , $ testClassType -> getInterfaceNames ( ) , TRUE ) ) { $ result = TRUE ; } else { $ errorMsg = "Class `$testClassName` doesn't implement interface `$interfaceName`." ; } if ( $ result && $ checkStaticMethods ) { $ allStaticsImplemented = TRUE ; $ interfaceMethods = static :: checkClassInterfaceGetPublicStaticMethods ( $ interfaceName ) ; foreach ( $ interfaceMethods as $ methodName ) { if ( ! $ testClassType -> hasMethod ( $ methodName ) ) { $ allStaticsImplemented = FALSE ; $ errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`." ; break ; } $ testClassStaticMethod = $ testClassType -> getMethod ( $ methodName ) ; if ( ! $ testClassStaticMethod -> isStatic ( ) ) { $ allStaticsImplemented = FALSE ; $ errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`, method is not static." ; break ; } } if ( ! $ allStaticsImplemented ) $ result = FALSE ; } if ( $ result ) return TRUE ; if ( ! $ throwException ) return FALSE ; $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ InvalidArgumentException ( "[" . $ selfClass . "] " . $ errorMsg ) ; } | Check if given class implements given interface else throw an exception . |
22,328 | public static function CheckClassTrait ( $ testClassName , $ traitName , $ checkParentClasses = FALSE , $ throwException = TRUE ) { $ result = FALSE ; $ errorMsg = '' ; $ testClassType = new \ ReflectionClass ( $ testClassName ) ; if ( in_array ( $ traitName , $ testClassType -> getTraitNames ( ) , TRUE ) ) { $ result = TRUE ; } else if ( $ checkParentClasses ) { $ currentClassType = $ testClassType ; while ( TRUE ) { $ parentClass = $ currentClassType -> getParentClass ( ) ; if ( $ parentClass === FALSE ) break ; $ parentClassType = new \ ReflectionClass ( $ parentClass -> getName ( ) ) ; if ( in_array ( $ traitName , $ parentClassType -> getTraitNames ( ) , TRUE ) ) { $ result = TRUE ; break ; } else { $ currentClassType = $ parentClassType ; } } } if ( ! $ result ) $ errorMsg = "Class `$testClassName` doesn't implement trait `$traitName`." ; if ( $ result ) return TRUE ; if ( ! $ throwException ) return FALSE ; $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ InvalidArgumentException ( "[" . $ selfClass . "] " . $ errorMsg ) ; } | Check if given class implements given trait else throw an exception . |
22,329 | protected static function & checkClassInterfaceGetPublicStaticMethods ( $ interfaceName ) { if ( ! isset ( static :: $ interfacesStaticMethodsCache [ $ interfaceName ] ) ) { $ methods = [ ] ; $ interfaceType = new \ ReflectionClass ( $ interfaceName ) ; $ publicOrStaticMethods = $ interfaceType -> getMethods ( \ ReflectionMethod :: IS_PUBLIC | \ ReflectionMethod :: IS_STATIC ) ; foreach ( $ publicOrStaticMethods as $ publicOrStaticMethod ) { if ( $ publicOrStaticMethod -> isStatic ( ) && $ publicOrStaticMethod -> isPublic ( ) ) { $ methods [ ] = $ publicOrStaticMethod -> getName ( ) ; } } static :: $ interfacesStaticMethodsCache [ $ interfaceName ] = $ methods ; } return static :: $ interfacesStaticMethodsCache [ $ interfaceName ] ; } | Complete array with only static and also only public method names by given interface name . Return completed array and cache it in static local array . |
22,330 | protected function generateHtmlString ( ... $ attributesList ) : HtmlString { $ attributesArray = $ this -> buildAttributesArray ( ... $ attributesList ) ; $ html = $ this -> buildHtmlString ( $ attributesArray ) ; return new HtmlString ( $ html ) ; } | Render html attributes from the given attributes list . |
22,331 | protected function buildHtmlString ( array $ attributesArray ) : string { $ html = '' ; foreach ( $ attributesArray as $ key => $ attribute ) { $ spacer = strlen ( $ html ) ? ' ' : '' ; if ( $ key && is_string ( $ key ) ) { $ html .= $ spacer . $ key . ( $ attribute ? '="' . $ attribute . '"' : '' ) ; } else { $ html .= $ spacer . $ attribute ; } } return $ html ; } | Build the html string from the attributes array . |
22,332 | public function withStatusCode ( int $ code ) { if ( $ this -> statusCode == $ code ) { return $ this ; } $ that = clone ( $ this ) ; $ that -> statusCode = $ code ; return $ that ; } | Returns a copy of the page with the status code set . |
22,333 | public function setLineSpacing ( $ spacing ) { if ( $ spacing < 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Line Spacing "%s" - Spacing Must Be Greater Than Zero' , ( string ) $ spacing ) ) ; } $ this -> spacing = ( float ) $ spacing ; return $ this ; } | Set the line spacing |
22,334 | public function getBoundingBox ( $ padding = 10 ) { $ bare = imageftbbox ( $ this -> getFontSize ( ) , 0 , $ this -> getFont ( ) , $ this -> getString ( ) , array ( 'linespacing' => $ this -> getLineSpacing ( ) ) ) ; $ a = deg2rad ( $ this -> getAngle ( ) ) ; $ ca = cos ( $ a ) ; $ sa = sin ( $ a ) ; $ rect = array ( ) ; for ( $ i = 0 ; $ i < 7 ; $ i += 2 ) { $ rect [ $ i ] = round ( $ bare [ $ i ] * $ ca + $ bare [ $ i + 1 ] * $ sa ) ; $ rect [ $ i + 1 ] = round ( $ bare [ $ i + 1 ] * $ ca - $ bare [ $ i ] * $ sa ) ; } $ minX = min ( array ( $ rect [ 0 ] , $ rect [ 2 ] , $ rect [ 4 ] , $ rect [ 6 ] ) ) ; $ maxX = max ( array ( $ rect [ 0 ] , $ rect [ 2 ] , $ rect [ 4 ] , $ rect [ 6 ] ) ) ; $ minY = min ( array ( $ rect [ 1 ] , $ rect [ 3 ] , $ rect [ 5 ] , $ rect [ 7 ] ) ) ; $ maxY = max ( array ( $ rect [ 1 ] , $ rect [ 3 ] , $ rect [ 5 ] , $ rect [ 7 ] ) ) ; $ dx = $ this -> getCoordinate ( ) -> getX ( ) - abs ( $ minX ) - 1 ; $ dy = $ this -> getCoordinate ( ) -> getY ( ) - abs ( $ minY ) - 1 + $ this -> getFontSize ( ) ; $ width = $ maxX - $ minX ; $ height = $ maxY - $ minY ; $ padding = ( int ) $ padding ; $ dimension = new Dimension ( $ width + 2 + ( $ padding * 2 ) , $ height + 2 + ( $ padding * 2 ) ) ; $ coordinate = new Coordinate ( $ dx - $ padding , $ dy - $ padding ) ; return new Box ( $ dimension , $ coordinate ) ; } | Get bouding box for the current text object |
22,335 | protected function createAuthentication ( ContainerBuilder $ container , $ authentication , $ type ) { if ( $ authentication [ 'type' ] == 'basic' && ( ! isset ( $ authentication [ 'username' ] ) || ! isset ( $ authentication [ 'password' ] ) ) ) { throw new \ LogicException ( 'Username and password are mandatory if using the basic authentication' ) ; } if ( $ authentication [ 'type' ] == 'basic' ) { $ authenticationDefinition = new Definition ( 'Bluetea\Api\Authentication\BasicAuthentication' , array ( 'username' => $ authentication [ 'username' ] , 'password' => $ authentication [ 'password' ] ) ) ; } elseif ( $ authentication [ 'type' ] == 'anonymous' ) { $ authenticationDefinition = new Definition ( 'Bluetea\Api\Authentication\AnonymousAuthentication' ) ; } else { throw new InvalidConfigurationException ( 'Invalid authentication' ) ; } $ container -> setDefinition ( sprintf ( 'jira_rest_api.%s_authentication' , $ type ) , $ authenticationDefinition ) ; } | Create authentication services |
22,336 | protected function createApiClient ( ContainerBuilder $ container , $ apiClient , $ baseUrl , $ type ) { if ( $ apiClient == 'guzzle' ) { $ apiClientDefinition = new Definition ( 'Bluetea\Api\Client\GuzzleClient' , array ( $ baseUrl , new Reference ( sprintf ( 'jira_rest_api.%s_authentication' , $ type ) ) ) ) ; $ apiClientDefinition -> addMethodCall ( 'setContentType' , array ( 'application/json' ) ) ; $ apiClientDefinition -> addMethodCall ( 'setAccept' , array ( 'application/json' ) ) ; } else { throw new \ LogicException ( 'Invalid api client' ) ; } $ container -> setDefinition ( sprintf ( 'jira_rest_api.%s_api_client' , $ type ) , $ apiClientDefinition ) ; } | Create API client |
22,337 | protected function initializeEndpoints ( ContainerBuilder $ container , $ availableApi ) { if ( isset ( $ availableApi [ 'jira' ] ) ) { $ taggedEndpoints = $ container -> findTaggedServiceIds ( 'jira_rest_api.jira_endpoint' ) ; foreach ( $ taggedEndpoints as $ serviceId => $ attributes ) { $ endpoint = $ container -> getDefinition ( $ serviceId ) ; $ endpoint -> setArguments ( array ( new Reference ( 'jira_rest_api.jira_api_client' ) ) ) ; } } if ( isset ( $ availableApi [ 'crowd' ] ) ) { $ taggedEndpoints = $ container -> findTaggedServiceIds ( 'jira_rest_api.crowd_endpoint' ) ; foreach ( $ taggedEndpoints as $ serviceId => $ attributes ) { $ endpoint = $ container -> getDefinition ( $ serviceId ) ; $ endpoint -> setArguments ( array ( new Reference ( 'jira_rest_api.crowd_api_client' ) ) ) ; } } } | Initialize API endpoints |
22,338 | protected function log ( $ operation , $ id = null , $ ttl = null , $ hit = null ) { $ message = strtoupper ( $ operation ) ; if ( $ id !== null ) { $ id = implode ( ', ' , ( array ) $ id ) ; if ( $ ttl !== null ) { $ message = sprintf ( '%s(%s, ttl=%s)' , $ message , $ id , $ ttl ) ; } else { $ message = sprintf ( '%s(%s)' , $ message , $ id ) ; } } if ( $ hit !== null ) { $ message .= ' = ' . ( $ hit ? 'HIT' : 'MISS' ) ; } $ this -> logger -> addRecord ( $ this -> logLevel , $ message ) ; } | Logs an operation |
22,339 | private static function debug_print ( $ file , $ level , $ format , $ data ) { array_shift ( $ data ) ; foreach ( $ data as $ k => $ v ) { if ( is_string ( $ v ) ) { $ data [ $ k ] = str_replace ( "\n" , ' ' , $ v ) ; } elseif ( $ v instanceof \ Exception ) { $ data [ $ k ] = $ v -> __toString ( ) ; } elseif ( ! is_numeric ( $ v ) ) { $ data [ $ k ] = str_replace ( "\n" , " " , json_encode ( $ v ) ) ; } } $ mtime = microtime ( true ) ; $ time = 1000 * ( $ mtime - intval ( $ mtime ) ) ; $ trace = debug_backtrace ( ) ; $ location = $ trace [ 2 ] [ 'function' ] ; for ( $ n = 2 ; $ n < sizeof ( $ trace ) ; $ n ++ ) { if ( isset ( $ trace [ $ n ] [ 'class' ] ) ) { $ location = $ trace [ $ n ] [ 'class' ] ; break ; } } $ id = isset ( $ _SERVER [ 'REMOTE_PORT' ] ) ? $ _SERVER [ 'REMOTE_PORT' ] : getmypid ( ) ; $ msg = sizeof ( $ data ) ? vsprintf ( $ format , $ data ) : $ format ; error_log ( sprintf ( "[%s.%03d %s %s %s] %s\n" , date ( 'd.m.Y H:m:s' ) , $ time , $ id , $ level , $ location , $ msg ) , 3 , $ file ) ; } | date time id path level msg |
22,340 | public static function getListQuery ( ? array $ condition = [ ] , $ key = null , $ value = null , $ indexBy = true , $ orderBy = true , $ alias = null ) { if ( ! $ alias && is_subclass_of ( get_called_class ( ) , ActiveRecord :: class ) ) { $ table = Yii :: $ app -> db -> schema -> getRawTableName ( ( get_called_class ( ) ) :: tableName ( ) ) ; } else if ( $ alias ) { $ table = $ alias ; } else { $ table = '' ; } ! $ table ? : $ table .= '.' ; $ key = $ key ?? static :: primaryKey ( ) [ 0 ] ; $ value = $ value ?? $ key ; $ query = static :: find ( ) -> select ( [ $ table . $ value , $ table . $ key , ] ) -> andFilterWhere ( $ condition ?? [ ] ) ; if ( $ orderBy === true ) { $ query -> orderBy ( $ table . $ value ) ; } else if ( $ orderBy !== false ) { $ query -> orderBy ( $ table . $ orderBy ) ; } if ( $ indexBy === true ) { $ query -> indexBy ( $ key ) ; } else if ( $ indexBy !== false ) { $ query -> indexBy ( $ indexBy ) ; } return $ query ; } | Return records as Array id = > column for dropdowns |
22,341 | public function getRawAttributes ( ? array $ only = null , ? array $ except = [ ] , ? bool $ schemaOnly = false ) { $ values = [ ] ; if ( $ only === null ) { $ only = $ this -> attributes ( $ only , $ except , $ schemaOnly ) ; } foreach ( $ only as $ name ) { $ values [ $ name ] = $ this -> getAttribute ( $ name ) ; } if ( $ except ) { $ values = array_diff_key ( $ values , array_flip ( $ except ) ) ; } return $ values ; } | Returns attribute values . |
22,342 | public function start ( $ browserName ) { if ( ! $ this -> customSidProvided ) { $ this -> sid = uniqid ( ) ; $ this -> executeCommand ( 'launchPreconfiguredBrowser' , array ( 'browserType' => $ browserName ) ) ; } } | Starts browser . |
22,343 | public function executeCommand ( $ command , array $ parameters = array ( ) ) { $ content = $ this -> post ( sprintf ( 'http://%s:%d/_s_/dyn/Driver_%s' , $ this -> host , $ this -> port , $ command ) , array_merge ( $ parameters , array ( 'sahisid' => $ this -> sid ) ) ) -> getContent ( ) ; if ( false !== strpos ( $ content , 'SAHI_ERROR' ) ) { throw new Exception \ ConnectionException ( 'Sahi proxy error. Full response:' . PHP_EOL . $ content ) ; } return $ content ; } | Execute Sahi command & returns its response . |
22,344 | public function executeStep ( $ step , $ limit = null ) { $ this -> executeCommand ( 'setStep' , array ( 'step' => $ step ) ) ; $ limit = $ limit ? : $ this -> limit ; $ check = 'false' ; while ( 'true' !== $ check ) { usleep ( 100000 ) ; if ( -- $ limit <= 0 ) { throw new Exception \ ConnectionException ( 'Command execution time limit reached: `' . $ step . '`' ) ; } $ check = $ this -> executeCommand ( 'doneStep' ) ; if ( 0 === mb_strpos ( $ check , 'error:' ) ) { throw new Exception \ ConnectionException ( $ check ) ; } } } | Execute Sahi step . |
22,345 | public function evaluateJavascript ( $ expression , $ limit = null ) { $ key = ' lastValue ' . uniqid ( ) ; $ this -> executeStep ( sprintf ( "_sahi.setServerVarPlain(%s, JSON.stringify(%s))" , json_encode ( $ key ) , $ expression ) , $ limit ) ; $ resp = $ this -> executeCommand ( 'getVariable' , array ( 'key' => $ key ) ) ; return json_decode ( $ resp , true ) ; } | Evaluates JS expression on the browser and returns it s value . |
22,346 | private function post ( $ url , array $ query = array ( ) ) { return $ this -> browser -> post ( $ url , array ( ) , $ this -> prepareQueryString ( $ query ) ) ; } | Send POST request to specified URL . |
22,347 | private function prepareQueryString ( array $ query ) { $ items = array ( ) ; foreach ( $ query as $ key => $ val ) { $ items [ ] = $ key . '=' . urlencode ( $ val ) ; } return implode ( '&' , $ items ) ; } | Convert array parameters to POST parameters . |
22,348 | public function getPlugin ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new PluginNotFoundException ( $ name , array_keys ( $ this -> plugins ) ) ; } return $ this -> plugins [ $ name ] ; } | Returns plugin by name . |
22,349 | public function getIndex ( $ indexName ) { if ( array_key_exists ( $ indexName , $ this -> indices ) ) { return $ this -> indices [ $ indexName ] ; } return null ; } | Get the specified lucene search - index |
22,350 | public function getChildrenRecursive ( $ idPage ) { $ results = array ( ) ; $ melisTree = $ this -> serviceLocator -> get ( 'MelisEngineTree' ) ; $ publishedOnly = 1 ; $ pages = $ melisTree -> getPageChildren ( $ idPage , $ publishedOnly ) ; if ( $ pages ) { $ rpages = $ pages -> toArray ( ) ; foreach ( $ rpages as $ page ) { $ tmp = $ this -> formatPageInArray ( $ page ) ; $ children = $ this -> getChildrenRecursive ( $ page [ 'tree_page_id' ] ) ; if ( ! empty ( $ children ) ) $ tmp [ 'pages' ] = $ children ; $ results [ ] = $ tmp ; } } return $ results ; } | Get subpages recursively |
22,351 | public function getAllSubpages ( $ pageId ) { $ results = array ( ) ; $ melisTree = $ this -> serviceLocator -> get ( 'MelisEngineTree' ) ; $ pagePub = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePagePublished' ) ; $ pageSave = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePageSaved' ) ; $ pageSearchType = null ; $ pages = $ melisTree -> getPageChildren ( $ pageId , 2 ) ; if ( $ pages ) { $ rpages = $ pages -> toArray ( ) ; foreach ( $ rpages as $ page ) { $ pageStat = $ page [ 'page_status' ] ?? null ; if ( $ pageStat ) { $ pageData = $ pagePub -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; $ pageSearchType = $ pageData -> page_search_type ?? null ; } else { $ pageData = $ pageSave -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; if ( ! $ pageData ) { $ pageData = $ pagePub -> getEntryById ( $ page [ 'tree_page_id' ] ) -> current ( ) ; } $ pageSearchType = $ pageData -> page_search_type ?? null ; } $ tmp = $ this -> formatPageInArray ( $ page , $ pageSearchType ) ; $ children = $ this -> getAllSubpages ( $ page [ 'tree_page_id' ] ?? null ) ; if ( ! empty ( $ children ) ) $ tmp [ 'pages' ] = $ children ; $ results [ ] = $ tmp ; } } return $ results ; } | Get all Subpages including published and unplublished |
22,352 | public function getCropEndpoint ( $ endpoint , $ parameters = array ( ) , $ absolute = UrlGeneratorInterface :: ABSOLUTE_PATH ) { $ parameters = array_merge ( $ parameters , array ( 'endpoint' => $ endpoint ) ) ; return $ this -> router -> generate ( $ this -> routeName , $ parameters , $ absolute ) ; } | Get crop endpoint url |
22,353 | public function setDigits ( $ digits ) { $ digits = abs ( intval ( $ digits ) ) ; if ( $ digits < 1 || $ digits > 10 ) { throw new \ InvalidArgumentException ( 'Digits must be a number between 1 and 10 inclusive' ) ; } $ this -> digits = $ digits ; return $ this ; } | Set the number of digits in the one - time password |
22,354 | public function setHashFunction ( $ hashFunction ) { $ hashFunction = strtolower ( $ hashFunction ) ; if ( ! in_array ( $ hashFunction , hash_algos ( ) ) ) { throw new \ InvalidArgumentException ( "$hashFunction is not a supported hash function" ) ; } $ this -> hashFunction = $ hashFunction ; return $ this ; } | Set the hash function |
22,355 | public function setWindow ( $ window ) { $ window = abs ( intval ( $ window ) ) ; $ this -> window = $ window ; return $ this ; } | Set the window value |
22,356 | public function getFieldType ( $ fieldName ) { if ( ! array_key_exists ( $ fieldName , $ this -> _fields ) ) { throw new \ Exception ( "Field name \"$fieldName\" not found in document." ) ; } return $ this -> _fields [ $ fieldName ] -> getType ( ) ; } | Returns type for a named field in this document . |
22,357 | public function message ( $ type , $ destination , $ messagearray , $ priority = SMARTIRC_MEDIUM ) { if ( ! is_array ( $ messagearray ) ) { $ messagearray = array ( $ messagearray ) ; } switch ( $ type ) { case SMARTIRC_TYPE_CHANNEL : case SMARTIRC_TYPE_QUERY : foreach ( $ messagearray as $ message ) { $ this -> send ( 'PRIVMSG ' . $ destination . ' :' . $ message , $ priority ) ; } break ; case SMARTIRC_TYPE_ACTION : foreach ( $ messagearray as $ message ) { $ this -> send ( 'PRIVMSG ' . $ destination . ' :' . chr ( 1 ) . 'ACTION ' . $ message . chr ( 1 ) , $ priority ) ; } break ; case SMARTIRC_TYPE_NOTICE : foreach ( $ messagearray as $ message ) { $ this -> send ( 'NOTICE ' . $ destination . ' :' . $ message , $ priority ) ; } break ; case SMARTIRC_TYPE_CTCP : case SMARTIRC_TYPE_CTCP_REPLY : foreach ( $ messagearray as $ message ) { $ this -> send ( 'NOTICE ' . $ destination . ' :' . chr ( 1 ) . $ message . chr ( 1 ) , $ priority ) ; } break ; case SMARTIRC_TYPE_CTCP_REQUEST : foreach ( $ messagearray as $ message ) { $ this -> send ( 'PRIVMSG ' . $ destination . ' :' . chr ( 1 ) . $ message . chr ( 1 ) , $ priority ) ; } break ; default : return false ; } return $ this ; } | sends a new message |
22,358 | public function join ( $ channelarray , $ key = null , $ priority = SMARTIRC_MEDIUM ) { if ( ! is_array ( $ channelarray ) ) { $ channelarray = array ( $ channelarray ) ; } $ channellist = implode ( ',' , $ channelarray ) ; if ( $ key !== null ) { foreach ( $ channelarray as $ idx => $ value ) { $ this -> send ( 'JOIN ' . $ value . ' ' . $ key , $ priority ) ; } } else { foreach ( $ channelarray as $ idx => $ value ) { $ this -> send ( 'JOIN ' . $ value , $ priority ) ; } } return $ this ; } | Joins one or more IRC channels with an optional key . |
22,359 | public function part ( $ channelarray , $ reason = null , $ priority = SMARTIRC_MEDIUM ) { if ( ! is_array ( $ channelarray ) ) { $ channelarray = array ( $ channelarray ) ; } $ channellist = implode ( ',' , $ channelarray ) ; if ( $ reason !== null ) { $ this -> send ( 'PART ' . $ channellist . ' :' . $ reason , $ priority ) ; } else { $ this -> send ( 'PART ' . $ channellist , $ priority ) ; } return $ this ; } | parts from one or more IRC channels with an optional reason |
22,360 | public function kick ( $ channel , $ nicknamearray , $ reason = null , $ priority = SMARTIRC_MEDIUM ) { if ( ! is_array ( $ nicknamearray ) ) { $ nicknamearray = array ( $ nicknamearray ) ; } $ nicknamelist = implode ( ',' , $ nicknamearray ) ; if ( $ reason !== null ) { $ this -> send ( 'KICK ' . $ channel . ' ' . $ nicknamelist . ' :' . $ reason , $ priority ) ; } else { $ this -> send ( 'KICK ' . $ channel . ' ' . $ nicknamelist , $ priority ) ; } return $ this ; } | Kicks one or more user from an IRC channel with an optional reason . |
22,361 | public function getList ( $ channelarray = null , $ priority = SMARTIRC_MEDIUM ) { if ( $ channelarray !== null ) { if ( ! is_array ( $ channelarray ) ) { $ channelarray = array ( $ channelarray ) ; } $ channellist = implode ( ',' , $ channelarray ) ; $ this -> send ( 'LIST ' . $ channellist , $ priority ) ; } else { $ this -> send ( 'LIST' , $ priority ) ; } return $ this ; } | gets a list of one ore more channels |
22,362 | public function setTopic ( $ channel , $ newtopic , $ priority = SMARTIRC_MEDIUM ) { $ this -> send ( 'TOPIC ' . $ channel . ' :' . $ newtopic , $ priority ) ; return $ this ; } | sets a new topic of a channel |
22,363 | public function mode ( $ target , $ newmode = null , $ priority = SMARTIRC_MEDIUM ) { if ( $ newmode !== null ) { $ this -> send ( 'MODE ' . $ target . ' ' . $ newmode , $ priority ) ; } else { $ this -> send ( 'MODE ' . $ target , $ priority ) ; } return $ this ; } | sets or gets the mode of an user or channel |
22,364 | public function founder ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '+q ' . $ nickname , $ priority ) ; } | founders an user in the given channel |
22,365 | public function defounder ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-q ' . $ nickname , $ priority ) ; } | defounders an user in the given channel |
22,366 | public function admin ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '+a ' . $ nickname , $ priority ) ; } | admins an user in the given channel |
22,367 | public function deadmin ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-a ' . $ nickname , $ priority ) ; } | deadmins an user in the given channel |
22,368 | public function op ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '+o ' . $ nickname , $ priority ) ; } | ops an user in the given channel |
22,369 | public function deop ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-o ' . $ nickname , $ priority ) ; } | deops an user in the given channel |
22,370 | public function hop ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '+h ' . $ nickname , $ priority ) ; } | hops an user in the given channel |
22,371 | public function dehop ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-h ' . $ nickname , $ priority ) ; } | dehops an user in the given channel |
22,372 | public function voice ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '+v ' . $ nickname , $ priority ) ; } | voice a user in the given channel |
22,373 | public function devoice ( $ channel , $ nickname , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-v ' . $ nickname , $ priority ) ; } | devoice a user in the given channel |
22,374 | public function ban ( $ channel , $ hostmask = null , $ priority = SMARTIRC_MEDIUM ) { if ( $ hostmask !== null ) { $ this -> mode ( $ channel , '+b ' . $ hostmask , $ priority ) ; } else { $ this -> mode ( $ channel , 'b' , $ priority ) ; } return $ this ; } | bans a hostmask for the given channel or requests the current banlist |
22,375 | public function unban ( $ channel , $ hostmask , $ priority = SMARTIRC_MEDIUM ) { return $ this -> mode ( $ channel , '-b ' . $ hostmask , $ priority ) ; } | unbans a hostmask on the given channel |
22,376 | public function invite ( $ nickname , $ channel , $ priority = SMARTIRC_MEDIUM ) { return $ this -> send ( 'INVITE ' . $ nickname . ' ' . $ channel , $ priority ) ; } | invites a user to the specified channel |
22,377 | public function changeNick ( $ newnick , $ priority = SMARTIRC_MEDIUM ) { $ this -> _nick = $ newnick ; return $ this -> send ( 'NICK ' . $ newnick , $ priority ) ; } | changes the own nickname |
22,378 | public function quit ( $ quitmessage = null , $ priority = SMARTIRC_CRITICAL ) { if ( $ quitmessage !== null ) { $ this -> send ( 'QUIT :' . $ quitmessage , $ priority ) ; } else { $ this -> send ( 'QUIT' , $ priority ) ; } return $ this -> disconnect ( true ) ; } | sends QUIT to IRC server and disconnects |
22,379 | public function parse_atts ( $ atts , $ tag ) { $ atts = \ shortcode_atts ( $ this -> default_atts ( ) , $ this -> validated_atts ( ( array ) $ atts ) , $ tag ) ; return $ atts ; } | Parse and validate the shortcode s attributes . |
22,380 | protected function default_atts ( ) { $ atts = array ( ) ; if ( ! $ this -> hasConfigKey ( 'atts' ) ) { return $ atts ; } $ atts_config = $ this -> getConfigKey ( 'atts' ) ; array_walk ( $ atts_config , function ( $ att_properties , $ att_label ) use ( & $ atts ) { $ atts [ $ att_label ] = $ att_properties [ 'default' ] ; } ) ; return $ atts ; } | Return an array of default attributes read from the configuration array . |
22,381 | protected function validated_atts ( $ atts ) { if ( ! $ this -> hasConfigKey ( 'atts' ) ) { return $ atts ; } $ atts_config = $ this -> getConfigKey ( 'atts' ) ; array_walk ( $ atts_config , function ( $ att_properties , $ att_label ) use ( & $ atts ) { if ( array_key_exists ( $ att_label , $ atts ) ) { $ validate_function = $ att_properties [ 'validate' ] ; $ atts [ $ att_label ] = $ validate_function ( $ atts [ $ att_label ] ) ; } } ) ; return $ atts ; } | Return an array of validated attributes checked against the configuration array . |
22,382 | public function LeaseGrant ( LeaseGrantRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Lease/LeaseGrant' , $ argument , [ '\Etcdserverpb\LeaseGrantResponse' , 'decode' ] , $ metadata , $ options ) ; } | LeaseGrant creates a lease which expires if the server does not receive a keepAlive within a given time to live period . All keys attached to the lease will be expired and deleted if the lease expires . Each expired key generates a delete event in the event history . |
22,383 | public function LeaseRevoke ( LeaseRevokeRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Lease/LeaseRevoke' , $ argument , [ '\Etcdserverpb\LeaseRevokeResponse' , 'decode' ] , $ metadata , $ options ) ; } | LeaseRevoke revokes a lease . All keys attached to the lease will expire and be deleted . |
22,384 | public function LeaseTimeToLive ( LeaseTimeToLiveRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Lease/LeaseTimeToLive' , $ argument , [ '\Etcdserverpb\LeaseTimeToLiveResponse' , 'decode' ] , $ metadata , $ options ) ; } | LeaseTimeToLive retrieves lease information . |
22,385 | public function isExcluded ( Carbon $ dt ) { foreach ( $ this -> exclusions ( ) as $ exc ) { if ( $ dt -> eq ( $ exc ) ) { return TRUE ; } } foreach ( $ this -> callbacks ( ) as $ fn ) { if ( $ fn ( $ dt ) == TRUE ) { return TRUE ; } } return FALSE ; } | Determine if a date is a non - business day |
22,386 | public function nbd ( Carbon $ dt = NULL ) { if ( ( $ dt instanceof Carbon ) == FALSE ) { $ dt = new Carbon ( ) ; } if ( $ this -> deadline ( ) ) { if ( $ this -> deadline ( ) -> lt ( $ dt ) ) { $ dt -> addDay ( ) ; } } else { $ dt -> addDay ( ) ; } $ dt -> setTime ( 0 , 0 , 0 ) ; $ iters = 0 ; while ( $ this -> isExcluded ( $ dt ) ) { if ( $ iters == static :: $ N_MAX_ITER ) { throw new \ RuntimeException ( 'Maximum iterations met for next business day calculation' ) ; } $ dt -> addDay ( ) ; $ iters ++ ; } return $ dt ; } | Determine the next business day |
22,387 | public function addLocation ( \ google \ protobuf \ SourceCodeInfo \ Location $ value ) { if ( $ this -> location === null ) { $ this -> location = new \ Protobuf \ MessageCollection ( ) ; } $ this -> location -> add ( $ value ) ; } | Add a new element to location |
22,388 | public function minify ( $ content , $ type , $ fileName ) { if ( $ type == 'css' ) { $ minifier = new Minify \ CSS ( ) ; $ minifier -> add ( $ content ) ; return $ minifier -> minify ( ) ; } elseif ( $ type == 'js' ) { $ minifier = new Minify \ JS ( ) ; $ minifier -> add ( $ content ) ; return $ minifier -> minify ( ) . ';' ; } return $ content ; } | Minify the given content |
22,389 | public function redirectPageSEO301 ( $ e , $ idpage ) { $ sm = $ e -> getApplication ( ) -> getServiceManager ( ) ; $ router = $ e -> getRouter ( ) ; $ uri = $ router -> getRequestUri ( ) ; $ uri = $ uri -> getPath ( ) ; if ( substr ( $ uri , 0 , 1 ) == '/' ) $ uri = substr ( $ uri , 1 , strlen ( $ uri ) ) ; $ melisTablePageSeo = $ sm -> get ( 'MelisEngineTablePageSeo' ) ; $ datasPageSeo = $ melisTablePageSeo -> getEntryById ( $ idpage ) ; if ( ! empty ( $ datasPageSeo ) ) { $ datasPageSeo = $ datasPageSeo -> current ( ) ; if ( ! empty ( $ datasPageSeo ) && ! empty ( $ datasPageSeo -> pseo_url_301 ) ) { if ( substr ( $ datasPageSeo -> pseo_url_301 , 0 , 4 ) != 'http' ) $ newuri = '/' . $ datasPageSeo -> pseo_url_301 ; else $ newuri = $ datasPageSeo -> pseo_url_301 ; $ newuri .= $ this -> getQueryParameters ( $ e ) ; return $ newuri ; } } return null ; } | This function handles the basic SEO 301 for Melis pages . This will be used when a page is unpublished |
22,390 | public function preFlush ( PreFlushEventArgs $ event ) { $ em = $ event -> getEntityManager ( ) ; $ changes = $ this -> meta_mutation_provider -> getFullChangeSet ( $ em ) ; foreach ( $ changes as $ updates ) { if ( 0 === count ( $ updates ) ) { continue ; } if ( false === $ this -> meta_annotation_provider -> isTracked ( $ em , current ( $ updates ) ) ) { continue ; } foreach ( $ updates as $ entity ) { if ( $ entity instanceof Proxy && ! $ entity -> __isInitialized ( ) ) { continue ; } $ original = $ this -> meta_mutation_provider -> createOriginalEntity ( $ em , $ entity ) ; $ mutated_fields = $ this -> meta_mutation_provider -> getMutatedFields ( $ em , $ entity , $ original ) ; if ( null === $ original || ! empty ( $ mutated_fields ) ) { $ this -> logger -> debug ( 'Going to notify a change (preFlush) to {entity_class}, which has {mutated_fields}' , [ 'entity_class' => get_class ( $ entity ) , 'mutated_fields' => $ mutated_fields ] ) ; $ em -> getEventManager ( ) -> dispatchEvent ( Events :: ENTITY_CHANGED , new EntityChangedEvent ( $ em , $ entity , $ original , $ mutated_fields ) ) ; } } } } | Pre Flush event callback |
22,391 | protected function handleGET ( ) { $ user = Session :: user ( ) ; if ( empty ( $ user ) ) { throw new UnauthorizedException ( 'There is no valid session for the current request.' ) ; } $ data = [ 'username' => $ user -> username , 'first_name' => $ user -> first_name , 'last_name' => $ user -> last_name , 'name' => $ user -> name , 'email' => $ user -> email , 'phone' => $ user -> phone , 'security_question' => $ user -> security_question , 'default_app_id' => $ user -> default_app_id , 'oauth_provider' => ( ! empty ( $ user -> oauth_provider ) ) ? $ user -> oauth_provider : '' , 'adldap' => ( ! empty ( $ user -> adldap ) ) ? $ user -> adldap : '' ] ; return $ data ; } | Fetches user profile . |
22,392 | protected function handlePOST ( ) { if ( empty ( $ payload = $ this -> getPayloadData ( ) ) ) { throw new BadRequestException ( 'No data supplied for operation.' ) ; } $ data = [ 'username' => array_get ( $ payload , 'username' ) , 'first_name' => array_get ( $ payload , 'first_name' ) , 'last_name' => array_get ( $ payload , 'last_name' ) , 'name' => array_get ( $ payload , 'name' ) , 'email' => array_get ( $ payload , 'email' ) , 'phone' => array_get ( $ payload , 'phone' ) , 'security_question' => array_get ( $ payload , 'security_question' ) , 'security_answer' => array_get ( $ payload , 'security_answer' ) , 'default_app_id' => array_get ( $ payload , 'default_app_id' ) ] ; $ data = array_filter ( $ data , function ( $ value ) { return ! is_null ( $ value ) ; } ) ; $ user = Session :: user ( ) ; if ( empty ( $ user ) ) { throw new NotFoundException ( 'No user session found.' ) ; } $ oldToken = Session :: getSessionToken ( ) ; $ email = $ user -> email ; $ user -> update ( $ data ) ; if ( ! empty ( $ oldToken ) && $ email !== array_get ( $ data , 'email' , $ email ) ) { $ forever = JWTUtilities :: isForever ( $ oldToken ) ; Session :: setUserInfoWithJWT ( $ user , $ forever ) ; $ newToken = Session :: getSessionToken ( ) ; return [ 'success' => true , 'session_token' => $ newToken ] ; } return [ 'success' => true ] ; } | Updates user profile . |
22,393 | public function addMethod ( \ google \ protobuf \ MethodDescriptorProto $ value ) { if ( $ this -> method === null ) { $ this -> method = new \ Protobuf \ MessageCollection ( ) ; } $ this -> method -> add ( $ value ) ; } | Add a new element to method |
22,394 | public function read ( array $ opts ) { return [ array_merge ( parent :: read ( $ opts ) [ 0 ] , [ 'recipe' => 'course_completed' , 'user_id' => $ opts [ 'relateduser' ] -> id , 'user_url' => $ opts [ 'relateduser' ] -> url , 'user_name' => $ opts [ 'relateduser' ] -> fullname , ] ) ] ; } | overides CourseViewed recipe . |
22,395 | protected function expandQuestion ( $ question , $ questions ) { if ( $ question -> qtype == 'randomsamatch' ) { $ subquestions = [ ] ; foreach ( $ questions as $ otherquestion ) { if ( $ otherquestion -> qtype == 'shortanswer' ) { foreach ( $ otherquestion -> answers as $ answer ) { if ( intval ( $ answer -> fraction ) === 1 ) { array_push ( $ subquestions , ( object ) [ "id" => $ answer -> id , "questiontext" => $ otherquestion -> questiontext , "answertext" => $ answer -> answer ] ) ; break ; } } } } $ question -> match = ( object ) [ 'subquestions' => $ subquestions ] ; } return $ question ; } | For certain question types expands question data by pulling from other questions . |
22,396 | public function resultFromState ( $ translatorevent , $ questionAttempt , $ submittedState ) { $ maxMark = isset ( $ questionAttempt -> maxmark ) ? $ questionAttempt -> maxmark : 100 ; $ scaledScore = $ submittedState -> fraction ; $ rawScore = $ scaledScore * floatval ( $ maxMark ) ; switch ( $ submittedState -> state ) { case "todo" : $ translatorevent [ 'attempt_completed' ] = false ; $ translatorevent [ 'attempt_success' ] = null ; break ; case "gaveup" : $ translatorevent [ 'attempt_completed' ] = false ; $ translatorevent [ 'attempt_success' ] = false ; break ; case "complete" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = null ; break ; case "gradedwrong" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = false ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; case "gradedpartial" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = false ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; case "gradedright" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = true ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; default : $ translatorevent [ 'attempt_completed' ] = null ; $ translatorevent [ 'attempt_success' ] = null ; break ; } return $ translatorevent ; } | Add some result data to translator event for an individual question attempt based on Moodle s question attempt state |
22,397 | public function numericStatement ( $ translatorevent , $ questionAttempt , $ question ) { $ translatorevent [ 'interaction_type' ] = 'numeric' ; $ correctAnswerId = null ; foreach ( $ question -> answers as $ answer ) { if ( intval ( $ answer -> fraction ) === 1 ) { $ correctAnswerId = $ answer -> id ; } } $ tolerance = 0 ; $ toleranceType = 2 ; $ answersdata = [ ] ; if ( $ question -> qtype == "numerical" ) { $ answersdata = $ question -> numerical -> answers ; } else if ( strpos ( $ question -> qtype , 'calculated' ) === 0 ) { $ answersdata = $ question -> calculated -> answers ; } if ( ! is_null ( $ correctAnswerId ) && count ( $ answersdata ) > 0 ) { foreach ( $ answersdata as $ answerdata ) { if ( isset ( $ answerdata -> answer ) ) { if ( $ answerdata -> answer == $ correctAnswerId ) { $ tolerance = floatval ( $ answerdata -> tolerance ) ; if ( isset ( $ answerdata -> tolerancetype ) ) { $ toleranceType = intval ( $ answerdata -> tolerancetype ) ; } } } } } $ rigthtanswer = floatval ( $ questionAttempt -> rightanswer ) ; if ( $ tolerance > 0 ) { $ toleranceMax = $ rigthtanswer + $ tolerance ; $ toleranceMin = $ rigthtanswer - $ tolerance ; switch ( $ toleranceType ) { case 1 : $ toleranceMax = $ rigthtanswer + ( $ rigthtanswer * $ tolerance ) ; $ toleranceMin = $ rigthtanswer - ( $ rigthtanswer * $ tolerance ) ; break ; case 3 : $ toleranceMax = $ rigthtanswer + ( $ rigthtanswer * $ tolerance ) ; $ toleranceMin = $ rigthtanswer / ( 1 + $ tolerance ) ; break ; default : break ; } $ rigthtanswerstring = strval ( $ toleranceMin ) . '[:]' . strval ( $ toleranceMax ) ; $ translatorevent [ 'interaction_correct_responses' ] = [ $ rigthtanswerstring ] ; } else { $ translatorevent [ 'interaction_correct_responses' ] = [ $ questionAttempt -> rightanswer ] ; } return $ translatorevent ; } | Add data specifc to numeric question types to a translator event . |
22,398 | public function shortanswerStatement ( $ translatorevent , $ questionAttempt , $ question ) { $ translatorevent [ 'interaction_type' ] = 'fill-in' ; $ translatorevent [ 'interaction_correct_responses' ] = [ ] ; foreach ( $ question -> answers as $ answer ) { if ( intval ( $ answer -> fraction ) === 1 ) { $ correctResponse ; if ( $ question -> shortanswer -> options -> usecase == '1' ) { $ correctResponse = '{case_matters=true}' . $ answer -> answer ; } else { $ correctResponse = '{case_matters=false}' . $ answer -> answer ; } array_push ( $ translatorevent [ 'interaction_correct_responses' ] , $ correctResponse ) ; } } return $ translatorevent ; } | Add data specifc to shortanswer question types to a translator event . |
22,399 | public function matchStatement ( $ translatorevent , $ questionAttempt , $ question ) { $ translatorevent [ 'interaction_type' ] = 'matching' ; $ targets = [ ] ; $ sources = [ ] ; $ correctResponses = [ ] ; $ responseTargetsPos = [ ] ; $ responseSourcesPos = [ ] ; foreach ( $ question -> match -> subquestions as $ subquestion ) { $ target = strip_tags ( $ subquestion -> questiontext ) ; $ source = strip_tags ( $ subquestion -> answertext ) ; $ targetId = 'moodle_quiz_question_target_' . $ subquestion -> id ; $ sourceId = 'moodle_quiz_question_source_' . $ subquestion -> id ; $ targets [ $ targetId ] = $ target ; $ sources [ $ sourceId ] = $ source ; array_push ( $ correctResponses , $ sourceId . '[.]' . $ targetId ) ; $ responseTargetsPos [ strpos ( $ questionAttempt -> responsesummary , $ target ) ] = $ targetId ; $ responseSourcesPos [ strpos ( $ questionAttempt -> responsesummary , $ source ) ] = $ sourceId ; } ksort ( $ responseTargetsPos ) ; $ responseTargets = array_values ( $ responseTargetsPos ) ; ksort ( $ responseSourcesPos ) ; $ responseSources = array_values ( $ responseSourcesPos ) ; $ translatorevent [ 'attempt_response' ] = '' ; if ( count ( $ responseTargets ) == count ( $ responseSources ) && count ( $ responseTargets ) > 0 ) { $ responses = [ ] ; foreach ( $ responseTargets as $ index => $ targetId ) { array_push ( $ responses , $ responseSources [ $ index ] . '[.]' . $ targetId ) ; } $ translatorevent [ 'attempt_response' ] = implode ( '[,]' , $ responses ) ; } $ translatorevent [ 'interaction_target' ] = $ targets ; $ translatorevent [ 'interaction_source' ] = $ sources ; $ translatorevent [ 'interaction_correct_responses' ] = [ implode ( '[,]' , $ correctResponses ) ] ; return $ translatorevent ; } | Add data specifc to matching question types to a translator event . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.