idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
54,200
|
public function getLemmas ( $ word , $ partOfSpeech = null ) { if ( $ partOfSpeech !== null && ! isset ( self :: $ partsOfSpeech [ $ partOfSpeech ] ) ) { $ posAsString = implode ( ' or ' , array_keys ( self :: $ partsOfSpeech ) ) ; throw new InvalidArgumentException ( "partsOfSpeech must be {$posAsString}." ) ; } $ wordEntity = new Word ( $ word ) ; if ( $ partOfSpeech !== null ) { $ pos = $ this -> getPos ( $ partOfSpeech ) ; $ lemmas = $ this -> getBaseForm ( $ wordEntity , $ pos ) ; if ( ! $ lemmas ) { $ lemmas [ ] = new Lemma ( $ word , $ partOfSpeech ) ; } } else { $ lemmas = [ ] ; foreach ( self :: $ partsOfSpeech as $ pos ) { $ lemmas = array_merge ( $ lemmas , $ this -> getBaseForm ( $ wordEntity , $ pos ) ) ; } if ( ! $ lemmas ) { foreach ( self :: $ partsOfSpeech as $ pos ) { if ( isset ( $ pos -> getWordsList ( ) [ $ word ] ) ) { $ lemmas [ ] = new Lemma ( $ word , $ pos -> getPartOfSpeechAsString ( ) ) ; } } } if ( ! $ lemmas ) { $ lemmas [ ] = new Lemma ( $ word ) ; } } return array_unique ( $ lemmas , SORT_REGULAR ) ; }
|
Lemmatize a word
|
54,201
|
protected function setIsDraftSecured ( Session $ session , $ secured ) { if ( method_exists ( Versioned :: class , 'set_draft_site_secured' ) ) { Versioned :: set_draft_site_secured ( $ secured ) ; } $ session -> set ( 'unsecuredDraftSite' , ! $ secured ) ; }
|
Set draft site security
|
54,202
|
public static function count ( Array $ body ) { $ instance = new static ; $ params = $ instance -> basicElasticParams ( ) ; $ params [ 'body' ] = $ body ; $ response = $ instance -> getElasticClient ( ) -> count ( $ params ) ; return intval ( $ response [ 'count' ] ) ; }
|
Returns match count
|
54,203
|
public static function search ( Array $ body ) { $ instance = new static ; $ params = $ instance -> basicElasticParams ( ) ; $ params [ 'body' ] = $ body ; $ response = $ instance -> getElasticClient ( ) -> search ( $ params ) ; return new ElasticCollection ( $ response , $ instance ) ; }
|
Builds an arbitrary query .
|
54,204
|
public static function fuzzy ( $ field , $ value , $ fuzziness = 'AUTO' ) { $ body = array ( 'query' => array ( 'fuzzy' => array ( $ field => array ( 'value' => $ value , 'fuzziness' => $ fuzziness ) ) ) , 'size' => 1000 ) ; return static :: search ( $ body ) ; }
|
Builds a fuzzy query .
|
54,205
|
public static function geoshape ( $ field , Array $ coordinates , $ type = 'envelope' ) { $ body = array ( 'query' => array ( 'geo_shape' => array ( $ field => array ( 'shape' => array ( 'type' => $ type , 'coordinates' => $ coordinates ) ) ) ) , 'size' => 1000 ) ; return static :: search ( $ body ) ; }
|
Builds a geoshape query .
|
54,206
|
public static function moreLikeThis ( Array $ fields , Array $ ids , $ minTermFreq = 1 , $ percentTermsToMatch = 0.5 , $ minWordLength = 3 ) { $ body = array ( 'query' => array ( 'more_like_this' => array ( 'fields' => $ fields , 'ids' => $ ids , 'min_term_freq' => $ minTermFreq , 'percent_terms_to_match' => $ percentTermsToMatch , 'min_word_length' => $ minWordLength , ) ) , 'size' => 1000 ) ; return static :: search ( $ body ) ; }
|
Builds a more_like_this query .
|
54,207
|
public static function getMapping ( ) { $ instance = new static ; $ params = $ instance -> basicElasticParams ( ) ; return $ instance -> getElasticClient ( ) -> indices ( ) -> getMapping ( $ params ) ; }
|
Gets mappings .
|
54,208
|
public static function putMapping ( ) { $ instance = new static ; $ mapping = $ instance -> basicElasticParams ( ) ; $ params = array ( '_source' => array ( 'enabled' => true ) , 'properties' => $ instance -> getMappingProperties ( ) ) ; $ mapping [ 'body' ] [ $ instance -> getTypeName ( ) ] = $ params ; return $ instance -> getElasticClient ( ) -> indices ( ) -> putMapping ( $ mapping ) ; }
|
Puts mappings .
|
54,209
|
public static function deleteMapping ( ) { $ instance = new static ; $ params = $ instance -> basicElasticParams ( ) ; return $ instance -> getElasticClient ( ) -> indices ( ) -> deleteMapping ( $ params ) ; }
|
Deletes mappings .
|
54,210
|
public function index ( ) { $ params = $ this -> basicElasticParams ( true ) ; $ params [ 'body' ] = $ this -> documentFields ( ) ; return $ this -> getElasticClient ( ) -> index ( $ params ) ; }
|
Indexes the model in Elasticsearch .
|
54,211
|
public function updateIndex ( Array $ fields = array ( ) ) { if ( $ fields ) { $ body = $ fields ; } elseif ( $ this -> isDirty ( ) ) { $ body = $ this -> getDirty ( ) ; } else { return true ; } foreach ( $ body as $ field => $ value ) { if ( $ value instanceof Carbon ) { $ body [ $ field ] = $ value -> toDateTimeString ( ) ; } } $ params = $ this -> basicElasticParams ( true ) ; $ params [ 'body' ] [ 'doc' ] = $ body ; try { return $ this -> getElasticClient ( ) -> update ( $ params ) ; } catch ( Missing404Exception $ e ) { return false ; } }
|
Updates the model s index .
|
54,212
|
public function removeIndex ( ) { try { return $ this -> getElasticClient ( ) -> delete ( $ this -> basicElasticParams ( true ) ) ; } catch ( Missing404Exception $ e ) { return false ; } }
|
Removes the model s index .
|
54,213
|
public function highlight ( $ field ) { if ( isset ( $ this -> highlighted [ $ field ] ) ) { return $ this -> highlighted [ $ field ] ; } return false ; }
|
Returns a highlighted field .
|
54,214
|
public function newFromElasticResults ( Array $ hit ) { $ instance = $ this -> newInstance ( array ( ) , true ) ; $ attributes = $ hit [ '_source' ] ; $ instance -> isDocument = true ; if ( isset ( $ hit [ '_score' ] ) ) { $ instance -> documentScore = $ hit [ '_score' ] ; } if ( isset ( $ hit [ '_version' ] ) ) { $ instance -> documentVersion = $ hit [ '_version' ] ; } if ( isset ( $ hit [ 'highlight' ] ) ) { foreach ( $ hit [ 'highlight' ] as $ field => $ value ) { $ instance -> highlighted [ $ field ] = $ value [ 0 ] ; } } $ instance -> setRawAttributes ( $ attributes , true ) ; return $ instance ; }
|
Fills a model s attributes with Elasticsearch result data .
|
54,215
|
protected function basicElasticParams ( $ withId = false ) { $ params = array ( 'index' => $ this -> getIndex ( ) , 'type' => $ this -> getTypeName ( ) ) ; if ( $ withId and $ this -> getKey ( ) ) { $ params [ 'id' ] = $ this -> getKey ( ) ; } return $ params ; }
|
Sets the basic Elasticsearch parameters .
|
54,216
|
public function addSlimPlugins ( RouterInterface $ router , $ uri ) { $ smartyPlugins = new SmartyPlugins ( $ router , $ uri ) ; $ this -> smarty -> registerPlugin ( 'function' , 'path_for' , [ $ smartyPlugins , 'pathFor' ] ) ; $ this -> smarty -> registerPlugin ( 'function' , 'base_url' , [ $ smartyPlugins , 'baseUrl' ] ) ; }
|
Method to add the Slim plugins to Smarty
|
54,217
|
public function registerPlugin ( $ type , $ tag , $ callback , $ cacheable = true , $ cache_attr = null ) { $ this -> smarty -> registerPlugin ( $ type , $ tag , $ callback , $ cacheable , $ cache_attr ) ; }
|
Proxy method to register a plugin to Smarty
|
54,218
|
protected function parseEscape ( $ text ) { if ( isset ( $ text [ 1 ] ) && in_array ( $ text [ 1 ] , $ this -> escapeCharacters ) ) { if ( $ text [ 1 ] === '\\' ) { return [ [ 'backslash' ] , 2 ] ; } return [ [ 'text' , $ text [ 1 ] ] , 2 ] ; } return [ [ 'text' , $ text [ 0 ] ] , 1 ] ; }
|
Parses escaped special characters . This allow a backslash to be interpreted as LaTeX
|
54,219
|
protected function escapeLatex ( $ string ) { if ( $ this -> _escaper === null ) { $ this -> _escaper = new TextToLatex ( ) ; } return $ this -> _escaper -> convert ( $ string ) ; }
|
Escape special LaTeX characters
|
54,220
|
public function distinctUntilChanged ( callable $ keySelector = null , callable $ comparer = null ) { return $ this -> lift ( function ( ) use ( $ keySelector , $ comparer ) { return new DistinctUntilChangedOperator ( $ keySelector , $ comparer ) ; } ) ; }
|
Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer .
|
54,221
|
public function scan ( callable $ accumulator , $ seed = null ) { return $ this -> lift ( function ( ) use ( $ accumulator , $ seed ) { return new ScanOperator ( $ accumulator , $ seed ) ; } ) ; }
|
Applies an accumulator function over an observable sequence and returns each intermediate result . The optional seed value is used as the initial accumulator value . For aggregation behavior with no intermediate results see Observable . aggregate .
|
54,222
|
public function zip ( array $ observables , callable $ selector = null ) { return $ this -> lift ( function ( ) use ( $ observables , $ selector ) { return new ZipOperator ( $ observables , $ selector ) ; } ) ; }
|
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index . If the result selector function is omitted a list with the elements of the observable sequences at corresponding indexes will be yielded .
|
54,223
|
public function index ( ) { if ( $ this -> isEmpty ( ) ) { return false ; } $ params = array ( ) ; foreach ( $ this -> all ( ) as $ item ) { $ params [ 'body' ] [ ] = array ( 'index' => array ( '_index' => $ item -> getIndex ( ) , '_type' => $ item -> getTypeName ( ) , '_id' => $ item -> getKey ( ) ) ) ; $ params [ 'body' ] [ ] = $ item -> documentFields ( ) ; } return $ this -> getElasticClient ( ) -> bulk ( $ params ) ; }
|
Indexes all the results from the collection .
|
54,224
|
public function paginate ( $ perPage = 15 ) { $ paginator = Paginator :: make ( $ this -> items , count ( $ this -> items ) , $ perPage ) ; $ start = ( $ paginator -> getFactory ( ) -> getCurrentPage ( ) - 1 ) * $ perPage ; $ sliced = array_slice ( $ this -> items , $ start , $ perPage ) ; return Paginator :: make ( $ sliced , count ( $ this -> items ) , $ perPage ) ; }
|
Paginates the Elasticsearch results .
|
54,225
|
public function limit ( $ limit = null ) { if ( $ limit ) { if ( $ limit < 0 ) { $ this -> items = array_slice ( $ this -> items , $ limit , abs ( $ limit ) ) ; } else { $ this -> items = array_slice ( $ this -> items , 0 , $ limit ) ; } } return $ this ; }
|
Limits the number of results .
|
54,226
|
protected function elasticToModel ( ) { $ items = array ( ) ; foreach ( $ this -> response [ 'hits' ] [ 'hits' ] as $ hit ) { $ items [ ] = $ this -> instance -> newFromElasticResults ( $ hit ) ; } return $ items ; }
|
Builds a list of models from Elasticsearch results .
|
54,227
|
public function shards ( $ key = null ) { $ shards = $ this -> response [ '_shards' ] ; if ( $ key and isset ( $ shards [ $ key ] ) ) { return $ shards [ $ key ] ; } return $ shards ; }
|
Shards information .
|
54,228
|
function addFile ( FileUpload $ file ) { $ a = func_get_args ( ) ; Debugger :: log ( __CLASS__ . ": " . __METHOD__ . "; args: " . print_r ( $ a , true ) ) ; }
|
Adds file to queue
|
54,229
|
private function convertRequest ( BrowserKitRequest $ request ) { $ environment = Environment :: mock ( $ request -> getServer ( ) ) ; $ uri = Uri :: createFromString ( $ request -> getUri ( ) ) ; $ headers = Headers :: createFromEnvironment ( $ environment ) ; $ cookies = Cookies :: parseHeader ( $ headers -> get ( 'Cookie' , [ ] ) ) ; $ container = $ this -> app -> getContainer ( ) ; $ slimRequest = $ container -> get ( 'request' ) ; $ slimRequest = $ slimRequest -> withMethod ( $ request -> getMethod ( ) ) -> withUri ( $ uri ) -> withUploadedFiles ( $ this -> convertFiles ( $ request -> getFiles ( ) ) ) -> withCookieParams ( $ cookies ) ; foreach ( $ headers -> keys ( ) as $ key ) { $ slimRequest = $ slimRequest -> withHeader ( $ key , $ headers -> get ( $ key ) ) ; } if ( $ request -> getContent ( ) !== null ) { $ body = new RequestBody ( ) ; $ body -> write ( $ request -> getContent ( ) ) ; $ slimRequest = $ slimRequest -> withBody ( $ body ) ; } $ parsed = [ ] ; if ( $ request -> getMethod ( ) !== 'GET' ) { $ parsed = $ request -> getParameters ( ) ; } if ( ! $ slimRequest -> getParsedBody ( ) ) { $ slimRequest = $ slimRequest -> withParsedBody ( $ parsed ) ; } return $ slimRequest ; }
|
Convert to PSR - 7 s ServerRequestInterface .
|
54,230
|
protected function isSourceDirUnused ( PackageInterface $ package ) { $ usageData = $ this -> packageDataManager -> getPackageUsage ( $ package ) ; return sizeof ( $ usageData ) <= 1 ; }
|
Detect if other project use the dependency by using the packages . json file
|
54,231
|
function processFile ( $ token , $ file ) { if ( ! $ file instanceof FileUpload ) { return false ; } $ validateCallback = MultipleFileUpload :: $ validateFileCallback ; $ isValid = $ validateCallback -> invoke ( $ file ) ; if ( $ isValid ) { MultipleFileUpload :: getQueuesModel ( ) -> getQueue ( $ token ) -> addFile ( $ file ) ; } return $ isValid ; }
|
Process single file
|
54,232
|
public function scopePimp ( Builder $ builder , $ query = [ ] , $ sort = [ ] , $ relations = [ ] ) { $ query = $ query ? : array_except ( Input :: all ( ) , [ $ this -> sortParameterName , $ this -> withParameterName ] ) ; $ builder -> filtered ( $ query ) -> sorted ( $ sort ) -> withRelations ( $ relations ) ; }
|
Enable searchable sortable and withable scopes
|
54,233
|
public function removePackageUsage ( PackageInterface $ package ) { $ usageData = $ this -> getPackageUsage ( $ package ) ; $ newUsageData = array ( ) ; $ projectName = $ this -> composer -> getPackage ( ) -> getName ( ) ; foreach ( $ usageData as $ usage ) { if ( $ projectName !== $ usage ) { $ newUsageData [ ] = $ usage ; } } $ this -> updatePackageUsageFile ( $ package , $ newUsageData ) ; }
|
Remove the row in the packages . json file
|
54,234
|
protected function initializePackageData ( ) { $ filePath = $ this -> vendorDir . DIRECTORY_SEPARATOR . self :: PACKAGE_DATA_FILENAME ; if ( ! is_file ( $ filePath ) ) { $ this -> packagesData = array ( ) ; } else { $ this -> packagesData = json_decode ( file_get_contents ( $ filePath ) , true ) ; } }
|
Initialize the package data array if not set
|
54,235
|
protected function setSymlinkBasePath ( array $ extraConfigs ) { if ( isset ( $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'symlink-base-path' ] ) ) { $ this -> symlinkBasePath = $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'symlink-base-path' ] ; if ( false !== getenv ( static :: ENV_PARAMETER_SYMLINK_BASE_PATH ) ) { $ this -> symlinkBasePath = getenv ( static :: ENV_PARAMETER_SYMLINK_BASE_PATH ) ; } if ( '/' === $ this -> symlinkBasePath [ strlen ( $ this -> symlinkBasePath ) - 1 ] ) { $ this -> symlinkBasePath = substr ( $ this -> symlinkBasePath , 0 , - 1 ) ; } } elseif ( 0 < strpos ( $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'vendor-dir' ] , '/' ) ) { $ this -> symlinkBasePath = $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'vendor-dir' ] ; } if ( 0 < strpos ( $ this -> symlinkBasePath , '/' ) ) { $ this -> symlinkBasePath = '../../' . $ this -> symlinkBasePath ; } }
|
Allow to override symlinks base path . This is useful for a Virtual Machine environment where directories can be different on the host machine and the guest machine .
|
54,236
|
protected function setIsSymlinkEnabled ( array $ extraConfigs ) { if ( isset ( $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'symlink-enabled' ] ) ) { if ( ! is_bool ( $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'symlink-enabled' ] ) ) { throw new \ UnexpectedValueException ( 'The configuration "symlink-enabled" should be a boolean' ) ; } $ this -> isSymlinkEnabled = $ extraConfigs [ SharedPackageInstaller :: PACKAGE_TYPE ] [ 'symlink-enabled' ] ; } }
|
The symlink directory creation process can be disabled . This may mean that you work directly with the sources directory so the symlink directory is useless .
|
54,237
|
public function getShippingMethodTemplate ( $ template , array $ order , $ shipping_model ) { if ( empty ( $ order [ 'shipping' ] ) ) { return '' ; } $ method = $ shipping_model -> get ( $ order [ 'shipping' ] ) ; return $ this -> getMethodTemplate ( $ template , $ order , $ method ) ; }
|
Returns a template for a shipping method
|
54,238
|
public function getPaymentMethodTemplate ( $ template , array $ order , $ payment_model ) { if ( empty ( $ order [ 'payment' ] ) ) { return '' ; } $ method = $ payment_model -> get ( $ order [ 'payment' ] ) ; return $ this -> getMethodTemplate ( $ template , $ order , $ method ) ; }
|
Returns a template for a payment method
|
54,239
|
public function boot ( ) { if ( true === $ this -> booted ) { return $ this ; } if ( $ this -> isDebug ( ) ) { ExceptionHandler :: register ( true , 'UTF-8' , 'PPI Framework' , self :: VERSION , true ) ; } $ this -> serviceManager = $ this -> buildServiceManager ( ) ; $ this -> log ( 'debug' , sprintf ( 'Booting %s ...' , $ this -> name ) ) ; $ this -> getModuleManager ( ) -> loadModules ( ) ; if ( $ this -> debug ) { $ modules = $ this -> getModuleManager ( ) -> getModules ( ) ; $ this -> log ( 'debug' , sprintf ( 'All modules online (%d): "%s"' , count ( $ modules ) , implode ( '", "' , $ modules ) ) ) ; } $ moduleServices = $ this -> serviceManager -> get ( 'ModuleDefaultListener' ) -> getServices ( ) ; foreach ( $ moduleServices as $ key => $ service ) { $ this -> serviceManager -> setFactory ( $ key , $ service ) ; } $ this -> booted = true ; if ( $ this -> debug ) { $ this -> log ( 'debug' , sprintf ( '%s has booted (in %.3f secs)' , $ this -> name , microtime ( true ) - $ this -> startTime ) ) ; } return $ this ; }
|
Run the boot process load our modules and their dependencies .
|
54,240
|
public function dispatch ( HttpRequest $ request , HttpResponse $ response ) { if ( false === $ this -> booted ) { $ this -> boot ( ) ; } $ routeParams = $ this -> handleRouting ( $ request ) ; $ request -> attributes -> add ( $ routeParams ) ; $ resolver = $ this -> serviceManager -> get ( 'ControllerResolver' ) ; if ( false === $ controller = $ resolver -> getController ( $ request ) ) { throw new NotFoundHttpException ( sprintf ( 'Unable to find the controller for path "%s".' , $ request -> getPathInfo ( ) ) ) ; } $ controllerArguments = $ resolver -> getArguments ( $ request , $ controller ) ; $ result = call_user_func_array ( $ controller , $ controllerArguments ) ; if ( $ result === null ) { throw new \ Exception ( 'Your action returned null. It must always return something' ) ; } elseif ( is_string ( $ result ) ) { $ response -> setContent ( $ result ) ; } elseif ( $ result instanceof SymfonyResponse || $ response instanceof HttpResponse ) { $ response = $ result ; } else { throw new \ Exception ( 'Invalid response type returned from controller' ) ; } return $ response ; }
|
Decide on a route to use and dispatch our module s controller action .
|
54,241
|
public function getName ( ) { if ( null === $ this -> name ) { $ this -> name = preg_replace ( '/[^a-zA-Z0-9_]+/' , '' , basename ( $ this -> rootDir ) ) ; } return $ this -> name ; }
|
Gets the name of the application .
|
54,242
|
public function getModuleManager ( ) { if ( null === $ this -> moduleManager ) { $ this -> moduleManager = $ this -> serviceManager -> get ( 'ModuleManager' ) ; } return $ this -> moduleManager ; }
|
Returns the Module Manager .
|
54,243
|
public function getConfigManager ( ) { if ( null === $ this -> configManager ) { $ cachePath = $ this -> getCacheDir ( ) . '/application-config-cache.' . $ this -> getName ( ) . '.php' ; $ this -> configManager = new ConfigManager ( $ cachePath , ! $ this -> debug , $ this -> rootDir . '/config' ) ; } return $ this -> configManager ; }
|
Returns a ConfigManager instance .
|
54,244
|
public function loadConfig ( $ resource , $ type = null ) { $ this -> getConfigManager ( ) -> addConfig ( $ resource , $ type ) ; return $ this ; }
|
Loads a configuration file or PHP array .
|
54,245
|
protected function getAppParameters ( ) { return array_merge ( array ( 'app.root_dir' => $ this -> rootDir , 'app.environment' => $ this -> environment , 'app.debug' => $ this -> debug , 'app.name' => $ this -> name , 'app.cache_dir' => $ this -> getCacheDir ( ) , 'app.logs_dir' => $ this -> getLogDir ( ) , 'app.charset' => $ this -> getCharset ( ) , ) , $ this -> getEnvParameters ( ) ) ; }
|
Returns the application parameters .
|
54,246
|
protected function getEnvParameters ( ) { $ parameters = array ( ) ; foreach ( $ _SERVER as $ key => $ value ) { if ( 0 === strpos ( $ key , 'PPI__' ) ) { $ parameters [ strtolower ( str_replace ( '__' , '.' , substr ( $ key , 5 ) ) ) ] = $ value ; } } return $ parameters ; }
|
Gets the environment parameters .
|
54,247
|
protected function buildServiceManager ( ) { $ serviceManager = new ServiceManagerBuilder ( $ this -> getConfigManager ( ) -> getMergedConfig ( ) ) ; $ serviceManager -> build ( $ this -> getAppParameters ( ) ) ; $ serviceManager -> set ( 'app' , $ this ) ; return $ serviceManager ; }
|
Creates and initializes a ServiceManager instance .
|
54,248
|
protected function handleRouting ( HttpRequest $ request ) { $ this -> router = $ this -> serviceManager -> get ( 'Router' ) ; $ this -> router -> warmUp ( $ this -> getCacheDir ( ) ) ; try { $ parameters = $ this -> router -> matchRequest ( $ request ) ; if ( ! empty ( $ parameters ) ) { if ( null !== $ this -> logger ) { $ this -> logger -> info ( sprintf ( 'Matched route "%s" (parameters: %s)' , $ parameters [ '_route' ] , $ this -> router -> parametersToString ( $ parameters ) ) ) ; } } } catch ( ResourceNotFoundException $ e ) { $ routeUri = $ this -> router -> generate ( 'Framework_404' ) ; $ parameters = $ this -> router -> matchRequest ( $ request :: create ( $ routeUri ) ) ; } catch ( \ Exception $ e ) { throw $ e ; } $ parameters [ '_route_params' ] = $ parameters ; return $ parameters ; }
|
Perform the matching of a route and return a set of routing parameters if a valid one is found . Otherwise exceptions get thrown .
|
54,249
|
public function language ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateLanguage ( ) ; $ this -> validateWeight ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateBool ( 'default' ) ; $ this -> validateNameLanguage ( ) ; $ this -> validateNativeNameLanguage ( ) ; $ this -> validateCodeLanguage ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
|
Performs full language data validation
|
54,250
|
protected function validateLanguage ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> language -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Language' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
|
Validates a language to be updated
|
54,251
|
protected function validateCodeLanguage ( ) { $ field = 'code' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( preg_match ( '/^[A-Za-z\\-]+$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ language = $ this -> language -> get ( $ value ) ; if ( ! empty ( $ language ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
|
Validates a language code
|
54,252
|
protected function validateNameLanguage ( ) { $ field = 'name' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return true ; } if ( mb_strlen ( $ value ) > 50 ) { $ this -> setErrorLengthRange ( $ field , $ this -> translation -> text ( 'Name' ) , 0 , 50 ) ; return false ; } return true ; }
|
Validates a language name
|
54,253
|
public function exists ( array $ data ) { if ( empty ( $ data [ 'product_id' ] ) ) { return false ; } $ product_id = $ data [ 'product_id' ] ; unset ( $ data [ 'product_id' ] ) ; $ items = ( array ) $ this -> getList ( $ data ) ; foreach ( $ items as $ item ) { if ( $ item [ 'product_id' ] == $ product_id ) { return true ; } } return false ; }
|
Whether a product ID already exists in the wishlist
|
54,254
|
public function exceedsLimit ( $ user_id , $ store_id ) { if ( $ this -> user -> isSuperadmin ( $ user_id ) ) { return false ; } $ limit = $ this -> getLimit ( $ user_id ) ; if ( empty ( $ limit ) ) { return false ; } $ conditions = array ( 'user_id' => $ user_id , 'store_id' => $ store_id ) ; $ existing = $ this -> getList ( $ conditions ) ; return count ( $ existing ) > $ limit ; }
|
Whether the user exceeds the max allowed number of products in the wishlist
|
54,255
|
public function getLimit ( $ user_id ) { if ( is_numeric ( $ user_id ) ) { $ user = $ this -> user -> get ( $ user_id ) ; if ( isset ( $ user [ 'role_id' ] ) ) { return $ this -> getLimitByRole ( $ user [ 'role_id' ] ) ; } } return $ this -> getDefaultLimit ( ) ; }
|
Returns a max number of items for the user
|
54,256
|
public function responseAjax ( ) { if ( ! $ this -> isAjax ( ) ) { $ this -> response -> outputError403 ( ) ; } $ action = $ this -> getPosted ( 'action' ) ; if ( empty ( $ action ) ) { $ this -> outputJson ( array ( 'error' => $ this -> text ( 'Unknown action' ) ) ) ; } $ this -> outputJson ( call_user_func ( array ( $ this , $ action ) ) ) ; }
|
Page callback Entry point for all AJAX requests
|
54,257
|
public function getStoreCategoriesAjax ( ) { if ( ! $ this -> access ( 'category' ) ) { return array ( 'error' => $ this -> text ( 'No access' ) ) ; } $ options = array ( 'store_id' => $ this -> getPosted ( 'store_id' , $ this -> store -> getDefault ( ) ) ) ; return $ this -> getCategoryOptionsByStore ( $ this -> category , $ this -> category_group , $ options ) ; }
|
Returns an array of store categories
|
54,258
|
public function switchProductOptionsAjax ( ) { $ product_id = $ this -> getPosted ( 'product_id' ) ; $ field_value_ids = $ this -> getPosted ( 'values' , array ( ) , true , 'array' ) ; if ( empty ( $ product_id ) ) { return array ( ) ; } $ product = $ this -> product -> get ( $ product_id ) ; $ response = $ this -> sku -> selectCombination ( $ product , $ field_value_ids ) ; $ response += $ product ; $ this -> setItemPriceCalculated ( $ response , $ this -> product ) ; $ this -> setItemPriceFormatted ( $ response , $ this -> price , $ this -> current_currency ) ; return $ response ; }
|
Toggles product options
|
54,259
|
public function getCollectionItemAjax ( ) { $ term = $ this -> getPosted ( 'term' ) ; $ collection_id = $ this -> getPosted ( 'collection_id' ) ; if ( empty ( $ term ) || empty ( $ collection_id ) ) { return array ( 'error' => $ this -> text ( 'An error occurred' ) ) ; } $ collection = $ this -> collection -> get ( $ collection_id ) ; if ( empty ( $ collection ) ) { return array ( 'error' => $ this -> text ( 'An error occurred' ) ) ; } if ( ! $ this -> access ( $ collection [ 'type' ] ) ) { return array ( 'error' => $ this -> text ( 'No access' ) ) ; } $ conditions = array ( 'status' => 1 , 'title' => $ term , 'store_id' => $ collection [ 'store_id' ] , 'limit' => array ( 0 , $ this -> config ( 'autocomplete_limit' , 10 ) ) ) ; return $ this -> collection_item -> getListEntities ( $ collection [ 'type' ] , $ conditions ) ; }
|
Returns an array of suggested collection entities
|
54,260
|
public function searchCityAjax ( ) { $ country = $ this -> getPosted ( 'country' ) ; $ state_id = $ this -> getPosted ( 'state_id' ) ; if ( empty ( $ country ) || empty ( $ state_id ) ) { return array ( ) ; } $ conditions = array ( 'status' => 1 , 'state_status' => 1 , 'country_status' => 1 , 'country' => $ country , 'state_id' => $ state_id , ) ; return ( array ) $ this -> city -> getList ( $ conditions ) ; }
|
Returns an array of cities for the given country and state ID
|
54,261
|
final public function redirect ( $ url = '' , $ options = array ( ) , $ full = false , $ nolangcode = false ) { if ( ! isset ( $ url ) ) { return null ; } if ( ! empty ( $ url ) && ( $ full || $ this -> isAbsolute ( $ url ) ) ) { $ url = filter_var ( $ url , FILTER_SANITIZE_URL ) ; } else { $ target = $ this -> request -> get ( 'target' , '' , 'string' ) ; if ( ! empty ( $ target ) ) { $ url = ( string ) parse_url ( $ target , PHP_URL_PATH ) ; $ parsed = parse_url ( $ target , PHP_URL_QUERY ) ; $ options = is_array ( $ parsed ) ? $ parsed : array ( ) ; } $ url = $ this -> get ( $ url , $ options , false , $ nolangcode ) ; } header ( "Location: $url" ) ; exit ; }
|
Redirects the user to a new location
|
54,262
|
public function get ( $ path = '' , $ options = array ( ) , $ absolute = false , $ nolangcode = false ) { $ pass_absolute = false ; if ( ! empty ( $ path ) ) { if ( $ absolute && $ this -> isAbsolute ( $ path ) ) { $ url = $ path ; $ pass_absolute = true ; } else { $ url = $ this -> request -> base ( $ nolangcode ) . trim ( $ path , '/' ) ; } } else { $ url = $ this -> server -> requestUri ( ) ; } $ url = strtok ( $ url , '?' ) ; if ( $ absolute && ! $ pass_absolute ) { $ url = $ this -> server -> httpScheme ( ) . $ this -> server -> httpHost ( ) . $ url ; } $ url = empty ( $ options ) ? $ url : "$url?" . http_build_query ( $ options ) ; return filter_var ( $ url , FILTER_SANITIZE_URL ) ; }
|
Returns an internal or external URL
|
54,263
|
public function language ( $ code , $ path = '' , $ options = array ( ) ) { $ segments = $ this -> getSegments ( true , $ path ) ; $ langcode = $ this -> request -> getLangcode ( ) ; if ( isset ( $ segments [ 0 ] ) && $ segments [ 0 ] === $ langcode ) { unset ( $ segments [ 0 ] ) ; } array_unshift ( $ segments , $ code ) ; $ url = $ this -> request -> base ( true ) . trim ( implode ( '/' , $ segments ) , '/' ) ; $ url = empty ( $ options ) ? $ url : "$url?" . http_build_query ( $ options ) ; return filter_var ( $ url , FILTER_SANITIZE_URL ) ; }
|
Returns a URL with appended language code
|
54,264
|
public function getSegments ( $ append_langcode = false , $ path = '' ) { if ( empty ( $ path ) ) { $ path = $ this -> path ( $ append_langcode ) ; } return explode ( '/' , trim ( $ path , '/' ) ) ; }
|
Returns an array of path components
|
54,265
|
public function path ( $ append_langcode = false ) { $ urn = $ this -> server -> requestUri ( ) ; return substr ( strtok ( $ urn , '?' ) , strlen ( $ this -> request -> base ( $ append_langcode ) ) ) ; }
|
Returns an internal path without query
|
54,266
|
public function getAccountId ( ) { $ segments = $ this -> getSegments ( ) ; if ( reset ( $ segments ) === 'account' && isset ( $ segments [ 1 ] ) && ctype_digit ( $ segments [ 1 ] ) ) { return ( int ) $ segments [ 1 ] ; } return false ; }
|
Returns a user ID from the path
|
54,267
|
public function file ( $ path , $ absolute = false ) { return $ this -> get ( 'files/' . trim ( $ path , '/' ) , array ( ) , $ absolute , true ) ; }
|
Creates a file URL from a path
|
54,268
|
public function image ( $ path ) { if ( gplcart_path_is_absolute ( $ path ) ) { $ file = $ path ; $ url = gplcart_path_relative ( $ path ) ; } else { $ path = gplcart_path_normalize ( $ path ) ; $ prefix = gplcart_path_relative ( GC_DIR_FILE ) ; if ( strpos ( $ path , "$prefix/" ) === 0 ) { $ url = $ path ; $ file = gplcart_file_absolute ( $ path ) ; } else { $ url = "$prefix/$path" ; $ file = gplcart_path_absolute ( $ path ) ; } } $ query = is_file ( $ file ) ? array ( 'v' => filemtime ( $ file ) ) : array ( ) ; return $ this -> get ( $ url , $ query , false , true ) ; }
|
Returns a string containing an image path
|
54,269
|
public function collectionItem ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateCollectionItem ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateWeight ( ) ; $ this -> validateUrlCollectionItem ( ) ; $ this -> validateCollectionCollectionItem ( ) ; $ this -> validateEntityIdCollectionItem ( ) ; $ this -> validateEntityCollectionItem ( ) ; $ this -> validateData ( ) ; $ this -> unsetSubmitted ( 'update' ) ; $ this -> unsetSubmitted ( 'collection' ) ; return $ this -> getResult ( ) ; }
|
Performs full collection item entity validation
|
54,270
|
protected function validateCollectionItem ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> collection_item -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Collection item' ) ) ; return false ; } $ this -> setSubmitted ( 'update' , $ data ) ; return true ; }
|
Validates a collection item to be updated
|
54,271
|
protected function validateUrlCollectionItem ( ) { $ url = $ this -> getSubmitted ( 'data.url' ) ; if ( isset ( $ url ) && mb_strlen ( $ url ) > 255 ) { $ this -> setErrorLengthRange ( 'data.url' , $ this -> translation -> text ( 'URL' ) , 0 , 255 ) ; return false ; } return true ; }
|
Validates collection item URL
|
54,272
|
protected function validateCollectionCollectionItem ( ) { $ field = 'collection_id' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ collection_id = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ collection_id ) ) { return null ; } $ label = $ this -> translation -> text ( 'Collection' ) ; if ( empty ( $ collection_id ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( ! is_numeric ( $ collection_id ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } $ collection = $ this -> collection -> get ( $ collection_id ) ; if ( empty ( $ collection ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } $ this -> setSubmitted ( 'collection' , $ collection ) ; return true ; }
|
Validates the collection data
|
54,273
|
protected function validateEntityIdCollectionItem ( ) { $ field = 'entity_id' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { return null ; } $ title = $ this -> getSubmitted ( 'title' ) ; if ( is_numeric ( $ title ) ) { $ value = $ title ; } $ label = $ this -> translation -> text ( 'Entity' ) ; if ( empty ( $ value ) || ! is_numeric ( $ value ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ update = $ this -> getUpdating ( ) ; if ( isset ( $ update [ 'collection_item_id' ] ) && $ update [ $ field ] == $ value ) { return null ; } $ conditions = array ( 'type' => $ this -> getSubmitted ( 'collection.type' ) , 'collection_id' => $ this -> getSubmitted ( 'collection.collection_id' ) ) ; $ existing = $ this -> collection_item -> getItems ( $ conditions ) ; if ( isset ( $ existing [ $ value ] ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } $ this -> setSubmitted ( $ field , $ value ) ; return true ; }
|
Validates submitted collection item entity ID
|
54,274
|
protected function validateEntityCollectionItem ( ) { if ( $ this -> isError ( ) ) { return null ; } $ collection = $ this -> getSubmitted ( 'collection' ) ; $ collection_id = $ this -> getSubmitted ( 'collection_id' ) ; if ( empty ( $ collection ) ) { if ( ! isset ( $ collection_id ) ) { $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'collection_id' ] ) ) { $ collection_id = $ updating [ 'collection_id' ] ; } } $ collection = $ this -> collection -> get ( $ collection_id ) ; } if ( empty ( $ collection [ 'type' ] ) ) { $ this -> setErrorUnavailable ( 'collection_id' , $ this -> translation -> text ( 'Collection' ) ) ; return false ; } try { $ entity_id = $ this -> getSubmitted ( 'entity_id' ) ; $ handlers = $ this -> collection -> getHandlers ( ) ; $ result = static :: call ( $ handlers , $ collection [ 'type' ] , 'validate' , array ( $ entity_id ) ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } if ( $ result === true ) { return true ; } $ this -> setError ( 'entity_id' , implode ( '<br>' , ( array ) $ result ) ) ; return false ; }
|
Validates collection item entities
|
54,275
|
public function validatePageCollectionItem ( $ page_id ) { $ page = $ this -> page -> get ( $ page_id ) ; if ( empty ( $ page [ 'status' ] ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'Page' ) ) ) ; } return true ; }
|
Validates page collection item . Hook callback
|
54,276
|
public function validateProductCollectionItem ( $ product_id ) { $ product = $ this -> product -> get ( $ product_id ) ; if ( empty ( $ product [ 'status' ] ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'Product' ) ) ) ; } return true ; }
|
Validates product collection item . Hook callback
|
54,277
|
public function validateFileCollectionItem ( $ file_id ) { $ file = $ this -> file -> get ( $ file_id ) ; if ( empty ( $ file ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'File' ) ) ) ; } return true ; }
|
Validates file collection item . Hook callback
|
54,278
|
public function summary ( ) { $ options = array ( 'count' => true ) ; return array ( 'user_total' => $ this -> user -> getList ( $ options ) , 'order_total' => $ this -> order -> getList ( $ options ) , 'review_total' => $ this -> review -> getList ( $ options ) , 'product_total' => $ this -> product -> getList ( $ options ) ) ; }
|
Returns an array of summary items
|
54,279
|
public function order ( ) { $ options = array ( 'order' => 'desc' , 'sort' => 'created' , 'limit' => array ( 0 , $ this -> config -> get ( 'dashboard_limit' , 10 ) ) ) ; $ items = $ this -> order -> getList ( $ options ) ; array_walk ( $ items , function ( & $ item ) { $ this -> setItemTotalFormatted ( $ item , $ this -> price ) ; $ this -> setItemOrderNew ( $ item , $ this -> order_history ) ; } ) ; return $ items ; }
|
Returns an array of recent orders
|
54,280
|
public function transaction ( ) { $ options = array ( 'order' => 'desc' , 'sort' => 'created' , 'limit' => array ( 0 , $ this -> config -> get ( 'dashboard_limit' , 10 ) ) ) ; $ items = $ this -> transaction -> getList ( $ options ) ; array_walk ( $ items , function ( & $ item ) { $ this -> setItemTotalFormatted ( $ item , $ this -> price ) ; } ) ; return $ items ; }
|
Returns an array of recent transactions
|
54,281
|
public function priceRule ( ) { $ options = array ( 'status' => 1 , 'order' => 'desc' , 'sort' => 'created' , 'limit' => array ( 0 , $ this -> config -> get ( 'dashboard_limit' , 10 ) ) ) ; $ items = $ this -> pricerule -> getList ( $ options ) ; array_walk ( $ items , function ( & $ item ) { $ item [ 'value_formatted' ] = $ this -> price -> format ( $ item [ 'value' ] , $ item [ 'currency' ] ) ; } ) ; return $ items ; }
|
Returns an array of active price rules
|
54,282
|
public function event ( ) { $ options = array ( 'limit' => array ( 0 , $ this -> config -> get ( 'dashboard_limit' , 10 ) ) ) ; $ events = ( array ) $ this -> report -> getList ( $ options ) ; foreach ( $ events as & $ event ) { $ variables = empty ( $ event [ 'data' ] [ 'variables' ] ) ? array ( ) : ( array ) $ event [ 'data' ] [ 'variables' ] ; $ message = empty ( $ event [ 'translatable' ] ) ? $ event [ 'text' ] : $ this -> translation -> text ( $ event [ 'text' ] , $ variables ) ; $ event [ 'message' ] = strip_tags ( $ message ) ; } return $ events ; }
|
Returns an array of recent events
|
54,283
|
public function percent ( & $ amount , array & $ components , array $ price_rule ) { $ value = $ amount * ( $ price_rule [ 'value' ] / 100 ) ; $ components [ $ price_rule [ 'price_rule_id' ] ] = array ( 'rule' => $ price_rule , 'price' => $ value ) ; return $ amount += $ value ; }
|
Adds a percent price rule value to the original amount
|
54,284
|
public function fixed ( & $ amount , array & $ components , array $ price_rule , array $ data ) { $ value = $ this -> convertValue ( $ price_rule , $ data [ 'currency' ] ) ; $ components [ $ price_rule [ 'price_rule_id' ] ] = array ( 'rule' => $ price_rule , 'price' => $ value ) ; return $ amount += $ value ; }
|
Adds a fixed price rule value to the original amount
|
54,285
|
public function finalAmount ( & $ amount , array & $ components , array $ price_rule , array $ data ) { $ value = $ this -> convertValue ( $ price_rule , $ data [ 'currency' ] ) ; $ components [ $ price_rule [ 'price_rule_id' ] ] = array ( 'rule' => $ price_rule , 'price' => $ value ) ; return $ amount = $ value ; }
|
Sets a final amount using the price rule value
|
54,286
|
protected function convertValue ( array $ price_rule , $ currency ) { $ amount = $ this -> price -> amount ( abs ( $ price_rule [ 'value' ] ) , $ price_rule [ 'currency' ] ) ; $ converted = $ this -> currency -> convert ( $ amount , $ price_rule [ 'currency' ] , $ currency ) ; return $ price_rule [ 'value' ] < 0 ? - $ converted : $ converted ; }
|
Converts a price rule value to the minor units considering the currency
|
54,287
|
public function get ( $ library_id ) { $ libraries = $ this -> getList ( ) ; return empty ( $ libraries [ $ library_id ] ) ? array ( ) : $ libraries [ $ library_id ] ; }
|
Returns an array of a library
|
54,288
|
protected function prepareListItem ( array & $ libraries , $ library_id , array & $ library ) { if ( empty ( $ library [ 'type' ] ) ) { unset ( $ libraries [ $ library_id ] ) ; return null ; } $ types = $ this -> getTypes ( ) ; if ( empty ( $ types [ $ library [ 'type' ] ] ) ) { unset ( $ libraries [ $ library_id ] ) ; return null ; } $ library [ 'id' ] = $ library_id ; if ( ! isset ( $ library [ 'basepath' ] ) ) { if ( isset ( $ library [ 'vendor' ] ) ) { $ library [ 'vendor' ] = strtolower ( $ library [ 'vendor' ] ) ; $ library [ 'basepath' ] = GC_DIR_VENDOR . "/{$library['vendor']}" ; } else if ( isset ( $ types [ $ library [ 'type' ] ] [ 'basepath' ] ) ) { $ library [ 'basepath' ] = "{$types[$library['type']]['basepath']}/$library_id" ; } else { unset ( $ libraries [ $ library_id ] ) ; return null ; } } if ( $ library [ 'type' ] === 'php' && empty ( $ library [ 'files' ] ) && ! empty ( $ library [ 'vendor' ] ) ) { $ library [ 'files' ] = array ( GC_FILE_AUTOLOAD ) ; } if ( ! isset ( $ library [ 'version' ] ) ) { $ library [ 'errors' ] [ ] = array ( 'Unknown version' , array ( ) ) ; } if ( ! $ this -> validateFiles ( $ library ) ) { $ library [ 'errors' ] [ ] = array ( 'Missing files' , array ( ) ) ; } return null ; }
|
Prepare a library list item
|
54,289
|
protected function validateFiles ( array & $ library ) { if ( empty ( $ library [ 'files' ] ) ) { return true ; } $ readable = $ count = 0 ; foreach ( $ library [ 'files' ] as & $ file ) { $ count ++ ; if ( ! gplcart_path_is_absolute ( $ file ) ) { $ file = $ library [ 'basepath' ] . "/$file" ; } $ readable += ( int ) ( is_file ( $ file ) && is_readable ( $ file ) ) ; } return $ count == $ readable ; }
|
Validates library files
|
54,290
|
public function getFiles ( $ ids ) { settype ( $ ids , 'array' ) ; $ libraries = $ this -> getList ( ) ; $ sorted = $ this -> graph -> sort ( $ ids , $ libraries ) ; if ( empty ( $ sorted ) ) { return array ( ) ; } return $ this -> prepareFiles ( $ sorted , $ libraries ) ; }
|
Returns an array of sorted files for the given library IDs according to their dependencies
|
54,291
|
public function load ( $ ids ) { settype ( $ ids , 'array' ) ; $ types = $ this -> getTypes ( ) ; $ libraries = $ this -> getList ( ) ; foreach ( $ ids as $ key => $ id ) { if ( $ this -> isLoaded ( $ id ) ) { unset ( $ ids [ $ key ] ) ; continue ; } if ( empty ( $ libraries [ $ id ] [ 'type' ] ) ) { unset ( $ ids [ $ key ] ) ; continue ; } if ( empty ( $ types [ $ libraries [ $ id ] [ 'type' ] ] [ 'load' ] ) ) { unset ( $ ids [ $ key ] ) ; } } $ sorted = $ this -> graph -> sort ( $ ids , $ libraries ) ; if ( empty ( $ sorted ) ) { return false ; } foreach ( $ this -> prepareFiles ( $ sorted , $ libraries ) as $ file ) { require_once $ file ; } $ this -> loaded = array_merge ( $ this -> loaded , $ sorted ) ; return true ; }
|
Includes libraries files
|
54,292
|
protected function prepareFiles ( array $ ids , array $ libraries ) { $ prepared = array ( ) ; foreach ( $ ids as $ id ) { if ( ! empty ( $ libraries [ $ id ] [ 'files' ] ) ) { $ prepared = array_merge ( $ prepared , $ libraries [ $ id ] [ 'files' ] ) ; } } return $ prepared ; }
|
Prepares files of the given libraries
|
54,293
|
public function listCountryState ( $ code ) { $ this -> setCountry ( $ code ) ; $ this -> actionListCountryState ( ) ; $ this -> setTitleListCountryState ( ) ; $ this -> setBreadcrumbListCountryState ( ) ; $ this -> setFilterListCountryState ( ) ; $ this -> setPagerListCountryState ( ) ; $ this -> setData ( 'country' , $ this -> data_country ) ; $ this -> setData ( 'states' , $ this -> getListCountryState ( ) ) ; $ this -> outputListCountryState ( ) ; }
|
Displays the country state overview page
|
54,294
|
protected function setCountry ( $ code ) { $ this -> data_country = $ this -> country -> get ( $ code ) ; if ( empty ( $ this -> data_country ) ) { $ this -> outputHttpStatus ( 404 ) ; } }
|
Sets a country data
|
54,295
|
protected function setCountryState ( $ state_id ) { $ this -> data_state = array ( ) ; if ( is_numeric ( $ state_id ) ) { $ this -> data_state = $ this -> state -> get ( $ state_id ) ; if ( empty ( $ this -> data_state ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
|
Sets a country state data
|
54,296
|
protected function actionListCountryState ( ) { list ( $ selected , $ action , $ value ) = $ this -> getPostedAction ( ) ; $ deleted = $ updated = 0 ; foreach ( $ selected as $ id ) { if ( $ action === 'status' && $ this -> access ( 'state_edit' ) ) { $ updated += ( int ) $ this -> state -> update ( $ id , array ( 'status' => $ value ) ) ; } if ( $ action === 'delete' && $ this -> access ( 'state_delete' ) ) { $ deleted += ( int ) $ this -> state -> delete ( $ id ) ; } } if ( $ updated > 0 ) { $ text = $ this -> text ( 'Updated %num item(s)' , array ( '%num' => $ updated ) ) ; $ this -> setMessage ( $ text , 'success' ) ; } if ( $ deleted > 0 ) { $ text = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ text , 'success' ) ; } }
|
Applies an action to the selected country states
|
54,297
|
protected function getListCountryState ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ conditions [ 'country' ] = $ this -> data_country [ 'code' ] ; return ( array ) $ this -> state -> getList ( $ conditions ) ; }
|
Returns an array of country states for the country and filter conditions
|
54,298
|
protected function setBreadcrumbListCountryState ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/country' ) , 'text' => $ this -> text ( 'Countries' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the country state overview page
|
54,299
|
public function editCountryState ( $ country_code , $ state_id = null ) { $ this -> setCountryState ( $ state_id ) ; $ this -> setCountry ( $ country_code ) ; $ this -> setTitleEditCountryState ( ) ; $ this -> setBreadcrumbEditCountryState ( ) ; $ this -> setData ( 'state' , $ this -> data_state ) ; $ this -> setData ( 'country' , $ this -> data_country ) ; $ this -> setData ( 'zones' , $ this -> getZonesCountryState ( ) ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteCountryState ( ) ) ; $ this -> submitEditCountryState ( ) ; $ this -> outputEditCountryState ( ) ; }
|
Displays the edit country state page
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.