idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
26,200
protected function perform ( $ statement , array $ bindings = [ ] , $ class = null ) { $ this -> connect ( ) ; if ( empty ( $ bindings ) ) { try { if ( ( $ sth = $ this -> pdo -> query ( $ statement ) ) === false ) { throw new PDOException ( 'Execute SQL query failed!' ) ; } } catch ( PDOException $ e ) { throw new QueryException ( $ statement , $ bindings , $ statement , $ e ) ; } } else { try { $ sth = $ this -> pdo -> prepare ( $ statement ) ; foreach ( $ bindings as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key += 1 ; } if ( $ value instanceof DateTimeInterface ) { $ value = $ value -> format ( $ this -> dateFormat ) ; } else if ( $ value === false ) { $ value = 0 ; } $ type = is_int ( $ value ) ? PDO :: PARAM_INT : PDO :: PARAM_STR ; $ sth -> bindValue ( $ key , $ value , $ type ) ; } if ( $ sth -> execute ( ) === false ) { throw new PDOException ( 'Execute SQL query failed!' ) ; } } catch ( PDOException $ e ) { throw new QueryException ( $ statement , $ bindings , $ this -> dump ( $ statement , $ bindings , true ) , $ e ) ; } } if ( $ class !== null ) { $ sth -> setFetchMode ( PDO :: FETCH_CLASS , $ class ) ; } return $ sth ; }
Performs a sql statement with bound values and returns the resulting PDOStatement .
26,201
public function showWikiTemplateAction ( ) { $ view = new ViewModel ( array ( 'template' => file_get_contents ( $ this -> getOptions ( ) -> getUseCaseDokuWikiTemplate ( ) ) , 'options' => $ this -> getOptions ( ) , ) ) ; return $ view ; }
Show wiki template action
26,202
public function editWikiTemplateAction ( ) { $ templateFile = $ this -> getOptions ( ) -> getUseCaseDokuWikiTemplate ( ) ; if ( ! is_writeable ( $ templateFile ) ) { throw new \ RuntimeException ( sprintf ( 'Template file "%s" is not writeable. Please fix the file priviliges first!' , $ templateFile ) ) ; } $ request = $ this -> getRequest ( ) ; $ form = $ this -> getServiceLocator ( ) -> get ( 'dlcusecase_editwikitemplate_form' ) ; if ( $ request -> getQuery ( ) -> get ( 'redirect' ) ) { $ redirect = $ request -> getQuery ( ) -> get ( 'redirect' ) ; } else { $ redirect = false ; } $ redirectUrl = $ this -> url ( ) -> fromRoute ( $ this -> getRouteIdentifierPrefix ( ) . '/edit-wiki-template' ) . ( $ redirect ? '?redirect=' . $ redirect : '' ) ; $ prg = $ this -> prg ( $ redirectUrl , true ) ; if ( $ prg instanceof Response ) { return $ prg ; } elseif ( $ prg === false ) { return array ( 'form' => $ form , 'options' => $ this -> getOptions ( ) , ) ; } $ post = $ prg ; $ redirect = isset ( $ prg [ 'redirect' ] ) ? $ prg [ 'redirect' ] : null ; $ form -> setData ( $ post ) ; if ( ! $ form -> isValid ( ) ) { return array ( 'options' => $ this -> getOptions ( ) , 'form' => $ form , 'redirect' => $ redirect , ) ; } $ formData = $ form -> getData ( ) ; file_put_contents ( $ this -> getOptions ( ) -> getUseCaseDokuWikiTemplate ( ) , $ formData [ 'wiki-template' ] ) ; return $ this -> redirect ( ) -> toUrl ( $ this -> url ( ) -> fromRoute ( $ this -> getRouteIdentifierPrefix ( ) . '/show-wiki-template' ) . ( $ redirect ? '?redirect=' . $ redirect : '' ) ) ; }
Edit wiki template action
26,203
protected static function _discover_tasks ( ) { $ result = array ( ) ; $ files = \ Finder :: instance ( ) -> list_files ( 'tasks' ) ; if ( count ( $ files ) > 0 ) { foreach ( $ files as $ file ) { $ task_name = str_replace ( '.php' , '' , basename ( $ file ) ) ; $ class_name = '\\Fuel\\Tasks\\' . $ task_name ; require $ file ; $ reflect = new \ ReflectionClass ( $ class_name ) ; $ methods = $ reflect -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ result [ $ task_name ] = array ( ) ; if ( count ( $ methods ) > 0 ) { foreach ( $ methods as $ method ) { strpos ( $ method -> name , '_' ) !== 0 and $ result [ $ task_name ] [ ] = $ method -> name ; } } } } return $ result ; }
Find all of the task classes in the system and use reflection to discover the commands we can call .
26,204
public function load_options ( string $ options ) { $ reflect = new \ ReflectionClass ( $ options ) ; $ options = $ reflect -> getConstants ( ) ; foreach ( $ options as $ option => $ default ) { $ key = strtolower ( $ option ) ; $ env = getenv ( $ option ) ; $ this -> options [ $ key ] = get_option ( $ key , $ default ) ; $ this -> options [ $ key ] = ! $ env ? $ this -> options [ $ key ] : $ env ; } }
Load required options
26,205
public function update_version ( ) { $ option = $ this -> slug . '_version' ; $ old_version = get_option ( $ option ) ; if ( false === $ old_version || version_compare ( $ old_version , $ this -> version , '<' ) ) { return update_option ( $ option , $ this -> version ) ; } return true ; }
Updates the version of the plugin
26,206
function it_throws_an_exception_when_attempting_to_register_the_same_type_twice ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> shouldThrow ( new ResourceHandlerAlreadyDefinedException ( 'An handler for resource "decimal" has already been registered.' ) ) -> duringSetType ( 'decimal' , $ converter ) ; }
It throws an exception when attempting to register the same type twice .
26,207
function it_converts_and_normalizes_values_from_pg ( $ converter , $ normalizer ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> fromPg ( '1.66180339887' , 'decimal' ) -> shouldBeLike ( ( object ) [ 'value' => 1.66180339887 ] ) ; }
It converts and normalizes values from pg .
26,208
function it_converts_and_normalizes_sets_from_pg ( $ converter , $ normalizer ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> fromPg ( [ '3.14159265359' , '1.66180339887' ] , 'decimal[]' ) -> shouldBeLike ( [ ( object ) [ 'value' => 3.14159265359 ] , ( object ) [ 'value' => 1.66180339887 ] ] ) ; }
It converts and normalizes sets from pg .
26,209
function it_converts_and_normalizes_nested_sets_from_pg ( $ converter , $ normalizer ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> fromPg ( [ [ '3.14159265359' ] , [ '1.66180339887' ] ] , 'decimal[][]' ) -> shouldBeLike ( [ [ ( object ) [ 'value' => 3.14159265359 ] ] , [ ( object ) [ 'value' => 1.66180339887 ] ] ] ) ; }
It converts and normalizes nested sets from pg .
26,210
function it_converts_rows_from_pg ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> setCompositeType ( 'real' , [ 'pi' => 'decimal' , 'phi' => 'decimal' ] ) ; $ this -> fromPg ( [ 'pi' => '3.14159265359' , 'phi' => '1.66180339887' ] , 'real' ) -> shouldBeLike ( [ 'pi' => 3.14159265359 , 'phi' => 1.66180339887 ] ) ; }
It converts rows from pg .
26,211
function it_converts_and_normalizes_rows_from_pg ( $ converter , $ normalizer ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> setCompositeType ( 'real' , [ 'pi' => 'decimal' , 'phi' => 'decimal' ] ) ; $ this -> fromPg ( [ 'pi' => '3.14159265359' , 'phi' => '1.66180339887' ] , 'real' ) -> shouldBeLike ( [ 'pi' => ( object ) [ 'value' => 3.14159265359 ] , 'phi' => ( object ) [ 'value' => 1.66180339887 ] ] ) ; }
It converts and normalizes rows from pg .
26,212
function it_converts_values_to_pg ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> toPg ( 1.66180339887 , 'decimal' ) -> shouldBeLike ( new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ) ; }
It converts values to pg
26,213
function it_converts_and_normalizes_values_to_pg ( $ normalizer , $ converter ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> toPg ( ( object ) [ 'value' => 1.66180339887 ] , 'decimal' ) -> shouldBeLike ( new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ) ; }
It converts and normalizes values to pg
26,214
function it_converts_sets_to_pg ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> toPg ( [ 3.14159265359 , 1.66180339887 ] , 'decimal[]' ) -> shouldBeLike ( new Set ( [ new Value ( '3.14159265359' , new Type ( 'decimal' ) ) , new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) ) ; }
It converts sets to pg .
26,215
function it_converts_and_normalizes_sets_to_pg ( $ normalizer , $ converter ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> toPg ( [ ( object ) [ 'value' => 3.14159265359 ] , ( object ) [ 'value' => 1.66180339887 ] ] , 'decimal[]' ) -> shouldBeLike ( new Set ( [ new Value ( '3.14159265359' , new Type ( 'decimal' ) ) , new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) ) ; }
It converts and normalizes sets to pg .
26,216
function it_converts_nested_sets_to_pg ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> toPg ( [ [ 3.14159265359 ] , [ 1.66180339887 ] ] , 'decimal[][]' ) -> shouldBeLike ( new Set ( [ new Set ( [ new Value ( '3.14159265359' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) , new Set ( [ new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) ] , new ArrayType ( new ArrayType ( new Type ( 'decimal' ) ) ) ) ) ; }
It converts nested sets to pg .
26,217
function it_converts_and_normalizes_nested_sets_to_pg ( $ normalizer , $ converter ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> toPg ( [ [ ( object ) [ 'value' => 3.14159265359 ] ] , [ ( object ) [ 'value' => 1.66180339887 ] ] ] , 'decimal[][]' ) -> shouldBeLike ( new Set ( [ new Set ( [ new Value ( '3.14159265359' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) , new Set ( [ new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new ArrayType ( new Type ( 'decimal' ) ) ) ] , new ArrayType ( new ArrayType ( new Type ( 'decimal' ) ) ) ) ) ; }
It converts and normalizes nested sets to pg .
26,218
function it_converts_rows_to_pg ( $ converter ) { $ this -> setType ( 'decimal' , $ converter ) ; $ this -> setCompositeType ( 'real' , [ 'pi' => 'decimal' , 'phi' => 'decimal' ] ) ; $ this -> toPg ( [ 'pi' => 3.14159265359 , 'phi' => 1.66180339887 ] , 'real' ) -> shouldBeLike ( new Row ( [ 'pi' => new Value ( '3.14159265359' , new Type ( 'decimal' ) ) , 'phi' => new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new Type ( 'real' ) ) ) ; }
It converts rows to pg .
26,219
function it_converts_and_normalizes_rows_to_pg ( $ normalizer , $ converter ) { $ this -> setType ( 'decimal' , $ converter , $ normalizer ) ; $ this -> setCompositeType ( 'real' , [ 'pi' => 'decimal' , 'phi' => 'decimal' ] ) ; $ this -> toPg ( [ 'pi' => ( object ) [ 'value' => 3.14159265359 ] , 'phi' => ( object ) [ 'value' => 1.66180339887 ] ] , 'real' ) -> shouldBeLike ( new Row ( [ 'pi' => new Value ( '3.14159265359' , new Type ( 'decimal' ) ) , 'phi' => new Value ( '1.66180339887' , new Type ( 'decimal' ) ) ] , new Type ( 'real' ) ) ) ; }
It converts and normalizes rows to pg .
26,220
public function valueLookup ( $ key ) { $ value = false ; if ( array_key_exists ( $ key , $ this -> array ) ) { $ value = $ this -> array [ $ key ] ; } return $ value ; }
Returns the value corresponding with a supplied key ; returns FALSE if the supplied key does not exist within the array .
26,221
public function close ( ) { $ html = $ this -> wrapUp ( 'table' ) . "\n" ; $ this -> head = false ; $ this -> foot = false ; $ this -> body = false ; $ this -> cell = '' ; $ this -> vars = '' ; return $ html . '</table>' ; }
Closes any remaining open tags .
26,222
private function wrapUp ( $ section ) { $ html = $ this -> cell ; $ this -> cell = '' ; switch ( $ section ) { case 'head' : if ( $ this -> head ) { $ html .= '</tr>' ; } else { if ( $ this -> foot ) { $ html .= '</tr></tfoot>' ; $ this -> foot = false ; } elseif ( $ this -> body ) { $ html .= '</tr></tbody>' ; $ this -> body = false ; } $ html .= '<thead>' ; } break ; case 'foot' : if ( $ this -> foot ) { $ html .= '</tr>' ; } else { if ( $ this -> head ) { $ html .= '</tr></thead>' ; $ this -> head = false ; } elseif ( $ this -> body ) { $ html .= '</tr></tbody>' ; $ this -> body = false ; } $ html .= '<tfoot>' ; } break ; case 'row' : if ( $ this -> body ) { $ html .= '</tr>' ; } else { if ( $ this -> head ) { $ html .= '</tr></thead>' ; $ this -> head = false ; } elseif ( $ this -> foot ) { $ html .= '</tr></tfoot>' ; $ this -> foot = false ; } $ html .= '<tbody>' ; } break ; case 'table' : if ( $ this -> head ) { $ html .= '</tr></thead>' ; } elseif ( $ this -> foot ) { $ html .= '</tr></tfoot>' ; } elseif ( $ this -> body ) { $ html .= '</tr></tbody>' ; } break ; } return $ html ; }
Closes a row s open tags to be ready for the next one .
26,223
protected function put ( $ line = '' , $ eol = PHP_EOL ) { $ this -> m -> shell -> put ( $ line , $ eol ) ; }
Print a line of text to standard output .
26,224
public function remove ( Closure $ criteria ) { foreach ( $ this -> members as $ k => $ member ) { if ( $ criteria ( $ member ) ) { unset ( $ this -> members [ $ k ] ) ; } } $ this -> members = array_values ( $ this -> members ) ; return $ this ; }
If criteria returns a non - empty value that member is removed .
26,225
protected function addgroup_database ( ) { $ this -> registerGroup ( BLang :: _ ( 'ADMIN_CONFIG_GENERAL_MYSQL' ) , 'database' , array ( new BConfigFieldString ( 'MYSQL_DB_HOST' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_MYSQL_DBHOST' ) , '127.0.0.1' ) , new BConfigFieldString ( 'MYSQL_DB_USERNAME' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_MYSQL_DBUSERNAME' ) , 'root' ) , new BConfigFieldPassword ( 'MYSQL_DB_PASSWORD' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_MYSQL_DBPASSWORD' ) , '' ) , new BConfigFieldString ( 'MYSQL_DB_NAME' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_MYSQL_DBNAME' ) , 'vidido' ) ) ) ; }
Adding the group of database settings - MySQL host username password and database name
26,226
protected function addgroup_email ( ) { $ this -> registerGroup ( BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL' ) , 'email' , array ( new BConfigFieldString ( 'EMAIL_SEND_EFROM' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL_SENDEFROM' ) , 'noreply@vidido.ua' ) , new BConfigFieldString ( 'EMAIL_SEND_NFROM' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL_SENDNFROM' ) , 'Vid i DO noreply' ) , new BConfigFieldList ( 'EMAIL_SEND_TYPE' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE' ) , array ( 1 => BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE1' ) , 2 => BLang :: _ ( 'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE2' ) ) ) , ) ) ; }
Adding the group of email & contacts settings
26,227
protected function addgroup_hostnames ( ) { $ this -> registerGroup ( BLang :: _ ( 'ADMIN_CONFIG_GENERAL_HOSTNAMES' ) , 'hostnames' , array ( new BConfigFieldString ( 'BHOSTNAME' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_BHOSTNAME' ) , 'vidido.ua' ) , new BConfigFieldString ( 'BHOSTNAME_STATIC' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_BHOSTNAME_STATIC' ) , 'static.vidido.ua' ) , new BConfigFieldString ( 'BHOSTNAME_MEDIA' , BLang :: _ ( 'ADMIN_CONFIG_GENERAL_BHOSTNAME_MEDIA' ) , 'media.vidido.ua' ) ) ) ; }
Adding fields group with hostnames
26,228
public function compile ( $ template , $ data ) { foreach ( $ data as $ key => $ value ) { if ( ! is_string ( $ value ) ) { continue ; } $ template = preg_replace ( "/\\$$key\\$/i" , $ value , $ template ) ; } return preg_replace ( '/(<?php)/' , "$1\n" . $ this -> renderBanner ( ) , $ template , 1 ) ; }
Compiles a template using the given data .
26,229
public function canCreate ( \ Interop \ Container \ ContainerInterface $ container , $ requestedName ) { $ this -> getConfig ( $ container , $ requestedName ) ; return isset ( $ this -> dependencies [ $ requestedName ] ) ; }
Factory can create the service if there is a key for it in the config
26,230
protected function initNodeTrait ( ? NodeInterface $ parent = null , ? string $ name = null ) { $ this -> nodeName = $ name ?? spl_object_hash ( $ this ) ; if ( ! $ parent ) { $ this -> nodeRoot = $ this ; $ this -> nodeParent = $ this ; } else { $ this -> nodeRoot = $ parent -> getRoot ( ) ; $ this -> nodeParent = $ parent ; $ parent -> addChild ( $ this ) ; } }
Call this function in the constructor .
26,231
public function play ( PlayerId $ playerId , Move $ move ) { $ playMethod = 'play' . $ this -> getClassName ( $ move ) ; if ( ! method_exists ( $ this , $ playMethod ) ) { throw new IllegalMoveException ( $ move , 'Error: move was not recognized!' ) ; } return $ this -> $ playMethod ( $ playerId , $ move ) ; }
Allows the player to play the game
26,232
public function insertRow ( $ row ) : void { if ( $ this -> connection === null ) { throw new \ RuntimeException ( 'Copying already ended. Create a new object' ) ; } if ( is_array ( $ row ) ) { $ row = $ this -> escape ( $ row ) ; } $ wynik = @ pg_put_line ( $ this -> connection , $ row ) ; if ( $ wynik === false ) { throw new \ RuntimeException ( 'Failed to insert the row' ) ; } }
Ingests a row of data .
26,233
public static function initialize ( $ startSession = true ) { \ ini_set ( 'session.gc_maxlifetime' , self :: SessionCookieGcTimeout + self :: SessionCookieLifetime ) ; \ session_set_cookie_params ( self :: SessionCookieLifetime , self :: SessionCookiePath ) ; \ session_start ( ) ; \ register_shutdown_function ( 'session_write_close' ) ; }
Initializes the database
26,234
protected function starting ( ) : void { $ this -> agg = ( new Aggregator ( $ this ) ) -> start ( ) ; $ this -> out = ( new Prometheus ( $ this -> host , $ this -> app , $ this -> agg ) ) -> start ( $ this -> listener , $ this -> gateway ) ; $ this -> cls = ( new Cleaner ( $ this ) ) -> start ( ) ; }
triggered when process started
26,235
protected function stopping ( Promised $ wait ) : void { $ this -> cls -> stop ( ) ; $ this -> out -> stop ( ) ; $ this -> agg -> stop ( ) -> sync ( $ wait ) ; }
triggered when process exiting
26,236
public static function image ( $ width = '120' , $ height = '40' , $ characters = '6' ) { $ font = __DIR__ . '/../' . static :: $ font ; $ code = static :: generateCode ( $ characters ) ; \ Asgard \ Container \ Container :: singleton ( ) [ 'httpKernel' ] -> getRequest ( ) -> session -> set ( 'captcha' , $ code ) ; $ font_size = $ height * 0.75 ; if ( ! $ image = imagecreate ( $ width , $ height ) ) throw new Exception ( 'Cannot initialize new GD image stream' ) ; $ background_color = imagecolorallocate ( $ image , 255 , 255 , 255 ) ; $ text_color = imagecolorallocate ( $ image , 20 , 40 , 100 ) ; $ noise_color = imagecolorallocate ( $ image , 100 , 120 , 180 ) ; for ( $ i = 0 ; $ i < ( $ width * $ height ) / 3 ; $ i ++ ) imagefilledellipse ( $ image , mt_rand ( 0 , $ width ) , mt_rand ( 0 , $ height ) , 1 , 1 , $ noise_color ) ; for ( $ i = 0 ; $ i < ( $ width * $ height ) / 150 ; $ i ++ ) imageline ( $ image , mt_rand ( 0 , $ width ) , mt_rand ( 0 , $ height ) , mt_rand ( 0 , $ width ) , mt_rand ( 0 , $ height ) , $ noise_color ) ; if ( ! $ textbox = imagettfbbox ( $ font_size , 0 , $ font , $ code ) ) throw new Exception ( 'Error in imagettfbbox function' ) ; $ x = ( $ width - $ textbox [ 4 ] ) / 2 ; $ y = ( $ height - $ textbox [ 5 ] ) / 2 ; if ( ! imagettftext ( $ image , $ font_size , 0 , $ x , $ y , $ text_color , $ font , $ code ) ) throw new Exception ( 'Error in imagettftext function' ) ; return $ image ; }
Generates a captcha image .
26,237
public function getFile ( string $ path ) : File { if ( $ this -> isDir ( $ path ) ) { throw new NotAFileException ( $ path ) ; } return $ this -> instantiateFile ( $ path ) ; }
Gets a file from the storage medium
26,238
public function getDirectory ( string $ path ) : Directory { if ( $ this -> isFile ( $ path ) ) { throw new NotADirectoryException ( $ path ) ; } return $ this -> instantiateDir ( $ path ) ; }
Gets a directory from the storage medium
26,239
public function make ( $ host ) { $ host = $ this -> resolver -> resolve ( $ host , '/' ) ; $ hash = md5 ( $ host ) ; if ( isset ( $ this -> instances [ $ hash ] ) ) { return $ this -> instances [ $ hash ] ; } $ dir = sprintf ( '%s/%s' , rtrim ( $ this -> cacheDir , '/' ) , $ hash ) ; $ instance = new Loader ( new FileCache ( sprintf ( '%s/definitions.php' , $ dir ) ) , $ this -> resolver , $ this -> builder , $ this -> http , $ this -> validator ) ; $ this -> instances [ $ hash ] = $ instance ; return $ instance ; }
Create a loader for a given host
26,240
public function findOneForHubIdAndStartTime ( $ hub_id , $ start_time ) { $ qb = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) -> from ( 'HarvestCloudCoreBundle:SellerWindow' , 'pw' ) -> select ( 'pw' ) -> where ( 'pw.start_time = :start_time' ) -> andWhere ( 'pw.start_time > :now' ) -> setParameter ( 'start_time' , date ( 'Y-m-d H:i:s' , $ start_time ) ) -> setParameter ( 'now' , date ( 'Y-m-d H:i:s' ) ) ; $ q = $ qb -> getQuery ( ) ; return $ q -> getOneOrNullResult ( ) ; }
Find for hub_id and datetime
26,241
public function findUpcomingForSeller ( Profile $ seller ) { $ em = $ this -> getEntityManager ( ) ; $ q = $ em -> createQuery ( ' SELECT w FROM HarvestCloudCoreBundle:SellerWindow w LEFT JOIN w.sellerHubRef shr LEFT JOIN shr.hub h WHERE shr.seller = :seller AND w.end_time >= :now ' ) -> setParameter ( 'seller' , $ seller ) -> setParameter ( 'now' , date ( 'Y-m-d H:i:s' ) ) ; return $ q -> getResult ( ) ; }
Find upcoming for a given Seller
26,242
private function saveTicket ( $ ticket , $ expire ) { $ data = [ 'ticket' => $ ticket , 'expire' => intval ( $ expire ) , 'time' => time ( ) ] ; return ( $ this -> getFileSystem ( ) -> put ( $ this -> getTicketFilePath ( ) , serialize ( $ data ) , true ) > 0 ) ; }
save js api ticket to file
26,243
private function readTicket ( ) { if ( ! $ this -> getFileSystem ( ) -> isFile ( $ this -> getTicketFilePath ( ) ) ) { return '' ; } $ content = trim ( $ this -> getFileSystem ( ) -> get ( $ this -> getTicketFilePath ( ) ) ) ; $ result = unserialize ( $ content ) ; if ( isset ( $ result [ 'ticket' ] ) && isset ( $ result [ 'expire' ] ) && isset ( $ result [ 'time' ] ) ) { $ expireTime = $ result [ 'time' ] + $ result [ 'expire' ] - self :: EXPIRE_SUB_TIME ; if ( $ expireTime > time ( ) ) { return $ result [ 'ticket' ] ; } } return '' ; }
read js api ticket from file
26,244
public function validate ( ) { if ( $ this -> initializer ) { Ensure :: isFalse ( $ this -> initializer -> getRepository ( ) && $ this -> initializer -> getValue ( ) , 'It makes no sense to define initializer repository and value simultaneously for column [%s]' , $ this -> name ) ; } }
Throws an exception if the settings are inconsistent .
26,245
public function getEditableDataString ( ) { $ valuePairs = array ( ) ; if ( $ this -> values ) { foreach ( $ this -> values as $ value ) { $ valuePairs [ ] = '\'' . $ value [ 'label' ] . '\':\'' . $ value [ 'value' ] . '\'' ; } } return '{' . join ( ', ' , $ valuePairs ) . '}' ; }
Returns the viewType specific data string for the editable plugin .
26,246
public function update ( Client $ client ) { $ this -> getEntityManager ( ) -> persist ( $ client ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Update a client in the DB
26,247
public function delete ( Client $ client ) { $ this -> getEntityManager ( ) -> remove ( $ client ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Remove a client from the databasee
26,248
public function setDisabledDates ( $ dates ) { if ( ! is_array ( $ dates ) ) { $ dates = ( array ) $ dates ; } $ this -> option_disabled_dates = $ dates ; $ this -> set_options [ 'disabled_dates' ] = 'disabledDates' ; return $ this ; }
Sets disabled dates . Accepts a single date or a list of dates in an array .
26,249
public function setEnabledDates ( $ dates ) { if ( ! is_array ( $ dates ) ) { $ dates = ( array ) $ dates ; } $ this -> option_enabled_dates = $ dates ; $ this -> set_options [ 'enablede_dates' ] = 'enabledDates' ; return $ this ; }
Sets enabled dates . Accepts a single date or a list of dates in an array .
26,250
public function showToday ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_show_today = is_bool ( $ bool ) ? $ bool : false ; $ this -> set_options [ 'show_today' ] = 'showToday' ; return $ this ; } else { return $ this -> option_show_today ; } }
Set flag to use or not use the show today button . This option is true by default . Calling this method without parameter returns the currently set value .
26,251
public function useCurrent ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_use_current = is_bool ( $ bool ) ? $ bool : false ; $ this -> set_options [ 'use_current' ] = 'useCurrent' ; return $ this ; } else { return $ this -> option_show_today ; } }
Set flag to use or not use the current button . This option is true by default . Calling this method without parameter returns the currently set value .
26,252
public function usePickDate ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_pick_date = ( bool ) $ bool ; $ this -> set_options [ 'pick_date' ] = 'pickDate' ; return $ this ; } else { return $ this -> option_pick_date ; } }
Set flag for using datepicker . This option is true by default . Calling this method without parameter returns the currently set value .
26,253
public function usePickTime ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_pick_time = ( bool ) $ bool ; $ this -> set_options [ 'pick_time' ] = 'pickTime' ; return $ this ; } else { return $ this -> option_pick_time ; } }
Set flag for using timepicker . This option is true by default . Calling this method without parameter returns the currently set value .
26,254
public function useMinutes ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_use_minutes = ( bool ) $ bool ; $ this -> set_options [ 'use_minutes' ] = 'useMinutes' ; return $ this ; } else { return $ this -> option_use_minutes ; } }
Set flag to use or not use minutes in timepicker . This option is true by default . Calling this method without parameter returns the currently set value .
26,255
public function useSeconds ( $ bool = null ) { if ( isset ( $ bool ) ) { $ this -> option_use_seconds = ( bool ) $ bool ; $ this -> set_options [ 'use_seconds' ] = 'useSeconds' ; return $ this ; } else { return $ this -> option_use_seconds ; } }
Set flag to use or not use saeconds int timepicker . This option is true by default . Calling this method without parameter returns the currently set value .
26,256
public function setLocale ( string $ locale ) : DateTimePicker { $ this -> option_locale = $ locale ; $ this -> set_options [ 'locale' ] = 'locale' ; return $ this ; }
Sets locale to use
26,257
public static function pageURL ( ) { $ URL = "http" ; if ( ! empty ( $ _SERVER [ "HTTPS" ] ) && $ _SERVER [ "HTTPS" ] == "on" ) { $ URL .= "s" ; } $ URL .= "://" . $ _SERVER [ "SERVER_NAME" ] ; if ( $ _SERVER [ "SERVER_PORT" ] != "80" ) { $ URL .= ":" . $ _SERVER [ "SERVER_PORT" ] ; } $ URL .= $ _SERVER [ "REQUEST_URI" ] ; return $ URL ; }
Returns URL of page where function is called .
26,258
public function addOption ( $ name , $ defaultValue , $ necessary = false ) { $ this -> defValues [ $ name ] = $ defaultValue ; if ( $ necessary ) $ this -> necessary [ $ name ] = true ; }
Add an option that this code might have or must have
26,259
protected function generateJqueryCode ( $ selector , $ function ) { $ code = '$( "' . $ selector . '" ).' . $ function . '(' ; $ optionsShown = false ; foreach ( $ this -> necessary as $ pname => $ v ) { $ pvalue = $ this -> getParam ( $ pname ) ; if ( $ pvalue == null ) $ pvalue = $ this -> defValues [ $ pname ] ; if ( ! empty ( $ pvalue ) && $ pvalue != "" ) { if ( ! $ optionsShown ) { $ code .= '{' ; $ optionsShown = true ; } else $ code .= ',' ; $ code .= "\n $pname : \"$pvalue\"" ; } } foreach ( $ this -> getParams ( ) as $ pname => $ pvalue ) { if ( ( ! isset ( $ this -> necessary [ $ pname ] ) && isset ( $ this -> defValues [ $ pname ] ) ) || ( isset ( $ this -> defValues [ $ pname ] ) && strtoupper ( $ this -> defValues [ $ pname ] ) != strtoupper ( $ pvalue ) ) ) { if ( ! empty ( $ pvalue ) && $ pvalue != "" ) { if ( ! $ optionsShown ) { $ code .= '{' ; $ optionsShown = true ; } else $ code .= ',' ; unset ( $ necessary [ $ pname ] ) ; $ code .= "\n $pname : $pvalue" ; } } } if ( $ optionsShown ) $ code .= "\n}" ; $ code .= ');' ; return $ code ; }
Generates the jquery code with default values as well
26,260
public function prepareDisplay ( ) { if ( $ this -> id == null && $ this -> class == null ) { $ this -> id = ( String ) ( new \ OWeb \ utils \ IdGenerator ( ) ) ; $ displayId = 'id="' . $ this -> id . '"' ; $ jid = "#" . $ this -> id ; } else if ( $ this -> id == null ) { $ displayId = 'class="' . $ this -> class . '"' ; $ jid = "." . $ this -> class ; } else { $ displayId = 'id="' . $ this -> id . '"' ; $ jid = "#" . $ this -> id ; } if ( $ this -> function == null ) { $ ex = new \ OWeb \ Exception ( "When creating a Jquery Code Generator you need to call setCallFunction to set up the function that needs to be called" ) ; $ ex = new \ OWeb \ types \ UserException ( $ this -> l ( "Function unset Error Title" ) , 0 , $ ex ) ; $ ex -> setUserDescription ( $ this -> l ( "Function unset Error Desc" ) ) ; throw $ ex ; } $ this -> view -> id = $ displayId ; return $ jid ; }
Makes the necessary verifications to see if the Controller can be displayed . Will also generate the selector for the jquery call as well as the code needed for it in the html code
26,261
public function checkAcl ( $ privilege ) { $ moduleName = substr ( get_class ( $ this ) , 0 , strpos ( get_class ( $ this ) , '\\' ) ) ; $ config = $ this -> getServiceLocator ( ) -> get ( 'Config' ) ; $ baseName = $ config [ 'jaztec_acl' ] [ 'name' ] [ $ moduleName ] ; $ allowed = $ this -> getAclService ( ) -> isAllowed ( $ this -> getRole ( ) , $ this -> aclDenominator , $ privilege , $ baseName ) ; return $ allowed ; }
Checks the ACL registry .
26,262
public function store ( $ username , $ should_propagate_password = null , $ password = null , $ account_id = null , $ account_identifier = null , $ account_username = null , $ expires_at = null , $ disabled = null ) { $ fields = [ ] ; $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ should_propagate_password ) ) $ fields [ 'should_propagate_password' ] = $ should_propagate_password ; if ( ! is_null ( $ password ) ) $ fields [ 'password' ] = $ password ; if ( ! is_null ( $ account_id ) ) $ fields [ 'account_id' ] = $ account_id ; if ( ! is_null ( $ account_identifier ) ) $ fields [ 'account_identifier' ] = $ account_identifier ; if ( ! is_null ( $ account_username ) ) $ fields [ 'account_username' ] = $ account_username ; if ( ! is_null ( $ expires_at ) ) $ fields [ 'expires_at' ] = strftime ( '%F %R' , $ expires_at ) ; if ( ! is_null ( $ disabled ) ) $ fields [ 'disabled' ] = $ disabled ; return $ this -> _post ( $ fields ) ; }
Store Alias Account
26,263
protected function resolveTemplate ( $ controller , $ moduleNamespace ) { $ class = get_class ( $ controller ) ; $ server = $ this -> getServer ( ) ; $ request = $ server -> getRequest ( ) ; $ action = $ request -> getAttribute ( 'action' , 'index' ) ; if ( 0 !== strpos ( $ class , $ moduleNamespace ) ) { throw new UnexpectedValueException ( sprintf ( 'The View Model of Controller "%s" returned unexpected module ' . 'namespace "%s". If you want to use this module namespace, ' . 'you need manually set a template to View Model.' , $ class , $ moduleNamespace ) ) ; } $ subNamespace = substr ( $ class , strlen ( $ moduleNamespace ) + 1 ) ; $ subNamespace = str_replace ( 'Controller' , '' , $ subNamespace ) ; $ subNamespace = str_replace ( '\\\\' , '\\' , $ subNamespace ) ; $ path = str_replace ( '\\' , '/' , $ subNamespace ) . '/' . $ action ; $ template = strtolower ( preg_replace ( '/([a-zA-Z])(?=[A-Z])/' , '$1-' , $ path ) ) ; return $ template ; }
Resolves template for received controller .
26,264
function mf_post_add_metaboxes ( ) { global $ post , $ mf_post_values ; if ( ! isset ( $ post ) ) { return false ; } $ mf_post_values = $ this -> mf_get_post_values ( $ post -> ID ) ; $ post_types = $ this -> mf_get_post_types ( array ( ) , 'names' ) ; foreach ( $ post_types as $ post_type ) { if ( post_type_supports ( $ post_type , 'page-attributes' ) && $ post_type != 'page' ) { add_meta_box ( 'mf_template_attribute' , __ ( 'Template' ) , array ( & $ this , 'mf_metabox_template' ) , $ post_type , 'side' , 'default' ) ; } if ( ! mf_custom_fields :: has_fields ( $ post_type ) ) { continue ; } $ groups = $ this -> get_groups_by_post_type ( $ post_type ) ; foreach ( $ groups as $ group ) { if ( $ this -> group_has_fields ( $ group [ 'id' ] ) ) { add_meta_box ( 'mf_' . $ group [ 'id' ] , $ group [ 'label' ] , array ( & $ this , 'mf_metabox_content' ) , $ post_type , 'normal' , 'default' , array ( 'group_info' => $ group ) ) ; } } } }
Adding the metaboxes
26,265
function mf_metabox_content ( $ post , $ metabox ) { global $ mf_domain , $ mf_post_values ; $ custom_fields = $ this -> get_custom_fields_by_group ( $ metabox [ 'args' ] [ 'group_info' ] [ 'id' ] ) ; $ group_id = $ metabox [ 'args' ] [ 'group_info' ] [ 'id' ] ; ?> <div class="mf-group-wrapper group- <?php print $ group_id ; ?> " id="mf_group- <?php print $ group_id ; ?> " > <!-- grupos se puede repetir <?php $ extraclass = "" ; if ( $ metabox [ 'args' ] [ 'group_info' ] [ 'duplicated' ] ) { $ extraclass = "mf_duplicate_group" ; $ repeated_groups = $ this -> mf_get_duplicated_groups ( $ post -> ID , $ group_id ) ; } else { $ repeated_groups = 1 ; } for ( $ group_index = 1 ; $ group_index <= $ repeated_groups ; $ group_index ++ ) { $ only = ( $ repeated_groups == 1 ) ? TRUE : FALSE ; $ this -> mf_draw_group ( $ metabox , $ extraclass , $ group_index , $ custom_fields , $ mf_post_values , $ only ) ; } printf ( '<input value="%d" id="mf_group_counter_%d" style="display:none" >' , $ repeated_groups , $ group_id ) ; ?> <!-- fin del grupo <?php }
Fill a metabox with custom fields
26,266
function mf_get_post_values ( $ post_id ) { global $ wpdb ; $ raw = $ wpdb -> get_results ( "SELECT mfpm.meta_id, mfpm.field_name, mfpm.field_count, mfpm.group_count, pm.meta_value FROM " . MF_TABLE_POST_META . " as mfpm LEFT JOIN " . $ wpdb -> postmeta . " as pm ON ( mfpm.meta_id = pm.meta_id ) WHERE mfpm.post_id = " . $ post_id ) ; $ data = array ( ) ; foreach ( $ raw as $ key => $ field ) { $ data [ $ field -> field_name ] [ $ field -> group_count ] [ $ field -> field_count ] = $ field -> meta_value ; } return $ data ; }
retrieve the custom fields values of a certain post
26,267
function mf_metabox_template ( ) { global $ post ; if ( 0 != count ( get_page_templates ( ) ) ) { $ template = get_post_meta ( $ post -> ID , '_wp_mf_page_template' , TRUE ) ; $ template = ( $ template != '' ) ? $ template : false ; ?> <label class="screen-reader-text" for="page_template"> <?php _e ( 'Page Template' ) ?> </label><select name="page_template" id="page_template"> <option value='default'> <?php _e ( 'Default Template' ) ; ?> </option> <?php page_template_dropdown ( $ template ) ; ?> </select> <?php } }
MF Meta box for select template
26,268
public function setAliases ( $ aliases ) { if ( ! is_array ( $ aliases ) && ! $ aliases instanceof \ Traversable ) { throw new InvalidArgumentException ( '$aliases must be an array or an instance of \Traversable' ) ; } foreach ( $ aliases as $ alias ) { $ this -> validateName ( $ alias ) ; } $ this -> aliases = $ aliases ; return $ this ; }
Sets the aliases for the command .
26,269
protected function filterCommand ( $ command , $ tail ) { $ command = trim ( $ command ) ; if ( ! $ command ) { throw new ShellException ( 'Command cannot be empty.' ) ; } if ( $ tail && ! strpos ( $ command , $ tail ) ) { $ command .= $ tail ; } return $ command ; }
Filter command string
26,270
protected function processError ( $ output , $ exceptionOnError = true , $ exceptionClass = ShellException :: class ) { if ( $ exceptionOnError && $ this -> hadError ( ) ) { $ exceptionClass = $ exceptionClass ? : ShellException :: class ; throw new $ exceptionClass ( $ output ) ; } return $ this ; }
Process error in output
26,271
public function getAbstract ( $ length = 100 ) { $ content = $ this -> getContent ( ) ; if ( mb_strlen ( $ content ) > $ length - 3 ) { return mb_substr ( $ content , 0 , $ length - 3 ) . '...' ; } else { return $ content ; } }
get content s abstract
26,272
public function execute ( Framework $ framework , WebRequest $ request , Response $ response ) { $ this -> setTitle ( $ this -> translate ( 'Profile' , '\\Zepi\\Web\\AccessControl' ) ) ; $ menuEntry = $ this -> activateMenuEntry ( ) ; $ overviewPage = $ this -> getOverviewPageRenderer ( ) -> render ( $ framework , $ menuEntry ) ; $ response -> setOutput ( $ this -> render ( '\\Zepi\\Web\\AccessControl\\Templates\\Profile' , array ( 'overviewPage' => $ overviewPage ) ) ) ; }
Displays the profile page for an logged in user .
26,273
public function executeAction ( ) { if ( $ this -> isUsage ( ) ) return [ self :: FORWARD_ACTION , 'spec.usage' ] ; if ( $ this -> application -> isProduction ( ) && ! $ this -> response -> confirmation ( 'May I execute spec in production environment ?' ) ) { $ this -> send ( 'aborted.' ) ; return ; } $ this -> setup ( ) ; $ this -> run ( ) ; }
execute spec files .
26,274
private function setup ( ) { $ this -> runner = $ this -> specHelper -> getRunner ( ) ; $ this -> setupWorkspace ( ) ; $ this -> setupTargets ( ) ; foreach ( $ this -> application -> config ( 'spec.initializers.*' ) as $ initializer ) { $ initializer ( $ this -> application ) ; } }
set up for to run spec .
26,275
private function setupWorkspace ( ) { $ config_file_name = $ this -> runner -> getConfigurationFileName ( ) ; $ dirs = explode ( DS , getcwd ( ) ) ; $ find = false ; do { $ workspace = join ( DS , $ dirs ) ; $ config_file_path = $ workspace . DS . $ config_file_name ; if ( file_exists ( $ config_file_path ) && is_file ( $ config_file_path ) ) { $ find = true ; break ; } } while ( array_pop ( $ dirs ) ) ; if ( ! $ find ) $ workspace = getcwd ( ) ; $ this -> runner -> setWorkspace ( $ workspace ) ; }
Setup workspace .
26,276
private function setupTargets ( ) { $ args = $ this -> request -> getAsArray ( 'args' ) ; foreach ( $ args as $ arg ) { $ this -> runner -> addTarget ( realpath ( $ arg ) ) ; } }
Setup target .
26,277
public function build ( ) { $ pageFinder = new PageFinder ( $ this -> browser ) ; if ( $ this -> isWithAssertions ) { $ pageFinder = new PageFinderWithAssertions ( $ pageFinder ) ; } if ( $ this -> isWithWaits ) { $ pageFinder = new PageFinderWithWaits ( $ pageFinder , $ this -> timeOutInSeconds ) ; } return $ pageFinder ; }
Creates and returns a new PageFinder object according to the current builder state .
26,278
public static function getContainer ( $ zendServiceManager = null ) { if ( ! self :: $ container ) { self :: $ container = new SymfonyContainerWithZFFallback ( ) ; } if ( ! Module :: $ zendServiceManager && $ zendServiceManager ) { if ( $ zendServiceManager -> has ( 'serviceLocator' ) ) { $ zendServiceManager = $ zendServiceManager -> get ( 'serviceLocator' ) ; } Module :: $ zendServiceManager = $ zendServiceManager ; } return self :: $ container ; }
Returns the Symfony Container
26,279
protected function createReceiveImageMsg ( array $ data ) { $ result = new WxReceiveImageMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setMediaId ( isset ( $ data [ 'MediaId' ] ) ? trim ( $ data [ 'MediaId' ] ) : '' ) ; $ result -> setPicUrl ( isset ( $ data [ 'PicUrl' ] ) ? trim ( $ data [ 'PicUrl' ] ) : '' ) ; return $ result ; }
create image msg
26,280
protected function createReceiveLinkMsg ( array $ data ) { $ result = new WxReceiveLinkMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setTitle ( isset ( $ data [ 'Title' ] ) ? trim ( $ data [ 'Title' ] ) : '' ) ; $ result -> setDescription ( isset ( $ data [ 'Description' ] ) ? trim ( $ data [ 'Description' ] ) : '' ) ; $ result -> setUrl ( isset ( $ data [ 'Url' ] ) ? trim ( $ data [ 'Url' ] ) : '' ) ; return $ result ; }
create link msg
26,281
protected function createReceiveLocationMsg ( array $ data ) { $ result = new WxReceiveLocationMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setLocationX ( isset ( $ data [ 'Location_X' ] ) ? $ data [ 'Location_X' ] : '' ) ; $ result -> setLocationY ( isset ( $ data [ 'Location_Y' ] ) ? $ data [ 'Location_Y' ] : '' ) ; $ result -> setScale ( isset ( $ data [ 'Scale' ] ) ? $ data [ 'Scale' ] : '' ) ; $ result -> setLabel ( isset ( $ data [ 'Label' ] ) ? trim ( $ data [ 'Label' ] ) : '' ) ; return $ result ; }
create location msg
26,282
protected function createReceiveShortVideoMsg ( array $ data ) { $ result = new WxReceiveShortVideoMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setMediaId ( isset ( $ data [ 'MediaId' ] ) ? trim ( $ data [ 'MediaId' ] ) : '' ) ; $ result -> setThumbMediaId ( isset ( $ data [ 'ThumbMediaId' ] ) ? trim ( $ data [ 'ThumbMediaId' ] ) : '' ) ; return $ result ; }
create short video msg
26,283
protected function createReceiveTextMsg ( array $ data ) { $ result = new WxReceiveTextMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; if ( isset ( $ data [ 'Content' ] ) ) { if ( ! is_string ( $ data [ 'Content' ] ) ) { Helper :: getLogWriter ( ) -> debug ( "[createReceiveTextMsg]" . serialize ( $ data ) ) ; $ data [ 'Content' ] = '' ; } } $ result -> setContent ( isset ( $ data [ 'Content' ] ) ? trim ( $ data [ 'Content' ] ) : '' ) ; return $ result ; }
create text msg
26,284
protected function createReceiveVideoMsg ( array $ data ) { $ result = new WxReceiveVideoMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setMediaId ( isset ( $ data [ 'MediaId' ] ) ? trim ( $ data [ 'MediaId' ] ) : '' ) ; $ result -> setThumbMediaId ( isset ( $ data [ 'ThumbMediaId' ] ) ? trim ( $ data [ 'ThumbMediaId' ] ) : '' ) ; return $ result ; }
create video msg
26,285
protected function createReceiveVoiceMsg ( array $ data ) { $ result = new WxReceiveVoiceMsg ( ) ; $ this -> initReceiveMsg ( $ result , $ data ) ; $ result -> setMediaId ( isset ( $ data [ 'MediaId' ] ) ? trim ( $ data [ 'MediaId' ] ) : '' ) ; $ result -> setFormat ( isset ( $ data [ 'Format' ] ) ? trim ( $ data [ 'Format' ] ) : '' ) ; return $ result ; }
create Voice msg
26,286
public function getPermFromRoute ( $ route ) { $ menu_info = Config :: get ( $ this -> config_path ) ; foreach ( $ menu_info as $ menu ) { if ( $ menu [ $ this -> route_variable_index ] == $ route ) { return $ menu [ $ this -> pemissions_variable_index ] ; } } }
Obtain the permissions from a given url
26,287
public function render ( $ as ) { $ this -> templateVariableContainer -> add ( $ as , $ this -> securityContext -> getAccount ( ) ) ; $ result = $ this -> renderChildren ( ) ; $ this -> templateVariableContainer -> remove ( $ as ) ; return $ result ; }
Assign the authenticated account to a template variable
26,288
public function isSequentialArray ( $ array ) { $ counter = 0 ; foreach ( $ array as $ key => $ value ) { if ( $ counter !== $ key ) { return false ; } $ counter ++ ; } return true ; }
Check if this array is sequential
26,289
public function setVisitPlugin ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitPlugin $ visitPlugin = null ) { $ this -> visitPlugin = $ visitPlugin ; return $ this ; }
Set visitPlugin .
26,290
public function Export ( ) { $ this -> Permission ( 'Garden.Export' ) ; set_time_limit ( 60 * 2 ) ; $ Ex = new ExportModel ( ) ; $ Ex -> PDO ( Gdn :: Database ( ) -> Connection ( ) ) ; $ Ex -> Prefix = Gdn :: Database ( ) -> DatabasePrefix ; $ Ex -> UseCompression = TRUE ; $ Ex -> BeginExport ( PATH_ROOT . DS . 'uploads' . DS . 'export ' . date ( 'Y-m-d His' ) . '.txt.gz' , 'Vanilla 2.0' ) ; $ Ex -> ExportTable ( 'User' , 'select * from :_User' ) ; $ Ex -> ExportTable ( 'Role' , 'select * from :_Role' ) ; $ Ex -> ExportTable ( 'UserRole' , 'select * from :_UserRole' ) ; $ Ex -> ExportTable ( 'Category' , 'select * from :_Category' ) ; $ Ex -> ExportTable ( 'Discussion' , 'select * from :_Discussion' ) ; $ Ex -> ExportTable ( 'Comment' , 'select * from :_Comment' ) ; $ Ex -> ExportTable ( 'Conversation' , 'select * from :_Conversation' ) ; $ Ex -> ExportTable ( 'UserConversation' , 'select * from :_UserConversation' ) ; $ Ex -> ExportTable ( 'ConversationMessage' , 'select * from :_ConversationMessage' ) ; $ Ex -> EndExport ( ) ; }
Export core Vanilla and Conversations tables .
26,291
public function Go ( ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; $ Imp = new ImportModel ( ) ; $ Imp -> LoadState ( ) ; $ this -> SetData ( 'Steps' , $ Imp -> Steps ( ) ) ; $ this -> Form = new Gdn_Form ( ) ; if ( $ Imp -> CurrentStep < 1 ) { if ( $ Imp -> ImportPath ) $ Imp -> CurrentStep = 1 ; else Redirect ( strtolower ( $ this -> Application ) . '/import' ) ; } if ( $ Imp -> CurrentStep >= 1 ) { if ( $ this -> Form -> IsPostBack ( ) ) $ Imp -> FromPost ( $ this -> Form -> FormValues ( ) ) ; try { $ Result = $ Imp -> RunStep ( $ Imp -> CurrentStep ) ; } catch ( Exception $ Ex ) { $ Result = FALSE ; $ this -> Form -> AddError ( $ Ex ) ; $ this -> SetJson ( 'Error' , TRUE ) ; } if ( $ Result === TRUE ) { $ Imp -> CurrentStep ++ ; } elseif ( $ Result === 'COMPLETE' ) { $ this -> SetJson ( 'Complete' , TRUE ) ; } } $ Imp -> SaveState ( ) ; $ this -> Form -> SetValidationResults ( $ Imp -> Validation -> Results ( ) ) ; $ this -> SetData ( 'Stats' , GetValue ( 'Stats' , $ Imp -> Data , array ( ) ) ) ; $ this -> SetData ( 'CurrentStep' , $ Imp -> CurrentStep ) ; $ this -> SetData ( 'CurrentStepMessage' , GetValue ( 'CurrentStepMessage' , $ Imp -> Data , '' ) ) ; $ this -> SetData ( 'ErrorType' , GetValue ( 'ErrorType' , $ Imp ) ) ; if ( $ this -> Data ( 'ErrorType' ) ) $ this -> SetJson ( 'Error' , TRUE ) ; $ Imp -> ToPost ( $ Post ) ; $ this -> Form -> FormValues ( $ Post ) ; $ this -> AddJsFile ( 'import.js' ) ; $ this -> Render ( ) ; }
Manage importing process .
26,292
public function Restart ( ) { $ this -> Permission ( 'Garden.Import' ) ; $ Imp = new ImportModel ( ) ; try { $ Imp -> LoadState ( ) ; $ Imp -> DeleteFiles ( ) ; } catch ( Exception $ Ex ) { } $ Imp -> DeleteState ( ) ; Redirect ( strtolower ( $ this -> Application ) . '/import' ) ; }
Restart the import process . Undo any work we ve done so far and erase state .
26,293
public function getPlaceableObject ( ) { if ( $ this -> placeableobject ) { return $ this -> placeableobject ; } $ instance = Injector :: inst ( ) -> get ( $ this -> ObjectClassName ) ; $ this -> placeableobject = $ instance ; return $ instance ; }
Gets a class instance of PlaceableObject
26,294
public function getSubClassNames ( ) { $ classes = array ( ) ; $ killAncestors = array ( ) ; foreach ( ClassInfo :: subclassesFor ( $ this -> ClassName ) as $ class ) { $ classes [ $ class ] = $ class ; } unset ( $ classes [ 'PlaceableObject_Preset' ] , $ classes [ 'BlockObject_Preset' ] , $ classes [ 'RegionObject_Preset' ] ) ; foreach ( $ classes as $ class ) { $ instance = singleton ( $ class ) ; if ( $ instance instanceof HiddenClass ) { unset ( $ classes [ $ class ] ) ; continue ; } ; $ classes [ $ class ] = $ instance -> i18n_singular_name ( ) ; if ( $ ancestor_to_hide = $ instance -> stat ( 'hide_ancestor' ) ) { $ killAncestors [ ] = $ ancestor_to_hide ; } } if ( $ killAncestors ) { $ killAncestors = array_unique ( $ killAncestors ) ; foreach ( $ killAncestors as $ mark ) { unset ( $ classes [ $ mark ] ) ; } } return $ classes ; }
Get available sub classes from current class
26,295
public function getStyles ( ) { $ styles = $ this -> config ( ) -> get ( 'styles' ) ; $ i18nStyles = array ( ) ; if ( $ styles ) { foreach ( $ styles as $ key => $ label ) { $ i18nStyles [ $ key ] = _t ( 'PlaceableObject_Preset.STYLE' . strtoupper ( $ key ) , $ label ) ; } } return $ i18nStyles ; }
Get available template styles from config
26,296
public function sendDigestMails ( ) { $ subscriptionRepository = $ this -> entityManager -> getRepository ( 'PhlexibleMessageBundle:Subscription' ) ; $ subscriptions = $ subscriptionRepository -> findByHandler ( 'digest' ) ; $ digests = [ ] ; foreach ( $ subscriptions as $ subscription ) { $ filter = $ this -> filterManager -> find ( $ subscription -> getFilterId ( ) ) ; if ( ! $ filter ) { continue ; } $ user = $ this -> userManager -> find ( $ subscription -> getUserId ( ) ) ; if ( ! $ user || ! $ user -> getEmail ( ) ) { continue ; } $ lastSend = $ subscription -> getAttribute ( 'lastSend' , null ) ; if ( ! $ lastSend ) { $ lastSend = new \ DateTime ( ) ; $ lastSend = $ lastSend -> sub ( new \ DateInterval ( 'P30D' ) ) ; } else { $ lastSend = new \ DateTime ( $ lastSend ) ; } $ criteria = new Criteria ( [ $ filter -> getCriteria ( ) ] , Criteria :: MODE_AND ) ; $ criteria -> dateFrom ( $ lastSend ) ; $ messages = $ this -> messageRepository -> findByCriteria ( $ criteria ) ; if ( ! count ( $ messages ) ) { continue ; } if ( $ this -> mailer -> sendDigestMail ( $ user , $ messages ) ) { $ digests [ ] = [ 'filter' => $ filter -> getTitle ( ) , 'to' => $ user -> getEmail ( ) , 'status' => 'ok' ] ; $ subscription -> setAttribute ( 'lastSend' , date ( 'Y-m-d H:i:s' ) ) ; $ this -> subscriptionRepository -> save ( $ subscription ) ; } else { $ digests [ ] = [ 'filter' => $ filter -> getTitle ( ) , 'to' => $ user -> getEmail ( ) , 'status' => 'failed' ] ; } } if ( count ( $ digests ) ) { $ message = Message :: create ( count ( $ digests ) . ' digest mail(s) sent.' , 'Status: ' . PHP_EOL . print_r ( $ digests , true ) , Message :: PRIORITY_NORMAL , null , 'ROLE_MESSAGES' , 'cli' ) ; $ this -> messageService -> post ( $ message ) ; } return $ digests ; }
Static send function for use with events .
26,297
public function load ( string $ key ) : CompanyInterface { if ( ! $ this -> has ( $ key ) ) { throw new NotFoundException ( 'the company with key "' . $ key . '" was not found' ) ; } $ company = $ this -> companies [ $ key ] ; return new Company ( $ key , $ company [ 'name' ] , $ company [ 'brandname' ] ) ; }
Gets the information about the company
26,298
public function remove ( $ component , $ name ) { $ this -> load ( ) ; $ propertyKey = sprintf ( '%s__%s' , $ component , $ name ) ; if ( isset ( $ this -> properties [ $ propertyKey ] ) ) { $ this -> entityManager -> remove ( $ this -> properties [ $ propertyKey ] ) ; unset ( $ this -> properties [ $ propertyKey ] ) ; } return $ this ; }
Remove property .
26,299
public function has ( $ component , $ name ) { $ this -> load ( ) ; return ( bool ) mb_strlen ( $ this -> get ( $ component , $ name ) ) ; }
Is property set?