idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
7,200
|
public function aggregate ( $ collection , array $ pipeline , $ options = [ ] ) { $ data = $ this -> dbConnection -> selectCollection ( $ collection ) -> aggregate ( $ pipeline ) ; if ( $ data [ 'ok' ] != 1 ) { throw new Exception ( "Tool Aggregation Error: " . $ data [ 'errmsg' ] , $ data [ 'code' ] ) ; } return $ data [ 'result' ] ; }
|
Run Aggregation through the Aggregation Pipeline
|
7,201
|
public function findOne ( $ collection , array $ criteria , array $ fields = [ ] ) { return $ this -> dbConnection -> selectCollection ( $ collection ) -> findOne ( $ criteria , $ fields ) ; }
|
returns the first found matching document
|
7,202
|
public function newObject ( $ collection ) { $ obj = $ this -> container -> get ( $ this -> classMap -> getClassForResult ( $ collection , [ ] ) ) ; $ obj -> setCollection ( $ collection ) ; return $ obj ; }
|
conveniant method to create new instances
|
7,203
|
public function jquery ( ) { $ this -> Html -> script ( 'libs/jquery.min.js' , $ this -> _setOptions ( [ 'alias' => __FUNCTION__ , 'weight' => self :: WEIGHT_CORE ] ) ) ; return $ this ; }
|
Include jquery lib .
|
7,204
|
public function jqueryFactory ( ) { $ this -> jquery ( ) ; $ this -> Html -> script ( 'libs/utils.min.js' , $ this -> _setOptions ( [ 'alias' => 'jquery-utils' , 'weight' => self :: WEIGHT_LIB ] ) ) ; $ this -> Html -> script ( 'libs/jquery-factory.min.js' , $ this -> _setOptions ( [ 'weight' => self :: WEIGHT_LIB , 'alias' => 'jquery-factory' ] ) ) ; return $ this ; }
|
Include jquery factory .
|
7,205
|
public function loadPluginAssets ( ) { $ plugin = ( string ) $ this -> request -> getParam ( 'plugin' ) ; $ prefix = ( $ this -> request -> getParam ( 'prefix' ) ) ? $ this -> request -> getParam ( 'prefix' ) . '/' : null ; $ action = ( string ) $ this -> request -> getParam ( 'action' ) ; $ controller = ( string ) $ this -> request -> getParam ( 'controller' ) ; $ widgetName = Str :: slug ( $ controller . '-' . $ action ) . '.js' ; $ cssOptions = [ 'block' => 'css_bottom' , 'fullBase' => true , 'force' => Configure :: read ( 'debug' ) ] ; $ this -> Html -> css ( $ plugin . '.' . $ prefix . 'styles.css' , $ cssOptions ) ; $ this -> Html -> less ( $ plugin . '.' . $ prefix . 'styles.less' , $ cssOptions ) ; $ this -> Html -> script ( [ $ plugin . '.' . $ prefix . 'widget/' . $ widgetName , $ plugin . '.' . $ prefix . 'script.js' ] , [ 'block' => 'script_bottom' , 'fullBase' => true ] ) ; }
|
Autoload plugin assets .
|
7,206
|
public function materialize ( ) { $ this -> jquery ( ) ; $ this -> Html -> script ( 'libs/materialize.min.js' , $ this -> _setOptions ( [ 'alias' => __FUNCTION__ , 'weight' => self :: WEIGHT_LIB ] ) ) ; $ this -> Html -> css ( 'libs/materialize.min.css' , $ this -> _setOptions ( [ 'alias' => __FUNCTION__ , 'weight' => self :: WEIGHT_CORE ] ) ) ; return $ this ; }
|
Include materialize design .
|
7,207
|
public function toggleField ( $ selector = '.jsToggleField' , $ widget = 'JBZoo.FieldToggle' , array $ options = [ ] ) { $ this -> jqueryFactory ( ) ; $ this -> Html -> script ( 'Core.admin/widget/field-toggle.js' , $ this -> _setOptions ( [ 'alias' => __FUNCTION__ , 'weight' => self :: WEIGHT_WIDGET ] ) ) ; $ options = Hash :: merge ( [ 'token' => $ this -> request -> getCookie ( 'csrfToken' ) ] , $ options ) ; $ this -> Js -> widget ( $ selector , $ widget , $ options ) ; return $ this ; }
|
Include toggle field js widget .
|
7,208
|
public function exists ( ) { return ( $ this -> page_id > 0 || $ this -> file_id > 0 || $ this -> custom_url !== null || $ this -> shortcode !== null && $ this -> title !== null ) ; }
|
Determines if any of the properties in this field have a value meaning at least one of them is not NULL .
|
7,209
|
public function addGroupKeyToPostbox ( $ post ) { if ( $ post -> post_type !== 'acf-field-group' ) { return ; } global $ acfExportManagerHasGroupIdInSidebar ; if ( $ acfExportManagerHasGroupIdInSidebar ) { return ; } $ acfExportManagerHasGroupIdInSidebar = true ; $ fieldgroup = acf_get_field_group ( $ post -> ID ) ; echo '<div class="misc-pub-section"><span style="color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;">#</span>' . $ fieldgroup [ 'key' ] . '</div>' ; }
|
Displays the fieldgroup key in misc publishing actions
|
7,210
|
public function deleteExport ( array $ fieldgroup ) : bool { $ filename = $ this -> getExportFilename ( $ fieldgroup ) ; $ this -> maybeUnlink ( $ this -> exportFolder . 'php/' . $ filename [ 'php' ] ) ; $ this -> maybeUnlink ( $ this -> exportFolder . 'json/' . $ filename [ 'json' ] ) ; return true ; }
|
Deletes export file for deleted fieldgroup
|
7,211
|
public function export ( array $ fieldgroup , bool $ restrictToExportPosts = true , bool $ translate = true ) : array { global $ locale ; $ locale = "en_US" ; if ( $ restrictToExportPosts && ! in_array ( $ fieldgroup [ 'key' ] , $ this -> exportPosts ) ) { return array ( ) ; } $ this -> maybeCreateExportFolders ( ) ; if ( $ this -> textdomain ) { acf_update_setting ( 'l10n' , true ) ; acf_update_setting ( 'l10n_textdomain' , $ this -> textdomain ) ; acf_update_setting ( 'l10n_var_export' , true ) ; } $ filename = $ this -> getExportFilename ( $ fieldgroup ) ; $ this -> maybeUnlink ( $ this -> exportFolder . 'php/' . $ filename [ 'php' ] ) ; $ code = $ this -> generatePhp ( $ fieldgroup [ 'ID' ] , $ translate ) ; $ phpFile = fopen ( $ this -> exportFolder . 'php/' . $ filename [ 'php' ] , 'w' ) ; fwrite ( $ phpFile , $ code ) ; fclose ( $ phpFile ) ; $ this -> maybeUnlink ( $ this -> exportFolder . 'json/' . $ filename [ 'json' ] ) ; $ jsonFile = fopen ( $ this -> exportFolder . 'json/' . $ filename [ 'json' ] , 'w' ) ; $ json = $ this -> getJson ( $ this -> getFieldgroupParams ( $ fieldgroup [ 'ID' ] , false ) ) ; fwrite ( $ jsonFile , $ json ) ; fclose ( $ jsonFile ) ; return array ( 'php' => $ this -> exportFolder . 'php/' . $ filename [ 'php' ] , 'json' => $ this -> exportFolder . 'json/' . $ filename [ 'json' ] ) ; }
|
Does the actual export of the php fields
|
7,212
|
public function getJson ( array $ fieldgroup ) : string { $ json = json_encode ( $ fieldgroup , JSON_PRETTY_PRINT ) ; $ json = str_replace ( '!!__(!!\'' , '' , $ json ) ; $ json = str_replace ( "!!', !!'" . $ this -> textdomain . "!!')!!" , '' , $ json ) ; return '[' . $ json . "]\n\r" ; }
|
Get fieldgroup as json
|
7,213
|
public function maybeCreateExportFolders ( ) { if ( ! is_writable ( $ this -> exportFolder ) ) { trigger_error ( 'The export folder (' . $ this -> exportFolder . ') is not writable. Exports will not be saved.' , E_USER_ERROR ) ; } if ( ! file_exists ( $ this -> exportFolder . 'json' ) ) { mkdir ( $ this -> exportFolder . 'json' ) ; chmod ( $ this -> exportFolder . 'json' , 0777 ) ; } if ( ! file_exists ( $ this -> exportFolder . 'php' ) ) { mkdir ( $ this -> exportFolder . 'php' ) ; chmod ( $ this -> exportFolder . 'php' , 0777 ) ; } }
|
Creates export folders if needed
|
7,214
|
public function getExportFilename ( array $ fieldgroup ) : array { if ( $ key = array_search ( $ fieldgroup [ 'key' ] , $ this -> exportPosts ) ) { return array ( 'php' => $ key . '.php' , 'json' => $ key . '.json' ) ; } return array ( 'php' => sanitize_title ( $ fieldgroup [ 'title' ] ) . '.php' , 'json' => sanitize_title ( $ fieldgroup [ 'title' ] ) . '.json' ) ; }
|
Get filename for the export file
|
7,215
|
protected function generatePhp ( int $ fieldgroupId , bool $ translate = true ) : string { $ strReplace = array ( " " => " " , "!!\'" => "'" , "'!!" => "" , "!!'" => "" , "array (" => "array(" , " => \n" => " => " ) ; $ pregReplace = array ( '/([\t\r\n]+?)array/' => 'array' , '/[0-9]+ => array/' => 'array' , '/=>(\s+)array\(/' => '=> array(' ) ; $ fieldgroup = $ this -> getFieldgroupParams ( $ fieldgroupId , $ translate ) ; $ code = var_export ( $ fieldgroup , true ) ; $ code = str_replace ( array_keys ( $ strReplace ) , array_values ( $ strReplace ) , $ code ) ; $ code = preg_replace ( array_keys ( $ pregReplace ) , array_values ( $ pregReplace ) , $ code ) ; $ export = "<?php \n\r\n\rif (function_exists('acf_add_local_field_group')) {\n\r" ; $ export .= " acf_add_local_field_group({$code});" ; $ export .= "\n\r}" ; acf_update_setting ( 'l10n_var_export' , false ) ; return $ export ; }
|
Generates PHP exportcode for a fieldgroup
|
7,216
|
public function getFieldgroupParams ( int $ fieldgroupId , bool $ translate = true ) : array { $ fieldgroup = acf_get_field_group ( $ fieldgroupId ) ; if ( empty ( $ fieldgroup ) ) { trigger_error ( 'The fieldgroup with id "' . $ fieldgroupId . '" is empty.' , E_USER_WARNING ) ; return array ( ) ; } $ fieldgroup [ 'fields' ] = acf_get_fields ( $ fieldgroup ) ; if ( $ translate ) { $ fieldgroup = $ this -> translate ( $ fieldgroup ) ; } return acf_prepare_field_group_for_export ( $ fieldgroup ) ; }
|
Get exportable fieldgroup params
|
7,217
|
public function translateFieldParams ( array $ field ) : array { $ keys = array ( 'prepend' , 'append' , 'placeholder' , 'default_value' ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ field [ $ key ] ) ) { continue ; } $ field [ $ key ] = acf_translate ( $ field [ $ key ] ) ; } if ( isset ( $ field [ 'sub_fields' ] ) && is_array ( $ field [ 'sub_fields' ] ) ) { foreach ( $ field [ 'sub_fields' ] as & $ subfield ) { if ( function_exists ( '\acf_translate_field' ) ) { $ subfield = \ acf_translate_field ( $ subfield ) ; } } } return $ field ; }
|
Translate field params
|
7,218
|
public function setExportFolder ( string $ folder ) { $ folder = trailingslashit ( $ folder ) ; if ( ! file_exists ( $ folder ) ) { if ( ! mkdir ( $ folder ) ) { trigger_error ( 'The export folder (' . $ folder . ') can not be found. Exports will not be saved.' , E_USER_WARNING ) ; } else { chmod ( $ folder , 0777 ) ; } } $ this -> exportFolder = $ folder ; }
|
Set exports folder
|
7,219
|
public function autoExport ( array $ ids ) { $ this -> exportPosts = array_replace ( $ this -> exportPosts , $ ids ) ; $ this -> exportPosts = array_unique ( $ this -> exportPosts ) ; }
|
Sets which acf - fieldgroups postids to autoexport
|
7,220
|
public function handleBulkExport ( $ redirectTo , $ doaction , $ postIds ) { if ( $ doaction !== 'acfExportManager-export' ) { return $ redirectTo ; } foreach ( $ postIds as $ postId ) { $ fieldgroup = acf_get_field_group ( $ postId ) ; if ( ! in_array ( $ fieldgroup [ 'key' ] , $ this -> exportPosts ) ) { continue ; } $ this -> export ( $ fieldgroup , false , false ) ; } $ redirectTo = add_query_arg ( 'bulkExportedFieldgroups' , count ( $ postIds ) , $ redirectTo ) ; return $ redirectTo ; }
|
Handles bulk exporting
|
7,221
|
public function hasCustomHandler ( ) { if ( ! class_exists ( \ App \ Exception \ Handler :: class ) ) { return false ; } if ( ! in_array ( \ Pharest \ Exception \ ExceptionHandler :: class , class_implements ( \ App \ Exception \ Handler :: class ) ) ) { return false ; } return true ; }
|
Determine if the app has custom exception handler
|
7,222
|
public static function relative ( $ ts ) { if ( ! ctype_digit ( $ ts ) ) $ ts = strtotime ( $ ts ) ; $ diff = time ( ) - $ ts ; if ( $ diff == 0 ) return __ ( 'Core::common.date.now' ) ; elseif ( $ diff > 0 ) { $ day_diff = floor ( $ diff / 86400 ) ; if ( $ day_diff == 0 ) { if ( $ diff < 60 ) return __ ( 'Core::common.date.just_now' ) ; if ( $ diff < 120 ) return __ ( 'Core::common.date.minute_ago' ) ; if ( $ diff < 3600 ) return __ ( 'Core::common.date.minutes_ago' , array ( 'num' => floor ( $ diff / 60 ) ) ) ; if ( $ diff < 7200 ) return __ ( 'Core::common.date.hour_ago' ) ; if ( $ diff < 86400 ) return __ ( 'Core::common.date.hours_ago' , array ( 'num' => floor ( $ diff / 3600 ) ) ) ; } if ( $ day_diff == 1 ) return __ ( 'Core::common.date.yesterday' ) ; if ( $ day_diff < 7 ) return __ ( 'Core::common.date.days_ago' , array ( 'num' => $ day_diff ) ) ; if ( $ day_diff < 31 ) return __ ( 'Core::common.date.weeks_ago' , array ( 'num' => ceil ( $ day_diff / 7 ) ) ) ; if ( $ day_diff < 60 ) return __ ( 'Core::common.date.last_month' ) ; return date ( 'F Y' , $ ts ) ; } else { $ diff = abs ( $ diff ) ; $ day_diff = floor ( $ diff / 86400 ) ; if ( $ day_diff == 0 ) { if ( $ diff < 120 ) return __ ( 'Core::common.date.in_minute' ) ; if ( $ diff < 3600 ) return __ ( 'Core::common.date.in_minutes' , array ( 'num' => floor ( $ diff / 60 ) ) ) ; if ( $ diff < 7200 ) return __ ( 'Core::common.date.in_hour' ) ; if ( $ diff < 86400 ) return __ ( 'Core::common.date.in_hours' , array ( 'num' => floor ( $ diff / 3600 ) ) ) ; } if ( $ day_diff == 1 ) return __ ( 'Core::common.date.tomorrow' ) ; if ( $ day_diff < 4 ) return date ( 'l' , $ ts ) ; if ( $ day_diff < 7 + ( 7 - date ( 'w' ) ) ) return 'next week' ; if ( ceil ( $ day_diff / 7 ) < 4 ) return 'in ' . ceil ( $ day_diff / 7 ) . ' weeks' ; if ( date ( 'n' , $ ts ) == date ( 'n' ) + 1 ) return 'next month' ; return date ( 'F Y' , $ ts ) ; } }
|
to string relative string
|
7,223
|
protected function render ( $ template , $ context = [ ] ) { $ context = array_merge ( $ this -> _context , $ context ) ; $ body = $ this -> twig -> render ( $ template , $ context ) ; return $ body ; }
|
render template with context will merge context with allready known context
|
7,224
|
public function truncateTables ( ) { $ dbName = env ( 'DB_DATABASE' ) ; $ tables = DB :: select ( 'SHOW TABLES WHERE `Tables_in_' . $ dbName . '` != ?' , [ 'migrations' ] ) ; DB :: statement ( 'SET FOREIGN_KEY_CHECKS=0;' ) ; foreach ( $ tables as $ table ) { DB :: table ( $ table -> { 'Tables_in_' . $ dbName } ) -> truncate ( ) ; } DB :: statement ( 'SET FOREIGN_KEY_CHECKS=1;' ) ; }
|
Truncates all tables except migrations .
|
7,225
|
public function getConfig ( $ type = null ) { $ types = [ 'php' => true , 'ini' => true ] ; $ type = isset ( $ types [ $ type ] ) ? $ type : 'ini' ; foreach ( [ 'app/config/' , 'config/' , 'apps/config/' , 'apps/frontend/config/' ] as $ configPath ) { if ( 'ini' == $ type && file_exists ( $ this -> rootPath . $ configPath . 'config.ini' ) ) { return new ConfigIni ( $ this -> rootPath . $ configPath . 'config.ini' ) ; } else { if ( file_exists ( $ this -> rootPath . $ configPath . 'config.php' ) ) { $ config = include ( $ this -> rootPath . $ configPath . 'config.php' ) ; if ( is_array ( $ config ) ) { $ config = new Config ( $ config ) ; } return $ config ; } } } $ directory = new RecursiveDirectoryIterator ( '.' ) ; $ iterator = new RecursiveIteratorIterator ( $ directory ) ; foreach ( $ iterator as $ f ) { if ( preg_match ( '/config\.php$/i' , $ f -> getPathName ( ) ) ) { $ config = include $ f -> getPathName ( ) ; if ( is_array ( $ config ) ) { $ config = new Config ( $ config ) ; } return $ config ; } else { if ( preg_match ( '/config\.ini$/i' , $ f -> getPathName ( ) ) ) { return new ConfigIni ( $ f -> getPathName ( ) ) ; } } } throw new BuilderException ( "Builder can't locate the configuration file" ) ; }
|
Tries to find the current configuration in the application
|
7,226
|
public function isAbsolutePath ( $ path ) { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { if ( preg_match ( '/^[A-Z]:\\\\/' , $ path ) ) { return true ; } } else { if ( substr ( $ path , 0 , 1 ) == DIRECTORY_SEPARATOR ) { return true ; } } return false ; }
|
Check if a path is absolute
|
7,227
|
public function add ( $ item ) { if ( strpos ( $ item , "<" ) !== false ) { $ macro = '_' ; } else { $ macro = CCStr :: extension ( $ item ) ; } if ( ! isset ( $ this -> assets [ $ macro ] ) ) { $ this -> assets [ $ macro ] = array ( ) ; } $ this -> assets [ $ macro ] [ ] = $ item ; }
|
Add an asset to the holder . Basically this method checks the file extension to sort them and generate the correct code using the macros .
|
7,228
|
public function getForm ( $ documentClass = null ) { if ( null === $ documentClass ) { $ documentClass = $ this -> getDocumentClass ( ) ; } $ builder = new AnnotationBuilder ( ) ; $ form = $ builder -> createForm ( $ documentClass ) ; $ hasDocument = false ; foreach ( $ form -> getElements ( ) as $ element ) { if ( method_exists ( $ element , 'setObjectManager' ) ) { $ element -> setObjectManager ( $ this -> getDocumentManager ( ) ) ; $ hasDocument = true ; } elseif ( method_exists ( $ element , 'getProxy' ) ) { $ proxy = $ element -> getProxy ( ) ; if ( method_exists ( $ proxy , 'setObjectManager' ) ) { $ proxy -> setObjectManager ( $ this -> getDocumentManager ( ) ) ; $ hasDocument = true ; } } } if ( $ hasDocument ) { $ hydrator = new DoctrineObjectHydrator ( $ this -> getDocumentManager ( ) , $ documentClass ) ; $ form -> setHydrator ( $ hydrator ) ; } else { $ form -> setHydrator ( new ClassMethods ( ) ) ; } $ form -> add ( [ 'type' => 'Zend\Form\Element\Csrf' , 'name' => 'csrf' , 'attributes' => [ 'id' => 'csrf' , ] , ] ) ; $ submitElement = new \ Zend \ Form \ Element \ Button ( 'submit' ) ; $ submitElement -> setAttributes ( [ 'type' => 'submit' , 'class' => 'btn btn-primary' , ] ) ; $ submitElement -> setLabel ( 'Salvar' ) ; $ form -> add ( $ submitElement , [ 'priority' => - 100 , ] ) ; $ cancelarElement = new \ Zend \ Form \ Element \ Button ( 'cancelar' ) ; $ cancelarElement -> setAttributes ( [ 'type' => 'button' , 'class' => 'btn btn-default' , 'onclick' => 'top.location=\'' . $ this -> url ( ) -> fromRoute ( $ this -> getActionRoute ( 'list' ) ) . '\'' , ] ) ; $ cancelarElement -> setLabel ( 'Cancelar' ) ; $ form -> add ( $ cancelarElement , [ 'priority' => - 100 , ] ) ; return $ form ; }
|
Retorna a form para o cadastro do documento .
|
7,229
|
public static function doSelectJoinCountry ( Criteria $ criteria , $ con = null , $ join_behavior = Criteria :: LEFT_JOIN ) { $ criteria = clone $ criteria ; if ( $ criteria -> getDbName ( ) == Propel :: getDefaultDB ( ) ) { $ criteria -> setDbName ( CustomerPeer :: DATABASE_NAME ) ; } CustomerPeer :: addSelectColumns ( $ criteria ) ; $ startcol = CustomerPeer :: NUM_HYDRATE_COLUMNS ; CountryPeer :: addSelectColumns ( $ criteria ) ; $ criteria -> addJoin ( CustomerPeer :: COUNTRY_ID , CountryPeer :: ID , $ join_behavior ) ; $ stmt = BasePeer :: doSelect ( $ criteria , $ con ) ; $ results = array ( ) ; while ( $ row = $ stmt -> fetch ( PDO :: FETCH_NUM ) ) { $ key1 = CustomerPeer :: getPrimaryKeyHashFromRow ( $ row , 0 ) ; if ( null !== ( $ obj1 = CustomerPeer :: getInstanceFromPool ( $ key1 ) ) ) { } else { $ cls = CustomerPeer :: getOMClass ( ) ; $ obj1 = new $ cls ( ) ; $ obj1 -> hydrate ( $ row ) ; CustomerPeer :: addInstanceToPool ( $ obj1 , $ key1 ) ; } $ key2 = CountryPeer :: getPrimaryKeyHashFromRow ( $ row , $ startcol ) ; if ( $ key2 !== null ) { $ obj2 = CountryPeer :: getInstanceFromPool ( $ key2 ) ; if ( ! $ obj2 ) { $ cls = CountryPeer :: getOMClass ( ) ; $ obj2 = new $ cls ( ) ; $ obj2 -> hydrate ( $ row , $ startcol ) ; CountryPeer :: addInstanceToPool ( $ obj2 , $ key2 ) ; } $ obj2 -> addCustomer ( $ obj1 ) ; } $ results [ ] = $ obj1 ; } $ stmt -> closeCursor ( ) ; return $ results ; }
|
Selects a collection of Customer objects pre - filled with their Country objects .
|
7,230
|
public static function doDeleteAll ( PropelPDO $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( CustomerPeer :: DATABASE_NAME , Propel :: CONNECTION_WRITE ) ; } $ affectedRows = 0 ; try { $ con -> beginTransaction ( ) ; $ affectedRows += CustomerPeer :: doOnDeleteCascade ( new Criteria ( CustomerPeer :: DATABASE_NAME ) , $ con ) ; CustomerPeer :: doOnDeleteSetNull ( new Criteria ( CustomerPeer :: DATABASE_NAME ) , $ con ) ; $ affectedRows += BasePeer :: doDeleteAll ( CustomerPeer :: TABLE_NAME , $ con , CustomerPeer :: DATABASE_NAME ) ; CustomerPeer :: clearInstancePool ( ) ; CustomerPeer :: clearRelatedInstancePool ( ) ; $ con -> commit ( ) ; return $ affectedRows ; } catch ( Exception $ e ) { $ con -> rollBack ( ) ; throw $ e ; } }
|
Deletes all rows from the customer table .
|
7,231
|
private function processStringData ( DataFromServerEvent $ event ) { $ regex = "/^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$/" ; preg_match ( $ regex , $ event -> getData ( ) , $ matches ) ; if ( isset ( $ matches [ 2 ] ) && ( '' !== trim ( $ matches [ 2 ] ) ) ) { $ this -> dispatcher -> dispatch ( 'whisnet_irc_bot.irc_command_' . $ matches [ 2 ] , new IrcCommandFoundEvent ( $ matches ) ) ; } }
|
Process string response from server .
|
7,232
|
public function preSend ( Event $ e ) { $ validator = new NotEmpty ( ) ; if ( ! isset ( $ this -> options [ 'tokenOrLogin' ] ) || ! $ validator -> isValid ( $ this -> options [ 'tokenOrLogin' ] ) ) { throw new Exception \ InvalidArgumentException ( 'You need to set OAuth token!' ) ; } $ request = $ e -> getTarget ( ) ; $ headers = $ request -> getHeaders ( ) ; $ params = array ( 'Authorization' => 'token ' . $ this -> options [ 'tokenOrLogin' ] , ) ; $ headers -> addHeaders ( $ params ) ; }
|
Add Authorization Token to Header
|
7,233
|
public function action_create ( $ params ) { $ name = array_shift ( $ params ) ; $ file = \ DB \ Migrator :: path ( $ name ) ; \ CCFile :: write ( $ file , "# - ) ; }
|
Create new migration
|
7,234
|
public function schedule ( $ type , $ details ) { $ schedule = array ( ) ; $ schedule [ $ type ] = $ details ; return $ this -> setArgument ( "schedule" , $ schedule ) ; }
|
Schedule this message
|
7,235
|
private static function _getCharMap ( ) : array { static $ map = [ ] ; if ( empty ( $ map ) ) { foreach ( StringHelper :: asciiCharMap ( ) as $ asciiChar => $ charsArray ) { foreach ( $ charsArray as $ char ) { $ map [ $ char ] = $ asciiChar ; } } foreach ( self :: _getPunctuation ( ) as $ value ) { $ map [ $ value ] = ' ' ; } } return $ map ; }
|
Get array of chars to be used for conversion .
|
7,236
|
protected function addUserFlash ( SessionInterface $ session , $ type , $ message ) { $ session -> getFlashBag ( ) -> add ( $ type , $ message ) ; }
|
Adds a flash message to the given session .
|
7,237
|
public static function create ( $ file , $ type = null ) { if ( is_null ( $ type ) ) { $ type = CCStr :: extension ( $ file ) ; if ( ! in_array ( $ type , static :: $ available_image_types ) ) { $ type = null ; } } $ image_data = getimagesize ( $ file ) ; if ( $ image_data === false ) { return false ; } $ image = null ; switch ( $ image_data [ 'mime' ] ) { case 'image/gif' : $ image = imagecreatefromgif ( $ file ) ; break ; case 'image/jpeg' ; $ image = imagecreatefromjpeg ( $ file ) ; break ; case 'image/png' : $ image = imagecreatefrompng ( $ file ) ; break ; default : return false ; break ; } if ( is_null ( $ type ) ) { $ type = CCStr :: suffix ( $ image_data [ 'mime' ] , '/' ) ; } return new static ( $ image , $ type ) ; }
|
Create a image from file
|
7,238
|
public static function string ( $ string , $ type = null ) { $ image = imagecreatefromstring ( $ string ) ; if ( $ image !== false ) { return new static ( $ image , $ type ) ; } return false ; }
|
Create an image from string
|
7,239
|
public static function aspect_ratio ( $ width , $ height , $ proper = false ) { $ ratio = $ width / $ height ; if ( ! $ proper ) { return $ ratio ; } $ tolerance = 1.e-6 ; $ h1 = 1 ; $ h2 = 0 ; $ k1 = 0 ; $ k2 = 1 ; $ b = 1 / $ ratio ; do { $ b = 1 / $ b ; $ a = floor ( $ b ) ; $ aux = $ h1 ; $ h1 = $ a * $ h1 + $ h2 ; $ h2 = $ aux ; $ aux = $ k1 ; $ k1 = $ a * $ k1 + $ k2 ; $ k2 = $ aux ; $ b = $ b - $ a ; } while ( abs ( $ ratio - $ h1 / $ k1 ) > $ ratio * $ tolerance ) ; return $ h1 . ":" . $ k1 ; }
|
Calculate the aspect ratio
|
7,240
|
protected function reload_context_info ( ) { $ this -> width = imagesx ( $ this -> image_context ) ; $ this -> height = imagesy ( $ this -> image_context ) ; }
|
Reload the image dimension etc .
|
7,241
|
protected function set_type ( $ type , $ overwrite = true ) { if ( ! is_null ( $ type ) ) { if ( ! in_array ( $ type , static :: $ available_image_types ) ) { throw new CCException ( "CCImage - Invalid image type '" . $ type . "'." ) ; } if ( $ type === 'jpg' ) { $ type = 'jpeg' ; } if ( $ overwrite ) { $ this -> type = $ type ; } } return $ type ; }
|
Set the current image type
|
7,242
|
public function stream ( $ quality = null , $ type = null ) { $ this -> save ( null , $ quality , $ type ) ; }
|
Send the image to the output buffer
|
7,243
|
public function stringify ( $ quality = null , $ type = null ) { ob_start ( ) ; $ this -> stream ( $ quality , $ type ) ; return ob_get_clean ( ) ; }
|
Return the image data as string
|
7,244
|
public function response ( $ quality = null , $ type = null ) { $ response = CCResponse :: create ( $ this -> stringify ( $ quality , $ type ) ) ; if ( ! is_null ( $ this -> type ) ) { $ response -> header ( 'Content-Type' , 'image/' . $ this -> type ) ; } return $ response ; }
|
Create a CCRespone of the image
|
7,245
|
public function resize ( $ width , $ height , $ mode = null ) { if ( strpos ( $ width , 'x' ) !== false ) { $ mode = $ height ; $ dimensions = explode ( 'x' , $ width ) ; $ width = $ dimensions [ 0 ] ; $ height = $ dimensions [ 1 ] ; } if ( is_null ( $ mode ) ) { $ mode = 'strict' ; } if ( $ width == 'auto' ) { $ mode = 'portrait' ; $ width = $ height ; } elseif ( $ height == 'auto' ) { $ mode = 'landscape' ; } $ method = 'resize_' . $ mode ; if ( ! method_exists ( $ this , $ method ) ) { throw new CCException ( "CCImage::resize - Invalid resize method " . $ mode . "." ) ; } return call_user_func_array ( array ( $ this , $ method ) , array ( $ width , $ height ) ) ; }
|
Resize the image
|
7,246
|
public function resize_landscape ( $ width , $ ignore_me ) { $ height = $ width * ( $ this -> height / $ this -> width ) ; return $ this -> resize_strict ( $ width , $ height ) ; }
|
Resize the current image from width and keep aspect ratio
|
7,247
|
public function resize_portrait ( $ height , $ ignore_me ) { $ width = $ height * ( $ this -> width / $ this -> height ) ; return $ this -> resize_strict ( $ width , $ height ) ; }
|
Resize the current image from height and keep aspect ratio
|
7,248
|
public function resize_max ( $ width , $ height ) { $ new_width = $ this -> width ; $ new_height = $ this -> height ; if ( $ new_width > $ width ) { $ new_width = $ width ; $ new_height = $ new_width * ( $ this -> height / $ this -> width ) ; } if ( $ new_height > $ height ) { $ new_height = $ height ; $ new_width = $ new_height * ( $ this -> width / $ this -> height ) ; } return $ this -> resize_strict ( $ new_width , $ new_height ) ; }
|
Resize the image that it fits into a size doesn t crop and does not add a border
|
7,249
|
public function resize_fit ( $ width , $ height , $ background_color = '#fff' ) { $ background = static :: blank ( $ width , $ height ) ; static :: resize_max ( $ width , $ height ) ; $ background -> fill_color ( $ background_color ) ; $ background -> add_layer ( $ this , 'center' , 'middle' ) ; $ this -> image_context = $ background -> image_context ; $ this -> width = $ width ; $ this -> height = $ height ; return $ this ; }
|
Resize the image that it fits into a size doesn t crop adds a background layer
|
7,250
|
public function resize_fill ( $ width , $ height ) { $ original_aspect = $ this -> width / $ this -> height ; $ thumb_aspect = $ width / $ height ; if ( $ original_aspect >= $ thumb_aspect ) { $ new_height = $ height ; $ new_width = $ this -> width / ( $ this -> height / $ height ) ; } else { $ new_width = $ width ; $ new_height = $ this -> height / ( $ this -> width / $ width ) ; } $ x = 0 - ( $ new_width - $ width ) / 2 ; $ y = 0 - ( $ new_height - $ height ) / 2 ; $ result = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ result , $ this -> image_context , $ x , $ y , 0 , 0 , $ new_width , $ new_height , $ this -> width , $ this -> height ) ; $ this -> image_context = $ result ; $ this -> reload_context_info ( ) ; return $ this ; }
|
Resize the image to fill the new size . This will crop your image .
|
7,251
|
public function resize_strict ( $ width , $ height ) { if ( ! ( $ width > 0 ) || ! ( $ height > 0 ) ) { throw new CCException ( "CCImage::resize_strict - width and height can't be smaller then 1" ) ; } $ result = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ result , $ this -> image_context , 0 , 0 , 0 , 0 , $ width , $ height , $ this -> width , $ this -> height ) ; $ this -> image_context = $ result ; $ this -> reload_context_info ( ) ; return $ this ; }
|
Resize the current image to strict dimensions
|
7,252
|
public function crop ( $ x , $ y , $ width , $ height ) { if ( $ x == 'center' || $ x == 'auto' ) { $ x = ( $ this -> width / 2 ) - ( $ width / 2 ) ; } if ( $ y == 'middle' || $ y == 'auto' ) { $ y = ( $ this -> height / 2 ) - ( $ height / 2 ) ; } $ result = imagecreatetruecolor ( $ width , $ height ) ; ImageCopyResampled ( $ result , $ this -> image_context , 0 , 0 , $ x , $ y , $ width , $ height , $ width , $ height ) ; $ this -> image_context = $ result ; $ this -> reload_context_info ( ) ; return $ this ; }
|
Crop the current image
|
7,253
|
public function add_layer ( CCImage $ image , $ x = 0 , $ y = 0 , $ alpha = 100 ) { if ( $ x == 'center' || $ x == 'auto' ) { $ x = ( $ this -> width / 2 ) - ( $ image -> width / 2 ) ; } elseif ( $ x == 'left' ) { $ x = 0 ; } elseif ( $ x == 'right' ) { $ x = $ this -> width - $ image -> width ; } if ( $ y == 'middle' || $ y == 'auto' ) { $ y = ( $ this -> height / 2 ) - ( $ image -> height / 2 ) ; } elseif ( $ x == 'top' ) { $ x = 0 ; } elseif ( $ x == 'bottom' ) { $ x = $ this -> height - $ image -> height ; } imagecopymerge ( $ this -> image_context , $ image -> image_context , $ x , $ y , 0 , 0 , $ image -> width , $ image -> height , $ alpha ) ; return $ this ; }
|
add an layer to the current image
|
7,254
|
public function fill_color ( $ color , $ alpha = 1 ) { $ alpha = $ alpha * 127 ; $ color = CCColor :: create ( $ color ) ; $ color = imagecolorallocatealpha ( $ this -> image_context , $ color -> RGB [ 0 ] , $ color -> RGB [ 1 ] , $ color -> RGB [ 2 ] , $ alpha ) ; imagefill ( $ this -> image_context , 0 , 0 , $ color ) ; return $ this ; }
|
fill the current image with an color you can pass an array with rgb or hex string
|
7,255
|
public function blur ( $ ratio = 5 ) { for ( $ x = 0 ; $ x < $ ratio ; $ x ++ ) { imagefilter ( $ this -> image_context , IMG_FILTER_GAUSSIAN_BLUR ) ; } return $ this ; }
|
Blur the image using the gaussian blur .
|
7,256
|
public function get_luminance ( $ num_samples = 10 ) { $ x_step = ( int ) $ this -> width / $ num_samples ; $ y_step = ( int ) $ this -> height / $ num_samples ; $ total_lum = 0 ; $ sample_no = 1 ; for ( $ x = 0 ; $ x < $ this -> width ; $ x += $ x_step ) { for ( $ y = 0 ; $ y < $ this -> height ; $ y += $ y_step ) { $ rgb = imagecolorat ( $ this -> image_context , $ x , $ y ) ; $ r = ( $ rgb >> 16 ) & 0xFF ; $ g = ( $ rgb >> 8 ) & 0xFF ; $ b = $ rgb & 0xFF ; $ lum = ( $ r + $ r + $ b + $ g + $ g + $ g ) / 6 ; $ total_lum += $ lum ; $ sample_no ++ ; } } return ( int ) ( $ total_lum / $ sample_no ) ; }
|
Get the average luminance of the image
|
7,257
|
function flip ( $ mode ) { $ width = $ this -> width ; $ height = $ this -> height ; $ src_x = 0 ; $ src_y = 0 ; $ src_width = $ width ; $ src_height = $ height ; switch ( $ mode ) { case 'vertical' : $ src_y = $ height - 1 ; $ src_height = - $ height ; break ; case 'horizontal' : $ src_x = $ width - 1 ; $ src_width = - $ width ; break ; case 'both' : $ src_x = $ width - 1 ; $ src_y = $ height - 1 ; $ src_width = - $ width ; $ src_height = - $ height ; break ; } $ imgdest = imagecreatetruecolor ( $ width , $ height ) ; if ( imagecopyresampled ( $ imgdest , $ this -> image_context , 0 , 0 , $ src_x , $ src_y , $ width , $ height , $ src_width , $ src_height ) ) { $ this -> image_context = $ imgdest ; } return $ this -> image_context ; }
|
Flip an image
|
7,258
|
public function work ( $ file , $ customFilters = null , $ customDeployer = null ) { foreach ( $ this -> assetsSource as $ source ) { if ( is_file ( $ source . DIRECTORY_SEPARATOR . $ file ) ) { $ asset = $ this -> objectsFactory -> buildAsset ( $ source . DIRECTORY_SEPARATOR . $ file ) ; } } if ( ! isset ( $ asset ) ) { $ asset = $ this -> objectsFactory -> buildAsset ( $ file ) ; } if ( is_array ( $ customFilters ) ) { $ filters = $ customFilters ; } else { $ ext = $ asset -> getExtension ( ) ; $ filters = isset ( $ this -> filters [ $ ext ] ) ? $ this -> filters [ $ ext ] : array ( ) ; } if ( is_string ( $ customDeployer ) ) { $ deployer = $ customDeployer ; } else { $ deployer = $ this -> loadedDeployer ; } $ cacheKey = $ this -> computeCacheKey ( $ asset -> getFullPath ( ) , $ filters , $ deployer ) ; $ cacheValue = $ this -> loadedCacheAdapter -> get ( $ cacheKey ) ; if ( $ cacheValue !== false ) { $ asset -> setOutputUrl ( $ cacheValue ) ; return $ asset ; } $ this -> applyFilterOutputExtension ( $ filters , $ asset ) ; if ( isset ( $ this -> deployersInstances [ $ deployer ] ) && $ this -> deployersInstances [ $ deployer ] -> isPreviouslyDeployed ( $ asset ) ) { $ cacheValue = $ asset -> getOutputUrl ( ) ; $ this -> loadedCacheAdapter -> save ( $ cacheKey , $ cacheValue , $ this -> cacheTtl ) ; return $ asset ; } $ this -> filterAsset ( $ filters , $ asset ) ; $ this -> deployAsset ( $ deployer , $ asset ) ; $ cacheValue = $ asset -> getOutputUrl ( ) ; $ this -> loadedCacheAdapter -> save ( $ cacheKey , $ cacheValue , $ this -> cacheTtl ) ; return $ asset ; }
|
Processes and deploys an asset and returns an Asset instance with modified properties according to used filters and deployers .
|
7,259
|
private function deployAsset ( $ deploy , Asset $ asset ) { if ( $ this -> loadDeployer ( $ deploy ) ) { try { $ this -> deployersInstances [ $ deploy ] -> deploy ( $ asset ) ; } catch ( PhassetsInternalException $ e ) { $ this -> loadedLogger -> error ( 'An error occurred while deploying the asset: ' . $ e ) ; } } }
|
Tries to load a deployer and passes the Asset instance through it .
|
7,260
|
private function loadFilter ( $ class ) { if ( isset ( $ this -> filtersInstances [ $ class ] ) ) { return true ; } $ filter = $ this -> objectsFactory -> buildFilter ( $ class , $ this -> loadedConfigurator ) ; if ( $ filter === false ) { $ this -> loadedLogger -> warning ( 'Could not load ' . $ class . ' filter.' ) ; return false ; } $ this -> filtersInstances [ $ class ] = $ filter ; $ this -> loadedLogger -> debug ( 'Filter ' . $ class . ' found & loaded.' ) ; return true ; }
|
Try to create & load an instance of a given Filter class name .
|
7,261
|
private function loadDeployer ( $ class ) { if ( isset ( $ this -> deployersInstances [ $ class ] ) ) { return true ; } $ deployer = $ this -> objectsFactory -> buildDeployer ( $ class , $ this -> loadedConfigurator , $ this -> loadedCacheAdapter ) ; if ( $ deployer === false ) { $ this -> loadedLogger -> warning ( 'Could not load ' . $ class . ' deployer.' ) ; return false ; } try { $ deployer -> isSupported ( ) ; } catch ( PhassetsInternalException $ e ) { $ this -> loadedLogger -> warning ( $ class . ' deployer is not supported: ' . $ e ) ; } $ this -> deployersInstances [ $ class ] = $ deployer ; $ this -> loadedLogger -> debug ( 'Deployer ' . $ class . ' found & loaded.' ) ; return true ; }
|
Try to create & load an instance of a given Deployer class name .
|
7,262
|
private function loadAssetsManager ( $ class ) { if ( isset ( $ this -> assetsMergerInstances [ $ class ] ) ) { return true ; } $ merger = $ this -> objectsFactory -> buildAssetsMerger ( $ class , $ this -> loadedConfigurator ) ; if ( $ merger === false ) { $ this -> loadedLogger -> warning ( 'Could not load ' . $ class . ' merger.' ) ; return false ; } $ this -> assetsMergerInstances [ $ class ] = $ merger ; $ this -> loadedLogger -> debug ( 'Assets merger ' . $ class . ' found & loaded.' ) ; return true ; }
|
Try to create & load an instance of a given AssetsMerger class name .
|
7,263
|
public function populateIndex ( ) { $ this -> buildDocumentsByManager ( $ this -> doctrine ) ; if ( $ this -> mongo ) { $ this -> buildDocumentsByManager ( $ this -> mongo ) ; } if ( ! empty ( $ this -> documents ) ) { $ response = $ this -> searchProvider -> addDocuments ( $ this -> documents ) ; $ this -> documents = [ ] ; } }
|
Populate the indexes
|
7,264
|
protected function render ( $ view , array $ parameters = array ( ) , Response $ response = null ) { return $ this -> app -> render ( $ view , $ parameters , $ response ) ; }
|
Render to response twig views .
|
7,265
|
public function redirectMyContentTypeNode ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ language = $ this -> languageManager -> getCurrentLanguage ( ) -> getId ( ) ; if ( $ request -> attributes -> get ( '_route' ) !== 'entity.node.canonical' ) { return ; } if ( $ request -> attributes -> get ( 'node' ) -> getType ( ) !== 'challenge' ) { return ; } $ node = $ request -> attributes -> get ( 'node' ) ; if ( $ language == 'fr' ) { $ redirect_url = '/fr/defis/' . $ node -> getTranslation ( 'fr' ) -> get ( 'field_friendly_url' ) -> getValue ( ) [ 0 ] [ 'value' ] ; } else { $ redirect_url = '/en/challenges/' . $ node -> get ( 'field_friendly_url' ) -> getValue ( ) [ 0 ] [ 'value' ] ; } $ response = new RedirectResponse ( $ redirect_url , 301 ) ; $ event -> setResponse ( $ response ) ; }
|
Redirect requests for challenge go to custom module controller route .
|
7,266
|
public function setBody ( $ body ) { if ( is_array ( $ body ) || is_object ( $ body ) ) $ this -> body = ( object ) $ body ; else $ this -> body = $ body ; return $ this ; }
|
Setzt den RequestBody
|
7,267
|
public function profile ( OutputInterface $ output , array $ response ) { $ this -> printList ( $ output , [ 'Fullname' , 'Username' , 'Email' , 'Admin' , 'Notifications' ] , [ 'fullname' , 'username' , 'email' , 'admin' , 'notifications' ] , $ response , function ( $ key , $ value ) { if ( 'Notifications' !== $ key ) { return $ value ; } return sprintf ( '%d / %d' , $ value [ 'new' ] , $ value [ 'total' ] ) ; } ) ; }
|
output for the profile api .
|
7,268
|
public function comments ( OutputInterface $ output , array $ response ) { $ table = $ this -> createTable ( $ output ) ; $ table -> setHeaders ( [ 'Name' , 'Language' , 'Version' , 'Type' , 'Date' , 'Comment' ] ) ; foreach ( $ response [ 'comments' ] as $ comment ) { $ table -> addRow ( [ $ comment [ 'product' ] [ 'name' ] , $ comment [ 'product' ] [ 'language' ] , $ comment [ 'product' ] [ 'version' ] , $ comment [ 'product' ] [ 'prod_type' ] , $ comment [ 'created_at' ] , $ comment [ 'comment' ] ] ) ; } $ table -> render ( $ output ) ; }
|
output for the comments api .
|
7,269
|
public function setMeta ( $ name , $ content = NULL , $ httpEquiv = FALSE , $ scheme = NULL ) { $ meta = HTML :: Tag ( 'meta' ) ; $ meta -> setOption ( 'selfClosing' , TRUE ) ; if ( $ content === NULL ) { $ this -> removeMeta ( $ name ) ; } else { if ( isset ( $ name ) ) { if ( ! $ httpEquiv ) $ meta -> setAttribute ( 'name' , $ name ) ; else $ meta -> setAttribute ( 'http-equiv' , $ name ) ; } if ( isset ( $ scheme ) ) $ meta -> setAttribute ( 'scheme' , $ scheme ) ; if ( $ content !== FALSE ) { $ meta -> setAttribute ( 'content' , $ content ) ; } $ key = NULL ; foreach ( $ this -> head -> content as $ itemKey => $ item ) { if ( $ item instanceof Tag && $ item -> getTag ( ) == 'meta' && ( $ item -> getAttribute ( 'name' ) == $ name || $ item -> getAttribute ( 'http-equiv' ) == $ name ) ) { $ key = $ itemKey ; break ; } } if ( $ key !== NULL ) { $ this -> head -> content [ $ key ] = & $ meta ; } else { $ this -> head -> content [ ] = & $ meta ; } } return $ meta ; }
|
Setzt ein Meta Attribut
|
7,270
|
public function validate ( $ data ) { if ( isset ( $ this -> callback ) ) { return $ this -> callback -> call ( array ( $ data ) ) ; } throw new \ Psc \ Exception ( 'empty rule!' ) ; }
|
Validiert die gespeicherte Rule
|
7,271
|
public function getForm ( $ entityClass = null ) { if ( null === $ entityClass ) { $ entityClass = $ this -> getEntityClass ( ) ; } $ builder = new AnnotationBuilder ( ) ; $ form = $ builder -> createForm ( $ entityClass ) ; $ hasEntity = false ; foreach ( $ form -> getElements ( ) as $ element ) { if ( method_exists ( $ element , 'setObjectManager' ) ) { $ element -> setObjectManager ( $ this -> getEntityManager ( ) ) ; $ hasEntity = true ; } elseif ( method_exists ( $ element , 'getProxy' ) ) { $ proxy = $ element -> getProxy ( ) ; if ( method_exists ( $ proxy , 'setObjectManager' ) ) { $ proxy -> setObjectManager ( $ this -> getEntityManager ( ) ) ; $ hasEntity = true ; } } } if ( $ hasEntity ) { $ hydrator = new DoctrineHydrator ( $ this -> getEntityManager ( ) , $ entityClass ) ; $ form -> setHydrator ( $ hydrator ) ; } else { $ form -> setHydrator ( new ClassMethods ( ) ) ; } $ form -> add ( [ 'type' => 'Zend\Form\Element\Csrf' , 'name' => 'csrf' , 'attributes' => [ 'id' => 'csrf' , ] , ] ) ; $ submitElement = new \ Zend \ Form \ Element \ Button ( 'submit' ) ; $ submitElement -> setAttributes ( [ 'type' => 'submit' , 'class' => 'btn btn-primary' , ] ) ; $ submitElement -> setLabel ( 'Salvar' ) ; $ form -> add ( $ submitElement , [ 'priority' => - 100 , ] ) ; $ cancelarElement = new \ Zend \ Form \ Element \ Button ( 'cancelar' ) ; $ cancelarElement -> setAttributes ( [ 'type' => 'button' , 'class' => 'btn btn-default' , 'onclick' => 'top.location=\'' . $ this -> url ( ) -> fromRoute ( $ this -> getActionRoute ( 'list' ) ) . '\'' , ] ) ; $ cancelarElement -> setLabel ( 'Cancelar' ) ; $ form -> add ( $ cancelarElement , [ 'priority' => - 100 , ] ) ; return $ form ; }
|
Retorna a form para o cadastro da entidade .
|
7,272
|
public function getQueryFrom ( DatatableViewInterface $ datatableView ) { $ twig = $ datatableView -> getTwig ( ) ; $ type = $ datatableView -> getAjax ( ) -> getType ( ) ; $ parameterBag = null ; if ( 'GET' === strtoupper ( $ type ) ) { $ parameterBag = $ this -> request -> query ; } if ( 'POST' === strtoupper ( $ type ) ) { $ parameterBag = $ this -> request -> request ; } $ params = $ parameterBag -> all ( ) ; $ query = new DatatableQuery ( $ this -> serializer , $ params , $ datatableView , $ this -> configs , $ twig , $ this -> imagineBundle , $ this -> doctrineExtensions , $ this -> locale ) ; return $ query ; }
|
Get query .
|
7,273
|
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof UserCustomerRelationQuery ) { return $ criteria ; } $ query = new UserCustomerRelationQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
|
Returns a new UserCustomerRelationQuery object .
|
7,274
|
public function filterByUser ( $ user , $ comparison = null ) { if ( $ user instanceof User ) { return $ this -> addUsingAlias ( UserCustomerRelationPeer :: USER_ID , $ user -> getId ( ) , $ comparison ) ; } elseif ( $ user instanceof PropelObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( UserCustomerRelationPeer :: USER_ID , $ user -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByUser() only accepts arguments of type User or PropelCollection' ) ; } }
|
Filter the query by a related User object
|
7,275
|
private static function prepare ( $ type , $ message ) { $ type = strtolower ( $ type ) ; if ( ! in_array ( $ type , static :: $ _types ) ) { throw new Exception ( "UI\Alert - Unknown alert type '{$type}'!" ) ; } if ( ! is_array ( $ message ) ) { return array ( $ message ) ; } return $ message ; }
|
Validate the alert type and format the message
|
7,276
|
public function getCloudStorage ( ) : ? Cloud { if ( ! $ this -> hasCloudStorage ( ) ) { $ this -> setCloudStorage ( $ this -> getDefaultCloudStorage ( ) ) ; } return $ this -> cloudStorage ; }
|
Get cloud storage
|
7,277
|
public function getDefaultCloudStorage ( ) : ? Cloud { $ manager = Storage :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { return $ manager -> disk ( ) ; } return $ manager ; }
|
Get a default cloud storage value if any is available
|
7,278
|
public function stream ( ) { if ( ob_get_level ( ) ) { ob_end_clean ( ) ; } if ( $ fd = fopen ( $ this -> path , 'rb' ) ) { while ( ! feof ( $ fd ) ) { echo fread ( $ fd , 1024 ) ; } fclose ( $ fd ) ; } }
|
Transfer an image to the browser
|
7,279
|
protected function getCachingHeaders ( $ fileinfo ) { $ last_modified = gmdate ( 'D, d M Y H:i:s' , $ fileinfo [ 9 ] ) . ' GMT' ; $ etag = md5 ( $ last_modified ) ; $ if_modified_since = $ this -> server_value ( 'HTTP_IF_MODIFIED_SINCE' , false ) ; $ if_none_match = $ this -> server_value ( 'HTTP_IF_NONE_MATCH' , false ) ; if ( $ if_modified_since && $ if_none_match && $ if_none_match == $ etag && $ if_modified_since == $ last_modified ) { $ this -> status = 304 ; } $ this -> headers [ 'Last-Modified' ] = $ last_modified ; $ this -> headers [ 'ETag' ] = $ etag ; }
|
Set file headers that handle If - Modified - Since correctly for the given fileinfo .
|
7,280
|
public function addCode ( $ tableName , $ columnName = 'code' ) { $ this -> addColumn ( '{{%' . $ tableName . '}}' , $ columnName , $ this -> string ( 32 ) -> comment ( 'Code for this item, used identifying when needed. Another criteria to replace ID because ID is auto-increment' ) ) ; $ this -> createIndex ( $ tableName . '_' . $ columnName . '_idx' , '{{%' . $ tableName . '}}' , $ columnName ) ; }
|
Add and put index to code column Use if identity an item alternatively to ID
|
7,281
|
public function addCreatorID ( $ tableName , $ columnName = 'creator_id' ) { $ this -> addColumn ( '{{%' . $ tableName . '}}' , $ columnName , $ this -> bigInteger ( ) -> comment ( 'ID of user who created this item' ) ) ; $ this -> createIndex ( $ tableName . '_' . $ columnName . '_idx' , '{{%' . $ tableName . '}}' , $ columnName ) ; }
|
Add and put Index to creator_id column Store id of user who create this record
|
7,282
|
public function setAutoCompleteRequestMeta ( \ Psc \ CMS \ AutoCompleteRequestMeta $ autoCompleteRequestMeta ) { $ this -> acRequestMeta = $ autoCompleteRequestMeta ; $ this -> avaibleItems = NULL ; return $ this ; }
|
Ist dies gesetzt wird avaibleItems ignoriert
|
7,283
|
public static function attachLabel ( $ element , $ label , $ type = self :: LABEL_TOP ) { Code :: value ( $ type , self :: LABEL_TOP , self :: LABEL_CHECKBOX ) ; if ( $ label != NULL ) { $ element -> templateContent -> label = fHTML :: label ( $ label , $ element ) -> addClass ( '\Psc\label' ) ; if ( $ type == self :: LABEL_TOP ) { $ element -> templatePrepend ( '%label%' ) ; } if ( $ type == self :: LABEL_CHECKBOX ) { $ element -> template = '%self% %label%' ; $ element -> templateContent -> label -> addClass ( 'checkbox-label' ) ; } } return $ element ; }
|
benutzt von dropBox2
|
7,284
|
public static function hasTrait ( $ class , $ traitName , $ isRecursive = false ) { if ( is_string ( $ class ) ) { $ class = new \ ReflectionClass ( $ class ) ; } if ( in_array ( $ traitName , $ class -> getTraitNames ( ) , true ) ) { return true ; } $ parentClass = $ class -> getParentClass ( ) ; if ( ( false === $ isRecursive ) || ( false === $ parentClass ) || ( null === $ parentClass ) ) { return false ; } return static :: hasTrait ( $ parentClass , $ traitName , $ isRecursive ) ; }
|
Return true if the given object use the given trait FALSE if not .
|
7,285
|
public function sort ( array $ sorts = array ( ) ) { if ( func_num_args ( ) === 0 ) { return $ this -> sorts ; } $ this -> sorts = array ( ) ; foreach ( $ sorts as $ key => $ value ) { if ( $ key [ 0 ] === '$' ) { $ key [ 0 ] = '_' ; } $ this -> sorts [ $ key ] = $ value ; } return $ this ; }
|
When argument specified will set new sorts otherwise will return existing sorts
|
7,286
|
public function match ( $ q ) { if ( is_null ( $ q ) ) { return $ this ; } $ orCriteria = array ( ) ; $ schema = $ this -> collection -> schema ( ) ; if ( empty ( $ schema ) ) { throw new \ Exception ( '[Norm\Cursor] Cannot use match for schemaless collection' ) ; } foreach ( $ schema as $ key => $ value ) { $ orCriteria [ ] = array ( $ key . '!like' => $ q ) ; } $ this -> criteria = $ this -> translateCriteria ( array ( '!or' => $ orCriteria ) ) ; return $ this ; }
|
Set query to match on every field exists in schema . Beware this will override criteria
|
7,287
|
public function toArray ( $ plain = false ) { $ result = array ( ) ; foreach ( $ this as $ key => $ value ) { if ( $ plain ) { $ result [ ] = $ value -> toArray ( ) ; } else { $ result [ ] = $ this -> connection -> unmarshall ( $ value ) ; } } return $ result ; }
|
Extract data into array of models .
|
7,288
|
public function import ( array $ data ) { $ response = $ this -> client -> post ( "{$this->uriImport}product/" , [ 'json' => $ data , 'query' => [ 'key' => $ this -> config [ 'data' ] [ 'key' ] , ] , ] ) ; $ response = json_decode ( $ response -> getBody ( ) , true ) ; if ( isset ( $ response [ 'affected' ] ) && $ response [ 'affected' ] > 0 ) { return true ; } return false ; }
|
Atomic product import .
|
7,289
|
public function search ( array $ data ) { if ( ! isset ( $ data [ 'size' ] ) ) { $ data [ 'size' ] = 10 ; } $ response = $ this -> client -> post ( "{$this->uriSearch}search/" , [ 'json' => $ data , 'query' => [ 'key' => $ this -> config [ 'search' ] [ 'key' ] , ] , ] ) ; $ response = json_decode ( $ response -> getBody ( ) , true ) ; return $ response ; }
|
Product Search .
|
7,290
|
public function delete ( $ id ) { $ response = false ; if ( empty ( $ id ) ) { throw new \ InvalidArgumentException ( 'ID Product cannot be empty' ) ; } try { $ apiResponse = $ this -> client -> delete ( "{$this->uriImport}product/{$id}" , [ 'query' => [ 'key' => $ this -> config [ 'data' ] [ 'key' ] , ] , ] ) ; $ apiResponse = json_decode ( $ apiResponse -> getBody ( ) , true ) ; if ( isset ( $ apiResponse [ 'affected' ] ) && $ apiResponse [ 'affected' ] > 0 ) { $ response = true ; } } catch ( ClientException $ e ) { $ response = false ; } return $ response ; }
|
Product Delete .
|
7,291
|
public function addAlias ( $ location , $ path ) { $ this -> setVar ( 'aliases' , $ this -> getVar ( 'aliases' ) . sprintf ( "\n Alias %s %s" , $ location , $ this -> replaceHelpers ( $ path ) ) ) ; return $ this ; }
|
Adds an Location alias
|
7,292
|
public function findSubjects ( Category $ category , $ getQuery = false ) { $ dql = " SELECT s.id as id, COUNT(m_count.id) AS count_messages, MAX(m.creationDate) AS last_message_created, s.id as subjectId, s.title as title, s.isSticked as isSticked, s.author as subject_author, subjectCreator.lastName as subject_creator_lastname, subjectCreator.firstName as subject_creator_firstname, subjectCreator.id as subject_creator_id, lastUser.lastName as last_message_creator_lastname, lastUser.firstName as last_message_creator_firstname, s.creationDate as subject_created, s.isClosed as is_closed FROM Claroline\ForumBundle\Entity\Subject s JOIN s.messages m_count JOIN s.creator subjectCreator JOIN s.category category JOIN s.messages m JOIN m.creator lastUser WITH lastUser.id = ( SELECT lcu.id FROM Claroline\ForumBundle\Entity\Message m2 JOIN m2.subject s2 JOIN m2.creator lcu JOIN s2.category c2 WHERE NOT EXISTS ( SELECT m3 FROM Claroline\ForumBundle\Entity\Message m3 JOIN m3.subject s3 WHERE s2.id = s3.id AND m2.id < m3.id ) and c2.id = :categoryId and m2.id = m.id ) WHERE category.id = :categoryId GROUP BY s.id, subjectCreator.lastName, subjectCreator.firstName, lastUser.lastName, lastUser.firstName ORDER BY isSticked DESC, last_message_created DESC " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'categoryId' , $ category -> getId ( ) ) ; return ( $ getQuery ) ? $ query : $ query -> getResult ( ) ; }
|
Deep magic goes here . Gets a subject with some of its last messages datas .
|
7,293
|
public function getMemoryUsageData ( ) { if ( null === $ this -> memoryUsageData ) { $ memoryUsage = memory_get_usage ( ) ; $ unit = [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ] ; $ this -> memoryUsageData = [ round ( $ memoryUsage / pow ( 1024 , ( $ i = floor ( log ( $ memoryUsage , 1024 ) ) ) ) , 2 ) , $ unit [ $ i ] ] ; } return $ this -> memoryUsageData ; }
|
Return the application memory usage data .
|
7,294
|
public function setConfiguration ( array $ config = [ ] ) { $ config = $ config + $ this -> getDefaultConfiguration ( ) ; if ( ! empty ( $ config [ 'debug' ] ) ) { $ this -> config = $ config ; } return $ config ; }
|
Return application configuration values .
|
7,295
|
private function generateNotFoundPlainResponse ( ServerRequestInterface $ request ) : ResponseInterface { $ response = ( $ this -> responseFactory ) ( ) -> withStatus ( StatusCodeInterface :: STATUS_NOT_FOUND ) ; $ response -> getBody ( ) -> write ( \ sprintf ( "Encountered a 404 Error, %s doesn't exist" , ( string ) $ request -> getUri ( ) ) ) ; return $ response ; }
|
Generates a plain text response indicating the request method and URI .
|
7,296
|
private function generateTemplateResponse ( Renderer $ renderer , ServerRequestInterface $ request ) : ResponseInterface { $ response = ( $ this -> responseFactory ) ( ) -> withStatus ( StatusCodeInterface :: STATUS_NOT_FOUND ) ; $ response -> getBody ( ) -> write ( $ renderer -> render ( $ this -> template , [ 'request' => $ request ] ) ) ; return $ response ; }
|
Generates a response using a template .
|
7,297
|
public function action_uninstall ( $ params ) { $ path = $ params [ 0 ] ; if ( empty ( $ path ) ) { CCCli :: line ( 'no ship path given.' , 'red' ) ; return ; } if ( substr ( $ path , 0 , 1 ) == '/' ) { if ( substr ( $ path , - 1 ) != '/' ) { $ path .= '/' ; } if ( ! is_dir ( $ path ) ) { CCCli :: line ( 'could not find a ship at path: ' . $ path , 'red' ) ; return ; } if ( ! CCCli :: confirm ( "are you sure you want to uninstall this ship?" , true ) ) { return ; } try { \ CCOrbit :: uninstall ( $ path ) ; } catch ( \ Exception $ e ) { CCCli :: line ( $ e -> getMessage ( ) , 'red' ) ; CCCli :: line ( 'ship destroying failure.' , 'red' ) ; return ; } if ( CCCli :: confirm ( "do you also wish to remove the ship files?" , true ) ) { \ CCFile :: delete ( $ path ) ; } CCCli :: line ( 'ship destroyed!' , 'green' ) ; return ; } if ( is_dir ( ORBITPATH . $ path ) ) { CCCli :: line ( 'found ship at path: ' . ORBITPATH . $ path , 'green' ) ; return static :: action_uninstall ( array ( ORBITPATH . $ path ) ) ; } CCCli :: line ( 'could not find a ship at this path or name.' , 'red' ) ; return ; }
|
uninstall an orbit module
|
7,298
|
private function config ( ) { $ this -> loadViewsFrom ( __DIR__ . '/views' , 'center' ) ; $ this -> loadTranslationsFrom ( __DIR__ . '/translations' , 'center' ) ; $ this -> publishes ( [ __DIR__ . '/../assets/public' => public_path ( 'vendor/center' ) , ] , 'public' ) ; $ this -> publishes ( [ __DIR__ . '/config' => config_path ( 'center' ) , ] , 'config' ) ; $ this -> publishes ( [ __DIR__ . '/translations/en/site.php' => app_path ( '../resources/lang/vendor/center/en/site.php' ) , __DIR__ . '/translations/en/users.php' => app_path ( '../resources/lang/vendor/center/en/users.php' ) , ] , 'lang' ) ; include __DIR__ . '/routes.php' ; }
|
set up publishes paths and define config locations
|
7,299
|
function isNumberIn ( $ number , $ integerConstraint = true ) { foreach ( $ this -> parts as $ part ) { if ( is_array ( $ part ) ) { if ( ( ! $ integerConstraint || floor ( $ number ) === ( float ) $ number ) && $ number >= $ part [ 0 ] && $ number <= $ part [ 1 ] ) { return true ; } } else { if ( $ number == $ part ) { return true ; } } } return false ; }
|
Determine if the given number is inside the range .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.