Skip to content

Latest commit

 

History

History
1919 lines (997 loc) · 49 KB

class.CategoryControllerCore.md

File metadata and controls

1919 lines (997 loc) · 49 KB

Class CategoryControllerCore

Contents

Properties

Methods

Properties

$cat_products

protected array $cat_products

$category

protected \Category $category

$customer_access

public boolean $customer_access = true

$nbProducts

protected integer $nbProducts

$php_self

public mixed $php_self = 'category'

string Internal controller name

$auth

public boolean $auth = false

$authRedirection

public boolean $authRedirection = false

Route of PrestaShop page to redirect to after forced login.

$cart

protected  $cart

$cookie

protected  $cookie

$currentCustomerGroups

protected array $currentCustomerGroups

$display_column_left

public boolean $display_column_left = true

$display_column_right

public boolean $display_column_right = true

$errors

public array $errors = array()

$guestAllowed

public boolean $guestAllowed = false

If set to true, user can be logged in as guest when checking if logged in.

$initialized

public boolean $initialized = false

True if controller has already been initialized.

Prevents initializing controller more than once.

$iso

public string $iso

$link

protected  $link

$maintenance

protected boolean $maintenance = false

$n

public integer $n

$nb_items_per_page

public integer $nb_items_per_page

$orderBy

public string $orderBy

$orderWay

public string $orderWay

$p

public integer $p

$restrictedCountry

protected boolean $restrictedCountry = false

$smarty

protected  $smarty

$ssl

public boolean $ssl = false

$ajax

public boolean $ajax = false

$content_only

protected boolean $content_only = false

$context

protected \Context $context

$controller_type

public string $controller_type

$css_files

public array $css_files = array()

$display_footer

protected string $display_footer

$display_header

protected boolean $display_header

$display_header_javascript

protected boolean $display_header_javascript

$js_files

public array $js_files = array()

$json

protected boolean $json = false

$php_errors

public array $php_errors = array()

$redirect_after

protected string $redirect_after = null

$status

protected string $status = ''

$template

protected string $template

Methods

__construct

mixed FrontControllerCore::__construct()

Controller constructor

addCSS

true|void FrontControllerCore::addCSS(array|string $css_uri, string $css_media_type, integer|null $offset, boolean $check_path)

Add one or several CSS for front, checking if css files are overridden in theme/css/modules/ directory

Arguments

  • $css_uri array|string - $media_uri Path to file, or an array of paths like: array(array(uri => media_type), ...)
  • $css_media_type string - CSS media type
  • $offset integer|null
  • $check_path boolean - If true, checks if files exists

addColorsToProductList

mixed FrontControllerCore::addColorsToProductList(array $products)

Renders and adds color list HTML for each product in a list

Arguments

  • $products array

addJS

true|void FrontControllerCore::addJS(array|string $js_uri, boolean $check_path)

Add one or several JS files for front, checking if js files are overridden in theme/js/modules/ directory

Arguments

  • $js_uri array|string - Path to file, or an array of paths
  • $check_path boolean - If true, checks if files exists

addJquery

mixed ControllerCore::addJquery(string|null $version, string|null $folder, boolean $minifier)

Adds jQuery library file to queued JS file list

Arguments

  • $version string|null - jQuery library version
  • $folder string|null - jQuery file folder
  • $minifier boolean - If set tot true, a minified version will be included.

addJqueryPlugin

mixed ControllerCore::addJqueryPlugin(string|array $name, $folder, boolean $css)

Adds jQuery plugin(s) to queued JS file list

Arguments

  • $name string|array
  • $folder mixed
  • $css boolean

addJqueryUI

mixed ControllerCore::addJqueryUI(string|array $component, string $theme, boolean $check_dependencies)

Adds jQuery UI component(s) to queued JS file list

Arguments

  • $component string|array
  • $theme string
  • $check_dependencies boolean

addMedia

true|void FrontControllerCore::addMedia(string|array $media_uri, string|null $css_media_type, integer|null $offset, boolean $remove, boolean $check_path)

Adds a media file(s) (CSS, JS) to page header

