idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
19,300 | protected function removeEventCallable ( $ eventName , $ callable ) { if ( null === $ callable ) { $ this -> events [ $ eventName ] -> flush ( ) ; } else { $ this -> events [ $ eventName ] -> remove ( $ callable ) ; } if ( count ( $ this -> events [ $ eventName ] ) === 0 ) { unset ( $ this -> events [ $ eventName ] ) ;... | Remove event or its callable |
19,301 | public function getClient ( $ accessToken ) { $ client = new Google_Client ( ) ; $ client -> setApplicationName ( $ this -> applicationName ) ; $ client -> setAccessType ( 'offline' ) ; $ client -> setAccessToken ( $ accessToken ) ; if ( $ client -> isAccessTokenExpired ( ) ) { $ client -> setAuthConfigFile ( Yii :: ge... | Returns an authorized API client . |
19,302 | public static function isJoomla ( ) { $ directories = array ( './libraries/cms' , './libraries/joomla' , './index.php' , './administrator/index.php' ) ; foreach ( $ directories as $ directory ) { $ path = realpath ( $ directory ) ; if ( ! file_exists ( $ path ) ) { return false ; } } return true ; } | Validate if the current working directory has a valid Joomla installation |
19,303 | public static function isJoomlatoolsPlatform ( ) { $ manifest = realpath ( './composer.json' ) ; if ( file_exists ( $ manifest ) ) { $ contents = file_get_contents ( $ manifest ) ; $ package = json_decode ( $ contents ) ; if ( isset ( $ package -> name ) && in_array ( $ package -> name , array ( 'joomlatools/platform' ... | Check if the working directory has Joomlatools Platform installed |
19,304 | public static function getPackageManifest ( $ installPath ) { if ( ! array_key_exists ( $ installPath , self :: $ __manifests ) ) { self :: $ __manifests [ $ installPath ] = false ; $ directories = new \ RecursiveDirectoryIterator ( $ installPath ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directories ) ; $ it... | Find the XML manifest of the installation package |
19,305 | public static function getNameFromManifest ( $ installPath ) { $ manifest = self :: getPackageManifest ( $ installPath ) ; if ( $ manifest === false ) { return false ; } $ xml = simplexml_load_file ( $ manifest ) ; if ( ! ( $ xml instanceof \ SimpleXMLElement ) ) { return false ; } $ element = false ; $ type = ( string... | Get the element name from the XML manifest |
19,306 | protected function _enablePlugin ( PackageInterface $ package , $ installPath , $ subdirectory = '' ) { $ path = realpath ( $ installPath . '/' . $ subdirectory ) ; $ file = Util :: getPackageManifest ( $ path ) ; if ( $ file !== false ) { $ manifest = simplexml_load_file ( $ file ) ; $ type = ( string ) $ manifest -> ... | Enable all plugins that were installed with this package . |
19,307 | public function validate ( Message $ message ) { foreach ( $ this -> validators as $ validator ) { $ validator -> validate ( $ message ) ; } } | Test a message against a number of validators . |
19,308 | protected function provideBlockSchema ( ) { $ blockSchema = parent :: provideBlockSchema ( ) ; if ( $ this -> File ( ) && $ this -> File ( ) -> exists ( ) && $ this -> File ( ) -> getIsImage ( ) ) { $ blockSchema [ 'fileURL' ] = $ this -> File ( ) -> CMSThumbnail ( ) -> getURL ( ) ; $ blockSchema [ 'fileTitle' ] = $ th... | Return file title and thumbnail for summary section of ElementEditor |
19,309 | protected function listenerEvents ( ListenerInterface $ listener ) { $ result = [ ] ; foreach ( $ listener -> eventsListening ( ) as $ eventName => $ data ) { $ newData = $ this -> expandToHandler ( $ data ) ; foreach ( $ newData as $ handler ) { $ result [ ] = $ this -> expandWithPriority ( $ listener , $ eventName , ... | standardize events definition |
19,310 | public function actionList ( $ showAllVersions = false ) { foreach ( $ this -> apis as $ id => $ versions ) { foreach ( $ versions as $ version => $ api ) { if ( ! $ showAllVersions ) { $ this -> stdout ( $ api -> name . ' - ' . $ api -> title . "\n" ) ; break ; } else { $ this -> stdout ( $ api -> id . ' - ' . $ api -... | List all the available APIs |
19,311 | public function getApis ( ) { if ( empty ( $ this -> theApis ) ) { $ response = Json :: decode ( file_get_contents ( self :: DISCOVERY_URL ) , false ) ; $ theApis = [ ] ; foreach ( $ response -> items as $ item ) { if ( ! isset ( $ theApis [ $ item -> name ] ) ) { $ theApis [ $ item -> name ] = [ ] ; } $ theApis [ $ it... | Fetches the Google API list |
19,312 | private function generateCredentialsFile ( $ api , $ scopes ) { $ credentialsPath = Yii :: getAlias ( $ this -> configPath ) . '/' . $ api . '_' . $ this -> getUuid ( ) . '.json' ; $ client = new Google_Client ( ) ; $ client -> setAuthConfigFile ( $ this -> clientSecretPath ) ; $ client -> setAccessType ( 'offline' ) ;... | Generates the credential file prompting the user for the verification code |
19,313 | public static function installGitMessageHook ( Event $ event ) { $ hookContent = self :: HOOK_CONTENTS ; $ inputOutput = $ event -> getIO ( ) ; $ question = 'Do you want to install and activate the Git ' ; $ question .= 'commit message hook? ' ; if ( $ inputOutput -> askConfirmation ( $ question , false ) ) { $ errorMe... | Installs and activates the Git commit message hook when confirmed by the user . An existing hook is backed with the . bak extension . |
19,314 | public static function installGitCommitMessageTemplate ( Event $ event ) { $ templateContent = self :: TEMPLATE_CONTENTS ; $ inputOutput = $ event -> getIO ( ) ; $ question = 'Do you want to install and configure the Git ' ; $ question .= 'commit message template? ' ; if ( $ inputOutput -> askConfirmation ( $ question ... | Installs and configures the Git commit message template when confirmed by the user . |
19,315 | public function isTitleCapitalised ( ) : bool { if ( 0 == $ this -> getTitleLength ( ) ) { return false ; } return $ this -> commitMessage [ 0 ] [ 0 ] === strtoupper ( $ this -> commitMessage [ 0 ] ) { 0 } ; } | Is the title capitalised . |
19,316 | public function hasTitleAFullStop ( ) : bool { if ( 0 == $ this -> getTitleLength ( ) ) { return false ; } $ lastCharacter = trim ( $ this -> commitMessage [ 0 ] ) { $ this -> getTitleLength ( ) - 1 } ; return '.' == $ lastCharacter ; } | Title ends with a full stop . |
19,317 | public function getBodyWrapLength ( ) : int { if ( count ( $ this -> commitMessage ) < 3 ) { return 0 ; } $ body = array_slice ( $ this -> commitMessage , 2 ) ; $ longestLineLength = 0 ; foreach ( $ body as $ line ) { if ( strlen ( $ line ) > $ longestLineLength ) { $ longestLineLength = strlen ( $ line ) ; } } return ... | The length at which the message wraps . |
19,318 | public function authenticate ( $ credentials ) { $ user = JFactory :: getUser ( ) ; $ user -> guest = 0 ; foreach ( $ credentials as $ key => $ value ) { $ user -> $ key = $ value ; } JFactory :: getSession ( ) -> set ( 'user' , $ user ) ; } | Authenticates the Joomla user . |
19,319 | public function isInstalled ( $ installPath ) { $ manifest = Util :: getPackageManifest ( $ installPath ) ; if ( $ manifest === false ) { return false ; } $ xml = simplexml_load_file ( $ manifest ) ; if ( $ xml instanceof \ SimpleXMLElement ) { $ type = ( string ) $ xml -> attributes ( ) -> type ; $ element = Util :: g... | Check if the Composer package located at the given path is installed or not . |
19,320 | public function uninstall ( $ id , $ type ) { $ installer = $ this -> getInstaller ( ) ; return $ installer -> uninstall ( $ type , $ id ) ; } | Uninstalls the given extension |
19,321 | protected function _setupLogging ( $ loglevel ) { if ( file_exists ( JPATH_LIBRARIES . '/src/Log/Log.php' ) ) { require_once JPATH_LIBRARIES . '/src/Log/Log.php' ; } else { require_once JPATH_LIBRARIES . '/joomla/log/log.php' ; } if ( $ loglevel == OutputInterface :: VERBOSITY_NORMAL ) { return ; } switch ( $ loglevel ... | Enable logging to stdout of Joomla system messages . |
19,322 | public static function getEventManager ( ) { if ( ! isset ( self :: $ event_manager [ get_called_class ( ) ] ) ) { self :: $ event_manager [ get_called_class ( ) ] = EventDispatcher :: getShareable ( static :: $ static_scope ) ; } return self :: $ event_manager [ get_called_class ( ) ] ; } | Get the inner event manager |
19,323 | public function getApplication ( ) { if ( ! ( $ this -> _io instanceof IOInterface ) ) { throw new \ RuntimeException ( 'Bootstrapper instance requires IOInterface instance. Please call setIO() first.' ) ; } if ( ! $ this -> _bootstrapped ) { $ this -> _bootstrap ( ) ; } if ( ! ( $ this -> _application instanceof Appli... | Get the application instance . If it s not initialised yet bootstrap the application . |
19,324 | private function parse ( $ content ) { $ xml = new SimpleXMLElement ( $ content ) ; if ( isset ( $ xml -> error ) ) { throw new Exception \ ZohoErrorException ( new ZohoError ( ( string ) $ xml -> error -> code , ( string ) $ xml -> error -> message ) ) ; } if ( isset ( $ xml -> nodata ) ) { throw new Exception \ NoDat... | Parses the XML returned by Zoho to the appropriate objects |
19,325 | public function getMessageValidator ( ) : ValidateMessage { $ messageValidator = new ValidateMessageImplementation ( [ new CapitalizeTheSubjectLineValidator ( ) , new DoNotEndTheSubjectLineWithAPeriodValidator ( ) , new LimitTheBodyWrapLengthTo72CharactersValidator ( ) , new LimitTheTitleLengthTo69CharactersValidator (... | Get a message validator set - up with all the validators . |
19,326 | public function combine ( Block $ block ) { $ this -> setBlockData ( $ block -> blockData , false ) ; $ this -> setGlobalData ( $ block -> globalData , false ) ; $ this -> addTemplates ( $ block -> templates ) ; $ this -> addRepeaterBlocks ( $ block -> inRepeaterBlocks ) ; $ this -> addRepeaterChildBlocks ( $ block -> ... | Add extra data from second block |
19,327 | public function subtract ( Block $ block ) { $ this -> blockData = array_diff_assoc ( $ this -> blockData , $ block -> blockData ) ; $ this -> globalData = array_diff_assoc ( $ this -> globalData , $ block -> globalData ) ; $ this -> templates = array_diff ( $ this -> templates , $ block -> templates ) ; $ this -> inRe... | Find any differences in the data |
19,328 | public function exportFiles ( $ content ) { $ images = [ ] ; if ( $ galleryData = $ this -> _defaultData ( $ content ) ) { foreach ( $ galleryData as $ image => $ imageData ) { $ images [ ] = '/uploads/system/gallery/' . $ this -> _block -> name . $ imageData -> path . $ image ; } } return $ images ; } | Export gallery images |
19,329 | public function editPage ( ) { $ page = Page :: preload ( $ this -> _block -> getPageId ( ) ) ; if ( $ page -> exists ) { $ paths = Path :: getById ( $ page -> id ) ; return View :: make ( 'coaster::pages.gallery' , [ 'paths' => $ paths , '_block' => $ this -> _block , 'can_delete' => Auth :: action ( 'gallery.delete' ... | Display full edit page for gallery |
19,330 | public function submitSort ( ) { $ order = 1 ; $ galleryData = $ this -> _defaultData ( $ this -> _block -> getContent ( ) ) ; foreach ( Request :: input ( 'arr' ) as $ image ) { if ( ! isset ( $ galleryData [ $ image ] ) ) { return 0 ; } $ galleryData [ $ image ] -> order = $ order ++ ; } $ this -> _block -> updateCon... | Update sort values of images |
19,331 | public function submitCaption ( ) { $ galleryData = $ this -> _defaultData ( $ this -> _block -> getContent ( ) ) ; if ( ! empty ( $ galleryData [ Request :: input ( 'file_data' ) ] ) ) { $ galleryData [ Request :: input ( 'file_data' ) ] -> caption = Request :: input ( 'caption' ) ; $ this -> _block -> updateContent (... | Update image caption in gallery |
19,332 | public function submitDelete ( $ file ) { AdminLog :: new_log ( 'Removed ' . $ file . ' from Gallery (ID ' . $ this -> _block -> id . ')' ) ; $ galleryData = $ this -> _defaultData ( $ this -> _block -> getContent ( ) ) ; $ path = '/' . $ this -> _block -> getPageId ( ) . '/' ; if ( isset ( $ galleryData [ $ file ] ) )... | Delete image from gallery |
19,333 | public function runHandler ( ) { $ currentData = $ this -> _defaultData ( $ this -> _block -> getContent ( ) ) ; $ uploadHandler = new GalleryUploadHandler ( [ 'print_response' => false , 'selected_data' => $ currentData , 'script_url' => Request :: url ( ) , 'max_file_size' => 2000000 , 'accept_file_types' => '/\.(gif... | Return upload images handler also uploads image if in request |
19,334 | public static function widget ( $ config = [ ] ) { $ widgetClass = get_called_class ( ) ; self :: $ _instance = new $ widgetClass ; foreach ( $ config as $ property => $ value ) { self :: $ _instance -> $ property = $ value ; } return self :: $ _instance -> run ( ) ; } | Creates a widget instance and runs it . The widget rendering result is returned by this method . |
19,335 | public function getViewPath ( ) { if ( self :: $ _viewPath ) { return self :: $ _viewPath ; } $ reflectionClass = new ReflectionClass ( $ this ) ; $ widgetPath = dirname ( $ reflectionClass -> getFileName ( ) ) ; $ relativePath = str_replace ( APPPATH , '' , $ widgetPath ) ; return self :: $ _viewPath = "../{$relativeP... | Returns the directory containing the view files for this widget . The default implementation returns the views subdirectory under the directory containing the widget class file . |
19,336 | protected function render ( $ viewFile , $ variables = [ ] ) { $ viewFile = ( strpos ( $ viewFile , '/' , 0 ) === false ) ? $ this -> getViewPath ( ) . $ viewFile : $ viewFile ; $ this -> CI -> load -> view ( $ viewFile , $ variables ) ; } | Render a view of Widget |
19,337 | public function filter ( $ content , $ search , $ type ) { $ search = is_array ( $ search ) ? $ search : [ $ search ] ; $ search = array_map ( function ( $ searchValue ) { return is_a ( $ searchValue , Carbon :: class ) ? $ searchValue : new Carbon ( $ searchValue ) ; } , $ search ) ; $ current = ( new Carbon ( $ conte... | Datetime exact match check as well as between check |
19,338 | public function display ( $ content , $ options = [ ] ) { $ formData = $ this -> _defaultData ( $ content ) ; $ view = ! empty ( $ options [ 'view' ] ) ? $ options [ 'view' ] : $ formData -> template ; return FormWrap :: view ( $ this -> _block , $ options , $ this -> displayView ( $ view ) , [ 'form_data' => $ formDat... | Display form view |
19,339 | public function submissionSaveData ( array $ formData ) { $ formData = array_filter ( $ formData ) ; $ files = [ ] ; foreach ( $ formData as $ field => $ value ) { if ( Request :: hasFile ( $ field ) ) { $ files [ $ field ] = Request :: file ( $ field ) ; unset ( $ formData [ $ field ] ) ; } } $ form_submission = new F... | Save form data |
19,340 | public function submissionSendEmail ( array $ formData , \ stdClass $ form_settings ) { $ subject = config ( 'coaster::site.name' ) . ': New Form Submission - ' . $ this -> _block -> label ; return Email :: sendFromFormData ( [ $ form_settings -> template , $ this -> _block -> name ] , $ formData , $ subject , $ form_s... | Send the form data by email |
19,341 | public function submission ( $ formData ) { if ( $ form_settings = $ this -> _block -> getContent ( true ) ) { $ form_settings = $ this -> _defaultData ( $ form_settings ) ; $ form_rules = BlockFormRule :: get_rules ( $ form_settings -> template ? : $ this -> _block -> name ) ; $ v = Validator :: make ( $ formData , $ ... | Save form data and send email |
19,342 | public static function resource ( ) { $ arguments = func_get_args ( ) ; $ path = $ arguments [ 0 ] ; $ controller = end ( $ arguments ) ; $ resourceRoutes = array ( 'get' => array ( 'pattern' => "$path" , 'method' => 'get' , 'handler' => "$controller:index" ) , 'get_paginate' => array ( 'pattern' => "$path/page/:page" ... | Route resource to single controller |
19,343 | public static function controller ( ) { $ arguments = func_get_args ( ) ; $ path = $ arguments [ 0 ] ; $ controller = end ( $ arguments ) ; $ class = new \ ReflectionClass ( $ controller ) ; $ controllerMethods = $ class -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ; fo... | Map route to all public controller method |
19,344 | public function index ( ) { $ this -> loadJs ( 'app/install.js' ) ; $ this -> publish ( 'baseUrl' , $ this -> data [ 'baseUrl' ] ) ; App :: render ( 'install/configure_db.twig' , $ this -> data ) ; } | display database configuration form |
19,345 | public function checkConnection ( ) { $ success = false ; $ message = '' ; $ config = $ this -> getPostConfiguration ( ) ; try { $ this -> makeConnection ( $ config ) ; switch ( $ config [ 'driver' ] ) { case 'mysql' : $ tables = Capsule :: select ( 'show tables' ) ; break ; case 'sqlite' : $ tables = Capsule :: select... | check database connection based on provided setting |
19,346 | public function writeConfiguration ( ) { $ configFile = APP_PATH . 'config/database.php' ; $ config = $ this -> getPostConfiguration ( ) ; $ configStr = <<<CONFIG<?php\$config['database'] = array( 'default' => '{$config['driver']}', 'connections' => array( '{$config['driver']}' => array( ... | write configuration to database configuration |
19,347 | private function getPostConfiguration ( ) { $ driver = Input :: post ( 'dbdriver' ) ; $ database = Input :: post ( 'dbname' ) ; if ( $ driver == 'sqlite' ) { $ database = APP_PATH . 'storage/db/' . $ database . '.sqlite' ; } return array ( 'driver' => $ driver , 'host' => Input :: post ( 'dbhost' ) , 'database' => $ da... | Get configuration value posted by user |
19,348 | public function build ( $ alternativeHost = null ) { $ finder = Util :: finder ( $ this -> directories , [ ] ) ; foreach ( $ finder as $ file ) { $ this -> analysis -> addAnalysis ( $ this -> analyser -> fromFile ( $ file -> getPathname ( ) ) ) ; } $ this -> analysis -> alternativeHost = $ alternativeHost ; $ this -> a... | Search for annotations process and validate definitions . |
19,349 | public function json ( $ alternativeHost = null , $ pretty = false ) { $ this -> build ( $ alternativeHost ) ; $ jsonOptions = JSON_UNESCAPED_SLASHES ; if ( $ pretty ) { $ jsonOptions |= JSON_PRETTY_PRINT ; } return json_encode ( $ this -> analysis -> swagger , $ jsonOptions ) ; } | Build and return OpenAPI json . |
19,350 | public function save ( $ filename , $ alternativeHost = null ) { $ this -> build ( $ alternativeHost ) ; $ this -> analysis -> swagger -> saveAs ( $ filename ) ; } | Build and save OpenAPI json to file . |
19,351 | public function move_to ( $ id = NULL , $ x = NULL , $ y = NULL ) { throw new Exception_Notimplemented ( __FUNCTION__ , $ this ) ; } | Move the mouse to a certain element |
19,352 | public static function extract_query_from_uri ( $ uri ) { $ uri_query_str = parse_url ( $ uri , PHP_URL_QUERY ) ; if ( ! $ uri_query_str ) { return array ( ) ; } parse_str ( $ uri_query_str , $ uri_query ) ; return $ uri_query ; } | Extract implicit query from URI |
19,353 | protected function _afterRun ( ) { foreach ( $ this -> _formTemplateRulesToDelete as $ template => $ fields ) { BlockFormRule :: where ( 'form_template' , '=' , $ template ) -> whereIn ( 'field' , array_keys ( $ fields ) ) -> delete ( ) ; } } | When adding form rules clear all previous rules for any conflicting form_templates |
19,354 | public function execute ( $ method , $ url , array $ post = array ( ) ) { $ curl = curl_init ( $ url ) ; curl_setopt ( $ curl , CURLOPT_FOLLOWLOCATION , TRUE ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ curl , CURLOPT_CUSTOMREQUEST , $ method ) ; curl_setopt ( $ curl , CURLOPT_USERAGENT ... | Perform the request follow redirects return the response |
19,355 | public function setConfig ( $ config ) { $ this -> config = $ config ; foreach ( $ config as $ key => $ value ) { $ this -> app -> config ( $ key , $ value ) ; } } | Setup SlimStarter configuration and inject it to Slim instance |
19,356 | public function bootEloquent ( $ config ) { try { $ this -> app -> container -> singleton ( 'db' , function ( ) { return new DatabaseManager ; } ) ; $ this -> app -> db -> addConnection ( $ config [ 'connections' ] [ $ config [ 'default' ] ] ) ; $ this -> app -> db -> setAsGlobal ( ) ; $ this -> app -> db -> bootEloque... | Boot up Eloquent ORM and inject to Slim container |
19,357 | public function bootModuleManager ( ) { $ app = $ this -> app ; $ this -> app -> container -> singleton ( 'module' , function ( ) use ( $ app ) { return new ModuleManager ( $ app ) ; } ) ; } | Boot up module manager and inject to Slim container |
19,358 | public function bootSentry ( $ config ) { $ app = $ this -> app ; $ this -> app -> container -> singleton ( 'sentry' , function ( ) use ( $ app , $ config ) { $ hasherProvider = $ this -> hasherProviderFactory ( $ config ) ; $ userProvider = $ this -> userProviderFactory ( $ hasherProvider , $ config ) ; $ groupProvide... | Boot up Sentry authorization provider |
19,359 | protected function hasherProviderFactory ( $ config ) { $ hasher = $ config [ 'hasher' ] ; switch ( $ hasher ) { case 'native' : return new NativeHasher ; break ; case 'bcrypt' : return new BcryptHasher ; break ; case 'sha256' : return new Sha256Hasher ; break ; case 'whirlpool' : return new WhirlpoolHasher ; break ; }... | Sentry specific factory adopted from SentryServiceProvider |
19,360 | public function bootTwig ( $ config ) { $ app = $ this -> app ; $ view = $ app -> view ; $ view -> parserOptions = $ config ; $ view -> parserExtensions = array ( new \ Slim \ Views \ TwigExtension ( ) , new \ SlimStarter \ TwigExtension \ MenuRenderer ( ) ) ; } | Boot up Twig template engine |
19,361 | public function boot ( ) { $ this -> bootFacade ( $ this -> config [ 'aliases' ] ) ; $ this -> bootMenuManager ( ) ; $ this -> bootEloquent ( $ this -> config [ 'database' ] ) ; $ this -> bootModuleManager ( ) ; $ this -> bootTwig ( $ this -> config [ 'twig' ] ) ; $ this -> bootSentry ( $ this -> config [ 'sentry' ] ) ... | Run the boot sequence |
19,362 | protected function _defaultData ( $ content ) { $ content = @ unserialize ( $ content ) ; if ( empty ( $ content ) || ! is_a ( $ content , \ stdClass :: class ) ) { $ content = new \ stdClass ; } $ content -> text = isset ( $ content -> text ) ? $ content -> text : '' ; $ content -> colour = isset ( $ content -> colour... | Return valid stringwcolour data |
19,363 | public function generateSearchText ( $ content ) { $ content = $ this -> _defaultData ( $ content ) ; $ searchText = $ this -> _generateSearchText ( $ content -> text , $ content -> colour ) ; return parent :: generateSearchText ( $ searchText ) ; } | Add text and colour data to search |
19,364 | public function seek ( $ offset ) { if ( $ this -> offsetExists ( $ offset ) ) { $ this -> _current = $ offset ; return TRUE ; } return FALSE ; } | Implementation of SeekableIterator |
19,365 | public static function is_port_open ( $ host , $ port ) { $ connection = @ fsockopen ( $ host , $ port ) ; if ( is_resource ( $ connection ) ) { fclose ( $ connection ) ; return FALSE ; } return TRUE ; } | Check if a port is open |
19,366 | public function edit ( $ content ) { $ content = $ this -> _defaultData ( $ content ) ; $ link = str_replace ( 'internal://' , '' , $ content [ 'link' ] , $ count ) ; $ content [ 'link' ] = ( $ count > 0 ) ? '' : $ content [ 'link' ] ; $ this -> _editViewData [ 'targetOptions' ] = [ 0 => 'Target: Same Tab' , '_blank' =... | Edit link settings |
19,367 | public function submit ( $ postContent ) { $ linkData = [ ] ; if ( ! empty ( $ postContent [ 'internal' ] ) ) { $ linkData [ 'link' ] = 'internal://' . $ postContent [ 'internal' ] ; } elseif ( ! empty ( $ postContent [ 'custom' ] ) ) { $ linkData [ 'link' ] = $ postContent [ 'custom' ] ; } else { $ linkData [ 'link' ]... | Update link settings |
19,368 | public function normaliseDevices ( $ pending = false ) { try { $ this -> originalDevices = json_decode ( $ this -> getClient ( ) -> request ( 'GET' , 'devices' ) -> getBody ( ) ) ; } catch ( \ Exception $ e ) { dd ( $ e -> getMessage ( ) ) ; } $ this -> devices = [ ] ; $ this -> pendingDevices = [ ] ; foreach ( $ this ... | Normalise Estimote return array to match up to expected for BlockBeacon |
19,369 | public function createException ( \ Exception $ e , $ soapFunction , $ input ) { if ( ! ( $ e instanceof ExecutorException ) ) { return $ e ; } $ e = $ e -> getPrevious ( ) ; if ( $ e instanceof \ SoapFault ) { switch ( $ e -> faultcode ) { default : throw InvalidInputDataException :: createExceptionFromSoapFault ( $ e... | Wraps exception to API s type |
19,370 | public function parentPageId ( $ noOverride = false ) { if ( $ this -> pageOverride && ! $ noOverride ) { return $ this -> pageOverride -> parent ; } else { return ( $ parentIndex = ( count ( $ this -> pageLevels ) - 2 ) ) >= 0 ? $ this -> pageLevels [ $ parentIndex ] -> id : 0 ; } } | Get parent page id based on the page levels loaded from url |
19,371 | public function display ( $ content , $ options = [ ] ) { if ( ! empty ( $ content ) ) { $ videoInfo = $ this -> _cache ( $ content ) ; if ( ! ( $ videoInfo || empty ( $ options [ 'alwaysRender' ] ) ) ) { return 'Video does not exist, it may have been removed from youtube' ; } return $ this -> _renderDisplayView ( $ op... | Display video using info from youtube API |
19,372 | public function submit ( $ postContent ) { if ( is_array ( $ postContent ) && array_key_exists ( 'select' , $ postContent ) ) { $ this -> _cache ( $ postContent [ 'select' ] , true ) ; } return parent :: submit ( $ postContent ) ; } | Save video with and youtube video API data to cache |
19,373 | protected function _cache ( $ videoId , $ dl = false ) { if ( ( ! array_key_exists ( $ videoId , static :: $ _cachedVideoData ) || $ dl ) ) { if ( $ videoId ) { $ videoData = BlockVideoCache :: where ( 'videoId' , '=' , $ videoId ) -> first ( ) ? : new BlockVideoCache ; if ( ! $ videoData -> exists ( ) || $ dl ) { if (... | Return cached youtube video API data or fetch if not cached |
19,374 | protected function _dl ( $ request , $ params = [ ] ) { try { $ youTube = new Client ( [ 'base_uri' => 'https://www.googleapis.com/youtube/v3/' ] ) ; $ params = $ params + [ 'key' => config ( 'coaster::key.yt_server' ) ] ; $ response = $ youTube -> request ( 'GET' , $ request , [ 'query' => $ params ] ) ; $ data = json... | Download youtube API data |
19,375 | public function display ( $ content , $ options = [ ] ) { if ( ! empty ( $ options [ 'meta' ] ) || ! empty ( $ options [ 'pageBuilder' ] ) ) { $ content = preg_replace_callback ( '/{{\s*\$(?P<block>\w*)\s*}}/' , function ( $ matches ) { return str_replace ( '"' , "'" , strip_tags ( PageBuilder :: block ( $ matches [ 'b... | Frontend display for the block |
19,376 | public function edit ( $ content ) { if ( stripos ( $ this -> _block -> name , 'meta' ) !== false ) { if ( stripos ( $ this -> _block -> name , 'title' ) !== false ) { $ lengthGuide = [ 'data-min' => 40 , 'data-max' => 60 ] ; } elseif ( stripos ( $ this -> _block -> name , 'desc' ) !== false ) { $ lengthGuide = [ 'data... | Meta length guides |
19,377 | protected function _loadPageLevels ( ) { $ urlSegments = count ( Request :: segments ( ) ) ; if ( $ urlSegments == 1 && substr ( Request :: segment ( 1 ) , 0 , 5 ) == 'root.' ) { if ( $ this -> feedExtension = Feed :: getFeedExtensionFromPath ( Request :: segment ( 1 ) ) ) { $ urlSegments = 0 ; } } if ( empty ( $ this ... | Load all page levels for current request . Also check if search page or feed page . |
19,378 | protected function _loadPageStatus ( ) { $ lowestLevelPage = count ( $ this -> pageLevels ) > 0 ? end ( $ this -> pageLevels ) : null ; if ( $ lowestLevelPage ) { $ this -> isLive = $ lowestLevelPage -> is_live ( ) ; if ( ! $ this -> is404 ) { if ( $ previewKey = Request :: input ( 'preview' ) ) { $ this -> previewVers... | Load current page status . Is live Is preview Custom Template |
19,379 | public function _loadPageTemplate ( ) { $ theme = Theme :: find ( config ( 'coaster::frontend.theme' ) ) ; $ lowestLevelPage = count ( $ this -> pageLevels ) > 0 ? end ( $ this -> pageLevels ) : null ; $ this -> theme = ! empty ( $ theme ) && is_dir ( base_path ( '/resources/views/themes/' . $ theme -> theme ) ) ? $ th... | Load theme name template name and content type to return |
19,380 | protected function _isSearchPage ( $ path , Page $ parentPage ) { $ ppIsNamedSearch = ( $ parentPage -> pageLang ( ) && $ parentPage -> pageLang ( ) -> url == 'search' ) ; if ( $ path == 'search' || $ ppIsNamedSearch ) { return $ ppIsNamedSearch ? 0 : 1 ; } else { return false ; } } | If a search page returns an additional offset from which segment to take the search query |
19,381 | public function start ( array $ desiredCapabilities = NULL ) { if ( ! ( $ this -> _session_id = $ this -> reuse_session ( ) ) ) { $ this -> _session_id = $ this -> new_session ( $ desiredCapabilities ) ; } $ this -> _server .= "session/{$this->_session_id}/" ; } | Start a new selenium session based on passed desired capabilities . Reuses the session if possible |
19,382 | public function reuse_session ( ) { $ sessions = $ this -> get ( 'sessions' ) ; foreach ( $ sessions as $ session ) { $ id = $ session [ 'id' ] ; try { $ this -> get ( "session/$id/window_handle" ) ; return $ id ; } catch ( Exception_Selenium $ exception ) { $ this -> delete ( "session/$id" ) ; } } } | Try to reuse an existing selenium session return the reused id |
19,383 | public function new_session ( array $ desiredCapabilities = NULL ) { if ( ! $ desiredCapabilities ) { $ desiredCapabilities = array ( 'browserName' => 'firefox' ) ; } $ session = $ this -> post ( 'session' , array ( 'desiredCapabilities' => $ desiredCapabilities ) ) ; return $ session [ 'webdriver.remote.sessionid' ] ;... | Initiate a new session based on the desired capabilities |
19,384 | public function post ( $ command , array $ params ) { $ options = array ( ) ; $ options [ CURLOPT_POST ] = TRUE ; if ( $ params ) { $ options [ CURLOPT_POSTFIELDS ] = json_encode ( $ params ) ; } return $ this -> call ( $ command , $ options ) ; } | Perform a post request to the selenium server |
19,385 | public function call ( $ command , array $ options = array ( ) ) { $ curl = curl_init ( ) ; $ options [ CURLOPT_URL ] = $ this -> server ( ) . $ command ; $ options [ CURLOPT_RETURNTRANSFER ] = TRUE ; $ options [ CURLOPT_FOLLOWLOCATION ] = TRUE ; $ options [ CURLOPT_HTTPHEADER ] = array ( 'Content-Type: application/jso... | Perform a request to the selenium server using curl |
19,386 | public static function getFullPathsVariations ( $ pageIds , $ separator = ' » ' ) { $ paths = [ ] ; foreach ( $ pageIds as $ pageId ) { $ paths [ $ pageId ] = self :: getFullPath ( $ pageId , $ separator ) ; if ( $ paths [ $ pageId ] -> groupContainers ) { foreach ( $ paths [ $ pageId ] -> groupContainers as $ gr... | Get paths with group variations |
19,387 | public static function unParsePageId ( $ unParsedPageId , $ returnFirstEl = true ) { $ parts = explode ( ',' , $ unParsedPageId ) ; return $ returnFirstEl ? $ parts [ 0 ] : $ parts ; } | remove group data from saved block content or block options |
19,388 | protected function _renderThemeFiles ( $ scope = 'file' ) { $ this -> _blocksCollection -> setScope ( $ scope ) ; $ themeBuilder = PageBuilder :: make ( ThemeBuilderInstance :: class , [ new PageLoaderDummy ( $ this -> _additionalData [ 'theme' ] -> theme ) , $ this -> _blocksCollection ] ) ; if ( $ this -> _templateLi... | Get all extra block data from theme files |
19,389 | protected function _renderCsvBlocks ( $ themeBuilder ) { $ themeBuilder -> setData ( 'template' , '' ) ; foreach ( $ this -> _blocksCollection -> getBlocks ( 'csv' ) as $ blockName => $ importBlock ) { $ themeBuilder -> block ( $ blockName ) ; } } | Run all blocks from import csv as they may not have be found and rendered in the theme files |
19,390 | private function configureGet ( Get $ operation , array $ options ) { if ( ! $ operation -> summary ) { if ( $ options [ 'returns' ] == Route :: RETURNS_ENTITY ) { $ operation -> summary = 'Fetch a ' . $ options [ 'entity_name' ] . ' entity' ; } else { $ operation -> summary = 'Fetch a collection of ' . $ options [ 'en... | Configure a Get annotation with FosRest data . |
19,391 | private function configurePost ( Post $ operation , array $ options ) { if ( ! $ operation -> summary ) { $ operation -> summary = 'Create a ' . $ options [ 'entity_name' ] . ' entity' ; } if ( ! isset ( $ operation -> parameters [ 'body' ] ) ) { $ operation -> parameters [ ] = new Parameter ( [ 'parameter' => 'body' ,... | Configure a Post annotation with FosRest data . |
19,392 | private function configurePut ( Put $ operation , array $ options ) { if ( ! $ operation -> summary ) { $ operation -> summary = 'Edit a ' . $ options [ 'entity_name' ] . ' entity' ; } if ( ! isset ( $ operation -> parameters [ 'body' ] ) ) { $ operation -> parameters [ ] = new Parameter ( [ 'parameter' => 'body' , 'in... | Configure a Put annotation with FosRest data . |
19,393 | private function configurePatch ( Patch $ operation , array $ options ) { if ( ! $ operation -> summary ) { $ operation -> summary = 'Edit fields of a ' . $ options [ 'entity_name' ] . ' entity' ; } if ( ! isset ( $ operation -> parameters [ 'body' ] ) ) { $ operation -> parameters [ ] = new Parameter ( [ 'parameter' =... | Configure a Patch annotation with FosRest data . |
19,394 | private function configureDelete ( Delete $ operation , array $ options ) { if ( ! $ operation -> summary ) { $ operation -> summary = 'Delete a ' . $ options [ 'entity_name' ] . ' entity' ; } $ this -> appendResponses ( $ operation , [ new Response ( [ 'response' => 204 , 'description' => 'Entity Deleted' , ] ) , new ... | Configure a Delete annotation with FosRest data . |
19,395 | private function appendResponses ( Operation $ operation , array $ newResponses ) { foreach ( $ newResponses as $ newResponse ) { if ( ! $ operation -> responses ) { $ operation -> responses = [ ] ; } $ hasResponse = false ; foreach ( $ operation -> responses as $ response ) { if ( $ response -> response == $ newRespon... | Append responses onto an operation checking first if they are already configured . |
19,396 | public function addItem ( $ name , \ SlimStarter \ Menu \ MenuItem $ item ) { $ this -> items [ $ name ] = $ item ; } | Add new item to menuCollection |
19,397 | public function data ( $ content , $ options = [ ] ) { if ( isset ( $ options [ 'returnAll' ] ) && $ options [ 'returnAll' ] ) { return BlockSelectOption :: getOptionsArray ( $ this -> _block -> id ) ; } return parent :: data ( $ content ) ; } | Add return all option to the data function |
19,398 | public function edit ( $ content ) { if ( ! array_key_exists ( 'selectOptions' , $ this -> _editViewData ) ) { $ this -> _editViewData [ 'selectOptions' ] = [ ] ; $ selectOptions = BlockSelectOption :: where ( 'block_id' , '=' , $ this -> _block -> id ) -> get ( ) ; foreach ( $ selectOptions as $ selectOption ) { $ thi... | Display select options will fill in bg colour if hexadecimal |
19,399 | protected static function _processFolders ( $ secureFolders ) { $ secureFolders = array_filter ( is_array ( $ secureFolders ) ? $ secureFolders : explode ( ',' , $ secureFolders ) , 'trim' ) ; foreach ( $ secureFolders as $ k => $ folder ) { $ secureFolders [ $ k ] = '/' . trim ( $ folder , '/' ) ; } if ( in_array ( '/... | Remove subfolders and blank entries then return array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.