SilverCart\Dev\DateTools
Provides methods for date tasks in SilverCart.
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2017 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class DateTools
extends Tools
{
- // Inherited constants from Tools
- const SESSION_KEY_MESSAGE_ERROR = 'SilverCart.Message.Error';
- const SESSION_KEY_MESSAGE_INFO = 'SilverCart.Message.Info';
- const SESSION_KEY_MESSAGE_SUCCESS = 'SilverCart.Message.Success';
- const SESSION_KEY_MESSAGE_WARNING = 'SilverCart.Message.Warning';
- // Inherited members from Tools
- public static $baseURLSegment;
- public static bool $isInstallationCompleted;
- public static bool $isIsolatedEnvironment;
- public static bool $isBackendEnvironment;
- public static ArrayList $pageHierarchy;
- protected static array $pagesByIdentifierCode;
- public static $localeToRestore;
- public static boolean $disableUpdateCheck;
- protected static array $fieldLabels;
- // methods
- public static int addOffDaysToBusinessDays()
- public static int addOffDaysTo()
- public static int getTotalDaysForBusinessDays()
- public static int getBusinessDaysUntil()
- public static int getTotalDayCountFor()
- // Inherited methods from Tools
- public static void initSession()
- public static Session Session()
- public static Session saveSession()
- public static string getBaseURLSegment()
- public static DBHTMLText string2html()
- public static string string2urlSegment()
- public static void replace_special_chars()
- public static void replace_cyrillic_chars()
- public static void Log()
- public static string AttributedDataObject()
- public static SiteTree PageByIdentifierCode()
- public static string PageByIdentifierCodeLink()
- public static string singular_name_for()
- public static string plural_name_for()
- public static string booleanToString()
- public static array field_labels_for()
- public static array field_labels()
- public static string field_label()
- public static array enum_i18n_labels()
- public static array enum_field_labels_for()
- public static boolean isInstallationCompleted()
- public static boolean isIsolatedEnvironment()
- public static boolean is_cms_preview()
- public static string prepareEmailAddress()
- public static boolean isBackendEnvironment()
- public static array getFlatChildPageIDsForPage()
- public static array getPageHierarchy()
- public static string getSalutationText()
- public static array extractAddressDataFrom()
- public static boolean findPageIdInHierarchy()
- public static SiteTree getPageLevelByPageId()
- public static boolean pageIsSiblingOf()
- public static boolean checkForUpdate()
- public static void redirectPermanentlyTo()
- public static string getDateWithTimeNice()
- public static string getDateNice()
- public static array getMonthMap()
- public static array getSalutationMap()
- public static void switchLocale()
- public static string current_locale()
- public static void set_current_locale()
- public static ArrayList content_locales()
- public static Locale default_locale()
- public static DataObject get_translation()
- public static ArrayList get_translations()
- public static bool has_translation()
- public static string get_redirect_back_url()
- public static string get_table_name()
- public static string get_base_table_name()
- public static string get_module_name()
- public static string mb_str_pad()
Hierarchy
Extends
Constants
Name | Value |
---|---|
SESSION_KEY_MESSAGE_ERROR | 'SilverCart.Message.Error' |
SESSION_KEY_MESSAGE_INFO | 'SilverCart.Message.Info' |
SESSION_KEY_MESSAGE_SUCCESS | 'SilverCart.Message.Success' |
SESSION_KEY_MESSAGE_WARNING | 'SilverCart.Message.Warning' |
Members
protected
- $fieldLabels
—
array
List of already collected field labels. - $pagesByIdentifierCode
—
array
List of already called pages
public
- $baseURLSegment
—
string
The base url segment - $disableUpdateCheck
—
boolean
Set this to true to disable checking for updates. - $isBackendEnvironment
—
SilverCart\Dev\bool
Indicates whether the current request is in backend - $isInstallationCompleted
—
SilverCart\Dev\bool
Indicates whether the installation is completed or not - $isIsolatedEnvironment
—
SilverCart\Dev\bool
Indicates whether the current request is in an isolated environment like dev/build, dev/test, installation, ... - $localeToRestore
—
string
locale to restore. - $pageHierarchy
—
SilverStripe\ORM\ArrayList
Cache for the page hierarchy model.
Methods
public
- addOffDaysTo() — Adds the off days to the given amount of days.
- addOffDaysToBusinessDays() — Expects an amount of business days (including Saturdays or not) and adds the amount of missing Sundays and off days (by extensions) to be able to determine an expected date.
- getBusinessDaysUntil() — Returns the amount of business days until the given $date.
- getTotalDayCountFor() — Returns the total amount of days until the given amount of $businessDays is reached.
- getTotalDaysForBusinessDays() — Returns the total amount of days for the given amount of business $days.
Inherited from SilverCart\Dev\Tools
public
- AttributedDataObject() — Returns the attributed DataObjects as string (limited to 150 chars) by the given DataList.
- Log() — Writes a log entry
- PageByIdentifierCode() — returns a single page by IdentifierCode used to retrieve links dynamically
- PageByIdentifierCodeLink() — returns a page link by IdentifierCode
- Session() — Returns the current Session.
- booleanToString() — Returns the i18n version of 'Yes' or 'No' dependent of the given $boolean value.
- checkForUpdate() — Checks on silvercart.org whether there is an update available.
- content_locales() — Returns the available content locales.
- current_locale() — Returns the current locale.
- default_locale() — Returns the default locale.
- enum_field_labels_for() — Returns the field labels for the values of a enum field.
- enum_i18n_labels() — Returns the i18n labels for an enum field.
- extractAddressDataFrom() — Removes a prefix from a checkout address data array.
- field_label() — Get a human-readable label for a single field, see {@link field_labels()} for more details.
- field_labels() — Get a list of i18n field labels.
- field_labels_for() — Returns the default field labels for the given DataObject.
- findPageIdInHierarchy() — Tries to find the given page ID in the page hierarchy structure.
- getBaseURLSegment() — Returns the base URL segment that's used for inclusion of css and javascript files via Requirements.
- getDateNice() — Returns the given date in a nice format
- getDateWithTimeNice() — Returns the given date with time in a nice format
- getFlatChildPageIDsForPage() — Returns a flat array containing the IDs of all child pages of the given page.
- getMonthMap() — Returns a map of month number and name to use in a drop down.
- getPageHierarchy() — Builds a hierarchy from the current page to the top product group page or holder.
- getPageLevelByPageId() — Tries to find the given page ID in the page hierarchy structure and returns the corresponding page.
- getSalutationMap() — Returns a map of salutation system text and i18n name to use in a drop down.
- getSalutationText() — Returns the localized salutation string.
- get_base_table_name() — Returns the base DB table name for the given class.
- get_module_name() — Returns the module name of the given working directory context.
- get_redirect_back_url() — Returns the redirect back url.
- get_table_name() — Returns the DB table name for the given class.
- get_translation() — Returns the translation with the given locale.
- get_translations() — Returns all translations of the given record.
- has_translation() — Returns whether the translation with the given locale exists for the given record.
- initSession() — Initializes silvercart specific session data.
- isBackendEnvironment() — Checks whether the current url location is in backend
- isInstallationCompleted() — Checks if the installation is complete. We assume a complete installation if the Member table has the field "ShoppingCartID" that is decorated via "Customer".
- isIsolatedEnvironment() — Checks whether the current request is a special, isolated environment
- is_cms_preview() — Checks whether the current request is a CMS preview
- mb_str_pad() — Multibyte alternative for the default PHP function str_pad.
- pageIsSiblingOf() — Checks if the given page IDs are siblings of the same level.
- plural_name_for() — Returns the translated plural name of the object. If no translation exists the class name will be returned.
- prepareEmailAddress() — Prepares a given email address to use for request handling.
- redirectPermanentlyTo() — Redirects to the given URL with status "303 See other".
- replace_cyrillic_chars() — Replaces cyrillic chars with latin chars
- replace_special_chars() — Replaces special chars.
- saveSession() — Returns the current Session.
- set_current_locale() — Sets the current locale.
- singular_name_for() — Returns the translated singular name of the given object. If no translation exists the class name will be returned.
- string2html() — Takes the given string and puts it into a DBHTMLText object to render properly in a template.
- string2urlSegment() — Remove chars from the given string that are not appropriate for an url
- switchLocale() — Switchs the locale from default to the current SS locale and back.