Arguments

  • $media_uri string|array - Path to file, or an array of paths like: array(array(uri => media_type), ...)
  • $css_media_type string|null - CSS media type
  • $offset integer|null
  • $remove boolean - If True, removes media files
  • $check_path boolean - If true, checks if files exists

ajaxDie

mixed ControllerCore::ajaxDie(string|null $value, string|null $controller, string|null $method)

Dies and echoes output value

Arguments

  • $value string|null
  • $controller string|null
  • $method string|null

assignProductList

mixed CategoryControllerCore::assignProductList()

Assigns product list template variables

assignScenes

mixed CategoryControllerCore::assignScenes()

Assigns scenes template variables

assignSubcategories

mixed CategoryControllerCore::assignSubcategories()

Assigns subcategory templates variables

canonicalRedirection

mixed CategoryControllerCore::canonicalRedirection(string $canonical_url)

Redirects to canonical or "Not Found" URL

Arguments

  • $canonical_url string

checkAccess

boolean FrontControllerCore::checkAccess()

Check if the controller is available for the current user/visitor

checkLiveEditAccess

boolean FrontControllerCore::checkLiveEditAccess()

Checks if the user can use Live Edit feature

display

boolean FrontControllerCore::display()

Compiles and outputs full page content

displayContent

mixed FrontControllerCore::displayContent()

Renders page content.

Used for retrocompatibility with PS 1.4

displayFooter

mixed FrontControllerCore::displayFooter($display)

Compiles and outputs page footer section

Arguments

  • $display mixed

displayHeader

mixed FrontControllerCore::displayHeader(boolean $display)

Compiles and outputs page header section (including HTML )

Arguments

  • $display boolean - If true, renders visual page header section

displayHeaderJavaScript

mixed ControllerCore::displayHeaderJavaScript(boolean $display)

Sets page header javascript display

Arguments

  • $display boolean

displayMaintenancePage

mixed FrontControllerCore::displayMaintenancePage()

Displays maintenance page if shop is closed.

displayRestrictedCountryPage

mixed FrontControllerCore::displayRestrictedCountryPage()

Displays 'country restricted' page if user's country is not allowed.

geolocationManagement

\Country|false FrontControllerCore::geolocationManagement(\Country $default_country)

Geolocation management

Arguments

getCategory

\Category CategoryControllerCore::getCategory()

Returns an instance of the current category

getColorsListCacheId

string FrontControllerCore::getColorsListCacheId(integer $id_product)

Returns cache ID for product color list

Arguments

  • $id_product integer

getController

\Controller ControllerCore::getController(string $class_name, boolean $auth, boolean $ssl)

returns a new instance of this controller

Arguments

  • $class_name string
  • $auth boolean
  • $ssl boolean

getCurrentCustomerGroups

array FrontControllerCore::getCurrentCustomerGroups()

Sets and returns customer groups that the current customer(visitor) belongs to.

getLayout

boolean|string FrontControllerCore::getLayout()

Returns the layout corresponding to the current page by using the override system Ex: On the url: http://localhost/index.php?id_product=1&controller=product, this method will check if the layout exists in the following files (in that order), and return the first found:

  • /themes/default/override/layout-product-1.tpl
  • /themes/default/override/layout-product.tpl
  • /themes/default/layout.tpl

getLiveEditFooter

string FrontControllerCore::getLiveEditFooter()

Renders Live Edit widget

getOverrideTemplate

string|boolean FrontControllerCore::getOverrideTemplate()

Returns an overridden template path (if any) for this controller.

If not overridden, will return false. This method can be easily overriden in a specific controller.

getOverrideThemeDir

string FrontControllerCore::getOverrideThemeDir()

Returns theme override directory (regular or mobile)

getTemplatePath

string FrontControllerCore::getTemplatePath(string $template)

Returns template path

Arguments

  • $template string

getThemeDir

string FrontControllerCore::getThemeDir()

Returns theme directory (regular or mobile)

init

mixed CategoryControllerCore::init()

Initializes controller

initContent

mixed CategoryControllerCore::initContent()

Initializes page content variables

initCursedPage

mixed FrontControllerCore::initCursedPage()

Renders and outputs maintenance page and ends controller process.

initFooter

