idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
50,200 | public function jsonSerialize ( ) { if ( ! $ this -> originalFilename ( ) ) { return [ ] ; } $ data = [ ] ; foreach ( $ this -> variants ( true ) as $ variant ) { $ data [ $ variant ] = [ 'path' => $ this -> variantPath ( $ variant ) , 'url' => $ this -> url ( $ variant ) ] ; } return $ data ; } | Return a JSON representation of this class . |
50,201 | protected function getOrMakeTargetInstance ( ) { if ( $ this -> target ) { return $ this -> target ; } $ this -> target = new InterpolatingTarget ( $ this -> interpolator , $ this , $ this -> config -> path ( ) , $ this -> config -> variantPath ( ) ) ; $ this -> target -> setVariantFilenames ( $ this -> variantFilename... | Returns the target instance to be passed to the file handler . |
50,202 | protected function makeTargetInstanceWithCurrentData ( ) { $ this -> target = new InterpolatingTarget ( $ this -> interpolator , $ this -> getCurrentAttachmentData ( ) , $ this -> config -> path ( ) , $ this -> config -> variantPath ( ) ) ; $ this -> target -> setVariantFilenames ( $ this -> variantFilenames ( ) ) ; $ ... | Returns a target instance with fixed historical data for the current state . |
50,203 | protected function variantFilenames ( ) { $ names = [ ] ; foreach ( $ this -> variants ( ) as $ variant ) { $ names [ $ variant ] = $ this -> variantFilename ( $ variant ) ; } return $ names ; } | Returns filenames keyed by variant . |
50,204 | protected function variantExtensions ( ) { $ extensions = $ this -> config -> variantExtensions ( ) ; $ variants = $ this -> variantsAttribute ( ) ; if ( ! empty ( $ variants ) ) { foreach ( $ this -> variants ( ) as $ variant ) { $ extension = Arr :: get ( $ variants , "{$variant}.ext" ) ; if ( $ extension ) { $ exten... | Returns alternative extensions keyed by variant . |
50,205 | public function afterSave ( AttachableInterface $ instance ) { $ this -> instance = $ instance ; $ this -> save ( ) ; $ this -> performCallableHookAfterProcessing ( ) ; } | Processes the write queue . |
50,206 | public function beforeDelete ( AttachableInterface $ instance ) { $ this -> instance = $ instance ; if ( ! $ this -> config -> preserveFiles ( ) ) { $ this -> clear ( ) ; } } | Queues up this attachments files for deletion . |
50,207 | protected function flushWrites ( ) { if ( ! $ this -> queuedForWrite ) { return ; } $ target = $ this -> getOrMakeTargetInstance ( ) ; $ storedFiles = $ this -> handler -> process ( $ this -> uploadedFile , $ target , $ this -> config -> toArray ( ) ) ; if ( $ this -> shouldVariantInformationBeStored ( ) ) { $ original... | Process the queuedForWrite queue . |
50,208 | protected function flushDeletes ( ) { if ( ! $ this -> deleteTarget ) { return ; } foreach ( $ this -> queuedForDelete as $ variant ) { $ this -> handler -> deleteVariant ( $ this -> deleteTarget , $ variant ) ; } $ this -> queuedForDelete = [ ] ; } | Process the queuedForDeletion queue . |
50,209 | protected function getCurrentAttachmentData ( ) { $ attributes = [ 'file_name' => $ this -> originalFilename ( ) , 'file_size' => $ this -> size ( ) , 'content_type' => $ this -> contentType ( ) , 'updated_at' => $ this -> updatedAt ( ) , 'created_at' => $ this -> createdAt ( ) , 'variants' => $ this -> variantsAttribu... | Returns the current attachment state data . |
50,210 | public function clearAttributes ( ) { $ this -> instanceWrite ( 'file_name' , null ) ; $ this -> instanceWrite ( 'file_size' , null ) ; $ this -> instanceWrite ( 'content_type' , null ) ; $ this -> instanceWrite ( 'updated_at' , null ) ; $ this -> instanceWrite ( 'variants' , null ) ; } | Clears all attachment related model attributes . |
50,211 | public function instanceWrite ( $ property , $ value ) { if ( $ property !== 'file_name' && ! $ this -> config -> attributeProperty ( $ property ) ) { return ; } $ this -> instance -> setAttribute ( "{$this->name}_{$property}" , $ value ) ; } | Sets an attachment property on the model instance . |
50,212 | private function attach ( ) { try { $ this -> semaphore = sem_get ( $ this -> key ) ; $ this -> mutex = new SemaphoreMutex ( $ this -> semaphore ) ; } catch ( \ InvalidArgumentException $ e ) { throw new StorageException ( "Could not get semaphore id." , 0 , $ e ) ; } $ this -> memory = shm_attach ( $ this -> key , 128... | Attaches the shared memory segment . |
50,213 | private function forVendor ( array $ map , $ default = "" ) { $ vendor = $ this -> pdo -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ; return isset ( $ map [ $ vendor ] ) ? $ map [ $ vendor ] : $ default ; } | Returns a vendor specific dialect value . |
50,214 | private function querySingleValue ( $ sql , $ parameters = [ ] ) { try { $ statement = $ this -> pdo -> prepare ( $ sql ) ; $ statement -> execute ( $ parameters ) ; $ value = $ statement -> fetchColumn ( ) ; $ statement -> closeCursor ( ) ; if ( $ value === false ) { throw new StorageException ( "The query returned no... | Returns one value from a query . |
50,215 | private function onErrorRollback ( callable $ code ) { if ( ! $ this -> pdo -> inTransaction ( ) ) { return call_user_func ( $ code ) ; } $ this -> pdo -> exec ( "SAVEPOINT onErrorRollback" ) ; try { $ result = call_user_func ( $ code ) ; } catch ( \ Exception $ e ) { $ this -> pdo -> exec ( "ROLLBACK TO SAVEPOINT onEr... | Rollback to an implicit savepoint . |
50,216 | public function convertMicrotimeToTokens ( $ microtime ) { $ delta = bcsub ( microtime ( true ) , $ microtime , $ this -> bcScale ) ; return $ this -> convertSecondsToTokens ( $ delta ) ; } | Converts a timestamp into tokens . |
50,217 | public static function unpack ( $ string ) { if ( strlen ( $ string ) !== 8 ) { throw new StorageException ( "The string is not 64 bit long." ) ; } $ unpack = unpack ( "d" , $ string ) ; if ( ! is_array ( $ unpack ) || ! array_key_exists ( 1 , $ unpack ) ) { throw new StorageException ( "Could not unpack string." ) ; }... | Unpacks a 64 bit double from an 8 byte string . |
50,218 | private function open ( ) { $ this -> fileHandle = fopen ( $ this -> path , "c+" ) ; if ( ! is_resource ( $ this -> fileHandle ) ) { throw new StorageException ( "Could not open '$this->path'." ) ; } $ this -> mutex = new FlockMutex ( $ this -> fileHandle ) ; } | Opens the file and initializes the mutex . |
50,219 | public function consume ( $ tokens ) { $ timedOut = is_null ( $ this -> timeout ) ? null : ( microtime ( true ) + $ this -> timeout ) ; while ( ! $ this -> bucket -> consume ( $ tokens , $ seconds ) ) { self :: throwTimeoutIfExceeded ( $ timedOut ) ; $ seconds = self :: keepSecondsWithinTimeout ( $ seconds , $ timedOut... | Consumes tokens . |
50,220 | private static function keepSecondsWithinTimeout ( $ seconds , $ timedOut ) { if ( is_null ( $ timedOut ) ) { return $ seconds ; } $ remainingSeconds = max ( $ timedOut - microtime ( true ) , 0 ) ; return min ( $ remainingSeconds , $ seconds ) ; } | Adjusts the wait seconds to be within the timeout . |
50,221 | public function bootstrap ( $ tokens = 0 ) { try { if ( $ tokens > $ this -> capacity ) { throw new \ LengthException ( "Initial token amount ($tokens) is larger than the capacity ($this->capacity)." ) ; } if ( $ tokens < 0 ) { throw new \ InvalidArgumentException ( "Initial token amount ($tokens) should be greater tha... | Bootstraps the storage with an initial amount of tokens . |
50,222 | public function consume ( $ tokens , & $ seconds = 0 ) { try { if ( $ tokens > $ this -> capacity ) { throw new \ LengthException ( "Token amount ($tokens) is larger than the capacity ($this->capacity)." ) ; } if ( $ tokens <= 0 ) { throw new \ InvalidArgumentException ( "Token amount ($tokens) should be greater than 0... | Consumes tokens from the bucket . |
50,223 | private function loadTokensAndTimestamp ( ) { $ microtime = $ this -> storage -> getMicrotime ( ) ; $ minMicrotime = $ this -> tokenConverter -> convertTokensToMicrotime ( $ this -> capacity ) ; if ( $ minMicrotime > $ microtime ) { $ microtime = $ minMicrotime ; } $ tokens = $ this -> tokenConverter -> convertMicrotim... | Loads the stored timestamp and its respective amount of tokens . |
50,224 | private function updateResult ( string $ value ) : string { $ value = str_replace ( self :: $ foundEntitiesCache [ 0 ] , self :: $ foundEntitiesCache [ 1 ] , $ value ) ; if ( strstr ( $ value , 'html5-dom-document-internal-entity' ) !== false ) { $ search = [ ] ; $ replace = [ ] ; $ matches = [ ] ; preg_match_all ( '/h... | Updates the result value before returning it . |
50,225 | public function getAttribute ( $ name ) : string { if ( $ this -> attributes -> length === 0 ) { return '' ; } $ value = parent :: getAttribute ( $ name ) ; return $ value !== '' ? ( strstr ( $ value , 'html5-dom-document-internal-entity' ) !== false ? $ this -> updateResult ( $ value ) : $ value ) : '' ; } | Returns the value for the attribute name specified . |
50,226 | public function getAttributes ( ) : array { $ attributes = [ ] ; foreach ( $ this -> attributes as $ attributeName => $ attribute ) { $ value = $ attribute -> value ; $ attributes [ $ attributeName ] = $ value !== '' ? ( strstr ( $ value , 'html5-dom-document-internal-entity' ) !== false ? $ this -> updateResult ( $ va... | Returns an array containing all attributes . |
50,227 | private function addHtmlElementIfMissing ( ) : bool { if ( $ this -> getElementsByTagName ( 'html' ) -> length === 0 ) { if ( ! isset ( self :: $ newObjectsCache [ 'htmlelement' ] ) ) { self :: $ newObjectsCache [ 'htmlelement' ] = new \ DOMElement ( 'html' ) ; } $ this -> appendChild ( clone ( self :: $ newObjectsCach... | Adds the HTML tag to the document if missing . |
50,228 | private function addHeadElementIfMissing ( ) : bool { if ( $ this -> getElementsByTagName ( 'head' ) -> length === 0 ) { $ htmlElement = $ this -> getElementsByTagName ( 'html' ) -> item ( 0 ) ; if ( ! isset ( self :: $ newObjectsCache [ 'headelement' ] ) ) { self :: $ newObjectsCache [ 'headelement' ] = new \ DOMEleme... | Adds the HEAD tag to the document if missing . |
50,229 | private function addBodyElementIfMissing ( ) : bool { if ( $ this -> getElementsByTagName ( 'body' ) -> length === 0 ) { if ( ! isset ( self :: $ newObjectsCache [ 'bodyelement' ] ) ) { self :: $ newObjectsCache [ 'bodyelement' ] = new \ DOMElement ( 'body' ) ; } $ this -> getElementsByTagName ( 'html' ) -> item ( 0 ) ... | Adds the BODY tag to the document if missing . |
50,230 | public function saveHTMLFile ( $ filename ) { if ( ! is_writable ( $ filename ) ) { return false ; } $ result = $ this -> saveHTML ( ) ; file_put_contents ( $ filename , $ result ) ; $ bytesWritten = filesize ( $ filename ) ; if ( $ bytesWritten === strlen ( $ result ) ) { return $ bytesWritten ; } return false ; } | Dumps the internal document into a file using HTML formatting . |
50,231 | public function createInsertTarget ( string $ name ) { if ( ! $ this -> loaded ) { $ this -> loadHTML ( '' ) ; } $ element = $ this -> createElement ( 'html5-dom-document-insert-target' ) ; $ element -> setAttribute ( 'name' , $ name ) ; return $ element ; } | Creates an element that will be replaced by the new body in insertHTML . |
50,232 | public function item ( int $ index ) { return $ this -> offsetExists ( $ index ) ? $ this -> offsetGet ( $ index ) : null ; } | Returns the item at the specified index . |
50,233 | public function add ( string ... $ tokens ) { if ( count ( $ tokens ) === 0 ) { return ; } foreach ( $ tokens as $ t ) { if ( in_array ( $ t , $ this -> tokens ) ) { continue ; } $ this -> tokens [ ] = $ t ; } $ this -> setAttributeValue ( ) ; } | Adds the given tokens to the list . |
50,234 | public function remove ( string ... $ tokens ) { if ( count ( $ tokens ) === 0 ) { return ; } if ( count ( $ this -> tokens ) === 0 ) { return ; } foreach ( $ tokens as $ t ) { $ i = array_search ( $ t , $ this -> tokens ) ; if ( $ i === false ) { continue ; } array_splice ( $ this -> tokens , $ i , 1 ) ; } $ this -> s... | Removes the specified tokens from the list . If the string does not exist in the list no error is thrown . |
50,235 | public function toggle ( string $ token , bool $ force = null ) : bool { $ this -> tokenize ( ) ; $ isThereAfter = false ; $ i = array_search ( $ token , $ this -> tokens ) ; if ( is_null ( $ force ) ) { if ( $ i === false ) { $ this -> tokens [ ] = $ token ; $ isThereAfter = true ; } else { array_splice ( $ this -> to... | Removes a given token from the list and returns false . If token doesn t exist it s added and the function returns true . |
50,236 | public function contains ( string $ token ) : bool { $ this -> tokenize ( ) ; return in_array ( $ token , $ this -> tokens ) ; } | Returns true if the list contains the given token otherwise false . |
50,237 | public function replace ( string $ old , string $ new ) { if ( $ old === $ new ) { return ; } $ this -> tokenize ( ) ; $ i = array_search ( $ old , $ this -> tokens ) ; if ( $ i !== false ) { $ j = array_search ( $ new , $ this -> tokens ) ; if ( $ j === false ) { $ this -> tokens [ $ i ] = $ new ; } else { array_splic... | Replaces an existing token with a new token . |
50,238 | protected function getParametersAliases ( ) { return array_merge ( parent :: getParametersAliases ( ) , array ( "login" => GenerisRdf :: PROPERTY_USER_LOGIN , "password" => GenerisRdf :: PROPERTY_USER_PASSWORD , "guiLg" => GenerisRdf :: PROPERTY_USER_UILG , "dataLg" => GenerisRdf :: PROPERTY_USER_DEFLG , "firstName" =>... | Optionnaly a specific rest controller may declare aliases for parameters used for the rest communication |
50,239 | protected function initCors ( ) { $ headers = Yii :: $ app -> getResponse ( ) -> getHeaders ( ) ; $ headers -> set ( 'Access-Control-Allow-Headers' , implode ( ', ' , [ 'Content-Type' , $ this -> apiKeyParam , 'Authorization' , ] ) ) ; $ headers -> set ( 'Access-Control-Allow-Methods' , 'GET, POST, DELETE, PUT' ) ; $ h... | Init cors . |
50,240 | function setCharset ( $ charset ) { $ locale = setlocale ( LC_CTYPE , 0 ) ; setlocale ( LC_CTYPE , 'en_US' ) ; $ this -> _charset = strtolower ( $ charset ) ; setlocale ( LC_CTYPE , $ locale ) ; } | Sets the charset of the provided table data . |
50,241 | function setBorder ( $ border ) { if ( $ border === self :: CONSOLE_TABLE_BORDER_ASCII ) { $ intersection = '+' ; $ horizontal = '-' ; $ vertical = '|' ; } else { if ( is_string ( $ border ) ) { $ intersection = $ horizontal = $ vertical = $ border ; } else { if ( $ border == '' ) { $ intersection = $ horizontal = $ ve... | Set the table border settings |
50,242 | function setBorderVisibility ( $ visibility ) { $ this -> _borderVisibility = array_merge ( $ this -> _borderVisibility , array_intersect_key ( $ visibility , $ this -> _borderVisibility ) ) ; } | Set which borders shall be shown . |
50,243 | function setAlign ( $ col_id , $ align = self :: CONSOLE_TABLE_ALIGN_LEFT ) { switch ( $ align ) { case self :: CONSOLE_TABLE_ALIGN_CENTER : $ pad = STR_PAD_BOTH ; break ; case self :: CONSOLE_TABLE_ALIGN_RIGHT : $ pad = STR_PAD_LEFT ; break ; default : $ pad = STR_PAD_RIGHT ; break ; } $ this -> _col_align [ $ col_id ... | Sets the alignment for the columns . |
50,244 | function insertRow ( $ row , $ row_id = 0 ) { array_splice ( $ this -> _data , $ row_id , 0 , array ( $ row ) ) ; $ this -> _updateRowsCols ( $ row ) ; } | Inserts a row after a given row number in the table . |
50,245 | function addData ( $ data , $ col_id = 0 , $ row_id = 0 ) { foreach ( $ data as $ row ) { if ( $ row === self :: CONSOLE_TABLE_HORIZONTAL_RULE ) { $ this -> _data [ $ row_id ] = self :: CONSOLE_TABLE_HORIZONTAL_RULE ; $ row_id ++ ; continue ; } $ starting_col = $ col_id ; foreach ( $ row as $ cell ) { $ this -> _data [... | Adds data to the table . |
50,246 | function _calculateTotals ( ) { if ( empty ( $ this -> _calculateTotals ) ) { return ; } $ this -> addSeparator ( ) ; $ totals = array ( ) ; foreach ( $ this -> _data as $ row ) { if ( is_array ( $ row ) ) { foreach ( $ this -> _calculateTotals as $ columnID ) { $ totals [ $ columnID ] += $ row [ $ columnID ] ; } } } $... | Calculates totals for columns . |
50,247 | function _validateTable ( ) { if ( ! empty ( $ this -> _headers ) ) { $ this -> _calculateRowHeight ( - 1 , $ this -> _headers [ 0 ] ) ; } for ( $ i = 0 ; $ i < $ this -> _max_rows ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> _max_cols ; $ j ++ ) { if ( ! isset ( $ this -> _data [ $ i ] [ $ j ] ) && ( ! isset ( $ this ... | Ensures that column and row counts are correct . |
50,248 | function _splitMultilineRows ( ) { ksort ( $ this -> _data ) ; $ sections = array ( & $ this -> _headers , & $ this -> _data ) ; $ max_rows = array ( count ( $ this -> _headers ) , $ this -> _max_rows ) ; $ row_height_offset = array ( - 1 , 0 ) ; for ( $ s = 0 ; $ s <= 1 ; $ s ++ ) { $ inserted = 0 ; $ new_data = $ sec... | Splits multiline rows into many smaller one - line rows . |
50,249 | function _buildTable ( ) { if ( ! count ( $ this -> _data ) ) { return '' ; } $ vertical = $ this -> _border [ 'vertical' ] ; $ separator = $ this -> _getSeparator ( ) ; $ return = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> _data ) ; $ i ++ ) { for ( $ j = 0 ; $ j < count ( $ this -> _data [ $ i ] ) ; $ j ++ )... | Builds the table . |
50,250 | function _getHeaderLine ( ) { for ( $ j = 0 ; $ j < count ( $ this -> _headers ) ; $ j ++ ) { for ( $ i = 0 ; $ i < $ this -> _max_cols ; $ i ++ ) { if ( ! isset ( $ this -> _headers [ $ j ] [ $ i ] ) ) { $ this -> _headers [ $ j ] [ $ i ] = '' ; } } } for ( $ j = 0 ; $ j < count ( $ this -> _headers ) ; $ j ++ ) { for... | Returns the header line for the table . |
50,251 | function _updateRowsCols ( $ rowdata = null ) { $ this -> _max_cols = max ( $ this -> _max_cols , count ( $ rowdata ) ) ; ksort ( $ this -> _data ) ; $ keys = array_keys ( $ this -> _data ) ; $ this -> _max_rows = end ( $ keys ) + 1 ; switch ( $ this -> _defaultAlign ) { case self :: CONSOLE_TABLE_ALIGN_CENTER : $ pad ... | Updates values for maximum columns and rows . |
50,252 | function _calculateCellLengths ( $ row ) { for ( $ i = 0 ; $ i < count ( $ row ) ; $ i ++ ) { if ( ! isset ( $ this -> _cell_lengths [ $ i ] ) ) { $ this -> _cell_lengths [ $ i ] = 0 ; } $ this -> _cell_lengths [ $ i ] = max ( $ this -> _cell_lengths [ $ i ] , $ this -> _strlen ( $ row [ $ i ] ) ) ; } } | Calculates the maximum length for each column of a row . |
50,253 | function _calculateRowHeight ( $ row_number , $ row ) { if ( ! isset ( $ this -> _row_heights [ $ row_number ] ) ) { $ this -> _row_heights [ $ row_number ] = 1 ; } if ( $ row === self :: CONSOLE_TABLE_HORIZONTAL_RULE ) { return ; } for ( $ i = 0 , $ c = count ( $ row ) ; $ i < $ c ; ++ $ i ) { $ lines = preg_split ( '... | Calculates the maximum height for all columns of a row . |
50,254 | function _strlen ( $ str ) { static $ mbstring ; if ( ! isset ( $ mbstring ) ) { $ mbstring = function_exists ( 'mb_strwidth' ) ; } if ( $ mbstring ) { return mb_strwidth ( $ str , $ this -> _charset ) ; } return strlen ( $ str ) ; } | Returns the character length of a string . |
50,255 | function _strpad ( $ input , $ length , $ pad = ' ' , $ type = STR_PAD_RIGHT ) { $ mb_length = $ this -> _strlen ( $ input ) ; $ sb_length = strlen ( $ input ) ; $ pad_length = $ this -> _strlen ( $ pad ) ; if ( $ mb_length >= $ length ) { return $ input ; } if ( $ mb_length == $ sb_length && $ pad_length == strlen ( $... | Returns a string padded to a certain length with another string . |
50,256 | public static function track ( ) { $ ip = Request :: server ( 'REMOTE_ADDR' ) ; $ online = time ( ) ; $ url = URL :: full ( ) ; $ path = Request :: path ( ) ; $ visited = static :: whereIp ( $ ip ) -> today ( ) -> first ( ) ; if ( ! empty ( $ visited ) ) { $ visited -> update ( [ 'online' => $ online , 'hits' => $ visi... | Track hits online visitors . |
50,257 | public function gravatar ( $ size = 60 , $ default = 'mm' , $ rating = 'g' ) { $ email = $ this -> email ; return 'http://www.gravatar.com/avatar/' . md5 ( strtolower ( trim ( $ email ) ) ) . "?s={$size}&d={$default}&r={$rating}" ; } | Get gravatar url . |
50,258 | public function update ( Update $ request , $ id ) { try { $ permission = $ this -> repository -> findById ( $ id ) ; $ data = $ request -> all ( ) ; $ permission -> update ( $ data ) ; return $ this -> redirect ( 'permissions.index' ) ; } catch ( ModelNotFoundException $ e ) { return $ this -> redirectNotFound ( ) ; }... | Update the specified permission in storage . |
50,259 | protected function installPackage ( ) { if ( $ this -> confirm ( 'Do you want publish the pingpong/admin\'s migrations ?' ) ) { $ this -> call ( 'admin:migration' ) ; } if ( $ this -> confirm ( 'Do you want publish the pingpong/trusty\'s migrations ?' ) ) { $ this -> call ( 'vendor:publish' , [ '--provider' => 'Pingpon... | Install the package . |
50,260 | protected function installMenus ( ) { $ file = app_path ( 'menus.php' ) ; if ( ! file_exists ( $ file ) ) { $ contents = $ this -> laravel [ 'files' ] -> get ( __DIR__ . '/stubs/menus.txt' ) ; $ this -> laravel [ 'files' ] -> put ( $ file , $ contents ) ; $ this -> info ( "Created : {$file}" ) ; } else { $ this -> erro... | Create the menus . php file in app directory if that file does not exist . |
50,261 | public function redirect ( $ route , $ parameters = array ( ) , $ status = 302 , $ headers = array ( ) ) { return Redirect :: route ( 'admin.' . $ route , $ parameters , $ status , $ headers ) ; } | Redirect to a route . |
50,262 | public function index ( Request $ request ) { $ categories = $ this -> repository -> allOrSearch ( $ request -> get ( 'q' ) ) ; $ no = $ categories -> firstItem ( ) ; return $ this -> view ( 'categories.index' , compact ( 'categories' , 'no' ) ) ; } | Display a listing of categories . |
50,263 | public function store ( Create $ request ) { $ data = $ request -> all ( ) ; $ category = Category :: create ( $ data ) ; return $ this -> redirect ( 'categories.index' ) ; } | Store a newly created category in storage . |
50,264 | public function show ( $ id ) { try { $ category = $ this -> repository -> findById ( $ id ) ; return $ this -> view ( 'categories.show' , compact ( 'category' ) ) ; } catch ( ModelNotFoundException $ e ) { return $ this -> redirectNotFound ( ) ; } } | Display the specified category . |
50,265 | public function destroy ( $ id ) { try { $ this -> repository -> delete ( $ id ) ; return $ this -> redirect ( 'categories.index' ) ; } catch ( ModelNotFoundException $ e ) { return $ this -> redirectNotFound ( ) ; } } | Remove the specified category from storage . |
50,266 | public function index ( ) { $ articles = $ this -> repository -> allOrSearch ( Input :: get ( 'q' ) ) ; $ no = $ articles -> firstItem ( ) ; return $ this -> view ( 'articles.index' , compact ( 'articles' , 'no' ) ) ; } | Display a listing of articles . |
50,267 | public function updateSettings ( ) { $ settings = \ Input :: all ( ) ; foreach ( $ settings as $ key => $ value ) { $ option = str_replace ( '_' , '.' , $ key ) ; Option :: findByKey ( $ option ) -> update ( [ 'value' => $ value , ] ) ; } return \ Redirect :: back ( ) -> withFlashMessage ( 'Settings has been successful... | Update the settings . |
50,268 | public function showArticle ( $ id ) { try { $ post = Article :: with ( 'user' , 'category' ) -> whereId ( intval ( $ id ) ) -> orWhere ( 'slug' , $ id ) -> firstOrFail ( ) ; $ view = \ Config :: get ( 'admin.views.post' ) ; return \ View :: make ( $ view , compact ( 'post' ) ) ; } catch ( ModelNotFoundException $ e ) ... | Show article . |
50,269 | public function reconnect ( ) { @ ftp_close ( $ this -> resource ) ; foreach ( $ this -> state as $ name => $ args ) { call_user_func_array ( array ( $ this , $ name ) , $ args ) ; } } | Reconnects to FTP server . |
50,270 | public function isDir ( $ dir ) { $ current = $ this -> pwd ( ) ; try { $ this -> chdir ( $ dir ) ; } catch ( FtpException $ e ) { } $ this -> chdir ( $ current ) ; return empty ( $ e ) ; } | Checks if directory exists . |
50,271 | public function mkDirRecursive ( $ dir ) { $ parts = explode ( '/' , $ dir ) ; $ path = '' ; while ( ! empty ( $ parts ) ) { $ path .= array_shift ( $ parts ) ; try { if ( $ path !== '' ) $ this -> mkdir ( $ path ) ; } catch ( FtpException $ e ) { if ( ! $ this -> isDir ( $ path ) ) { throw new FtpException ( "Cannot c... | Recursive creates directories . |
50,272 | public function deleteRecursive ( $ path ) { if ( ! $ this -> tryDelete ( $ path ) ) { foreach ( ( array ) $ this -> nlist ( $ path ) as $ file ) { if ( $ file !== '.' && $ file !== '..' ) { $ this -> deleteRecursive ( strpos ( $ file , '/' ) === FALSE ? "$path/$file" : $ file ) ; } } $ this -> rmdir ( $ path ) ; } } | Recursive deletes path . |
50,273 | protected function registerSecurity ( ) { $ this -> app -> singleton ( 'security' , function ( Container $ app ) { $ evil = $ app -> config -> get ( 'security.evil' ) ; return new Security ( $ evil ) ; } ) ; $ this -> app -> alias ( 'security' , Security :: class ) ; } | Register the security class . |
50,274 | public function add ( $ id , $ name , $ price , $ quantity , $ options = [ ] ) { $ cartItem = new CartItem ( $ id , $ name , $ price , $ quantity , $ options ) ; $ uniqueId = $ cartItem -> getUniqueId ( ) ; if ( $ this -> content -> has ( $ uniqueId ) ) { $ cartItem -> quantity += $ this -> content -> get ( $ uniqueId ... | Add an item to the shopping cart . |
50,275 | public function remove ( $ uniqueId ) { if ( $ cartItem = $ this -> get ( $ uniqueId ) ) { $ this -> content -> pull ( $ cartItem -> getUniqueId ( ) ) ; return true ; } return false ; } | Remove the item with the specified unique id from shopping cart . |
50,276 | public function setQuantity ( $ uniqueId , $ quantity ) { if ( $ cartItem = $ this -> get ( $ uniqueId ) ) { $ cartItem -> quantity = $ quantity ; $ this -> content -> put ( $ cartItem -> getUniqueId ( ) , $ cartItem ) ; return true ; } return false ; } | Get the quantity of the cart item with specified unique id . |
50,277 | public function getTotalWithCoupons ( ) { $ total = $ this -> getTotal ( ) ; $ totalWithCoupons = $ total ; $ this -> coupons -> each ( function ( Coupon $ coupon ) use ( $ total , & $ totalWithCoupons ) { $ totalWithCoupons -= $ coupon -> apply ( $ total ) ; } ) ; return $ totalWithCoupons ; } | Get total price with coupons . |
50,278 | public function instance ( $ name ) { $ name = $ name ? : self :: DEFAULT_INSTANCE_NAME ; $ name = str_replace ( 'shopping-cart.' , '' , $ name ) ; $ this -> instanceName = sprintf ( '%s.%s' , 'shopping-cart' , $ name ) ; return $ this ; } | Set shopping cart instance name . |
50,279 | public function store ( $ id ) { $ this -> repo -> createOrUpdate ( $ id , $ this -> instanceName , json_encode ( serialize ( [ 'content' => $ this -> content , 'coupons' => $ this -> coupons , ] ) ) ) ; return $ this ; } | Store the current instance of the cart . |
50,280 | public function restore ( $ id ) { $ cart = $ this -> repo -> findByIdAndInstanceName ( $ id , $ this -> instanceName ) ; if ( $ cart === null ) { return ; } $ unserialized = unserialize ( json_decode ( $ cart -> content ) ) ; $ this -> content = $ unserialized [ 'content' ] ; $ this -> coupons = $ unserialized [ 'coup... | Store the specified instance of the cart . |
50,281 | protected function generateUniqueId ( ) { ksort ( $ this -> options ) ; return md5 ( $ this -> id . serialize ( $ this -> options ) ) ; } | Generate a unique id for the cart item . |
50,282 | public function remove ( $ id , $ instanceName ) { $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -> where ( 'id' , $ id ) -> where ( 'instance' , $ instanceName ) -> delete ( ) ; } | Remove shopping cart by its identifier and instance name . |
50,283 | protected function create ( $ id , $ instanceName , $ content ) { $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -> insert ( [ 'id' => $ id , 'instance' => $ instanceName , 'content' => $ content , ] ) ; } | Create shopping cart instance . |
50,284 | protected function update ( $ id , $ instanceName , $ content ) { $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -> where ( 'id' , $ id ) -> where ( 'instance' , $ instanceName ) -> update ( [ 'content' => $ content ] ) ; } | Update shopping cart instance . |
50,285 | protected function exists ( $ id , $ instanceName ) { return $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -> where ( 'id' , $ id ) -> where ( 'instance' , $ instanceName ) -> exists ( ) ; } | Check if shopping cart instance exitsts . |
50,286 | public static function contentToCatalogue ( $ content , $ locale , $ domain ) { $ loader = new XliffLoader ( ) ; $ catalogue = new MessageCatalogue ( $ locale ) ; $ loader -> extractFromContent ( $ content , $ catalogue , $ domain ) ; return $ catalogue ; } | Create a catalogue from the contents of a XLIFF file . |
50,287 | private function writeCatalogue ( MessageCatalogueInterface $ catalogue , $ locale , $ domain ) { $ resources = $ catalogue -> getResources ( ) ; $ options = $ this -> options ; $ written = false ; foreach ( $ resources as $ resource ) { $ path = ( string ) $ resource ; if ( preg_match ( '|/' . $ domain . '\.' . $ loca... | Save catalogue back to file . |
50,288 | private function loadCatalogue ( $ locale , array $ dirs ) { $ currentCatalogue = new MessageCatalogue ( $ locale ) ; foreach ( $ dirs as $ path ) { if ( is_dir ( $ path ) ) { $ this -> reader -> read ( $ path , $ currentCatalogue ) ; } } $ this -> catalogues [ $ locale ] = $ currentCatalogue ; } | Load catalogue from files . |
50,289 | public function rpoplpush ( string $ sourceList , string $ destinationList ) { $ rpopValue = $ this -> rpop ( $ sourceList ) ; if ( null !== $ rpopValue ) { $ this -> lpush ( $ destinationList , $ rpopValue ) ; } return $ rpopValue ; } | Mock the rpoplpush command |
50,290 | public function formatted_page ( $ doctype = 'html5' , $ externalcss = true , $ title = '' , $ lang = 'en' ) { switch ( $ doctype ) { case 'html5' : $ doctype_output = '<!DOCTYPE html>' ; break ; case 'xhtml1.0strict' : $ doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR... | Returns the formatted CSS code to make a complete webpage |
50,291 | public function get_ratio ( ) { if ( ! $ this -> output_css_plain ) { $ this -> formatted ( ) ; } return round ( ( strlen ( $ this -> input_css ) - strlen ( $ this -> output_css_plain ) ) / strlen ( $ this -> input_css ) , 3 ) * 100 ; } | Get compression ratio |
50,292 | public function get_diff ( ) { if ( ! $ this -> output_css_plain ) { $ this -> formatted ( ) ; } $ diff = strlen ( $ this -> output_css_plain ) - strlen ( $ this -> input_css ) ; if ( $ diff > 0 ) { return '+' . $ diff ; } elseif ( $ diff == 0 ) { return '+-' . $ diff ; } return $ diff ; } | Get difference between the old and new code in bytes and prints the code if necessary . |
50,293 | public function size ( $ loc = 'output' ) { if ( $ loc === 'output' && ! $ this -> output_css ) { $ this -> formatted ( ) ; } if ( $ loc === 'input' ) { return ( strlen ( $ this -> input_css ) / 1000 ) ; } else { return ( strlen ( $ this -> output_css_plain ) / 1000 ) ; } } | Get the size of either input or output CSS in KB |
50,294 | public function subvalue ( ) { $ replace_colors = & $ this -> parser -> data [ 'csstidy' ] [ 'replace_colors' ] ; $ this -> sub_value = trim ( $ this -> sub_value ) ; if ( $ this -> sub_value == '' ) { return ; } $ important = '' ; if ( $ this -> parser -> is_important ( $ this -> sub_value ) ) { $ important = '!import... | Optimises a sub - value |
50,295 | public function compress_important ( & $ string ) { if ( $ this -> parser -> is_important ( $ string ) ) { $ important = $ this -> parser -> get_cfg ( 'space_before_important' ) ? ' !important' : '!important' ; $ string = $ this -> parser -> gvw_important ( $ string ) . $ important ; } return $ string ; } | Removes unnecessary whitespace in ! important |
50,296 | public function AnalyseCssNumber ( $ string ) { if ( strlen ( $ string ) == 0 || ctype_alpha ( $ string { 0 } ) ) { return false ; } $ units = & $ this -> parser -> data [ 'csstidy' ] [ 'units' ] ; $ return = array ( 0 , '' ) ; $ return [ 0 ] = floatval ( $ string ) ; if ( abs ( $ return [ 0 ] ) > 0 && abs ( $ return [... | Checks if a given string is a CSS valid number . If it is an array containing the value and unit is returned |
50,297 | public function discard_invalid_selectors ( & $ array ) { $ invalid = array ( '+' => true , '~' => true , ',' => true , '>' => true ) ; foreach ( $ array as $ selector => $ decls ) { $ ok = true ; $ selectors = array_map ( 'trim' , explode ( ',' , $ selector ) ) ; foreach ( $ selectors as $ s ) { $ simple_selectors = p... | Removes invalid selectors and their corresponding rule - sets as defined by 4 . 1 . 7 in REC - CSS2 . This is a very rudimentary check and should be replaced by a full - blown parsing algorithm or regular expression |
50,298 | public function merge_bg ( $ input_css ) { $ background_prop_default = & $ this -> parser -> data [ 'csstidy' ] [ 'background_prop_default' ] ; $ number_of_values = @ max ( count ( $ this -> explode_ws ( ',' , $ input_css [ 'background-image' ] ) ) , count ( $ this -> explode_ws ( ',' , $ input_css [ 'background-color'... | Merges all background properties |
50,299 | public function merge_font ( $ input_css ) { $ font_prop_default = & $ this -> parser -> data [ 'csstidy' ] [ 'font_prop_default' ] ; $ new_font_value = '' ; $ important = '' ; if ( isset ( $ input_css [ 'font-family' ] ) && isset ( $ input_css [ 'font-size' ] ) && $ input_css [ 'font-family' ] != 'inherit' ) { if ( is... | Merges all fonts properties |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.