idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
56,000
|
public function userTopTracks ( string $ username ) : Lastfm { $ this -> query = array_merge ( $ this -> query , [ 'method' => 'user.getTopTracks' , 'user' => $ username , ] ) ; $ this -> pluck = 'toptracks.track' ; return $ this ; }
|
Get an array of top tracks .
|
56,001
|
public function userWeeklyTopArtists ( string $ username , \ DateTime $ startdate ) : Lastfm { $ this -> query = array_merge ( $ this -> query , [ 'method' => 'user.getWeeklyArtistChart' , 'user' => $ username , 'from' => $ startdate -> format ( 'U' ) , 'to' => $ startdate -> modify ( '+7 day' ) -> format ( 'U' ) , ] ) ; $ this -> pluck = 'weeklyartistchart.artist' ; return $ this ; }
|
Get an array of weekly top artists .
|
56,002
|
public function userWeeklyChartList ( string $ username ) : Lastfm { $ this -> query = array_merge ( $ this -> query , [ 'method' => 'user.getWeeklyChartList' , 'user' => $ username , ] ) ; $ this -> pluck = 'weeklychartlist.chart' ; return $ this ; }
|
Get an array of weekly chart list .
|
56,003
|
public function userRecentTracks ( string $ username ) : Lastfm { $ this -> query = array_merge ( $ this -> query , [ 'method' => 'user.getRecentTracks' , 'user' => $ username , ] ) ; $ this -> pluck = 'recenttracks.track' ; return $ this ; }
|
Get an array of most recent tracks .
|
56,004
|
public function nowListening ( string $ username ) { $ this -> query = array_merge ( $ this -> query , [ 'method' => 'user.getRecentTracks' , 'user' => $ username , ] ) ; $ this -> pluck = 'recenttracks.track.0' ; $ most_recent_track = $ this -> limit ( 1 ) -> get ( ) ; if ( ! isset ( $ most_recent_track [ '@attr' ] [ 'nowplaying' ] ) ) { return false ; } return $ most_recent_track ; }
|
Retrieve the track that is currently playing or false if not currently playing any track .
|
56,005
|
public function period ( string $ period ) { if ( ! in_array ( $ period , Constants :: PERIODS ) ) { throw new InvalidPeriodException ( 'Request period is not valid. Valid values are defined in \Barryvanveen\Lastfm\Constants::PERIODS.' ) ; } $ this -> query = array_merge ( $ this -> query ?? [ ] , [ 'period' => $ period ] ) ; return $ this ; }
|
Set or overwrite the period requested from the Last . fm API .
|
56,006
|
public function limit ( int $ limit ) { $ this -> query = array_merge ( $ this -> query ?? [ ] , [ 'limit' => $ limit ] ) ; return $ this ; }
|
Set or overwrite the number of items that is requested from the Last . fm API .
|
56,007
|
public function page ( int $ page ) { $ this -> query = array_merge ( $ this -> query ?? [ ] , [ 'page' => $ page ] ) ; return $ this ; }
|
Set or overwrite the page of items that is requested from the Last . fm API .
|
56,008
|
public function get ( ) : array { $ dataFetcher = new DataFetcher ( $ this -> httpClient ) ; $ this -> data = $ dataFetcher -> get ( $ this -> query , $ this -> pluck ) ; return $ this -> data ; }
|
Retrieve results from the Last . fm API .
|
56,009
|
public function get ( array $ query , $ pluck = null ) { $ this -> responseString = $ this -> client -> get ( self :: LASTFM_API_BASEURL , [ 'http_errors' => false , 'query' => $ query , ] ) ; $ this -> data = json_decode ( ( string ) $ this -> responseString -> getBody ( ) , true ) ; if ( 200 !== $ this -> responseString -> getStatusCode ( ) || null === $ this -> data ) { $ this -> throwResponseException ( ) ; } if ( isset ( $ pluck ) ) { return $ this -> pluckData ( $ this -> data , $ pluck ) ; } return $ this -> data ; }
|
Get parse and validate a response from the given url .
|
56,010
|
protected function throwResponseException ( ) { if ( null === $ this -> data ) { throw new ResponseException ( 'Undecodable response was returned.' ) ; } if ( isset ( $ this -> data [ 'error' ] , $ this -> data [ 'message' ] ) ) { throw new ResponseException ( $ this -> data [ 'message' ] , $ this -> data [ 'error' ] ) ; } throw new ResponseException ( 'Unknown error' ) ; }
|
Throw an exception detailing what went wrong with this request .
|
56,011
|
private function getSiteaccessesByRepository ( ) { $ siteaccesses = [ ] ; foreach ( $ this -> siteaccesses as $ siteaccess ) { $ repository = $ this -> resolveRepositoryName ( $ this -> configResolver -> getParameter ( 'repository' , null , $ siteaccess ) ) ; if ( ! isset ( $ siteaccesses [ $ repository ] ) ) { $ siteaccesses [ $ repository ] = [ ] ; } $ siteaccesses [ $ repository ] [ ] = $ siteaccess ; } return $ siteaccesses ; }
|
Gets a list of siteaccesses grouped by repository .
|
56,012
|
private function resolveRepositoryName ( $ repository ) { if ( $ repository === null ) { $ aliases = array_keys ( $ this -> repositories ) ; $ repository = array_shift ( $ aliases ) ; } return $ repository ; }
|
Resolves repository name .
|
56,013
|
public function serialize ( $ jobId , $ class , $ args = [ ] , $ retry = true , $ queue = null ) { $ class = is_object ( $ class ) ? get_class ( $ class ) : $ class ; $ data = [ 'class' => $ class , 'jid' => $ jobId , 'created_at' => microtime ( true ) , 'enqueued_at' => microtime ( true ) , 'args' => $ args , 'retry' => $ retry , ] ; if ( $ queue !== null ) { $ data [ 'queue' ] = $ queue ; } $ jsonEncodedData = json_encode ( $ data ) ; if ( $ jsonEncodedData === false ) { throw new JsonEncodeException ( $ data , json_last_error ( ) , json_last_error_msg ( ) ) ; } return $ jsonEncodedData ; }
|
Serialize and normalize job data
|
56,014
|
public function shellAction ( Request $ request ) { $ this -> translator -> setLocale ( $ request -> getPreferredLanguage ( ) ? : $ request -> getDefaultLocale ( ) ) ; return $ this -> render ( 'eZPlatformUIBundle:PlatformUI:shell.html.twig' , [ 'parameters' => $ this -> configAggregator -> getConfig ( ) ] ) ; }
|
Renders the shell page to run the JavaScript application .
|
56,015
|
public function combineLoaderAction ( Request $ request ) { $ files = array_keys ( $ request -> query -> all ( ) ) ; $ version = $ this -> get ( 'assets.packages' ) -> getVersion ( '/' ) ; try { $ type = $ this -> loader -> getCombinedFilesContentType ( $ files , $ version ) ; $ content = $ this -> loader -> combineFilesContent ( $ files , $ version ) ; } catch ( NotFoundException $ e ) { throw new NotFoundHttpException ( $ e -> getMessage ( ) ) ; } catch ( InvalidArgumentValue $ e ) { throw new BadRequestHttpException ( $ e -> getMessage ( ) ) ; } $ headers = [ 'Content-Type' => $ type ] ; if ( $ this -> comboCacheTtl && $ version != '' ) { $ headers [ 'Cache-Control' ] = "public, s-maxage=$this->comboCacheTtl" ; } return new Response ( $ content , Response :: HTTP_OK , $ headers ) ; }
|
Load JS or CSS assets .
|
56,016
|
public function setPjaxRequestLocale ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ event -> isMasterRequest ( ) || ! $ this -> requestMatcher -> matches ( $ request ) ) { return ; } $ request -> setLocale ( $ request -> getPreferredLanguage ( ) ) ; $ request -> attributes -> set ( '_locale' , $ request -> getPreferredLanguage ( ) ) ; }
|
On pjax requests sets the request s locale from the browser s accept - language header .
|
56,017
|
protected function validateUpdate ( Validable $ model ) { $ model -> getValidator ( ) -> setRules ( $ model -> getUpdateRules ( ) ) ; $ valid = $ model -> isValid ( ) ; $ model -> getValidator ( ) -> setRules ( $ model -> getCreateRules ( ) ) ; if ( ! $ valid ) { return false ; } }
|
Halt updating if model doesn t pass validation .
|
56,018
|
final protected function raise ( DomainEvent $ event ) : void { $ this -> setStateHash ( $ this -> calculateNextStateHash ( $ event ) ) ; if ( $ event instanceof AbstractDomainEvent ) { AbstractDomainEvent :: initEvent ( $ event , $ this -> getId ( ) , $ this -> stateHash ( ) ) ; } EventPublisher :: instance ( ) -> post ( $ event ) ; }
|
Updates the state hash and sends the DomainEvent to the EventPublisher . It also automatically fills the raised event if it extends AbstractDomainEvent .
|
56,019
|
public function createSnapshot ( AggregateId $ aggregateId ) : void { if ( ! $ this -> eventSourced ( $ aggregateId ) ) { return ; } $ aggregateRoot = $ this -> loadSnapshot ( $ aggregateId ) ; $ stateHash = $ aggregateRoot === null ? null : $ aggregateRoot -> stateHash ( ) ; $ events = $ this -> getEventsFor ( $ aggregateId , $ stateHash ) ; if ( $ events -> count ( ) == 0 ) { return ; } if ( $ aggregateRoot === null ) { $ aggregateRoot = ObjectClass :: forName ( $ aggregateId -> aggregateClass ( ) ) -> newInstanceWithoutConstructor ( ) ; } $ aggregateRoot -> loadFromHistory ( $ events ) ; $ this -> doCreateSnapshot ( $ aggregateRoot ) ; }
|
Events raised in the current transaction are not being stored in this snapshot . Only the already persisted events are being utilized .
|
56,020
|
public function updateVersion ( $ contentId , $ versionNumber , Request $ request ) { if ( ! $ this -> isUserContent ( $ contentId ) ) { return parent :: updateVersion ( $ contentId , $ versionNumber , $ request ) ; } $ updatedUser = $ this -> repository -> getUserService ( ) -> updateUser ( $ this -> repository -> getUserService ( ) -> loadUser ( $ contentId ) , $ this -> mapRequestToUserUpdateStruct ( $ request ) ) ; return $ this -> mapUserToVersion ( $ updatedUser , $ request ) ; }
|
If the updated content is a user update it using the user API and return a Version object .
|
56,021
|
public function publishVersion ( $ contentId , $ versionNumber ) { if ( ! $ this -> isUserContent ( $ contentId ) ) { parent :: publishVersion ( $ contentId , $ versionNumber ) ; } return new NoContent ( ) ; }
|
If the published content is a user return directly without publishing .
|
56,022
|
public function getValidationMessage ( $ attribute , $ rule , $ data = [ ] , $ type = null ) { $ path = Str :: snake ( $ rule ) ; if ( $ type !== null ) { $ path .= '.' . $ type ; } if ( $ this -> translator -> has ( 'validation.custom.' . $ attribute . '.' . $ path ) ) { $ path = 'custom.' . $ attribute . '.' . $ path ; } $ niceName = $ this -> getValidationAttribute ( $ attribute ) ; return $ this -> translator -> get ( 'validation.' . $ path , $ data + [ 'attribute' => $ niceName ] ) ; }
|
Get user friendly validation message .
|
56,023
|
public function dataSet ( ) { $ base = $ this -> storeManager -> getStore ( 0 ) -> getBaseUrl ( ) ; $ modules = $ this -> _moduleList -> getNames ( ) ; foreach ( $ modules as $ module ) { if ( strpos ( $ module , self :: EADESIGN ) !== false ) { $ this -> connect ( [ 'url' => $ base , 'version' => $ this -> moduleResource -> getDbVersion ( $ module ) , 'extension' => $ module , 'mversion' => 2 ] ) ; } } }
|
Prepare the data to send to the connector
|
56,024
|
public function setHash ( $ hash ) { if ( ! preg_match ( "/[0-9a-f]{32}/" , $ hash ) ) { throw new InvalidArgumentException ( "Asset cache buster hash must be a valid md5 hash." ) ; } $ hash = trim ( $ hash , '/' ) ; $ this -> hash = $ hash ; }
|
Sets the hash
|
56,025
|
public function setPrefix ( $ prefix = null ) { $ prefix = trim ( $ prefix , '/' ) ; $ this -> prefix = ( $ prefix ) ? trim ( $ prefix , '/' ) . '/' : '' ; }
|
Sets the asset prefix path
|
56,026
|
public function url ( $ path = '' ) { $ path = trim ( $ path , '/' ) ; if ( $ this -> enabled ) { $ hash = ( $ this -> hash ) ? trim ( $ this -> hash , '/' ) . '/' : '' ; return $ this -> cdn . $ this -> prefix . $ hash . $ path ; } else { return $ this -> cdn . $ path ; } }
|
Generates an asset url
|
56,027
|
public function setCurrentConfig ( $ content ) { if ( ! $ this -> configExists ( ) ) { throw new \ InvalidArgumentException ( 'The config file does not exist. Did you run the vendor:publish command?' ) ; } $ this -> filesystem -> put ( $ this -> getConfigFile ( ) , $ content ) ; }
|
Saves config as current config
|
56,028
|
public function actionNotify ( string $ transactionId = null ) { $ transaction = $ this -> checkNotify ( $ transactionId ) ; if ( $ transaction === null ) { return 'Unknown transaction' ; } Yii :: $ app -> response -> format = Response :: FORMAT_RAW ; return $ transaction -> isConfirmed ( ) ? 'OK' : $ transaction -> getParameter ( 'error' ) ; }
|
Action handles notifications from payment systems processes them and report success or error for the payment system .
|
56,029
|
public function renderDeposit ( $ form ) { $ request = new DepositRequest ( ) ; $ request -> amount = $ form -> amount ; $ request -> currency = $ form -> currency ; $ request -> finishUrl = $ form -> finishUrl ; $ requests = $ this -> getMerchantModule ( ) -> getPurchaseRequestCollection ( $ request ) -> getItems ( ) ; return $ this -> render ( 'deposit' , [ 'requests' => $ requests , 'depositForm' => $ form ] ) ; }
|
Renders depositing buttons for given request data .
|
56,030
|
public static function getResponseLine ( ResponseInterface $ response ) : string { return sprintf ( '%s %d%s' , self :: getProtocol ( $ response ) , self :: getStatus ( $ response ) , ( $ response -> getReasonPhrase ( ) ? ' ' . $ response -> getReasonPhrase ( ) : '' ) ) ; }
|
Returns the response status line
|
56,031
|
private static function getServerParam ( ServerRequestInterface $ request , string $ key , string $ default = '-' ) : string { $ server = $ request -> getServerParams ( ) ; return empty ( $ server [ $ key ] ) ? $ default : $ server [ $ key ] ; }
|
Returns an server parameter value
|
56,032
|
private static function getServerParamIp ( ServerRequestInterface $ request , string $ key ) : string { $ ip = self :: getServerParam ( $ request , $ key ) ; if ( filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 ) ) { return $ ip ; } return '-' ; }
|
Returns an ip from the server params
|
56,033
|
public function getPagesRange ( ) { $ pageRange = $ this -> getPageRange ( ) ; $ pageNumber = $ this -> getCurrentPageNumber ( ) ; $ pageCount = $ this -> getNumberOfPages ( ) ; if ( $ pageRange > $ pageCount ) { $ pageRange = $ pageCount ; } $ delta = ceil ( $ pageRange / 2 ) ; if ( $ pageNumber - $ delta > $ pageCount - $ pageRange ) { $ lowerBound = $ pageCount - $ pageRange + 1 ; $ upperBound = $ pageCount ; } else { if ( $ pageNumber - $ delta < 0 ) { $ delta = $ pageNumber ; } $ offset = $ pageNumber - $ delta ; $ lowerBound = $ offset + 1 ; $ upperBound = $ offset + $ pageRange ; } $ pages = array ( ) ; for ( $ pageNumber = $ lowerBound ; $ pageNumber <= $ upperBound ; $ pageNumber ++ ) { $ pages [ $ pageNumber ] = $ pageNumber ; } return $ pages ; }
|
From Zend \ Paginator \ Paginator
|
56,034
|
public function set ( $ rules , $ formName = null ) { if ( isset ( $ rules ) ) { $ this -> currentFormName = $ formName ; $ this -> validationRules [ $ formName ] = ( array ) $ rules ; } }
|
Set rules for validation .
|
56,035
|
public function reset ( $ formName = false ) { if ( is_bool ( $ formName ) ) $ formName = $ this -> currentFormName ; if ( array_key_exists ( $ formName , $ this -> validationRules ) ) { $ this -> validationRules [ $ formName ] = [ ] ; } }
|
Reset validation rules .
|
56,036
|
public function getValidationRules ( $ formName = false ) { if ( is_bool ( $ formName ) ) $ formName = $ this -> currentFormName ; if ( array_key_exists ( $ formName , $ this -> validationRules ) ) { return $ this -> validationRules [ $ formName ] ; } return [ ] ; }
|
Get all given validation rules .
|
56,037
|
protected function getValidationRule ( $ inputName ) { $ rules = $ this -> getValidationRules ( ) ; return is_array ( $ rules [ $ inputName ] ) ? $ rules [ $ inputName ] : explode ( '|' , $ rules [ $ inputName ] ) ; }
|
Returns validation rules for given input name .
|
56,038
|
protected function getTypeOfInput ( $ rulesOfInput ) { foreach ( $ rulesOfInput as $ key => $ rule ) { $ parsedRule = $ this -> parseValidationRule ( $ rule ) ; if ( in_array ( $ parsedRule [ 'name' ] , static :: $ numericRules ) ) { return 'numeric' ; } elseif ( $ parsedRule [ 'name' ] === 'array' ) { return 'array' ; } elseif ( in_array ( $ parsedRule [ 'name' ] , static :: $ fileRules ) ) { return 'file' ; } } return 'string' ; }
|
Get all rules and return type of input if rule specifies type
|
56,039
|
protected function parseValidationRule ( $ rule ) { $ ruleArray = array ( ) ; $ explodedRule = explode ( ':' , $ rule , 2 ) ; $ ruleArray [ 'name' ] = array_shift ( $ explodedRule ) ; if ( empty ( $ explodedRule ) || ! in_array ( strtolower ( $ ruleArray [ 'name' ] ) , static :: $ multiParamRules ) ) { $ ruleArray [ 'parameters' ] = $ explodedRule ; } else { $ ruleArray [ 'parameters' ] = str_getcsv ( $ explodedRule [ 0 ] ) ; } return $ ruleArray ; }
|
Parses validation rule of laravel .
|
56,040
|
protected function getDefaultErrorMessage ( $ laravelRule , $ attribute ) { $ message = $ this -> message ( ) -> getValidationMessage ( $ attribute , $ laravelRule ) ; return [ 'data-msg-' . $ laravelRule => $ message ] ; }
|
Gets default error message .
|
56,041
|
public function getItems ( $ offset , $ itemCountPerPage ) { if ( $ offset >= $ this -> count ( ) ) { return array ( ) ; } $ remainItemCount = $ this -> count ( ) - $ offset ; $ currentItemCount = $ remainItemCount > $ itemCountPerPage ? $ itemCountPerPage : $ remainItemCount ; return array_fill ( 0 , $ currentItemCount , null ) ; }
|
From Zend \ Paginator \ Adapter \ Null
|
56,042
|
public function replaceHash ( ) { $ currentHash = $ this -> cacheBuster -> getHash ( ) ; $ hash = $ this -> cacheBuster -> generateHash ( ) ; $ this -> writeHash ( $ currentHash , $ hash ) ; $ this -> cacheBuster -> setHash ( $ hash ) ; return $ hash ; }
|
Generate and save new hash
|
56,043
|
final protected function insert ( string $ table , array $ data ) : AbstractMigration { $ this -> execute ( $ this -> adapter -> buildInsertQuery ( $ table , $ data ) ) ; return $ this ; }
|
adds insert query to list of queries to execute
|
56,044
|
final protected function update ( string $ table , array $ data , array $ conditions = [ ] , string $ where = '' ) : AbstractMigration { $ this -> execute ( $ this -> adapter -> buildUpdateQuery ( $ table , $ data , $ conditions , $ where ) ) ; return $ this ; }
|
adds update query to list of queries to execute
|
56,045
|
final protected function delete ( string $ table , array $ conditions = [ ] , string $ where = '' ) : AbstractMigration { $ this -> execute ( $ this -> adapter -> buildDeleteQuery ( $ table , $ conditions , $ where ) ) ; return $ this ; }
|
adds delete query to list of queries to exectue
|
56,046
|
public function prepareRequestData ( $ depositRequest ) { $ depositRequest -> username = $ this -> getUsername ( ) ; $ depositRequest -> notifyUrl = $ this -> buildUrl ( 'notify' , $ depositRequest ) ; $ depositRequest -> returnUrl = $ this -> buildUrl ( 'return' , $ depositRequest ) ; $ depositRequest -> cancelUrl = $ this -> buildUrl ( 'cancel' , $ depositRequest ) ; $ depositRequest -> finishUrl = $ this -> buildUrl ( 'finish' , $ depositRequest ) ; }
|
Method builds data for merchant request .
|
56,047
|
public function buildUrl ( $ destination , DepositRequest $ depositRequest ) { $ page = [ $ this -> getPage ( $ destination , $ depositRequest ) , 'username' => $ depositRequest -> username , 'merchant' => $ depositRequest -> merchant , 'transactionId' => $ depositRequest -> id , ] ; if ( is_array ( $ page ) ) { $ page [ 0 ] = $ this -> localizePage ( $ page [ 0 ] ) ; } else { $ page = $ this -> localizePage ( $ page ) ; } return Url :: to ( $ page , true ) ; }
|
Builds URLs that will be passed in the request to the merchant .
|
56,048
|
public function renderButton ( ) { return $ this -> render ( 'pay-button' , [ 'widget' => $ this , 'request' => $ this -> request , 'depositRequest' => new DepositRequest ( [ 'id' => $ this -> request -> id , 'amount' => $ this -> depositForm -> amount , 'currency' => $ this -> depositForm -> currency , 'merchant' => $ this -> getMerchantName ( ) , 'finishUrl' => $ this -> depositForm -> finishUrl , ] ) ] ) ; }
|
Renders the payment button .
|
56,049
|
public function getToken ( ) { if ( ! isset ( $ this -> token ) ) { $ this -> token = $ this -> csrf -> getToken ( ) ; } return $ this -> token ; }
|
Returns the generated token .
|
56,050
|
protected function __prefixExists ( $ prefix ) { if ( Hash :: get ( $ this -> prefixes , ucfirst ( $ prefix ) ) == null ) { return false ; } return true ; }
|
Checks if a prefix exists .
|
56,051
|
public function setSources ( array $ sources ) { $ this -> sources = array_map ( function ( Source \ TokenSource $ source ) { return $ source ; } , $ sources ) ; }
|
Sets the possible sources for submitted token .
|
56,052
|
public function validateRequest ( $ throw = false ) { $ this -> getTrueToken ( ) ; if ( ! $ this -> isValidatedRequest ( ) ) { return true ; } if ( ! $ this -> validateRequestToken ( ) ) { if ( $ throw ) { throw new InvalidCSRFTokenException ( 'Invalid CSRF token' ) ; } $ this -> killScript ( ) ; } return true ; }
|
Validates the csrf token in the HTTP request .
|
56,053
|
public function validateToken ( $ token ) { if ( ! is_string ( $ token ) ) { return false ; } $ token = base64_decode ( $ token , true ) ; if ( strlen ( $ token ) !== self :: TOKEN_LENGTH * 2 ) { return false ; } list ( $ key , $ encrypted ) = str_split ( $ token , self :: TOKEN_LENGTH ) ; return call_user_func ( $ this -> compare , $ this -> encryptToken ( $ this -> getTrueToken ( ) , $ key ) , $ encrypted ) ; }
|
Validates the csrf token .
|
56,054
|
public function getToken ( ) { $ key = $ this -> getGenerator ( ) -> getBytes ( self :: TOKEN_LENGTH ) ; return base64_encode ( $ key . $ this -> encryptToken ( $ this -> getTrueToken ( ) , $ key ) ) ; }
|
Generates a new secure base64 encoded csrf token .
|
56,055
|
public function regenerateToken ( ) { do { $ token = $ this -> getGenerator ( ) -> getBytes ( self :: TOKEN_LENGTH ) ; } while ( $ token === $ this -> token ) ; $ this -> token = $ token ; $ this -> storage -> storeToken ( $ this -> token ) ; return $ this ; }
|
Regenerates the actual CSRF token .
|
56,056
|
public function getTrueToken ( ) { if ( ! isset ( $ this -> token ) ) { $ token = $ this -> storage -> getStoredToken ( ) ; $ this -> token = is_string ( $ token ) ? $ token : '' ; } if ( strlen ( $ this -> token ) !== self :: TOKEN_LENGTH ) { $ this -> regenerateToken ( ) ; } return $ this -> token ; }
|
Returns the current actual CSRF token .
|
56,057
|
public function getRequestToken ( ) { $ token = false ; foreach ( $ this -> sources as $ source ) { if ( ( $ token = $ source -> getRequestToken ( ) ) !== false ) { break ; } } return $ token ; }
|
Returns the token sent in the request .
|
56,058
|
private function compareStrings ( $ knownString , $ userString ) { $ result = "\x00" ; for ( $ i = 0 , $ length = strlen ( $ knownString ) ; $ i < $ length ; $ i ++ ) { $ result |= $ knownString [ $ i ] ^ $ userString [ $ i ] ; } return $ result === "\x00" ; }
|
Compares two string in constant time .
|
56,059
|
function toRaw ( ) { $ result = File_MARC :: SUBFIELD_INDICATOR . $ this -> code . $ this -> data ; return ( string ) $ result ; }
|
Return the USMARC representation of the subfield
|
56,060
|
public function initMenuItems ( ) { $ this -> Menu -> area ( 'headerLeft' ) ; $ this -> Menu -> add ( 'ca.user' , [ 'title' => $ this -> authUser [ Configure :: read ( 'CA.fields.username' ) ] , 'url' => '#' ] ) ; $ this -> Menu -> add ( 'ca.logout' , [ 'parent' => 'ca.user' , 'title' => __d ( 'CakeAdmin' , 'Logout' ) , 'url' => [ 'prefix' => 'admin' , 'plugin' => 'CakeAdmin' , 'controller' => 'Users' , 'action' => 'logout' , ] ] ) ; $ this -> Menu -> area ( 'main' ) ; $ this -> Menu -> add ( 'ca.dashboard' , [ 'title' => __d ( 'CakeAdmin' , 'Dashboard' ) , 'url' => [ 'prefix' => 'admin' , 'plugin' => 'CakeAdmin' , 'controller' => 'Dashboard' , 'action' => 'index' , ] , 'weight' => 0 , ] ) ; $ this -> Menu -> add ( 'ca.settings' , [ 'title' => __d ( 'CakeAdmin' , 'Settings' ) , 'url' => [ 'prefix' => 'admin' , 'plugin' => 'CakeAdmin' , 'controller' => 'Settings' , 'action' => 'index' , ] , 'weight' => 50 ] ) ; foreach ( Configure :: read ( 'CA.Menu.main' ) as $ key => $ value ) { $ this -> Menu -> add ( $ key , $ value ) ; } }
|
Initializes all admin menu - items .
|
56,061
|
protected function _addNotificationMenu ( ) { $ this -> Menu -> area ( 'headerLeft' ) ; $ this -> Menu -> add ( 'notifier.notifications' , [ 'title' => __d ( 'CakeAdmin' , 'Notifications ({0})' , $ this -> Notifier -> countNotifications ( null , true ) ) , 'url' => '#' , 'weight' => 5 ] ) ; $ notifications = $ this -> Notifier -> getNotifications ( null , true ) ; foreach ( $ notifications as $ not ) { $ this -> Menu -> add ( 'notifier.notifications.' . $ not -> id , [ 'parent' => 'notifier.notifications' , 'title' => $ not -> title , 'url' => [ 'prefix' => 'admin' , 'plugin' => 'CakeAdmin' , 'controller' => 'Notifications' , 'action' => 'index' ] ] ) ; } $ this -> Menu -> add ( 'notifier.notifications.url' , [ 'parent' => 'notifier.notifications' , 'title' => '> ' . __d ( 'CakeAdmin' , 'All Notifications' ) , 'url' => [ 'prefix' => 'admin' , 'plugin' => 'CakeAdmin' , 'controller' => 'Notifications' , 'action' => 'index' ] ] ) ; }
|
Adds the notification - menu - item to the header menu .
|
56,062
|
public static function getTypeFromPath ( $ file_name ) { $ ext = strtolower ( preg_replace ( '/^.*\.([^.]+)$/' , '$1' , $ file_name ) ) ; switch ( $ ext ) { case 'jpeg' : case 'jpg' : return self :: JPEG ; break ; case 'otf' : return self :: OpenType ; break ; case 'opf' : return self :: OPF2 ; break ; case 'smil' : return self :: MediaOverlays301 ; break ; case 'js' : return self :: JS ; break ; default : $ const_name = strtoupper ( $ ext ) ; $ refl = new \ ReflectionClass ( get_called_class ( ) ) ; return $ refl -> getConstant ( $ const_name ) ; break ; } }
|
Get extension from file path
|
56,063
|
public static function getDestinationFolder ( $ path ) { $ path = ( string ) $ path ; if ( preg_match ( '/\.(jpe?g|gif|png|svg)$/i' , $ path ) ) { return 'Image' ; } elseif ( preg_match ( '/\.(otf|woff|ttf)$/i' , $ path ) ) { return 'Font' ; } elseif ( preg_match ( '/\.(css)$/i' , $ path ) ) { return 'CSS' ; } elseif ( preg_match ( '/\.(mp4|mp3)$/i' , $ path ) ) { return 'Media' ; } elseif ( preg_match ( '/\.(smil|pls)$/i' , $ path ) ) { return 'Speech' ; } elseif ( preg_match ( '/\.(js|json)$/i' , $ path ) ) { return 'JS' ; } elseif ( preg_match ( '/\.x?html$/i' , $ path ) ) { return 'Text' ; } else { return 'Misc' ; } }
|
Return folder name
|
56,064
|
public function addRootFile ( $ path ) { $ rootFile = $ this -> dom -> rootfiles -> addChild ( 'rootfile' ) ; $ rootFile [ 'full-path' ] = $ path ; $ rootFile [ 'media-type' ] = 'application/oebps-package+xml' ; }
|
Set root file element
|
56,065
|
public function insertNode ( $ new_node , $ existing_node , $ before = false ) { $ pos = 0 ; $ exist_pos = $ existing_node -> getPosition ( ) ; $ this -> rewind ( ) ; switch ( $ before ) { case true : $ this -> add ( $ exist_pos , $ new_node ) ; break ; case false : if ( $ this -> offsetExists ( $ exist_pos + 1 ) ) { $ this -> add ( $ exist_pos + 1 , $ new_node ) ; } else { $ this -> appendNode ( $ new_node ) ; return true ; } break ; } $ this -> rewind ( ) ; while ( $ n = $ this -> current ( ) ) { $ n -> setPosition ( $ pos ) ; $ this -> next ( ) ; $ pos ++ ; } return true ; }
|
Inserts a node into the linked list based on a reference node that already exists in the list .
|
56,066
|
public function appendNode ( $ new_node ) { $ pos = $ this -> count ( ) ; $ new_node -> setPosition ( $ pos ) ; $ this -> push ( $ new_node ) ; }
|
Adds a node onto the linked list .
|
56,067
|
public function deleteNode ( $ node ) { $ target_pos = $ node -> getPosition ( ) ; $ this -> rewind ( ) ; $ pos = 0 ; $ done = false ; try { while ( $ n = $ this -> current ( ) ) { if ( $ pos == $ target_pos && ! $ done ) { $ done = true ; $ this -> next ( ) ; $ this -> offsetUnset ( $ pos ) ; } elseif ( $ pos >= $ target_pos ) { $ n -> setPosition ( $ pos ) ; $ pos ++ ; $ this -> next ( ) ; } else { $ pos ++ ; $ this -> next ( ) ; } } } catch ( Exception $ e ) { } }
|
Deletes a node from the linked list .
|
56,068
|
public function setTitle ( $ string , $ id , $ type = 'main' , $ sequence = 1 ) { $ sequence = max ( 1 , $ sequence ) ; $ title = $ this -> dom -> metadata -> addChild ( 'title' , $ this -> h ( $ string ) , Schemas :: DC ) ; $ title [ 'id' ] = $ id ; $ meta = $ this -> dom -> metadata -> addChild ( 'meta' , $ type ) ; $ meta [ 'refines' ] = '#' . $ id ; $ meta [ 'property' ] = 'title-type' ; $ meta = $ this -> dom -> metadata -> addChild ( 'meta' , $ sequence ) ; $ meta [ 'refines' ] = '#' . $ id ; $ meta [ 'property' ] = 'display-seq' ; }
|
Set title meta
|
56,069
|
public function addMeta ( $ tag , $ value , array $ attributes = [ ] ) { $ value = $ this -> h ( $ value ) ; if ( false !== strpos ( $ tag , ':' ) ) { $ tags = explode ( ':' , $ tag ) ; $ node = $ this -> dom -> metadata -> addChild ( $ tags [ 1 ] , $ value , Schemas :: getUri ( $ tags [ 0 ] ) ) ; } else { $ node = $ this -> dom -> metadata -> addChild ( $ tag , $ value ) ; } foreach ( $ attributes as $ key => $ val ) { $ node [ $ key ] = $ this -> h ( $ val ) ; } }
|
Add meta item
|
56,070
|
public function addItem ( $ relative_path , $ id = '' , array $ properties = [ ] ) { $ id = $ id ? : $ this -> pathToId ( $ relative_path ) ; foreach ( $ this -> dom -> manifest -> item as $ item ) { $ attr = $ item -> attributes ( ) ; if ( isset ( $ attr [ 'id' ] ) && $ id == $ attr [ 'id' ] ) { return $ id ; } } $ item = $ this -> dom -> manifest -> addChild ( 'item' ) ; $ item [ 'id' ] = $ id ; $ item [ 'href' ] = $ relative_path ; $ item [ 'media-type' ] = Mime :: getTypeFromPath ( $ relative_path ) ; if ( $ properties ) { $ item [ 'properties' ] = implode ( ' ' , $ properties ) ; } return $ id ; }
|
Add item to
|
56,071
|
public function addIdref ( $ id , $ liner = 'yes' , array $ properties = [ ] ) { $ itemref = $ this -> dom -> spine -> addChild ( 'itemref' ) ; $ itemref [ 'idref' ] = $ id ; if ( 'no' === $ liner ) { $ itemref [ 'linear' ] = 'no' ; } if ( ! empty ( $ properties ) ) { $ itemref [ 'properties' ] = implode ( ' ' , $ properties ) ; } return $ itemref ; }
|
Add item ref to spine
|
56,072
|
public function addGuide ( $ type , $ href ) { if ( ! $ this -> dom -> guide -> count ( ) ) { $ guide = $ this -> dom -> addChild ( 'guide' ) ; } else { $ guide = $ this -> dom -> guide ; } $ ref = $ guide -> addChild ( 'reference' ) ; $ ref [ 'type' ] = $ type ; $ ref [ 'href' ] = $ href ; return $ ref ; }
|
Add guide element
|
56,073
|
public function pathToId ( $ path ) { $ path = ltrim ( ltrim ( $ path , '.' ) , DIRECTORY_SEPARATOR ) ; return strtolower ( preg_replace ( '/[_\.\/\\\\]/' , '-' , $ path ) ) ; }
|
Convert id to path
|
56,074
|
public function administrators ( $ field = null ) { $ model = TableRegistry :: get ( 'CakeAdmin.Administrators' ) ; $ query = $ model -> find ( 'all' ) ; if ( $ field ) { $ model -> displayField ( $ field ) ; $ query -> find ( 'list' ) ; } $ result = $ query -> toArray ( ) ; return $ result ; }
|
Returns a list of administrators .
|
56,075
|
public function isLoggedIn ( ) { $ session = $ this -> Controller -> request -> session ( ) ; if ( $ session -> check ( 'Auth.CakeAdmin' ) ) { return ( bool ) $ session -> read ( 'Auth.CakeAdmin' ) ; } return false ; }
|
Checks if an administrator is logged in .
|
56,076
|
public function authUser ( ) { $ session = $ this -> Controller -> request -> session ( ) ; if ( $ session -> check ( 'Auth.CakeAdmin' ) ) { return $ session -> read ( 'Auth.CakeAdmin' ) ; } return false ; }
|
Returns the logged in administrator . Will return false when there se no session .
|
56,077
|
public function getHTML ( $ header = '' , $ footer = '' ) { $ title = htmlspecialchars ( $ this -> label , ENT_QUOTES , 'UTF-8' ) ; $ html = <<<HTML<html xmlns:epub="http://www.idpf.org/2007/ops"><head><meta charset="UTF-8"><title>{$title}</title>{$header}</head><body>HTML ; $ html .= $ this -> getNavHTML ( ) ; $ html .= <<<HTML{$footer}</body></html>HTML ; return $ html ; }
|
Get simple navigation
|
56,078
|
public function getNavHTML ( $ content_label ) { if ( ! $ this -> root ) { return '' ; } $ landmarks = '' ; $ toc = '' ; foreach ( $ this -> children as $ child ) { $ toc .= $ this -> makeList ( $ child , false ) ; $ landmarks .= $ this -> makeList ( $ child , true , $ content_label ) ; } $ html = <<<HTML<nav epub:type="toc" id="toc"> <ol> {$toc} </ol></nav><nav id="landmarks" epub:type="landmarks" hidden="hidden" class="hidden"> <ol epub:type="list"> {$landmarks} </ol></nav>HTML ; return trim ( $ html ) ; }
|
Get navigation html
|
56,079
|
public static function get ( $ id ) { if ( isset ( self :: $ instances [ $ id ] ) ) { return self :: $ instances [ $ id ] ; } return null ; }
|
Get toc instance
|
56,080
|
public static function init ( $ id , $ label = 'Index' ) { if ( ! isset ( self :: $ instances [ $ id ] ) ) { self :: $ instances [ $ id ] = new Toc ( $ label , '' , true ) ; } return self :: $ instances [ $ id ] ; }
|
Initialize toc element
|
56,081
|
function formatField ( $ exclude = array ( '2' ) ) { if ( $ this -> isControlField ( ) ) { return $ this -> getData ( ) ; } else { $ out = '' ; foreach ( $ this -> getSubfields ( ) as $ subfield ) { if ( substr ( $ this -> getTag ( ) , 0 , 1 ) == '6' and ( in_array ( $ subfield -> getCode ( ) , array ( 'v' , 'x' , 'y' , 'z' ) ) ) ) { $ out .= ' -- ' . $ subfield -> getData ( ) ; } elseif ( ! in_array ( $ subfield -> getCode ( ) , $ exclude ) ) { $ out .= ' ' . $ subfield -> getData ( ) ; } } return trim ( $ out ) ; } }
|
Pretty print a MARC_Field object without tags indicators etc .
|
56,082
|
private function getHeader ( $ name , $ headers ) { $ headers = array_change_key_case ( $ headers ) ; $ name = strtolower ( $ name ) ; return isset ( $ headers [ $ name ] ) ? ( string ) $ headers [ $ name ] : false ; }
|
Returns the case insensitive header from the list of headers .
|
56,083
|
private function _buildDirectory ( ) { $ fields = array ( ) ; $ directory = array ( ) ; $ data_end = 0 ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isEmpty ( ) ) { $ str = $ field -> toRaw ( ) ; $ fields [ ] = $ str ; $ len = strlen ( $ str ) ; $ direntry = sprintf ( "%03s%04d%05d" , $ field -> getTag ( ) , $ len , $ data_end ) ; $ directory [ ] = $ direntry ; $ data_end += $ len ; } } $ base_address = File_MARC :: LEADER_LEN + ( count ( $ directory ) * File_MARC :: DIRECTORY_ENTRY_LEN ) + 1 ; $ total = $ base_address + $ data_end + 1 ; return array ( $ fields , $ directory , $ total , $ base_address ) ; }
|
Build record directory
|
56,084
|
function setLeaderLengths ( $ record_length , $ base_address ) { if ( ! is_int ( $ record_length ) ) { return false ; } if ( ! is_int ( $ base_address ) ) { return false ; } $ this -> setLeader ( substr_replace ( $ this -> getLeader ( ) , sprintf ( "%05d" , $ record_length ) , 0 , 5 ) ) ; $ this -> setLeader ( substr_replace ( $ this -> getLeader ( ) , sprintf ( "%05d" , $ base_address ) , File_MARC :: DIRECTORY_ENTRY_LEN , 5 ) ) ; $ this -> setLeader ( substr_replace ( $ this -> getLeader ( ) , '22' , 10 , 2 ) ) ; $ this -> setLeader ( substr_replace ( $ this -> getLeader ( ) , '4500' , 20 , 4 ) ) ; if ( strlen ( $ this -> getLeader ( ) ) > File_MARC :: LEADER_LEN ) { $ this -> setLeader ( substr ( $ this -> getLeader ( ) , 0 , File_MARC :: LEADER_LEN ) ) ; $ this -> addWarning ( "Input leader was too long; truncated to " . File_MARC :: LEADER_LEN . " characters" ) ; } return true ; }
|
Set MARC record leader lengths
|
56,085
|
function deleteFields ( $ tag , $ pcre = null ) { $ cnt = 0 ; foreach ( $ this -> getFields ( ) as $ field ) { if ( ( $ pcre && preg_match ( "/$tag/" , $ field -> getTag ( ) ) ) || ( ! $ pcre && $ tag == $ field -> getTag ( ) ) ) { $ field -> delete ( ) ; $ cnt ++ ; } } return $ cnt ; }
|
Delete all occurrences of a field matching a tag name from the record .
|
56,086
|
function toRaw ( ) { list ( $ fields , $ directory , $ record_length , $ base_address ) = $ this -> _buildDirectory ( ) ; $ this -> setLeaderLengths ( $ record_length , $ base_address ) ; return $ this -> getLeader ( ) . implode ( "" , $ directory ) . File_MARC :: END_OF_FIELD . implode ( "" , $ fields ) . File_MARC :: END_OF_RECORD ; }
|
Return the record in raw MARC format .
|
56,087
|
function toJSON ( ) { $ json = new StdClass ( ) ; $ json -> leader = utf8_encode ( $ this -> getLeader ( ) ) ; $ fields = array ( ) ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isEmpty ( ) ) { switch ( get_class ( $ field ) ) { case "File_MARC_Control_Field" : $ fields [ ] = array ( utf8_encode ( $ field -> getTag ( ) ) => utf8_encode ( $ field -> getData ( ) ) ) ; break ; case "File_MARC_Data_Field" : $ subs = array ( ) ; foreach ( $ field -> getSubfields ( ) as $ sf ) { $ subs [ ] = array ( utf8_encode ( $ sf -> getCode ( ) ) => utf8_encode ( $ sf -> getData ( ) ) ) ; } $ contents = new StdClass ( ) ; $ contents -> ind1 = utf8_encode ( $ field -> getIndicator ( 1 ) ) ; $ contents -> ind2 = utf8_encode ( $ field -> getIndicator ( 2 ) ) ; $ contents -> subfields = $ subs ; $ fields [ ] = array ( utf8_encode ( $ field -> getTag ( ) ) => $ contents ) ; break ; } } } $ json -> fields = $ fields ; $ json_rec = json_encode ( $ json ) ; return preg_replace ( '/("subfields":)(.*?)\["([^\"]+?)"\]/' , '\1\2{"0":"\3"}' , $ json_rec ) ; }
|
Return the MARC record in JSON format
|
56,088
|
function toJSONHash ( ) { $ json = new StdClass ( ) ; $ json -> type = "marc-hash" ; $ json -> version = array ( 1 , 0 ) ; $ json -> leader = utf8_encode ( $ this -> getLeader ( ) ) ; $ fields = array ( ) ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isEmpty ( ) ) { switch ( get_class ( $ field ) ) { case "File_MARC_Control_Field" : $ fields [ ] = array ( utf8_encode ( $ field -> getTag ( ) ) , utf8_encode ( $ field -> getData ( ) ) ) ; break ; case "File_MARC_Data_Field" : $ subs = array ( ) ; foreach ( $ field -> getSubfields ( ) as $ sf ) { $ subs [ ] = array ( utf8_encode ( $ sf -> getCode ( ) ) , utf8_encode ( $ sf -> getData ( ) ) ) ; } $ contents = array ( utf8_encode ( $ field -> getTag ( ) ) , utf8_encode ( $ field -> getIndicator ( 1 ) ) , utf8_encode ( $ field -> getIndicator ( 2 ) ) , $ subs ) ; $ fields [ ] = $ contents ; break ; } } } $ json -> fields = $ fields ; return json_encode ( $ json ) ; }
|
Return the MARC record in Bill Dueber s MARC - HASH JSON format
|
56,089
|
function toXML ( $ encoding = "UTF-8" , $ indent = true , $ single = true ) { $ this -> marcxml -> setIndent ( $ indent ) ; if ( $ single ) { $ this -> marcxml -> startElement ( "collection" ) ; $ this -> marcxml -> writeAttribute ( "xmlns" , "http://www.loc.gov/MARC21/slim" ) ; $ this -> marcxml -> startElement ( "record" ) ; } else { $ this -> marcxml -> startElement ( "record" ) ; $ this -> marcxml -> writeAttribute ( "xmlns" , "http://www.loc.gov/MARC21/slim" ) ; } $ xmlLeader = $ this -> getLeader ( ) ; if ( $ xmlLeader [ 5 ] == " " ) { $ xmlLeader [ 5 ] = "n" ; } if ( $ xmlLeader [ 6 ] == " " ) { $ xmlLeader [ 6 ] = "a" ; } $ this -> marcxml -> writeElement ( "leader" , $ xmlLeader ) ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isEmpty ( ) ) { switch ( get_class ( $ field ) ) { case "File_MARC_Control_Field" : $ this -> marcxml -> startElement ( "controlfield" ) ; $ this -> marcxml -> writeAttribute ( "tag" , $ field -> getTag ( ) ) ; $ this -> marcxml -> text ( $ field -> getData ( ) ) ; $ this -> marcxml -> endElement ( ) ; break ; case "File_MARC_Data_Field" : $ this -> marcxml -> startElement ( "datafield" ) ; $ this -> marcxml -> writeAttribute ( "tag" , $ field -> getTag ( ) ) ; $ this -> marcxml -> writeAttribute ( "ind1" , $ field -> getIndicator ( 1 ) ) ; $ this -> marcxml -> writeAttribute ( "ind2" , $ field -> getIndicator ( 2 ) ) ; foreach ( $ field -> getSubfields ( ) as $ subfield ) { $ this -> marcxml -> startElement ( "subfield" ) ; $ this -> marcxml -> writeAttribute ( "code" , $ subfield -> getCode ( ) ) ; $ this -> marcxml -> text ( $ subfield -> getData ( ) ) ; $ this -> marcxml -> endElement ( ) ; } $ this -> marcxml -> endElement ( ) ; break ; } } } $ this -> marcxml -> endElement ( ) ; if ( $ single ) { $ this -> marcxml -> endElement ( ) ; $ this -> marcxml -> endDocument ( ) ; } return $ this -> marcxml -> outputMemory ( ) ; }
|
Return the MARC record in MARCXML format
|
56,090
|
public static function getUri ( $ name_space ) { $ refl = new \ ReflectionClass ( get_called_class ( ) ) ; $ name_space = strtoupper ( $ name_space ) ; return $ refl -> hasConstant ( $ name_space ) ? $ refl -> getConstant ( $ name_space ) : '' ; }
|
Get name space URL
|
56,091
|
public function getXML ( ) { $ doc = new \ DomDocument ( '1.0' ) ; $ doc -> preserveWhiteSpace = false ; $ doc -> formatOutput = true ; $ doc -> loadXML ( $ this -> dom -> asXml ( ) ) ; return $ doc -> saveXML ( ) ; }
|
Get XML string in pretty format
|
56,092
|
public function putXML ( ) { $ xml = $ this -> getXML ( ) ; return $ this -> distributor -> write ( $ xml , $ this -> proper_path ) ; }
|
Put XML file
|
56,093
|
private function setDir ( $ rel_path ) { $ path = $ this -> temp_dir . DIRECTORY_SEPARATOR . ltrim ( $ rel_path , DIRECTORY_SEPARATOR ) ; $ dir = dirname ( $ path ) ; if ( ! is_dir ( $ dir ) ) { if ( ! mkdir ( $ dir , 0755 , true ) ) { return false ; } } return $ path ; }
|
Ensure parent directory is ready and writable
|
56,094
|
public function compile ( $ to ) { copy ( $ this -> path -> skeleton , $ to ) ; $ epub = new \ ZipArchive ( ) ; if ( true === $ epub -> open ( $ to ) ) { $ this -> deliver ( $ epub , $ this -> temp_dir ) ; } }
|
Compile ePub File
|
56,095
|
private function deliver ( \ ZipArchive & $ epub , $ src , $ dir = '' ) { if ( ! $ dir ) { $ dir = $ src ; } if ( is_dir ( $ src ) ) { $ root = rtrim ( $ src , DIRECTORY_SEPARATOR ) ; foreach ( scandir ( $ src ) as $ file ) { if ( ! preg_match ( '/^\./' , $ file ) ) { $ path = $ root . DIRECTORY_SEPARATOR . $ file ; $ this -> deliver ( $ epub , $ path , $ dir ) ; } } } elseif ( file_exists ( $ src ) ) { $ relative_path = ltrim ( str_replace ( $ dir , '' , $ src ) , DIRECTORY_SEPARATOR ) ; $ epub -> addFile ( $ src , $ relative_path ) ; } else { throw new CompileException ( sprintf ( 'Cannot copy file %s.' , $ src ) ) ; } }
|
Copy file into zip
|
56,096
|
private function _decode ( $ text ) { $ marc = new $ this -> record_class ( $ this ) ; $ marc -> setLeader ( $ text -> leader ) ; foreach ( $ text -> controlfield as $ controlfield ) { $ controlfieldattributes = $ controlfield -> attributes ( ) ; $ marc -> appendField ( new File_MARC_Control_Field ( ( string ) $ controlfieldattributes [ 'tag' ] , $ controlfield ) ) ; } foreach ( $ text -> datafield as $ datafield ) { $ datafieldattributes = $ datafield -> attributes ( ) ; $ subfield_data = array ( ) ; foreach ( $ datafield -> subfield as $ subfield ) { $ subfieldattributes = $ subfield -> attributes ( ) ; $ subfield_data [ ] = new File_MARC_Subfield ( ( string ) $ subfieldattributes [ 'code' ] , $ subfield ) ; } try { $ new_field = new File_MARC_Data_Field ( ( string ) $ datafieldattributes [ 'tag' ] , $ subfield_data , $ datafieldattributes [ 'ind1' ] , $ datafieldattributes [ 'ind2' ] ) ; $ marc -> appendField ( $ new_field ) ; } catch ( Exception $ e ) { $ marc -> addWarning ( $ e -> getMessage ( ) ) ; } } return $ marc ; }
|
Decode a given MARCXML record
|
56,097
|
public function registerHTML ( $ id , $ html , $ linear = 'yes' , array $ properties = [ ] ) { $ dom = $ this -> parser -> parseFromString ( $ html ) ; if ( $ dom ) { if ( ! isset ( $ this -> doms [ $ id ] ) ) { $ this -> opf -> addIdref ( $ id . '.xhtml' , $ linear , $ properties ) ; } $ this -> doms [ $ id ] = $ dom ; return $ dom ; } return false ; }
|
Register HTML string
|
56,098
|
public function includeTemplate ( $ id , $ path , array $ args = [ ] , $ linear = 'yes' , array $ properties = [ ] ) { if ( ! file_exists ( $ path ) ) { return false ; } if ( ! empty ( $ args ) ) { extract ( $ args ) ; } ob_start ( ) ; include $ path ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ this -> registerHTML ( $ id , $ content , $ linear , $ properties ) ; }
|
Load from path
|
56,099
|
public function registerFromPath ( $ id , $ path ) { if ( ! file_exists ( $ path ) ) { return false ; } $ dom = $ this -> parser -> parseFromString ( file_get_contents ( $ path ) ) ; if ( $ dom ) { $ this -> doms [ $ id ] = $ dom ; } return false ; }
|
Register HTML from file path
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.