mixed FrontControllerCore::initFooter()

Initializes page footer variables

initHeader

mixed FrontControllerCore::initHeader()

Initializes page header variables

initLogoAndFavicon

array FrontControllerCore::initLogoAndFavicon()

Returns logo and favicon variables, depending on active theme type (regular or mobile)

isCached

boolean ControllerCore::isCached(string $template, string|null $cache_id, string|null $compile_id)

Checks if a template is cached

Arguments

  • $template string
  • $cache_id string|null - Cache item ID
  • $compile_id string|null

isInWhitelistForGeolocation

boolean FrontControllerCore::isInWhitelistForGeolocation()

Checks if user's location is whitelisted.

isTokenValid

boolean FrontControllerCore::isTokenValid()

Checks if token is valid

isXmlHttpRequest

boolean ControllerCore::isXmlHttpRequest()

Checks if the controller has been called from XmlHttpRequest (AJAX)

myErrorHandler

boolean ControllerCore::myErrorHandler(string $errno, string $errstr, string $errfile, integer $errline)

Custom error handler

Arguments

  • $errno string
  • $errstr string
  • $errfile string
  • $errline integer

pagination

mixed FrontControllerCore::pagination(integer|null $total_products)

Assigns product list page pagination variables

Arguments

  • $total_products integer|null

postProcess

mixed FrontControllerCore::postProcess()

Method that is executed after init() and checkAccess().

Used to process user input.

process

mixed FrontControllerCore::process()

Called before compiling common page sections (header, footer, columns).

Good place to modify smarty variables.

productSort

mixed FrontControllerCore::productSort()

Assigns product list page sorting variables

recoverCart

integer|false FrontControllerCore::recoverCart()

Recovers cart information

redirect

mixed FrontControllerCore::redirect()

Redirects to redirect_after link

removeCSS

mixed FrontControllerCore::removeCSS(array|string $css_uri, string $css_media_type, boolean $check_path)

Removes CSS file(s) from page header

Arguments

  • $css_uri array|string - $media_uri Path to file, or an array of paths like: array(array(uri => media_type), ...)
  • $css_media_type string - CSS media type
  • $check_path boolean - If true, checks if files exists

removeJS

mixed FrontControllerCore::removeJS(array|string $js_uri, boolean $check_path)

Removes JS file(s) from page header

Arguments

  • $js_uri array|string - Path to file, or an array of paths
  • $check_path boolean - If true, checks if files exists

removeMedia

mixed FrontControllerCore::removeMedia(string|array $media_uri, string|null $css_media_type, boolean $check_path)

Removes media file(s) from page header

Arguments

  • $media_uri string|array - Path to file, or an array paths of like: array(array(uri => media_type), ...)
  • $css_media_type string|null - CSS media type
  • $check_path boolean - If true, checks if files exists

run

mixed ControllerCore::run()

Starts the controller process (this method should not be overridden!)

setMedia

mixed CategoryControllerCore::setMedia()

Sets default medias for this controller

setMobileMedia

mixed FrontControllerCore::setMobileMedia()

Specific medias for mobile device.

If autoload directory is present in the mobile theme, these files will not be loaded

setMobileTemplate

mixed FrontControllerCore::setMobileTemplate(string $template)

Checks if the template set is available for mobile themes, otherwise front template is chosen.

Arguments

  • $template string

setRedirectAfter

mixed ControllerCore::setRedirectAfter($url)

Set $this->redirect_after that will be used by redirect() after the process

Arguments

  • $url mixed

setTemplate

mixed FrontControllerCore::setTemplate(string $default_template)

Sets template file for page content output

Arguments

  • $default_template string

smartyOutputContent

mixed ControllerCore::smartyOutputContent(array|string $content)

Renders controller templates and generates page content

Arguments

  • $content array|string - Template file(s) to be rendered

sslRedirection

mixed FrontControllerCore::sslRedirection()

Redirects to correct protocol if settings and request methods don't match.

useMobileTheme

boolean FrontControllerCore::useMobileTheme()

Checks if mobile theme is active and in use.

viewAccess

boolean FrontControllerCore::viewAccess()

Check if the current user/visitor has valid view permissions