owner
stringclasses
603 values
repo
stringclasses
778 values
repo_dir
stringclasses
830 values
file_rel_repo
stringlengths
6
222
file_rel_outdir
stringlengths
16
235
size
int64
0
2.36M
mtime
int64
1.76B
1.76B
lang
stringclasses
10 values
content
stringlengths
0
2.36M
updated_at
stringdate
2025-09-24 14:46:58
2025-09-24 14:46:58
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/2.1.0.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/2.1.0.md
6,929
1,758,118,090
en
# 2.1.0 (2007-10-02) SilverStripe 2.1.0 was released on '''2 October 2007''' and had the following changes: ## Overview * Comment administration section, and comment moderation * Allow CMS users to limit view/edit access to a page * Show an rss link for page comments on each page ## Upgrading ### Too many redirects A problem occurs of 'too many redirects' or the page just doesn't load (home page) because of these situations: * Access tab for home page has 'logged in users only', OR * NO radio buttons have been set. This happens when upgrading site from old DB. It's caused by a redirect to Security/login on the home page controller, which is blocked off, so you can't actually login, so it infinitely loops a redirect. See http://open.silverstripe.com/ticket/1488 ## Features and Enhancements * Theme support * Widget support * Better extension API * Unit testing framework * More API documentation * Added support for __ss_environment.php files * New classes * BankAccountField * BBCodeParser * HasManyComplexTableField * HasOneComplexTableField * ManyManyComplexTableField * NewsletterType * RestfulService (from mashups module) * Improved classes * ComplexTableField * Validation in popup * ContentController * Added project() * Controller * Added redirectedTo() * Convert * Added raw2htmlatt() * Added raw2mailto() * DatabaseAdmin * Drastically improved database build performance * DataObject * Added ID,ID,ID syntax for populating many-many joins * DataObjectDecorator * Allow member CMS fields to be added * DataObjectSet * Added getRange() * Date * Added past_date() * Director * Added set_dev_servers() * Added set_test_servers() * Added redirected_to() * Refactored CMS page-URL accessing to use ->AbsoluteLink(), which can be overridden by defining alternateAbsoluteLink() * Debug * Optionally hide backtrace-headers in message() and show() (applied in 'showqueries') * Email * MimeType-fallback (from /etc/mime.types) * Improved validation in is_valid_address() * FieldSet * Added insertAfter() * Form * Automatic filesystem backup of POST-data * FormField * Support for right-aligned titles * Custom CSS-classes by addExtraClass() and removeExtraClass() * Group * Added Description field * HtmlEditorField * Allow classes other than 'typography' to be set * Image * Added PaddedImage() * ImageField * Added readonly transformation * PageCommentInterface * Added anchors to page comments, and made rss feed link to them * Permission * Added $strict flag to check() * Allow passing of an array of permission codes to get_members_by_permission() * Added get_groups_by_permission() * PhoneNumberField * Improved validation * Security * Added basicauthlogin() * SecurityAdmin * Added EDIT_PERMISSIONS permission code * TableField * Validation and RequiredFields * TableListField * Added sorting, highlighting, formatting * Improved styling * TreeDropdownField * Improved styling * Varchar * Added RTF() * ViewableData * Added `<% if HasPerm(PERM_CODE() %>` for templates * Javascript * Implemented showIndicator() and hideIndicator() * Improved statusMessage() to clear manually instead of fixed interval * Added hideStatusMessage() #### Bug Fixes * CMS * Fix specific newsletter bug * Don't show classes user doesn't have permissions to change to in class dropdown * Fix reading of Live pages in CMSMain * Fix double page reading after changing the class * Fix insert flash * Fix version regex for release candidates * Fix delete in Files and Images section * Fixed saving root folder causes error * Fixed "non-numeric ID" error that occurs when visiting newsletter section for a newsletter that doesn't exist (caused by session sometimes) * Fixed CMS sort subpages bug * Sapphire * Improved spam detection * Support for running SilverStripe in safe mode and under open_basedir restrictions * PHP notice fixes * Use normal authentification rather than basicauth for db/build * Fix CSS of profiler pop-up * Changed DropdownField $emptyString syntax from '0' to '' * Fixed IE6 DOM-parsing bug caused by FormResponse::load_form() * Triggering previewwrite for 'delete' and 'replace' SQL-actions * Changed record-insertion in DataObject * Boolean accepts database-default * Fixed Permission::get_members_by_permission() * Added memory_limit to publishall() * Fix many-many component set relation setting * The Link for a RedirectorPage points to its target * Add SQL_ prefix in place it was missing in Email * Added a check to make sure record exists before calling hasMethod on it in CheckboxSetField * Fixed bug in DataObject::addStaticVars() * Check for string 'true' as well as boolean in SiteTree::MetaTags() * Fix AllNewsletters value not being passed to OptionSetField in SubscribeForm * Improved the encapsulation of ErrorPage publication * Fix redirect back after failing login * Fixed renaming of .tar.gz and .tar.bz2 files * Fixed validation of DateField, EmailField and NumericField * Fix livesite bug for visibility handling difference between PHP5.2.0 and PHP5.1.6 * Changed colouring of db/build to be more appropriate for the actual meaning of the messages * Fixed redirection from /home/ to /./ in IE6 * Use the homepage as a model for the security base-page, so that things like the current subsite are factored in * Sorted permission codes in Permission::get_codes * Changes to support gallery module * Added missing has_many in DataObjectDecorator * Replace empty strings in SQL queries with NULL * JSParty * TinyMCE has been updated to 2.1.1.1 Installer * New installer look based on BlackCandy * Use the new theme system * Add first and last name fields * Added ability to set servers that will be in dev mode * When the posix module isn't present, throw a warning instead of dying * Warn if PHP version is less that 5.2.0 in support of GoPHP5 (http://www.gophp5.org) * Added favicon to installer and default template * Optional reporting of version information to SilverStripe * Installer now runs with short tags disabled * open_basedir and safe mode fixes
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/2.3.1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/2.3.1.md
5,116
1,758,118,090
en
# 2.3.1 (2009-03-19) ## New Features * ![rev:72804] #3659 - Update key to show what purple means (ezero) * ![rev:72791] #3614 - Allow spell checking in HTMLEditorField when used outside of the CMS * ![rev:72788] #3612 - Option to auto-login with basic auth (jshipman) * ![rev:72771] added ability to disable AJAX commenting * ![rev:72763] #3610 - Require ADMIN permissions for ?flush=all * ![rev:72517] Allow access to the live site via RESTful api * ![rev:73435] more robust conditional check before we go to foreach loop, more robust conditional checking before we call a FormField function where we are not sure the caller is a FormField object. * ![rev:73285] Added Director::is_relative_url() and Director::is_site_url() * ![rev:73149] Allow calling methods on DataObjects using RESTful API. Methods which can be called must be specified in the $allowed_actions array of the DataObject. * ![rev:72574] Made JS i18n optional; disable it by calling Requirements::set_js_i18n(false) * ![rev:72497] Database will fix itself if you view the site and the database doesn't exist * ![rev:72496] Added BASE_SCRIPT_URL that lets you run a site without rewriting rules * ![rev:72346] Added onBeforeSecurityLogin event handler to Security/login, for extensions to plug into * ![rev:72229] Fixed invalid RSSFeed format - added `<atom:link>` and `<dc:creator>` elements, removed `<author>` element (invalid unless it contains an email address) * ![rev:72119] #3232 lenix: Added Date::FormatI18N() ## Bugfixes * ![rev:73437] Fixed possible SQL injection in file name part for File::find() * ![rev:73318] Added missing action 'DeleteImageForm' to Image::$allowed_actions * ![rev:73304] Added missing action 'EditImageForm' to Image::$allowed_actions * ![rev:73301] Fixed too strict permission checking on Image::$allowed_actions. Replaced broken * permission check with explicit method names * ![rev:73299] Fixed array to string conversion caused by patch commited in r73285 * ![rev:73291] Using $allowed_actions in Image_Uploader (Merged from r73255) * ![rev:73290] Validating $_FILES in Upload->validate() (Merged from r73254) * ![rev:73289] Existence check for Member autologin token (Merged from r73253) * ![rev:73288] Checking for Director::is_site_url() before redirecting in Controller->redirectBack() and MemberLoginForm (Merged from r73252) * ![rev:73286] Added isDev() and Permission::check() directives to DatabaseAdmin and DevelopmentAdmin (Merged from r73251) * ![rev:73285] Validating $_FILES array in Director::direct() * ![rev:73284] Using $allowed_actions in ImageEditor (Merged from r73248) * ![rev:73261] Interpret 401s and 403s created init() methods as 'finished' requests * ![rev:73117] Fixed ajax-response for multiple-item deletion * ![rev:73099] Fix notice-level error in rewriteless operation of homepage when db needs to be created * ![rev:73084] #3715: Show the changes message in a popup instead of a blank confirm box * ![rev:73082] #3716: Added error trapping to WYSIWYG side forms * ![rev:73080] #3714: Added default value to modeladmin search button * ![rev:73016] redirect user down to their posted comment if it was not posted via AJAX * ![rev:72926] #3591: Make Controller::isAjax() more reliable * ![rev:72854] #3529 - SilverStripeNavigator causes strict XHTML pages to fail in Firefox (michaek) * ![rev:72852] #3596 - Creating more than one new folder causes infinite loop (hamish) * ![rev:72819] Only use target="_blank" for files by default * ![rev:72816] #3645 - CommenterURL missing from CMS * ![rev:72798] #1450 - Passwords should be obscured when adding a member in a MemberTableField * ![rev:72760] Make sure "Template to install" retains its value when rechecking requirements * ![rev:72694] #3590: Allow subclassing of Folder * ![rev:72693] #3590: Allow subclassing of Folder * ![rev:72564] Include i18n where necessary. 2nd part of r72563 * ![rev:72563] Updated i18n javascript system so that the i18n javascript needs to be explicitly included, so that it doesn't poke its nose in where it's not wanted. * ![rev:72557] #3418: Remove jQuery coupling from Email field focus, and only include email focus when validation is enabled * ![rev:72457] #3644 - _ss_environment.php search creates open_basedir error (ed) * ![rev:72341] Ensure that $this->class is set on ArrayData objects * ![rev:72338] Allow SilverStripe to work when asp_tags is on * ![rev:72252] Memory usage improvements to CsvBulkLoader and Member::onBeforeWrite() * ![rev:72201] fixed syntax fail in silverstripe navigator * ![rev:72200] Prevent infinite redirection when the homepage isn't available, when using modules such as subsites. * ![rev:72190] escaped filename before querying with it - #ajoneil * ![rev:73283] Using auto-escaped get_by_id() in CommentAdmin and SecurityAdmin (Merged from r73247) * ![rev:73395] Disallow access of cli-script.php through a browser * ![rev:72602] restored image panel showing 3 across (#3670) * ![rev:72254] Fix tabs not being correct size when first loaded ## Other * ![rev:73285] (Merged from r73250)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/beta/2.4.0-beta1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/beta/2.4.0-beta1.md
69,136
1,758,118,090
en
# 2.4.0-beta1 (2010-01-29) ## Changelog ### Overview * Support for SQLite and PostgreSQL databases (via separate module) * Partial caching in templates, to allow for faster load times of certain aspects in dynamic pages. * Upload controls in the CMS no longer require the Adobe Flash plugin, and work again on Mac OSX. * File and page dropdown selections support inline searching, to make handling larger tree structures easier. * Fixed password hashing design flaw, which makes SilverStripe databases more portable between different server architectures. * Improved reporting API to unify the CMS sidebar reports and full-page reports on their own section. Its easier to add custom filters to reports. * Batch action handling handles larger tree structures, provides better visual feedback, and respects permissions on individual pages. * Global site configuration is translatable, meaning titles for your website can be in different languages without any switching in your templates. * Allow selection of themes through the site configuration interface (in addition to changing the theme via configuration code) * More fine-grained translation permissions: A group can be limited to only edit a certain language in the CMS. * Added dropdown to choose from existing anchor links when inserting a link from the CMS sidebar. * Team members can get permissions to see the draft version of a page in preview mode without requiring CMS access. * Pages of type "Virtual Page" have improved stability in regards to their permission control, translation and publication. * Improved broken link detection (''talk to Andy for more info'') * Removed the jsparty/ toplevel folder, and moved all its dependencies into sapphire/thirdparty and cms/thirdparty * More than 350 bugfix and enhancement commits, and 200 minor changes. ### Features and Enhancements * [rev:98268] Moved the log-in validation process from individual authenticators into Member->checkPassword() and canLogIn(), to allow more extensibility and control (trunk, 2.4). * [rev:98219] roll batch permissions in to a generic function (from r97748) * [rev:98211] batchactions can now implement confirmationDialog() to provide a custom confirmation dialog to the front end. * [rev:98180] Allow for custom generation of SSReport::ID() for parameterised reports. * [rev:98179] Removed broken links reports from sidebar (in anticipation of adding them to the main reporting area) (from r95954) * [rev:98173] Improved look and feel for report filtering * [rev:98165] Performance improvement to CMS load time with many pages. (from r95490) * [rev:98159] added canAddTopLevel permission to SiteConfig to determine which users/groups can add pages to the root of the sitetree. (from r87279) * [rev:98156] audit trails * [rev:98156] ability to parameterize SSReport's (from r85903) * [rev:98132] Allow sort descending as well as ascending. (from r96054) * [rev:98110] Allow user theme selection through SiteConfig, falling back to SSViewer::set_theme() as a default if there are none selected * [rev:98104] Improved TableListField header styling. (from r96028) * [rev:98102] Add a function to give link to Live site (from r95948) * [rev:98091] ManifestBuilder::get_manifest_info() now uses ManifestBuilder::get_themes() instead of doing it's own retrieval of available themes * [rev:98080] Removed dev/reset, instead encouraging the use of dev/tests/startsession for tests. * [rev:98080] Let people use dev/tests/startsession without a fixture, instead calling requireDefaultRecords * [rev:98041] added support for MySQL data type SET used in MultiEnum FEATURE: added datetime helper functions * [rev:98025] add 'view site tree as' functionality. * [rev:97896] 2.4 tickets (#4670) new permission code to view draft w/o CMS access * [rev:97895] 2.4 tickets (#4670), new permission code to view draft stage w/o CMS access * [rev:97819] Allow ungrouped retrieval of Permission::get_codes() through new $grouped switch * [rev:97793] removed the situation, when the user is left with empty search box and empty dropdown. * [rev:97792] use Validator::get_javascript_validator_handler() to check if the handler is turned on before doing either js or php validation * [rev:97765] Select the uploaded image after uploading by default. #4962 * [rev:97745] adapt the page dropdown based off the allowedChildren values * [rev:97606] Added hover states to "Available widgets" boxes in the CMS for usability * [rev:97602] Added visual elements to aid in the usability of the WidgetAreaEditor * [rev:97601] CMS Editor Upload panel now loads the root files directly and allows the user to upload to the root assets dir * [rev:97597] Changed menu title from "Site Content" to "Pages" to be consistent with other menu labels * [rev:97597] Changed tree root node in CMS to get title from SiteConfig rather than defaulting to "Site Content" * [rev:97597] Changed tree panel headline in CMS from "Site Content and Structure" to "Page Tree" to stay consistent with new CMS menu title * [rev:97583] Don't set up the test db if database tests aren't being run. From: Sam Minnee * [rev:97530] Adjusted "Available Widgets" column to be narrower than "Widgets currently used", allowing more space for configuring widgets * [rev:97478] Member->requireDefaultRecords() no longer creates a default administrator based on $_REQUEST data. Moved functionality into Installer->install() * [rev:97436] Updated Member->getMemberFormFields() to use scaffolding and to be in line with Member->getCMSFields(). From: Andrew Short (from r97401) * [rev:97391] Add partial caching support to SSViewer. * [rev:97390] Add aggregate calculation to DataObject, allowing (cached) calculation of Max, Min, Count, Avg, etc * [rev:97389] Add cache factory that provides nice API over top of Zend_Cache * [rev:97370] Allowing translation of SiteConfig (including toplevel permission groups) * [rev:97207] Added ContentController->ContentLocale() to allow XHTML/HTML specific lang= attribute settings in custom template code (see #4858). Removed `<meta http-equiv="Content-Language"...>` tag in SiteTree->MetaTags(). * [rev:97207] Updated blackcandy theme to use new $ContentLocale attribute to set the locale of the current page (in Page.ss) * [rev:97192] Added RestfulService::set_default_proxy() and RestfulService->setProxy() (#4637, thanks hamish) * [rev:97031] upgrading the search functionality of the TreeDropdownTree with pluggable search function * [rev:97028] include menu title in default search. PATCH via lubzee #4508 * [rev:97024] added Session::clearAll() functionality. ENHANCEMENT: Added Unit Tests covering Session API. MINOR: Tided up formatting in session class and included doc comments for API level documentation * [rev:97018] Use tidied HTML in DataDifferencer * [rev:97017] Try to tidy HTML using external libraries if available * [rev:97011] Added TabIndex to FormActions. Ticket: #4905. PATCH: via keeny * [rev:96821] Added applicable pages checks to delete from live, delete from draft, and publish (from r94775) * [rev:96820] Added 'greyed out' status of batch action checkboxes while applicable pages are being loaded via ajax. (from r94774) * [rev:96819] Update the checkboxes available to batch-actions to show only the applicable pages for that particular action. * [rev:96800] Let LeftAndMain subclass canView() methods optionally redirect. (from r90018) * [rev:96793] Renamed Author column to User in the page version history to better reflect that they might not have been authors, and just iniators of workflow actions. (from r89015) * [rev:96792] Added new onRenameLinkAsset() handler to static publishing for better link rewriting. (from r89014) * [rev:96778] Files and images section warns if you are deleting a file that is linked to * [rev:96752] Recognise HTTP_X_FORWARDED_HOST header and use that in place of HTTP_HOST (from r93148) * [rev:96668] Change to TreeDropdownField, giving it filtering behaviour as described in ticket http://open.silverstripe.org/ticket/3007 . Its disabled by default for legacy compatibility, but enabled for HtmlEditorField so that link editor is filterable for local links, via an extra boolean parameter on TreeDowndownField. * [rev:96440] Add onLoad callback handler CMSLoadFunctions * [rev:96049] Added Date::Rfc3339() for returning an RFC 3339 valid date format (from r96010) * [rev:95418] added delete all link to page comments. Patch via #4427. Thanks walec51 * [rev:95194] added translatable support to mathspamprotection. PATCH via noini (#4755) * [rev:94887] added several tests for PermissionCheckboxSetField, PermissionRole and Group * [rev:94515] Improved layout of altercation message when called via CLI. Patch via simon_w #4373 * [rev:94423] Allow passing in an Exception object to SS_Log::log() in addition to an array describing the error context (line number, file, trace etc) * [rev:94381] Added FunctionalTest::findAttribute() as a helper for getting an attribute from a SimpleXMLElement object by it's name * [rev:94297] Added DataObjectSet::emptyItems() to remove all the items from the set - this is useful for when you are augmenting CMS and front end fields via updateCMSFields() and updateFrontEndFields() on a DataObjectDecorator * [rev:94063] Added MultipleOf and Modulus methods to ViewableData - useful for templating work * [rev:94062] Loading of tinymce_ssbuttons plugin via relative paths in HtmlEditorConfig rather than using the plugin name as a path spec (see r94060) * [rev:94060] Added support for loading external plugins (with relative paths) in HtmlEditorConfig. This means relative paths can be separate from the plugin name, and fixes a bug where paths containing dashes were ignored by TinyMCE.init(). * [rev:94060] Changed sapphire/thirdparty/tinymce-advcode to use the original plugin name, and specify its relative path through HtmlEditorConfig instead. * [rev:93771] Added parameter to DBLocale->Nice() * [rev:93771] Added DBLocale->getNativeName() * [rev:92879] Allowing to hide certain permission from showing in SecurityAdmin? through add_hidden_permission() (refactored from r92428) (from r92866) * [rev:91576] Pluggable password encryption through PasswordEncryptor class (#3665) (merged from r90949) * [rev:91496] added ability to upload images from site content pane. Merged via r9130, r91347, r91350, r91480 ### API Changes * [rev:98373] HTTP::setGetVar() always returns absolute URLs. Use Director::makeRelative() to make them relative again. * [rev:98373] HTTP::setGetVar() combines any GET parameters in PHP array notation (e.g. "foo[bar]=val") instead of replacing the whole array * [rev:98224] Refactor Versioned so a single state is kept for stage, archived date, or any module specific reading modes (from r98161) * [rev:98215] Introduced new API for SS_Report * [rev:98191] Added SideReportWrapper to help you tailor report columns for the side reports. * [rev:98191] Allow use of 'casting' option on side report columns. * [rev:98191] Make 'title' optional on side report columns. (from r96272) * [rev:98176] Removed SideReport class, use SSReport as the base-class for them instead. * [rev:98176] Use SSReport::register(SideReport) to explicitly register reports on the LHS of the content view. * [rev:98175] Added explicit registration of reports with SSReport::register() (from r95857) * [rev:98159] Security::permissionFailure(); will no longer tell the client side JS to show the login box if the user is already logged in * [rev:98101] Allow passing of an explicit map of dropdown items to a TreeDropdownField. * [rev:98096] Refactored test for whether a SQLQuery can be sorted by a particular column into SQLQuery::canSortBy($fieldName) (from r95850) * [rev:98056] Decimal now allows setting a default value properly * [rev:97996] rename the class "Cache" to "SS_Cache" (ref ticket: #4997) * [rev:97827] Added cancelSchemaUpdate() and doesSchemaNeedUpdating() to the Database class * [rev:97819] Removed $blankItemText parameter from Permission::get_codes() * [rev:97818] Removed Member::init_db_fields(), its no longer needed due to the Member.PasswordEncyrption property changing from an ENUM to Varchar. * [rev:97797] Fixed i18n _t() calls without namespaces in template includes: They now default to setting the include filename as namespace, rather than the including template (#4915, #3400 - thanks Henk_Poley, jwalsoe, walec51) * [rev:97731] Determine default BASE_PATH/BASE_URL from the __FILE__ content, so that the script that initiated the Sapphire process doesn't matter. This means that index.php doesn't need to manipulate those variables. * [rev:97582] #4929: Add $class argument to DataObjectDecorator::extraStatics() * [rev:97489] removed SWFUpload. Refactored Content Editors uploader to use standard uploader. * [rev:97478] Security::setDefaultAdmin() no longer writes credentials to any Member database records (created through Security::findAnAdministrator(). This prevents outdated credentials when setDefaultAdmin() code changes after creating the database record (see #4271) * [rev:97478] Security::findAnAdministrator() no longer sets 'Email' and 'Password' properties on newly created members. Removed the $username and $password argments from the method. * [rev:97475] Moved GSTNumberField from sapphire/forms to new 'formfields_nz' module * [rev:97474] Moved BankAccountField from sapphire/forms to new 'formfields_nz' module * [rev:97270] Unique_identifier now accepted as the login requirement, allowing alternatives to 'Email' * [rev:97207] Deprecated ContentController->LangAttributes(). Use ContentLocale() instead and write attribute names suitable to XHTML/HTML templates directly in the template. * [rev:96988] #3600 Inconsistency in File::getURL() which returns an absolute URL, when it should be relative - please use getAbsoluteURL() instead for old behaviour * [rev:96988] #3600 Image no longer has an explicit getURL() method, instead it inherits getURL() from File which returns a relative URL * [rev:96824] Added capability for batch actions to indicate failure through red checkboxes (from r94868) * [rev:96823] Added canView() to CMSBatchAction so that you could hide certain batch actions from some users. (from r94846) * [rev:96821] Added applicablePagesHelper to CMSBatchAction to ease the process of creating new applicable page methods. * [rev:96819] Allow for an applicablePages($idArray) method to be defined on a CMSBatchAction class. (from r94761) * [rev:96810] Added FilesystemPublisher::getExistingStaticCacheFiles(), to help build caching logic methods. (from r91354) * [rev:96809] Added numChildrenMethod argument to LeftAndMain::getSiteTreeFor() * [rev:96756] Added canDeleteFromLive permission to SiteTree, separate from canPublish (from r93315) * [rev:96751] Define VirtualPage::isPublishable() so that people know not to even request publication if it's not allowed. (from r93098) * [rev:96749] Added DataObjectDecorator::cacheKeyComponent() to ensure that the cached behind DataObject::get_one() is appropriately specific (from r93095) * [rev:96739] Added Hierarchy::numHistoricalChildren() and Versioned::get_including_deleted_query() * [rev:96739] Added numChildrenMethod arg to getChildrenAsUL, markPartialTree, markChildren, markingFinished * [rev:96734] Don't generate TestOnly DataObjects in the database immediately; instead let test developers specify them in SapphireTest::$extraDataObjects. * [rev:96734] Added SapphireTest::resetDBSchema() (from r90054) * [rev:96727] Renamed SapphireTest::set_up_once/tear_down_once to setUpOnce/tearDownOnce, and made them instance methods. * [rev:96727] Added SapphireTest::$illegalExtensions and SapphireTest::$requiredExtensions for making tests depending on particular extension sets (from r89958) * [rev:96725] Moved popupdatetimefields to pop up below the text field instead of next to the icon. (from r89914) * [rev:94430] Group::addByGroupName() now creates the group if one does not already exist (from r83010) * [rev:94178] Renamed ViewableData->SecurityID() to getSecurityID() in order to get its value loading through Form->loadDataFrom() * [rev:94062] Changed cms/javascript/tinymce_ssbuttons plugin name to "ssbuttons" (see r94060) * [rev:94062] Changed cms/javascript/tinymce_ssmacron plugin name to "ssmacron" (see r94060) * [rev:93785] removed Director::Link(). Use Controller::join_links() instead * [rev:93693] removed deprecated RestrictedText fields * [rev:93687] removed deprecated LeftAndMain::add_menu_item. Use CMSMenu::add_menu_item() * [rev:93685] removed deprecated extend calls (r93632). API CHANGE: removed fieldExists(). Use hasField() (r93633). API CHANGE removed listOfFields() (r93647). API CHANGE: removed Tag() and URL() from Image. Use getTag() and getURL(). BUGFIX: updated Image.php to use getTag() (r93639, r93646). API CHANGE: removed val(). Use XML_val() (r93650). API CHANGE: removed $add_action. Use singlar_name or lang tables (r93658). API CHANGE: removed ConfirmedFormAction (r93674). API CHANGE: removed ajax_render on CTF (r93679). * [rev:93660] Removed ComponentSet::removeByFilter() since it's not flexible enough and fixed calls to this from HtmlEditorField::saveInto() to use custom code instead * [rev:93640] Removed deprecated static function ContentNegotiator::disable() - it's disabled by default * [rev:92878] Refactored hiding of Permissions added in r92428. Added PermissionCheckboxSetField?->setHiddenPermissions() (from r92865) * [rev:92428] add the ability to remove some permissions specified by their code in the rendered field html of PermissionChecksetBoxField and full-covered unit tests of this ability. * [rev:91612] Replaced BasicAuth::enable() with BasicAuth::protect_entire_site() * [rev:91612] BasicAuth::requireLogin() no longer has an option to automatically log you in. You can call logIn() on the object returned, instead. (from r91603) * [rev:91576] Deprecated Security::encrypt_passwords() (merged from r90949) * [rev:91576] Deprecated Security::$useSalt, use custom PasswordEncryptor implementation (merged from r90949) * [rev:91576] Removed Security::get_encryption_algorithms() (merged from r90949) * [rev:91576] MySQL-specific encyrption types 'password' and 'old_password' are no longer included by default. Use PasswordEncryptor_MySQLPassword and PasswordEncryptor_MySQLOldPassword * [rev:91576] Built-in number of hashing algorithms has been reduced to 'none', 'md5', 'sha1'. Use PasswordEncryptor::register() and PasswordEncryptor_PHPHash to re-add others. (merged from r90949) ### Bugfixes * [rev:98403] Fixed Hierarchy->loadDescendantIdList() to call setOwner() on the extension instance. This was necessary due to underlying Object/Extension changes in 2.4. * [rev:98382] #5044 Hierarchy::loadDescendantIDListInto() now uses Object::getExtensionInstance('Hierarchy') instead of going through __call(), as PHP 5.3 has issues converting references to values * [rev:98373] HTTP::setGetVar() uses parse_url() and http_build_query() to add query parameters to an existing URL, instead of doing its own regex-based parsing. This means existing GET parameters are correctly url encoded. * [rev:98324] Fixed ContentController->deleteinstallfiles (added to $allowed_actions, see #5040) * [rev:98272] Don't force SSL when running from CLI * [rev:98265] Don't register member IDs that don't exist in the DB as being logged in. * [rev:98263] Updated SiteConfig-based theme selection to remove inappropriate coupling from SSViewer * [rev:98257] Check for SubsiteReportWrapper class, not Subsite, so the CMS still works with older versions of Subsites * [rev:98252] allow all characters in the anchor's name attributes * [rev:98226] Fixed side report seelctor * [rev:98221] Let ModelAsController::init() extensions trigger redirections. (from r97767) * [rev:98218] More fixes renaming SSReport to SS_Report * [rev:98217] Don't allow translations of VirtualPage (until we can reliably copy data between locales) (see #5000) * [rev:98205] Better broken reason sorting (from r96989) * [rev:98204] Allow changing direction in broken link type (from r96987) * [rev:98203] Fix broken reasons sorting (from r96985) * [rev:98202] Improvements to sorting of columns on broken links report (from r96979) * [rev:98185] Add horizontal scrolling to reports when necessary. (from r96086) * [rev:98184] Add horizontal scrolling to reports when necessary. (from r96085) * [rev:98183] Add horizontal scrolling to reports when necessary. (from r96075) * [rev:98182] Removed unnecessary '?' from report URLs when there are no search criteria (from r96052) * [rev:98180] Don't throw an error if there are no report filters. * [rev:98180] Don't randomise the order of reports with the same priority. (from r95955) * [rev:98177] Only list reports in admin/reports that you can actually view (from r95885) * [rev:98176] Updated all cms side reports to use SSReport as the base class. (from r95884) * [rev:98170] Fixed bug with report search fields not showing the value that you just searched for. (from r95567) * [rev:98168] Fixed report pagination, with or without search params (from r95555) * [rev:98152] pagination was being applied (with a limit of NULL) to print and export actions. This was due to $_REQUEST['methodname'] not existing. (from r97114) * [rev:98150] TreeMultiselectField_Readonly now posts the correct value to the server (from r97100) * [rev:98136] still use the correct methods to get a value, even if we're generating a CSV ($xmlSafe = false) (from r96212) * [rev:98134] Don't default to sorted descending if you already have a different column sorted ascending. (from r96061) * [rev:98133] Don't make ManifestBuilder choke on empty files. (from r96058) * [rev:98132] Make TableListField sort checking use SQLQuery::canSortBy() to let SSReprot_FakeQuery work. * [rev:98131] Correct direction of sort arrows in TableListField (from r96051) * [rev:98114] fixed test that was trying to do a assertContains between a DataObjectSet and a Member object. Changed it to an assertEquals between Member and the First item in the Set. Also added an inverse test to check that Set doesn't contain the wrong Member. * [rev:98111] removing search&replace victim, using unpopulated cache. Reverted to AllChildren, which calls the cache itself. * [rev:98103] Fixed readonly transformation of TreeMultiselectField in cases where $this->value is explicitly set. (from r95962) * [rev:98101] Allow creation of TreeDropdownFields on forms with querystring URLs. * [rev:98101] Make use of the $this->value setting of TreeMultiselectFields. (from r95910) * [rev:98095] Let FieldMap access non-data fields too (from r95825) * [rev:98094] Make TableListField rely on SQLQuery for its count-generation. * [rev:98094] Make SQLQuery return an appropriate count if a HAVING clause is used. (from r95814) * [rev:98083] reintroducing the forceValue url param, so the TreeDropdownField value can be set via JS (previously if the item was deep within the tree structure it would not be selected) * [rev:98030] fixed member labels not appearing in cms popup. #5025 * [rev:98018] Fixed incorrect logic in CMSMain::generateTreeStylingJS() stopping different tree icons from working * [rev:98001] Ticket #4805 * [rev:97984] FileIFrameField throws sub-URLs error when changing cms to a non default language (#4767) * [rev:97980] #5009: Removed inappropriate field-detection change on multienums with no default * [rev:97937] missing comma * [rev:97935] can't upload swf file in admin/assets (open ticket #4999) * [rev:97926] remove the possibility that Director::isDev() could be recursively called when putting isDev=1 in $_GET, addressed in ticket #4978 (http://open.silverstripe.org/ticket/4978) * [rev:97912] Allowing translations of VirtualPage by not copying over original Locale property (see #5000) * [rev:97911] If a Group doesn't have any specific TRANSLATE_`<locale>` edit rights, but has general CMS access (CMS_ACCESS_CMSMain, CMS_ACCESS_LeftAndMain, ADMIN), then assign TRANSLATE_ALL permissions as a default. Necessary to avoid locking out CMS editors from their default language (see #4940 and 4941) * [rev:97909] Don't let a user's theme break the CMS. * [rev:97881] Checking that URL controller in HTTPRequest->match() is a subclass of Controller, not RequestHandler (which would include nested controllers like Form or FormField subclasses that shouldn't be accessible on their own toplevel URL namespace) * [rev:97878] Folder::findOrMake() will call mkdir if needed, even if object already exists in database. * [rev:97833] remove serverside Validator::get_javascript_validator_handler() checking when trying to valid the field in serverside. * [rev:97783] File don't have method URL(), instead, we use $image->URL, which will call $image->getURL() * [rev:97775] removed unneccessary comma (it breaks the IE) * [rev:97764] changed the stylesheet path to proper one - #4968 * [rev:97755] add custom search function, so the search catches also the Titles (search uses DataObject::get, which bypasses the getMenuTitle function) * [rev:97746] allow only 2 and 4 digit years. * [rev:97731] Use BASE_PATH and BASE_URL instead of data from $_SERVER. * [rev:97730] fix front-end validation for DYMCalendarDateField, addressed in open ticket #4967(http://open.silverstripe.org/ticket/4967). * [rev:97728] Don't rely on the current working directory for any file access; use BASE_PATH. * [rev:97727] Don't rely on the current directory for any logic. * [rev:97673] the anchor dropdown now works in IE. Also fixes other anchor-related problems as described in ticket #4961 * [rev:97653] Fixed Permission::get_members_by_permission() for DB abstractions * [rev:97638] Fixed CMS Editor loading in AssetAdmin * [rev:97603] Fixed bug when user selects no folder and uses the search box it incorrectly doesnt append the where statements * [rev:97599] Use correct paths for requirements * [rev:97594] Fixed potential data corruption issue when you are changing the class of a SiteTree subclass between two subclasses that share a fieldname. * [rev:97593] Another bugfix for r97583 * [rev:97589] Fixed bug that was caused by r97583 * [rev:97586] #4929: Fixed Object::add_static_vars() for uninherited static.s * [rev:97581] #4471: Fixed link insertion in Safari. * [rev:97545] Fixed widgets not being clickable to use them in IE * [rev:97541] Clicking available widgets now applies only to h3 elements * [rev:97541] Widgets are now prepended to the available widget stack by use of Insertion.Top * [rev:97522] When adding a new widget by clicking one of the available widgets, add it to the top of the currently used widgets instead of the bottom * [rev:97507] Fixed incorrect lables "TOADD" etc in WidgetAreaEditor * [rev:97482] Fixed NumericField->jsValidation(), now accepts negative numbers, making it more like the equivalent phpValidation(), which is using is_numeric() (see #4874, thanks Allisone) * [rev:97480] Checking for presence of all columns in Security::database_is_ready(). This was necessitated by an earlier change to the sapphire ORM which now selects all columns explicitly in a SQL query (instead of SELECT *) (see #4027) * [rev:97472] Setting 'Locale' as HiddenField in CMSMain->getEditForm() to support translatable SiteConfig records (see r97370, #4770) * [rev:97437] Properly closed a tag in AssetTableField that was hiding content after the back link tracking tab. From: Andrew Short (from r95036) * [rev:97433] Fixed nested URLs operation for pages more than 4 levels deep. From: Andrew Short (from r95902) * [rev:97414] Was using custom_database_fields in Aggregate, not database_fields, and so aggregates for the common fields (LastEdited, Created, ClassName) would fail * [rev:97370] Fixed SiteConfig->canView()/canEdit() to respect empty CanViewType/CanEditType assignments. * [rev:97357] old 2.3 passwords now handled correctly and migrated accordingly * [rev:97307] getByKey replaced with objectForKey * [rev:97300] The 5.1 replacement array_fill_keys function now made available to the cron jobs * [rev:97267] Let users without a specific TRANSLATE_ permission edit the default locale, so that things don't break when you install the Translatabe module. * [rev:97260] Move TreeDropdownField requirements to Field() so requirements are loaded properly in popups * [rev:97231] removing hardcoded reference to ModelAdmin_RecordController, also added getters for model controllers. * [rev:97211] Fixed URLSegment access for translated homepages in SiteTree->RelativeLink (#4781, thanks martijn) * [rev:97210] Language switcher dropdown javascript uses baseHref() to avoid invalid relative links in IE8 (#4891) * [rev:97179] Fixed redirection destionation of the modeladmin delete button on the detail form. * [rev:97168] now hiding the permissions via SecurityAdmin::add_hidden_permission works also for PermissionRoleAdmin * [rev:97073] Attribute escaping in PageCommentInterface?_singlecomment.ss (merged from r97071) * [rev:97051] Fixed bug in r97036 * [rev:97038] Fix display of exception backtrace in CLI view. * [rev:97036] Use locally included Zend framework components in favour of those installed with PEAR * [rev:97031] the search was only operating on the part of the tree (as returned by markPartialTree), now it searches globally * [rev:97023] HTTPResponse has been replaced with SS_HTTPResponse * [rev:97016] Comment URL field check is now case insenstive. Included tests for various protocols. PATCH via simon_w. Ticket #4776 * [rev:97013] removed name attribute from label fields since this is invalid html. Ticket: #4887. PATCH via tobych * [rev:96997] Check for an empty list of keys before attempting to create an array with them * [rev:96993] #4857 Fixed potential bug where a file would just be uploaded to a random folder, also files can now be uploaded to the assets root properly * [rev:96977] reintroduced 96961, build failed for other reason. * [rev:96961] loading a subtree was failing - couldn't call getSiteTreeFor reliably on LeftAndMain which is abstract class in its nature. Now using valid subclass instead. * [rev:96941] Fixed bug in VirtualPage::isPublishable() when CopyContentFromID not set * [rev:96884] Fixed add button overlapping image/flash popups in modeladmin. #4906 * [rev:96879] fixed onBeforeDuplicate calling before page existed * [rev:96868] Fixed a PHP segfault bug with the WidgetAreaEditor * [rev:96828] Adjust EncryptAllPasswordsTask test to match API for BuildTask * [rev:96822] Removed XSS holes (from r94822) * [rev:96818] Don't show obsolete page if you refresh the CMS after deleting a page (from r94242) * [rev:96817] Use canDeleteFromLive instead of canPublish for checking delete from live action (from r93316) * [rev:96812] Correct labels for "delete from draft" batch actions (from r91838) * [rev:96811] Use doDeleteFromLive when deleting pages from live, so that onBeforeUnpublish and onAfterUnpublish are called. (from r91381) * [rev:96809] Use the correct numChildrenMethod when showing the 'all children, including deleted' tree (from r91166) * [rev:96806] Preserve selection of LHS multiselect tree when switching between filters. (from r90290) * [rev:96805] Correct confirmation alert message when rolling back to a specific version. (from r90261) * [rev:96799] Updated onAfterUnpublish to republish page from static cache as well as unpublish them. (from r90002) * [rev:96798] Removed destroy() calls from static cache builder; with the garbage collection improvements it shouldn't be necessary. (from r89983) * [rev:96797] Fixed width of time dropdown fields in the LHS CMS (from r89913) * [rev:96796] Don't set the Owner by default on new records. (from r89910) * [rev:96795] Fixed viewing of deleted pages. (from r89833) * [rev:96790] Don't cut off document.body overflow in CTF popups in the admin, when on test mode. (from r88958) * [rev:96785] Ignore elements without a name in change detection. * [rev:96782] Fix image tracking not working cross subsite (from r88008) * [rev:96781] Fix changing the URLSegment on a page making the Draft Site link * [rev:96780] Fix deleting folders in Internet Explorer (from r87390) * [rev:96779] Fix highlighting of incorrect page when loading a page in the * [rev:96775] Use Controller::join_links() for all TableListField and ComplexTableField link building, to support form URLs with querystrings. * [rev:96775] If ComplexTableField::getParentRecord() can't find a record, just return null rather than erroring. (from r96555) (from r96649) * [rev:96774] Don't let Versioned archive tables clutter the global state when testing. * [rev:96774] Don't let mocked datetimes clutter the global state when testing. (from r96640) (from r96648) * [rev:96773] Removed XSS holes (from r94823) * [rev:96770] Don't set the nodelete class on the CMS tree on load, since this is now handled by the batch-action system with an Ajax call. (from r94762) * [rev:96767] Don't let users edit the location in the Behaviour tab if they don't have sitetree reorganise permission (from r94609) * [rev:96765] Fixed readonly form of TreeDropdownField when field is made readonly before value is set (from r94608) * [rev:96762] Allow opening of the detail pop-ups of a record on a ComplexTableField attached to a deleted page. (from r94593) * [rev:96761] Apply file extension restrictions to extensions properly. (from r93531) * [rev:96760] Don't publish virtual pages on regular page publish unless the page has already been published. (from r93529) * [rev:96759] Changed default config to restrict file-upload types to ADMINs, since it's protecting against security holes. (from r93327) * [rev:96758] Virtual pages can be deleted from the live site even when the're not publishable. (from r93319) * [rev:96755] Fixed notice-level errors when checking permissions of pages that don't exist anywhere (from r93166) * [rev:96754] Resized images which return null or false are now ignored * [rev:96752] Add a default list of allowed extensions so that the CMS works reasonably out of the box. * [rev:96752] Allow files that don't have an extension (most notably folders) * [rev:96752] Ensure that file URL rewriting works if you rename a page twice without publishing. * [rev:96752] Ensure that the page doesn't go green after URLs are rewritten * [rev:96750] Fixed bug in r93095 (from r93097) * [rev:96748] Update virtual pages semantics to grab content from the published version of the source page when you publish the virtual page, and to not allow publication before their source page is published. (from r92209) * [rev:96746] Amended some references to HTTPResponse, replacing with SS_HTTPResponse * [rev:96741] Use live permissions if the stage page has been deleted. (from r91761) * [rev:96740] Make virtual page broken link detection work across subsites. (from r91311) * [rev:96739] Clear the bypassStaticCache cookie when you return to the live site. (from r91165) * [rev:96736] Include newly set fields in the differences shown by DataDifferencer (from r90264) * [rev:96735] Use draft site permissions over published, if available. (from r90220) * [rev:96733] Change EncryptAllPasswords to BuildTask instead of DailyTask * [rev:96732] Call onBeforeUnpublish/onAfterUnpublish events in doDeleteFromLive, because they amount to the same thing. (from r90001) * [rev:96731] Fixed broken link correction when a page is deleted. (from r89989) * [rev:96729] Added better handling of rendering SiteTree objects, to prevent test errors. (from r89963) * [rev:96726] Reset the methods applied to classes after adding/removing extensions. (from r89957) * [rev:96724] Prevented notice-level error when publishing HTMLText fiels on tables other than SiteTree. (from r89908) * [rev:96722] Update file link tracking as part of Filesystem::sync() (from r89907) * [rev:96721] Fixed image link rewriting in virtual pages. (from r89904) * [rev:96720] Fixed onchange handler for DropdownTimeField (from r89903) * [rev:96719] Fixed layout glitch in TreeDropdownField in Firefox (from r89842) * [rev:96718] Don't let non ADMINs with permission-editing rights assign themselves ADMIN permissions. (from r89805) * [rev:96717] Fixed SiteTree::rewriteFileURL() (from r89804) * [rev:96715] Version field weird'ed up rollback functionality (from r89464) * [rev:96705] Make sure Linkto Dropdown works right with filter() * [rev:96681] alternative function for versions of PHP prior to version 5.2 * [rev:96680] array_fill_keys function created for version prior to PHP 5.2 * [rev:96679] Ensure .js variable defined with var keyword * [rev:96678] Ensure .js variable defined with var keyword * [rev:96663] Allow set objects as properties if the property is not a database field * [rev:96623] anchor, target, and title are not set on a link that's inserted without selection. Also when using createElement in that way firefox encodes the spaces within href parameter breaking the shortcodes. Switched to using the 'mctmp' placeholder now. * [rev:96566] Fix IE bug with Files&Images (#4912) * [rev:96551] getting rid of problem with disappearing buttons on the initial page load (not ajax). The initialization was called twice on the CMSForm, and on the second call the ajaxActionsAtTop was removing the buttons - now the buttons are removed only when there is something to be added. * [rev:96443] Check for functions existence * [rev:96441] Check for empty * [rev:96427] Fixed reloading of TableFields after ajax save. (http://mingle.silverstripe.com/projects/air_nz_cms_enhancements/cards/154) (from r88921) * [rev:96363] Fix multiselect tree selection, since changes in r91342 * [rev:96362] Readonly TreeMultiSelectField has form linked properly * [rev:95973] #4140 When clicking a tree node that was just dragged, "Stack overflow" error would be given in IE. Firebug would report "Too much recursion" * [rev:95972] when the JS files are combined, swfupload.js gets included in pages where there are no placeholder elements available, failing with exception and killing the javascript for the page. Now the exception is intercepted and ignored. * [rev:95968] Fallback for arrays which do not contain 'alreadyLoggedIn' values * [rev:95788] fixing CMS_ACCESS_LeftAndMain permission (=access all cms sections). Also added the test. * [rev:95558] Show selected row in autocomplete dropdown * [rev:95511] Prevent text-selection during drag operation, Firefox-specific * [rev:95422] Fixed undefined $this->Parent in SiteTree::getCMSFields() * [rev:95388] LessThanFilter uses SearchFilter::getDbFormattedValue, just like GreaterThanFilter * [rev:95339] pass $allowHTML through to the parent class * [rev:95169] If running a BuildTask via AJAX, e.g. Filesystem::sync() is run from AssetAdmin, don't show the message "Running [task] ..." * [rev:95108] Fix fatal error when exporting a csv from a tablefield with a custom query * [rev:95093] ComplexTableField - fixed sprintf() not enough arguments when the referrer has a % character in it, the referrer is now an argument instead of being hardcoded in the string * [rev:95091] #4847 Fixed ComplexTableField undefined in IE8 when opening a CTF popup in the Security section of the CMS * [rev:95088] #4848 Fixed ComplexTableField undefined error in IE8 when it is not available * [rev:95084] #4848 FileIFrameField visual problem where the preview image is hidden if the TreeDropdownField gets too long for selecting a file * [rev:94885] Fixed ModelAsController::findOldPage() failing on MSSQLDatabase using "sqlsrv" driver * [rev:94859] adding onAfterDelete hooks to remove the no longer necessary permissions * [rev:94835] orphaned permissions and subsite administrator groups were causing trouble - now with the JOIN the first global administrator group is picked up when ussing the override login. * [rev:94810] removing permissions before re-applying them (previously it just removed the components on the relation which resulted in permissions having GroupID set to 0) * [rev:94721] fixed typing error * [rev:94571] fixed spam not being turned into ham if spamprotection isnt enabled. PATCH via simon_w #4813 * [rev:94568] check akismet is enabled before saving spam. PATCH via simon_w - #4812 * [rev:94461] Fix fileiframefields dying when an image is attached and a folder is expanded via ajax * [rev:94443] fixed closing action on profiler popup * [rev:94437] include customHeadScripts in clear rule. * [rev:94416] Fixed undefined function error ip2country() in Geoip::ipcountry_check() * [rev:94378] match returns null on not-found, querying raw.length resulted in an error. Now it's possible to add links to the page again. * [rev:94369] Make sure findAnAdministrator gets a global administrator when subsites is installed. * [rev:94358] #4686 Fixed $member non-object error, and decorated checks from not working in Member::canView(), Member::canEdit() and Member::canDelete() * [rev:94353] #4566 Time::Nice() and Time::Nice24() return bad results if there is no value * [rev:94350] Fix default inclusion of (theme|project)/css/editor.css into the WYSWIWYG editor. * [rev:94349] Don't throw a notice-level error if you access a setting that hasn't been set yet. * [rev:94332] convert ImageFormAction form prototype syntax to jQuery syntax, merged from r94304 * [rev:94319] Cleanup after aborted drag operation in Assets (#4735) (from r93071) * [rev:94301] Fixed undefined calls to URL() in SimpleImageField, replacing them with getURL() instead * [rev:94238] is tinyMCE is not loaded, we cannot call its function. This is specially important in a pop-up of ComplexTableField * [rev:94170] Fixed IE bug in ReportAdmin_left.js * [rev:94134] #4661 Fix SS temporary directory bug with Windows environments - the directory would always be "silverstripe-cache" instead of a namespaced one so that multiple SS sites don't conflict with eachother * [rev:94100] if SecurityAdmin::add_hidden_permission() is called more than once, the later one is never added due two array operator "+" * [rev:94073] Fixed inconsistent default to ViewableData::Modulus() - should be 0 as per ViewableData::MultipleOf() * [rev:94071] Modulus and MultipleOf should start at index 0 to match the iterator position, by default * [rev:94061] fixed reference to incorrect class * [rev:94002] fix some missing langs/en.js loading. * [rev:93984] add proper language link broken * [rev:93965] Changed paths according to moved thirdparty dependencies. This bit change is merged from r92613. * [rev:93955] fix bug that can't find tinymce_ssbuttons under sapphire/thirdpaty. this is a change merged from r92853 http://open.silverstripe.org/changeset/92853#file3 * [rev:93950] fix bug that can't find tinymce_ssbuttons under sapphire/thirdpaty. this is a change merged from r92853 http://open.silverstripe.org/changeset/92853#file3 * [rev:93935] merge r92502 from trunk for HtmlEditorConfig.php, merge r93934 from trunk for HtmlEditorField.js, merge r92500 from trunk for sapphire/thirdpart/tinymce-advcode/editor_plugin_src.js, aiming to solve the conflict of folder name tinymce-advcode. * [rev:93860] Fixed incorrect hasDatabaseField() in SearchFilter::getDbName() - use hasOwnTableDatabaseField() instead * [rev:93777] Fixed SearchContextTest failure * [rev:93754] Fixed drag link event handling on ComplexTableField.js (#4737) * [rev:93707] Removed code that relied on deprecated functions in MemberTableField * [rev:93677] Removed calls to Translatable::is_enabled() since it's deprecated, replaced with Object::has_extension('SiteTree', 'Translatable') instead * [rev:93676] Removed calls to Translatable::is_enabled() since it's deprecated, replaced with Object::has_extension('SiteTree', 'Translatable') instead * [rev:93673] #4762 Replace Debug::log_errors_to() in ConfigureFromEnv to use SS_Log instead. Thanks simon_w! * [rev:93620] Fixed reference to tree.css which doesn't exist because of files moving around * [rev:93579] Adjusted YamlFixture to new Spyc API: loadFile() instead of load() (from r92566) * [rev:93542] applied patch from #4381. Observable doesnt play nice with jQuery (manual jsparty merge from r90857) (from r92571) * [rev:93514] Fix javascript error on IE8 by forcing IE7 compat mode. * [rev:93259] Fixed dev/build not redirecting properly on first install of SS website on IIS * [rev:93161] Fixed newlines for Windows when logging errors in LogErrorFileFormatter * [rev:92411] Fix TreeDropdownFields throwing an exception. * [rev:92220] Fixed newlines working properly across different platforms - Windows, for example, won't work properly with just \n so use PHP_EOL for a cross-platform solution * [rev:92129] More robust checks on the current member in Member::canEdit() and Member::canDelete() if there is no logged in member * [rev:92077] Fixed regexp in anchor link rewriting * [rev:91958] FolderID was not present in post, so file would not be uploaded to the correct place. * [rev:91775] Fixed Group::collateFamilyIDs() when working with MSSQL * [rev:91746] Include salt in legacy password encryptor (from r91743) * [rev:91659] Made use of new BasicAuth::protect_entire_site() consistent. (from r91658) * [rev:91613] Don't enable site-wide protection by default (from r91609) * [rev:91576] Fixed password hashing design flaw in Security::encrypt_password(). Removing base_convert() packing with unsafe precision, but retaining backwards compatibilty through pluggable encryptors: PasswordEncryptor_LegacyPHPHash (#3004) (merged from r90949) * [rev:91572] Legacy password hash migration in MemberAuthenticator::authenticate() which fixes the precision problems mentioned in #3004 when a user logs in (from r90950) * [rev:91549] changed condition to display uploaded File * [rev:91542] fixed order inclusion of js * [rev:91444] Fixed PageComment boolean operators in WHERE SQL clauses that break MSSQL * [rev:91418] MigrateSiteTreeLinkingTask returns duplicate results from databases like MSSQL - remove any duplicates that may be around ### Minor changes * [rev:98409] Fixed HTTPTest->testSetGetVar() * [rev:98407] Fixed HTTPTest->testSetGetVar() * [rev:98404] Partially reverted r98382 which added unnecessarily defensive checking to Hierarchy->allChildren() * [rev:98403] Fixed HierarchyTest assertions around including grand children counts * [rev:98390] Removed argument to getDescendantIDList() in ThumbnailStripField that doesn't exist on the method * [rev:98383] Fixed HTTPTest when invoked through dev/tests/all or with GET parameters (see r98373) * [rev:98376] Testing of grand-children items in HierarchyTest::testLoadDescendantIDListIntoArray() and HierarchyTest::testNumChildren() * [rev:98372] Documentation * [rev:98370] Fixed test case name in Hierarchy * [rev:98369] Added test case for Hierarchy::getDescendantIDList() which also tests Hierarchy::loadDescendantIDListInto() * [rev:98341] Removed arguments to Hierarchy::getDescendantIDList() calls, as the method does not have any * [rev:98326] Make pass use a password field, dont require call by reference (merged from r72930) * [rev:98321] Use 'b' mode for fopen() where possible for better portability * [rev:98285] Fixed SS_HTTPResponse references in CMSBatchActionHandler * [rev:98284] Documentation * [rev:98282] fixed setName() * [rev:98275] Removed message alteration from ValidationResult->error() to make it more predictable for string matching in unit tests like SecurityTest * [rev:98274] Fixed unit tests after change Member->checkPassword() to return ValidationResult instead of boolean (see r98268) * [rev:98268] Use a ValidationResult to log in a member so that custom errors can be generated. From: Andrew Short (from r98267) * [rev:98264] Only clear theme in CMS if we're not redirecting to the login form (better for testing). * [rev:98228] Adding SiteConfig as Translatable dependency in SiteTreeTest and TranslatableTest * [rev:98223] make showing virtual pages tab conditional * [rev:98223] made virtual page tracking sitetree tablelistfield subsite agnostic (from r98005) * [rev:98222] removed redundant method call (from r97817) * [rev:98211] added above confiration to batch setting expiry (from r97215) * [rev:98210] add pretty warning colors to expiring content warning (from r97151) * [rev:98208] set Print flag correctly on TLF * [rev:98208] custom print template for SSReport TLF's that exposes the report title, and filters set (from r97138) * [rev:98206] fix dropdown labels (from r97063) * [rev:98201] fixed typos in the comments * [rev:98200] Change page title heading to "Page name" for consistency in CSV export (from r96925) * [rev:98199] added quotes * [rev:98198] Fixed side report tests to suit new report system. (from r96646) * [rev:98197] using better sorting api (from r96483) * [rev:98196] fix sorting in this report. (from r96481) * [rev:98195] make site checking clearer on broken links report (from r96456) * [rev:98193] typo fixes, adding missing columns (from r96433) * [rev:98192] remove sort direction when running canSortBy. Also added test coverage for this. (from r96428) * [rev:98189] improved wording on reports (from r96258) * [rev:98187] added broken links report (from r96139) * [rev:98186] Correct sidebar report order. (from r96090) * [rev:98180] Added SSReport::dataClass() accessor. * [rev:98178] use DB doubles only in MySQL, fall back to float * [rev:98174] Added missing template from r95815 (from r95822) * [rev:98171] Nicer date formatting (from r95761) * [rev:98164] added locking to static publisher to avoid two queues running at the same time. (from r87792) * [rev:98163] fixed IE JS errors (from r87420) * [rev:98162] apply a sitetree filter when changing subsites (from r87369) * [rev:98160] updated detection for an empty report (from r87362) * [rev:98158] when you delete a user from a group, they are also removed from any sub groups. (from r87119) * [rev:98156] applied correct decorators * [rev:98156] Page.ss now takes advantage of the SiteConfig * [rev:98156] fixed JS error around concurrent editing * [rev:98156] ability to disable sorting on tablelistfield * [rev:98156] added default timezone to static-main.php to avoid PHP warnings * [rev:98156] only display Roles tab on groups if there are roles in the system * [rev:98156] publishing activity report * [rev:98155] better error reporting for broken redirector & virtual pages (from r97185) * [rev:98154] set Print flag correctly on TLF * [rev:98154] custom print template for SSReport TLF's that exposes the report title, and filters set (from r97138) * [rev:98153] Fixed TableListField tests that don't set $_REQUEST['url'] (from r97127) * [rev:98143] Always position calendars below the entry field - this gives it consistency with PopupDateTimeFields, as well as ensure the popup button isnt hidden. (from r96916) * [rev:98142] Fixed PermissionTest assertion (from r96642) * [rev:98141] Fixed TableListField test to suit changed behaviour. (from r96639) * [rev:98140] if the $fieldname to DOS->sort has a direction in it, split it out, and pass it. (from r96482) * [rev:98139] redirector link tracking is more intelligent (from r96461) * [rev:98138] remove sort direction when running canSortBy. Also added test coverage for this. (from r96428) * [rev:98137] move sort column&direction into their own vars, otherwise, canSortBy(Date DESC) will always return false, since DESC is not part of the column name. (from r96411) * [rev:98135] fix field escaping in CSV export of TableListField (from r96157) * [rev:98128] Update en_US with SiteConfig.THEME and SiteConfig.DEFAULTTHEME translatable entities * [rev:98127] Cleanup test folder after SiteConfigTest::testAvailableThemes() is run * [rev:98115] added descriptive text to test assert. * [rev:98110] Unit tests for SSViewer::current_theme() and SiteConfig::getAvailableThemes() * [rev:98106] Fixed broken tests * [rev:98098] Removed specific removal of temporary directory in ManifestBuilderTest::testThemeRetrieval() and replaced it with Filesystem::replaceFolder() which does the same thing * [rev:98097] don't HTML-format queries from showqueries if this is an AJAX request. (from r95855) * [rev:98092] Initialise variables to fix unit test (from r95754) * [rev:98091] Added ManifestBuilderTest::testThemeRetrieval() to test ManifestBuilder::get_themes() * [rev:98090] Edit-case checking of data in ViewableData::$failover for better error message. (from r95560) * [rev:98089] Don't try and access the ORM from ComplexTableField in situations where it shouldn't. (from r95544) * [rev:98088] Boundary condition check in TableListField for more helpful errors. (from r95543) * [rev:98086] Fixed FileTest execution if the assets/ directory doesn't exist. (from r88353) * [rev:98085] added direct links to items in the backlinks report (from r88277) * [rev:98084] unit test for getting members by permission via roles (from r88276) * [rev:98079] Partially reverted accidental commit from r97920 (unconditionally requiring ADMIN login via BasicAuth in DevelopmentAdmin) * [rev:98059] Changed MySQLDatabase::now() block comment to be more useful * [rev:98056] Unit tests for Decimal field type default value through new test class DecimalTest * [rev:98055] Allow creating fixture records without any columns by checking the fields exist first before doing a foreach() in YamlFixture::writeDataObject() * [rev:98043] niced the way MultiEnums call requireField to give alternative adapter access * [rev:98042] use ENUM hack for dealing with SET legacy values * [rev:98032] visual tweaks to the widgets area including widget titles can now be spread over multiple lines and padding between columns. #4965 * [rev:98025] fix permissions * [rev:98017] permission code is case sensitive in some cases * [rev:97991] Deleted reference to CalendarDateField.js * [rev:97991] Year validation (accept just 4 digit, like the error message says). * [rev:97985] groupby works for SQLite too * [rev:97979] Better error message on bad Enum default * [rev:97936] add flv (flash file) to File::$allowed_extensions * [rev:97920] Preserve theme settings in tests * [rev:97910] Removed debug code * [rev:97875] fix call to undefined method when a virtual page picks up the wrong object. * [rev:97838] PHP notice error * [rev:97825] Removed debug code * [rev:97705] replaced proprietary update query with one that is ANSI compliant in doPublish() * [rev:97669] #4674 applied patch for special chars in folder titles * [rev:97652] Make SecurityDefaultAdminTest when you run it by itself. * [rev:97602] Added better help text underneath "Available Widgets" and "Widgets currently used" * [rev:97596] fix file iframe upload width * [rev:97592] Re-enabled SiteTreePermissionsTest tests * [rev:97566] If CurrencyField->setValue() passed a null or empty value, default to 0.00 so number_format() has no issues converting the number * [rev:97543] Tree selector expands by default to show selected nodes * [rev:97540] Cursor is now a pointer for available widgets, as you need to click them to add to the available widget stack * [rev:97532] Removed end php tag from WidgetAreaEditor * [rev:97511] Changed wording for WidgetAreaEditor.TOADD advising users to "click" instead of drag widgets * [rev:97509] Fixed default wording of WidgetAreaEditor.TOADD "drag them here from the left" * [rev:97487] Updated master translation file * [rev:97486] Updated master translation file * [rev:97485] Backwards compat fix for sprintf() call in CMSMain->providePermissions() (#4764) * [rev:97484] Using SiteTree::get_by_link() in SiteTree->requireDefaultRecords() (see #4590) * [rev:97483] Fixed setForm() invocation in Form::__construct() (see #4558, thanks ajshort) * [rev:97481] Use addExtraClass() in FormField::__construct() instead of direct assignment (see #4607, thanks Tjofras) * [rev:97478] Security::findAnAdministrator() names any default administrators 'Default Admin' instead of 'Admin' * [rev:97435] Don't include files and folders starting with an underscore in the asset system. * [rev:97435] Automatically rename files and folders beginning with an underscore. From: Andrew Short (from r97400) * [rev:97434] Fixed deep-nested-URLs test to work on sites in subfolders (from r96836) * [rev:97432] Made ComplexTableField sub-forms testable by returning rather than echoing results. From: Andrew Short (from r95035) * [rev:97431] Allow a validation error to be thrown when a DataObject is saved in ComplexTableField. From: Andrew Short (from r95034) * [rev:97369] Fixed MemberAuthenticatorTest, was setting global state in r97357 * [rev:97182] Reverted 'single instance only' feature from r79868, delayed until later release (see #4277) * [rev:97178] Removed 'print' button from CMSMain->getEditForm() for display of older versions (see #4745) * [rev:97072] added comments * [rev:97035] folders without children in trees now have the folder icon * [rev:97031] renamed 'filter' to 'search' * [rev:96942] Removed unnecessary illegalExtensions data from TranslatableTest * [rev:96882] Ensure DropdownField option elements have escaped the title correctly * [rev:96877] added hooks for extending duplicate page functionality * [rev:96830] Added explicit listing of testonly dataobjects for widget tests. * [rev:96829] Fixed bugs with test execution. * [rev:96827] Fixed CMSMainTest to be more flexible about modules altering the buttons. * [rev:96816] moved allowed_extensions and friends to the model layer (from r92046) * [rev:96815] moved File validation to the model (from r92044) * [rev:96814] implement the allowedExtensions functionality of AssetAdmin when you rename a file (from r92037) * [rev:96813] Made delete from draft batch action text more consistent with published. (from r91839) * [rev:96808] add a hidden field to attach the subsite ID, rather than relying on the session (from r91014) * [rev:96807] no longer assume with batch actions that the child pages of a parent are to be ticked (from r90999) * [rev:96804] Fixed notice-level error in rollback. (from r90260) * [rev:96803] Updated ModelAdminTest to use extraDataObjects (from r90055) * [rev:96802] Removed debugging statements (from r90052) * [rev:96801] Fixed testing quirk of static publisher unpublishing. (from r90048) * [rev:96794] Make CMSMainTest compatible with cmsworkflow module. (from r89030) * [rev:96789] added batch deletion back for workflow (from r88916) * [rev:96788] more fix around batch action parameters (from r88837) * [rev:96787] fix issue where javascript popup calendar would not fire (from r88836) * [rev:96786] rename deleted pages report (from r88333) * [rev:96784] create the ability to have some roles only be able to be applied by admins (from r88090) * [rev:96783] remove default form actions. Unit tests pass. (from r88065) * [rev:96776] fix javscript syntax that can confuse ie (from r86395) * [rev:96772] Ensure that cuke can work with --dry-run (from r94819) * [rev:96771] when a parent page is unpublished, unpublish all related virtual pages, includes test coverage (from r94777) * [rev:96768] track virtual pages that link to the current page (from r94700) * [rev:96753] Removed debugging information: (from r93151) * [rev:96747] Give all test ADMIN privileges by default (from r92208) * [rev:96745] Fixed SiteTree::canEdit() for records not yet saved to DB (from r92193) * [rev:96744] can_edit_multiple() should return false, not 0, for permission failure. (from r92192) * [rev:96743] moved allowed_extensions and friends to the model layer (from r92046) * [rev:96742] moved File validation to the model (from r92044) * [rev:96738] if looking at a specific stage, set a cooking to bypass static cacheing (from r91006) * [rev:96737] virtual pages are now marked as broken if their pointer page is deleted (from r90996) * [rev:96730] Flush get_one cache after rebuilding database schema. (from r89966) * [rev:96716] fix syntax error (from r89472) * [rev:96714] update merge info, merged in r87119 (from r88839) * [rev:96710] changed the method to get a page's siteconfig, it is now subsite aware. (from r89870) * [rev:96230] Moved defined variables in AssetAdmin::doUpload() to the top of the method for consistency * [rev:95971] Set url variable in TreeAPI.reload as local variable in LeftAndMain_left.js * [rev:95966] Added unit test for ViewableData::MultipleOf() when using an offset of 1 (an alternative approach) * [rev:95086] make widgetarea/editor more suitable for generic use * [rev:95070] remove relic of concurrent editing * [rev:95052] remove director rule for removed Image_Uploader in r77012 * [rev:94986] adding maori macron button back * [rev:94856] added comment * [rev:94829] fixed bug where widget area editor would not be activated * [rev:94711] test support for superglobals in testrequest * [rev:94710] test support for superglobals in testrequest * [rev:94684] added cookies to Director::test() * [rev:94531] Fixed a few glitches in the cuke tests * [rev:94529] Added a first cut of some cucumber tests for the CMS * [rev:94528] Added db-fixture creation for cucumber-based testing * [rev:94438] removed duplicate writes for performance * [rev:94432] Don't use test manifest for dev/startsession and dev/endsession (from r93528) (from r94431) * [rev:94429] Added small fixture YML that just lets you log in, for bootstrapping browser automation tests. * [rev:94420] Fixed misspelled acronym for "Cross-site request forgery" * [rev:94418] Documentation updates to SS_Log * [rev:94359] Added tests methods for Member::can*() methods to MemberTest * [rev:94359] Added test Extension classes for testing decorated can*() methods * [rev:94358] Added additional tests to MemberTest * [rev:94352] #4973 Automatically generate URLSegment for default records on SiteTree and ErrorPage instead of explicitly setting them * [rev:94336] Tweak to test name display on the test runner * [rev:94198] fixed widget area * [rev:94198] added select box listing anchors in text * [rev:94136] Fixed error message for Folder::addUploadToFolder() to be accurate * [rev:94135] Less obtrusive tests for testing the SS temp directory * [rev:94065] Added a few missing pieces to DataObjectSetTest::testMultipleOf() * [rev:93966] Use jquery instead of prototype for silverstripenavigator * [rev:93859] Fixed tabs * [rev:93762] Javascript variable declarations in CMSMain_left.js (#4741) * [rev:93738] Fixed reference to fieldExists() on SearchFilter which was removed from DataObject * [rev:93701] reverted r93693 due to the field being required for the CMS * [rev:93682] Removed calls to ContentNegotiator::disable() since it's disabled by default * [rev:93681] Removed ContentNegotiator::disable() since it's disabled by default (in AssetAdmin) * [rev:93662] Removed MemberTableField deprecated methods for adding fields - this should be done by implementing summary fields on a Member decorator instead * [rev:93659] Removed ContentNegoitator::disable() from FormResponse - it's disabled already * [rev:93641] Moved static functions in ContentNegotiator above the instance methods * [rev:93623] Fixed capitalization of JSMin.php include (from r92870) * [rev:93622] Fixed path for spyc thirdparty library * [rev:93612] Updated paths from jsparty to sapphire/thirdparty, cms/thirdparty and cms/javascript * [rev:93611] Updated paths from jsparty to sapphire/thirdparty, cms/thirdparty and sapphire/javascript * [rev:93610] Moved jsparty/tiny_mce to sapphire/thirdparty/tinymce * [rev:93591] Moved jsparty/greybox to sapphire/thirdparty/greybox * [rev:93589] Moved jsparty/jquery/jquery_improvements.js to sapphire/javascript/jquery_improvements.js * [rev:93577] Moved jsparty/prototype_improvements.js to sapphire/javascript/prototype_improvements.js * [rev:93576] Moved jsparty/prototype15.js to sapphire/thirdparty/prototype/prototype15.js * [rev:93575] Moved jsparty/prototype-safe.js to sapphire/thirdparty/prototype/prototype-safe.js * [rev:93574] Moved jsparty/prototype.js to sapphire/thirdparty/prototype/prototype.js * [rev:93571] Moved jsparty/loader.js to sapphire/javascript/loader.js * [rev:93570] Moved jsparty/layout_helpers.js to sapphire/javascript/layout_helpers.js * [rev:93569] Moved jsparty/hover.js to cms/javascript/hover.js * [rev:93568] Moved jsparty/highlight.js to cms/javascript/highlight.js * [rev:93567] Moved jsparty/tiny_mce_improvements.js to sapphire/javascript/tiny_mce_improvements.js * [rev:93565] Moved jsparty/tree to sapphire/javascript/tree * [rev:93564] Moved jsparty/tinymce_ssmacron to cms/javascript/tinymce_ssmacron * [rev:93563] Moved jsparty/tinymce_ssbuttons to cms/javascript/tinymce_ssbuttons * [rev:93562] Moved jsparty/tinymce_advcode to sapphire/thirdparty/tinymce-advcode * [rev:93560] Moved jsparty/tabstrip to sapphire/thirdparty/tabstrip * [rev:93559] Moved jsparty/SWFUpload to cms/thirdparty/swfupload * [rev:93557] Copied jsparty/multifile to cms/thirdparty/multifile * [rev:93555] Moved jsparty/calendar to sapphire/thirdparty/calendar * [rev:93554] Moved jsparty/scriptaculous to sapphire/thirdparty/scriptaculous * [rev:93553] Moved jsparty/jquery/plugins/greybox to sapphire/thirdparty/greybox * [rev:93552] Moved jsparty/jquery/plugins/livequery to sapphire/thirdparty/jquery-livequery * [rev:93551] Moved jsparty/jquery/plugins/metadata to sapphire/thirdparty/jquery-metadata * [rev:93550] Moved jsparty/jquery/plugins/form to sapphire/thirdparty/jquery-form * [rev:93549] Moved jsparty/jquery/plugins/effen to sapphire/thirdparty/jquery-effen * [rev:93548] Added jquery.cookie library to allow saving of last selected jQuery UI tab (from r92507) * [rev:93547] Moved jsparty/jquery/themes to sapphire/thirdparty/jquery-ui-themes * [rev:93546] Moved jsparty/jquery/ui to sapphire/thirdparty/jquery-ui * [rev:93544] Moved jsparty/jquery/jquery.js to sapphire/thirdparty/jquery * [rev:93543] Added sapphire/thirdparty/firebug-lite (from r92496) * [rev:93541] Added sapphire/thirdparty/behaviour (from r92497) * [rev:93532] Added Zend_Log thirdparty dependency (merge from r84322) (merged from r92549) * [rev:93530] Replaced sapphire/thirdparty/Zend external with piston-managed version (merged from r92492) * [rev:93527] Added simpletest thirdparty library (previously included as an external) (merged from r92857) * [rev:93526] Re-added sapphire/thirdparty/spyc library * [rev:93525] Re-added sapphire/thirdparty/simplepie library * [rev:93524] Re-added sapphire/thirdparty/jsmin library * [rev:93521] Re-added sapphire/thirdparty/json dependency * [rev:93449] Update the main.php PHP version numbers at the top doc block * [rev:92351] Increase size of URL length to be lowest common denominator of maximum length in modern browsers. * [rev:92220] Fixed appropriate failing tests to use PHP_EOL * [rev:92135] Removed MemberTableField::setController() - this is now redundant from r92134 * [rev:92134] Added ComplexTableField::setController() which makes testing useful for switching between controllers * [rev:91850] added stubs to allow widgets to use treedropdown fields * [rev:91564] Moved Security::encryptallpasswords() to EncryptAllPasswordsTask (merged from r90948) * [rev:91543] removed debug statements * [rev:91541] fixed typo with path * [rev:91394] BUGFIX Disabling security token in HtmlEditorField?->FlashForm?(), its not passed in by the ajax request (merged from r91392) * [rev:91307] merged in 91306 from trunk * [rev:91261] Whitespace change ### Other * [rev:98173] ENHANCEMNT: Added export and print buttons to reports (from r95815) * [rev:98172] Nicer dates (from r95776) * [rev:98147] Validation for calendardatefields (from r96958) * [rev:98093] Add some nice date formats (from r95772) * [rev:98001] added a canCreateTopLevel() if there is no parent object in CMSMain.php * [rev:98001] added testCreationOfTopLevelPage toCMSMainTest.php * [rev:98001] added the nessessary 'database entries' in the CMSMainTest.yml * [rev:97991] Deleted javascript/CalendarDateField.js. The file is empty. * [rev:97898] Added values for new permission code 'VIEW_DRAFT_CONTENT' test * [rev:97897] Added test for new permission code. * [rev:97878] This covers the corner case where DB is out of sync with filesystem. * [rev:97384] REVERT: r97017 (Try to tidy HTML...) as causes inconsistent HTML * [rev:96966] REVERTED: 96961 fails the test, reverted. * [rev:96926] `<a ... />` tag which is not so nice * [rev:96781] point to the wrong subsite (from r87776) * [rev:96779] admin section via URL (from r87320) * [rev:96777] javascript syntax fixes (from r86396) * [rev:96712] MERGE merged back a whole bunch of defect fixes from trunk (from r87846) *
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/beta/2.4.0-beta2.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/beta/2.4.0-beta2.md
54,403
1,758,118,090
en
# 2.4.0-beta2 (2010-05-17) ## Changelog ### Features and Enhancements * [rev:101127] Added 'Dependent pages' tab to CMS, to show virtuals, redirectors, and backlinks that point to this page. * [rev:101054] Allowing SQLite selection in installer * [rev:101054] Moved all Javascript containedin install.php and config-form.html to install.js, and using jQuery to simplify logic * [rev:101054] Allow installer to attach custom form fields based on the install driver (as defined in _register_database.php) * [rev:100989] If no arguments specified for cli-script.php/sake, then provide a friendly message to the user on where to get help * [rev:100966] MoneyField currency dropdown can be made from an associate array like array('NZD'=>'New Zealand Dollor', 'USD'=>"United States Dollor') as well * [rev:100940] Added help text for "locale" setting in installer * [rev:100937] Redirecting to translated page when original is requested with a 'locale' GET parameter (e.g. 'about-us/?locale=de_DE' will redirect to 'ueber-uns' with a 301 HTTP response). Implemented in ContentController->handleRequest(). (see #5001) * [rev:100908] Added DatabaseAdapterRegistry::unregister() to remove a database from the registry * [rev:100902] Added _register_database.php to sapphire which sets the SS provided databases for DatabaseAdapterRegistry * [rev:100893] Added Hebrew (he_IL) language to sapphire (thanks Oren, Yotam, tzvika, Amir, ohad) * [rev:100893] Added Lithuanian (lt_LT) language to sapphire (thanks Irmantas, Mindaugas, Donatas, Andrius) * [rev:100892] Added Hebrew (he_IL) language to cms (thanks Oren, Yotam, tzvika, Amir, ohad) * [rev:100892] Added Lithuanian (lt_LT) language to cms (thanks Irmantas, Mindaugas, Donatas, Andrius) * [rev:100884] Using jquery.live instead of livequery for SelectionGroup.js * [rev:100852] Updated jquery.ondemand.js to sapphire trunk version, to ensure compatibility with jQuery 1.4.2 * [rev:100849] Only defining document.getElementsByClassName() in prototype.js if no native implementation exists (which speeds up the CMS). Ported from 'jquery13' module, thanks Hamish * [rev:100847] Updated jquery.livequery from v1.0.2 to v1.1.1 (located in sapphire/thirdparty/jquery-livequery/ * [rev:100846] Updated jquery.metadata from ~v.1.0 to v2.1 (located in sapphire/thirdparty/jquery-metadata * [rev:100845] Updated jQuery.form library from v2.08 to v2.40 (located in sapphire/thirdparty/jquery-form * [rev:100844] Updated jQuery library from v1.2.6 to v1.4.2 (located in sapphire/thirdparty/jquery/ * [rev:100799] Creating default "Content Authors" group with limited rights if no other groups exist. * [rev:100776] Better editing of roles through SecurityAdmin instead of a new "Roles" tab. Removed (previously unreleased) PermissionRoleAdmin. (see #4757) * [rev:100774] Allowing custom popup requirements in ComplexTableField without subclassing through $requirementsForPopupCallback * [rev:100771] Respecting SecurityAdmin::$hidden_permissions in PermissionRole->getCMSFields() * [rev:100769] you can now choose your site locale at install time * [rev:100753] Added 'updateImageForm', 'updateFlashForm', 'updateLinkForm' hooks to HtmlEditorField (the imageform hook was necessary to make the 'pixlr' module work) (see #3938) * [rev:100696] show all database systems we support, along with messages if the user cannot use them. Also allow 3rd parties to register their own database classes to appear in this list. * [rev:100536] Stored combined files in assets/_combinedfiles by default * [rev:100529] Combined files now live in assets/.combinedfiles by default * [rev:100528] #3387 Requirements now has a new static function called Requirements::set_combined_files_folder() for setting where the combined files should belong * [rev:100453] #4599 DataObjectSet now uses more array functions instead of performing equivalent tasks - thanks simon_w! * [rev:100423] Convert JSON functions now use the Services_JSON library where appropriate instead of custom code, and if json_decode() or json_encode() are available these are used * [rev:100400] #5072 RSSFeed_Entry::rssField() now respects custom getters on the data class * [rev:100327] allow ordering of page commented to be configurabled * [rev:100058] AssetAdmin now uses Upload_Validator instead of setting the rules directly on Upload * [rev:99954] you can now do coverage tests of single/multiple tests, or entire modules * [rev:99942] fixed forward button underneath result form * [rev:99929] #4787 Widget now respects updateCMSFields on extension classes so additional fields can be add (or existing ones removed) * [rev:99845] #4043 Allow setting the from address for debug information in SS_LogEmailWriter - thanks Hamish! * [rev:99841] #5024 Installer now checks that the user has entered a username and password correctly for the default admin, an additional button for re-checking requirements is now found at the bottom of the admin configuration section * [rev:99841] Error messages for database AND admin configuration are now in the same place at the top of the installer * [rev:99737] Allow DataObjectSet to remove duplicates based on any field (#5094, thanks mobiusnz) (from r99736) * [rev:99692] Disabling/checking permission checkboxes in admin/security when 'ADMIN' permission is selected * [rev:99690] Saving group relations on SecurityAdmin->EditForm()/RootForm() through TreeMultiselectField instead of hidden 'Group'/'GroupID' values (from r99579) * [rev:99688] Saving MemberTableField through new 'Groups' field added in Member->getCMSFields(). (from r98882) * [rev:99679] added new PageCommnet to yml so we have different amounts of moderated/unmodereated * [rev:99677] Making setting optional in MemberTableField. Field instances without will list all members unfiltered, and remove members from the database rather than the group relation. * [rev:99677] Allow disabling of 'inline add' formfields in a MemberTableField through setPermissions(array('inlineadd')) (from r98825) * [rev:99667] Only show 'HTML Editor Config' dropdown in Group->getCMSFields() if more than one option exists * [rev:99666] Showing checkboxes as disabled for inherited roles in Group->getCMSFields() (from r99597) * [rev:99664] Added OptionsetField->setDisabledItems() to allow specifically disabling certain checkboxes * [rev:99664] Added CheckboxSetField->setDefaultItems() to tick specified checkboxes regardless of the value passed (from r99596) * [rev:99662] Showing (readonly) permissions for a Member record in admin/security popup (from r99586) * [rev:99660] PermissionCheckboxSetField_Readonly (with all checkboxes disabled) * [rev:99660] Added 'assigned to...' label to group permissions in PermissionCheckboxSetField - used in Member->getCMSFields() readonly permission view (from r99585) * [rev:99658] Allowing PermissionCheckboxSetField to inspect multiple group records for existing permissions (from r99584) * [rev:99648] View and select groups for a specific member via the member popup in admin/security (requires EDIT_PERMISSIONS) (from r98880) * [rev:99361] Allow locale/dateformat specific reordering of day, month, year input fields in DateField * [rev:99360] New DatetimeField class (form field wrapper composed of DateField andTimeField) * [rev:99360] New DateField and TimeField form classes with more consistent API and easier localization * [rev:99360] Using Zend_Date for DateField and TimeField, with more robust date handling, starting localization support. Set globally via i18n::set_locale(), or for a field instance through setLocale(). Note: Javascript validation is not localized yet. * [rev:99302] SiteTree::batch_permission_check() populates its own cache (from r97900) * [rev:99117] set file metadata on upload. (from r97780) * [rev:99106] set file metadata on upload. (from r97780) * [rev:99088] Add close link (from r97751) * [rev:99080] Add Link to silverstripe navigator (from r97407) * [rev:99069] added PageComment for CommentAdminTest * [rev:99066] CommentAdmin unitest * [rev:99047] Make navigator items more overloadable (from r97376) * [rev:99046] Refactor links in $SilverStripeNavigator so modules can add extras (from r97299) * [rev:98756] Added help texts for MemberImportForm and GroupImportForm (merged and rewritten from r98750) * [rev:98737] Allow extension of LeftAndMain->getEditForm() (and subclasses) through a new updateEditForm() hook (see r98736 for additions to AssetAdmin and CMSMain) * [rev:98736] Import groups from CSV in admin/security through the new GroupImportForm class (and GroupCsvBulkLoader) (merged and rewritten from r98711) * [rev:98735] Allowing custom 'root forms' when id values '0' or 'root' are passed from the tree selection. (rewritten from r98710) * [rev:98732] Import members and their group assignments from CSV in admin/security through the new MemberImportForm class (merged from r98708) * [rev:98715] Added GroupCsvBulkLoader class to facilitate group imports with permission codes and hierarchy (merged from r94252) * [rev:98714] MemberCsvBulkLoader for easy member import with group associations (merged from r94251) * [rev:98713] Added BulkLoader->deleteExistingRecords(), removed unnecessary parameters from BulkLoader->load() (merged from r94250) * [rev:98713] Decreased memory usage in BulkLoader->load() when deleting all records before importing (merged from r94250) * [rev:98677] Added checkbox to switch off using the environment during install if it's available * [rev:98659] #3903 Initial changes to installer to support selection of different database drivers * [rev:98656] you can now pass arbitrary CURL options to the request() method of RestfulService. * [rev:98469] Add HTMLCleaner abstract class, and Diff::cleanHTML() * [rev:98428] Allow overriding TableListField_Item on TableListField by setting the property itemClass ### API Changes * [rev:101155] Add option for DataObjectDecorator::onAfterSkippedWrite() * [rev:101137] Partial cache adjustments - now supports nested cache blocks (which are independant of their containing cache block), conditionals to control if a given cache block is active, and includes hash of template code in key (so template changes mean cache is invalidated). Changes template control for cache block to `<% cached %>`, to which the now deprecated `<% cacheblock %>` is aliased, and an additional template control `<% uncached %>` has been added. * [rev:101127] Added SiteTree::VirtualPages() and SiteTree::DependentPages() accessors. * [rev:101119] Allow on_db_reset() methods on DataObjects as well as DataObjectDecortators * [rev:101093] Replaced eval based creation of extension and field objects with Object::create_from_string(). * [rev:101093] Introduced new function Object::create_from_string() to instantiate an object from a string like 'Int(50)' * [rev:101044] Made MySQL fulltext search optional, activated with MySQLFulltextSearchable::enable() * [rev:101043] Pass the full extension string as the 2nd argument to DataObjectDecorator::extraStatics() * [rev:100842] Upgraded jQuery UI from v1.6rc1 (r687) to v1.8rc3. This release prefixes all *.js and *.css files with 'jquery', so ui.core.js is now called jquery.ui.core.js. * [rev:100842] Upgraded jQuery UI themes from v1.6rc1 to v1.8rc3. Removed 'flora' and 'default' themes, replaced with the 'base' and 'smoothness' themes found in the default distribution * [rev:100718] Removed "auto-merging" of member records from Member->onBeforeWrite() due to security reasons - please use DataObject->merge() explicitly if this is desired behaviour (from r100705) * [rev:100651] dbDataType function created * [rev:100513] Refactored Requirements to use Requirements_Backend at all times - this makes testing far easier. Thanks tobych! * [rev:100512] TreeDropdownField no longer requires your object to have the Hierarchy extension * [rev:100503] Removed deprecated Email_Template class, please use Email instead! * [rev:100498] Removed deprecated Image::loadUploaded() (deprecated from the parent::loadUploaded for which it called), please use Upload directly instead! * [rev:100495] Removed deprecated File::loadUploaded(), please use Upload directly instead! * [rev:100493] Removed deprecated function RootURLController::get_homepage_urlsegment(), please use RootURLController::get_homepage_link() instead! * [rev:100492] Removed deprecated function SiteTree::get_by_url(), please use SiteTree::get_by_link() instead! * [rev:100490] Removed deprecated methods DataObjectSet::filter_map() and DataObjectSet::map_multiple() - please use map() instead! * [rev:100057] #5107 Upload now uses Upload_Validator to separate the validation rules from the File loading done in the Upload class * [rev:99849] SiteTree::validURLSegment extendable (#5907) * [rev:99360] Date/time parsing in DateField, TimeField and DatetimeField defaults to i18n::get_locale() ('en_US') instead of using en_NZ/en_GB specific parsing. Use i18n::set_locale('en_NZ') in mysite/_config.php to revert to old behaviour. * [rev:99360] $timeformat constructor parameter in TimeField needs to be in ISO date notation (not PHP's date()) * [rev:99360] TimeField, DateField and related subclasses use Zend_Date for date parsing, meaning they're stricer than the previously used strtotime() * [rev:99360] Removed DMYCalendarDateField and CalendarDateField, use DateField with setConfig('showcalendar') * [rev:99360] Removed CompositeDateField, DMYDateField, use DateField with setConfig('dmyfields') * [rev:99360] Removed DropdownTimeField, use TimeField with setConfig('showdropdown') * [rev:99360] Removed PopupDateTimeField, use DatetimeField * [rev:99360] Changed 'date', 'month' and 'year' HTML field names to lowercase in DMYDateField * [rev:99360] Removed support for ambiguous date formats in DateField, e.g. '06/03/03'. Use DateField->setConfig('dateformat', `<format>`) to revert to this behaviour. * [rev:99360] Removed $futureOnly flag from DateField, CalendarDateField etc., use DateField->setConfig('min') and DateField->setConfig('max') * [rev:99119] Refactor Versioned so a single state is kept for stage, archived date, or any module specific reading modes (from r98161) * [rev:99114] Use the same navigator items in the CMS that are used on the frontend (from r97395) * [rev:99079] Use the same navigator items in the CMS that are used on the frontend (from r97395) * [rev:99063] Let sitetree extensions prepopulate permisson cache for their own permissions. (from r98650) * [rev:99051] Let any DataObjectDecorator define an on_db_reset() method that is called by tests, like in Versioned. (from r97734) * [rev:98786] Installer now uses a database configuration helper class which isolates the logic of checking the database away from the installer, this interface can be used by other databases like MSSQL and PostgreSQL. The installer now looks for a specific file inside each database module, provided it's configured in install.php MySQL is provided by default, as it lives in sapphire * [rev:98543] Made ComplexTableField not use Object::create() for item and popup classes to be consistent with TableListField. These can be overridden as itemClass and popupClass are public properties on ComplexTableField * [rev:98373] HTTP::setGetVar() always returns absolute URLs. Use Director::makeRelative() to make them relative again. * [rev:98373] HTTP::setGetVar() combines any GET parameters in PHP array notation (e.g. "foo[bar]=val") instead of replacing the whole array ### Bugfixes * [rev:101175] Fixed quotes around Folder::hasChildFolders() ParentID column * [rev:101173] Don't run click() on all inputs, but input:radio only * [rev:101171] Pass correct class to allowPrimaryKeyEditing in yaml fixture * [rev:101170] Don't recreate a missing draft page when calling SiteTree::doUnpublish() * [rev:101167] #5216 Installer has issues with click handlers applied to the entire li, be more specific and apply it to the label and input instead * [rev:101165] Fixed versioning of pages * [rev:101155] Prevent failed migrateVersion writes from breaking versioning system in future writes. * [rev:101155] MAke site tree pages go green when you save a new draft. * [rev:101154] #5214 ViewableData::obj() was creating a DBField without a fieldname argument and caused problems, one example is the version panel of the CMS * [rev:101153] Ensure that Versioned works on classes with underscores in the names. (from r100905) * [rev:101138] Fixed issues with broekn link tracking * [rev:101131] Allow classes to be referred to with casing that differs from their definition. * [rev:101129] Fixed FileLinkTrackingTest to cope with the empty alt="" and title="" attributes that are created * [rev:101127] Improved reliabilty of broken link tracking. * [rev:101127] Don't mark a page as changed on stage if the only thing that has changed is broken link metadata * [rev:101116] Flush cache after deleting an item. * [rev:101116] Fixed databaseFieldsOnly version of DataObject::getChangedFields() * [rev:101112] Fixed bugs with copying custom fields into Virtual pages, generally made virtual pages more robust and performant. * [rev:101110] Fixed link rewriting to work on other HTMLText fields (from r99517) * [rev:101109] Return true if SiteTree:doUnpublish() succeeds. (from r99515) * [rev:101105] Update Object::parse_class_spec() to handle arrays. * [rev:101099] call_user_func_array changed to PHP 5.1 compatible notation * [rev:101087] #5202 Installer now properly populates database configuration inputs from request after user clicks "Re-check requirements" * [rev:101080] Fixed TableListField->print() - was unsetting $cachedSourceItems instead of null'ing it, which breaks later access to the property * [rev:101068] #5199 Duplicate file uploads have odd numbering attached to end of file * [rev:101061] Fixed Upload and checking for size with files that don't have any extension * [rev:101051] Allow files with no extensions by setting File::$allowed_extensions with an empty string * [rev:101050] #5188 Upload and Folder don't handle the duplicate naming of files that have no extension * [rev:101046] Cookies set to a value other than NULL (effectively unsetting the cookie) will now use the httpOnly parameter by default for better XSS protection (from r101045) * [rev:101034] Fix static caching file lookup to match file generation. * [rev:101005] Image should pass through the title to Image_Cached so that Image::getTag() can produce a more useful alt attribute instead of just the filename (from r101003) * [rev:100998] column and table names now quoted properly * [rev:100986] Disable javascript date validation via DateField->jsValidation() if locale is not 'en_NZ" (which is the only format it validates for). * [rev:100985] HTMLEditorField->saveInto() can now find images with urlencoded information for resample (e.g. spaces in filenames) * [rev:100982] Fixed file-write testing issues in requirements combined file generation * [rev:100980] Remove cache for Hierarchy::AllChildren() and Hierarchy::AllChildrenIncludingDeleted(), since they increase memory usage unnecessarily. * [rev:100979] Don't make CMS loading slow if the combined javascript files can't be written. * [rev:100932] SiteTree::getSiteConfig() should always fall back to using a default if an alternate config wasn't found * [rev:100924] Allow DatabaseAdmin to run dev/build in live mode when not Security::is_database_ready(), and avoid broken login due to broken db queries (selecting unknown columns before dev/build) (see #4957) * [rev:100921] DataObject::hasValue() is now compatible with parent ViewableData::hasValue() (this also fixes E_STRICT standards in PHP) * [rev:100919] RequestHandler::handleRequest is now compatible with Controller::handleRequest in that SS_HTTPRequest is the type hint for the $request parameter * [rev:100918] ManifestBuilder::up_children() should be declared as static as it's called statically * [rev:100904] Produce XHTML compliant URLs in HTTP::setGetVar() by default (regression from r98373, see #5101) * [rev:100896] #5138: DataObjectSet::removeDuplicates() removes objects of different classes with the same ID * [rev:100866] #5176 Javascript error in IE for the installer - use "this" instead of e.target which doesn't work * [rev:100862] Use "wb" argument in ManifestBuilder fopen() calls for better cross-platform compatibility * [rev:100861] #5157 If paths are longer than 255 characters, fopen() produces an "Invalid argument" error, shorten the paths by using basename() instead of realpath() on the manifest filename when producing the cache path in ManifestBuilder * [rev:100858] Fixed notice level error with folder ID * [rev:100854] fixed file uploading not uploading any files at all * [rev:100853] Fixed jQuery.ondemand.js script to work with prototype.js (will probably need to be merged back to trunk for legacy purposes) * [rev:100848] Fixed variable declaration order in tabstrip.js (necessary due to changed jquery.livequery behaviour * [rev:100825] Added single quote as a valid local-part of an email address as per RFC5322. Other symbols still excluded although in the spec * [rev:100795] #5157 strftime() %F format parameter does not work on Windows - use %Y-%m-%d instead * [rev:100767] Date::now() supplies wrong string - it misses leading zeroes on hours * [rev:100763] added uniqueness id, to prevet multiple VirtuaLage reloads on publish * [rev:100755] TreeSelectorField doubles up on concating base_url, doesn't include the security ID (#5164, thanks marcus) * [rev:100747] #5099 FileIFrameField fails when using it with a locale different to the default * [rev:100727] allow selection of database adpater * [rev:100726] misspelled variable * [rev:100724] some sections dont have a tree at all, but they still use LeftAndMain as their base class (eg report admin). Added a guard. * [rev:100723] Fixed SapphireTest->loginWithPermission() and MemberAuthenticatorTest to use existing Members based on their unique_identifier_field (if existing) to accommodate recent Member->onBeforeWrite() changes (see r100705) * [rev:100722] reload page if broken link tracking values changed during a save. Ticket #1363 * [rev:100721] Unsetting 'ID' parameter in MemberTableField->addtogroup() to avoid confusion between Group and Member records (regression from r100716) (from r100720) * [rev:100719] Fixed MemberTableField->addtogroup() to fetch existing Member records by ID or $unique_identifier_field instead of relying on the (now removed) "auto-merging" in Member->onBeforeWrite() (see r100705) (from r100716) * [rev:100717] Fixing Member_ProfileForm to validate for existing members via Member_Validator to avoid CMS users to switch to another existing user account by using their email address (from r100704) * [rev:100701] moving the ajaxupdatesort JS response code from php to js to get rid of eval. Also disable the "loading" on the moved element when we are done, in case we are repositioning other than the selected item - otherwise the progress indicator is displayed indefinitely. * [rev:100699] column names quoted properly * [rev:100693] column names quoted properly * [rev:100692] column names quoted properly * [rev:100691] column names quoted properly * [rev:100690] column names quoted properly * [rev:100689] column name capitalised * [rev:100688] column names quoted properly * [rev:100687] column names quoted properly * [rev:100686] the default value for decimals are now cast as (doubles) * [rev:100657] tables and columns now quoted properly * [rev:100632] Fixed SiteTree->MetaTags() to either use `<meta name=>` or `<meta http-equiv=>`, and only using the "http-equiv" attribute for valid HTTP headers (see http://www.w3.org/TR/html4/struct/global.html#edef-META) (from r100631) * [rev:100627] DB::getConnect() should be properly declared as a static function * [rev:100616] Fixed filemtime() check in Requirements_Backend::process_combined_files() not getting the right path * [rev:100614] Proper check for combined file path in Requirements_Backend::process_combined_files() * [rev:100560] #4572 Fixed Windows failure on SS_Cli::supports_colour() because posix functions are not supported * [rev:100548] If fixture file is NULL don't cause the test framework to break down because of it * [rev:100527] Set Member default Locale * [rev:100525] get TreeMultiselectField working with an array of items, rather than a relation. * [rev:100519] add 'var' to local variable 'constructor' inside of function definition which break IE8 (8.0.6001.18702 +) * [rev:100508] wrong constructor function name * [rev:100496] replacing calls to deprecated Upload functions - using validator instead (related to r100057) * [rev:100466] #5012 BasicAuth should check if there's already a current member logged in before asking for a login/password * [rev:100438] GD::setQuality() persistence issue because the GD instance is re-created instead of being cloned - thanks Tjofras! * [rev:100417] #5121 Fixed cache flushing for FieldSet when removing fields - thanks paradigmincarnate! * [rev:100415] #5136 Ensure $coverage argument to TestRunner::runTests() has a strict check before running coverage tests, as sometimes an SS_HTTPRequest object can be passed into this argument * [rev:100407] FormAction input tag attributes were being doubly-escaped. * [rev:100406] Fix mismatch with $all_locales and $common_locales (#5096) * [rev:100394] #5135 LeftAndMain extra requirements loading for "themedcss" should use Requirements::themedCSS() not Requirements::css() - thanks Hamish! * [rev:100393] YamlFixture::writeDataObject() - some databases need special allowance to edit the primary key column - do so by using DB::getConn()->allowPrimaryKeyEditing() * [rev:100375] Sam's fix for "Unknown column Group.SubsiteID" with new subsites * [rev:100370] use localized prefix to compare group codes rather than hard coded english string. MINOR: updated lang file * [rev:100367] PHP 5.1 requires an array rather than a string for call_user_func() * [rev:100359] Show Language dropdown in English (#5098) * [rev:100335] #5023 AssetAdmin::sync() is now used to sync tasks, as it works when the user only has access to the AssetAdmin controller instead of going to dev/tasks/FilesystemSyncTask which can only be run by administrators or if the site is in dev mode * [rev:100116] Fix TestRunner coverage pattern to work as documented (Fixes QA scripts too) * [rev:100053] SQL Error is a member is not part of any groups * [rev:99993] Setting default $groups in MemberTableField::AddForm() in addition to MemberTableField_Popup::__construct() - this was broken by r99777 * [rev:99960] #2022: Fixed CMS dropdowns in Opera. * [rev:99952] Fix #2138, allow modification of existing images * [rev:99951] Fix #2138, notify Image Toolbar on TinyMCE node selection change * [rev:99942] action buttons always visible (not need to scroll) ticket 5051 * [rev:99942] got rid of double scroll * [rev:99942] do not show action buttons (delete/save) when showing result list * [rev:99887] Use underscores in names of combined .js (#3581) * [rev:99854] Quoting keys in JSONDataFormatter to ensure valid JSON (#5119) (from r99853) * [rev:99850] Fix #5097, Translatable uses augmentValidURLSegment to check that URLSegment is valid * [rev:99843] Respect SilverStripe's cache folder * [rev:99818] Handle filename deduping when uploading of double-barrelled extensions and files ending in numbers better. * [rev:99816] Fixed the code for the unused file list, although the feature is still disabled. * [rev:99789] #5073: Fixed CMS version indicator for alpha and beta versions. * [rev:99779] make siteconfig work again * [rev:99777] #5087: Show default values in CTF 'add' popups. * [rev:99745] #3458: Don't show javascript:mctmp(0) URLs in URL editor * [rev:99739] tree selector base URL calculation wrong when field is nested * [rev:99738] #4974: Improve accuracy of ManifestBuilder::parse_file() cache, to remove a source of upgrade bugs. * [rev:99713] Fixed MemberTableField limiting of , wasnt taking children groups into account (regression from r99684) (from r99706) * [rev:99711] Setting ID explicitly in MemberTableField-> to ensure getCsvQuery() correctly filters (the custom group filter was only implemented in sourceItems() before) (from r99684) * [rev:99693] Changed sitetree default selection in LeftAndMain.Tree.js to fire on window.load instead of document.ready() through entwine. We need to ensure behaviour.js bindings are available before * [rev:99693] Automatically selecting root node in CMS trees (necessary because now we actually have forms on the root node, and its a valid click target) (from r99605) * [rev:99679] really testing deletemarked now. * [rev:99667] Fixed bogus HTMLEditorConfig instance when get() is called without a valid identifier (due to NULL database columns) (from r99599) * [rev:99655] Fixed TreeMultiselectField/TreeDropdownField saving with 'unchanged' default values from constructor (from r99581) * [rev:99647] Fixed TreeMultiselectField->Field() to respect settings, and give them priority over existing relations through getItems(). This is used in MemberTableField to set default groups for 'add member' popups. (from r98879) * [rev:99640] Fixed DataObject->fieldLabels() to respect flag (from r98748) * [rev:99638] Folder::findOrMake() will create the assets/ folder if it's missing * [rev:99613] Fixed bug in r99552 * [rev:99595] Fixed Access tab on SiteConfig * [rev:99594] Debugged and simplified Access tab javascript * [rev:99587] Show 'Inherit' option for edit and view all the time (since we now have SiteConfig) * [rev:99572] Pages that you can't edit should always be grey, even if there are unpublished changes. * [rev:99553] Remove buttons from display if you load a CMS page that should have no buttons - reverts bug caused by r96551 and fixes the issue it was trying to solve. * [rev:99552] Fixed behaviour's ID selector matching when the ID is inside another context - eg 'body.className #ID' * [rev:99522] Image::onBeforeDelete() now calls deleteFormattedImages() so resampled images in the filesystem are cleaned up * [rev:99506] use the correct method for retrieving the report ID * [rev:99490] tablename and columns quoted properly * [rev:99479] Setting ID = -1 on Security/lostpassword to avoid showing toplevel navigation (see #5086) * [rev:99465] Correct StaticPublisher filenames, now works with nested URLS * [rev:99443] batch_permission_check returns null rather than empty array when user has no permissions * [rev:99394] Fixed variable existence checks in setValue() in FormField::__construct() by checking for !== NULL (changed from isset($value) to $value in r99360) * [rev:99391] Fixed MoneyField constructor - parent (FormField) constructor calls setValue() already, which needs to happen *after* setting certain field instances * [rev:99342] Enforcing creation of temp database in SapphireTest->setUp() to avoid writing to production databases. This check should only kick in for single test case runs, as the temp database connection should be set in a dev/tests/all run after the first db-related test anyway. (see #5034) * [rev:99303] Disable some permission caching for now, as it was breaking unit tests (from r98504) * [rev:99302] SiteTree::batch_permission_check() doesn't recurse with ID=0 calls * [rev:99128] Fix not being able to print/export reports (from r98684) * [rev:99125] Fixed cache prepopulation on sitetree load. (from r98651) * [rev:99124] Make sure navigation links update when urlsegment is changed (from r98649) * [rev:99116] Fix navigator links not opening in new windows. (from r97510) * [rev:99115] Fixed bug in r97395 (from r97508) * [rev:99101] Take into account tablename with custom columns in get_title_sql (from r97003) * [rev:99100] use proper quotes for sep (from r96401) * [rev:99089] Only show live link when page has been published (from r97839) * [rev:99087] Make sure draft/published links go to the right subsite (from r97747) * [rev:99086] Fix navigator links not opening in new windows. (from r97510) * [rev:99085] Show a hand icon and better title for the 'share link' piece of the navigator toolbar. (from r97439) * [rev:99067] Ensure that ModelAsController::init() can trigger redirections. (from r98702) * [rev:99065] Fixed SiteTree_versions version numbers for published virtual pages. (from r98675) * [rev:99060] fixed query to get number of unmoderated comments * [rev:99052] Generate SiteTree_version records for VirtualPages more reliably. (from r98309) * [rev:99050] fix incorrect link in CMS (from r97408) * [rev:99049] Make sure CMS link knows when its currently in the CMS (from r97403) * [rev:99031] Don't show FailedLoginCount field unless Member::$lock_out_after_incorrect_logins is enabled * [rev:99005] Development server list should be retained when user submits installer form and gets redirected back * [rev:98957] fix for #5076 * [rev:98946] the ID should be that of untranslated child (it's the middle segment that's from translated version, not the last one) * [rev:98944] testing framework needs to be reset to a clean state after each test: now also nested urls and redirection state will be reverted * [rev:98897] Fixed strpos() check in BASE_URL check * [rev:98895] Installer now opens if mod_rewrite is disabled. Using index.php instead of rewriting the URL didn't quite work with the new BASE_URL, so we need to take this case into account as well * [rev:98869] Fixed big problem on Windows when redirecting to install.php - because of SCRIPT_NAME backslashes caused a bit of havoc and need special treatment * [rev:98860] restore the original nested_urls state after running the test, so we can enable and disable nested URLs within the tests safely. * [rev:98853] Fixed URL generation in TreeSelectorField.js, was failing to detect relative URLs - prefixing with `<base>` URL as a workaround * [rev:98852] Added missing Requirements to TreeDropdownField->Field() and TreeMultiSelect->Field() * [rev:98847] modified float to have the same database table schema as int. Now defaults to zero and 'not null' * [rev:98777] Fixed quoting on ContentController::successfullyinstaller() - this broke certain databases like PostgreSQL * [rev:98776] #5053 Aggregate::query() should not set an orderby clause, otherwise databases will complain * [rev:98694] columns quoted properly * [rev:98693] Fixed ManifestBuilder::has_been_included() * [rev:98690] Closing TinyMCE image, link or flash panel when loading form (ticket #4907) * [rev:98688] Checkbox for overriding the install from environment now checks for the file existance properly * [rev:98678] Fixed initial state of "use environment" checkbox in installer * [rev:98671] fallback for changes in r98101, required if TreeDropdownField is used in a widgetarea, and does not know its field * [rev:98537] Fixed ManifestBuilder::get_themes() not to assume an existing themes/ folder * [rev:98536] Removed obsolete start argument from ComplexTableField_Item constructor. * [rev:98534] Make Security/login page's ID give a different number for loggedin vs loggedout, to help with partial caching * [rev:98520] Fix virtual pages not returning correct content * [rev:98448] Fixed missing third argument to ComplexTableField_Item when the parent class instantiates it * [rev:98434] Fixed infinite loop in FILE_TO_URL_MAPPING lookup when calling arbitrary scripts via CLI * [rev:98432] Make login form work without any theme loaded. * [rev:98403] Fixed Hierarchy->loadDescendantIdList() to call setOwner() on the extension instance. This was necessary due to underlying Object/Extension changes in 2.4. * [rev:98382] #5044 Hierarchy::loadDescendantIDListInto() now uses Object::getExtensionInstance('Hierarchy') instead of going through __call(), as PHP 5.3 has issues converting references to values * [rev:98373] HTTP::setGetVar() uses parse_url() and http_build_query() to add query parameters to an existing URL, instead of doing its own regex-based parsing. This means existing GET parameters are correctly url encoded. * [rev:98324] Fixed ContentController->deleteinstallfiles (added to $allowed_actions, see #5040) ### Minor changes * [rev:101172] Fix output format of buildbot test runs to not include colour control codes. * [rev:101166] versioning test for SiteTree * [rev:101135] Fixed multifile.js non-standard forEach() reference, using jQuery.each() instead * [rev:101134] Localized "dependent pages" features in SiteTree->getCMSFields() * [rev:101132] Fixed test that was relying on bug fixed in r101116 * [rev:101117] Fixed test that was relying on bug fixed in r101116 * [rev:101111] Fixed wrong default value for AssetAdmin (see r101106) * [rev:101107] Documentation relating to r101106 * [rev:101106] Disabled metadata upload in AssetAdmin by default, configurable through AssetAdmin::$metadata_upload_enabled. Feature needs UI review. * [rev:101091] Use castingHelper() rather than castingHelperPair() to look for a field presence. * [rev:101076] Fixed merge error from r99117 * [rev:101071] Updated lang files * [rev:101070] Fixed PermissionCheckboxSetField.js checkbox toggling when no previous values have been saved through jQuery.data() * [rev:101062] Fixed permission language code regression * [rev:101057] Improved wording of SQLite installer * [rev:101055] No need for a ternary for in_array check in Upload::isValidExtension() * [rev:101053] Update function doc for Upload::isValidExtension() * [rev:101052] phpDoc change for Upload * [rev:101025] tests can now require default records on classes * [rev:100992] Removed unused variable in SiteTree::MetaTags() * [rev:100991] UploadTest now cleans up after itself when it creates a custom folder relative to assets * [rev:100990] Added tests for Upload_Validator/UploadTest_Validator for allowed extensions validation * [rev:100988] Updated required version to 5.1 in php5-required template * [rev:100978] Removed whitespace from "Development servers" textarea for installer * [rev:100975] Updated r100966 to include spaces on ternary operator for readability and coding conventions * [rev:100974] Adjusted CMSMain->getRootForm() to SiteConfig API changes * [rev:100967] Renamed SiteTree->getEditFormFields() to getCMSFields() (including new decorator hook for 'updateCMSFields'). Renamed SiteTree->getEditFormActions() to getCMSActions() (including new decorator hook for 'updateCMSActions'). Old API was never released * [rev:100965] Fixed "disabled" styling for database options in config-form.html (showed all as green when "use _ss_environment" was ticked * [rev:100950] Correction on email address validator, and a unit test for EmailField php validation * [rev:100946] Added jQuery requirement to TreeDropdownField (see #5139) * [rev:100940] Changed `<div>` hierarchy in config-form.html to allow right-aligned help texts which horizontically align with their respective field sets on the left. * [rev:100922] Fixed phpDoc argument in ViewableData::hasValue() * [rev:100898] Changed the way DatabaseAdapterRegistry accepts databases * [rev:100893] Updated languages in cms from translate.silverstripe.org * [rev:100892] Updated languages in cms from translate.silverstripe.org * [rev:100891] Updated sapphire/ lang files * [rev:100890] Updated cms/ lang files * [rev:100888] Using jquery.live instead of livequery in MemberImportForm.js * [rev:100887] Using jquery.live and behaviour.js instead of livequery in ModelAdmin.js * [rev:100886] Using jquery.live instead of livequery on ImageFormAction.js * [rev:100885] Using Behaviour.register instead of jquery.livequery in TabSet.php/tabstrip.js (already replaced with jQuery.entwine in next release, we try to reduce the dependencies to jquery plugins) * [rev:100883] SilverStripeNavigator.js used jquery.live instead of livequery, and doesn't include unnecessary behaviour.js * [rev:100851] Fixed jquery-ui paths in FileIframeField * [rev:100850] Fixed jQuery selector in TreeSelectorField.js to fit jQuery 1.4 syntax * [rev:100843] Added jQuery UI license files * [rev:100832] Supress notice if $_REQUEST['url'] doesn't exist in Debug::showError() * [rev:100801] removed sqlite msg * [rev:100799] Moved Permission->requireDefaultRecords() to Group->requireDefaultRecords() and Member->requireDefaultRecords(). * [rev:100799] Removed outdated checks for CanCMS and CanCMSAdmin from Permission->requireDefaultRecords() * [rev:100791] Using PermissionCheckboxSetField.js instead of MemberTableField.js * [rev:100790] Moved PermissionCheckboxSetField specific javascript logic from MemberTableField.js to new sapphire/javascript/PermissionCheckboxSetField.js file * [rev:100789] Improved help texts around permissions * [rev:100784] Improved help texts around permissions * [rev:100783] Improved help texts around permissions * [rev:100775] Fixed regression from r100774 * [rev:100774] Added getParentController() to TableListField_ItemRequest and ComplexTableField_Popup * [rev:100774] Extending ComplexTableField_ItemRequest from TableListField_ItemRequest to avoid redundant code * [rev:100772] dont copy embargo or expiry to virtual page * [rev:100771] Setting PermissionRole $singular_name and $plural_name * [rev:100770] Removed "only advanced users" notice in Group->getCMSFields() - this field is now sufficiently useable for all admins with access to admin/security without knowing about permission codes * [rev:100740] Added more allowed extensions to File::$allowed_extensions * [rev:100732] make cache header clearer * [rev:100697] remove the sqlite databases from the installer list. * [rev:100670] Director::currentPage() is deprecated but shouldn't throw a notice-level error until the next major release. * [rev:100669] Added note about other databases * [rev:100626] BasicAuth - removed unncessary extending of Object since this class only has a bunch of static functions * [rev:100625] Cookie - removed unncessary extending of Object since this class only has a bunch of static functions * [rev:100624] Convert - removed unncessary extending of Object since this class only has a bunch of static functions * [rev:100623] ArrayLib - removed unncessary extending of Object since this class only has a bunch of static functions * [rev:100622] When the installer is using the environment for configuration, disable the development servers textarea as it's automatically configured from environment * [rev:100618] Removed double slashes from path in Requirements_Backend::process_combined_files() * [rev:100615] Requirements_Backend::process_combined_files() only needs one location where the combined file is * [rev:100552] Wording change in installer for database details not correct * [rev:100550] Fixed undefined variable $error in MySQLDatabaseConfigurationHelper * [rev:100537] Removed underscores from combined files in LeftAndMain, made redundant by r100536 * [rev:100534] Reverted default location for combined JS/CSS as you can't customise this easily * [rev:100533] Removed Requirements:: static call and replace with instance * [rev:100530] LeftAndMain combined files don't need to be prefixed with "assets" because default combined folder is set in sapphire/_config.php * [rev:100517] Removed whitespace * [rev:100514] Removed end php tag for Requirements and RequirementsTest * [rev:100513] Updated RequirementsTest to test Requirements_Backend instead of global statics * [rev:100511] can always create top level if admin * [rev:100499] Made Upload::load() error more useful * [rev:100491] Fixed tabbing in DataObjectSet * [rev:100487] Changed places of Object::extInstance() to Object::getExtensionInstance() and added a notice if extInstance is used in future * [rev:100486] Pushed @deprecated 2.3 items out to 2.5 since they're still in use for now * [rev:100485] Reverted r100484 as it was causing too many problems * [rev:100484] Replaced locations of Director::is_ajax() and Director::redirectBack() with instance method calls - the latter static function is deprecated * [rev:100483] Changed @deprecated note for Director::redirectBack to 2.5 as it's still widely used * [rev:100461] Fixed regression of Convert::json2obj() not working when json_decode() is being used * [rev:100424] phpDoc bits for Convert Services_JSON functions * [rev:100423] Added unit tests for Convert JSON functions * [rev:100418] Use "email" instead of username for validation of admin account during install * [rev:100409] Geoip class no longer extends Object, as it's not necessary * [rev:100387] Updated installer to use "CMS / Framework" instead of just "CMS" * [rev:100387] Updated copyright year to current year * [rev:100372] added lang file for cs_CZ * [rev:100360] add extendability to SecurityAdmin * [rev:100323] correct order of OBW * [rev:100032] added Rfc2822 method to SS_Datetime. Fixed bug where dates in DataObject would not set times. * [rev:100008] LastEdited/Created dates are now mockable via SS_Datetime * [rev:99957] Reverted r99843 - we're not modifying thirdparty dependencies * [rev:99862] Reinstated UploadTest * [rev:99823] Reverted r99522 as this will cause problems if File records are deleted when the resampled images are linked to in the content fields * [rev:99801] Added Group->CMSTreeClasses() (required for GroupCsvBulkLoader refresh in SecurityAdmin) * [rev:99753] Cleaned up tabbing and code formatting in automated task classes * [rev:99750] More tests for array data * [rev:99715] Fixed OptionsetField->disabledItems omission from r99596 (from r99708) * [rev:99714] Fixed MemberTableField regression from r99706 (from r99710) * [rev:99689] Fixed height of MemberTableField 'Groups' tab to allow enough room for TreeMultiSelectField expansion (from r98883) * [rev:99687] Moved generic .TreeDropdownField styling from cms/css/cms_right.css to sapphire/css/TreeDropdownField.css (from r98881) * [rev:99686] Moved ul.tree rules from cms/css/cms_left.css to sapphire/javascript/tree/tree.css (particularly around multiselect tickbox styling) (see r98854) (merged from r98855) (from r98865) * [rev:99668] Placing 'ADMIN' permission in new 'Administrator' group at the top of the permissions list (from r99601) * [rev:99663] Localized strings in PermissionCheckboxSetField (from r99590) * [rev:99660] Re-adding support for Group and PermissionRole records in PermissionCheckboxSetField * [rev:99657] Using localized titles for permission formfields in PermissionRole and Member (from r99583) * [rev:99656] Using TreeMultiselectField instead of MemberTableField->relationAutoSetting in Group->getCMSFields() (from r99582) * [rev:99654] Added ComponentSetTest (from r99580) * [rev:99646] Moved generic .TreeDropdownField styling from cms/css/cms_right.css to sapphire/css/TreeDropdownField.css * [rev:99646] Fixed .TreeDropdownField styling (borders and margins) in TreeDropdownField.css (was assumed to be inherited from LeftAndMain/CMS stylesheets) (from r98878) * [rev:99645] Added MemberCsvBulkLoaderTest->testCleartextPasswordsAreHashedWithDefaultAlgo() (from r98841) * [rev:99644] Allow custom TitleText on TableListField_Item.ss (e.g. to show a description of the 'delete' button) (from r98828) * [rev:99641] Setting new 'inlineadd' permissions on MemberTableField instance in Group->getCMSFields() (from r98827) * [rev:99497] add pass thru group and sort methods * [rev:99492] Fixed SapphireTest->logInWithPermission() spelling * [rev:99491] Fixed SapphireTest->logInWithPermission() spelling * [rev:99363] Using DateField in CMSMain->SiteTreeFilterDateField(), as CalendarDateField is now deprecated * [rev:99362] Moved cms specific styling in CalendarDateField.css to cms/css/cms_right.css * [rev:99359] Moved cms specific styling in CalendarDateField.css to cms/css/cms_right.css * [rev:99350] Temporarily disabled nested url specific cases inTranslatableTest->testAlternateGetByLink(), unclear functionality requirements * [rev:99347] Fixed FilesystemPublisherTest to have self-contained extension settings, and not rely on static publishing being enable in mysite/_config.php already. Fixed login permissions for doPublish() calls in test case. * [rev:99178] Moved timezone coupling in SS_Report labels into timezoneawareness module * [rev:99137] Localized reports * [rev:99130] Fixed merge error (see r99114) * [rev:99127] Bugfix in previous commit (from r98660) * [rev:99126] refactored setting/getting strict hierarchy setting. (from r98654) * [rev:99123] don't load a report by default (from r98561) * [rev:99122] don't remember what report you had selected in ReportAdmin (from r98560) * [rev:99121] more unit tests around loose hierarchy (from r98509) * [rev:99120] added LiveURLSegment to ignored field in change detection (from r98494) * [rev:99118] fixed two reports with links that did not open in new windows (from r97816) * [rev:99113] add the ability to link-check the live table too (from r89473) (from r95310) * [rev:99112] pingStatus ping frequency reduced * [rev:99112] updated lang file for SiteConfig * [rev:99112] improved documentation in StaticPublisher * [rev:99112] improved documentation in CMSMain surrounding reports and siteconfig * [rev:99112] migrated headers in SiteConfig to i18n'd (from r86429) * [rev:99111] Localized File->uploadMetadataFields() * [rev:99110] Documentation * [rev:99099] ability to customize the text that comes out of Member->Title * [rev:99099] updated workflow reports (from r96352) * [rev:99098] Added Requirements for SilverStripeNavigator (see r99080) * [rev:99097] Added Requirements for SilverStripeNavigator (see r99080) * [rev:99081] Partially reverted r99079 - SiteTree->getNavigatorItems() was refactored to SilverStripeNavigator::get_for_record() * [rev:99076] make static caching smarter around cacheSubdirs * [rev:99068] adjustments to ensure that the cached permissions were actually hit (from r98835) * [rev:99064] refactored setting/getting strict hierarchy setting. (from r98654) * [rev:99062] more unit tests around loose hierarchy (from r98509) * [rev:99059] added enforce_strict_hierarchy option, and tests around not cascading deletions (from r98498) * [rev:99057] reload the virtual page if you are looking at the current one on save. To prevent overwriting fields (from r98496) * [rev:99009] force a specific cache subdirectory * [rev:99008] disable real-time static publishing * [rev:98980] fix typo * [rev:98898] Added brackets around strpos() check just to be sure it works * [rev:98872] Fixed clearing issue in installer that was recently removed * [rev:98855] Moved ul.tree rules from cms/css/cms_left.css to sapphire/javascript/tree/tree.css (particularly around multiselect tickbox styling) (see r98854) * [rev:98854] Moved ul.tree rules from cms/css/cms_left.css to sapphire/javascript/tree/tree.css (particularly around multiselect tickbox styling) * [rev:98800] Removed return of connection and changed variables to conincide with r98795 * [rev:98792] Removed whitespace in textarea value that caused an empty string in the development servers list in installer (regression from recent change) * [rev:98781] Styling on installer * [rev:98733] Defensive scripting in LeftAndMain.Tree.js (merged from r98709) * [rev:98713] Re-enabled CsvBulkloaderTest cases, were disabled by accident (merged from r94250) * [rev:98679] Reverted broken variables in installer for checking environment * [rev:98670] Install template cleanup * [rev:98668] Styling for help text in the installer * [rev:98667] Styling fixes for installer * [rev:98666] Tidy up of install template * [rev:98662] Changed config-form to HTML 4.01 and validated the page minus a few issues with the form field placement * [rev:98643] disable form fields if they are set from _ss_environment. See #5054 * [rev:98544] Removed useless third argument to instantiation of itemClass in TableListField::generateExportFileData() * [rev:98538] Fixed caching of login page for tests * [rev:98519] Renamed manifest test temp dir as there was some kind of conflict * [rev:98480] Removed double brackets from Diff::cleanHTML() * [rev:98477] Fix documentation for Diff::cleanHTML * [rev:98433] Speed up cache test (1s is as good a test expiry as 8s) * [rev:98427] Fixed SiteTreeBacklinksTest on Windows * [rev:98409] Fixed HTTPTest->testSetGetVar() * [rev:98407] Fixed HTTPTest->testSetGetVar() * [rev:98404] Partially reverted r98382 which added unnecessarily defensive checking to Hierarchy->allChildren() * [rev:98403] Fixed HierarchyTest assertions around including grand children counts * [rev:98390] Removed argument to getDescendantIDList() in ThumbnailStripField that doesn't exist on the method * [rev:98383] Fixed HTTPTest when invoked through dev/tests/all or with GET parameters (see r98373) * [rev:98376] Testing of grand-children items in HierarchyTest::testLoadDescendantIDListIntoArray() and HierarchyTest::testNumChildren() * [rev:98372] Documentation * [rev:98370] Fixed test case name in Hierarchy * [rev:98369] Added test case for Hierarchy::getDescendantIDList() which also tests Hierarchy::loadDescendantIDListInto() * [rev:98341] Removed arguments to Hierarchy::getDescendantIDList() calls, as the method does not have any * [rev:98326] Make pass use a password field, dont require call by reference (merged from r72930) * [rev:98321] Use 'b' mode for fopen() where possible for better portability * [rev:98282] fixed setName() ### Other * [rev:99952] via Image panel, and keep proportions when changing size * [rev:99952] in text input boxes. * [rev:99849] Uses $this->extend('augmentValidURLSegment') * [rev:99849] so that (for instance) Translatable can hook this. * [rev:99848] Revert "FEATURE: Use tidied HTML in DataDifferencer" * [rev:99848] * [rev:99848] This reverts commit a0d2f7b3e289d12dedcdbd02ae52eec3e6718340. * [rev:99732] BUFGFIX: Prevent selection of self as parent (see #5106) * [rev:99084] Add missing JS file (from r97410) * [rev:98873] REVERT: reverse merging the change, it breaks some tests.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/rc/2.4.0-rc2.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/rc/2.4.0-rc2.md
11,255
1,758,118,090
en
# 2.4.0-rc2 (2010-04-30) ## Overview * Improved permission handling in the "Security" section: "Access to all CMS sections" not automatically checks all inherited permissions * Fixed usage of file, image and link selection in the CMS with multilingual sites (Translatable) * Fixed core unit tests for PostgreSQL * Fixed a core bug in PostgreSQL concerning the ordering and grouping of DataObjectSet results * Allowing the new "SiteConfig" interface to save TinyMCE content, enabling easier usage of default content which doesn't belong to a single page * Updated api.silverstripe.org to accurately reflect the current API in different releases, with a nightly rebuild to keep it that way ## Changelog ### Features and Enhancements * [rev:103730] use FileSystem class to create cache directory to unsure the right permissions are set * [rev:103710] MemberLoginForm::performLogin() now uses the authenticator_class variable set in subclasses of MemberLoginForm, without having to overload performLogin() * [rev:103708] create cache directory when it does not exist before running the cache build test * [rev:103581] Added i18n::set_default_locale() to set standard locale (which is different from "current locale" retrieved through i18n::get_locale()) * [rev:103466] make the getTree ajax call more generic so it get local from its containing form, rather than hard-coded "Form_EditForm_Locale" cos the field is not only used in "EditForm" * [rev:103465] to make the FileIFrameField and TreeSelectionField easy to use in CMS with Translatable on. * [rev:103328] Automatically checking all "CMS section" checkboxes in PermissionCheckboxSetField.js when "Access to all CMS interfaces" is selected. Saving these permissions individually also resolves certain edge cases like #5438. * [rev:103250] added tests for checking the change password functionality, including the resulting redirection (from #5420) * [rev:103229] allow ChangePasswordForm to redirect to BackURL (from #5420) * [rev:103198] allow onAfterPublish and onBeforePublish handlers directly on Page classes (#5112) * [rev:103047] allow to check for any changed fields on the DataObject, this is expected behaviour when isChanged function is called without parameters (#5421, patch by walec51) * [rev:102899] added language (Ticket #5390) ### API Changes * [rev:103792] changed the modulus offset to 1 to correctly order sets ### Bugfixes * [rev:103803] Rebuilding test database for postgresql in SearchFormTest and TranslatableSearchFormTest to avoid stale index information in the database * [rev:103745] static publisher for a site that resides in a subfolder of webroot * [rev:103734] Fix linkCount .js in AssetAdmin deleteRecord (ticket #5486) * [rev:103706] Use correct quoting for BrokenLinksReport (ticket #5474) * [rev:103674] #5485 PermissionCheckboxSetField javascript would always uncheck all CMS_ACCESS_* permission checkboxes on initialize event * [rev:103620] Fixed ordering by aggregate columns for DataObject::get() calls with joins. * [rev:103613] Fixed unlimitedRowCount() for grouped queries * [rev:103612] Ensure that group by of many-many queries with extraFields is set correctly. * [rev:103591] ModelAsController test failed for projects which do not support nested urls. This fix stores the original configuration and enables 'nested-urls' at the beginning of the tests and reset the state in tearDown. * [rev:103588] #5362: Fixed duplicate removal on DataObject:get() with join argument for all databases. * [rev:103582] Choosing i18n::default_locale() in Member->populateDefaults() instead of "current locale". This fixes a bug where a new member created through admin/security automatically "inherits" the current locale settings of the admin creating it. * [rev:103552] CSSContentParser now reports better errors by using simplexml_load_string() instead of SimpleXMLElement directly * [rev:103519] Prevent duplicate HTML IDs in ModelAdmin * [rev:103518] Fixed redirection in PageCommentInterface to use Link() instead of URLSegment (fixes 4200, thanks ktauber) * [rev:103461] Renamed Nested URLs are automatically redirected to their new location with 301 HTTP status code in ModelAsController/ContentController (fixes #5393, thanks cbarberis) * [rev:103451] Fixed CurrencyField->jsValidation() regex escaping (fixes #5462, thanks mobiusnz) * [rev:103450] DateField with setConfig('dmyfields') now validates TRUE for empty values (fixes #5458) * [rev:103448] Allow EDIT_SITECONFIG permission selection in admin/security (fixes #5459) * [rev:103341] Don't show error when adding default SiteConfig records after upgrading a site. * [rev:103336] Using try/catch in MemberTableField->saveComplexTableField() similiar to parent implementation, which means trying to save a Member duplicate doesn't end up in a fatal error (fixes #5444) * [rev:103255] static publishing now uses the last non-null theme, OR the value defined in StaticPublisher::static_publisher_theme. * [rev:103240] r101093 broke casting of values from the failover object. Add lookup to the failover for casting info, and add test * [rev:103226] made the invalid password message translatable; disallow new blank password (as it makes it impossible to login); Member::checkPassword now returns ValidationResult - handle that properly (#5420, patch submitted by walec51) * [rev:103214] the decorator was not completely removed, which caused trouble for tests running later in the same batch * [rev:103183] default sort column now quoted * [rev:103182] default sort column now quoted * [rev:103127] realtime publishing now enabled by default * [rev:103099] Only replace double slashes in SS_HTTPRequest->__construct() for relative- its a failsafe against wrongly formatted URLs like 'admin//assets' instead of 'admin/assets', but breaks absolute URLs with 'http://' prefix * [rev:103092] disallow numeric actions - numeric array indexes are incorrectly picked up as allowed actions (#5331) * [rev:103083] make the javascript-producing functions behave in the same way. Now they will return a javascript snippet and the caller is responsible for adding it to a FormResponse. Removes the duplication in AJAX response which happened when FormResponse::add has been used before the call to JS helper functions (#5359) * [rev:103037] correct mollom field mapping * [rev:103012] added optional separator for http_build_query in HTTP:setGetVar(). this fixes sorting columns in ModelAdmin (ticket #5325). * [rev:102730] Fixing RquestHandler->checkAccessAction() on PHP 5.2 - ReflectionMethod->class returns inconsisent results in older PHP versions. (see r102003) * [rev:102712] Fixed CTF sorting in ModelAdmin results (was failing because of missing 'ResultAssembly' GET parameters * [rev:102686] Float should always be not null and default 0 in the database * [rev:102545] Using i18n::get_locale() in ContentController->ContentLocale() to ensure the correct locale can be used in templates withouth Translatable enabled (broken in r97207, thanks DesignCity) (from r102544) * [rev:102460] #5316 Float and Double should never try to save NULL as the "null" value * [rev:102436] #5320 ManyManyComplexTableField::getQuery() now uses T-SQL compatible syntax CASE WHEN instead of IF THEN which works in multiple databases as well * [rev:102386] delete from published site never calls canDeleteFromLive(). (via marcus #5364) * [rev:102320] fixed invalid HTML output from page comments template * [rev:102300] SSViewer now allows cli to do a flush on non-dev environments * [rev:102265] Fix Salad tests * [rev:102237] exchanged MySQL CONCAT function with ANSI compliant operator * [rev:102160] allow HTMLEditorFields to save in SiteConfig, fixes #5246 * [rev:102156] fallback to the standard authenticator before throwing user_error as in some cases auth method is not passed back to the login form * [rev:102094] Fixed bug with SiteTree::onBeforeWrite() that broke subsites. * [rev:102084] #5343: Call DataObject::onBeforeWrite only once for SiteTree * [rev:102081] #5337: Allow decoration of DataObject * [rev:102074] Fixed SiteTree::page_type_classes() to exclude 'SiteTree' even if on array position 0 - slight difference in return values from Postgres to MySQL (fixes #5336) * [rev:102072] Logging in with an invalid email returns no error message (fixes #5332, thanks ajshort) ### Minor changes * [rev:103821] Fixed TranslatableSearchFormTest for postgresql (strict type assertions) * [rev:103819] Fixed TranslatableTest for postgresql database driver (mostly ordering issues) * [rev:103818] Fixed CMSMainTest for postgres by not hardcoding fixture IDs * [rev:103799] Removed mysql specific functionality from DataObjectSchemaGenerationTest and moved it to a new MySQLDatabaseTest * [rev:103798] Fixed TranslatableTest for postgresql database driver (mostly ordering issues) * [rev:103787] update unit test for checking whether a DataObject has been changed or not without providing a field name * [rev:103763] Unsetting state in FilesystemPublisherTest (regression from r103745) * [rev:103744] Allowing querystring arguments in sapphire/Makefile * [rev:103692] Restored docblock of SQLQuery::unlimitedRowCount() * [rev:103640] Fixed AggregateTest for MSSQLDatabase (wrong date formatting) * [rev:103606] recache tables if cache is empty * [rev:103558] sort page comment table by Created field - show newest entries first * [rev:103555] added moderation message for non-ajax mode * [rev:103533] Fix to ModelAdmin, part of r103519 * [rev:103520] add more in-line documentation and fix the typo: should => should not * [rev:103515] Database quoting in TreeDropdownField (fixes #5484) * [rev:103485] Documentation * [rev:103398] Fixed phpdoc documentation * [rev:103397] Fixed phpdoc documentation * [rev:103391] Fixed phpdoc documentation (from r103390) * [rev:103388] Fixed phpdoc documentation (from r103385) * [rev:103386] Fixed phpdoc documentation (from r103384) * [rev:103345] Reverted accidental commit of date_default_timezone_set() to Pacific/Auckland (see r89164) * [rev:103337] Returning ValidationResult from Member->onBeforeWrite() to ensure the ValidationException is compatible with MemberTableField (related to r103336) * [rev:103322] Enum DBField class should default to ExactMatchFilter to avoid wrong results with overlapping Enum values in LIKE queries (see #5434) * [rev:103226] typo * [rev:103093] fixed the error message on class conflict (#5439, patch submitted by rorschach) * [rev:102909] Using canView() instead of deprecated can('view') in ContentController * [rev:102901] reverted wrong change * [rev:102518] Fixed undefined variable in SiteTree::can_edit_multiple() (broken in r83442) (from r102516) * [rev:102149] Fixed phpDoc @package and @subpackage for MySQLDatabaseConfigurationHelper * [rev:102077] added abstract datetime helper functions * [rev:102071] Removed unnecessary sapphire/thirdparty/.gitignore, as the directory doesnt contain svn:externals any longer (fixes #5334) * [rev:102045] Fixed spelling mistake in ConfigureFromEnv class documentation {![](_images/./sscreatechangelog --version 2.4.0-rc2 --branch branches/2.4 --stoprevision 102039)}
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/rc/2.4.0-rc1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/rc/2.4.0-rc1.md
12,978
1,758,118,090
en
# 2.4.0-rc1 (2010-04-01) ## Changelog ### Features and Enhancements * [rev:101871] Updated automatic regression tests (Salad) * [rev:101670] RedirectorPage ExternalURL field now defaults to http:// to be consistent with the "Another website" option for HtmlEditorField LinkForm * [rev:101661] tidied up installer process to streamline process. Moved requirements to top and button to bottom and added visual seperation of the individual steps * [rev:101381] refactored requirements section to hide successful tests * [rev:101378] Added links to installation introduction text for sources of help and suggested web hosts * [rev:101246] Improved wording and styling in installer. Added links to server requirements, themes download, tutorial. Decreased vertical space before the "install" button to make it more obvious. * [rev:101127] Added 'Dependent pages' tab to CMS, to show virtuals, redirectors, and backlinks that point to this page. ### API Changes * [rev:102012] Changed MySQLFulltextSearchable class to FulltextSearchable (applies to all databases) * [rev:102003] Disallow methods/actions in RequestHandler->checkAccessAction() which are implemented on parent classes (e.g. ViewableData and Object), unless access is controlled through $allowed_actions. This limits information exposure from getters used in template contexts. * [rev:101833] Allow cached blocks within control and if blocks, as long as that control or if block is contained within an uncached block, not a cached block * [rev:101155] Add option for DataObjectDecorator::onAfterSkippedWrite() * [rev:101137] Partial cache adjustments - now supports nested cache blocks (which are independant of their containing cache block), conditionals to control if a given cache block is active, and includes hash of template code in key (so template changes mean cache is invalidated). Changes template control for cache block to `<% cached %>`, to which the now deprecated `<% cacheblock %>` is aliased, and an additional template control `<% uncached %>` has been added. * [rev:101127] Added SiteTree::VirtualPages() and SiteTree::DependentPages() accessors. ### Bugfixes * [rev:102038] #5255 LeftAndMain should include the correct editor.css file so typography from user selected theme in SiteConfig is shown in TinyMCE * [rev:102026] Fixed SiteTree::page_type_classes() removal of base class (was broken if database driver returned classes in arbitrary order, e.g. in Postgres) * [rev:102004] Prevent handling of controller actions which return $this avoid infinite loops in RequestHandler->handleRequest (thanks Hamish!) * [rev:101975] Resetting image sidepanel fields when opening the panel instead of inserting an image, to avoid losing focus of TinyMCE in IE. Using getBookmark() in TinyMCE to save the original location. (fixes #5263) * [rev:101969] Stop IE6/IE7 from redirecting in admin/assets after deleting multiple folders (fixes #5208) * [rev:101958] Checking for existing redirections in FormResponse::respond (fixes #5208) * [rev:101956] Fixed "object not found" javascript error in SecurityAdmin_right.js when changing group nodes (fixes #5179) * [rev:101939] Ensure that DataObject IDs are numbers and no string equivalents of numbers - 3 not '3' * [rev:101869] Update Salad tests to match behaviour * [rev:101867] #4188 simon_w: Let require tags in templates be conditional * [rev:101866] Recover if a manifestClassParse file doesn't have the necessary content. * [rev:101812] Added allowed_actions to ContentControllerSearchExtension * [rev:101810] #5295: Update CMS site name in LHS via Ajax after siteconfig save. * [rev:101807] fixed undefined error in CTFs. BUGFIX: added action class to actions to allow the popup hook to open links * [rev:101795] keep ModelAdmin from importing data twice * [rev:101794] avoid call to non-object * [rev:101793] preserve the port value if given in HTTP::setGetVar (#5280). BUGFIX: allow username only input rather than user:pass combo. * [rev:101792] disable function re-enabled * [rev:101791] deprecated split function replaced * [rev:101758] fix #5320 * [rev:101747] Always including "Locale" field in Translatable->getCMSFields() regardless of "excluded" page types. Necessary to enable form state serialization for fields like TreeSelectorField on a VirtualPage (fixes #5269) * [rev:101739] Versioned->publish() with $createNewVersion=TRUE now increases version number of in-memory object (fixes #5261) * [rev:101737] RedirectorPage types shouldn't appear in "Pages with no content" side report in the CMS Pages tab * [rev:101724] #5277 Sort of default SiteTree records is now explicitly set to avoid strange ordering set by SiteTree::onBeforeWrite for default records * [rev:101719] Only show "Roles" tab in admin/security if user has APPLY_ROLES permissions (fixes #5258) * [rev:101711] Don't replace "home/" URLSegment in SiteTree->RelativeLink() if Translatable is enabled and the homepage is not on the root level (nested URLs allows you to have homepages called "en/home" and "ru/home") (fixes #5244) * [rev:101668] #5259 RedirectorPage and HtmlEditorField TinyMCE integration now prefixes http:// if no prefix is found * [rev:101657] #5245 Sometimes page records will have a NULL ParentID value, it should be a number even if it's 0 (thanks wrossiter!) * [rev:101638] #5243 Undefined Convert functions in ViewableData replaced with working versions. Thanks benediktb! * [rev:101631] test that the class exists before running subclass tests * [rev:101623] put back into the SSNavigator the archived site link (#5251) * [rev:101608] Explicitly specify the many_many's join table name in the join's ON match statement in ManyManyComplexTableField * [rev:101604] remove the unnecessary DOM manipulation, this is legacy code due to SilverStripeNavigator changes (open #5250) * [rev:101603] the function makes an assumption we are working on Draft site, and breaks if we are not. Rewritten to be stage-independent, as get_version (open #5231) * [rev:101602] IE does not accept TD element without a table, repacking into DIV (open #5228) * [rev:101592] get a object inside transaction block will alway exist * [rev:101554] tables and column quoted properly * [rev:101493] tables and column quoted properly * [rev:101492] results sorted alphabetically for consistency * [rev:101491] results sorted alphabetically for consistency * [rev:101392] HTTP::setGetVar() returns a relative URL if a relative URL is passed, to make behaviour closer to 2.3 * [rev:101380] disabling unused file list as feature is still buggy. * [rev:101375] Fixed closing `</div>` which should have been a `</td>` for dragfile in AssetTableField * [rev:101302] Fixed SiteTree->Content link shortcode parsing introduced in r101093 (#5227) * [rev:101267] #5222 Fixed TreeDropdownField not working on FileIFrameField/ImageField * [rev:101266] Fixed Folder writing by overloading validate() (was inheriting File->validate() which does extension checks) * [rev:101266] Fixed Folder::findOrMake() not to create "new-folder" through File->setName() if using a trailing slash in the path (which causes an empty name). Added FolderTest to verify this. * [rev:101264] Checking for existence of "ShowInMenus" property in Folder->liveChildren() and stageChildren() (#5190) * [rev:101227] Don't delete index.php after successful installation - in ContentController->deleteinstallfiles(). URL routing might rely on it without mod_rewrite. * [rev:101227] Require ADMIN permissions for ContentController->deleteinstallfiles() - together with retaining index.php this removed a vulnerability where unauthenticated users can disrupt mod_rewrite-less URL routing. * [rev:101220] TeamComment table added to dataobjects list * [rev:101189] Make SS_ReportWrapper::sourceRecords()' arguments optional * [rev:101175] Fixed quotes around Folder::hasChildFolders() ParentID column * [rev:101173] Don't run click() on all inputs, but input:radio only * [rev:101171] Pass correct class to allowPrimaryKeyEditing in yaml fixture * [rev:101170] Don't recreate a missing draft page when calling SiteTree::doUnpublish() * [rev:101167] #5216 Installer has issues with click handlers applied to the entire li, be more specific and apply it to the label and input instead * [rev:101165] Fixed versioning of pages * [rev:101155] Prevent failed migrateVersion writes from breaking versioning system in future writes. * [rev:101155] MAke site tree pages go green when you save a new draft. * [rev:101154] #5214 ViewableData::obj() was creating a DBField without a fieldname argument and caused problems, one example is the version panel of the CMS * [rev:101153] Ensure that Versioned works on classes with underscores in the names. (from r100905) * [rev:101138] Fixed issues with broekn link tracking * [rev:101131] Allow classes to be referred to with casing that differs from their definition. * [rev:101129] Fixed FileLinkTrackingTest to cope with the empty alt="" and title="" attributes that are created * [rev:101127] Improved reliabilty of broken link tracking. * [rev:101127] Don't mark a page as changed on stage if the only thing that has changed is broken link metadata ### Minor changes * [rev:102045] Fixed spelling mistake in ConfigureFromEnv class documentation * [rev:102018] Fixed VersionedTest arguments in test case * [rev:102010] Fixed regression from r101752 (adding permission roles button was missing) * [rev:102009] Fixed indentation * [rev:101974] Saving TinyMCE editor focus in tinymce_ssbuttons plugin when sidepanel is opened (see #5263) * [rev:101971] Fixed indentation * [rev:101970] Fix tests to cope with ID type cleanup changed recently * [rev:101889] removed duplication of variable and conditional that would never pass * [rev:101883] take advantage of an alternate path for error pages * [rev:101882] TreeTitle really should return title, not name. * [rev:101870] Make Salad accept "login" or "log in" * [rev:101868] Added missing file for r101867 * [rev:101811] Fixed JSONDataFormatter excaping (fixes #5309, thanks briley) * [rev:101782] Marked DataObject::has_own_table() as static * [rev:101754] Removed unnecessary console.*() from cms javascript files * [rev:101753] Removed unnecessary console.*() from sapphire javascript files * [rev:101752] Removed unnecessary "show" icons in "Roles" and "Member" ComplexTableFields * [rev:101751] Removed unnecessary "show" icons in "Roles" and "Member" ComplexTableFields * [rev:101729] use red font instead of gray when displaying error * [rev:101723] Fixed getElementsByClassName() usage in AssetTableField.js (fixes #5256) * [rev:101718] Fixed tab naming in Group->getCMSFields() * [rev:101698] Respecting folder sort order in admin/assets by adding Folder::$default_sort="Sort" (#5235) * [rev:101688] Removed fullstop where it wasn't needed * [rev:101687] Tidied up the layout of the Themes area of the installer slightly - now consistent helptext as other areas * [rev:101686] Updated CMS Admin Account text to be more precise * [rev:101683] Altered wording in installer for localised interface * [rev:101671] Reverted r101670 as it broke assumptions made in RedirectorPageTest * [rev:101638] Updated ViewableDataTest to verify ViewableData changes * [rev:101619] Made the default database directory relative to assets ".db" which is more precise than ".sqlitedb" * [rev:101618] Made SQLite path in installer use DIRECTORY_SEPARATOR so it shows as correct on Windows using backslashes instead of forwardslashes - this is more of a cosmetic thing, as slashes can be interchanged and still parsed correctly by PHP * [rev:101600] fixed notice level error * [rev:101353] Removed rewritest.php places in sapphire since it's no longer part of the phpinstaller/branches/2.4 package * [rev:101341] Made reinstall message more precise by adding web.config to the files that will get overwritten * [rev:101282] Moved "theme" section further down in the installer, its much less likely to be changed than the database connection and admin account fields. * [rev:101254] Fixed missing closing `<div>` in ContentController->successfullyinstalled() * [rev:101251] Fixed regression in install.js option selection (see r101173) * [rev:101172] Fix output format of buildbot test runs to not include colour control codes. * [rev:101166] versioning test for SiteTree * [rev:101135] Fixed multifile.js non-standard forEach() reference, using jQuery.each() instead * [rev:101134] Localized "dependent pages" features in SiteTree->getCMSFields() * [rev:101132] Fixed test that was relying on bug fixed in r101116 ### Other * [rev:101314] ENHNACEMENT Installer no longer asks for firstname and surname for default CMS admin account, this can be changed later on and doesn't need to be entered for installation {![](_images/./sscreatechangelog --version 2.4.0-rc1 --branch branches/2.4 --stoprevision 101127)}
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/rc/2.4.0-rc3.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/rc/2.4.0-rc3.md
1,572
1,758,118,090
en
# 2.4.0-rc3 (2010-05-04) ## Overview * Bugfix release for a minor MySQL 4 bug as well as some static publishing quirks ## Changelog ### Bugfixes * [rev:103961] Bypass static caching through static-main.php when GET or POST parameters are set (regression from 2.3 API, fixes #5519, thanks ktauber) * [rev:103960] Fixed publication of homepage with '/' URL through StaticPublisher (fixes #5514, thanks ktauber) * [rev:103957] Fixed Database->requireTable() for Mysql 4.1 (fixes #5517, thanks gw0) * [rev:103936] Fixed double pragma after referer redirection on forms with Form->httpSubmission() (fixes #5509, thanks ktauber) * [rev:103933] login BackURL wrong when using nested urls (fixes #5520, thanks ktauber) * [rev:103932] Fixed SS_Report::unregister() parameter naming (fixes #5511, thanks ktauber) * [rev:103912] Trimming expected output of WebserverRoutingTest (newlines before the "ok" string were causing failures on PHP 5.3) * [rev:103910] Disabled MemoryLimitTest for environments where memory_limit can't be freely set (e.g. PHP with suhosin patch) * [rev:103851] table and column names now quoted properly ### Minor changes * [rev:103975] Removed unnecessary $timeformat parameter from TimeField::__construct, and getting the default from Zend_Locale_Format in the same way that DateField behaves (unreleased API, so no api change). * [rev:103975] Automatically choosing $locale in TimeField::__construct, to be consistent with DateField {![](_images/./sscreatechangelog --version 2.4.0-rc2 --branch branches/2.4 --stoprevision 103839)}
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/rc/2.3.8-rc1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/rc/2.3.8-rc1.md
2,482
1,758,118,090
en
# 2.3.8-rc1 (2010-07-16) ## Changelog ### Features and Enhancements * [rev:108062] Added File::$allowed_extensions (backport from 2.4 to enable File->validate() security fix) * [rev:103684] Allowing TestRunner? to skip certain tests through the ?SkipTests?=... GET paramete (merged from branches/2.3-nzct) (from r80646) * [rev:103659] do not show comments that need moderation in the comment rss feed ### API Changes * [rev:108062] Don't reflect changes in File and Folder property setters on filesystem before write() is called, to ensure that validate() applies in all cases. This fixes a problem where File->setName() would circumvent restrictions in File::$allowed_extensions (fixes #5693) * [rev:108062] Removed File->resetFilename(), use File->updateFilesystem() to update the filesystem, and File->getRelativePath() to just update the "Filename" property without any filesystem changes (emulating the old $renamePhysicalFile method argument in resetFilename()) * [rev:108062] Removed File->autosetFilename(), please set the "Filename" property via File->getRelativePath() ### Bugfixes * [rev:108045] Don't allow direct access to PHP files in mysite module. (from r108029) * [rev:108044] Don't allow direct access to PHP files in cms module. (from r108028) * [rev:108043] Don't allow direct access to PHP files in sapphire module, except for main.php and static-main.php (from r108023) ### Minor changes * [rev:108062] Added unit tests to FileTest and FolderTest (some of them copied from FileTest, to test Folder behaviour separately) * [rev:108046] Partially reverted r108045, mistakenly committed RewriteBase change * [rev:108040] Added .mergesources.yml * [rev:103897] Added querystring option to Makefile (from r103884) * [rev:103895] Added querystring option to Makefile (from r103746) * [rev:103528] sort page comment table by Created field - show newest entries first * [rev:103521] Fixed FileTest execution if the assets/ directory doesn't exist. (from r88353) (from r98086) * [rev:103447] Fixed js applying to non-tinymce textarea fields in ModelAdmin.js (fixes #5453) * [rev:103362] Fixed js applying to non-tinymce textarea fields in ModelAdmin.js (fixes #5453) * [rev:103348] added moderation message for non-ajax mode * [rev:101258] Fixed missing closing `<div>` in ContentController->successfullyinstalled() (from r101254) {![](_images/./sscreatechangelog --version 2.3.8-rc1 --branch branches/2.3 --stopbranch tags/2.3.7)}
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/rc/2.4.1-rc1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/rc/2.4.1-rc1.md
29,388
1,758,118,090
en
# 2.4.1-rc1 (2010-07-16) ## Overview * Fixed a security issue where logged-in CMS authors were allowed to rename files with harmful extensions in the "Files & Images" section * Improved installer security by disallowing re-installation when a configuration file is already present. * Installing in "live mode" instead of "dev mode" by default, and avoid setting certain domains as "dev mode" by default. This fixes an issue where attackers were able to force a site into "dev mode" by spoofing the domain name on certain server configurations. * Fixed password encryption when saving members through the "Add Member" dialog in the "Security" admin. The saving process was disregarding password encyrption and saving them as plaintext (issue was introduced in 2.4.0) * Fixed potential information disclosure on misconfigured servers by disallowing direct execution of *.php files in "sapphire", "cms" and "mysite" folders. If PHP was configured to show errors on screen (development setting), attackers could find out server paths and other environment information. * Allow CMS authors to set their own localized date and time formats, independently from the defaults set through their interface language. * More useable date picker (jQuery UI) for date form fields (both in the CMS and in website forms) * Better URL "transliteration" of special characters like Umlauts or Macrons (Example title: "Brötchen für alle!", URL in 2.4.0: "brtchen-fr-alle", URL in 2.4.1: "broetchen-fuer-alle") * Better batch editing of comments in the admin interface (e.g. marking multiple comments as "spam") * More sophisticated access control for decorators on page types (tri-state permissions checks: allow, deny, ignore). ## Changelog ### Features and Enhancements * [rev:108024] Show a warning inside the the CMS if you've neglected to delete install.php * [rev:108012] added getter to get array back out of an ArrayData instance. MINOR: updated docblocks in ArrayData * [rev:107877] Added Latvian (Latvia) translation to sapphire (thanks Kristaps and Andris!) * [rev:107875] Added Latvian (Latvia) translation to cms (thanks Kristaps and Andris!) * [rev:107867] Allowing custom messages and permission codes in BasicAuth::protect_entire_site() * [rev:107867] Making $permissionCode argument optional for BasicAuth::requireLogin(). If not set the logic only checks for a valid account (but no group memberships) * [rev:107867] Using SS_HTTPResponse_Exception instead of header()/die() in BasicAuth::requireLogin() to make it more testable * [rev:107810] Added class to time icon in TimeField so it can be styled * [rev:107443] html2raw now properly replace strong tag with asterix #5494 * [rev:107438] Using jQuery UI datepicker in DateField and DatetimeField instead of outdated DHTML calendar.js (fixes #5397) * [rev:107438] Abstracted optional DateField->setConfig('showcalendar') logic to DateField_View_JQuery * [rev:107434] allow adding a new a field to ArrayData * [rev:107429] Added documentation and changed static names * [rev:107426] Added static to set regeneration of default pages (ticket #5633) * [rev:107415] Added Security::$force_database_is_ready to mock database_is_ready() state * [rev:107415] Added permission check exception in TaskRunner and DatabaseAdmin if SapphireTest::is_running_test() returns TRUE (necessary for DevelopmentAdminTest) * [rev:107380] Use array_combine() instead of custom logic for ArrayLib::valuekey() (thanks paradigmincarnate!) * [rev:107365] Member_DatetimeOptionsetField toggle text is now translatable * [rev:107334] #5352 Translatable entities for help text in Member_DatetimeOptionsetField::getFormattingHelpText() * [rev:107327] #5352 CMS now uses the user's preferred date and time formatting in DateField and TimeField * [rev:107326] #5352 Decouple date display from i18n locales, users now have access to change their date and time formats in Member::getCMSFields() using Member_DatetimeOptionsetField field * [rev:107094] abstracted protocol detection out to Director::protocol() #5450 * [rev:107091] in referencing a file in combine_files() it should fall back to standard requirement tags if combining has been disabled eg dev mode * [rev:107088] throw user error when not passing correctly formatted array rather than simply passing * [rev:107086] added setDisabled() to set DropdownField::$disabled * [rev:106877] Added TestRunner::$coverage_filter_dirs to exclude certain directories from PHPUnit test coverage reports * [rev:106705] Calling Image->deleteFormattedImages() in Image->onBeforeWrite() (#5423) * [rev:106200] added prefix and suffix support to ContextSummary * [rev:106194] Prevent image search queries all images in the site initially when the page is loaded * [rev:106178] Enable switch between legacy image search and new version * [rev:106118] added setRows() and setColumns() to customize the size of the textarea field outside of the controller * [rev:105890] Added method for $this->request->latestParam() backwards compatibility with Director::urlParam() * [rev:105732] Ability to hide form by className or for the whole ModelAdmin * [rev:105712] Added MySQLDatabaseConfigurationHelper::getDatabaseVersion() which abstracts the version number away from the version check the installer requires * [rev:105275] Preserve sort options in pagination links in TableListField * [rev:105271] 'Select all' and 'Select none' checkboxes for CommentTableField for easier batch handling of comments, improved its styling in CommentAdmin * [rev:105269] Showing 20 comments in tabular view for CommentAdmin (and making the setting configurable via CommentAdmin::set_comments_per_page()) * [rev:105268] Abbreviating comment text display in CommentAdmin to first 150 characters * [rev:105266] Allowing batch checkbox selection of TableListField rows with TableListField->Markable and TableListField->addSelectOptions() * [rev:105126] Added CSSContentParser->getByXpath() * [rev:105028] Added variable for the server configuration file so the config-form can display it for the installation * [rev:104968] Added PageComment->canView()/canEdit()/canDelete(), and using these permissions in PageCommentInterface. Caution: canCreate() actions are still determined by PageCommentInterface::$comments_require_login/$comments_require_permission * [rev:104935] added Month function for consistency * [rev:104827] added plugins to i18n to support modules that provide custom translations. * [rev:104707] Installer now supports requireDatabaseVersion() on each database configuration helper implementation, e.g. MySQLDatabaseConfigurationHelper. If it's not defined, the test is skipped. * [rev:104706] Added MySQLDatabaseConfigurationHelper::requireDatabaseVersion() to check whether the connected instance is using version 5.0+ * [rev:104671] Macrons, umlauts, etc, are now transliterated when inserted into URLS. API CHANGE: Added Transliterator class, which uses iconv() or strtr() to convert characters with diacritical marks to their ASCII equivalents. API CHANGE: Added Extension hook updateURLSegment for SiteeTree. * [rev:104515] initial commit * [rev:104232] Add 'Given I load the fixture file "app/tests/xyz.yml"' step to salad * [rev:104231] Add dev/tests/sessionloadyml to load a yml fixture into an existing test session * [rev:104162] Added cs_CZ javascript translations (#5540, thanks Pike) ### API Changes * [rev:107439] Using FieldHolder() instead of Field() for subfields in DatetimeField->FieldHolder(), in order to get configuraton settings for javascript DateField * [rev:107273] Don't reflect changes in File and Folder property setters on filesystem before write() is called, to ensure that validate() applies in all cases. This fixes a problem where File->setName() would circumvent restrictions in File::$allowed_extensions (fixes #5693) * [rev:107273] Removed File->resetFilename(), use File->updateFilesystem() to update the filesystem, and File->getRelativePath() to just update the "Filename" property without any filesystem changes (emulating the old $renamePhysicalFile method argument in resetFilename()) * [rev:107273] Removed File->autosetFilename(), please set the "Filename" property via File->getRelativePath() * [rev:107268] Deprecated File->getLinkedURL() * [rev:107054] Deprecated AutocompleteTextField, use third-party solutions * [rev:106217] moved Group::addToGroupByName to $member->addToGroupByCode. * [rev:105756] refactored methods in session to use coding conventions * [rev:104987] Removed ImageEditor functionality, please use thirdparty modules, e.g. "silverstripe-pixlr" (http://github.com/nyeholt/silverstripe-pixlr) * [rev:104923] Added interface method DatabaseConfigurationHelper::requireDatabaseVersion(), all database helpers that implement DatabaseConfigurationHelper must now have this method, which as of now is MySQL, PostgreSQL, SQL Server and SQLite * [rev:104673] Added RsyncMultiHostPublisher::set_excluded_folders(). * [rev:104669] Moved site tree permission extension to a 3-state system (true, false, null, where null means "no effect") ### Bugfixes * [rev:108032] Fixed CLI installation. * [rev:108031] Don't set any dev servers by default, host-based dev-server selection is unreliable. * [rev:108030] Don't allow reinstalling without first making the user manually delete mysite/_config.php * [rev:108029] Don't allow direct access to PHP files in mysite module. * [rev:108028] Don't allow direct access to PHP files in cms module. * [rev:108027] Don't have any host-based dev servers set by default. * [rev:108026] Don't allow reinstalling without first making the user manually delete mysite/_config.php * [rev:108023] Don't allow direct access to PHP files in sapphire module, except for main.php and static-main.php * [rev:108001] #5833 Duplicate IDs when two similar date formats in Member_DatetimeOptionsetField containing different delimiters (e.g / and .) replaced to an empty string * [rev:107940] tests now pass when the locale is set to something other than 'en_US' in the mysite's _config.php file * [rev:107831] dev/build always reporting index change because of a whitespace in the index column names * [rev:107812] Styling fixes for DateField/TimeField/DatetimeField in the CMS * [rev:107811] Added a clearing div after the date and time fields, not the best way of doing it but the only way as the overflow css trick for clearing fields doesn't work with the time dropdown * [rev:107789] Fixed DateField->validate() with keyed, but empty array values * [rev:107786] Using actual date format settings in DateField/TimeField->validate() messages * [rev:107785] Limit 'showcalendar' javascript option to DateField instances (rather than applying to all available) * [rev:107585] fixed inclusion of environment file when document root is the web root * [rev:107539] Case insensitive extension checks in File::validate() (fixes #5781, thanks simon_w) * [rev:107537] Remove dummy entry created by Versioned if record is first written to Live stage (fixes #5596, thanks muzdowski) * [rev:107532] Fixed Member->PasswordEncryption defaults when writing new Member without setting a password. Fixes critical issue with MemberTableField saving in admin/security, where new members are stored with a cleartext password by default instead of using the default SHA1 (see #5772) * [rev:107441] Allowing DatetimeField->saveInto() to save a partial array notation with missing 'time' value * [rev:107428] Added quotes for postgres * [rev:107423] Only highlight strings more than 2 characters long. #4949 * [rev:107417] Reverted 107414, wrong patch * [rev:107415] Allowing dev/build in "live" mode when Security::database_is_ready() returns FALSE (typically happens when an existing SilverStripe project is upgraded and database columns in Member/Permission/Group have been added) (fixes #4957) * [rev:107414] TableListField headings i18n translation (ticket #5742) * [rev:107390] Added Locale hidden field to HTMLEditorField->LinkForm() in order to show correct context in "page on the site" dropdown (fixes #5743) * [rev:107369] Fixed spelling error of $databaseConfig in cli-script.php causing database configuration to not load (thanks aimcom!) * [rev:107116] Undo commit to wrong place * [rev:107115] Undo incorrect commit * [rev:107095] check the $removeAll var before removing cache files. PATCH via ajshort (#5672) * [rev:107090] prevented HTTPRequest->shift() throwing notices when shifting multiple elements. APICHANGE: SS_HTTPRequest->shift($multiple) no longer returns an array of size $multiple spaced with nulls, it returns an array up to the size of $multiple. * [rev:107089] fixed notice level errors getting through * [rev:106867] Making status description in Debug::friendlyError() compatible to HTTP 1.1 spec (removing any markup and newlines) * [rev:106777] Re-enabling theme in ErrorPage->doPublish() (it's usually disabled in the publication context through LeftAndMain->init()) * [rev:106755] Stricter checking that a relation exists on ComplexTableField::saveComplexTableField() * [rev:106671] Fixed ImageField->EditFileForm() to list subclasses of Image in tree dropdown (fixes #5708, thanks keeny) * [rev:106666] Prevent DateField->performReadonlyTransformation() from segfaulting on PHP 5.2 due to broken __toString() casting (fixes #5713, thanks charden) * [rev:106360] re-enable broken link notification using BackLinkTracking() (this was broken since r101127 * [rev:106351] Apply AJShort's patch to fix SiteConfig (trac 5671) * [rev:106225] Checking for the same combined filename in Requirements::combine_files() to avoid irrelevant error messages * [rev:106205] updated tests for Text * [rev:106183] fix query error when image search doesn't use legacy search * [rev:106154] if running in cli do not output html tags when rebuilding the db * [rev:106122] Fixed caching of homepage. * [rev:106121] Open help in a new tab. * [rev:106120] Replaced Versioned's unique index definition with an array syntax. * [rev:106096] Setting 'ID' field on CMSMain->RootForm() so it can work with formfields that require it (fixes #5671, thanks ajshort) * [rev:106086] image search was not honouring the selected folder, so could only search in root folder * [rev:106082] Fixed SiteTree::IsModifiedOnStage() for an edge-case that was identified when deleteFromStage() stopped manipulating the current record. * [rev:106080] Don't let deleteFromStage() kill the ID of the original record. * [rev:106079] Add a unique index to SiteTree_versions.RecordID+Version. Fix saving methods to support this. * [rev:106078] Throw an exception if you try an delete an unsaved or already-deleted record * [rev:106071] MySQLDatabaseConfigurationHelper::getVersion() will fallback to trying to get the version using a query if mysql_get_server_info() returns nothing * [rev:105907] fixed phpunit directive * [rev:105903] reverted revision 105890 to fix build * [rev:105889] invalid use of @covers annotation * [rev:105876] TableListField_Item::SelectOptionClasses() can not use it parent protected variable. * [rev:105875] rollback r105858 which introducesa bug * [rev:105872] updated select options classes to work with the dataobjectset returned by selectoptions rather than the array previously * [rev:105868] fixed select all link using incorrect function * [rev:105858] TableListField_Item::SelectOptionClasses() can use it parent protected variable. * [rev:105833] fixed incorrect include path * [rev:105732] validate file in import from CSV form * [rev:105726] If database version can't be determined, just use the database adapter class * [rev:105711] Install now supports sending database version if available from the helper * [rev:105705] ss2stat URL not generated correctly (has NULL values) * [rev:105668] Moved SiteTree->ParentID property to Hierarchy extension (fixes #5638) * [rev:105667] More specific regex in Requirements->includeInHTML() to avoid duplicating information by matching HTML5-style `<header>` tags instead of `<head>` (fixes #5640) * [rev:105665] Can't set width or height on MemberTableField popup (fixes #5625, thanks smurkas) * [rev:105514] if moderation on comments is enabled then redirect the user back down to the comment section to view the message rather than trying to direct to selector which doesnt exist * [rev:105505] avoid adding loading class to TinyMCE add link, image, flash buttons * [rev:105468] #5349: Use TEMP_FOLDER for Zend's cache temp dir. * [rev:105337] get_title_sql has string concat hardcoded as ||, fixed for MSSQL which uses +, fix for #5613 * [rev:105278] Stricter object type checks in ViewableData->hasValue() and ViewableData->XMLval(). Broke in cases when SS_HTTPResponse is returned which doesn't extend from Object, hence doesn't have an exist() method (fixes #5524, thanks hamish) * [rev:105264] addFieldToTab segfaulting under PHP 5.2 * [rev:105225] force dateformat to en_NZ if showcalendar is enabled as calendar is compatibile with en_NZ only * [rev:105030] Fixed correct input ID in install.js due to change in r105029 * [rev:105029] Fixed inconsistent styling of reinstall actions at the bottom of the installer, and if using IIS, warn that this will overwrite the web.config file, not .htaccess * [rev:104995] Fixed i18nTextCollector when used with i18nEntityProvider - class manifest is now stored lowercase, which means i18n::get_owner_module() didnt work reliably * [rev:104972] TestSession::submitForm throws proper error if form not found * [rev:104968] Requiring CMS_ACCESS_CommentAdmin instead of ADMIN permissions in PageCommentInterface and CommentAdmin administrative actions * [rev:104962] Fixed bug in basicauth failover to session member. * [rev:104962] Don't use session member for test site protection feature. * [rev:104847] catch case of plugin not returning translations for the locale * [rev:104793] Installer now checks the database version AFTER it has determined a connection can be established, which some databases require first * [rev:104793] Database version check failures are now a warning, so a user can install at their own risk * [rev:104745] after reset password, the site redirect to non-exisit page (SC #1) * [rev:104720] Fixed installation problem where version error didn't show * [rev:104679] Make URLs lowercase * [rev:104678] Fixed Translatable::canEdit() to suit new permission customisation scheme * [rev:104675] Prevent DataDifferencer from creating empty `<ins />` and `<del />` takes that confuse the browser. * [rev:104672] Make RsyncMultiHostPublisher protected; give default value. * [rev:104670] Director::test() shouldn't break if $_SESSION isn't set. * [rev:104666] Removed references to php5 binary in Makefile * [rev:104608] check if a request is present before using it to prevent undefined errors * [rev:104581] Generate stage/live links using Controller::join_links() instead of string concatenation. * [rev:104580] Fixed Controller::join_links() handling of fragment identifiers * [rev:104552] when using custom Member title, the join was failing - it had wrong parameters. Now changed to correctly handle the ansi sql join for all Member columns. * [rev:104533] Fix ModelAdmin Import hang (ticket 5569) * [rev:104468] When finding an old page in the 404 handler, favour existing subpages over historical ones. * [rev:104463] Fix legacy URL redirection for pre-nestedurls URLs, after it has been enabled. * [rev:104436] Removed erroneous default config for unused templates module. * [rev:104403] Wrong HTML syntax in LeftAndMain.ss (fixes #5552, thanks simon_w) ### Minor changes * [rev:108049] Added warning about Director::set_dev_servers() * [rev:108048] Documentation in CSVBulkLoader * [rev:108025] Added test for #5662 (calling delete twice) * [rev:108002] Fixed incorrect word "colon" with "dot" * [rev:107878] Updated translations * [rev:107876] Updated translations * [rev:107838] Reverted r107831 * [rev:107789] Fixed DateField/TimeField validation message translation (wrong sprintf() nesting) * [rev:107787] Fixed TimeField validation _t() entity name * [rev:107784] Disabled 'showcalendar' option on CMSMain->SiteTreeFilterDateField() - it causes the CMS to load jQuery UI javascript just for this (rarely used field). To be re-enabled once we work with jQuery UI on a broader scale. * [rev:107726] Moved class-specific documentation from doc.silverstripe.org back into class-level PHPDoc * [rev:107725] Moved class-specific documentation from doc.silverstripe.org back into class-level PHPDoc * [rev:107586] removed whitespace * [rev:107525] Removed debug code in MemberTableField * [rev:107442] Fixed DatetimeField display in cms * [rev:107442] Removed obsolete .calendardate styles from cms_right.css * [rev:107440] Using Google CDN for jQuery dependencies in FileIFrameField * [rev:107437] Better error handling in i18n::get_language_name() * [rev:107430] Fixed Documentation * [rev:107415] Using Object::create() in DevelopmentAdmin to make objects mockable * [rev:107400] Documentation in DataObjectSet * [rev:107394] Changed "no_NO" locale for Norwegian into the more commonly used "nb_NO" in i18n class, meaning translations from translate.silverstripe.com can actually be selected now (fixes #5746) * [rev:107366] Tweaking of installer text to avoid misleading information about "exists" when there's actually an error * [rev:107307] Reverted r107305 * [rev:107305] Code formatting fix for setting Member locale in LeftAndMain::init() * [rev:107276] Checking that Folder::findOrMake() can create an assets/assets/ folder * [rev:107275] Using Filesystem::makeFolder() instead of mkdir() in Folder for file operations * [rev:107274] Better presentation of extension error message in File and UploadValidator * [rev:107273] Added unit tests to FileTest and FolderTest (some of them copied from FileTest, to test Folder behaviour separately) * [rev:107272] Changed ImageTest to use fixture files located in assets/ folder, the filesystem API doesn't support Folder objects with "sapphire/..." paths, which leads to inconsistent results * [rev:107271] Making FileTest->setUp()/tearDown() more resilient against in-test file/folder renames * [rev:107270] More identifiable file naming in FileTest * [rev:107269] Using File::get_file_extension() instead of substr() magic in File->setName() * [rev:107269] Using exceptions instead of user_error() in File->setName() * [rev:107268] Avoiding duplication by using existing getFullPath() in File->getAbsoluteURL() * [rev:107267] Made File::get_file_extension() more readable, and added unit test * [rev:107266] Removed File->setField(), doesn't have any overloaded functionality * [rev:107265] Documentation in File and Folder class * [rev:107214] updated generator tag URL * [rev:107175] force exclusive connection * [rev:107104] Added initial docs * [rev:107030] return false rather than error out in case SS_Query:: is not a resource * [rev:106938] mysql_fetch_row() expects resource, this will fatal if query was e.g. UPDATE when iterating a result because MySQLQuery::nextRecord() is used by Iterator::valid() and MySQLQuery:: is bool in this case * [rev:106876] Making $Email available in Security_passwordsent.ss template (fixes #5737) * [rev:106805] Added FileTest->testValidateExtension() (related to #5693) * [rev:106804] Documentation * [rev:106777] Reverted r88633, it breaks `<base>` tag in static HTML for ErrorPage->doPublish() * [rev:106694] Removed trailing slash in BackURL, fixed error message sentence structure in PageCommentInterface.ss (fixes #5520) * [rev:106687] Fixed hardcoded error message in PasswordValidator (fixes #5734) * [rev:106687] Added PasswordValidatorTest * [rev:106568] Provide a default message for FIELDISREQUIRED * [rev:106313] Correct typo in comments * [rev:106248] Made CMSMainTest more resilient against database ID changes (Postgres doesn't have auto-increment resets across tests at the moment) * [rev:106190] Fixed memory limit setting in SapphireTest (regression from r106128) * [rev:106187] Better checking of safe_mode in MemoryLimitTest * [rev:106180] Add comments for ThumbnailStripField * [rev:106156] Don't run memory limit tests in safe mode, * [rev:106128] Preserve memory_limit between tests (for better PHP5.1 behaviour) * [rev:106119] Added test for Database::hasTable(). * [rev:106090] Fixed test that required a separate Page table. * [rev:106083] Removed db/build legacy wording in DevelopmentAdmin (fixes #5676) * [rev:106081] Added test for #5657 * [rev:105985] add text/plain to the list of accepted mime types * [rev:105912] Better error handling in Form::__construct() (fixes #5649) * [rev:105732] Clear DB checkbox unchecked by default * [rev:105517] Installer should not repeat "Could not determine your database version" twice in slightly varied words * [rev:105516] Show better message if couldn't find MySQL version in MySQLDatabaseConfigurationHelper * [rev:105305] More solid markup testing in TableListFieldTest through xpath * [rev:105297] Fixed TableListFieldTest->testSelectOptionsRendering() * [rev:105282] Using ASSETS_DIR and THEMES_DIR constant in Image, ManifestBuilder, Requirements, File (fixes #5619) * [rev:105281] Using ASSETS_DIR constant in StaticPublisher (fixes #5619) * [rev:105277] Translations * [rev:105276] Translations * [rev:105274] Reverted r105264, breaks CompositeFieldTest, FieldSetTest, TranslatableTest * [rev:105273] Updated TableListField sublcass template to work with new TableListField->SelectOptions() setting * [rev:105272] Fixed _t() call in PageCommentInterface.ss * [rev:105270] missing slash / from Requirements::css() parameter * [rev:105267] Removed jquery.livequery as a Requirement from LeftAndMain.php, its only necessary in SecurityAdmin for MemberImportForm.js now. * [rev:105198] Fixed fixture location for DbDatetimeTest * [rev:105196] Added DbDatetimeTest cases to sapphire (these were previously in the sqlite3 module, but they actually test core Database functionality) * [rev:105188] Documentation * [rev:105139] increased height of the todo text field in the cms * [rev:105027] Checking for headers_sent() before setting cookies in Versioned::choose_site_stage() to avoid problems with URL parameters like showqueries=1 and ContentController calling choose_site_stage() (fixes #5557) * [rev:105011] Documentation * [rev:105009] Documentation * [rev:105005] Documentation * [rev:104996] Documentation * [rev:104993] Language master file * [rev:104992] Removed duplicated code in i18nTextCollector, more defensive checks for get_owner_module() * [rev:104980] Added translations for BrokenLinksReport, ReportAdminForm.ss, AssetTableField.ss (fixes #5527, thanks Martimiz) * [rev:104978] Allowing translation of "save" button in SiteConfig->getCMSActions() * [rev:104970] Translations in PageCommentInterface.ss (fixes #5598, thanks Pike) * [rev:104924] Reverted r104923, as current database releases of mssql and sqlite3 modules don't support this yet * [rev:104883] Fixed hidden mbstring reliance in SiteTree->generateURLSegment() (broken in r104679) * [rev:104835] Save and restore lang state in test * [rev:104798] Fixed SiteTreeTest and SiteTreePermissionsTest to work alongside subsites module (SiteTreeSubsites changes the canEdit() behaviour) * [rev:104796] Fixed SiteConfigTest to work alongsite subsites module (SiteTreeSubsites changes the canEdit() behaviour) * [rev:104795] Documentation * [rev:104769] Documentation * [rev:104767] Documentation * [rev:104733] fixed umlauts * [rev:104711] Added DirectorTest->testURLParam() and DirectorTest->testURLParams() * [rev:104710] Installing screen now has a page title called "Installing SilverStripe..." instead of "PHP 5 is required" * [rev:104709] Removed double returns in installer (redundant code) * [rev:104708] Renamed checkdatabase method to checkDatabase to be consistent * [rev:104705] Show install MySQL version at 5.0+ as 4.1 does not work properly with SilverStripe * [rev:104704] Tweaks to positioning of help text in installer * [rev:104682] fixed api doc * [rev:104636] added illustrator formats to the allowed extensions. * [rev:104610] Documentation * [rev:104598] Fixed wrong _t() notation in ChangePasswordForm (broken in r103226 and r104596) * [rev:104596] Making strings in ContentControllerSearchExtension translatable * [rev:104594] Defensive coding in MigrateSiteTreeLinkingTask * [rev:104490] Removed ForumAdmin.js which shouldn't belong in the CMS module * [rev:104483] Documentation * [rev:104404] Documentation * [rev:104402] Documentation * [rev:104158] Documentation migrated from doc.ss.org * [rev:104157] Migrated various API-style documentation from doc.ss.org ### Other * [rev:105057] MINOT Translation in SiteTree (#5603, thanks Pike) * [rev:104674] ENHANCMENT: RsyncMultiHostPublisher also rsyncs sapphire/static-main.php. * [rev:104668] Sake fix: look for php binary before php5, to prevent errors on CentOS and Cygwin. * [rev:104667] Added explicit bash handler to sake * [rev:104442] Multi-use redemption page created {![](_images/./sscreatechangelog --version 2.4.1-rc1 --branch branches/2.4 --stopbranch tags/2.4.0)}
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/changelogs/alpha/2.4.0-alpha1.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/changelogs/alpha/2.4.0-alpha1.md
39,317
1,758,118,090
en
# 2.4.0-alpha1 (2009-11-11) ## Changelog ### Overview * Support for hierarchical URLs * Support for MSSQL server database abstraction (via a separate module) * A "SiteConfig" record stores site-wide settings and default permissions and author groups for pages * "Permission Roles" are a simple way to combine multiple permission codes and assign them to groups in the Security interface. This makes permissions easier to maintain and less repetitive to set up. * The CMS searches for broken internal links to other pages and broken file references, and highlights them in the WYSIWYG editor * Dramatically reduced memory usage in CMS tree on larger sites (10,000+) * Performance improvements around Object and ViewableData property access. * Improved Shortcode API to allow for custom tag parsing in CMS content * More fine-grained permission control for translators * Improved unit test execution speed, increased number of tests cases by 30% * Better XSS security of the autologin token by using HTTPOnly cookies, more secure brute force login restrictions * Decreased memory usage in "Files & Images" section ### New Features * [rev:91044] Added Session::destroy() as a means to remove the current session using session_destroy() * [rev:90036] Allow Text/Varchar fields to be configured to differentiate between NULL and empty string. (#4178, petebd) * [rev:89827] If there is no Name set, but there is an author, use the author's name (from r89650) * [rev:89221] batch actions for setting/resetting embargo/expiry (from r85397) * [rev:89194] SiteConfig (from r85339) * [rev:89193] Add a simple interface for administrating permission roles. (from r85297) * [rev:89190] SiteConfig (from r85339) * [rev:89189] Add a simple interface for administrating permission roles. (from r85297) * [rev:89176] Add another permission code that allows users to edit siteconfig without having admin priveleges (from r87261) * [rev:89157] Virtual pages now copy allowed children from the page they are * [rev:88992] Added MigrateSiteTreeLinkingTask to allow plain HTML links to be migrated into shortcode links. From: Andrew Short * [rev:88516] Added a SideReport to display all pages with broken page or file links. From: Andrew Short * [rev:88510] Re-instated broken link highlighting by manually checking all shortcodes in HtmlEditorField->Field(), and adding a class to broken ones. From: Andrew Short * [rev:88508] Added RequestHandler->allowedActions() to return a unified representation (including extensions) of all allowed actions on a controller. * [rev:88505] Added RequestHandler->hasAction() and Controller->hasAction() to check if a specific action is defined on a controller. * [rev:88503] Updated SiteTree::get_by_link() to integrate with translatable, and allow it to work across languages by implementing Translatable->alternateGetByLink(). * [rev:88496] Refactored RootURLController to allow nested home pages. * [rev:88492] Updated HtmlEditorField to use DOMDocument to more reliably parse image tracking and shortcode link tracking data. From: Andrew Short * [rev:88484] Added SiteTree::get_by_link() to fetch the SiteTree object associated with a nested link. * [rev:88483] Allow you to access nested pages by falling over to a child page in ContentController if one is available. From: Andrew Short * [rev:88481] Allow you to link to SiteTree? objects in HTMLText or HTMLVarchar fields by using a "[sitetree_link id=n]" shortcode. From: Andrew Short * [rev:88474] Refactored ViewableData. The main changes are: * [rev:88472] Added the Shortcode API (ShortcodeParser) to allow you to replace simple BBCode-like tags in a string with the results of a callback. From: Andrew Short * [rev:88468] Added utility methods to enable and disable nested URLs to SiteTree. From: Andrew Short * [rev:88104] added extend() call to enable FieldHolder() html to be customized via extensions. * [rev:85789] Added Widget_Controller class to enable nested forms within Wiget class. ### API Change * [rev:91048] Added Lower and Upper methods to Varchar, Text, and Enum * [rev:90963] Allow fieldList arguments to Form::loadDataFrom() and Form::saveInto(), for situations where the data passed only applies to a segment of the form. (from r90872) * [rev:90962] Inserting $HiddenFields into a form template will show the input tags of all the hidden fields. (from r90871) * [rev:90097] replaced Database::alteration_message() with DB::alteration_message() * [rev:90076] Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog. * [rev:90075] Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog. * [rev:90059] Added dev/tests/build, which runs everything, meaning that dev/tests/all doesn't need to run PhpSyntaxTes * [rev:89988] Add extra classes to WidgetHolder (#3855, patch from jshipman) * [rev:89841] Fixed change in r89716 to be more semantic with FileIFrameField * [rev:89726] TableListField customQuery and customCsvQuery won't automatically include ID, ClassName, and RecordClassName fields (from r87354) * [rev:89708] Change the way that Database::requireField() gets field type information from the underlying database driver. (from r82793) * [rev:89209] Added SapphireTest::logInWithPermission() (from r89012) * [rev:89205] Don't automatically set a default action on complex table fiels. It leads to too many accidental clicks when trying to click a non-default action. Still allow for people to explicitly select a default action. (from r88961) * [rev:89187] Added PermissionRole and PermissionRoleCode, along with relevant tests for the permission system. (from r85173) * [rev:88991] Updated Form->FormAction() to use Controller::join_links() rather than relying on the action parameter (to preserve b/c). From: Andrew Short * [rev:88797] HTTPRequest and HTTPResponse no longer inherit from Object, since they should not be extended. From: Andrew Short * [rev:88700] SSViewer and SQLQuery no longer inherit from Object, since they should not be extended. From: Andrew Short * [rev:88632] Added Debug::$friendly_error_header and Debug::$friendly_error_detail for customising the friendly error message. (from r69855) * [rev:88507] Decoupled ErrorPage::response_for() from the request and updated it so it will only return a response if an appropriate error page can be found. * [rev:88503] Moved lang_filter enabling & disabling into static methods on Translatable, and renamed to locale_filter. * [rev:88495] #3724: Unified the Link() method to accept an action parameter. From: Andrew Short * [rev:88296] support for advanced database options now included * [rev:88295] The advancedOptions variable now passed to the database connection * [rev:88294] $database_extensions static variable now supported * [rev:88293] The advancedOptions variable now passed to the database connection * [rev:88123] Requiring TRANSLATE_ALL or TRANSLATE_`<locale>` permission for authors without administrative access to edit translations * [rev:87894] array brackets removed for generation of field types * [rev:87893] Transaction stubs created * [rev:87568] array data type now supported * [rev:87567] array data type now supported * [rev:87566] array data type now supported * [rev:87565] array data type now supported * [rev:87564] array data type now supported * [rev:87563] array data type now supported * [rev:87562] array data type now supported * [rev:87561] array data type now supported * [rev:87560] array data type now supported * [rev:87559] array data type now supported * [rev:87558] array data type now supported * [rev:87557] array data type now supported * [rev:87555] array data types now supported by dev/build * [rev:87087] Added name argument to DB::getConn() and DB::setConn(), so that you can store multiple named connections. * [rev:86006] Removed Permission->listcodes(), use custom code * [rev:86002] Don't exempt 'index' controller actions from $allowed_actions check - they might still contain sensitive information (for example ImageEditor). This action has to explicitly allowed on controllers with $allowed_actions defined now. * [rev:85789] Removed unnecessary WidgetFormProxy class and Widget->FormObjectLink(), broken functionality since the RequestHandler restructuring in 2.3. Use Widget_Controller instead. * [rev:85073] Added DataObjectSet assertions to SapphireTest * [rev:85028] Added comparison argument to SSLog::add_writer() * [rev:84828] Added SSLogFileWriter to replace Debug::log_errors_to() and Debug::log_error_if_necessary() - the existing formatting for the Debug deprecation functions is now wrapped into SSLogErrorFileFormatter * [rev:84774] Debug::send_errors_to() and Debug::send_warnings_to() are deprecated in favour of SSLog. See class documentation for SSLog on configuration of error email notifications * [rev:84570] added onAfterSave in LeftAndMain * [rev:84523] Refactor CMSMenu internals to not generate the menu item list until its actually needed, rather than from a CMSMenu::populate_menu() call in cms/_config.php. This lets an app/_config.php file actually manipulate the menu. * [rev:84521] If you can't create a given dataobject type, then don't show an import form in modeladmin * [rev:84161] Deprecated DataObject::databaseFields() in favour of the static DataObject::database_fields() * [rev:84160] Extension no longer inherits from Object. * [rev:84151] Make Object::uninherited_static() have a separate execution path to Object::get_static(), for more reliable operation. The intention is that for any given static, you either use Object::get_static() or you use Object::uninherited_static() - not both. * [rev:84061] Database and Query no longer inherit from Object, since they shouldn't be extended with Extensions. ### Bugfixes * [rev:91209] Return correct error when 404 page doesn't exist and page is not found. * [rev:91203] Fix concurrent editing message always being displayed on page version history. * [rev:91156] Returning TRUE on Translatable->hasTranslation() if called on a record that is in the current locale (merged from r91032) * [rev:91047] Don't failover to standard value in ViewableData_Customised if the customised value is defined but isn't set. $obj->customise(array('Content'=>'')) should set Content to '' * [rev:91045] Session::destroy() should make use of setcookie() to remove the cookie from the user, unsetting the superglobal doesn't unset from the browser * [rev:91036] Added setup/teardown methods to SiteTreeBrokenLinksTest? to make it work with Translatable enabled (merged from r91033) * [rev:90964] use second argument only if its an array (from r90927) * [rev:90936] Fixed pages not being manipulated properly in the CMS because of a PHP error in CMSBatchAction * [rev:90934] MSSQL does not support double, using float instead (from r90928) * [rev:90876] Added ContentController->successfullyinstalled() to $allowed_actions * [rev:90857] applied patch from #4381. Observable doesnt play nice with jQuery (from r82094) * [rev:90855] Added rewriteHashlinks = 'php' option to SSViewer so that static publisher can handle internal hashlinks properly. (from r89612) * [rev:90854] Pass locale rather than language to spellchecker_languages (from r87869) * [rev:90853] Fixed Links to Moderate Comments from the CMS and front end. MINOR: removed complextable functions which no longer get called, moved logic to the PageComment Class (from r86325) * [rev:90852] Tied rollback action to edit, rather than publish, permission, since it only involves editing the draft site. (from r84957) * [rev:90851] Fix Form.FieldMap, used when constructing forms that have the HTML explicitly specified. * [rev:90850] Allow null default on MultiEnum fields * [rev:90849] Fixing the comment's author website url being converted to lowercase: now case is not affected. (from r84380) * [rev:90848] CMSMenuItem constructor now calls parent to respect inheritance (from r83586) * [rev:90845] Fixed bugs in content differencer, and improved styling. BUGFIX: fixed notice when getting title of member which didnt exist. Merged from trunk r77661. (from r81942) * [rev:90842] Added rewriteHashlinks = 'php' option to SSViewer so that static publisher can handle internal hashlinks properly. (from r89611) * [rev:90834] was being passed to foreach without a check to see if it's an array or not. (from r86202) * [rev:90833] Added required javascript files (behaviour, prototype, prototype_improvements) to the Field() method of TreeSelectorField.php (from r84320) * [rev:90831] WidgetArea now works. Can have multiple areas on a page, and has unit tests * [rev:90747] Fixed Text::scaffoldFormField() showing a "Is Null" checkbox, even if nullifyEmpty is true * [rev:90644] Fixed "Class not found CMSBatchAction_Unpublish ..." in BatchActionHandler.php, since this class was removed in r90489 * [rev:90632] Make DataObject::dbObject('ClassName') work. * [rev:90595] When deleting a WidgetArea, delete all the widgets it contains. * [rev:90554] #4609: Fixed portoguese locales in common locales list. * [rev:90553] #4617: Make delete formatted images case-insensitive. * [rev:90552] #4642: Fixed creation of folders in non-english languages. * [rev:90551] Fixed glitch in permission code formats. * [rev:90550] Fixed glitch in permission code formats. * [rev:90548] #2476: Rename lowercase tables to correct casing if they have been transferred from a windows box. * [rev:90547] #4063: Corrected base tag for IE6 * [rev:90196] fixed typo * [rev:90082] Don't skip flushCache() extension if $cache_get_one is empty on DataObject->flushCache() * [rev:90056] UTF-8 byte order mark gets propagated from template files (#4357) * [rev:90051] Remove blockquote from tinymce default plugin list - blockquote isnt a plugin in tinymce3. * [rev:90047] Some places want tableList() to have lower case, some want native case - return both! * [rev:90023] Security::$default_login_dest isn't used (#4179, simon_w) * [rev:90020] Reenable setting size on HasManyComplexTableField popups (#3921, rjmackay) * [rev:89911] Fixing regression in TranslatableTest due to outdated singleton caching. * [rev:89893] Moved SINGLETON resetting for test runs from SiteTreeTest/ObjectTest into SapphireTest - there should be no caching between all test invocations to avoid side effects * [rev:89881] Reset $_SINGLETONS cache in SiteTreeTest::tear_down() to avoid stale Translatable information. This broke SiteTreePermissionTest and SiteTreeTest when running in parallel with Translatable enabled. * [rev:89864] Added setup/teardown methods to CMSMainTest to fix test breakages when used alongside cmsworkflow module (which unsets the public batch action) * [rev:89863] Added setup/teardown methods to SiteTreeBacklinksTest to make it work with Translatable enabled * [rev:89825] Fix comment feed on SQLServer (from r89641) * [rev:89823] Made dragndropping possible for folders in ajax-expanded tree. Also fixed glitch in r82534 that made page drag and drop impossible (from r82571) * [rev:89821] repaired dragndropping files into nested directories - now code refers to the updated object which is initially hidden and zero sized (from r82534) * [rev:89812] If image does not exist in the file system, don't show a non-object error when viewing the Image/File record in AssetTableField (from r82390) * [rev:89811] Paging of search results now works for AssetTableField by overloading the TableListField link methods (from r81190, r82188) * [rev:89798] Removed double up of classes in TestRunner::coverage() (from r88463) * [rev:89731] Fixed ModelAdmin_CollectionController->Link() return value * [rev:89719] Folder::syncChildren() now uses far less memory - we do this by destroying the child object memory after use (from r82780) * [rev:89718] Fixed array to string conversion error in Date::setValue() (from r82749) * [rev:89716] disabling user ability to upload images into the CMS from their local computer (from r82573) * [rev:89715] Ensure that FileIFrameField gets the proper class, this could be a subclass of File instead * [rev:89714] Ensure that before creating default 404 error page, we don't have one already that exists with a record ID (from r81991) * [rev:89460] Hard code the migration task to use Content instead of the no-longer-used FieldName. This should probably be improved to iterate over all HTMLText fields on the model. * [rev:89444] Removed SiteTree::rewriteLink() method that is no longer necessary due to the use of shortcodes. * [rev:89338] Respecting SiteTree->canDelete() in SiteTree->getCMSActions() * [rev:89333] Removed 'name' attribute from HeaderField markup - its invalid HTML to put in `<h*>` elements (#4623) * [rev:89328] Fixed CMSSiteTreeFilter * [rev:89236] Fixed SiteTree->validURLSegment() to perform a DataObject::get_one() instead of raw SQL, in order for decorated filtering (e.g. by the subsites module) to apply correctly. * [rev:89215] Detect a brokenh link on an incompletely specified redirector page. (from r89043) * [rev:89213] Fixed link generation in CTF default action (from r89026) * [rev:89208] Fixed image link rewriting and added a test. (from r89011) * [rev:89206] Fixed diabled image references for edit and delete links in CTF (from r88967) * [rev:89204] If a CTF without a show action is made readonly, don't add the show action back. (from r88960) * [rev:89203] Fixed resolution of amibiguous has_many foreign keys in ComplexTableField to use the same logic as DataObject (from r88945) * [rev:89200] Fixed inversion of condition created in r88869 (from r88905) * [rev:89199] AuthorID field for page version history wasn't being set. (from r88894) * [rev:89183] Fixed generation of static cache files in subdirectories. (from r88569) * [rev:89177] Fix image tracking not working cross subsite (from r88008) * [rev:89175] Fix broken link tracking of linked files (from r87252) * [rev:89172] Fix error when adding roles tab (from r86997) * [rev:89170] Fix image tracking to take resized images into account (from r86198) * [rev:89169] Fix items not deleting on tablefields (from r86099) * [rev:89163] Fixed RequestHandler->allowedActions() lowercasing of actions - was applying the logic, but not writing it back to the $actions array. * [rev:89161] Don't return empty value from ViewableData->XML_val() if the actual value is an uncasted 0 integeter (or anything else evaluating to untyped boolean false) * [rev:89003] Added PageComments to ContentController::$allowed_actions so commenting works. From: Andrew Short * [rev:88989] Reset broken file & link flags in HtmlEditorField->saveInto() before determining if a record contains broken links. From: Andrew Short * [rev:88957] Fixed missing default english text for "Clear" and "Search" buttons in template CMSMain_left.ss * [rev:88956] #4605 DataObject::newClassInstance() should repopulate it's defaults after changing to an instance of a different class, otherwise databases will complain of NULL values being written to columns that don't accept NULL values. * [rev:88799] Updated ModelAsController->findOldPage() query to be cross-database compatible. From: Andrew Short * [rev:88774] Stopped HtmlEditorField->saveInto() from dying when encountering a link that cannot be made relative. From: Andrew Short * [rev:88773] Suppressed errors in SS_HTMLValue->setContent() so it can handle malformed HTML. * [rev:88752] error messages suppressed as a temporary fix * [rev:88664] Fixed bugs in ViewableData casting system. From: Sam Minnee * [rev:88639] Set publication base_url on every URL, just in case it gets re-set by some rogue script (from r73510) * [rev:88523] Fix regression in r88521 that prevented the index action from being explictly disabled by setting the * key in allowed_actions * [rev:88522] Improved reliability of PhpSyntaxTest on build slave. * [rev:88521] Ensure that the index action works even if allowed_actions is set. * [rev:88513] #3858: Updated StaticExporter to handle nested pages. From: Andrew Short * [rev:88512] #3724: Updated Link() methods to accept an action parameter. From: Andrew Short * [rev:88508] Updated Controller->hasAction() to use RequestHandler->allowedActions() so that extension actions are recognised. From: Andrew Short * [rev:88503] Fixed viewing a translatable page by URL without explicitly setting a Locale in ContentController->handleRequest(). From: Andrew Short * [rev:88494] Fixed Controller::join_links() to properly handle multiple consecutive slashes. From: Andrew Short * [rev:88493] Use Link() on the controller to generate to form action path. From: Andrew Short * [rev:88473] #3862: Explicitly defined browsing and viewing actions on CodeViewer. From: Andrew Short * [rev:88471] #2133: Removed UniqueTextField JavaScript that was causing URLSegments to be incorrectly rewritten if they had a number at the end. From: Andrew Short * [rev:88469] Updated HTTP::findByTagAndAttribute() to be more versatile, especially when dealing with attributes containing special characters. From: Andrew Short * [rev:88218] #3685: Fixed setting of character set by default when no content negotiator is used. * [rev:88145] Added setup/teardown routines to SiteTreeActionsTest to avoid breaking with Translatable enabled on recent canTranslate()/canEdit() extensions * [rev:88143] Added setup/teardown routines to SiteTreeTest and SiteTreePermissionsTest to avoid breaking with Translatable enabled on recent canTranslate()/canEdit() extensions * [rev:88139] Changed CMSMain->LangSelector() to always return a DropdownField, which ensures the 'Locale' parameter is always available to be passed along with ajax queries * [rev:88138] Filter both 'available' and 'new' languages in LanguageDropdownField for canTranslate() permissions * [rev:88124] Added required permissions to TranslatableSearchFormTest * [rev:88003] Fixed CSVBulkLoaderTest not to assume ID ordering in the assertions, which breaks with databases not ordering by PK automatically (e.g. Postgres) * [rev:88000] Fixed SearchContextTest capitalization of string assertions * [rev:87926] Fixed SearchFilterApplyRelationTest not to assume ID ordering in the assertions, which breaks with databases not ordering by PK automatically (e.g. Postgres) * [rev:87925] Fixed SoapModelAccessTest not to assume ID ordering in the assertions, which breaks with databases not ordering by PK automatically (e.g. Postgres) * [rev:87922] Fixed RestfulServerTest not to assume ID ordering in the assertions, which breaks with databases not ordering by PK automatically (e.g. Postgres) * [rev:87913] Fixed ID associations in TableListFieldTest (was assuming numerically ascending IDs, which isnt necessarily true in Postgres) * [rev:87897] tests which aren't supported by Postgres temporarily disabled * [rev:87456] #4579: Translatable's call to new LanguageDropdownField() broked * [rev:87234] Fix MemoryLimitTest not to fail on machines with <1G of memory and later versions of PHP 5.2.x that check available memory before setting memory_limit setting. * [rev:87228] Fixed bug in recent changes to Hierarchy::liveChildren() to do with Translatable * [rev:87210] Fixed Hierarchy::liveChildren() to work on PostgreSQL * [rev:87131] Don't throw a notice-level error in DB::getConn() if connection hasn't been set yet, to mimic previous behaviour. * [rev:86876] Fixed content-type for SapphireSoapServer->wsdl() (#4570, thanks Cristian) * [rev:86556] missplaced quotes were ruining unit tests * [rev:86532] $params variable removed * [rev:86414] Fixed SearchFilterApplyRelationTest to match new SearchContext->addFilter() API: Needs the full name including relation instead of the ambiguous stripped name. This matches DataObject->scaffoldSearchFields() and getDefaultSearchContext() * [rev:86218] Initializing controllers through init() in WidgetArea->WidgetControllers() * [rev:86217] Return FALSE in SapphireTest->assertDOSEquals() if no valid DataObjectSet is passed in * [rev:86170] ID column in delete function now quoted properly * [rev:86085] Don't lowercase permission codes contained in $allowed_actions in RequestHandler->checkAccessAction(). Permission checks are case sensitive. * [rev:86060] Made SecurityAdminTest more resilient against changes to localized strings, by inspecting the CSV line-by-line instead * [rev:86008] Consistently returning from a Security::permissionFailure() to avoid ambiguous situations when controllers are in ajax mode * [rev:85817] Fixed WidgetControllerTest by adding missing url routing to ContentController (see r85789) * [rev:85758] Detecting DataObjectSet for readonly transformations in CheckboxSetField (thanks martijn, #4527) * [rev:85713] moved $versionAuthor variable invocation into a check for the existence of the $record variable on which it depends (Ticket #4458) * [rev:85696] Ticket #4220 - Copying of uploaded files from temp to assets folder fails on IIS installs; simple patch fixes it * [rev:85514] More robust URL handling in SecurityTest to avoid failing on custom /admin redirects * [rev:85513] More robust URL handling in CMSMainTest to avoid failing on custom /admin redirects * [rev:85336] Fixed SiteTree::can_edit_multiple() and canEdit() to collect permissions from different Versioned tables, which fixes querying a SiteTree record which has been deleted from stage for its permissions (e.g. in SiteTreeActionsTest) * [rev:85330] Disabled PHPUnit backup of global variables, which caused i18n::_t() calls in subsequent test cases to fail because of a cached empty global * [rev:85310] Limiting i18n::include_by_locale() to scan directories only * [rev:85281] Implementing TestOnly interface in ModelAdminTest to avoid having it included automatically in CMSMenu and hence breaking other tests like LeftAndMainTest. * [rev:85157] #4423: Don't allow page duplication if canCreate is false. * [rev:85136] #3713 Escape HTTP request URL properly in DebugView::writeError() using htmlentities() * [rev:85130] merge r 85079 from branches/iss to fix Payment Validation of php side when submit a OrderForm * [rev:85120] Fix the bug in buildSQL() by trying to join an table with non-exsiting composite db field like "Money" * [rev:85086] #4463: Set AuthorID and PublisherID correctly * [rev:85085] Use default File classname in Folder::syncChildren() * [rev:85076] #3228 Fixed undefined offset error in Text::BigSummary() if trying to summarise text that is smaller than the requested word limit * [rev:85039] SelectionGroup.js typo, prevAl()l change to nextAll() * [rev:84980] Fixed issues with recent CMSMenu refactoring. * [rev:84976] SelectionGroup should include jQuery and jQuery livequery plugin when it's used or it will fail * [rev:84971] Fixed code for regenerating cached test manifest. * [rev:84843] #4486 Make use of DataObject::get_by_id() in File::getRelativePath() instead of building ID query manually in a get_one() * [rev:84796] Fixed querying of composite fields (broken due to inappropriate optimisation of hasField) * [rev:84789] Reverted some changes from r84163 because they broke cases where you have two fields of the same name on different subclasses. * [rev:84167] Performance improvement to Member::currentUserID() * [rev:84166] Performance imporvement to i18n::include_by_locale * [rev:84164] Removed deprecated (and slower) eregi_replace * [rev:84162] Removed some code that needed Extension to extend from Object. * [rev:84156] Ameneded r84151 so that the application order of extensions is the same as it was previously. * [rev:84155] Ameneded r84151 so that the application order of extensions is the same as it was previously. * [rev:84147] Added static resetting methods for more reliable test execution. * [rev:84093] Fixed SQLQuery::filtersOnID() for cases where a ClassName filter is inserted before the ID filter. * [rev:84092] Fixed filtering by archive date * [rev:84086] an time field input between 12:00pm to 12:59pm can't save back to database or always save as 00:00:00. * [rev:84079] VirtualPages won't call SiteTree_Controller anymore. * [rev:84068] Restored SiteTree::canView() functionality. * [rev:84066] Fixed some bugs in the performance fixes on Permission * [rev:84065] Fixed manifest builder tests to not have fake data, and to test that classes can be in files with different names * [rev:84064] Removed Requirements::combine_files() reference to non-existent cms/javascript/FilterSiteTree.js * [rev:84063] Don't make the Director completely fail if there was output prior to session_start() being called. * [rev:84000] prevent a nasty permissions situation where no one but an admin can edit a new page * [rev:83999] prevent a nasty permissions situation where no one but an admin can edit a new page * [rev:83970] Using standard SQL and SSDatetime::now() in SideReport_RecentlyEdited (see #4052) * [rev:83969] Fixed SiteTreeActionsTest to use unconditional class defintion - was failing due to recent changes in ClassInfo and class_exists() ### Enhancement * [rev:91044] Added optional $sid parameter to Session::start() to start the session using an existing session ID * [rev:90084] Changed Hierarchy->numChildren() caching to be instance specific and respect flushCache(). This increases the amount of queries on large sets, but decreases the time for a single instance call (implemented in r89999) * [rev:89999] Only run a single query per class for Hierarchy::numChildren() * [rev:89883] Improved CMSSiteTreeFilter API to make it easier to create custom filter.s (from r89071, from r88465) * [rev:89820] Current search and current page of asset section are persistent. Fixes the open source ticket #4470 and also a part of #4256 (from r84091) * [rev:89815] FilesystemSyncTask: If folderID GET parameter is available, only synchronise that folder ID - useful for only synchronising a specific folder and it's children (from r82841) * [rev:89813] Return the results of the FilesystemSyncTask to the status message in the CMS instead of a generic success message (from r82618) * [rev:89724] Filesystem::sync() now accepts a folderID argument, meaning you can specifically target a folder and it's children to sychronise, instead of everything (from r82840) * [rev:89717] Filesystem::sync() will now return the number of added and deleted files and folders instead of null (from r82616, 82617 and 82724) * [rev:89182] Fixed sapphire execution if you run the uninstalled sake from a foreigh directory. (from r88533) * [rev:88635] Added Member::set_login_marker_cookie(), to let developers bypass static caching for logged-in users (from r73803) * [rev:88633] Make base tag in 404 page dynamic (from r72282) * [rev:88570] Improved performance of ViewableData casting by removing an object::get_static call From: Sam Minnee * [rev:88518] #3729: Updated the link inserter to insert a shortcode rather than a plain HTML link. From: Andrew Short * [rev:88505] Updated ContentController->handleRequest() to use Controller->hasAction() to check whether to fall over to a child page, rather than relying on an error response from Controller->handleRequest(). From: Andrew Short * [rev:88504] Cached the value for RootURLController::get_homepage_link() between calls. From: ajshort * [rev:88502] Updated the SiteTree URLSegment conflict resolver to work with nested URLs. * [rev:88501] Updated SiteTree CMS fields to be in line with nested URL changes. From: Andrew Short * [rev:88499] Refactored ModelAsController to only grab the first page of a request, then pass control on to it. From: Andrew Short * [rev:88491] #3279: Updated the link inserter to insert a shortcode rather than a plain HTML link. From: Andrew Short * [rev:88489] Updated the SiteTree link and section code to derive data from the current page, rather than relying on its own cache. * [rev:88488] Added Hierachy->getAncestors() to return all the parent objects of the class in a DataObjectSet. From: Andrew Short * [rev:88487] Update ContentController to manually set the current Director page in handleRequest(). * [rev:88482] Refactored TreeDropdownField to generate and manage the tree using Hierachy's ParentID data, rather than relying on the client. From: Andrew Short * [rev:88480] Added ErrorPage::response_for() to get a response for a HTTP error code and request. * [rev:88479] Added ModelAsController::controller_for() to link a SiteTree object to its controller. From: Andrew Short * [rev:88478] Added HTTPRequest->isMedia() to check if a request is for a common media type. From: Andrew Short * [rev:88477] Added Controller->hasActionTemplate() to check if a template exists for a specific action. From: Andrew Short * [rev:88476] Updated SiteTree linking methods to generate nested URLs. * [rev:88474] Added template and value methods to database fields. * [rev:88139] Passing sitetree instance to CMSMain->LangSelector() in order to trigger canTranslate() filtering * [rev:88125] Added Translatable->getAllowedLocalesForMember() * [rev:88123] Added Translatable->providePermissions() * [rev:87777] Added ComponentSet->getComponentInfo() (#4587, thanks rorschach) * [rev:86506] Database specific version of RANDOM() created * [rev:86402] Added SearchContext->getFullName() to preserve the original fieldname including the relationship * [rev:86338] Added TableListField->paginationBaseLink * [rev:86216] Supporting full parameter signature in Versioned->Versions(), allVersions() * [rev:86027] Limiting "alc_enc" cookie (remember login token) to httpOnly to reduce risk of information exposure through XSS * [rev:86026] Added full parameter signature of PHP's set_cookie() to Cookie::set(), including the new $httpOnly flag * [rev:86021] Avoid information disclosure in Security/lostpassword form by returning the same message regardless wether a matching email address was found in the database. * [rev:86017] Added Member->FailedLoginCount property to allow Member->registerFailedLogin() to persist across sessions by writing them to the database, and be less vulnerable to brute force attacks. This means failed logins will persist longer than before, but are still reset after a valid login. * [rev:85823] Allowing Widget->Content() to render with any templates found in ancestry instead of requiring a template for the specific subclass * [rev:85789] Added handleWidgets() to ContentController to support new Widget_Controller class * [rev:85736] added tinymce valid element to allow style, ids and classes on any element to allow for styling hooks. Ticket: #4455 * [rev:85731] hide unmoderated page comments from the page comment RSS feed. Ticket #4477 * [rev:85716] Ticket #3910 - MySQL Time Zone support (alternative time zone to that of the website to which the server is set to) * [rev:85709] added option to truncate (clear) database table before importing a new CSV file with CSVBulkerLoader and ModelAdmin. * [rev:85700] Ticket #4297 - Use Director::baseFolder instead of relative links in sapphire/core/Image.php * [rev:85281] Filtering out TestOnly classes in CMSMenu::get_cms_classes() * [rev:84860] convert SelectionGroup.js from prototype version to jQuery version * [rev:84816] Updated SSLogErrorEmailFormatter to support NOTICE priority level logging * [rev:84774] Added SSLog, SSLogEmailWriter and SSLogErrorEmailFormatter for silverstripe message reporting * [rev:84165] Improved performance of DataObject::hasField() * [rev:84160] Object::__construct() performance improved slightly. * [rev:84159] Improved performance of Object::uninherited_static() * [rev:84158] Improved performance of Object::allMethodNames() and Object::addMethodsFrom() * [rev:84149] add more assertion in SearchFilterAapplyRelationTest to test more cases for many_many relation. * [rev:84117] add more assertion in SearchFilterAapplyRelationTest to test more cases for many_many relation. * [rev:84113] add "InnerJoin" clause for an has_many component's ancestry classes for SearchFilter::applyRelation() so that an searchfliter could filter on that component's ancestry's field. add unit tests for this enhancement and r83500 * [rev:84073] added new permission, SITETREE_REORGANISE * [rev:83798] #3638: There is no longer any need to have the class name match the PHP filename * [rev:83789] Added ClassInfo::is_subclass_of() for better performance * [rev:83674] sitetree filters now show up in a dropdown, and you can add your own by extending CMSSiteTreeFilter ### Other * [rev:90071] Merge branch 'master' of :sminnee/sapphire From: Sam Minnee * [rev:89715] (from r82175) * [rev:89702] Merge branch 'master' of :sminnee/silverstripe-cms From: Sam Minnee * [rev:89224] slightly later, so FormResponses can be overridden if necessary. (from r85614) * [rev:89220] ENHANCMENT side reports can now have parameters (from r85329) * [rev:89207] ENHANCMENT improved reporting around broken links/files (from r88993) * [rev:89186] #108 - Subsite Virtual Page ordering (from r84848) * [rev:89178] as they are confusing. (from r88019) * [rev:89174] #148 - Stable against restructures (from r87251) * [rev:89157] pointing at. (from r85197) * [rev:89155] #63 - Stable against restructures (from r84861) * [rev:88638] Add support for configuring multiple static publisher on a single site (from r70203) * [rev:88637] Basic authentication now (back) in configurefromenv.php (from r82551) * [rev:88527] Added readme for github From: Sam Minnee * [rev:88525] Added readme for GitHub copy of SilverStripe. From: Sam Minnee * [rev:88474] * Removed ViewableData_ObjectCustomised - now just uses ViewableData_Customised. * [rev:87896] Transaction test created * [rev:86684] Merged in Requirements::combine_files() fix from branches/2.3 - r83048 * [rev:86679] Merged in Member::sendInfo() bug fixes from branches/2.3 - r85779 * [rev:86678] Merged in Email template codes change from branches/2.3 - r84594 * [rev:86676] Merged in parent::__construct() additions from branches/2.3 - r83580 and r83587 * [rev:86669] Merged Text::ContextSummary() changes from branches/2.3 - r82035 and r82036 * [rev:86655] Patched to allow id|class|style|title attributes in all elements and allow empty td cells (will pad with non-breaking space) in line with #4332 and 4497 in 2.3.x changes to cms/LeftAndMain.php * [rev:84981] Ensure that DataObject->ClassName is set on object instantiation * [rev:84970] Made timing code for test runner more accurate (includes initial db build): * [rev:84814] ENHANCMENT: get svn merged revision 84806:84808 from branches/iss * [rev:84163] ENHANCMENT: Low-level performance improvements in database access.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/sitetree.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/sitetree.md
10,999
1,758,118,090
en
# Introduction Basic data-object representing all pages within the site tree. The omnipresent *Page* class (located in *mysite/code/Page.php*) is based on this class. # Usage ## Linking :::php // wrong $mylink = $mypage->URLSegment; // right $mylink = $mypage->Link(); // alternatively: AbsoluteLink(), RelativeLink() ## Querying Use *SiteTree::get_by_link()* to correctly retrieve a page by URL, as it taked nested URLs into account (a page URL might consist of more than one *URLSegment*). :::php // wrong $mypage = DataObject::get_one('SiteTree', '"URLSegment" = \'<mylink>\''); // right $mypage = SiteTree::get_by_link('<mylink>'); ## Nested/Hierarchical URLs In a nutshell, the nested URLs feature means that your site URLs now reflect the actual parent/child page structure of your site. In SilverStripe 2.3 and earlier, all page URLs would be on the top level, regardless of whether they were nested under other pages or not. In 2.4 however, the URLs now map directly to the chain of parent and child pages. The below table shows a quick summary of what these changes mean for your site: ![url table](http://silverstripe.org/assets/screenshots/Nested-URLs-Table.png) This feature is enabled by default in SilverStripe 2.4 or newer. To activate it for older sites, insert the following code in your *mysite/_config.php*: :::php SiteTree::enable_nested_urls(); After activating nested URLs on an existing database, you'll have to run a migration task to rewrite internal URL references in the *SiteTree.Content* field. http://<yourdomain.tld>/dev/tasks/MigrateSiteTreeLinkingTask ## Limiting Children/Parent By default, any page type can be the child of any other page type. However, there are 4 static properties that can be used to set up restrictions that will preserve the integrity of the page hierarchy. :::php class BlogHolder extends Page { // Blog holders can only contain blog entries static $allowed_children = array("BlogEntry"); static $default_child = "BlogEntry"; ... class BlogEntry extends Page { // Blog entries can't contain children static $allowed_children = "none"; static $default_parent = "blog"; static $can_be_root = false; ... class Page extends SiteTree { // Don't let BlogEntry pages be underneath Pages. Only underneath Blog holders. static $allowed_children = array("*Page,", "BlogHolder"); } * **allowed_children:** This can be an array of allowed child classes, or the string "none" - indicating that this page type can't have children. If a classname is prefixed by "*", such as "*Page", then only that class is allowed - no subclasses. Otherwise, the class and all its subclasses are allowed. * **default_child:** If a page is allowed more than 1 type of child, you can set a default. This is the value that will be automatically selected in the page type dropdown when you create a page in the CMS. * **default_parent:** This should be set to the *URLSegment* of a specific page, not to a class name. If you have asked to create a page of a particular type that's not allowed underneath the page that you have selected, then the default_parent page will be selected. For example, if you have a gallery page open in the CMS, and you select add blog entry, you can set your site up to automatically select the blog page as a parent. * **can_be_root:** This is a boolean variable. It lets you specify whether the given page type can be in the top level. Note that there is no allowed_parents control. To set this, you will need to specify the allowed_children of all other page types to exclude the page type in question. IMO this is less than ideal; it's possible that in a future release we will add allowed_parents, but right now we're trying to limit the amount of mucking around with the API we do. Here is an overview of everything you can add to a class that extends sitetree. NOTE: this example will not work, but it is a good starting point, for choosing your customisation. :::php class Page extends SiteTree { // tree customisation static $icon = ""; static $allowed_children = array("SiteTree"); // set to string "none" or array of classname(s) static $default_child = "Page"; //one classname static $default_parent = null; // NOTE: has to be a URL segment NOT a class name static $can_be_root = true; // static $hide_ancestor = null; //dont show ancestry class // extensions and functionality static $versioning = array(); static $default_sort = "Sort"; /static $extensions = array(); public static $breadcrumbs_delimiter = " &raquo; "; public function canCreate() { //here is a trick to only allow one (e.g. holder) of a page return !DataObject::get_one($this->class); } public function canDelete() { return false; } function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } ## Recipes ### Automatic Child Selection By default, `[api:SiteTree]` class to build a tree using the ParentID field. However, sometimes, you want to change this default behaviour. For example, in our e-commerce module, we use a many-to-many join, Product::Parents, to let you put Products in multiple groups. Here's how to implement such a change: * **Set up your new data model:** Create the appropriate many-many join or whatever it is that you're going to use to store parents. * **Define stageChildren method:** This method should return the children of the current page, for the current version. If you use DataObject::get, the `[api:Versioned]` class will rewrite your query to access the live site when appropriate. * **Define liveChildren method:** The method should return the children of the current page, for the live site. Both the CMS and the site's data controls will make use of this, so navigation, breadcrumbs, etc will be updated. If 1 node appears in the tree more than once, it will be represented differently. **TO DO:** Work out this representation. ### Custom Children Getters Returning custom children for a specific ''SiteTree'' subclass can be handy to influence the tree display within the CMS. An example of custom children might be products which belong to multiple categories. One category would get its products from a ''$many_many'' join rather than the default relations. Children objects are generated from two functions ''stageChildren()'' and ''liveChildren()'' and the tree generation in the CMS is calculated from ''numChildren()''. Please keep in mind that the returned children should still be instances of ''SiteTree''. Example: :::php class MyProduct extends Page { static $belongs_many_many = array( 'MyCategories' => 'MyCategory' ); } class MyCategory extends Page { static $many_many = array( 'MyProducts' => 'MyProduct' ); function stageChildren($showAll = false) { // @todo Implement $showAll return $this->MyProducts(); } function liveChildren($showAll = false) { // @todo Implement $showAll return $this->MyProducts(); } function numChildren() { return $this->MyProducts()->Count(); } } } } ### Multiple parents in the tree The `[api:LeftAndMain]` tree supports multiple parents. We overload CMSTreeClasses and make it include "manyparents" in the class list. :::php function CMSTreeClasses($controller) { return parent::CMSTreeClasses($controller) . ' manyparents'; } Don't forget to define a new Parent() method that also references your new many-many join (or however it is you've set up the hierarchy! :::php function getParent() { return $this->Parent(); } function Parent() { $parents = $this->Parents(); if($parents) return $parents->First(); } Sometimes, you don't want to mess with the CMS in this manner. In this case, leave stageChildren() and liveChildren() as-is, and instead make another method, such as ChildProducts(), to get the data from your many-many join. ### Dynamic Grouping Something that has been talked about [here](http://www.silverstripe.com/site-builders-forum/flat/15416#post15940) is the concept of "dynamic grouping". In essence, it means adding navigational tree nodes to the tree that don't correspond to a database record. How would we do this? In our example, we're going to update BlogHolder to show BlogEntry children grouped into months. We will create a class called BlogMonthTreeNode, which will extend ViewableData instead of DataRecord, since it's not saved into the database. This will represent our dynamic groups. #### LeftAndMain::getSiteTreeFor() Currently LeftAndMain::getSiteTreeFor() Calls LeftAndMain::getRecord($id) to get a new record. We need to instead create a new function getTreeRecord($id) which will be able to create BlogMonthTreeNode objects as well as look up SiteTree records from the database. The IDs don't **need** be numeric; so we can set the system to allow for 2 $id formats. * (ID): A regular SiteTree object * BlogMonthTreeNode-(BlogHolderID)-(Year)-(Month): A BlogMonthTreeNode object To keep the code generic, we will assume that if the $id isn't numeric, then we should explode('-', $id), and use the first part as the classname, and all the remaining parts as arguments to the constructor. Your BlogMonthTreeNode constructor will then need to take $blogHolderID, $year, $month as arguments. #### Divorcing front-end site's Children() and the CMS's AllChildrenIncludingDeleted() We need a way of cleanly specifying that there are two different child sources - children for the CMS tree, and children for the front-end site. * We currently have stageChildren() / liveChildren() * We should probably add cmsStageChildren() and cmsLiveChildren() into the mix, for SiteTree. AllChildrenIncludingDeleted() could then call the "cms..." versions of the functions, but if we were to to this, we should probably rename AllChildrenIncludingDeleted() to CMSTreeChildren() or something like that. #### BlogHolder::cmsStageChildren() & BlogHolder::cmsLiveChildren() We will need to define these methods, to * Get the stage/live children of the page, grouped by month * For each entry returned, generate a new BlogMonthTreeNode object. * Return that as a dataobjectset. #### BlogMonthTreeNode * Parameter 'ID': should return 'BlogMonthTreeNode-(BlogHolderID)-(Year)-(Month)'. You can do this by implementing getID(). * Methods cmsStageChildren() and cmsLiveChildren(): These should return the blog-entries for that month. After that, there will be some other things to tweak, like the tree icons. #### Where to from here? This is a lot of work for the specific example of blog-entries grouped by month. Instead of BlogMonthTreeNode, you could genericise this to a DynamicTreeGroup class, which would let you specify the parent node, the type of grouping, and the specific group. # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/core/SiteTree.html)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/versioned.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/versioned.md
878
1,758,118,090
en
# Versioned The Versioned class is a `[api:DataObject]` that adds versioning and staging capabilities to the objects. ### Trapping the publication event Sometimes, you'll want to do something whenever a particular kind of page is published. This example sends an email whenever a blog entry has been published. *SilverStripe 2.3* :::php class Page extends SiteTree { // ... function publish($fromStage, $toStage, $createNewVersion = false) { mail("[email protected]", "Blog published", "The blog has been published"); return $this->extension_instances['Versioned']->publish($fromStage, $toStage, $createNewVersion); } } *SilverStripe 2.4* :::php class Page extends SiteTree { // ... function onAfterPublish() { mail("[email protected]", "Blog published", "The blog has been published"); parent::onAfterPublish(); } }
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/bbcode.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/bbcode.md
589
1,758,118,090
en
# BBcode support Yes! SilverStripe supports BBCode * A bbcode tags help box shows when the "BBCode help" link is clicked. Javascript is required for this to work. * It has been encorporated as a modified version of PEAR's [HTML_BBCodeParser](http://pear.php.net/package/HTML_BBCodeParser) * BBCode is used by default in blog and forum. To add bbcode parsing to a template, instead of $Content use: :::php $Content.Parse(BBCodeParser) BBCode can be enabled in comments by adding the following to _config.php :::php PageComment::enableBBCode(); ## Currently Supported Tags
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/siteconfig.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/siteconfig.md
1,735
1,758,118,090
en
# Site Config The SiteConfig panel was introduced in 2.4 for providing a generic interface for managing site wide settings or functionality which is used throughout the site. Out of the box it provides 2 fields 'Site Name' and 'Site Tagline'. ## Accessing SiteConfig Options You can access SiteConfig options from any SS template by using the function $SiteConfig.FieldName :::html $SiteConfig.Title $SiteConfig.Tagline Or <% control SiteConfig %> $Title $AnotherField <% end_control %> Or if you want to access variables in the PHP you can do :::php $config = SiteConfig::current_site_config(); $config->Title ## Extending SiteConfig To extend the options available in the panel you can define your own fields via an Extension. Create a mysite/code/CustomSiteConfig.php file. :::php <?php class CustomSiteConfig extends Extension { function extraStatics() { return array( 'db' => array( 'FooterContent' => 'HTMLText' ) ); } public function updateCMSFields(FieldSet $fields) { $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContact", "Footer Contact Info")); } } Then add a link to your extension in the _config.php file like below. Object::add_extension('SiteConfig', 'CustomSiteConfig'); This tells SilverStripe to add the CustomSiteConfig extension to the SiteConfig class. After adding those two pieces of code, rebuild your database by visiting http://yoursite.com/dev/build and then reload the admin interface. You may need to reload it with a ?flush=1 on the end. You can define as many extensions for SiteConfig as you need. For example if you are developing a module you can define your own global settings for the dashboard.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/tablelistfield.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/tablelistfield.md
7,495
1,758,118,090
en
# Introduction Form field that embeds a list of `[api:DataObject]`s into a form, such as a member list or a file list. Provides customizeable columns, record-deletion by ajax, paging, sorting, CSV-export, printing, input by `[api:DataObject]` or raw SQL. # Example Here's an example of a full featured TableListField implementation. It features editing members in the database directly as a button on each record, as well as filtering, and sorting. It also makes use of the 'export' permission, allowing export of data as a CSV. :::php function getReportField() { $resultSet = new DataObjectSet(); $filter = ''; $sort = "Member.ID ASC"; $join = ''; $instance = singleton('Member'); $query = $instance->buildSQL($filter, $sort, null, $join); $query->groupby[] = 'Member.ID'; $report = new TableListField( 'CorporateReport', 'Member', array( 'ID' => 'ID', 'FirstName' => 'First Name', 'Surname' => 'Surname', 'Email' => 'Email', 'MembershipType' => 'Membership Type', 'MembershipStatus' => 'Membership Status', 'DateJoined' => 'Date Joined', 'PaidUntil' => 'Paid Until', 'Edit' => '' ) ); $report->setCustomQuery($query); $report->setFieldFormatting(array( 'Email' => '<a href=\"mailto: $Email\" title=\"Email $FirstName\">$Email</a>', 'Edit' => '<a href=\"admin/security/index/1?executeForm=EditForm&ID=1&ajax=1&action_callfieldmethod&fieldName=Members&ctf[childID]=$ID&ctf[ID]=1&ctf[start]=0&methodName=edit\"><img src=\"cms/images/edit.gif\" alt=\"Edit this member\" /></a>' )); $report->setFieldCasting(array( 'DateJoined' => 'Date->Nice', 'PaidUntil' => 'Date->Nice' )); $report->setShowPagination(true); if(isset($_REQUEST['printable'])) { $report->setPageSize(false); } else { $report->setPageSize(20); } $report->setPermissions(array( 'export', 'delete', 'print' )); return $report; } For more information on each of the features used in the example, you can read below. # Features ## Source Input :::php // default: DataObject selection (e.g. all 'Product's) $myTableListField = new TableListField( 'MyName', 'Product', array('Price', 'Code') ); // custom DataObjectSet $myProducts = DataObject::get('Product','Code = "MyCode"'); $myTableListField->setCustomSourceItems($myProducts); // custom SQL $customCsvQuery = singleton('Product')->buildSQL(); $customCsvQuery->select[] = "CONCAT(col1,col2) AS MyCustomSQLColumn"; $myTableListField->setCustomCsvQuery($customQuery); TableListField also tries to resolve Component-relations(has_one, has_many) and custom getters automatically: :::php $myTableListField = new TableListField( 'MyName', 'Product', array( 'Buyer.LastName', 'PriceWithShipping' ) ); // Product.php Example class Product extends DataObject { $has_one = array('Buyer'=>'Member'); function getPriceWithShipping() { return $this->Price + $this->Shipping; } } ## Pagination Paging works by AJAX, but also works without javascript on link-basis. :::php $myTableListField->setPageSize(100); // defaults to 20 ## Sorting The easiest method is to add the sorting criteria as a constructor parameter. Sorting should be applied manually, where appropriate. Only direct columns from the produced SQL-query are supported. Example (sorting by "FirstName" column): :::php $report = new TableListField( 'CorporateReport', // name 'Member', // sourceClass array( 'ID' => 'ID', 'FirstName' => 'First Name', 'LastName' => 'Last Name', ), // fieldList null, // sourceFilter 'FirstName' // sourceSort ); If you want to sort by custom getters in your DataObject, please reformulate them to a custom SQL column. This restriction is needed to avoid performance-hits by caching and sorting potentially large datasets on PHP-level. ## Casting Column-values can be casted, based on the casting-types available through DBObject (sapphire/core/model/fieldtypes). :::php $myTableListField->setFieldCasting(array( "MyCustomDate"=>"Date", "MyShortText"=>"Text->FirstSentence" )); ## Permissions Permissions vary in different TableListField-implementations, and are evaluated in the template. By default, all listed permissions are enabled. :::php $myTableListField->setPermissions(array( 'delete', 'export', 'print' )); ## Formatting Specify custom formatting for fields, e.g. to render a link instead of pure text. Caution: Make sure to escape special php-characters like in a normal php-statement. :::php $myTableListField->setFieldFormatting(array( "myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>' )); ## Highlighting "Highlighting" is similiar to "Formatting", but applies to the whole row rather than a column. Definitions for highlighting table-rows with a specific CSS-class. You can use all column-names in the result of a query. Use in combination with {@setCustomQuery} to select custom properties and joined objects. :::php $myTableListField->setHighlightConditions(array( array( "rule" => '$Flag == "red"', "class" => "red" ), array( "rule" => '$Flag == "orange"', "class" => "orange" ) )); ## Export Export works only to CSV currently, with following specs: * Line delimiter: "\n" * Separator: ";" * Column-quotes: none :::php $myTableListField->setPermissions(array('export')); $myTableListField->setFieldListCsv(array( 'Price' => 'Price', 'ItemCount' => 'Item Count', 'ModelNumber' => 'Model Number' )); You can influence the exported values by adjusting the generated SQL. :::php $customCsvQuery = singleton('Product')->buildSQL(); $customCsvQuery->select[] = "CONCAT(col1,col2) AS MyCustomSQLColumn"; $myTableListField->setCustomCsvQuery($customQuery); $myTableListField->setFieldListCsv(array( 'MyCustomSQLColumn' )); ## Row-Summaries You can summarize specific columns in your result-set. The term "summary" is used in a broad sense, you can also implement averages etc. :::php $myTableListField->addSummary( 'Total Revenue and Sales Count', array( "Price" => array("sum","Currency->Nice"), "ItemCount" => "sum" ) ); In TableField-implementation, these summaries also react to changes in input-fields by javascript. Available methods: * sum * avg ## Grouping Used to group by a specific column in the DataObject and create partial summaries. Please use only together with addSummary(). (Automatically disables sorting). :::php $myTableListField->groupByField = 'MyColumnName'; # Best Practices ## Custom Sorting Please subclass TableListField to implement custom sorting, following the naming-convention "`colFunction_<yourFunctionName>`". :::php class CustomTableListField extends TableListField { // referenced through "dateAverage" function colFunction_dateAverage($values) { // custom date summaries } } ## Adding Utility-functions In case you want to perform utility-functions like "export" or "print" through action-buttons, make sure to subclass Utility() which collates all possible actions. ## Customizing Look&Feel You can exchange the used template, e.g. to change applied CSS-classes or the HTML-markup: :::php $myTableListField->setTemplate("MyPrettyTableListField"); # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/forms/fields-relational/TableListField.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/dataobjectset.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/dataobjectset.md
2,462
1,758,118,090
en
# Introduction This class represents a set of `[api:DataObject]s`, such as the results of a query. It is the base for all [datamodel](/topics/datamodel)-related querying. It implements the [Iterator interface](http://php.net/manual/en/language.oop5.iterations.php) introduced in PHP5. Relations (`has_many`/`many_many`) are described in `[api:ComponentSet]`, a subclass of DataObjectSet. # Usage ## Getting the size :::php $mySet->Count(); ## Getting an single element :::php $myFirstDataObject = $mySet->First(); $myLastDataObject = $mySet->Last(); ## Getting multiple elements :::php $mySpecialDataObjects = $mySet->find('Status', 'special'); $startingFromTen = $mySet->getOffset(10); $tenToTwenty = $mySet->getRange(10, 10); ## Getting one property :::php $myIDArray = $mySet->column('ID'); ## Grouping You can group a set by a specific column. Consider using `[api:SQLQuery]` with a *GROUP BY* statement for enhanced performance. :::php $groupedSet = $mySet->groupBy('Lastname'); ## Sorting Sort a set by a specific column. :::php $mySet->sort('Lastname'); //ascending $mySet->sort('Lastname', 'DESC'); //descending This works on the object itself, so do NOT do something like this: :::php $sortedSet = $mySet->sort('Lastname'); //ascending ## Merge with other DataObjectSets :::php $myFirstSet->merge($mySecondSet); // $myFirstSet now contains all combined values ## Mapping for Dropdowns When using `[api:DropdownField]` and its numerous subclasses to select a value from a set, you can easily map the records to a compatible array: :::php $map = $mySet->toDropDownMap('ID', 'Title'); $dropdownField = new DropdownField('myField', 'my label', $map); ## Converting to array :::php $myArray = $mySet->toArray(); ## Output as HTML-list Use [buildNestedUL](http://doc.silverstripe.com/assets/classes/default/DataObjectSet.html#buildNestedUL) to return a nested unordered list out of a "chain" of DataObject-relations. ## Checking for existence It is good practice to check for empty sets before doing any iteration. :::php $mySet = DataObject::get('Players'); if($mySet->exists()) foreach($mySet as $player) ## Paging DataObjects have native support for dealing with **pagination**. See *setPageLimits*, *setPageLength*, etc. FIXME Complete pagination documentation # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/DataObjectSet.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/complextablefield.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/complextablefield.md
5,004
1,758,118,090
en
# ComplexTableField ## Introduction Shows a group of DataObjects as a (readonly) tabular list (similiar to `[api:TableListField]`. You can specify limits and filters for the resultset by customizing query-settings (mostly the ID-field on the other side of a one-to-many-relationship). See `[api:TableListField]` for more documentation on the base-class ## Source Input See `[api:TableListField]`. ## Setting Parent/Child-Relations ComplexTableField tries to determine the parent-relation automatically by looking at the $has_one property on the listed child, or the record loaded into the surrounding form (see getParentClass() and getParentIdName()). You can force a specific parent relation: :::php $myCTF->setParentClass('ProductGroup'); ## Customizing Popup By default, getCMSFields() is called on the listed DataObject. You can override this behaviour in various ways: :::php // option 1: implicit (left out of the constructor), chooses based on Object::useCustomClass or specific instance $myCTF = new ComplexTableField( $this, 'MyName', 'Product', array('Price','Code') ) // option 2: constructor $myCTF = new ComplexTableField( $this, 'MyName', 'Product', array('Price','Code'), new FieldSet( new TextField('Price') ) ) // option 3: constructor function $myCTF = new ComplexTableField( $this, 'MyName', 'Product', array('Price','Code'), 'getCustomCMSFields' ) ## Customizing Display & Functionality If you don't want several functions to appear (e.g. no add-link), there's several ways: * Use ComplexTableField->setPermissions(array("show","edit")) to limit the functionality without touching the template (more secure). Possible values are "show","edit", "delete" and "add". * Subclass ComplexTableField and override the rendering-mechanism * Use ComplexTableField->setTemplate() and ComplexTableField->setTemplatePopup() to provide custom templates ### Customising fields and Requirements in the popup There are several ways to customise the fields in the popup. Often you would want to display more information in the popup as there is more real-estate for you to play with. ComplexTableField gives you several options to do this. You can either * Pass a FieldSet in the constructor. * Pass a String in the constructor. The first will simply add the fieldset to the form, and populate it with the source class. The second will call the String as a method on the source class (Which should return a FieldSet) of fields for the Popup. You can also customise Javascript which is loaded for the Lightbox. As Requirements::clear() is called when the popup is instantiated, ComplexTableField will look for a function to gather any specific requirements that you might need on your source class. (e.g. Inline Javascript or styling). For this, create a function called "getRequirementsForPopup". ## Getting it working on the front end (not the CMS) Sometimes you'll want to have a nice table on the front end, so you can move away from relying on the CMS for maintaing parts of your site. You'll have to do something like this in your form: :::php $tableField = new ComplexTableField( $controller, 'Works', 'Work', array( 'MyField' => 'My awesome field name' ), 'getPopupFields' ); $tableField->setParentClass(false); $fields = new FieldSet( new HiddenField('ID', ''), $tableField ); You have to hack in an ID on the form, as the CMS forms have this, and front end forms usually do not. It's not a perfect solution, but it works relatively well to get a simple ComplexTableField up and running on the front end. To come: Make it a lot more flexible so tables can be easily used on the front end. It also needs to be flexible enough to use a popup as well, out of the box. ## Subclassing Most of the time, you need to override the following methods: * ComplexTableField->sourceItems() - querying * ComplexTableField->DetailForm() - form output * ComplexTableField_Popup->saveComplexTableField() - saving ## Examples * `[api:AssetTableField]` * `[api:MemberTableField]` ## API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/forms/fields-relational/ComplexTableField.html). ## Todo * Find a less fragile solution for accessing this field through the main controller and ReferencedField, e.g. build a seperate CTF-instance (doesn't necessarly have to be connected to the original by ReferencedField) * Control width/height of popup by constructor (hardcoded at the moment) * Integrate search from MemberTableField.php directly on ComplexTableField * Less performance-hungry implementation of detail-view paging (don't return all items on a single view) * Use automatic has-many and many-many functions to return a ComponentSet rather than building the join manually * Javascript/Ajax-Sorting (see http://www.activewidgets.com/grid/ and http://openrico.org/rico/livegrid.page)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/dataobject.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/dataobject.md
4,863
1,758,118,090
en
# DataObject ## Introduction A single database record & abstract class for the data-access-model. ## Usage * [datamodel](/topics/datamodel): The basic pricinples * [data-types](/topics/data-types): Casting and special property-parsing * `[api:DataObject]`: A "container" for DataObjects ### Basics The call to ''DataObject->getCMSFields()'' is the centerpiece of every data administration interface in Silverstripe, which returns a `[api:FieldSet]`''. :::php class MyPage extends Page { function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Content',new CheckboxField('CustomProperty')); return $fields; } } ## Scaffolding Formfields These calls retrieve a `[api:FieldSet]` for the area where you intend to work with the scaffolded form. ### For the CMS // Requirements: SilverStripe 2.3.// :::php $fields = singleton('MyDataObject')->getCMSFields(); ### For the Frontend Used for simple frontend forms without relation editing or `[api:TabSet] behaviour. Uses ''scaffoldFormFields()'' by default. To customize, either overload this method in your subclass, or decorate it by ''DataObjectDecorator->updateFormFields()''. // Requirements: SilverStripe 2.3.// :::php $fields = singleton('MyDataObject')->getFrontEndFields(); ## Customizing Scaffolded Fields // Requirements: SilverStripe 2.3.// This section covers how to enhance the default scaffolded form fields from above. It is particularly useful when used in conjunction with the `[api:ModelAdmin]` in the CMS to make relevant data administration interfaces. ### Searchable Fields // Requirements: SilverStripe 2.3.// The ''$searchable_fields'' property uses a mixed array format that can be used to further customize your generated admin system. The default is a set of array values listing the fields. Example: Getting predefined searchable fields :::php $fields = singleton('MyDataObject')->searchableFields(); Example: Simple Definition :::php class MyDataObject extends DataObject { static $searchable_fields = array( 'Name', 'ProductCode' ); } Searchable fields will be appear in the search interface with a default form field (usually a TextField) and a default search filter assigned (usually an ExactMatchFilter). To override these defaults, you can specify additional information on ''$searchable_fields'': :::php class MyDataObject extends DataObject { static $searchable_fields = array( 'Name' => 'PartialMatchFilter', 'ProductCode' => 'NumericField' ); } If you assign a single string value, you can set it to be either a FormField or SearchFilter. To specify both, you can assign an array: :::php class MyDataObject extends DataObject { static $searchable_fields = array( 'Name' => array( 'field' => 'TextField', 'filter' => 'PartialMatchFilter', ), 'ProductCode' => array( 'title' => 'Product code #', 'field' => 'NumericField', 'filter' => 'PartialMatchFilter', ), ); } To include relations (''$has_one'', ''$has_many'' and ''$many_many'') in your search, you can use a dot-notation. :::php class Team extends DataObject { static $db = array( 'Title' => 'Varchar' ); static $many_many = array( 'Players' => 'Player' ); static $searchable_fields = array( 'Title', 'Players.Name', ); } class Player extends DataObject { static $db = array( 'Name' => 'Varchar', 'Birthday' => 'Date' ); static $belongs_many_many = array( 'Teams' => 'Team' ); } ### Summary Fields // Requirements: SilverStripe 2.3.// Summary fields can be used to show a quick overview of the data for a specific DataObject record. Most common use is their display as table columns, e.g. in the search results of a `[api:ModelAdmin]` CMS interface. Example: Getting predefined summary fields :::php $fields = singleton('MyDataObject')->summaryFields(); Example: Simple Definition :::php class MyDataObject extends DataObject { static $db = array( 'Name' => 'Text', 'OtherProperty' => 'Text', 'ProductCode' => 'Int', ); static $summary_fields = array( 'Name', 'ProductCode' ); } To include relations in your summaries, you can use a dot-notation. :::php class OtherObject extends DataObject { static $db = array( 'Title' => 'Varchar' ); } class MyDataObject extends DataObject { static $db = array( 'Name' => 'Text' ); static $has_one = array( 'OtherObject' => 'OtherObject' ); static $summary_fields = array( 'Name', 'OtherObject.Title' ); } ## API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/core/DataObject.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/member.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/member.md
4,711
1,758,118,090
en
**This is partially deprecated - see the `[api:DataObject]` page for more information** # Introduction The Member class is used to represent user accounts on a Silverstripe site (including newsletter recipients). ## Testing For Logged In Users The Member class comes with 2 static methods for getting information about the current logged in user. **Member::currentUserID()** Retrieves the ID (int) of the current logged in member. Returns *0* if user is not logged in. Much lighter than the next method for testing if you just need to test. :::php // Is a member logged in? if( Member::currentUserID() ) { // Yes! } else { // No! } **Member::currentUser()** Returns the full *Member* Object for the current user, returns *null* if user is not logged in. :::php if( $member = Member::currentUser() ) { // Work with $member } else { // Do non-member stuff } ## Subclassing [note] This is the least desirable way of extending the Member class. It's better to use DataObjectDecorator (see below). [/note] You can defined subclasses of member to add extra fields or functionality to the built-in membership system. :::php class ParishouseMember extends Member { static $db = array( "Age" => "Int", "Address" => "Text", ); } To ensure that all new members are created using this class, put a call to Object::useCustomClass in (project)/_config.php: :::php Object::useCustomClass("Member", "ParishouseMember"); Note that if you want to look this class-name up, you can call Object::getCustomClass("Member") ### Overloading getCMSFields() If you overload the built-in function getCMSFields(), then you can change the form that is used to view & edit member details in the newsletter system. This function returns a FieldSet object. You should generally start by calling parent::getCMSFields() and manipulate the FieldSet from there. :::php function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertBefore(new TextField("Age"), "HTMLEmail"); $fields->removeByName("JobTitle"); $fields->removeByName("Organisation"); return $fields; } ## Extending Member or DataObject? Basic rule: Class "Member" should just be extended for entities who have some kind of login. If you have different types of Members in the system, you have to make sure that those with login-capabilities have unique email-addresses (as this is used for login-credentials). For persons without login-capabilities (e.g. for an address-database), you shouldn't extend member to avoid conflicts with the Member-database. This enables us to have a different subclass of Member for an email-address with login-data, and another subclass for the same email-address in the address-database. ### New Idea: Member Role Decorator Using inheritance to add extra behaviour or data fields to a member is limiting, because you can only inherit from 1 class. A better way is to use role decorators to add this behaviour. :::php DataObject::add_extension('Member', 'ForumRole'); // OR Member::add_role('ForumRole'); A role decorator is simply a subclass of DataObjectDecorator that is designed to be used to add behaviour to Member. The roles affect the entire class - all members will get the additional behaviour. However, if you want to restrict things, you should add appropriate Permission::checkMember() calls to the role's methods. :::php class ForumRole extends DataObjectDecorator { /** * Modify the field set to be displayed in the CMS detail pop-up */ function updateCMSFields(FieldSet $currentFields) { // Only show the additional fields on an appropriate kind of use if(Permission::checkMember($this->owner->ID, "VIEW_FORUM")) { // Edit the fieldset passed, adding or removing fields as necessary } } function extraStatics() { // Return an array containing keys 'db', 'has_one', 'many_many', 'belongs_many_many', } function somethingElse() { // You can add any other methods you like, which you can call directly on the member object. } } Sam is going to implement this change; Romain will be using it to create a ForumRole for the new forum module. # TODO * MemberTableField has to determine which fields is should display based on the subclass of the requested record * MemberTableField needs to have a switch for creating new Members with different fields * We should add a getOverviewFields() to each Member-class which specifiy which fields to use in the overview (and accordingly have different tables for each subclass of members) # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/security/Member.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/built-in-page-controls.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/built-in-page-controls.md
13,643
1,758,118,090
en
# Page Controls Ever wonder when you use $Title and `<% Control Children %>` what else you can do / call in the templates?. This page is here to help with a guide on what template controls you can call. **Note for advanced users:** These built-in page controls are defined in the `[api:SiteTree]` classes, which are the 'root' data-object and controller classes for all the sites. So if you're dealing with something that isn't a sub-class of one of these, our handy reference to 'built-in page controls' won't be so relevant. ## Page controls that can't be nested These page controls are defined on the **controller** which means they can only be used at a top level, not nested within another page control. ### Controlling Menus Datafeeds #### <% control Menu(1) %>, <% control Menu(2) %>, ... Returns a fixed level menu. Because this only works in the top level, you can't use it for nested menus. Used <% control Children %> instead. You can nest `<% control Children %>`. #### <% control ChildrenOf(page-url) %> This will create a datafeed of the children of the given page. Handy if you want a list of the subpages under staff (eg the staff) on the homepage etc ### Controlling Certain Pages #### <% control Level(1) %>, <% control Level(2) %>, $Level(1).Title, $Level(2).Content, etc Returns the current section of the site that we're in, at the level specified by the numbers. For example, imagine you're on the page __about us > staff > bob marley__: * `<% control Level(1) %>` would return the about us page * `<% control Level(2) %>` would return the staff page * `<% control Level(3) %>` would return the bob marley page #### <% control Page(my-page) %>$Title<% end_control %> "Page" will return a single page from the site tree, looking it up by URL. You can use it in the `<% control %>` format. Can't be called using $Page(my-page).Title. ## Page controls that can be used anywhere These are defined in the data-object and so can be used as nested page controls. Lucky us! we can control Children of Children of Children for example. ### Conditional Logic SilverStripe supports a simple set of conditional logic :::html <% if Foo %> // if Foo is true or an object do this <% else_if Bar %> // if Bar is true or an object do this <% else %> // then do this by default <% end_if %> See more information on conditional logic on http://doc.silverstripe.org/doku.php?id=templates#if_blocks ### Site wide settings Since 2.4.0, SilverStripe provides a generic interface for accessing global properties such as *Site name* or *Site tag line*. This interface is implemented by the [api:SiteConfig] class. ### Controlling Parents and Children #### <% control Children %> This will return the children of the current page as a nested datafeed. Useful for nested navigations such as pop-out menus. #### <% control AllChildren %> This will show all children of a page even if the option 'show in menus?' is unchecked in the tab panel behaviour. #### <% control Parent %> or $Parent.Title, $Parent.Content, etc This will return the parent page. The $ variable format lets us reference an attribute of the parent page directly. ### Site Navigation - Breadcrumbs #### <% control Breadcrumbs %> This will return a breadcrumbs widgets for the given page. You can call this on any data-object, so, for example, you could display the breadcrumbs of every search result if you wanted. It has a few options. #### <% control Breadcrumbs(3) %> Will return a maximum of 3 pages in the breadcrumb list, this can be handy if you're wanting to put breadcrumbs in a place without spilling #### <% control Breadcrumbs(3, true) %> Will return the same, but without any links. This is handy if you're wanting to put the breadcrumb list into another link tag. ### Links and Classes #### $LinkingMode, $LinkOrCurrent and $LinkOrSection These return different linking modes. $LinkingMode provides the greatest control, outputting 3 different strings: * link: Neither this page nor any of its children are current open. * section: A child of this page is currently open, which means that we're currently in this section of the site. * current: This page is currently open. A useful way of using this is in your menus. You can use the following code below to generate an class="current" or class="section" on your links. Take the following code :::html <li><a href="$Link" class="$LinkingMode">$Title</a></li> When viewed on the Home page it will render like this :::html <li><a href="home/" class="current">Home</a></li> $LinkOrCurrent ignores the section status, returning link instead. $LinkOrSection ingores the current status, returning section instead. Both of these options can simplify your CSS when you only have 2 different cases to consider. #### <% if LinkOrCurrent = current %> This is an alternative way to set up your menus - if you want different HTML for the current menu item, you can do something like this: :::html <% if LinkOrCurrent = current %> <strong>$Title</strong> <% else %> <a href="$Link">$Title</a> <% end_if %> #### <% if LinkOrSection = section %> Will return true if you are on the current page OR a child page of the page. Useful for menus which you only want to show a second level menu when you are on that page or a child of it #### <% if InSection(page-url) %> This if block will pass if we're currently on the page-url page or one of its children. ### Titles and CMS Defined Options #### $MetaTags This returns a segment of HTML appropriate for putting into the `<head>` tag. It will set up title, keywords and description meta-tags, based on the CMS content. If you don't want to include the title-tag (for custom templating), use **$MetaTags(false)**. #### $MenuTitle This is the title that you should put into navigation menus. CMS authors can choose to put a different menu title from the main page title. #### $Title This is the title of the page which displays in the browser window and usually is the title of the page. :::html <h1>$Title</h1> #### $URLSegment This returns the part of the URL of the page you're currently on. Could be handy to use as an id on your body-tag. ( when doing this, watch out that it doesn't create invalid id-attributes though.). This is useful for adding a class to the body so you can target certain pages. Watch out for pages named clear or anything you might have used in your CSS file :::html <body class="$URLSegment"> #### $ClassName Returns the ClassName of the PHP object. Eg if you have a custom HomePage page type with $ClassName in the template, it will return "HomePage" #### $BaseHref Returns the base URL for the current site. This is used to populate the `<base>` tag by default, so if you want to override `<% base_tag %>` with a specific piece of HTML, you can do something like `<base href="$BaseHref">``</base>` ### Controlling Members and Visitors Data #### <% control CurrentMember %>, <% if CurrentMember %> or $CurrentMember.FirstName CurrentMember returns the currently logged in member, if there is one. All of their details or any special Member page controls can be called on this. Alternately, you can use `<% if CurrentMember %>` to detect whether someone has logged in. To Display a welcome message you can do :::html <% if CurrentMember %> Welcome Back, $CurrentMember.FirstName <% end_if %> If the user is logged in this will print out :::html Welcome Back, Admin #### <% if PastMember %>, <% if PastVisitor %> These controls detect the visitor's previous experience with the site: * $PastVisitor will return true if the visitor has been to the site before * $PastMember will return true if the visitor has signed up or logged in on the site before ### Date and Time #### $Now.Nice, $Now.Year $Now returns the current date. You can call any of the [date methods](http://doc.silverstripe.com/doku.php?id=date) on it. #### $Created.Nice, $Created.Ago $Created returns the time the page was created, $Created.Ago returns how long ago the page was created. You can also call any of the [date methods](http://doc.silverstripe.com/doku.php?id=date) on it #### $LastEdited.Nice, $LastEdited.Ago $LastEdited returns the time the page was modified, $LastEdited.Ago returns how long ago the page was modified.You can also call any of the [date methods](http://doc.silverstripe.com/doku.php?id=date) on it ### DataObjectSet Options If you are using a DataObjectSet you have a wide range of methods you can call on it from the templates #### <% if Even %>, <% if Odd %>, $EvenOdd These controls can be used to do zebra-striping. $EvenOdd will return 'even' or 'odd' as appropriate. #### <% if First %>, <% if Last %>, <% if Middle %>, $FirstLast These controls can be used to set up special behaviour for the first and last records of a datafeed. `<% if Middle %>` is set when neither first not last are set. $FirstLast will be 'first', 'last', or '' #### $Pos, $TotalItems $TotalItems will return the number of items on this page of the datafeed, and Pos will return a counter starting at 1. #### $Top When you're inside a control loop in your template, and want to reference methods on the current controller you're on, breaking out of the loop to get it, you can use $Top to do so. For example: :::html $URLSegment <% control News %> $URLSegment <!-- may not return anything, as you're requesting URLSegment on the News objects --> $Top.URLSegment <!-- returns the same as $URLSegment above --> <% end_control %> ## Properties of a datafeed itself, rather than one of its items If we have a control such as `<% control SearchResults %>`, there are some properties, such as $SearchResults.NextLink, that aren't accessible within `<% control SearchResults %>`. These can be used on any datafeed. ### Search Results #### <% if SearchResults.MoreThanOnePage %> Returns true when we have a multi-page datafeed, restricted with a limit. #### $SearchResults.NextLink, $SearchResults.PrevLink This returns links to the next and previous page in a multi-page datafeed. They will return blank if there's no appropriate page to go to, so $PrevLink will return blank when you're on the first page. You can therefore use <% if PrevLink %> to keep your template tidy. #### $SearchResults.CurrentPage, $SearchResults.TotalPages CurrentPage returns the number of the page you're currently on, and TotalPages returns the total number of pages. #### $SearchResults.TotalItems This returns the total number of items across all pages. #### <% control SearchResults.First %>, <% control SearchResults.Last %> These controls return the first and last item on the current page of the datafeed. #### <% control SearchResults.Pages %> This will return another datafeed, listing all of the pages in this datafeed. It will have the following data available: * **$PageNum:** page number, starting at 1 * **$Link:** a link straight to that page * `<% if CurrentBool %>`:** returns true if you're currently on that page `<% control SearchResults.Pages(30) %>` will show a maximum of 30 pages, useful in situations where you could get 100s of pages returned. #### $SearchResults.UL This is a quick way of generating a `<ul>` containing an `<li>` and `<a>` for each item in the datafeed. Usually too restricted to use in a final application, but handy for debugging stuff. ## Quick Reference Below is a list of fields and methods that are typically available for templates (grouped by their source) - use this as a quick reference (not all of them are described above): ### All methods available in Page_Controller $NexPageLink, $Link, $RelativeLink, $ChildrenOf, $Page, $Level, $Menu, $Section2, $LoginForm, $SilverStripeNavigator, $PageComments, $Now, $LinkTo, $AbsoluteLink, $CurrentMember, $PastVisitor, $PastMember, $XML_val, $RAW_val, $SQL_val, $JS_val, $ATT_val, $First, $Last, $FirstLast, $MiddleString, $Middle, $Even, $Odd, $EvenOdd, $Pos, $TotalItems, $BaseHref, $Debug, $CurrentPage, $Top ### All fields available in Page_Controller $ID, $ClassName, $Created, $LastEdited, $URLSegment, $Title, $MenuTitle, $Content, $MetaTitle, $MetaDescription, $MetaKeywords, $ShowInMenus, $ShowInSearch, $HomepageForDomain, $ProvideComments, $Sort, $LegacyURL, $HasBrokenFile, $HasBrokenLink, $Status, $ReportClass, $ParentID, $Version, $EmailTo, $EmailOnSubmit, $SubmitButtonText, $OnCompleteMessage, $Subscribe, $AllNewsletters, $Subject, $ErrorCode, $LinkedPageID, $RedirectionType, $ExternalURL, $LinkToID, $VersionID, $CopyContentFromID, $RecordClassName ### All methods available in Page $Link, $LinkOrCurrent, $LinkOrSection, $LinkingMode, $ElementName, $InSection, $Comments, $Breadcrumbs, $NestedTitle, $MetaTags, $ContentSource, $MultipleParents, $TreeTitle, $CMSTreeClasses, $Now, $LinkTo, $AbsoluteLink, $CurrentMember, $PastVisitor, $PastMember, $XML_val, $RAW_val, $SQL_val, $JS_val, $ATT_val, $First, $Last, $FirstLast, $MiddleString, $Middle, $Even, $Odd, $EvenOdd, $Pos, $TotalItems, $BaseHref, $CurrentPage, $Top ### All fields available in Page $ID, $ClassName, $Created, $LastEdited, $URLSegment, $Title, $MenuTitle, $Content, $MetaTitle, $MetaDescription, $MetaKeywords, $ShowInMenus, $ShowInSearch, $HomepageForDomain, $ProvideComments, $Sort, $LegacyURL, $HasBrokenFile, $HasBrokenLink, $Status, $ReportClass, $ParentID, $Version, $EmailTo, $EmailOnSubmit, $SubmitButtonText, $OnCompleteMessage, $Subscribe, $AllNewsletters, $Subject, $ErrorCode, $LinkedPageID, $RedirectionType, $ExternalURL, $LinkToID, $VersionID, $CopyContentFromID, $RecordClassName
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/partial-caching.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/partial-caching.md
7,629
1,758,118,090
en
# Partial Caching Partial caching, new in SilverStripe 2.4, is a feature that allows the caching of just a portion of a page. As opposed to static publishing, which avoids the SilverStripe controller layer on cached pages, partial caching allows caching for pages that contain a mix of moderately static & user specific data, and still provide full access control and permission enforcement. The trade-off is that it does not provide as much performance improvement as static publishing, although for data heavy pages the speed increases can be significant. ## Basics The way you mark a section of the template as being cached is to wrap that section in a cached tag, like so: :::html <% cached %> $DataTable ... <% end_cached %> Each cache block has a cache key - an unlimited number of comma separated variables (in the same form as `if` and `control` tag variables) and quoted strings. Every time the cache key returns a different result, the contents of the block are recalculated. If the cache key is the same as a previous render, the cached value stored last time is used. Since the above example contains just one argument as the cache key, a string (which will be the same every render) it will invalidate the cache after the TTL has expired (default 10 minutes) Here are some more complex examples: From a block that updates every time the Page subclass it's the template for updates :::html <% cached 'database', LastEdited %> From a block that shows a login block if not logged in, or a homepage link if logged in, depending on the current member :::html <% cached 'loginblock', CurrentMember.ID %> From a block that shows a summary of the page edits if administrator, nothing if not :::html <% cached 'loginblock', LastEdited, CurrentMember.isAdmin %> ## Aggregates Often you want to invalidate a cache when any in a set of objects change, or when the objects in a relationship change. To help do this, SilverStripe 2.4 also introduces the concept of Aggregates. These calculate and return SQL aggregates on sets of DataObjects - the most useful for us being the Max aggregate. For example, if we have a menu, we want that menu to update whenever _any_ page is edited, but would like to cache it otherwise. By using aggregates, that's easy :::html <% cached 'navigation', Aggregate(Page).Max(LastEdited) %> If we have a block that shows a list of categories, we can make sure the cache updates every time a category is added or edited :::html <% cached 'categorylist', Aggregate(Category).Max(LastEdited) %> We can also calculate aggregates on relationships. A block that shows the current member's favourites needs to update whenever the relationship Member::$has_many = array('Favourites' => Favourite') changes. :::html <% cached 'favourites', CurrentMember.ID, CurrentMember.RelationshipAggregate(Favourites).Max(LastEdited) %> ## Cache key calculated in controller That last example is a bit large, and is complicating our template up with icky logic. Better would be to extract that logic into the controller :::php function FavouriteCacheKey() { $member = Member::currentUser(); return implode('_', array( 'favourites', $member->ID, $member->RelationshipAggregate('Favourites')->Max('LastEdited') )); } and then using that function in the cache key :::html <% cached FavouriteCacheKey %> ## Cache blocks and template changes In addition to the key elements passed as parameters to the cached control, the system automatically includes the template name and a sha1 hash of the contents of the cache block in the key. This means that any time the template is changed the cached contents will automatically refreshed. ## Purposely stale data In some situations it's more important to be fast than to always be showing the latest data. By constructing the cache key to invalidate less often than the data updates you can ensure rendering time is constant no matter how often the data updates. For instance, if we show some blog statistics, but are happy having them be slightly stale, we could do :::html <% cached 'blogstatistics', Blog.ID %> which will invalidate after the cache lifetime expires. If you need more control than that (cache lifetime is configurable only on a site-wide basis), you could add a special function to your controller: :::php function BlogStatisticsCounter() { return (int)(time() / 60 / 5); // Returns a new number every five minutes } and then use it in the cache key :::html <% cached 'blogstatistics', Blog.ID, BlogStatisticsCounter %> ## Cache block conditionals You may wish to conditionally enable or disable caching. To support this, in cached tags you may (after any key arguments) specify 'if' or 'unless' followed by a standard template variable argument. If 'if' is used, the resultant value must be true for that block to be cached. Conversely if 'unless' is used, the result must be false. Following on from the previous example, you might wish to only cache slightly-stale data if the server is experiencing heavy load: :::html <% cached 'blogstatistics', Blog.ID if HighLoad %> By adding a HighLoad function to your page controller, you could enable or disable caching dynamically. To cache the contents of a page for all anonymous users, but dynamically calculate the contents for logged in members, you could use something like: :::html <% cached unless CurrentUser %> As a shortcut, the template tag 'uncached' can be used - it is the exact equivilent of a cached block with an if condition that always returns false. The key and conditionals in an uncached tag are ignored, so you can easily temporarily disable a particular cache block by changing just the tag, leaving the key and conditional intact. :::html <% uncached %> ## Nested cacheblocks New since 2.4 beta 2 is the ability to nest independent cache blocks (with one important rule, discussed later). Any nested cache blocks are calculated independently from their containing block, regardless of the cached state of that container. This allows you to wrap an entire page in a cache block on the page's LastEdited value, but still keep a member-specific portion dynamic, without having to include any member info in the page's cache key. An example: :::html <% cached LastEdited %> Our wonderful site <% cached Member.ID %> Welcome $Member.Name <% end_cached %> $ASlowCalculation <% end_cached %> This will cache the entire outer section until the next time the page is edited, but will display a different welcome message depending on the logged in member. Cache conditionals and the uncached tag also work in the same nested manner. Since Member.Name is fast to calculate, you could also write the last example as: :::html <% cached LastEdited %> Our wonderful site <% uncached %> Welcome $Member.Name <% end_uncached %> $ASlowCalculation <% end_cached %> ## The important rule Currently cached blocks can not be contained within if or control blocks. The template engine will throw an error letting you know if you've done this. You can often get around this using aggregates. Failing example: :::html <% cached LastEdited %> <% control Children %> <% cached LastEdited %> $Name <% end_cached %> <% end_control %> <% end_cached %> Can be re-written as: :::html <% cached LastEdited %> <% cached RelationshipAggregate(Children).Max(LastEdited) %> <% control Children %> $Name <% end_control %> <% end_cached %> <% end_cached %>
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/index.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/index.md
0
1,758,118,090
en
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/staticpublisher.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/staticpublisher.md
8,795
1,758,118,090
en
## Introduction Many sites get too much traffic to justify dynamically sending every request. Caching is needed. The static publication system will generate static versions of your content that can be served without ever hitting PHP. See `[api:StaticExporter]` for a less flexible, but easier way of building a local static cache from all of your pages. ## Requirements *Requires SilverStripe 2.3* ## Usage SilverStripe doesn't have enough information about your template and data-structures to automatically determine which URLs need to be cached, and at which time they are considered outdated. By adding a custom method allPagesToCache() to your Page class, you can determine which URLs need caching, and hook in custom logic. This array of URLs is used by the publisher to generate folders and HTML-files. :::php class Page extends SiteTree { // ... /** * Return a list of all the pages to cache */ function allPagesToCache() { // Get each page type to define its sub-urls $urls = array(); // memory intensive depending on number of pages $pages = DataObject::get("SiteTree"); foreach($pages as $page) { $urls = array_merge($urls, (array)$page->subPagesToCache()); } // add any custom URLs which are not SiteTree instances $urls[] = "sitemap.xml"; return $urls; } /** * Get a list of URLs to cache related to this page */ function subPagesToCache() { $urls = array(); // add current page $urls[] = $this->Link(); // cache the RSS feed if comments are enabled if ($this->ProvideComments) { $urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID; } return $urls; } function pagesAffectedByChanges() { $urls = $this->subPagesToCache(); if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache()); return $urls; } } ## Single server Caching This setup will store the cached content on the same server as the CMS. This is good for performance enhancement. ### Setup Put this in mysite/_config.php. This will create static content in a "cache/" subdirectory, with an HTML suffix. :::php Object::add_extension("SiteTree", "FilesystemPublisher('cache/', 'html')"); * Put this into your .htaccess. It will serve requests from the cache, statically, if the cache file exists. Replace **sitedir** with the a subdirectory that you would like to serve the site from (for example, in your dev environment). [View .htaccess example](http://open.silverstripe.com/browser/modules/cms/trunk/code/staticpublisher/htaccess_example_rsyncsingleserver) * **New for 2.4:** In 2.4, we use a simple PHP script, static-main.php, to control cache lookup. This make the .htaccess update simpler. Just look for this line: RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] And change the PHP script from main.php to static-main.php: RewriteRule .* sapphire/static-main.php?url=%1&%{QUERY_STRING} [L] ## Using Static Publisher With Subsites Module Append the following code to mysite/config.php :::php FilesystemPublisher::$domain_based_caching = true; Instead of the above code snippet for Page.php, use the following code: :::php class Page extends SiteTree { // ... function allPagesToCache() { // Get each page type to define its sub-urls $urls = array(); // memory intensive depending on number of pages $pages = Subsite::get_from_all_subsites("SiteTree"); foreach($pages as $page) { $urls = array_merge($urls, (array)$page->subPagesToCache()); } return $urls; } function subPagesToCache() { $urls = array(); $urls[] = $this->AbsoluteLink(); return $urls; } function pagesAffectedByChanges() { $urls = $this->subPagesToCache(); if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache()); return $urls; } // ... some other code ... } And the last thing you need to do is adding your main site's host mapping to subsites/host-map.php. For example, your main site's host is mysite.com the content of the file would be: :::php <?php $subsiteHostmap = array ( // .. subsite hots mapping .., 'mysite.com', 'mysite.com' ); Remember that you need to add main site's host mapping every time a subsite is added or modified because the operation overwrites your manual modification to the file and subsite module does not add main site's hot mapping automatically at the moment. Another note for host-map.php file. This file doesn't not exist until you have created at least one subsite. ## Multiple Server Caching In this setup, you have one server that is your dynamic CMS server, and one or more separate servers that are responsible for serving static content. The publication system on the CMS will rsync changes to the static content servers as needed. No PHP files will be synced to the static content servers unless explicitly requested. All static assets (images, javascript, etc.) will be rsynced from their original locations. You can then put a load-balancer on the front of the static content servers. This approach is very secure, because you can lock the CMS right down (for example, by IP) and hide all the PHP code away from potential hackers. It is also good for high-traffic situations. ### Setup Add the RsyncMultiHostPublisher extension to your SiteTree objects in mysite/_config.php. This will create static content in a "cache/" subdirectory, with an HTML suffix. :::php Object::add_extension("SiteTree", "RsyncMultiHostPublisher('cache/', 'html')"); RsyncMultiHostPublisher::set_targets(array( '<rsyncuser>@<static-server1>:<webroot>', '<rsyncuser>@<static-server2>:<webroot>', )); Where `<rsyncuser>` is a unix account with write permissions to `<webroot>` (e.g. ''/var/www''), and `<static-server1>` and `<static-server2>` are the names of your static content servers. The number of servers is flexible and depends on your infrastructure and scalability needs. * Ensure that the ''rsync'' unix tool is installed on the CMS server, and ssh access is enabled on the static content servers. * No password can be specified for the SSH connection . The class assumes a key-based authentication without requiring a password for the username specified in `<rsyncuser>` (see [http://www.csua.berkeley.edu/~ranga/notes/ssh_nopass.html tutorial](http://www.csua.berkeley.edu/~ranga/notes/ssh_nopass.html tutorial)). * Put the .htaccess file linked below into the webroot of each static content server (and rename it to ''.htaccess''). It will serve requests from the cache, statically, if the cache file exists. Replace **sitedir** with the a subdirectory that you would like to serve the site from (for example, in your dev environment). [View .htaccess example](http://open.silverstripe.com/browser/modules/cms/trunk/code/staticpublisher/htaccess_example_rsyncmultiservers) ## Cache Control There is also the option to wrap some PHP logic around the static HTML content served by the content servers, which can greatly reduce the bandwidth required on your content servers. This code takes care of cache control through HTTP headers (''Cache-control'', ''If-modified-since''), meaning the files will only be delivered if they changed since the browser client last requested them. The last modification date for each static file is controlled by the publication script, meaning the cache gets invalidated on each publication. To enable cache control, specify "php" instead of "html" in the RsyncMultiHostPublisher definition. :::php Object::add_extension("SiteTree", "RsyncMultiHostPublisher('cache/', 'php')"); And use this slightly different .htaccess file. Make sure that index.php can be used as a directory index! [View .htaccess example](http://open.silverstripe.com/browser/modules/cms/trunk/code/staticpublisher/htaccess_example_rsyncwithphp) ## Deployment Once you've set up your rewrite rules and defined which pages need caching, you can build the static HTML files. This is done by the `[api:RebuildStaticCacheTask]` Execution via URL http://www.example.com/dev/buildcache?flush=1 Execution on CLI (via [sake](/topics/commandline)) sake dev/buildcache flush=1 Depending on which extension you've set up for your SiteTree (FilesystemPublisher or RsyncMultiHostPublisher), the method publishPages() either stores the generated HTML-files on the server's filesystem, or deploys them to other servers via rsync. It is adviseable to set dev/buildcache up as an automated task (e.g. unix cron) which continually rebuilds and redeploys the cache. ## Related * `[api:StaticExporter]`
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/database-structure.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/database-structure.md
5,551
1,758,118,090
en
# Database Structure SilverStripe is currently hard-coded to use a fix mapping between data-objects and the underlying database structure - opting for "convention over configuration". This page details what that database structure is. ## Base tables Each direct sub-class of DataObject will have its own table. The following fields are always created. * ID: Primary Key * ClassName: An enumeration listing this data-class and all of its subclasses. * Created: A date/time field set to the creation date of this record * LastEdited: A date/time field set to the date this record was last edited Every object of this class **or any of its subclasses** will have an entry in this table ### Extra Fields * Every field listed in the data object's **$db** array will be included in this table. * For every relationship listed in the data object's **$has_one** array, there will be an integer field included in the table. This will contain the ID of the data-object being linked to. The database field name will be of the form "(relationship-name)ID", for example, ParentID. ### ID Generation When a new record is created, we don't use the database's built-in auto-numbering system. Instead, we generate a new ID by adding 1 to the current maximum ID. ## Subclass tables At SilverStripe's heart is an object-relational model. And a component of object-oriented data is **inheritance**. Unfortunately, there is no native way of representing inheritance in a relational database. What we do is store the data sub-classed objects across **multiple tables**. For example, suppose we have the following set of classes: * Class SiteTree extends DataObject: Title, Content fields * Class Page extends SiteTree: Abstract field * Class NewsSection extends SiteTree: *No special fields* * Class NewsArticle extend Page: ArticleDate field The data for the following classes would be stored across the following tables: * SiteTree * ID: Int * ClassName: Enum('SiteTree', 'Page', 'NewsArticle') * Created: Datetime * LastEdited: Datetime * Title: Varchar * Content: Text * Page * ID: Int * Abstract: Text * NewsArticle * ID: Int * ArticleDate: Date The way it works is this: * "Base classes" are direct sub-classes of DataObject. They are always given a table, whether or not they have special fields. This is called the "base table" * The base table's ClassName field is set to class of the given record. It's an enumeration of all possible sub-classes of the base class (including the base class itself) * Each sub-class of the base object will also be given its own table, *as long as it has custom fields*. In the example above, NewsSection didn't have its own data and so an extra table would be redundant. * In all the tables, ID is the primary key. A matching ID number is used for all parts of a particular record: record #2 in Page refers to the same object as record #2 in SiteTree. To retrieve a news article, SilverStripe joins the SiteTree, Page and NewsArticle tables by their ID fields. We use a left-join for robustness; if there is no matching record in Page, we can return a record with a blank Article field. ## Staging and versioning ## Schema auto-generation Visiting the URL (your-site)/db/build will run a script that automatically builds the database manifest. ## Related code The information documented in this page is reflected in a few places in the code: * `[api:DataObject]` * requireTable() is responsible for specifying the required database schema * instance_get() and instance_get_one() are responsible for generating the database queries for selecting data. * write() is responsible for generating the database queries for writing data. * `[api:Versioned]` * augmentWrite() is responsible for altering the normal database writing operation to handle versions. * augmentQuery() is responsible for altering the normal data selection queries to support versions. * augmentDatabase() is responsible for specifying the altered database schema to support versions. * `[api:MySQLDatabase]`: getNextID() is used when creating new objects; it also handles the mechanics of updating the database to have the required schema. * How versioning works * Building the database shema: db/build ## Common Problems See [database-troubleshooting](/howto/database-troubleshooting) for common issues that happen with our database structure. ## Future work * We realise that a fixed mapping between the database and object-model isn't appropriate in all cases. In particular, it could be beneficial to set up a SilverStripe data-object as an interface layer to the databases of other applications. This kind of configuration support is on the cards for development once we start looking more seriously at providing avenues for clean integration between systems. * Some developers have commented that the the database layer could be used to maintain the relational integrity of this database structure. I don't know whether MySQL supports this or not, but in any case, this stuff would be available in other database platforms if we chose to support them. * We'd like to support more than just MySQL, however, there needs to be a pretty good reason for doing so since it will become something that needs to be supported for the rest of SilverStripe's life and could easily become an albatross. On the cards are MS SQL, PostgreSQL and SQLite. * It could be desireable to implement a non-repeating auto-numbering system.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/modeladmin.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/modeladmin.md
3,156
1,758,118,090
en
# ModelAdmin *Replaces GenericDataAdmin in Silverstripe 2.3* The ModelAdmin provides a simple way to utilize the SilverStripe CMS UI with your own custom data models. The ModelAdmin uses the `[api:DataObject]`'s Scaffolding to create the search fields, forms, and displayed data within the CMS. In order to customize the ModelAdmin CMS interface you will need to understand how `[api:DataObject]` works. #### Requirements * *Requires Silverstripe 2.3* ## Usage 1. Extend ModelAdmin with a custom class for your admin area, and edit the ''$managed_models'' property with the list of data objects you want to scaffold an interface for: :::php class MyCatalogAdmin extends ModelAdmin { public static $managed_models = array( //since 2.3.2 'Product', 'Category' ); static $url_segment = 'products'; // will be linked as /admin/products static $menu_title = 'My Product Admin'; } To add the ModelAdmin to your CMS menu, you simply need to define a couple of statics on your ModelAdmin subclass. See `[api:LeftAndMain]` on how to make your menu title translatable. 2. Add a ''$searchable_fields'' (See `[api:ModelAdmin::$searchable_fields]`) property to your data models, to define the fields and filters for the search interface: Datamodel ''Product'': :::php class Product extends DataObject { static $db = array( 'Name' => 'Varchar', 'ProductCode' => 'Varchar', 'Description' => 'Text', 'Price' => 'Currency' ); static $has_one = array( 'Category' => 'Category' ); static $searchable_fields = array( 'Name', 'ProductCode' ); } Datamodel ''Category'': :::php <?php class Category extends DataObject { static $db = array( 'Title' => 'Text' ); } ?> 3. You can now log in to the main CMS admin and manage your data objects, with no extra implementation required. ![](_images/modeladmin_edit.png) ![](_images/modeladmin_results.png) ### Note about has_one Scaffolding **has_one** relationships in your ModelAdmin relies on a column in the related model to be named **Title** or **Name** of a string type (varchar, char, etc). These will be pulled in to the dropdown when creating a new object. If you are seeing a list of ID#s when creating new objects, ensure you have one of those two in the related model. ### Searchable Fields You can customize the fields which are searchable for each managed DataObject class, as well as the ways in which the fields are searched (e.g. "partial match", "fulltext", etc.) using ''$searchable_fields''. * See `[api:DataObject]` ![](_images/modeladmin_search.png) ### Summary Fields Summary Fields are the columns which are shown in the `[api:TableListField]` when viewing DataObjects. These can be customized for each DataObject's search results using ''$summary_fields''. * See `[api:DataObject]` ## Related * `[api:SearchContext]` * [genericviews Module](http://silverstripe.org/genericviews-module) * [Presentation about ModelAdmin at SupperHappyDevHouse Wellington](http://www.slideshare.net/chillu/modeladmin-in-silverstripe-23)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/leftandmain.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/leftandmain.md
4,673
1,758,118,090
en
# Introduction LeftAndMain is the base class of all the admin area controllers. # Best Practices ## Refreshing Please use LeftAndMain::ForceReload to reload the whole form-area after an Ajax-Request. If you just need to refresh parts of the form, please use javascript-replacement in the response of the original Ajax-Request. Consider using `[api:Form]` for compiling Ajax-Responses and automatic detection of Ajax/Non-Ajax-Calls. ## Custom Access Checking You can customize access control in `[api:LeftAndMain]`. :::php // mysite/_config.php LeftAndMain::add_extension('MyLeftAndMain'); // MyLeftAndMain.php class MyLeftAndMain extends Extension { function augumentInit() { // add custom requirements etc. } function alternateAccessCheck() { // custom permission checks, e.g. to check for an SSL-connection, or an LDAP-group-membership } } # Subclassing There are a few steps in creating a subclass of LeftAndMain. #### MyAdmin.php The PHP file defining your new subclass is the first step in the process. This provides a good starting point: :::php class MyAdmin extends LeftAndMain { static $url_segment = 'myadmin'; static $url_rule = '$Action/$ID'; static $menu_title = 'My Admin'; static $menu_priority = 60; /** * Initialisation method called before accessing any functionality that BulkLoaderAdmin has to offer */ public function init() { Requirements::javascript('cms/javascript/MyAdmin.js'); parent::init(); } /** * Form that will be shown when we open one of the items */ public function getEditForm($id = null) { return new Form($this, "EditForm", new FieldSet( new ReadonlyField('id #',$id) ), new FieldSet( new FormAction('go') ) ); } } #### Templates Next, create templates, (classname)_left.ss and (classname)_right.ss. Again, here are a couple of starting points: * On the left, we're using the tree as a way of providing navigation. The left and side could be replaced with anything but LeftAndMain has built-in support for trees. * On the right, we have the skeleton that the form will be loaded into. MyAdmin_left.ss :::html <div class="title"><div>Functions</div></div> <div id="treepanes"> <div id="sitetree_holder" style="overflow:auto"> <% if Items %> <ul id="sitetree" class="tree unformatted"> <li id="$ID" class="root Root"><a>Items</a> <ul> <% control Items %> <li id="record-$class"> <a href="admin/my/show/$ID">$Title</a> </li> <% end_control %> </ul> </li> </ul> <% end_if %> </div> </div> MyAdmin_right.ss :::html <div class="title"><div>My admin</div></div> <% if EditForm %> $EditForm <% else %> <form id="Form_EditForm" action="admin/my?executeForm=EditForm" method="post" enctype="multipart/form-data"> <p>Welcome to my $ApplicationName admin section. Please choose something from the left.</p> </form> <% end_if %> <p id="statusMessage" style="visibility:hidden"></p> ### Customising the main menu *Minimum Requirement: Silverstripe 2.3* The static variable $url_segment determines the sub url of the controller. The static variable $url_rule has the url format for the actions performed by the class. The static variable $menu_title is the title of the administration panel in the menu. The static variable $menu_priority tells the CMS where to put the menu item relative to other panels. For example: :::php static $url_segment = 'myadmin'; static $url_rule = '$Action/$ID'; static $menu_title = 'My Admin'; static $menu_priority = 60; See also `[api:CMSMenu]` ##### Translatable Menu Titles Override the function getMenuTitle() to create a translated menu title name. Eg: :::php public function getMenuTitle() { return _t('LeftAndMain.MYADMIN', 'My Admin', PR_HIGH, 'Menu title'); ## 'onload' javascript in the CMS You can have custom scripting called when a Page is loaded by clicking on the Site Content Tree. This can be used to set up event handlers, or populate dropdowns, etc. You could insert this code using Requirements from a custom page class. :::javascript Behaviour.register({ '#Form_EditForm' : { initialize : function() { this.observeMethod('PageLoaded', this.adminPageHandler); this.adminPageHandler(); }, adminPageHandler : function() { // Place your custom code here. } } }); ## Related * `[api:CMSMain]` * `[api:AssetAdmin]` * `[api:SecurityAdmin]` * `[api:ModelAdmin]` # TODO * Explain how to build the javascript file * Explain how the ajax button handlers work * Explain how to create little pop-up dialogs
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/execution-pipeline.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/execution-pipeline.md
3,324
1,758,118,090
en
# Introduction This page documents all the steps from an URL request to the delivered page. ## .htaccess and RewriteRule Silverstripe uses **[mod_rewrite](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html)** to deal with page requests. So instead of having your normal everyday ''index.php'' file which tells all, you need to look elsewhere. The basic .htaccess file after installing SilverStripe look like this: <file> ### SILVERSTRIPE START ### <Files *.ss> Order deny,allow Deny from all Allow from 127.0.0.1 </Files> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$) RewriteCond %{REQUEST_URI} ^(.*)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] </IfModule> ### SILVERSTRIPE END ### </file> The `<Files>` section denies direct access to the template files from anywhere but the server itself. The next section enables the rewriting engine and rewrites requests to ''sapphire/main.php'' if they meet the following criteria: * URI doesn't end in .gif, .jpg, .png, .css, or .js * The requested file doesn't exist on the filesystem ''sapphire/main.php'' is called with the REQUEST_FILENAME (%1) as the ''url'' parameter and also appends the original QUERY_STRING. See the [mod_rewrite documentation](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) for more information on how mod_rewrite works. ## main.php All requests go through main.php, which sets up the environment and then hands control over to Director. **See:** [The API documentation of main.php](http://api.silverstripe.org/trunk/sapphire/core/_sapphire---main.php.html) for information about how main.php processes requests. ## Director and URL patterns main.php relies on Director to work out which controller should handle this request. Director will instantiate that controller object and then call [Controller::run()](http://api.silverstripe.org/trunk/sapphire/control/Controller.html#run). **See:** [The API documentation of Director](http://api.silverstripe.org/trunk/sapphire/control/Director.html) for information about how Director parses URLs and hands control over to a controller object. In general, the URL is build up as follows: page/action/ID/otherID - e.g. http://www.mysite.com/mypage/addToCart/12. This will add an object with ID 12 to the cart. When you create a function, you can access the ID like this: :::php function addToCart ($request) { $param = $r->allParams(); echo "my ID = ".$param["ID"]; $obj = DataObject::get("myProduct", $param["ID"]); $obj->addNow(); } ## Controllers and actions Controllers are the building blocks of your application. **See:** [The API documentation for Controller](http://api.silverstripe.org/trunk/sapphire/control/Controller.html) You can access the following controller-method with /team/signup :::php class Team extends DataObject {} class Team_Controller extends Controller { function signup($id, $otherId) { return $this->renderWith('MyTemplate'); } } ## SSViewer template rendering See [templates](/topics/templates) for information on the SSViewer template system. **See:** [The API documentation for SSViewer](http://api.silverstripe.org/trunk/sapphire/view/SSViewer.html)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/director.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/director.md
2,719
1,758,118,090
en
# Introduction Director is the first step in the "execution pipeline". It parses the URL, matching it to one of a number of patterns, and determines the controller, action and any argument to be used. It then runs the controller, which will finally run the viewer and/or perform processing steps. [Full method documentation available here](http://api.silverstripe.org/2.4/sapphire/control/Director.html) # Best Practices * Forcing a site to run in SSL mode: see [ssl](/howto/ssl) * Checking for an Ajax-Request: Use Director::is_ajax() instead of checking for $_REQUEST['ajax']. # Redirection The Director class has a number of methods to facilitate 301 and 302 HTTP redirection. * **Director::redirect("action-name")**: If there's no slash in the URL passed to redirect, then it is assumed that you want to go to a different action on the current controller. * **Director::redirect("relative/url")**: If there is a slash in the URL, it's taken to be a normal URL. Relative URLs will are assumed to be relative to the site-root; so Director::redirect("home/") will work no matter what the current URL is. * **Director::redirect("http://www.absoluteurl.com")**: Of course, you can pass redirect() absolute URL s too. * **Director::redirectPerm("any-url")**: redirectPerm takes the same arguments as redirect, but it will send a 301 (permanent) instead of a 302 (temporary) header. It improves search rankings, so this should be used whenever the following two conditions are true: * Nothing happens server-side prior to the redirection * The redirection will always occur * **Director::redirectBack()**: This will return you to the previous page. There's no permanent version of redirectBack(). # Custom Rewrite Rules You can influence the way URLs are resolved one of 2 ways 1. Adding rules to Director in `<yourproject>/_config.php` (See Default Rewrite Rules below for examples) 2. Adding rules in your extended Controller class via the *$url_handlers* static variable See [controller](/topics/controller) for examples and explanations on how the rules get processed for both 1 and 2 above. * Static redirect for specific URL :::php Director::addRules(100, array( 'myPermanentRedirect' => 'redirect:http://www.mysite.com' )); # Default Rewrite Rules SilverStripe comes with certain rewrite rules (e.g. for *admin/assets*). * [sapphire/_config.php](http://open.silverstripe.org/browser/modules/sapphire/trunk/_config.php) * [cms/_config.php](http://open.silverstripe.org/browser/modules/cms/trunk/_config.php) # Links * See ModelAsController class for details on controller/model-coupling * See [execution-pipeline](/reference/execution-pipeline) for custom routing
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/typography.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/typography.md
2,343
1,758,118,090
en
SilverStripe lets you customise the style of content in the CMS. This is done by setting up a CSS file called (projectname)/css/typography.css You also need to create a file called (projectname)/css/editor.css with the following content: :::css /** * This support file is used to style the WYSIWYG editor in the CMS */ @import "typography.css"; body.mceContentBody { min-height: 200px; font-size: 62.5%; } body.mceContentBody a.broken { background-color: #FF7B71; border: 1px red solid; } In typography.css you can define styles of any of the tags that will get created by the editor: * P, BLOCKQUOTE * H1-6 * UL, OL, LI * TABLE * STRONG, EM, U * A It's important to realise that this CSS file is included directly into the CMS system, and if you aren't careful, you can alter the styling of other parts of the interface. While this is novel, it can be dangerous and is probably not what you're after. The way around this is to limit all your styling selectors to elements inside something with class="typography". The other half of this is to put class="typography" onto any area in your template where you would like the styling to be applied. **WRONG** :::css CSS: h1, h2 { color: #F77; } Template: <div> $Content </div> **RIGHT** :::css CSS: .typography h1, .typography h2 { color: #F77; } Template: <div class="typography"> $Content </div> If you would to include different styles for different sections of your site, you can use class names the same as the name of the data fields. This example sets up different paragraph styles for 2 HTML editor fieldsc alled Content and OtherContent: :::css .Content.typography p { font-size: 12px; } .OtherContent.typography p { font-size: 10px; } ** Removing the typography class ** Sometimes, it's not enough to add a class, you also want to remove the typography class. You can use the HTMLEditorField method setCSSClass. This example sets another CSS class typographybis: :::php function getCMSFields() { ... $htmleditor = new HTMLEditorField("ContentBis", "Content Bis"); $htmleditor->setCSSClass('typographybis'); $fields->addFieldToTab("Root.Content.Main", $htmleditor); ... return $fields; } This functionnality will be available in the version 2.0.2 of the CMS.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/site-reports.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/site-reports.md
2,979
1,758,118,090
en
# Site Reports A report is a little bit of functionally in the CMS designed to provide a report of your data or content. You can access the site reports by clicking "Site Reports" in the left hand side bar and selecting the report you wish to view. ![](_images/sitereport.png) By default the CMS ships with a couple basic reports - ### Default Reports * "Empty Pages" which will generate a list of pages without content * "Pages edited in the last 2 weeks" which will list all the pages edited in the last 2 weeks in order of most recently edited. * "To Do" which displays all the ToDo notes you have added to each page and a link to the page. This is in 2.2.2 and later * Also the Ecommerce module provides 2 or 3 reports out of box. Such as All Products, Orders... ## Creating Custom Reports You can create reports for you own data quickly and easily. A general knowledge of Silverstripes [Datamodel](http://doc.silverstripe.com/doku.php?id=datamodel) would help before you attempt this. Inside the Mysite/Code folder - your projects code, create a file called CustomSideReport or MyProjectSiteReport and inside this file we can add our site reports. CustomSideReport.php :::php <?php class CustomSideReport_NameOfReport extends SideReport { function title() { // the name of our report } function records() { // what we want the report to return and what order } function fieldsToShow() { // which fields on that object do we want to show? Title, Author? } } ?> Now this won't do anything! You will just get a blank report that doesn't work! So for this to do something we have to fill in these 3 methods title() records() and fieldsToShow() till we have something like this. For example if you want to list every Page on your site! CustomSideReport.php :::php <?php /** * This report lists all the pages in the CMS * of type Page. Sorted by title. */ class CustomSideReport_AllPages extends SideReport { function title() { // this is the title of the report return "All Pages"; } function records() { // the data the report returns all the dataobjects of type Page and sorted by title. See datamodel for more info return DataObject::get("Page", "", "Title"); } function fieldsToShow() { // fields you want to display. This will display a list of titles which link to the page in the cms. Handy! return array( "Title" => array("NestedTitle", array("2")), ); } } ?> Reload the CMS and test it out for your self! You should be able to select the report and view all the pages. ## Further on.. Notes * Your CustomSideReport_ReportName must extend SideReport! * You can have more then 1 report in the 1 file. Actually its recommended!. You should create 1 CustomSideReport.php file and add class's as you need them inside that for each report. ## TODO * How to format and make nicer reports. * More examples.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/rssfeed.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/rssfeed.md
2,508
1,758,118,090
en
# Introduction Generating RSS/Atom-feeds is just a matter of rendering a `[api:DataObject]` and the Page Comment Interface. Handled through the `[api:RSSFeed]` class. RSSFeed doesn't limit you to generating "article-based" feeds, it is just as easy to create a feed of your current staff-members. The only logical limitation here is that every item in the RSS-feed should be accessible through a URL on your website, so its advisable to just create feeds from subclasses of `[api:SiteTree]`. # Usage ## Showing latest Blog posts * The first part will add an appropriate link tag for autodetecting RSS feeds * The second part sets up /this-page/rss to return the RSS feed. This one returns the children of the current page. :::php function init() { RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of this blog"); parent::init(); } function rss() { $rss = new RSSFeed($this->Children(), $this->Link(), "My feed", "This is an example feed.", "Title", "Content", "Author"); $rss->outputToBrowser(); } ## Example of showing the 10 most recently updated pages You can use RSSFeed to easily create a feed showing your latest Page updates. Just change mysite/code/Page.php to something like this: :::php <?php class Page extends SiteTree { static $db = array( ); static $has_one = array( ); } class Page_Controller extends ContentController { function init() { RSSFeed::linkToFeed($this->Link() . "rss", "10 Most Recently Updated Pages"); parent::init(); } function rss() { $rss = new RSSFeed($this->LatestUpdates(), $this->Link(), "10 Most Recently Updated Pages", "Shows a list of the 10 most recently updated pages.", "Title", "Content", "Author"); $rss->outputToBrowser(); } function LatestUpdates() { // 10 is the number of pages return DataObject::get("Page", "", "LastEdited DESC", "", 10); } } ?> # Viewing Comment RSS Feeds You can view RSS feeds for comments for a certain page or for all comments on your site by visiting http://www.yoursite.com/PageComment/rss . That produces a RSS Feed of the most recent comments to all of your site. You can also do http://www.yoursite.com/PageComment/rss?pageid=46 where pageid is the id of the page you want to follow # External Sources RSSFeed only creates feeds from your own data. We've included the [SimplePie](http://simplepie.org) RSS-parser for accessing feeds from external sources. # Related * [blog module](http://silverstripe.org/blog-module)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/sqlquery.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/sqlquery.md
5,847
1,758,118,090
en
# Introduction An object representing a SQL query. It is easier to deal with object-wrappers than string-parsing a raw SQL-query. This object is used by `[api:DataObject]`, though... A word of caution: Dealing with low-level SQL is not encouraged in the Silverstripe [datamodel](/topics/datamodel) for various reasons. You'll break the behaviour of: * Custom getters/setters * DataObject::onBeforeWrite/onBeforeDelete * Automatic casting * Default-setting through object-model * `[api:DataObject]` * Database abstraction We'll explain some ways to use *SELECT* with the full power of SQL, but still maintain a connection to the Silverstripe [datamodel](/topics/datamodel). # Usage ## SELECT :::php $sqlQuery = new SQLQuery(); $sqlQuery->select = array( 'Firstname AS Name', 'YEAR(Birthday) AS BirthYear' ); $sqlQuery->from = " Player LEFT JOIN Team ON Player.TeamID = Team.ID "; $sqlQuery->where = " YEAR(Birthday) = 1982 "; // $sqlQuery->orderby = ""; // $sqlQuery->groupby = ""; // $sqlQuery->having = ""; // $sqlQuery->limit = ""; // $sqlQuery->distinct = true; // get the raw SQL $rawSQL = $sqlQuery->sql(); // execute and return a Query-object $result = $sqlQuery->execute(); ## DELETE :::php // ... $sqlQuery->delete = true; ## INSERT/UPDATE (currently not supported -see below for alternative solutions) # Working with results The result is an array lightly wrapped in a database-specific subclass of `[api:Query]`. This class implements the *Iterator*-interface defined in PHP5, and provides convenience-methods for accessing the data. ## Iterating :::php foreach($result as $row) { echo $row['BirthYear']; } ## Quick value checking Raw SQL is handy for performance-optimized calls. :::php class Team extends DataObject { function getPlayerCount() { $sqlQuery = new SQLQuery( "COUNT(Player.ID)", "Team LEFT JOIN Player ON Team.ID = Player.TeamID" ); return $sqlQuery->execute()->value(); } Way faster than dealing with `[api:DataObject]`s, but watch out for premature optimisation: :::php $players = $myTeam->Players(); echo $players->Count(); ## Mapping Useful for creating dropdowns. :::php $sqlQuery = new SQLQuery( array('YEAR(Birthdate)', 'Birthdate'), 'Player' ); $map = $sqlQuery->execute()->map(); $field = new DropdownField('Birthdates', 'Birthdates', $map); ## "Raw" SQL with DB::query() This is not recommended for most cases, but you can also use the Silverstripe database-layer to fire off a raw query: :::php DB::query("UPDATE Player SET Status='Active'"); ## "Semi-raw" SQL with buildSQL() You can gain some ground on the datamodel-side when involving the selected class for querying. You don't necessarily need to call *buildSQL* from a specific object-instance, a *singleton* will do just fine. :::php $sqlQuery = singleton('Player')->buildSQL( 'YEAR(Birthdate) = 1982' ); This form of building a query has the following advantages: * Respects DataObject::$default_sort * Automatically LEFT JOIN on all base-tables (see [database-structure](database-structure)) * Selection of *ID*, *ClassName*, *RecordClassName*, which are necessary to use *buildDataObjectSet* later on * Filtering records for correct *ClassName* ## Transforming a result to DataObjectSet This is a commonly used technique inside Silverstripe: Use raw SQL, but transfer the resulting rows back into DataObjects. :::php $sqlQuery = new SQLQuery(); $sqlQuery->select = array( 'Firstname AS Name', 'YEAR(Birthday) AS BirthYear', // IMPORTANT: Needs to be set after other selects to avoid overlays 'Player.ClassName AS ClassName', 'Player.ClassName AS RecordClassName', 'Player.ID AS ID', ); $sqlQuery->from = array( "Player", "LEFT JOIN Team ON Player.TeamID = Team.ID" ); $sqlQuery->where = array( "YEAR(Player.Birthday) = 1982" ); $result = $sqlQuery->execute(); var_dump($result->first()); // array // let Silverstripe work the magic $myDataObjectSet = singleton('Player')->buildDataObjectSet($result); var_dump($myDataObjectSet->First()); // DataObject // this is where it gets tricky $myFirstPlayer = $myDataObjectSet->First(); var_dump($myFirstPlayer->Name); // 'John' var_dump($myFirstPlayer->Firstname); // undefined, as it was not part of the SELECT-clause; var_dump($myFirstPlayer->Surname); // undefined, as it was not part of the SELECT-clause // lets assume that class Player extends BasePlayer, // and BasePlayer has a database-column "Status" var_dump($myFirstPlayer->Status); // undefined, as we didn't LEFT JOIN the BasePlayer-table CAUTION: Depending on the selected columns in your query, you might get into one of the following scenarios: * Not all object-properties accessible: You need to take care of selecting the right stuff yourself * Overlayed object-properties: If you *LEFT JOIN* a table which also has a column 'Birthdate' and do a global select on this table, you might not be able to access original object-properties. * You can't create DataObjects where no scalar record-data is available, e.g. when using *GROUP BY* * Naming conflicts with custom getters: A getter like Player->getName() will overlay the column-data selected in the above example Be careful when saving back DataObjects created through *buildDataObjectSet*, you might get strange side-effects due to the issues noted above. ## Using FormFields with custom SQL Some subclasses of `[api:FormField]` for ways to create sophisticated report-tables based on SQL. # Related * [datamodel](datamodel) * `[api:DataObject]` * [database-troubleshooting](database-troubleshooting) * [database-structure](database-structure) # API Documentation [Click here for API documentation](http://api.silverstripe.org/trunk/sapphire/SQLQuery.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/tablefield.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/tablefield.md
2,869
1,758,118,090
en
# Introduction TableField behaves in the same manner as `[api:TableListField]`, however allows the editing of existing and adding of new rows. The data is saved back by the surrounding form-saving (mostly EditForm->save). See `[api:TableListField]` for more documentation on the base-class # Source Input See `[api:TableListField]`. # Features ## Add hidden default data Please use **TableField->setExtraData()** to specify additional (non-editable) data. You might use the following code that shows the Player of Team with a particular Team ID and automatically saves new Players into this Team. In this example, you'll note that we're setting TeamID to $this->ID. This works well if you're including a TableField as an editable field on a getCMSFields() call. :::php $myTableField = new TableField( 'MyTableField', // fieldName 'Player', // sourceType array( 'FirstName'=>'First Name', 'Surname'=>'Surname' ), // fieldList array( 'FirstName'=>'TextField', 'Surname'=>'TextField' ), // fieldTypes null, // filterField (legacy) "Player.TeamID", $this->ID ); // add some HiddenFields thats saved with each new row $myTableField->setExtraData(array( 'TeamID' => $this->ID ? $this->ID : '$RecordID' )); The '$RecordID' value is used when building forms that create new records. It will be populated with whatever record id is created. ## Row Transformation You can apply a `[api:FormTransformation]` to any given field, based on a eval()ed php-rule. You can access all columns on the generated DataObjects here. :::php $myTF->setTransformationConditions(array( "PlayerName" => array( "rule" => '$PlayerStatus == "Retired" || $PlayerStatus == "Injured"', "transformation" => "performReadonlyTransformation" ) )); # Best Practices ## Required Fields Due to the nested nature of this fields dataset, you can't set any required columns as usual with the `[api:RequiredFields]`** on the TableField-instance for this. Note: You still have to attach some form of `[api:Validator]` to the form to trigger any validation on this field. ## Nested Table Fields When you have TableField inside a `[api:ComplexTableField]`, the parent ID may not be known in your getCMSFields() method. In these cases, you can set a value to '$RecordID' in your TableField extra data, and this will be populated with the newly created record id upon save. # Known Issues * A TableField doesn't reload any submitted form-data if the saving is interrupted by a failed validation. After refreshing the form with the validation-errors, the TableField will be blank again. * You can't add **visible default data** to columns in a TableField, please use *setExtraData* # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/forms/fields-relational/TableField.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/templates.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/templates.md
11,895
1,758,118,090
en
# Introduction SilverStripe templates consist of HTML code augmented with special control codes, described below. Because of this, you can have as much control of your site's HTML code as you like. Because the SilverStripe templating language is a string processing language it can therefore be used to make other text-based data formats, such as XML or RTF. Here is a very simple template: :::html <html> <head> <% base_tag %> <title>$Title</title> </head> <body> <h1>$Title</h1> <p> <% control Menu(1) %> <a href="$Link" title="$Description.JS">$Title</a> <% end_control %> </p> <div class="typography"> $Content </div> </body> </html> # Template Syntax The following control codes are available. For a more details list see [built-in-page-controls](/reference/built-in-page-controls): ## Variables :::html $Property $Property(param) $Property.SubProperty These **variables** will call a method/field on the object and insert the returned value as a string into the template. * $Property will call $obj->Property() (or the field $obj->Property) * $Property(param) will call $obj->Property("param") * $Property.SubProperty will call $obj->Property()->SubProperty() (or field equivalents) If a Variable returns a string, that string will be inserted into the template. If the variable returns an object, then the system will attempt to render the object through its forTemplate() method. If the forTemplate() method has not been defined, the system will return an error. Note you also cannot past a variable into a variable, so using $Property($Value) within your template will not work ## Includes You can perform includes using the Requirements Class via the template controls. See the section on [Includes in Templates](requirements#including_inside_template_files) for more details and examples. :::html <% require themedCSS(LeftNavMenu) %> ## Controls :::html <% control Property %> ... content ... <% end_control %> <% control Property.SubProperty %> ... content ... <% end_control %> <% control Property(param) %> ... content ... <% end_control %> Control blocks reference the same methods / fields as variables. Think of it as a foreach loop in PHP or other template languages. `<% control Property %>` gets the same data as $Property. However, instead of interpreting the result as a string, control blocks interpret the result as an object or a array of objects. The content between `<% control %>` and `<% end_control %>` acts as a sub-template that is used to render the object returned. In this example, $A and $B refer to $obj->Property()->A() and $obj->Property()->B(). :::html <% control Property %> <span>$A</span> <span>$B</span> <% end_control %> If the method/field returned is an iterator such as a `[api:DataObject]`, then the control block will be repeated for each element of that iterator. This is the cornerstone of all menu and list generation in SilverStripe. In this example, Menu(1) returns a DataObjectSet listing each top level main menu item (for more info on Menu(1): [Making a Navigation System](http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site#making_a_navigation_system)). The `<a>` tag is repeated once for each main menu item, and the $Link and $Title values for each menu item is substituted in. :::html <% control Menu(1) %> <a href="$Link">$Title</a> <% end_control %> ## If blocks :::html <% if Property %> ... optional content ... <% else_if OtherProperty %> ... alternative content ... <% else %> ... alternative content ... <% end_if %> <% if Property == value %> <% else %> <% end_if %> <% if Property != value %> <% end_if %> <% if Property && Property2 %> <% end_if %> <% if Property || Property2 %> <% end_if %> If blocks let you mark off optional content in your template. The optional content will only be shown if the requested field / method returns a nonzero value. In the second syntax, the optional content will only be shown if the requested field / method returns the value you specify. You should **not** include quotes around the value. The `<% else %>` blocks perform as you would expect - content between `<% else %>` and `<% end_if %>` is shown if the first block fails. `<% else %>` is an optional part of the syntax - you can just use `<% if %>` and `<% end_if %>` if that's appropriate. ## Comments Using standard HTML comments is supported. These comments will be included in the published site. :::html $EditForm <!-- Some Comment About the Edit Form --> However you can also use special SilverStripe comments which will be stripped out of the published site. This is useful for adding notes for other developers but for things you don't want published in the public html. :::html $EditForm <%-- This is Located in MemberEditForm.php --%> ## Formatting Template Values The following example takes the Title field of our object, casts it to a `[api:Varchar]` object, and then calls the $XML object on that Varchar object. :::html <% control Title %> $XML <% end_control %> Note that this code can be more concisely represented as follows: :::html $Title.XML See [data-types](/topics/data-types) for more information. ## Escaping Sometimes you will have template tags which need to roll into one another. This can often result in SilverStripe looking for a "FooBar" value rather than a "Foo" and then "Bar" value or when you have a string directly before or after the variable you will need to escape the specific variable. In the following example $Foo is 3. :::html $Foopx // returns "" (as it looks for a Foopx value) {$Foo}px // returns "3px" (CORRECT) Or when having a $ sign in front of the variable :::html $$Foo // returns "" ${$Foo} // returns "$3" ## Partial Caching From SilverStripe 2.4 you can specify a block to cache between requests :::html <% cacheblock 'slowoperation', LastEdited %> $SlowOperation <% end_cacheblock %> See [partial-caching](/reference/partial-caching) for more information. # Built In Template Variables and Controls Out of the box, the template engine gives you lots of neat little variables and controls which you will find useful. For a list of all the controls see [built-in-page-controls](/reference/built-in-page-controls). # Creating your own Template Variables and Controls There are 2 ways you can extend the template variables you have available. You can create a new Database field in your $db or if you do not need the variable to be editable in the cms you can create a function which returns a value in your Page.php class. :::php **mysite/code/Page.php** ... function MyCustomValue() { return "Hi, this is my site"; } Will give you the ability to call $MyCustomValue from anywhere in your template. :::html I've got one thing to say to you: <i>$MyCustomValue</i> // output "I've got one thing to say to you: <i>Hi, this is my site</i>" Your function could return a single value as above or it could be a subclass of `[api:ArrayData]` for example a `[api:DataObject]` with many values then each of these could be accessible via a control loop :::php .. function MyCustomValues() { return new ArrayData(array("Hi" => "Kia Ora", "Name" => "John Smith")); } And now you could call these values by using :::html <% control MyCustomValues %> $Hi , $Name <% end_control %> // output "Kia Ora , John Smith" Or by using the dot notation you would have :::html $MyCustomValues.Hi , $MyCustomValues.Name // output "Kia Ora , John Smith" ##### Side effects All functions that provide data to templates must have no side effects, as the value is cached after first access. For example, this Controller method :::php private $counter = 0; function Counter() { $this->counter += 1; return $this->counter; } and this template :::html $Counter, $Counter, $Counter will give "1, 1, 1", not "1, 2, 3" # Calling templates from PHP code This is all very well and good, but how do the templates actually get called? Templates do nothing on their own. Rather, they are used to render *a particular object*. All of the `<% if %>`, <% control %>, and variable codes are methods or parameters that are called *on that object*. All that is necessary is that the object is an instance of ViewableData (or one of its subclasses). The key is ViewableData::renderWith(). This method is passed a For example, within the controller's default action, there is an instruction of the following sort: :::php $controller->renderWith("TemplateName"); Here's what this line does: * First renderWith() constructs a new object: $template = new SSViewer("TemplateName"); * SSViewer will take the content of TemplateName.ss, and turn it into PHP code. * Then renderWith() passes the controller to $template->process($controller); * SSViewer::process() will execute the PHP code generated from TemplateName.ss and return the results. renderWith() returns a string - the populated template. In essence, it uses a template to cast an object to a string. renderWith() can also be passed an array of template names. If this is done, then renderWith() will use the first available template name. Below is an example of how to implement renderWith. In the example below the page is rendered using the myAjaxTemplate if the page is called by an ajax function (using Director::is_ajax()). Note that the index function is called by default if it exists and there is no action in the url parameters. :::php class MyPage_Controller extends Page_Controller { function init(){ parent::init(); } function index() { if(Director::is_ajax()) { return $this->renderWith("myAjaxTemplate"); } else { return Array();// execution as usual in this case... } } } ##### How does ViewableData work? ViewableData provides two methods that perform the casting necessary for templates to work as we have described. * obj("Parameter") - Return the given field / method as an object, casting if necessary * XML_val("Parameter) - Return the given field / method as a scalar, converting to an XML-safe format and casting if necessary These methods work as described in the syntax section above. SSViewer calls these methods when processing templates. However, if you want, you can call obj() and val() yourself. # Fragment Link rewriting Fragment links are links with a "#" in them. A frequent use-case is to use fragment links to point to different sections of the current page. For example, we might have this in our template. For, example, we might have this on http://www.example.com/my-long-page/ :::html <ul> <li><a href="#section1">Section 1</a></li> <li><a href="#section2">Section 2</a></li> </ul> So far, so obvious. However, things get tricky because of we have set our `<base>` tag to point to the root of your site. So, when you click the first link you will be sent to http://www.example.com/#section1 instead of http://www.example.com/my-long-page/#section1 In order to prevent this situation, the SSViewer template renderer will automatically rewrite any fragment link that doesn't specify a URL before the fragment, prefixing the URL of the current page. For our example above, the following would be created: :::html <ul> <li><a href="my-long-page/#section1">Section 1</a></li> <li><a href="my-long-page/#section2">Section 2</a></li> </ul> There arecases where this can be unhelpful. HTML fragments created from Ajax responses are the most common. In these situations, you can disable fragment link rewriting like so: :::php SSViewer::setOption('rewriteHashlinks', false); # Related Pages [HTML Guidelines](http://doc.silverstripe.com/doku.php?id=html) [Themes](http://doc.silverstripe.com/doku.php?id=themes)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/searchcontext.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/searchcontext.md
5,901
1,758,118,090
en
# SearchContext ## Introduction Manages searching of properties on one or more `[api:DataObject]` types, based on a given set of input parameters. SearchContext is intentionally decoupled from any controller-logic, it just receives a set of search parameters and an object class it acts on. The default output of a SearchContext is either a `[api:SQLQuery]` object for further refinement, or a `[api:DataObject]` instance. In case you need multiple contexts, consider namespacing your request parameters by using ''FieldSet->namespace()'' on the $fields constructor parameter. SearchContext is mainly used by `[api:ModelAdmin]`, our generic data administration interface. Another implementation can be found in generic frontend search forms through the [genericviews](http://silverstripe.org/genericviews-module) module. ## Requirements * *SilverStripe 2.3* ## Usage Getting results :::php singleton('MyDataObject')->getDefaultSearchContext(); ### Defining fields on your DataObject See `[api:DataObject::$searchable_fields]`. ### Customizing fields and filters In this example we're defining three attributes on our MyDataObject subclasss: ''PublicProperty'', ''HiddenProperty'' and ''MyDate''. The attribute ''HiddenProperty'' should not be searchable, and ''MyDate'' should only search for dates *after* the search entry (with a ''GreaterThanFilter''). Similiar to the built-in ''DataObject->getDefaultSearchContext()'' method, we're building our own ''getCustomSearchContext()'' variant. :::php class MyDataObject extends DataObject { static $db = array( 'PublicProperty' => 'Text' 'HiddenProperty' => 'Text', 'MyDate' => 'Date' ); public function getCustomSearchContext() { $fields = $this->scaffoldSearchFields(array( 'restrictFields' => array('PublicProperty','MyDate') )); $filters = array( 'PublicProperty' => new PartialMatchFilter('PublicProperty'), 'MyDate' => new GreaterThanFilter('MyDate') ); return new SearchContext( $this->class, $fields, $filters ); } } ### Generating a search form from the context :::php class Page_Controller extends ContentController { public function SearchForm() { $context = singleton('MyDataObject')->getCustomSearchContext(); $fields = $context->getSearchFields(); $form = new Form($this, "SearchForm", $fields, new FieldSet( new FormAction('doSearch') ) ); return $form; } public function doSearch($data, $form) { $context = singleton('MyDataObject')->getCustomSearchContext(); $results = $context->getResults($data); return $this->customise(array( 'Results' => $results ))->renderWith('Page_results'); } } ### Pagination For paginating records on multiple pages, you need to get the generated ''SQLQuery'' before firing off the actual search. This way we can set the "page limits" on the result through ''setPageLimits()'', and only retrieve a fraction of the whole result set. :::php function getResults($searchCriteria = array()) { $start = ($this->request->getVar('start')) ? (int)$this->request->getVar('start') : 0; $limit = 10; $context = singleton('MyDataObject')->getCustomSearchContext(); $query = $context->getQuery($searchCriteria, null, array('start'=>$start,'limit'=>$limit)); $records = $context->getResults($searchCriteria, null, array('start'=>$start,'limit'=>$limit)); if($records) { $records->setPageLimits($start, $limit, $query->unlimitedRowCount()); } return $records; } notice that if you want to use this getResults function, you need to change the function doSearch for this one: :::php public function doSearch($data, $form) { $context = singleton('MyDataObject')->getCustomSearchContext(); $results = $this->getResults($data); return $this->customise(array( 'Results' => $results ))->renderWith(array('Catalogo_results', 'Page')); } The change is in **$results = $this->getResults($data);**, because you are using a custom getResults function. Another thing you cant forget is to check the name of the singleton you are using in your project. the example uses **MyDataObject**, you need to change it for the one you are using For more information on how to paginate your results within the template, see [Tutorial: Site Search](tutorial/4-site-search). ### The Pagination Template to show the results of your custom search you need at least this content in your template, notice that Results.PaginationSummary(4) defines how many pages the search will show in the search results. something like: **Next 1 2 *3* 4 5 … 558** :::html <% if Results %> <ul> <% control Results %> <li>$Titulo, $Autor</li> <% end_control %> </ul> <% else %> <p>Sorry, your search query did not return any results.</p> <% end_if %> <% if Results.MoreThanOnePage %> <div id="PageNumbers"> <p> <% if Results.NotFirstPage %> <a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a> <% end_if %> <span> <% control Results.PaginationSummary(4) %> <% if CurrentBool %> $PageNum <% else %> <% if Link %> <a href="$Link" title="View page number $PageNum">$PageNum</a> <% else %> &hellip; <% end_if %> <% end_if %> <% end_control %> </span> <% if Results.NotLastPage %> <a class="next" href="$Results.NextLink" title="View the next page">Next</a> <% end_if %> </p> </div> <% end_if %> ## Available SearchFilters See [SearchFilter API Documentation](http://api.silverstripe.org/current/sapphire/search/SearchFilter.html) ## API Documentation [API documentation](http://api.silverstripe.org/current/sapphire/search/SearchContext.html). ## Related * `[api:ModelAdmin]` * `[api:RestfulServer]` * [Tutorial: Site Search](/tutorials/4-site-search)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/dataobjectdecorator.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/dataobjectdecorator.md
5,973
1,758,118,090
en
#DataObjectDecorator ## Introduction Extensions (also referred to as decorators) allow for adding additional functionality to a `[api:DataObject]`. In some cases, it can be easier to completely replace the used class throughout the core with your custom implementation. Have a look at `[api:Object->useCustomClass()]`. ## Usage Your Decorator will nee to be a subclass of DataObjectDecorator or the Extension class. :::php <?php // mysite/code/CustomMember.php class CustomMember extends DataObjectDecorator { } This defines your own extension where you can add your own functions, database fields or other properties you want. After you create this extension however it does not yet apply it to your object. Next you need to tell SilverStripe what class you want to extend. ### Adding a decorator to a built-in class Sometimes you will want to add decorators to classes that you didn't make. For example, you might want to add the ForumRole decorator to the Member object. :::php Object::add_extension('Class You Want To Override', 'Your Class Name'); For example above we want to override Member with a Custom Member so we would write the following :::php // add to mysite/_config.php Object::add_extension('Member', 'CustomMember');</code> ## Implementation ### Adding extra database fields Extra database fields can be added with a decorator by defining an **extraStatics()** method. These will be added to the table of the base object - the decorator will actually edit the $db, $has_one, etc static variables on load. The function should return a map where the keys are the names of the static variables to update: :::php class CustomMember extends DataObjectDecorator { function extraStatics() { return array( 'db' => array( 'AvatarURL' => 'Varchar', ), 'has_one' => array( 'RelatedMember' => 'Member', ), ); } } #### NOTE If you want to add has_one or db items to a particular class, then that class **must** have that static variable explicitly defined, even if it's just a blank array. For example, the decorator method above wouldn't work if you added to a class that didn't have static $has_one explicitly declared on the object. This is because of PHP's crappy support for statics. ### Modifying CMS Fields The member class demonstrates an extension that allows you to update the default CMS fields for an object in a decorator: :::php public function getCMSFields() { ... $this->extend('updateCMSFields', $fields); return $fields; } The $fields parameter is passed by reference, as it is an object. :::php public function updateCMSFields(FieldSet $fields) { $fields->push(new TextField('Position', 'Position Title')); $fields->push(new ImageField('Image', 'Profile Image')); } ### Custom database generation Some decorators are designed to transparently add more sophisticated data-collection capabilities to your data object. For example, Versioned adds version tracking and staging to any data object that it is applied to. To do this, you need to be able to create additional database tables and fields to keep your state stored in. To do this, define an **augmentDatabase()** method on your decorator. This will be called when db/build is visited. * You can query $this->owner for information about the data object, such as the fields it has * You can use **DB::requireTable($tableName, $fieldList, $indexList)** to set up your new tables. This function takes care of creating, modifying, or leaving tables as required, based on your desired schema. ### Custom write queries If you have customised the generated database, then you probably want to change the way that writes happen. This is used by Versioned to get an entry written in ClassName_versions whenever an insert/update happens. To do this, define the **augmentWrite(&$manipulation)** method. This method is passed a manipulation array representing the write about to happen, and is able to amend this as desired, since it is passed by reference. ### Custom relation queries The other queries that you will want to customise are the selection queries, called by get & get_one. For example, the Versioned object has code to redirect every request to ClassName_live, if you are browsing the live site. To do this, define the **augmentSQL(SQLQuery &$query)** method. Again, the $query object is passed by reference and can be modified as needed by your method. Instead of a manipulation array, we have a `[api:SQLQuery]` object. ### Additional methods The other thing you may want to do with a decorator is provide a method that can be called on the DataObject that is being decorated. For instance, you may add a publish() method to every DataObject that is decorated with Versioned. This is as simple as defining a method called publish() on your decorator. Bear in mind, however, that instead of $this, you should be referring to $this->owner. * $this = The DataObjectDecorator object. * $this->owner = The related DataObject object. If you want to add your own internal properties, you can add this to the DataObjectDecorator, and these will be referred to as $this->propertyName. Every DataObject has an associated DataObjectDecorator instance for each class that it is decorated by. :::php class Customer extends DataObject { static $has_one = array('Account'=>'Account'); static $extensions = array( 'CustomerWorkflow' ); } class Account extends DataObject { static $db = array( 'IsMarkedForDeletion'=>'Boolean' ); static $has_many = array('Customers'=>'Customer'); } class CustomerWorkflow extends DataObjectDecorator { function IsMarkedForDeletion() { return ($this->owner->Account()->IsMarkedForDeletion == 1) ? true : false; } } ## API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/DataObjectDecorator.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/restfulservice.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/restfulservice.md
5,099
1,758,118,090
en
# Introduction RestfulService enables connecting to remote web services which supports REST interface and consume those web services (for example Flickr, Youtube, Amazon and etc). RestfulService can parse the XML response (sorry no JSON support) returned from the web service. Further it supports caching of the response, and you can customize the cache interval. To gain the functionality you can either create a new RestfulService object or create a class extending the RestfulService (see `flickrservice` and `youtubeservice` modules). # Examples ##### Creating a new RestfulObject :::php //example for using RestfulService to connect and retrive latest twitter status of an user. $twitter = new RestfulService("http://twitter.com/statuses/user_timeline/user.xml", $cache_expiry ); $params = array('count' => 1); $twitter->setQueryString($params); $conn = $twitter->connect(); $msgs = $twitter->getValues($conn, "status"); ##### Extending to a new class :::php //example for extending RestfulService class FlickrService extends RestfulService { function __construct($expiry=NULL){ parent::__construct('http://www.flickr.com/services/rest/', $expiry); $this->checkErrors = true; } ...... ##### Multiple requests by using the $subURL argument on connect() :::php // Set up REST service $service = new RestfulService("http://example.harvestapp.com"); $service->basicAuth('username', 'password'); $service->httpHeader('Accept: application/xml'); $service->httpHeader('Content-Type: application/xml'); $peopleXML = $service->connect('/people'); $people = $service->getValues($peopleXML, 'user'); ... $taskXML = $service->connect('/tasks'); $tasks = $service->getValues($taskXML, 'task'); # Features ## Caching To set the cache interval you can pass it as the 2nd argument to constructor. :::php new RestfulService("http://twitter.com/statuses/user_timeline/user.xml", 3600 ); ## Getting Values & Attributes You can traverse throught document tree to get the values or attribute of a particular node. for example you can traverse :::xml <entries> <entry id='12'>Sally</entry> <entry id='15'>Ted</entry> <entry id='30'>Matt</entry> <entry id='22'>John</entry> <entries> to extract the id attributes of the entries use: :::php $this->getAttributes($xml, "entries", "entry") //will return all attributes of each entry node to extract the values (the names) of the entries use: :::php $this->getValues($xml, "entries", "entry") //will return all values of each entry node ## Searching for Values & Attributes If you don't know the exact position of dom tree where the node will appear you can use xpath to search for the node.Recommended for retrieving values of namespaced nodes. :::xml <media:guide> <media:entry id="2030">video</media:entry> </media:guide> to get the value of entry node with the namespace media, use: :::php $this->searchValue($response, "//media:guide/media:entry") # Best Practices ## Handling Errors If the web service returned an error (for example, API key not available or inadequate parameters) RestfulService could delgate the error handling to it's descendant class. To handle the errors define a function called errorCatch :::php /* This will raise Youtube API specific error messages (if any). */ function errorCatch($response){ $err_msg = $response; if(strpos($err_msg, '<') === false) //user_error("YouTube Service Error : $err_msg", E_USER_ERROR); user_error("YouTube Service Error : $err_msg", E_USER_ERROR); else return $response; } If you want to bypass error handling on your sub-classes you could define that in the constructor. :::php function __construct($expiry=NULL){ parent::__construct('http://www.flickr.com/services/rest/', $expiry); $this->checkErrors = false; //Set checkErrors to false to bypass error checking } # Other Uses ## How to use RestfulService to easily embed an RSS feed [RestfulService](RestfulService) can be used to easily embed an RSS feed (since it's also an xml response) from a site such as del.icio.us Put something like this code in mysite/code/Page.php inside class Page_Controller :::php // Accepts an RSS feed URL and outputs a list of links from it function RestfulLinks($url){ $delicious = new RestfulService($url); $conn = $delicious->connect(); $result = $delicious->getValues($conn, "item"); $output = ''; foreach ($result as $key => $value) { // Fix quote encoding $description = str_replace('&amp;quot;', '&quot;', $value->description); $output .= '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>'; } return $output; } Put something like this code in mysite/templates/Layout/HomePage.ss: :::html <h3>My Latest Del.icio.us Links</h3> <ul> $RestfulLinks(http://del.icio.us/rss/elijahlofgren) </ul> # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/core/RestfulService.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/permission.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/permission.md
3,044
1,758,118,090
en
# Introduction This class implements SilverStripe's permission system. ## Usage Permissions are defined on a group-by-group basis. To give a permission to a member, go to a group that contains them, and then select the permissions tab, and add that permission to the list. The simple usage, Permission::check("PERM_CODE") will detect if the currently logged in member has the given permission. See the API docs for more options. #### Group ACLs * Call **Permission::check("MY_PERMISSION_CODE")** to see if the current user has MY_PERMISSION_CODE. * MY_PERMISSION_CODE can be loaded into the Security admin on the appropriate group, using the "Permissions" tab. You can use whatever codes you like, but for the sanity of developers and users, it would be worth listing the codes in [permissions:codes](permissions/codes) ## Adding Permissions ### PermissionProvider PermissionProvider is an interface which lets you define a method *providePermissions()*. This method should return a map of permission code names with a human readable explanation of its purpose (see [:permission:codes](/permission/codes)). :::php class Page_Controller implements PermissionProvider { function init() { if(!Permission::check("VIEW_SITE")) Security::permissionFailure(); } function providePermissions() { return array( "VIEW_SITE" => "Access the site", ); } } This can then be used to add a dropdown for permission codes to the security panel. Permission::get_all_codes() will be a helper method that will call providePermissions() on every applicable class, and collate the resuls into a single dropdown. ### Default use By default, permissions are used in the following way: * The 'View' permission is checked when opening a page * The 'View' permissions is used on **all** default datafeeds: * If not logged in, the 'View' permissions must be 'anyone logged in' for a page to be displayed in a menu * If logged in, you must be allowed to view a page for it to be displayed in a menu **NOTE:** Should the canView() method on SiteTree be updated to call Permission::check("SITETREE_VIEW", $this->ID)? Making this work well is a subtle business and should be discussed with a few developers. ### Setting up permissions * By default, permissions are linked to groups. You define a many-many relationship called Can(permname), eg, "CanView". Please note that group permissions are more efficient, as SQL joins are used to filter data. * Alternatively, you can create a custom permission by defining a function called can(permname) ### Using permissions * On an individual data record, $page->can("View", $member = null) and be called. If a member isn't passed, the currently logged in member is assumed. * On a request, $request->hasPermission("View", $member = null) can be called. See [datamodel](/topics/datamodel) for information on request objects. # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/database/Permission.html).
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/image.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/image.md
4,364
1,758,118,090
en
# Introduction Represents an image object, inheriting all base functionality from the [file](file) class with extra functionality including resizing. # Usage ## Form Fields * `[api:Image]`. Designed to provide a complex image uploader for the CMS. * `[api:SimpleImageField]`. A Simple Image Upload Form * See [imageupload](/howto/image-upload) for a example ## Resizing Images in PHP The following are methods defined on the GD class which you can call on Image Objects. Note to get the following to work you need to have GD2 support in your PHP installation and because these generate files you must have write access to your tmp folder. :::php // manipulation functions $image->resize(width,height); // Basic resize, just skews the image $image->resizeRatio(width,height) // Resizes an image with max width and height $image->paddedResize(width,height) // Adds padding after resizing to width or height. $image->croppedResize(width,height) // Crops the image from the centre, to given values. $image->resizeByHeight(height) // Maximum height the image resizes to, keeps proportion $image->resizeByWidth(width) // Maximum width the image resizes to, keeps proportion $image->greyscale(r,g,b) // alters image channels === // values $image->getHeight() // Returns the height of the image. $image->getWidth() // Returns the width of the image $image->getOrienation() // Returns a class constant: ORIENTATION_SQUARE or ORIENTATION_PORTRAIT or ORIENTATION_LANDSCAPE You can also create your own functions by extending the image class, for example :::php class MyImage extends Image { public function generateRotateClockwise(GD $gd) { return $gd->rotate(90); } public function generateRotateCounterClockwise(GD $gd) { return $gd->rotate(270); } public function clearResampledImages() { $files = glob(Director::baseFolder().'/'.$this->Parent()->Filename."_resampled/*-$this->Name"); foreach($files as $file) {unlink($file);} } public function Landscape() { return $this->getWidth() > $this->getHeight(); } public function Portrait() { return $this->getWidth() < $this->getHeight(); } function generatePaddedImageByWidth(GD $gd,$width=600,$color="fff"){ return $gd->paddedResize($width, round($gd->getHeight()/($gd->getWidth()/$width),0),$color); } public function Exif(){ //http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data $image = $this->AbsoluteURL; $d=new DataObjectSet(); $exif = exif_read_data($image, 0, true); foreach ($exif as $key => $section) { $a=new DataObjectSet(); foreach ($section as $name => $val) $a->push(new ArrayData(array("Title"=>$name,"Content"=>$val))); $d->push(new ArrayData(array("Title"=>strtolower($key),"Content"=>$a))); } return $d; } } ## Resizing in Templates You can call certain resize functions directly from the template, to use the inbuilt GD functions as the template parser supports these, for example SetWidth() or SetHeight(). For output of an image tag with the image automatically resized to 80px width, you can use: :::php $Image.SetWidth(80) // returns a image 80px wide, ratio kept the same $Image.SetHeight(80) // returns a image 80px tall, ration kept the same $Image.SetSize(80,80) // returns a 80x80px padded image $Image.SetRatioSize(80,80) // **New in 2.4** returns an image scaled proportional, with its greatest diameter scaled to 80px $Image.PaddedImage(80, 80) // Returns an 80x80 image. Unused space is padded white. No crop. No stretching $Image.Width // returns width of image $Image.Height // returns height of image $Image.Orientation // returns Orientation $Image.Filename // returns filename $Image.URL // returns filename ## Form Upload For usage on a website form, see [imageupload](howto/image-upload) and `[api:SimpleImageField]`. If you want to upload images within the CMS, see `[api:ImageField]`. ## Clearing Thumbnail Cache Images are (like all other Files) synchronized with the SilverStripe database. This syncing happens whenever you load the "Files & Images" interface, and whenever you upload or modify an Image through SilverStripe. If you encounter problems with images not appearing, or have mysteriously disappeared, you can try manually flushing the image cache. http://www.mysite.com/images/flush
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/form-field-types.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/form-field-types.md
4,129
1,758,118,090
en
# Introduction This is a highlevel overview of available FormFields. An automatically generated list is available through our [API](api:FormField) ## Formatted Input * `[AjaxUniqueTextField](api:AjaxUniqueTextField)`: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables * `[AutocompleteTextField](api:AutocompleteTextField)` * `[ConfirmedPasswordField](api:ConfirmedPasswordField)`: Shows two password-fields, and checks for matching passwords. * `[CreditCardField](api:CreditCardField)` * `[CurrencyField](api:CurrencyField)` * `[EmailField](api:EmailField)` * `[HTMLEditorField](api:HTMLEditorField)`: A WYSIWYG editor field, powered by tinymce. * `[NumericField](api:NumericField)`: A Single Numeric field extending a typical TextField but with validation. * `[PasswordField](api:PasswordField)` * `[UniqueRestrictedTextField](api:UniqueRestrictedTextField)`: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables * `[UniqueTextField](api:UniqueTextField)`: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables ## Date/Time * `[DateField](api:DateField)`: Represents a date in a textfield (New Zealand) * `[DatetimeField](api:DatetimeField)`: Combined date- and time field * `[TimeField](api:TimeField)`: Represents time in a textfield (New Zealand) ## Structure * `[CompositeField](api:CompositeField)`: Base class for all fields that contain other fields. Uses `<div>` in template, but doesn't necessarily have any visible styling. * `[FieldGroup](api:FieldGroup)`: Same as CompositeField, but has default styling (indentation) attached in CMS-context. * `[api:FieldSet]`: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a `<fieldgroup>`. * `[TabSet](api:TabSet)` * `[Tab](api:Tab)` ## Actions * `[api:Form]` for more info * `[InlineFormAction](api:InlineFormAction)`: Render a button that will act as If you want to add custom behaviour, please set {inlcudeDefaultJS} to false and work with behaviour.js. * `[api:Image]`: Action that uses an image instead of a button * `[InlineFormAction](api:InlineFormAction)`: Prevents placement of a button in the CMS-button-bar. ## Files * `[FileField](api:FileField)`: Simple file upload dialog. * `[FileIFrameField](api:FileIFrameField)`: File uploads through an iframe * `[api:Image]`: Image upload through an iframe, with thumbnails and file-selection from existing assets * `[SimpleImageField](api:SimpleImageField)`: SimpleImageField provides an easy way of uploading images to Image has_one relationships. Unlike ImageField, it doesn't use an iframe. ## Relations * `[ComplexTableField](api:ComplexTableField)`: Provides a tabuar list in your form with view/edit/add/delete links to modify records with a "has-one"-relationship (in a lightbox-popup). * `[HasManyComplexTableField](api:HasManyComplexTableField)` * `[HasOneComplexTableField](api:HasOneComplexTableField)` * `[LanguageDropdownField](api:LanguageDropdownField)`: An extension to dropdown field, pre-configured to list languages. Tied into i18n. * `[ManyManyComplexTableField](api:ManyManyComplexTableField)` * `[TableField](api:TableField)` * `[api:TableListField]` * `[TreeDropdownField](api:TreeDropdownField)` * `[TreeMultiselectField](api:TreeMultiselectField)`: represents many-many joins using a tree selector shown in a dropdown-like element * `[api:WidgetArea]` ## Dataless/Utility * `[DatalessField](api:DatalessField)` - Base class for fields which add some HTML to the form but don't submit any data or save it to the database * `[HeaderField](api:HeaderField)`: Renders a simple `<h1>`-`<h6>` header * `[HiddenField](api:HiddenField)` * `[LabelField](api:LabelField)` * `[LiteralField](api:LiteralField)`: Renders arbitrary HTML into a form. ## CMS Field Editor Please see `[api:HTMLEditorField]` for in-depth documentation about custom forms created through a GUI in the CMS.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/requirements.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/requirements.md
8,033
1,758,118,090
en
# Introduction The requirements class takes care of including CSS and JavaScript into your applications. This is preferred to hardcoding any references in the `<head>`-tag of your template, as it enables a more flexible handling. # Usage ## Including inside PHP Code It is common practice to include most Requirements either in the *init()*-method of your [controller](topics/controller), or as close to rendering as possible (e.g. in `[api:FormField]` :::php Requirements::javascript("cms/javascript/LeftAndMain.js"); Requirements::css("cms/css/TreeSelector.css"); If you're using the CSS method a second argument can be used. This argument defines the 'media' attribute of the `<link>` element, so you can define 'screen' or 'print' for example. Requirements::css("cms/css/TreeSelector.css", "screen,projection"); ## Including inside Template files If you do not want to touch the PHP (for example you are constructing a generic theme) then you can include a file via the templates <% require css(cms/css/TreeSelector.css) %> <% require themedCSS(TreeSelector) %> <% require javascript(cms/javascript/LeftAndMain.js) %> Note that currently (as of 2.3) you cannot pass a second parameter to a function via the template parser so doing the following will not work. <% require css(cms/css/TreeSelector.css, 'screen,projection') %> ## Combining Files You can concatenate several CSS or javascript files into a single dynamically generated file. This increases performance reducing HTTP requests. Note that for debugging purposes combined files is disabled in devmode. :::php // supports CSS + JS Requirements::combine_files( 'foobar.js', array( 'mysite/javascript/foo.js', 'mysite/javascript/bar.js', ) ); By default it stores the generated file in the assets/ folder but you can configure this by setting :::php // relative from the base folder Requirements::set_combined_files_folder('folder'); If SilverStripe doesn't have permissions on your server to write these files it will default back to including them individually . ## Custom Inline Scripts You can also quote custom script directly. This may seem a bit ugly, but is useful when you need to transfer some kind of 'configuration' from the database to the javascript/css. You'll need to use the "heredoc" syntax to quote JS and CSS, this is generally speaking the best way to do these things - it clearly marks the copy as belonging to a different language. :::php Requirements::customScript(<<<JS alert("hi there"); JS ); Requirements::customCSS(<<<CSS .tree li.$className { background-image: url($icon); } CSS ); ## Templated javascript A variant on the inclusion of custom javascript is the inclusion of *templated* javascript. Here, you keep your JavaScript in a separate file and instead load, via search and replace, several PHP-generated variables into that code. :::php $vars = array( "EditorCSS" => "mot/css/editor.css", ) Requirements::javascriptTemplate("cms/javascript/editor.template.js", $vars); ## Clearing You may want to clear all of the requirements mentioned thus far. I've used this when you've put an iframe generator as an action on the controller that uses it. The iframe has a completely different set of scripting and styling requirements, and it's easiest to flush all the default stuff and start again. :::php Requirements::clear(); You can also clear specific Requirements: :::php Requirements::clear('jsparty/prototype.js'); Caution: Depending on where you call this command, a Requirement might be *re-included* afterwards. ## Inclusion Order Requirements acts like a stack, where everything is rendered sequentially in the order it was included. There is no way to change inclusion-order, other than using *Requirements::clear* and rebuilding (=guessing) the whole set of requirements. Caution: Inclusion order is both relevant for CSS and Javascript files in terms of dependencies, inheritance and overlays - please be careful when messing with the order of Requirements. NOTE: By default, SilverStripe includes all Javascript files at the bottom of the page body. If this causes problems for you, for example if you're using animation that ends up showing everything until the bottom of the page loads, or shows buttons before pushing them will actually work, you can change this behaviour: In your controller's init() function, add: :::php Requirements::set_write_js_to_body(false); ## CMS Requirements The Silverstripe core includes a lot of Requirements by itself. Most of these are collated in `[api:LeftAndMain]`// first. # Motivation Every page requested is made up of a number of parts, and many of those parts require their own CSS or JavaScript. Rather than force the developer to put all of those requests into the template, or the header function, you can reference required files anywhere in your application. This lets you create very modular units of PHP+JavaScript+CSS, which a powerful concept but must be managed carefully. ## Managing Generic CSS styling One of the aims of this is to create units of functionality that can be reasonably easily deployed as-is, while still giving developers the option to customise them. The logical solution to this is to create 'generic' CSS to be applied to these things. However, we must take great care to keep the CSS selectors very nonspecific. This precludes us from adding any CSS that would "override customisations" in the form - for example, resetting the width of a field where 100% width isn't appropriate. Another solution would be to include some "generic CSS" for form elements at the very high level, so that fixed widths on forms were applied to the generic form, and could therefore be overridden by a field's generic stylesheet. Similar to this is mandating the use of "form div.field input" to style form input tags, whether it's a generic form or a custom one. Perhaps we could make use of a Requirements::disallowCSS() function, with which we could prevent the standard CSS from being included in situations where it caused problems. But the complexity could potentially balloon, and really, it's a bit of an admission of defeat - we shouldn't need to have to do this if our generic CSS was well-designed. # Ideas/Problems ##### Ajax The whole "include it when you need it" thing shows some weaknesses in areas such as the CMS, where Ajax is used to load in large pieces of the application, which potentially require more CSS and JavaScript to be included. At this stage, the only workaround is to ensure that everything you might need is included on the first page-load. One idea is to mention the CSS and JavaScript which should be included in the header of the Ajax response, so that the client can load up those scripts and stylesheets upon completion of the Ajax request. This could be coded quite cleanly, but for best results we'd want to extend prototype.js with our own changes to their Ajax system, so that every script had consistent support for this. ##### Lots of files Because everything's quite modular, it's easy to end up with a large number of small CSS and JavaScript files. This has problems with download time, and potentially maintainability. We don't have any easy answers here, but here are some ideas: * Merging the required files into a single download on the server. The flip side of this is that if every page has a slightly different JS/CSS requirements, the whole lot will be refetched. * Better: "Tagging" each required file for different use-cases, and creating a small set of common functionalities (e.g. everything tagged "base" such as prototype.js would always be included) * Do lazy fetching of scripts within an ajax-call. This seems to be possible, but very tricky due to the asynchronous nature of an ajax-request. Needs some more research # API Documentation [Full method documentation available here](http://api.silverstripe.org/trunk/sapphire/Requirements.html)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/reference/urlvariabletools.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/reference/urlvariabletools.md
7,445
1,758,118,090
en
# URL Variable Tools This page lists a number of "page options" , "rendering tools" or "special URL variables" that you can use to debug your sapphire applications. These are consumed in PHP using the $_REQUEST or $_GET superglobals throughout the Sapphire core. **General Usage** Append the option and corresponding value to your URL in your browser's address bar. You may find the [Firefox UrlParams extension](https///addons.mozilla.org/en-US/firefox/addon/1290) useful in order to debug a POST requests (Like Forms). http://yoursite.com/page?option_name=value http://yoursite.com/page?option_1=value&option_2=value ## Templates | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | flush | | 1,all | | This will clear out all cached information about the page. This is used frequently during development - for example, when adding new PHP or SS files. See below for value descriptions. | | showtemplate | | 1 | | Show the compiled version of all the templates used, including line numbers. Good when you have a syntax error in a template. Cannot be used on a Live site without **isDev** **flush** can be used with the following values: | | ?flush=1 | | | | | Flushes the current page and included templates | | ?flush=all | | | | Flushes the entire template cache | ## General Testing | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | isDev | | 1 | | Put the site into [development mode](/topics/debugging), enabling debugging messages to the browser on a live server. For security, you'll be asked to log in with an administrator log-in | | isTest | | 1 | | Put the site into [test mode](/topics/debugging), enabling debugging messages to the admin email and generic errors to the browser on a live server | | debug | | 1 | | Show a collection of debugging information about the director / controller operation | | debug_request | | 1 | | Show all steps of the request from initial HTTPRequest to Controller to Template Rendering | ## Classes and Objects | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | debugmanifest | | 1 | | Show the entire Sapphire manifest as currently built (Use /dev/build to rebuild) | | usetestmanifest | | 1 | | Force use of the default test manifest | | debugmethods | | 1 | | Shows all methods available when an object is constructed (useful when extending classes or using object decorators) | | debugfailover | | 1 | | Shows failover methods from classes extended | ## Database | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | showqueries | | 1 | | List all SQL queries executed | | previewwrite | | 1 | | List all insert / update SQL queries, and **don't** execute them. Useful for previewing writes to the database. | ## Profiling | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | debug_memory | | 1 | | Output the number of bytes of memory used for this request | | debug_profile | | 1 | | Enable the [profiler](profiler) for the duration of the request | | profile_trace | | 1 | | Includes full stack traces, must be used with **debug_profile** | | debug_behaviour | | 1 | | Get profiling of [Behaviour.js](http://bennolan.com/behaviour) performance (Firebug recommended) | | debug_javascript | | 1 | | Force debug-output on live-sites | ## Misc | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | forceFormat | | xhtml,html | | Force the content negotiator to deliver HTML or XHTML is allowed | | showspam | | 1 | | Show comments marked as spam when viewing Comments on a Page (Saving spam to the database must be enabled) | | ajax | | 1 | | Force request to process as AJAX request, useful for debugging from a browser | | force_ajax | | 1 | | Similar to **ajax** | ## Security Redirects You can set an URL to redirect back to after a [Security](/topics/security) action. See the section on [URL Redirections](security#redirect_back_to_another_page_after_login) for more information and examples. | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | BackURL | | URL | | Set to a relative URL string to use once Security Action is complete | # Building and Publishing URLS | Site URL | | Action | | -------- | | ------ | | %%http://yoursite.com%%**/dev/build** | | Rebuild the entire database and manifest, see below for additional URL Variables | | %%http://yoursite.com%%**/admin/publishall/** | | Publish all pages on the site | | %%http://yoursite.com%%**/anypage/images/flush** | | Creates new images for the page by deleting the resized ones and going back to the original to create new resized one | ## /dev/build | URL Variable | | Values | | Description | | ------------ | | ------ | | ----------- | | quiet | | 1 | | Don't show messages during build | | dont_populate | | 1 | | Don't run **requireDefaultRecords()** on the models when building. This will build the table but not insert any records |
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/themes.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/themes.md
1,822
1,758,118,090
en
# Themes Themes can be used to kick start your SilverStripe projects, and generally make you look good. ## Installing #### Downloading A Prebuilt Theme Head to the [ Themes ](http://www.silverstripe.org/themes ) area of the website to check out the wide range of themes the community has built. Each theme has a page with links you can use to preview and download it. The theme is provided as a .tar.gz file. #### Install 1. Simply unpack the contents of the zip file into the /themes directory in your SilverStripe installation. 2. Change to the theme by putting the following line in your ./mysite/_config.php: `SSViewer::set_theme("themename");` 1. Visit your homepage, ensuring you flush the cache (append ?flush=1 to the URL). # Developing a Theme See themes:[[themes:developing ]] to get an idea of how themes actually work and how you can develop your own. # Submitting your theme to SilverStripe If you want to submit your theme to the silverstripe directory then check * You should ensure your templates are well structured, modular and commented so it's easy for other people to customise them. * Templates should not contain text inside images and all images provided must be open source and not break any copyright law. This includes any icons your template uses in the frontend or the backend CMS * A theme does not include any PHP files. Only 3 folders - css/, images/ and templates. Your theme file must be in a .tar.gz format. A useful tool for this is - [7 Zip](http://www.7-zip.org/). Using 7Zip you must select the your_theme folder and Add to archive, select TAR and create. Then after you have the TAR file right click it -> Add to Archive (again) -> Then use the archive format GZIP. ## Discussing Head over to the [ Themes Forum ](http://www.silverstripe.com/showcase-forum/ )
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/page-types.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/page-types.md
6,636
1,758,118,090
en
# Introduction Page Types are the basic building blocks of any SilverStripe website. A page type can define: * The template or templates that are used to display content * What fields are available to edit in the CMS * Behaviour specific to a page type – for example a contact form on the ‘Contact Us’ page that sends an email when the form is submitted All the pages on the base installation are of the page type "Page". See [tutorial:2-extending-a-basic-site](tutorial/2-extending-a-basic-site) for a good introduction to page-types. Each page type on your website is a sub-class of the SiteTree class. Usually, you’ll define a class called ‘Page’ and use this template to lay out the basic design elements that don’t change. Take a look at mysite/templates/Page.ss. It contains standard HTML markup, with some differences. We’ll go over these later, but for now, you can see that this file only generates some of the content – it sets up the `<html>` tags, deals with the `<head>` section, creates the first-level navigation, and then closes it all off again. See $Layout? That’s what is doing most of the work when you visit a page. Now take a look at mysite/templates/Layout/Page.ss. This as you can see has a lot more markup in it – it’s what is included into $Layout when the ‘Page’ page type is rendered. Similarly, mysite/templates/Layout/HomePage.ss would be rendered into $Layout when the ‘HomePage’ page type is selected for the current page you’re viewing. Why do we sub-class Page for everything? The easiest way to explain this is to use the example of a search form. If we create a search form on the Page class, then any other sub-class can also use it in their templates. This saves us re-defining commonly used forms or controls in every class we use. ![](_images/pagetype-inheritance.png) Each page type is represented by two classes: a data object and a controller. In the diagrams above and below, the data objects are black and the controllers are blue. The page controllers are only used when the page type is actually visited on the website. In our example above, the search form would become a method on the ‘Page_Controller’ class. Any methods put on the data object will be available wherever we use this page. For example, we put any customizations we want to do to the CMS for this page type in here. ![](_images/controllers-and-dataobjects.png) Page types are created using PHP classes. If you’re not sure about how these work, [click here for a gentler introduction to PHP classes](http://www-128.ibm.com/developerworks/opensource/library/os-phpobj/). We put the Page class into a file called Page.php inside mysite/code. We also put Page_Controller in here. Any other classes that are based on Page – for example, the class Page_AnythingElse will also go into Page.php. Likewise, the StaffPage_Image class will go into StaffPage.php. # Usage ## Adding database-fields Adding database fields is a simple process. You define them in an array of the static variable ''$db'', this array is added on the object class. For example, Page or StaffPage. Every time you run db/build to recompile the manifest, it checks if any new entries are added to the ''$db'' array and adds any fields to the database that are missing. For example, you may want an additional field on a StaffPage class which extends Page, called Author. Author is a standard text field, and can be [casted](objectmodel) as a variable character object in php (VARCHAR in SQL). In the following example, our Author field is casted as a variable character object with maximum characters of 50. This is especially useful if you know how long your source data needs to be. :::php class StaffPage extends Page { static $db = array( 'Author' => 'Varchar(50)' ); } class StaffPage_Controller extends Page_Controller { } See [datamodel](/topics/datamodel) for a more detailed explanation on adding database fields, and how the SilverStripe data model works. ## Adding formfields and tabs See [form](/topics/forms) and [tutorial:2-extending-a-basic-site](tutorial/2-extending-a-basic-site) ## Removing inherited form fields and tabs ### removeFieldFromTab() Overloading ''getCMSFields()'' you can call ''removeFieldFromTab()'' on a ''FieldSet'' object. For example, if you don't want the MenuTitle field to show on your page, which is inherited from SiteTree. :::php class StaffPage extends Page { function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle'); return $fields; } } class StaffPage_Controller extends Page_Controller { } ### removeByName() ''removeByName()'' for normal form fields is useful for breaking inheritance where you know a field in your form isn't required on a certain page-type. :::php class MyForm extends Form { function __construct($controller, $name) { // add a default FieldSet of form fields $member = singleton('Member'); $fields = $member->formFields(); // We don't want the Country field from our default set of fields, so we remove it. $fields->removeByName('Country'); $actions = new FieldSet( new FormAction('submit', 'Submit') ); parent::__construct($controller, $name, $fields, $actions); } } This will also work if you want to remove a whole tab e.g. $fields->removeByName('Metadata'); will remove the whole Metadata tab. For more information on forms, see [form](/topics/forms), [tutorial:2-extending-a-basic-site](/tutorials/2-extending-a-basic-site) and [tutorial:3-forms](/tutorials/3-forms). ## Creating a new page: :::php $page = new Page(); $page->ParentID = 18; //if you want it to be a child of a certain other page... $page->Title = "Crazy page"; $page->MetaTitle = "madness"; $page->PageTitle = "Funny"; $page->writeToStage('Stage'); $page->publish('Stage', 'Live'); ## updating a page: :::php $page = DataObject::get_one("Page", "ParentID = 18"); $page->Title = "More Serious"; $page->writeToStage('Stage'); $page->Publish('Stage', 'Live'); $page->Status = "Published"; ## Deleting pages :::php $id = $page->ID; $stageRecord = Versioned::get_one_by_stage('SiteTree', 'Stage', "SiteTree.ID = $id"); if ($stageRecord) $stageRecord->delete(); $liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "SiteTree_Live.ID = $id"); if ($liveRecord) $liveRecord->delete(); ## Built-in Fields FIXME List fields from LeftAndMain->getCMSFields() ## Adding new fields and tabs
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/extending-the-cms.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/extending-the-cms.md
2,180
1,758,118,090
en
CMSMain is part of the CMS. It is the controller for the content editor. # Creating another hierarchical editor by subclassing CMSMain Sometimes you'll want to provide an administration interface that is pretty much exactly what CMSMain provides, but it's not appropriate to include your data in with the site content. For example, Hayden developed a hierarchical category administrator on the Guano application. Here's how you can do this: ## Using classes other than SiteTree in the site tree It is possible to use to different classes in two separate site trees. In Guano for example, there is the usual site content tree and a category tree. To change that find: :::php static $tree_class = 'SiteTree'; And change the string to the name of the class that will be the base class for classes visible in the site tree. ## Overloading page urls If using a url other than admin/ for your section then you will need to change the SiteTreeHandlers to use the correct controller. Create the init method: :::php function init() { parent::init(); Requirements::javascript('project-name/javascript/Classname_left.js'); } Where project-name and Classname are changed as appropriate. Create the javascript file and add the handlers: :::php if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {}; SiteTreeHandlers.parentChanged_url = 'url/ajaxupdateparent'; SiteTreeHandlers.orderChanged_url = 'url/ajaxupdatesort'; SiteTreeHandlers.showRecord_url = 'url/show/'; SiteTreeHandlers.loadPage_url = 'url/show/'; SiteTreeHandlers.loadTree_url = 'url/getsubtree'; where url is the relative link to the page (eg 'admin/categories'). You can change the handler functions as necessary. ## Overloading EditForm You may need to overload EditForm if your class does not use the Versioned extension. ## Overloading SiteTreeAsUL The tree hints can sometimes cause problems when reorganising the tree, and the CMSMain::SiteTreeAsUL function uses SiteTree explicitly. Use: :::php public function SiteTreeAsUL() { // $this->generateDataTreeHints(); $this->generateTreeStylingJS(); return $this->getSiteTreeFor( $this->stat('tree_class') ); }
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/index.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/index.md
0
1,758,118,090
en
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/forms.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/forms.md
8,568
1,758,118,090
en
# Forms Form is the base class of all forms in a sapphire application. Forms in your application can be created either by instantiating the Form class itself, or by subclassing it. ## Instantiating a form Creating a form is a matter of defining a method to represent that form. This method should return a form object. The constructor takes the following arguments: * ''$controller'': This must be the controller that contains the form. * ''$name'': This must be the name of the method on that controller that is called to return the form. The first two fields allow the form object to be re-created after submission. **It's vital that they are properly set - if you ever have problems with form action handler not working, check that these values are correct.* * ''$fields'': A `[api:FieldSet]`s that make up the editable portion of the form. * ''$actions'': A `[api:FieldSet]`s that make up the control portion of the form - the butons at the bottom. * ''$validator'': An optional `[api:Validator]` for more information. Example: :::php function MyCustomForm() { $fields = new FieldSet( new EmailField("Email"), new EncryptField("Password") ); $actions = new FieldSet(new FormAction("login", "Log in")); return new Form($this, "MyCustomForm", $fields, $actions); } ## Subclassing a form It's the reponsibility of your subclass' constructor to call :::php parent::__construct() with the right parameters. You may choose to take $fields and $actions as arguments if you wish, but $controller and $name must be passed - their values depend on where the form is instantiated. :::php class MyForm extends Form { function __construct($controller, $name) { $fields = new FieldSet( new EmailField("Email"), new EncryptedField("Password") ); $actions = new FieldSet(new FormAction("login", "Log in")); parent::__construct($controller, $name, $fields, $actions); } } The real difference, however, is that you can then define your controller methods within the form class itself. # Form Field Types There are many classes extending `[api:FormField]`. Some examples: * `[api:TextField]` * `[api:EmailField]` * `[api:NumericField]` * `[api:DateField]` * `[api:CheckboxField]` * `[api:DropdownField]` * `[api:OptionsetField]` * `[api:CheckboxSetField]` Full overview at [form-field-types](/reference/form-field-types) ## Using Form Fields To get these fields automatically rendered into a form element, all you need to do is create a new instance of the class, and add it to the fieldset of the form. :::php $form = new Form( $controller = $this, $name = "SignupForm", $fields = new FieldSet( new TextField( $name = "FirstName", $title = "First name" ), new TextField("Surname"), new EmailField("Email", "Email address"), ), $actions = new FieldSet( // List the action buttons here new FormAction("signup", "Sign up") ), $requiredFields = new RequiredFields( // List the required fields here: "Email", "FirstName" ) ); You'll note some of the fields are optional. Implementing the more complex fields requires extra arguments. :::php $form = new Form( $controller = $this, $name = "SignupForm", $fields = new FieldSet( // List the your fields here new TextField( $name = "FirstName", $title = "First name" ), new TextField("Surname"), new EmailField("Email", "Email address") new DropdownField( $name = "Country", $title = "Country (if outside nz)", $source = Geoip::getCountryDropDown(), $value = Geoip::visitor_country() ) ), new FieldSet( // List the action buttons here new FormAction("signup", "Sign up") ), new RequiredFields( // List the required fields here: "Email", "FirstName" ) ); # Readonly Readonly on a Form :::php $myForm->makeReadonly(); Readonly on a FieldSet :::php $myFieldSet->makeReadonly(); Readonly on a FormField :::php $myReadonlyField = $myField->transform(new ReadonlyTransformation()); // shortcut $myReadonlyField = $myField->performReadonlyTransformation(); # Using a custom template *Required Silverstripe 2.3 for some displayed functionality* You can use a custom form template to render with, instead of *Form.ss* It's recommended you only do this if you've got a lot of presentation text, graphics that surround the form fields. This is better than defining those as *LiteralField* objects, as it doesn't clutter the data layer with presentation junk. First of all, you need to create your form on it's own class, that way you can define a custom template using a ''forTemplate()'' method on your Form class. :::php class MyForm extends Form { function __construct($controller, $name) { $fields = new FieldSet( new TextField('FirstName', 'First name'), new EmailField('Email', 'Email address') ); $actions = new FieldSet( new FormAction('submit', 'Submit') ); parent::__construct($controller, $name, $fields, $actions); } function forTemplate() { return $this->renderWith(array( $this->class, 'Form' )); } function submit($data, $form) { // do stuff here } } ''forTemplate()'' tells the Form class to render with a template of return value of ''$this->class'', which in this case is *MyForm*, the name of the class. If the template doesn't exist, then it falls back to using Form.ss *MyForm.ss* should then be placed into your *templates/Includes* directory for your project. Here is an example of basic customisation: :::html <form $FormAttributes> <% if Message %> <p id="{$FormName}_error" class="message $MessageType">$Message</p> <% else %> <p id="{$FormName}_error" class="message $MessageType" style="display: none"></p> <% end_if %> <fieldset> <div id="FirstName" class="field text"> <label class="left" for="$FormName_FirstName">First name</label> $dataFieldByName(FirstName) </div> <div id="Email" class="field email"> <label class="left" for="$FormName_Email">Email</label> $dataFieldByName(Email) </div> $dataFieldByName(SecurityID) </fieldset> <% if Actions %> <div class="Actions"> <% control Actions %>$Field<% end_control %> </div> <% end_if %> </form> ''$dataFieldByName(FirstName)'' will return the form control contents of ''Field()'' for the particular field object, in this case ''TextField->Field()'' or ''EmailField->Field()'' which returns an `<input>` element with specific markup for the type of field. Pass in the name of the field as the first parameter, as done above, to render it into the template. To find more methods, have a look at the Form class, as there is a lot of different methods of customising the form templates, for example, you could use `<% control Fields %>` instead of specifying each field manually, as we've done above. ## Securing forms against Cross-Site Request Forgery (CSRF) SilverStripe tries to protect users against *Cross-Site Request Forgery (CSRF)* by adding a hidden *SecurityID* parameter to each form. See [secure-development](/topics/security) for details. ## Remove existing fields If you want to remove certain fields from your subclass: :::php class MyCustomForm extends MyForm { function __construct($controller, $name) { parent::__construct($controller, $name); // remove a normal field $this->fields->removeByName('MyFieldName'); // remove a field from a tab $this->fields->removeFieldFromTab('TabName', 'MyFieldName'); } } ## Working with tabs Adds a new text field called FavouriteColour next to the Content field in the CMS :::php $fields->addFieldToTab('Root.Content.Main', new TextField('FavouriteColour'), 'Content'); # Related * [form-field-types](/reference/form-field-types) * `[api:FormField]` class * [multiform module](http://silverstripe.org/multiform-module) # API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/forms/Form.html)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/directory-structure.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/directory-structure.md
3,317
1,758,118,090
en
# Introduction The directory-structure in Silverstripe it built on "convention over configuration", so the placement of some files and directories is meaningful to its logic. ## Core Structure Directory | Description --------- | ----------- `assets/` | Contains images and other files uploaded via the SilverStripe CMS. You can also place your own content inside it, and link to it from within the content area of the CMS. `cms/` | Contains all the files that form the CMS area of your site. It’s structure is similiar to the mysite/ directory, so if you find something interesting, it should be easy enough to look inside and see how it was built. `sapphire/` | The framework that builds both your own site and as the CMS that powers it. You’ll be utilizing files in this directory often, both directly and indirectly. ## Custom Code Structure We're using `<mysite>` as an example - arbitrary directory-names are allowed, as long as they don't collide with existing modules or the directories listes in "Core Structure". | Directory | Description | | --------- | ----------- | | `<mysite>/` | This directory contains all of your code that defines your website. | | `<mysite>/code` | PHP code for model and controller (subdirectories are optional) | | `<mysite>/templates` | HTML [templates](templates) with *.ss-extension | | `<mysite>/css ` | CSS files | | `<mysite>/images ` | Images used in the HTML templates | | `<mysite>/javascript` | Javascript and other script files ## Themes Structure | `themes/blackcandy/` | Standard "blackcandy" theme | | ------------------ | --------------------------- | | `themes/blackcandy_blog/` | Theme additions for the blog module | | `themes/yourtheme/` | The themes folder can contain more than one theme - here's your own | See [themes](/topics/themes) ## Module Structure Modules are currently top-level folders that need to have a *_config.php*-file present. They should follow the same conventions as posed in "Custom Site Structure" Example Forum: | Directory | Description | | --------- | ----------- | | `forum/` | This directory contains all of your code that defines your website. | | `forum/code` | PHP code for model and controller (subdirectories are optional) | | ... | ... | ![](_images/modules_folder.jpg) ## PHP Include Paths Due to the way `[api:ManifestBuilder]` recursively detects php-files and includes them through PHP5's *__autoload()*-feature, you don't need to worry about include paths. Feel free to structure your php-code into subdirectories inside the *code*-directory. # Best Practices ## Making /assets readonly See [secure-development#filesystem](secure-development#filesystem)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/configuration.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/configuration.md
7,172
1,758,118,090
en
# Introduction Silverstripe doesn't have a global configuration-array or an interface with all available configuration-options. As all Silverstripe logic is contained in classes, the appropriate place to configure their behaviour is directly in the class itself. This lack of a configuration-GUI is on purpose, as we'd like to keep developer-level options where they belong (into code), without cluttering up the interface. See this core forum discussion ["The role of the CMS"](http://www.silverstripe.com/core-team-discussion/flat/2723) for further reasoning. In addition to these principle, some settings are * Author-level configuration like interface language or date/time formats can be performed in the CMS "My Profile" section (`admin/myprofile`). * Group-related configuration like [api:HTMLEditorField] settings can be found in the "Security" section (`admin/security`). * Site-wide settings like page titles can be set (and extended) on the root tree element in the CMS "Content" section (through the [siteconfig](/reference/siteconfig) API). ## _ss_environment.php See [environment-management](/topics/environment-management). ## mysite/_config.php This file is detected in each folder by `[api:ManifestBuilder]`. This way, every toplevel-folder (=module) can have independent configuration-rules. //Please note that this is the only place where you can put in procedural code - all other functionality is wrapped in classes (see [common-problems](/topics/common-problems)).// You can call most static methods from _config.php - classes will be loaded as required. Here's a list - **this is incomplete - please add to it** *Try to keep it in alphabetical order too! :)* | Call | | Description | | ---- | | ----------- | | Authenticator::register_authenticator($authenticator);| | Enable an authentication method (for more details see [security](/topics/security)). | | Authenticator::set_default_authenticator($authenticator); | | Modify tab-order on login-form.| | BasicAuth::disable() | | Disable basic authentication checking for dev sites (useful when testing credit card transaction post-backs etc) | | BBCodeParser::disable_autolink_urls(); | | Disables plain hyperlinks from being turned into links when bbcode is parsed. | | BlogEntry::allow_wysiwyg_editing(); | | Enable rich text editing for blog posts. | | ContentNegotiator::set_encoding(string $encoding) | | The encoding charset to use - UTF-8 by default | | ContentNegotiator::disable() | | Disables the negotiation of content type -usually used to stop it from rewriting the DOCTYPE of the document | Debug::send_errors_to(string $email) | | Send live errors on your site to this address (site has to be in 'live' mode using Director::set_environment_type(live) for this to occur | | Director::set_environment_type(string dev,test,live) | | Sets the environment type (e.g. dev site will show errors, live site hides them and displays a 500 error instead) | | Director::set_dev_servers(array('localhost', 'dev.mysite.com)) | | Set servers that should be run in dev mode (see [debugging](debugging)) | | Director::addRules(int priority, array rules) | | Create a number of URL rules to be checked against when SilverStripe tries to figure out how to display a page. See cms/_config.php for some examples. Note: Using ->something/ as the value for one of these will redirect the user to the something/ page. | | Email::setAdminEmail(string $adminemail) | | Sets the admin email for the site, used if there is no From address specified, or when you call Email::getAdminEmail() | | Email::send_all_emails_to(string $email) | | Sends all emails to this address. Useful for debugging your email sending functions | | Email::cc_all_emails_to(string $email) | | Useful for CC'ing all emails to someone checking correspondence | | Email::bcc_all_emails_to(string $email) | | BCC all emails to this address, similar to CC'ing emails (above) | | MathSpamProtection::setEnabled() | | Adds a math spam question to all page comment forms | | PageComment::enableModeration(); | | Enables comment moderation | | Security::encrypt_passwords($encrypt_passwords); | | Specify if you want store your passwords in clear text or encrypted (for more details see [security](/topics/security)) | | Security::set_password_encryption_algorithm($algorithm, $use_salt);| | If you choose to encrypt your passwords, you can choose which algorithm is used to and if a salt should be used to increase the security level even more (for more details see [security](/topics/security)). | | Security::setDefaultAdmin('admin','password'); | | Set default admin email and password, helpful for recovering your password | | SSAkismet::setAPIKey(string $key) | | Enables use of the Akismet spam filter. The key must be a valid WordPress API key. | | SSViewer::set_theme(string $themename) | | Choose the default theme for your site | ## Constants Some constants are user-defineable within *_ss_environment.php*. | Name | | Description | | ---- | | ----------- | | *TEMP_FOLDER* | | Absolute file path to store temporary files such as cached templates or the class manifest. Needs to be writeable by the webserver user. Defaults to *sys_get_temp_dir()*, and falls back to *silverstripe-cache* in the webroot. See *getTempFolder()* in *sapphire/core/Core.php* | ## User-level: Member-object All user-related preferences are stored as a property of the `[api:Member]`-class (and as a database-column in the *Member*-table). You can "mix in" your custom preferences by using `[api:DataObject]` for details. ## Permissions See [security](/topics/security) and [permission](/reference/permission)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/files.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/files.md
508
1,758,118,090
en
# Files and Images ## Files as database records TODO Explain relationship of files to database ## Management through "Files & Images" TODO Screenshot of admin interface ## Upload TODO Link to Upload and FileIframeField classes ## Image Resizing If you've changed the resize functions of your image uploaders you can run this again - and all the images will be resampled to the new arguments for the GD functions. This also, in some cases, repairs broken image links that can happen from time to time.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/commandline.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/commandline.md
4,272
1,758,118,090
en
# Commandline usage in SilverStripe ## Introduction SilverStripe can call controllers through commandline `php` just as easily as through a web browser. This can be handy to automate tasks with cron jobs, run unit tests and maintenance tasks, and a whole bunch of other scripted goodness. The main entry point for any commandline execution is `cli-script.php`. For example, to run a database rebuild from the commandline, use this command: cd your-webroot/ php sapphire/cli-script.php dev/build Make sure that your commandline php version uses the same configuration as your webserver (run `php -i` to find out more). ## GET parameters as arguments You can add parameters to the command by using normal form encoding. All parameters will be available in `$_GET` within SilverStripe. cd your-webroot/ php sapphire/cli-script.php myurl myparam=1 myotherparam=2 ## SAKE: Sapphire make Sake is a simple wrapper around `cli-script.php`. It also tries to detect which `php` executable to use if more than one are available. **If you are using a debian server:** Check you have the php-cli package installed for sake to work. If you get an error when running the command php -v, then you may not have php-cli installed so sake won't work. ### Installation You can copy the `sake` file into `/usr/bin/sake` for easier access (this is optional): cd your-webroot/ sudo ./sapphire/sake installsake Note: This currently only works on unix-like systems, not on Windows. ## Configuration Sometimes SilverStripe needs to know the URL of your site, for example, when sending an email. When you're visiting your site in a web browser this is easy to work out, but if you're executing scripts on the command-line, it has no way of knowing. To work this out, you should add lines of this form to your [_ss_environment.php](/topics/environment-management) file. :::php global $_FILE_TO_URL_MAPPING; $_FILE_TO_URL_MAPPING['/Users/sminnee/Sites'] = 'http://localhost'; What the line says is that any Folder under /Users/sminnee/Sites/ can be accessed in a web browser from http://localhost. For example, /Users/sminnee/Sites/mysite will be available at http://localhost/mysite. You can add multiple file to url mapping definitions. The most specific mapping will be used. For example: :::php global $_FILE_TO_URL_MAPPING; $_FILE_TO_URL_MAPPING['/Users/sminnee/Sites'] = 'http://localhost'; $_FILE_TO_URL_MAPPING['/Users/sminnee/Sites/mysite'] = 'http://mysite.localhost'; Using this example, /Users/sminnee/Sites/mysite/ would be accessed at http://mysite.localhost/, and /Users/sminnee/Sites/othersite/ would be accessed at http://localhost/othersite/ ## Usage Sake will either run `./sapphire/cli-script.php` or `./cli-script.php`, depending on what's available. It's particularly useful for running build tasks... cd /your/site/folder sake db/build sake dev/tests/all It can also be handy if you have a long running script. cd /your/site/folder sake MyReallyLongTask #### Running processes You can use sake to make daemon processes for your application. Step 1: Make a task or controller class that runs a loop. Because Sapphire has memory leaks, you should make the PHP process exit when it hits some reasonable memory limit. Sake will automatically restart your process whenever it exits. The other thing you should do is include some appropriate sleep()s so that your process doesn't hog the system. The best thing to do is to have a short sleep when the process is in the middle of doing things, and a long sleep when doesn't have anything to do. This code provides a good template: :::php class MyProcess extends Controller { function index() { set_time_limit(0); while(memory_get_usage() < 32*1024*1024) { if($this->somethingToDo()) { $this->doSomething(); sleep(1) } else { sleep(300); } } } } Step 2: Install the "daemon" command-line tool on your server. Step 3: Use sake to start and stop your process sake -start MyProcess sake -stop MyProcess Note that sake processes are currently a little brittle, in that the pid and log files are placed in the site root directory, rather than somewhere sensible like /var/log or /var/run.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/security.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/security.md
12,089
1,758,118,090
en
# Introduction This page details notes on how to ensure that we develop secure SilverStripe applications. See [security](/topics/security) for the Silverstripe-class as a starting-point for most security-related functionality. See our [contributing guidelines](http://doc.silverstripe.org/doku.php?id=contributing#reporting_security_issues) on how to report security issues. # SQL Injection The [coding-conventions](/misc/coding-conventions) help guard against SQL injection attacks but still require developer dilligence: ensure that any variable you insert into a filter / sort / join clause has been escaped. See [http://shiflett.org/articles/sql-injection](http://shiflett.org/articles/sql-injection). ## Automatic escaping Silverstripe automatically runs [addslashes()](http://php.net/addslashes) in DataObject::write() wherever possible. Data is escaped when saving back to the database, not when writing to object-properties. * DataObject::get_by_id() * DataObject::update() * DataObject::castedUpdate() * DataObject->Property = 'val', DataObject->setField('Property','val') * DataObject::write() * Form->saveInto() * FormField->saveInto() * DBField->saveInto() Note: It is NOT good practice to "be sure" and convert the data passed to the functions below manually. This might result in *double escaping* and alters the actually saved data (e.g. by adding slashes to your content). ## Manual escaping As a rule of thumb, whenever you're creating raw queries (or just chunks of SQL), you need to take care of escaping yourself. See [coding-conventions](/misc/coding-conventions) and [escape-types](escape-types) for ways to cast and convert your data. * SQLQuery * DataObject::buildSQL() * DB::query() * Director::urlParams() * Controller->requestParams, Controller->urlParams * GET/POST data passed to a Form-method Example: :::php class MyForm extends Form { function save($RAW_data, $form) { $SQL_data = Convert::raw2sql($RAW_data); // works recursively on an array $objs = DataObject::get('Player', "Name = '{$SQL_data[name]}'"); // ... } } * FormField->Value() * URLParams passed to a Controller-method Example: :::php class MyController extends Controller { function myurlaction($RAW_urlParams) { $SQL_urlParams = Convert::raw2sql($RAW_urlParams); // works recursively on an array $objs = DataObject::get('Player', "Name = '{$SQL_data[OtherID]}'"); // ... } } As a rule of thumb, you should escape your data **as close to querying as possible**. This means if you've got a chain of functions passing data through, escaping should happen at the end of the chain. :::php class MyController extends Controller { /** * @param array $RAW_data All names in an indexed array (not SQL-safe) */ function saveAllNames($RAW_data) { // $SQL_data = Convert::raw2sql($RAW_data); // premature escaping foreach($RAW_data as $item) $this->saveName($item); } function saveName($RAW_name) { $SQL_name = Convert::raw2sql($RAW_name); DB::query("UPDATE Player SET Name = '{$SQL_name}'"); } } This might not be applicable in all cases - especially if you are building an API thats likely to be customized. If you're passing unescaped data, make sure to be explicit about it by writing *phpdoc*-documentation and *prefixing* your variables ($RAW_data instead of $data). # XSS (Cross-Site-Scripting) SilverStripe helps you guard any output against clientside attacks initiated by malicious user input, commonly known as XSS (Cross-Site-Scripting). With some basic guidelines, you can ensure your output is safe for a specific use case (e.g. displaying a blog post in HTML from a trusted author, or escaping a search parameter from an untrusted visitor before redisplaying it). Note: SilverStripe templates do not remove tags, please use [strip_tags()](http://php.net/strip_tags) for this purpose or [sanitize](http://htmlpurifier.org/) it correctly. See [http://shiflett.org/articles/foiling-cross-site-attacks](http://shiflett.org/articles/foiling-cross-site-attacks) for in-depth information about "Cross-Site-Scripting". ## Escaping model properties `[api:SSViewer]` (the SilverStripe template engine) automatically takes care of escaping HTML tags from specific object-properties by [casting](casting) its string value into a `[api:DBField]` object. PHP: :::php class MyObject extends DataObject { public static $db = array( 'MyEscapedValue' => 'Text', // Example value: <b>not bold</b> 'MyUnescapedValue' => 'HTMLText' // Example value: <b>bold</b> ); } Template: :::php <ul> <li>$MyEscapedValue</li> // output: &lt;b&gt;not bold&lt;b&gt; <li>$MyUnescapedValue</li> // output: <b>bold</b> </ul> The example below assumes that data wasn't properly filtered when saving to the database, but are escaped before outputting through SSViewer. ## Overriding default escaping in templates You can force escaping on a casted value/object by using an [escape type](escape-types) method in your template, e.g. "XML" or "ATT". Template (see above): :::php <ul> // output: <a href="#" title="foo &amp; &#quot;bar&quot;">foo &amp; "bar"</a> <li><a href="#" title="$Title.ATT">$Title</a></li> <li>$MyEscapedValue</li> // output: &lt;b&gt;not bold&lt;b&gt; <li>$MyUnescapedValue</li> // output: <b>bold</b> <li>$MyUnescapedValue.XML</li> // output: &lt;b&gt;bold&lt;b&gt; </ul> ## Escaping custom attributes and getters Every object attribute or getter method used for template purposes should have its escape type defined through the static *$casting* array. Caution: Casting only applies when using values in a template, not in PHP. PHP: :::php class MyObject extends DataObject { public $Title = '<b>not bold</b>'; // will be escaped due to Text casting $casting = array( "Title" => "Text", // forcing a casting 'TitleWithHTMLSuffix' => 'HTMLText' // optional, as HTMLText is the default casting ); function TitleWithHTMLSuffix($suffix) { // $this->Title is not casted in PHP return $this->Title . '<small>(' . $suffix. ')</small>'; } } Template: :::php <ul> <li>$Title</li> // output: &lt;b&gt;not bold&lt;b&gt; <li>$Title.RAW</li> // output: <b>not bold</b> <li>$TitleWithHTMLSuffix</li> // output: <b>not bold</b>: <small>(...)</small> </ul> Note: Avoid generating HTML by string concatenation in PHP wherever possible to minimize risk and separate your presentation from business logic. ## Manual escaping in PHP When using *customise()* or *renderWith()* calls in your controller, or otherwise forcing a custom context for your template, you'll need to take care of casting and escaping yourself in PHP. The `[api:Convert]` class has utilities for this, mainly *Convert::raw2xml()* and *Convert::raw2att()* (which is also used by *XML* and *ATT* in template code). PHP: :::php class MyController extends Controller { function search($request) { $htmlTitle = '<p>Your results for:' . Convert::raw2xml($request->getVar('Query')) . '</p>'; return $this->customise(array( 'Query' => DBField::create('Text', $request->getVar('Query')), 'HTMLTitle' => DBField::create('HTMLText', $htmlTitle) )); } } Template: :::php <h2 title="Searching for $Query.ATT">$HTMLTitle</h2> Whenever you insert a variable into an HTML attribute within a template, use $VarName.ATT, no not $VarName. You can also use the built-in casting in PHP by using the *obj()* wrapper, see [objectmodel](objectmodel) . ## Escaping URLs Whenever you are generating a URL that contains querystring components based on user data, use urlencode() to escape the user data, not *Convert::raw2att()*. Use raw ampersands in your URL, and cast the URL as a "Text" DBField: PHP: :::php class MyController extends Controller { function search($request) { $rssRelativeLink = "/rss?Query=" . urlencode($_REQUEST['query']) . "&sortOrder=asc"; $rssLink = Controller::join_links($this->Link(), $rssRelativeLink); return $this->customise(array( "RSSLink" => DBField::create("Text", $rssLink), )); } } Template: :::php <a href="$RSSLink.ATT">RSS feed</a> Some rules of thumb: * Don't concatenate URLs in a template. It only works in extremely simple cases that usually contain bugs. * Use *Controller::join_links()* to concatenate URLs. It deals with querystrings and other such edge cases. # Cross-Site Request Forgery (CSRF) SilverStripe has built-in countermeasures against this type of identity theft for all form submissions. A form object will automatically contain a *SecurityID* parameter which is generated as a secure hash on the server, connected to the currently active session of the user. If this form is submitted without this parameter, or if the parameter doesn't match the hash stored in the users session, the request is discarded. If you know what you're doing, you can disable this behaviour: :::php $myForm->disableSecurityToken(); See [http://shiflett.org/articles/cross-site-request-forgeries](http://shiflett.org/articles/cross-site-request-forgeries) ## Casting user input When working with ''$_GET'', ''$_POST'' or ''Director::urlParams'' variables, and you know your variable has to be of a certain type, like an integer, then it's essential to cast it as one. *Why?* To be sure that any processing of your given variable is done safely, with the assumption that it's an integer. To cast the variable as an integer, place ''(int)'' or ''(integer)'' before the variable. For example: a page with the URL paramaters *mysite.com/home/add/1* requires that ''Director::urlParams['ID']'' be an integer. We cast it by adding ''(int)'' - ''(int)Director::urlParams['ID']''. If a value other than an integer is passed, such as *mysite.com/home/add/dfsdfdsfd*, then it returns 0. Below is an example with different ways you would use this casting technique: :::php function CaseStudies() { // cast an ID from URL parameters e.g. (mysite.com/home/action/ID) $anotherID = (int)Director::urlParams['ID']; // perform a calculation, the prerequisite being $anotherID must be an integer $calc = $anotherID + (5 - 2) / 2; // cast the 'category' GET variable as an integer $categoryID = (int)$_GET['category']; // perform a get_by_id, ensure the ID is an integer before querying return DataObject::get_by_id('CaseStudy', $categoryID); } The same technique can be employed anywhere in your PHP code you know something must be of a certain type. A list of PHP cast types can be found here: * ''(int)'', ''(integer)'' - cast to integer * ''(bool)'', ''(boolean)'' - cast to boolean * ''(float)'', ''(double)'', ''(real)'' - cast to float * ''(string)'' - cast to string * ''(array)'' - cast to array * ''(object)'' - cast to object Note that there is also a 'SilverStripe' way of casting fields on a class, this is a different type of casting to the standard PHP way. See [ casting](casting ). # Filesystem ## Don't allow script-execution in /assets As all uploaded files are stored by default on the /assets-directory, you should disallow script-execution for this folder. This is just an additional security-measure to making sure you avoid directory-traversal, check for filesize and disallow certain filetypes. Example configuration for Apache2: <VirtualHost *:80> ... <LocationMatch assets/> php_flag engine off Options -ExecCGI -Includes -Indexes </LocationMatch> </VirtualHost> If you are using shared hosting or in a situation where you cannot alter your Vhost definitions, you can use a .htaccess file in the assets directory. This requires PHP to be loaded as an Apache module (not CGI or FastCGI). **/assets/.htaccess** php_flag engine off Options -ExecCGI -Includes -Indexes # Related * [http://silverstripe.org/security-releases/](http://silverstripe.org/security-releases/) # Links * [Best-practices for securing MySQL (securityfocus.com)](http://www.securityfocus.com/infocus/1726)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/modules.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/modules.md
4,078
1,758,118,090
en
# What are SilverStripe Modules? Sapphire is designed to be a modular application system - even the CMS is simply a module that plugs into it. A module is, quite simply, a collection of classes, templates, and other resources that is loaded into a top-level directory. In a default SilverStripe download, even resources in 'sapphire' and 'mysite' are treated in exactly the same as every other module. Sapphire's `[api:ManifestBuilder]` will find any class, css or template files anywhere under the site's main directory. The _config.php file in the module directory can be used to define director rules, calls to Object::useCustomClass(), and the like. So, by unpacking a module into site's main directory and viewing the site with ?flush=1 on the end of the URL, all the module's new behaviour will be incorporated to your site: * You can create subclasses of base classes such as SiteTree to extend behaviour. * You can use Object::useCustomClass() to replace a built in class with a class of your own. * You can use [a decorator](api:DataObjectDecorator) to extend or alter the behaviour of a built-in class without replacing it. * You can provide additional director rules to define your own controller for particular URLs. For more information on creating modules, see [module-development](/topics/module-development). ## Types of Modules Because of the broad definition of modules, they can be created for a number of purposes: * **Applications:** A module can define a standalone application that may work out of the box, or may get customisation from your mysite folder. "cms" is an example of this. * **CMS Add-ons:** A module can define an extension to the CMS, usually by defining special page types with their own templates and behaviour. "blog", "ecommerce", "forum", and "gallery" are examples of this. * **Blog Widgets:** A module can provide 1 or more blog-widget classes. See [widgets](/topics/widgets) for more information. * **Developer Tools:** A module can provide a number of classes or resource files that do nothing by themselves, but instead make it easier for developers to build other applications. ## Finding Modules * [Official module list on silverstripe.org](http://silverstripe.org/modules) * [Subversion repository on open.silverstripe.org](http://open.silverstripe.org/browser/modules) ## Installation Modules should exist in the root folder of your SilverStripe. The root folder being the one that contains the *sapphire*, *cms* and other folders. The following article explains the generic installation of a module. Individual modules have their own requirements such as creating folders or configuring API keys. For information about installing or configuring a specific module see the modules *INSTALL* (or *README*) file. Modules should adhere to the [directory-structure](/topics/directory-structure) guidelines. ### Download To install a module you need to download the tar.gz file from the [modules page](http://www.silverstripe.org/modules) or a generated [dailybuild](http://dailybuilds.silverstripe.org) and extract this tar.gz to the root folder mentioned above. Note some times the folders extracted from the tar.gz contain the version number or some other folders. You need to make sure the folder name is the correct name of the module. ### Subversion #### Option 1: Checkout cd ~/Sites/yourSilverStripeProject/ svn co http://svn.silverstripe.com/open/modules/modulename/trunk modulename/ Note: Some modules are stored in subfolders. If you want to use a module that is in a subfolder, such as widgets, put an _ between the subfolder name and the module name, like this: cd /your/website/root svn co http://svn.silverstripe.com/open/modules/widgets/twitter/trunk widgets_twitter #### Option 2: Add to svn:externals cd ~/Sites/yourSilverStripeProject/ svn propedit svn:externals . In the editor add the following line (lines if you want multiple) modulename/ http://svn.silverstripe.com/open/modules/modulename/trunk Exit the editor and then run svn up
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/i18n.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/i18n.md
12,420
1,758,118,090
en
# Introduction The i18n class (short for "internationalization") in Silverstripe enables you to display templates and PHP code in different languages based on your global settings and the preferences of your website users. This process is also known as l10n (short for "localization"). For translating any content managed through the CMS or stored in the database, please refer to the [translation](/topics/translation) documentation (which explains the `[api:Translatable]` extension). This page aims to describe the low-level functionality of the i18n-API. It targets developers who: * are involved in creating templates in different languages * want to build their own modules with i18n capabilities * want to make their PHP-code (e.g. form labels) i18n-ready Please note that this project scope currently **doesn't include full support for format conversion in dates or currencies**. Check our [roadmap](http://open.silverstripe.com/roadmap). # Usage ## Enabling i18n The i18n class is enabled by default. ## Setting the locale To set the locale you just need to call `[api:i18n::set_locale()]` passing, as a parameter, the name of the locale that you want to set. :::php //Example 1: setting the locale i18n::set_locale('de_DE'); //Setting the locale to German (Germany) i18n::set_locale('ca_AD'); //Setting to Catalan (Andorra) Once we set a locale, all the calls to the translator function will return strings according to the set locale value, if these translations are available. See [unicode.org](http://unicode.org/cldr/data/diff/supplemental/languages_and_territories.html) for a complete listing of available locales. ## Getting the locale As you set the locale you can also get the current value, just by calling `[api:i18n::get_locale()]`. ## Date and time formats Formats can be set globally in the i18n class. These settings are currently only picked up by the CMS, you'll need to write your own logic for any frontend output. :::php i18n::set_date_format('dd.MM.YYYY'); i18n::set_time_format('HH:mm'); Most localization routines in SilverStripe use the [http://framework.zend.com/manual/en/zend.date.html](Zend_Date API). This means all formats are defined in [http://framework.zend.com/manual/en/zend.date.constants.html#zend.date.constants.selfdefinedformats](ISO date format), not PHP's built-in [http://nz.php.net/manual/en/function.date.php](date()). ## i18n in Form Fields Date- and time related form fields support i18n ([api:DateField], [api:TimeField], [api:DatetimeField]). :::php i18n::set_locale('ca_AD'); $field = new DateField(); // will automatically set date format defaults for 'ca_AD' $field->setLocale('de_DE'); // will not update the date formats $field->setConfig('dateformat', 'dd.MM.YYYY'); // sets typical 'de_DE' date format Form fields in the CMS are automatically set according to the profile settings for the logged-in user (`Member->DateFormat` and `Member->TimeFormat`). # Adapting modules for i18n Adapting a module to make it localizable is easy with SilverStripe. You just need to avoid hardcoding strings that are language-dependent and use a translator function call instead. :::php // without i18n echo "This is a string"; // with i18n echo _t("Namespace.Entity","This is a string"); All strings passed through the _t() function will be collected in a separate language table (see "Collecting entities" below), which is the starting point for translations. ## The _t() function Here is the function prototype of this translator function :::php function _t(string $entity [, string $string [, int $priority [, string $context]]]) { #### Entity The first parameter is the identifier, and is composed by a namespace and an entity name, with a dot separating them. The main class name (i.e. the same one that the php name file) should usually be used as the namespace. This means that if we are coding in the file LeftAndMain.php, the namespace should be 'LeftAndMain', and therefore the complete first parameter would be 'LeftAndMain.ENTITY'. There is an exception to this rule. If you are using the same exactly string in two different files, for example in A.php and B.php, and the string in B.php will always be the same string that in A.php, then you can 'declare' this string in A.php with `_t('A.ENTITY','String that is used in A and B');`{php} and then in B.php simply write: `_t('A.ENTITY');`{php} In this way if somewhere in the future you need to modify this string, you just need to edit it in one file (A.php). Translators will also have to translate this string just once. Entity names are by convention written in uppercase. They have to be unique within their namespace, and its purpose is to serve as an identificator to this string, together with the namespace. Having an unique identificator for each string allows some features like change tracking. Therefore, a meaningful name is always welcomed, although not required. And also, that's why you shouldn't change an existing entity name in the code, unless you have a good reason to do it. #### String The second parameter is the string itself. It's not mandatory if you have set this same string in another place before (using the same class and entity). So you could write :::php _t('ClassName.HELLO',"Hello") and later :::php _t('ClassName.HELLO') In fact, if you write the string in this second case, a warning will be issued when text-collecting to alert that you are redeclaring an entity. #### Priority Priority parameter is an optional parameter and it can be used to set a translation priority. If a string is widely used, it should have a high priority (PR_HIGH), in this way translators will be able to prioritise the translation of this strings. If a string is extremely rarely shown, use PR_LOW. You can use PR_MEDIUM as well. Leaving this field blank will be interpretated as a "normal" priority (some less than PR_MEDIUM). Using priorities allows translators to benefit from the 80/20 rule when translating, since typically there is a reduced set of strings that are widely displayed, and a lot of more specific strings. Therefore, in a module with a considerable amount of strings, where partial translations can be expected, priorities will help to have translated the most displayed strings. If a string is in a class is inheritable, it's not recommended to establish a priority (we don't know about child behavior a priori). #### Context Last parameter is context, it's also optional. Sometimes short phrases or words can have several translations depending upon where they are used, and Context serves as a way to tell translators more information about the string in these cases where translating can be difficult, due to lack of context or ambiguity. This context param can also be used with other situations where translation may need to know more than the original string, for example with sprintf '%' params inside the string, since you can tell translators about the meaning of this parameters. :::php //Example 4: Using context to hint information about a parameter sprintf(_t('CMSMain.RESTORED', "Restored '%s' successfully", PR_MEDIUM, 'Param %s is a title' ), $title) ## Usage There're two types of files in a module where you can use this _t() function: code files (under code folder) and template files (under templates) * In code files, in order to ask for a translated string, we have to write a normal php call to this function. Example: :::php _t('LeftAndMain.HELLO','Site content',PR_HIGH,'Menu title'); _t('LeftAndMain.FILESIMAGES','Files & Images',PR_HIGH); _t('LeftAndMain.NEWSLETTERS','Newsletters'); * In template files these calls are written slightly different to ease readibility, diminish overhead and allow a cleaner template file. Calls can be placed anywhere, but they are preceded and followed by `<% and %>` as usual in the SilverStripe templating language, and the first parameter is omitted (namespace in template files is always the file itself). Therefore, the following would be a valid use in templates: :::html <a href="http://www.silverstripe.com" title="<% _t('VISIT','Visit www.silverstripe.com') %>"> Using SS templating variables in the translatable string (e.g. $Author, $Date..) is not currently supported. ### sprintf()-support Sprintf enables us to dynamically replace parts of a translated string, e.g. by a username or a page-title. :::php // in PHP-file sprintf( _t('CMSMain.RESTORED',"Restored '%s' successfully"), $title ) **Caution**: In templates (*.ss)-files you can only use ONE argument for your sprintf-support, and can't use spaces between parameters. :::php // in SS-template ($title must be available in the current template-scope) <% sprintf(_t('CMSMain.RESTORED',"Restored '%s' successfully"),$title) %> # Collecting text To collect all the text in code and template files we have just to visit: `http://<mysite>/dev/tasks/i18nTextCollectorTask` Text collector will then read the files, build the master string table for each module where it finds calls to the underscore function, and tell you about the created files and any possible entity redeclaration. If you want to run the text collector for just one module you can use the 'module' parameter: `http://<mysite>/dev/tasks/i18nTextCollectorTask/?module=cms` **Note**: You'll need to install PHPUnit to run the text collector (see [testing-guide](/topics/testing)). # Language tables in PHP Each module can have one language table per locale. These tables are just PHP files with array notations. By convention, the files are stored in the /lang subfolder, and are named after their locale value, e.g. "en_US.php". Example: sapphire/lang/en_US.php (extract) :::php // ... $lang['en_US']['ImageUploader']['ATTACH'] = array( 'Attach %s', PR_MEDIUM, 'Attach image/file' ); $lang['en_US']['FileIFrameField']['NOTEADDFILES'] = 'You can add files once you have saved for the first time.'; // ... Translation table: sapphire/lang/de_DE.php (extract) :::php $lang['de_DE']['ImageUploader']['ATTACH'] = '%s anhängen'; $lang['de_DE']['FileIframeField']['NOTEADDFILES'] = 'Sie können Dateien hinzufügen sobald Sie das erste mal gespeichert haben'; # Javascript Usage *Requires SilverStripe 2.3* i18n in javascript works with mostly the same assumption as its PHP-equivalent. ## Requirements Add the i18n library requirement to your code. :::php Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js"); Each language has its own language table in a separate file. To save bandwidth, only two tables are actually loaded by the browser: The current locale, and the default locale as a fallback. The Requirements class has a special method to determine these includes: Just point it to a directory instead of a file, and the class will figure out the includes. :::php Requirements::add_i18n_javascript('<my-module-dir>/javascript/lang'); ## Translation Tables in JavaScript Translation tables are automatically included as required, depending on the configured locale in *i18n::get_locale()*. As a fallback for partially translated tables we always include the master table (en_US.js) as well. Master Table (mymodule/javascript/lang/en_US.js) :::javascript if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { console.error('Class ss.i18n not defined'); } else { ss.i18n.addDictionary('en_US', { 'MYMODULE.MYENTITY' : "Really delete these articles?" }); } Example Translation Table (mymodule/javascript/lang/de_DE.js) :::javascript ss.i18n.addDictionary('de_DE', { 'MYMODULE.MYENTITY' : "Artikel wirklich löschen?" }); ## Basic Usage :::javascript alert(ss.i18n._t('MYMODULE.MYENTITY')); ## Advanced Usage with sprintf() :::javascript // MYMODULE.MYENTITY contains "Really delete %s articles by %s authors?" alert(ss.i18n.sprintf( ss.i18n._t('MYMODULE.MYENTITY'), 42, 'Douglas Adams' )); // Displays: "Really delete 42 articles by Douglas Adams?" # Limitations * No detectin/conversion of character encodings (we rely fully on UTF-8) * Translation of graphics/assets * Usage of gettext (too clumsy, too many requirements) * Displaying multipe languages/encodings on the same page ## Links * [http://www.i18nguy.com/](http://www.i18nguy.com/)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/data-types.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/data-types.md
1,693
1,758,118,090
en
# Introduction These are the data-types that you can use when defining your data objects. They are all subclasses of `[api:DBField]` for introducing their usage. # Types * `[api:Varchar]`: A variable-length string of up to 255 characters, designed to store raw text * `[api:Text]`: A variable-length string of up to 2 megabytes, designed to store raw text * `[api:HTMLVarchar]`: A variable-length string of up to 255 characters, designed to store HTML * `[api:HTMLText]`: A variable-length string of up to 2 megabytes, designed to store HTML * `[api:Enum]`: An enumeration of a set of strings. * `[api:Boolean]` field. * `[api:Int]`: An integer field. * `[api:Decimal]`: A decimal number. * `[api:Currency]`: A number with 2 decimal points of precision, designed to store currency values. * `[api:Percentage]`: A decimal number between 0 and 1 that represents a percentage. * `[api:Date]`: A date field * `[api:SS_Datetime]`: A date / time field * `[api:Time]`: A time field #### HTMLText vs. Text, and HTMLVarchar vs. Varchar The database field types HTMLVarchar and Varchar are exactly the same in the database. However, the templating engine knows to escape the Varchar field and not the HTMLVarchar field. So, it's important you use the right field if you don't want to be putting $FieldType.XML everywhere. If you're going to put HTML content into the field, please use the field type with the HTML prefix. Otherwise, you're going to risk double-escaping your data, forgetting to escape your data, and generally creating a confusing situation. # Usage * See [datamodel](/topics/datamodel) for information about **database schemas** implementing these types
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/access-control.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/access-control.md
2,338
1,758,118,090
en
# How page security works in Silverstripe There is a fairly comprehensive security mechanism in place for Silverstripe. If you want to add premium content to your site you have to figure this stuff out, and it's not entirely obvious. ### Ways to restrict access There are a number of ways to restrict access in Silverstripe. In the security tab in the CMS you can create groups that have access to certain parts. The options can be found here: [http://doc.silverstripe.com/doku.php?id=permissions:codes](http://doc.silverstripe.com/doku.php?id=permissions:codes). Once you have groups, you can set access for each page for a particular groups. This can be: - anyone - any person who is logged in - a specific group It is unclear how this works for data-objects that are not pages. ### The Security Groups in Silverstripe In the security tab you can make groups for security. The way this was intended was as follows (this may be a counter intuitive): - employees 1. marketing - marketing executive Thus, the further up the hierarchy you go the MORE privileges you can get. Similarly, you could have: - members 1. coordinators - admins Where members have some privileges, coordinators slightly more and administrators the most; having each group inheriting privileges from its parent group. ### Permission checking is at class level Silverstripe provides a security mechanism via the *Permission::check* method (see *LeftAndMain.php* for examples on how the admin screens work) (next step -- go from *Permission::checkMember*... #### Nuts and bolts -- figuring it out Here are my notes trying to figure this stuff out. Not really useful unless you're VERY interested in how exactly SS works. #### Loading the admin page: looking at security If you go to [your site]/admin -- how does that work? *Director.php* maps the 'admin' URL request through a *Director* rule to the CMSMain controller (see [cmsmain](cmsmain), with no arguments. *CMSMain.init()* calls its parent which, of all things is called *LeftAndMain*. It's in *LeftAndMain* that the important security checks are made by calling *Permission::check*. //Security::`[api:permissionFailure]`// is the next utility function you can use to redirect to the login form. #### Customizing Access Checks in CMS Classes see `[api:LeftAndMain]`
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/module-development.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/module-development.md
2,430
1,758,118,090
en
## Creating modules Creating a module is a good way to re-use abstract code and templates across multiple projects. SilverStripe already has certain modules included, for example "sapphire" and "cms". These three modules are the core functionality and templating for any initial installation. If you're wanting to add generic functionality that isn't specific to your project, like a forum, an ecommerce package or a blog you can do it like this; 1. Create another directory at the root level (same level as "sapphire" and "cms") 2. You must create an _config.php inside your module directory, else SilverStripe will not include it 3. Inside your module directory, follow our [directory structure guidelines](/topics/directory-structure#module_structure) ## Tips Try and keep your module as generic as possible - for example if you're making a forum module, your members section shouldn't contain fields like 'Games You Play' or 'Your LiveJournal Name' - if people want to add these fields they can sub-class your class, or decorate the fields on to it. If you're using Requirements to include generic support files for your project like CSS or Javascript, and want to override these files to be more specific in your project, the following code is an example of how to do so using the init() function on your module controller classes: :::php class Forum_Controller extends Page_Controller { function init() { if(Director::fileExists(project() . "/css/forum.css")) { Requirements::css(project() . "/css/forum.css"); }else{ Requirements::css("forum/css/forum.css"); } parent::init(); } } This will use your_project/css/forum.css if it exists, otherwise it falls back to using forum/css/forum.css. ## Submitting your module to silverstripe.org/modules If you wish to submit your module to our public directory, you take responsibility for a certain level of code quality, adherence to conventions, writing documentation, and releasing updates. See [contributing](/misc/contributing). ## Reference **How To:** * [Add a link to your module in the main SilverStripe Admin Menu](leftandmain) ** Useful Links:** * [Debugging methods](/topics/debugging) * [URL Variable Tools](/reference/urlvariabletools) - Lists a number of “page options” , “rendering tools” or “special URL variables” that you can use to debug your sapphire applications
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/common-problems.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/common-problems.md
3,620
1,758,118,090
en
# Common Problems From time to time, things will go wrong. Here's a few things to try when you're confused. ## The output shows only "Website Error" This first and foremost means that your environment is set to "live mode" (see [environment-management]), which disallows detailed error messages for security reasons. You'll typically need to get your environment into "dev mode" to see more information. If you can log-in to the CMS as an administrator, append `?isDev=1` to any URL to temporarily set your browsing session into "dev mode". If you can't log-in in the first place because of the error, add this directive to your `mysite/_config.php` (don't forget to remove it afterwards!): :::php Director::set_environment_type('dev'); // temporary debugging statement Note: On "live" environments, the `?isDev=1` solution is preferred, as it means that your other visitors don't see ugly (and potentially security sensitive) PHP errors as well. ## My templates don't update on page refresh Putting ?flush=1 on the end of any SilverStripe URL will clear out all cached content; this is a pretty common solution to a lot of development problems. Here are some specifics situations: * You've created a new SS or PHP file * You've edited a nested template (one inserted with the `<% include %>` tag) * You've published a new copy of your site * You've upgraded your version of SilverStripe ## A SQL query fails with "Column not found" or "Table not found" Whenever you change the model definitions in PHP (e.g. when adding a property to the [$db](api:DataObject::$db) array, creating a new page type), SilverStripe will need to update the database. Visiting `http://`<my-domain>`/dev/build` in your browser runs a script that will check the database schema and update it as necessary. Putting `?flush=1` on the end makes sure that nothing that's linked to the old database structure will be carried over. If things aren't saving, pages aren't loading, or other random things aren't working it's possible that the database hasn't been updated to handle the new code. Here are some specifics situations: * You've created a new page type / other data object type * You've change the type of one of your database fields * You've published a new copy of your site * You've upgraded your version of SilverStripe ## My edited CMS content doesn't show on the website If you've set up your site and it used to be working, but now it's suddenly totally broken, you may have forgotten to publish your draft content. Go to the CMS and use the "publish" button. You can visit `admin/publishall` to publish every page on the site, if that's easier. ## I can see unparsed PHP output in my browser Please make sure all code inside '*.php' files is wrapped in classes. Due to the way `[api:ManifestBuilder]` includes all files with this extension, any **procedural code will be executed on every call**. Most common error here is putting a test.php/phpinfo.php file in the document root. See [datamodel](/topics/datamodel) and [controllers](/topics/controllers) for ways how to structure your code. ## I've got file permission problems during installation The php installer needs to be able write files during installation, which should be restricted again afterwards. It needs to create/have write-access to: * The main installation directory (for creating .htaccess file and assets directory) * The mysite folder (to create _config.php) * After the install, the assets directory is the only directory that needs write access. * Image thumbnails will not show in the CMS if permission is not given
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/datamodel.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/datamodel.md
13,945
1,758,118,090
en
# Introduction Silverstripe uses an [object-relational model](http://en.wikipedia.org/wiki/Object-relational_model) that assumes the following connections: * Each database-table maps to a php-class * Each database-row maps to a php-object * Each database-column maps to a property on a php-object All data tables in Silverstripe are defined as subclasses of `[api:DataObject]`. Inheritance is supported in the data model: seperate tables will be linked together, the data spread across these tables. The mapping and saving/loading logic is handled by sapphire, you don't need to worry about writing SQL most of the time. The advanced object-relational layer in Silverstripe is one of the main reasons for requiring PHP5. Most of its customizations are possible through [PHP5 Object Overloading](http://www.onlamp.com/pub/a/php/2005/06/16/overloading.html) handled in the `[api:Object]`-class. See [database-structure](/reference/database-structure) for in-depth information on the database-schema. ## Generating the database-schema The Silverstripe database-schema is generated automatically by visiting the URL. `http://`<mysite>`/dev/build` Or, for older versions of SilverStripe: `http://`<mysite>`/db/build` Note: You need to be logged in as an administrator to perform this command. ## Querying Data There are static methods available for querying data. They automatically compile the necessary SQL to query the database so they are very helpful. In case you need to fall back to plain-jane SQL, have a look at `[api:SQLQuery]`. :::php $records = DataObject::get($obj, $filter, $sort, $join, $limit); :::php $record = DataObject::get_one($obj, $filter); :::php $record = DataObject::get_by_id($obj, $id); CAUTION: Please make sure to properly escape your SQL-snippets (see [security](/topics/security) and [escape-types](escape-types)). ## Joining Passing a *$join* statement to DataObject::get will filter results further by the JOINs performed against the foreign table. **It will NOT return the additionally joined data.** The returned *$records* will always be a `[api:DataObject]`. When using *$join* statements be sure the string is in the proper format for the respective database engine. In MySQL the use of backticks may be necessary when referring Table Names and potentially Columns. (see [MySQL Identifiers](http://dev.mysql.com/doc/refman/5.0/en/identifiers.html)): :::php // Example from the forums: http://www.silverstripe.org/archive/show/79865#post79865 // Note the use of backticks on table names $links = DataObject::get("SiteTree", "ShowInMenus = 1 AND ParentID = 23", "", "LEFT JOIN `ConsultationPaperHolder` ON `ConsultationPaperHolder`.ID = `SiteTree`.ID", "0, 10"); # Properties ## Definition Data is defined in the static variable $db on each class, in the format: `<property-name>` => "data-type" :::php class Player extends DataObject { static $db = array( "FirstName" => "Varchar", "Surname" => "Varchar", "Description" => "Text", "Status" => "Enum('Active, Injured, Retired')", "Birthday" => "Date" ); } See [data-types](data-types) for all available types. ## Overloading "Getters" and "Setters" are functions that help us save fields to our data objects. By default, the methods getField() and setField() are used to set data object fields. They save to the protected array, $obj->record. We can overload the default behaviour by making a function called "get`<fieldname>`" or "set`<fieldname>`". :::php class Player extends DataObject { static $db = array( "Status" => "Enum('Active, Injured, Retired')" ); // access through $myPlayer->Status function getStatus() { // check if the Player is actually... born already! return (!$this->obj("Birthday")->InPast()) ? "Unborn" : $this->Status; } ## Customizing We can create new "virtual properties" which are not actually listed in *static $db* or stored in the database-row. Here we combined a Player's first- and surname, accessible through $myPlayer->Title. :::php class Player extends DataObject { function getTitle() { return "{$this->FirstName} {$this->Surname}"; } // access through $myPlayer->Title = "John Doe"; // just saves data on the object, please use $myPlayer->write() to save the database-row function setTitle($title) { list($firstName, $surName) = explode(' ', $title); $this->FirstName = $firstName; $this->Surname = $surName; } } CAUTION: It is common practice to make sure that pairs of custom getters/setter deal with the same data, in a consistent format. \\ CAUTION: Custom setters can be hard to debug: Please doublecheck if you could transform your data in more straight-forward logic embedded to your custom controller or form-saving. ## Default Values Define the default values for all the $db fields. This example sets the "Status"-column on Player to "Active" whenever a new object is created. :::php class Player extends DataObject { static $defaults = array( "Status" => 'Active', ); } Note: Alternatively you can set defaults directly in the database-schema (rather than the object-model). See [data-types](data-types) for details. ## Casting Properties defined in *static $db* are automatically casted to their [data-types](data-types) when used in templates. You can also cast the return-values of your custom functions (e.g. your "virtual properties"). Calling those functions directly will still return whatever type your php-code generates, but using the *obj()*-method or accessing through a template will cast the value accordig to the $casting-definition. :::php class Player extends DataObject { static $casting = array( "MembershipFee" => 'Currency', ); // $myPlayer->MembershipFee() returns a float (e.g. 123.45) // $myPlayer->obj('MembershipFee') returns a object of type Currency // In a template: <% control MyPlayer %>MembershipFee.Nice<% end_control %> returns a casted string (e.g. "$123.45") function getMembershipFee() { return $this->Team()->BaseFee * $this->MembershipYears; } } # Relations Relations are built through static array definitions on a class, in the format:\\ `<relationship-name>` => `<classname>`{php} ## has_one A 1-to-1 relation creates a database-column called "`<relationship-name>`ID", in the example below this would be "TeamID" on the "Player"-table. :::php // access with $myPlayer->Team() class Player extends DataObject { static $has_one = array( "Team" => "Team", ); } Silverstripe's `[api:SiteTree]` base-class for content-pages uses a 1-to-1 relationship to link to its parent element in the tree: :::php // access with $mySiteTree->Parent() class SiteTree extends DataObject { static $has_one = array( "Parent" => "SiteTree", ); } ## has_many Defines 1-to-many joins. A database-column named ""`<relationship-name>`ID"" will to be created in the child-class. **CAUTION:** Please specify a $has_one-relationship on the related child-class as well, in order to have the necessary accessors available on both ends. :::php // access with $myTeam->Players() or $player->Team() class Team extends DataObject { static $has_many = array( "Players" => "Player", ); } class Player extends DataObject { static $has_one = array( "Team" => "Team", ); } To specify multiple has_manys to the same object you can use dot notation to distinguish them like below :::php class Person { static $has_many = array( "Managing" => "Company.Manager", "Cleaning" => "Company.Cleaner", ); } class Company { static $has_one = array( "Manager" => "Person", "Cleaner" => "Person" ); } Multiple $has_one relationships are okay if they aren't linking to the same object type. :::php /** * THIS IS BAD */ class Team extends DataObject { static $has_many = array( "Players" => "Player", ); } class Player extends DataObject { static $has_one = array( "Team" => "Team", "AnotherTeam" => "Team", ); } ## many_many Defines many-to-many joins. A new table, (this-class)_(relationship-name), will be created with a pair of ID fields. CAUTION: Please specify a $belongs_many_many-relationship on the related class as well, in order to have the necessary accessors available on both ends. :::php // access with $myTeam->Categories() or $myCategory->Teams() class Team extends DataObject { static $many_many = array( "Categories" => "Category", ); } class Category extends DataObject { static $belongs_many_many = array( "Teams" => "Team", ); } See [recipes:many_many-example](http://doc.silverstripe.org/recipes/many_many-example) for a more in-depth example ## Adding relations Inside sapphire it doesn't matter if you're editing a *has_many*- or a *many_many*-relationship. You need to get a `[api:ComponentSet]`. :::php class Team extends DataObject { // see "many_many"-description for a sample definition of class "Category" static $many_many = array( "Categories" => "Category", ); /** * @param DataObjectSet */ function addCategories($additionalCategories) { $existingCategories = $this->Categories(); // method 1: Add many by iteration foreach($additionalCategories as $category) { $existingCategories->add($category); } // method 2: Add many by ID-List $existingCategories->addMany(array(1,2,45,745)); } } ## Custom Relation Getters You can use the flexible datamodel to get a filtered result-list without writing any SQL. For example, this snippet gets you the "Players"-relation on a team, but only containing active players. (See `[api:DataObject::$has_many]` for more info on the described relations). :::php class Team extends DataObject { static $has_many = array( "Players" => "Player" ); // can be accessed by $myTeam->ActivePlayers function getActivePlayers() { return $this->Players("Status='Active'"); } } # Data Handling When saving data through the object model, you don't have to manually escape strings to create SQL-safe commands. You have to make sure though that certain properties are not overwritten, e.g. *ID* or *ClassName*. ## Creation :::php $myPlayer = new Player(); $myPlayer->Firstname = "John"; // sets property on object $myPlayer->write(); // writes row to database ## Update :::php $myPlayer = DataObject::get_by_id('Player',99); if($myPlayer) { $myPlayer->Firstname = "John"; // sets property on object $myPlayer->write(); // writes row to database } ## Batch Update :::php $myPlayer->update( ArrayLib::filter_keys( $_REQUEST, array('Birthday', 'Firstname') ) ); Alternatively you can use *castedUpdate()* to respect the [data-types](/topics/data-types). This is preferred to manually casting data before saving. :::php $myPlayer->castedUpdate( ArrayLib::filter_keys( $_REQUEST, array('Birthday', 'Firstname') ) ); ## onBeforeWrite You can customize saving-behaviour for each DataObject, e.g. for adding security. These functions are private, obviously it wouldn't make sense to call them externally on the object. They are triggered when calling *write()*. Example: Disallow creation of new players if the currently logged-in player is not a team-manager. :::php class Player extends DataObject { static $has_many = array( "Teams"=>"Team" ); function onBeforeWrite() { // check on first write action, aka "database row creation" (ID-property is not set) if(!$this->ID) { $currentPlayer = Member::currentUser(); if(!$currentPlayer->IsTeamManager()) { user_error('Player-creation not allowed', E_USER_ERROR); exit(); } } // check on every write action if(!$this->record['TeamID']) { user_error('Cannot save player without a valid team-connection', E_USER_ERROR); exit(); } // CAUTION: You are required to call the parent-function, otherwise sapphire will not execute the request. parent::onBeforeWrite(); } } Note: There are no separate methods for *onBeforeCreate* and *onBeforeUpdate*. Please check for the existence of $this->ID to toggle these two modes, as shown in the example above. ## onBeforeDelete Triggered before executing *delete()* on an existing object. Example: Checking for a specific [permission](/reference/permission) to delete this type of object. It checks if a member is logged in who belongs to a group containing the permission "PLAYER_DELETE". :::php class Player extends DataObject { static $has_many = array( "Teams"=>"Team" ); function onBeforeDelete() { if(!Permission::check('PLAYER_DELETE')) { Security::permissionFailure($this); exit(); } parent::onBeforeDelete(); } } ## Saving data with forms See [forms](/topics/forms). ## Saving data with custom SQL See `[api:SQLQuery]` for custom *INSERT*, *UPDATE*, *DELETE* queries. # Decorating DataObjects You can add properties and methods to existing DataObjects like `[api:Member]` (a core class) without hacking core code or subclassing. Please see `[api:DataObjectDecorator]` for a general description, and `[api:Hierarchy]` for our most popular examples. # FAQ ##### Whats the difference between DataObject::get() and a relation-getter? You can work with both in pretty much the same way, but relationship-getters return a special type of collection: A `[api:ComponentSet]` with relation-specific functionality. :::php $myTeam = DataObject::get_by_id('Team',$myPlayer->TeamID); // returns DataObjectSet $myTeam->add(new Player()); // fails $myTeam = $myPlayer->Team(); // returns Componentset $myTeam->add(new Player()); // works
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/email.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/email.md
3,940
1,758,118,090
en
# Introduction SilverStripe has emailing functionality using the built-in mail() function in PHP. Features include sending plaintext- and HTML emails, sending bulk emails, subscription, handling bounced back emails. # Configuration Your PHP configuration needs to include the SMTP module for sending emails. If you are not running an SMTP server together with your webserver, you might need to setup PHP with the credentials for an external SMTP server (see [PHP documentation for mail()](http://php.net/mail)). # Usage ## Sending combined HTML and Plaintext By default, emails are sent in both HTML and Plaintext format. A plaintext representation is automatically generated from the system by stripping HTML markup, or transformining it where possible (e.g. `<strong>text</strong>` is converted to `*text*`). :::php $email = new Email($from, $to, $subject, $body); $email->send(); The default HTML template is located in ''sapphire/templates/email/GenericEmail.ss''. ## Sending Plaintext only :::php $email = new Email($from, $to, $subject, $body); $email->sendPlain(); ## Templates **Requirements: SilverStripe 2.3+** * Create a SS-template file called, in this example we will use 'MyEmail.ss' inside mysite/templates/email. * Fill this out with the body text for your email. You can use any [SS-template syntax](/topics/templates) (e.g. `<% control %>`, `<% if %>`, $FirstName etc) * Choose your template with **setTemplate()** * Populate any custom data into the template before sending with **populateTemplate()** :::php $email = new Email($from, $to, $subject, $body); $email->setTemplate('MyEmail'); // You can call this multiple times or bundle everything into an array, including DataSetObjects $email->populateTemplate(Member::currentUser()); $welcomeMsg = 'Thank you for joining on '.date('Y-m-d'.'!'; $email->populateTemplate( array( 'WelcomeMessage' => $welcomeMsg, // Accessible in template via $WelcomeMessage ) ); $email->send(); ## Subclassing Class definition: :::php <?php class MyEmail extends Email{ protected $to = '$Email', // Be sure to encase this in single-quotes, as it is evaluated later by the template parser $from = '[email protected]', $ss_template = 'MyEmail'; } ?> Usage: :::php <?php $email = new MyEmail(); $email->populateTemplate(Member::currentUser()); // This will populate the template, $to, $from etc variables if they exist $email->send(); // Will immediately send an HTML email with appropriate plain-text content ?> ## Administrator Emails The static function ''Email::setAdminEmail()'' can be called from a _config.php file to set the address that these emails should originate from. This address is used if the ''from'' field is empty. ## Redirecting Emails * Email::send_all_emails_to($address) will redirect all emails sent to the given address. Handy for testing! * Email::cc_all_emails_to() and Email::bcc_all_emails_to() will keep the email going to its original recipients, but add an additional receipient in the BCC/CC header. Good for monitoring system-generated correspondence on the live systems. :::php if(Director::isLive()) Email::bcc_all_emails_to("[email protected]"); else Email::send_all_emails_to("[email protected]"); ## Setting Custom Headers For email headers which do not have getters or setters (like setTo(), setFrom()) you can use **addCustomHeader($header, $value)** :::php $email = new Email(...); $email->addCustomHeader('HeaderName', 'HeaderValue'); .. See http://en.wikipedia.org/wiki/E-mail#Message_header for a list of header names. ## Bounced Emails [email_bouncehandler](email_bouncehandler) ## Newsletters The [newsletter module](http://silverstripe.org/newsletter-module) provides a UI and logic to send batch emails. # API Documentation [ Click here for API documentation](http://api.silverstripe.org/trunk/sapphire/Email.html)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/translation.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/translation.md
14,340
1,758,118,090
en
# Introduction This page introduces developers to using the CMS for creating content in multiple languages. Please see [i18n](/topics/i18n) for a internationalization, globalization and localization support of built-in datatypes as well as translating templates and PHP code. Translations can be enabled for all subclasses of `[api:DataObject]`, so it can easily be implemented into existing code with minimal interference. Warning: If you're upgrading from a SilverStripe version prior to 2.3.2, please migrate your datamodel before using the extension (see below). # Requirements *SilverStripe 2.3.2* # Screenshots ![](_images/translatable4_small.png) *Translated website* ![](_images/translatable1.png) *CMS: Language dropdown* ![](_images/translatable2.png) *CMS: Translatable field with original value* ![](_images/translatable3.png) *CMS: Create a new translation* # Usage ## Configuration ### ThroughObject::add_extension() Enabling Translatable through *Object::add_extension()* in your *mysite/_config.php*: :::php Object::add_extension('SiteTree', 'Translatable'); Object::add_extension('SiteConfig', 'Translatable'); // 2.4 or newer only ### Through$extensions :::php class Page extends SiteTree { static $extensions = array( "Translatable" ); } Make sure to rebuild the database through /dev/build after enabling translatable. Use the correct set_default_locale() before building the database for the first time, as this locale will be written on all new records. ### Setting the defaultlocale Important: If the "default language" of your site is not english (en_US), please ensure to set the appropriate default language for your content before building the database with Translatable enabled: :::php Translatable::set_default_locale(<locale>); // Important: Call add_extension() after setting the default locale Object::add_extension('SiteTree', 'Translatable'); For the Translatable class, a "locale" consists of a language code plus a region code separated by an underscore, for example "de_AT" for German language ("de") in the region Austria ("AT"). See http://www.w3.org/International/articles/language-tags/ for a detailed description. # Usage Getting a translation for an existing instance: :::php $translatedObj = Translatable::get_one_by_locale('MyObject', 'de_DE'); Getting a translation for an existing instance: :::php $obj = DataObject::get_by_id('MyObject', 99); // original language $translatedObj = $obj->getTranslation('de_DE'); Getting translations through Translatable::set_reading_locale(). This is *not* a recommended approach, but sometimes inavoidable (e.g. for Versioned methods). :::php $origLocale = Translatable::get_reading_locale(); Translatable::set_reading_locale('de_DE'); $obj = Versioned::get_one_by_stage('MyObject', "ID = 99"); Translatable::set_reading_locale($origLocale); Creating a translation: :::php $obj = new MyObject(); $translatedObj = $obj->createTranslation('de_DE'); ## Usage for SiteTree Translatable can be used for subclasses of SiteTree as well. If a child page translation is requested without the parent page already having a translation in this language, the extension will recursively create translations up the tree. Caution: The "URLSegment" property is enforced to be unique across languages by auto-appending the language code at the end. You'll need to ensure that the appropriate "reading language" is set before showing links to other pages on a website through $_GET['locale']. Pages in different languages can have different publication states through the Versioned extension. Note: You can't get Children() for a parent page in a different language through set_reading_locale(). Get the translated parent first. :::php // wrong Translatable::set_reading_lang('de_DE'); $englishParent->Children(); // right $germanParent = $englishParent->getTranslation('de_DE'); $germanParent->Children(); ## Translating custom properties Keep in mind that the Translatable extension currently doesn't support the exclusion of properties from being translated - all custom properties will automatically be fetched from their translated record on the database. This means you don't have to explicitly mark any custom properties as being translatable. The Translatable decorator applies only to the getCMSFields() method on DataObject or SiteTree, not to any fields added in overloaded getCMSFields() implementations. See Translatable->updateCMSFields() for details. By default, custom fields in the CMS won't show an original readonly value on a translated record, although they will save correctly. You can attach this behaviour to custom fields by using Translatable_Transformation as shown below. :::php class Page extends SiteTree { public static $db = array( 'AdditionalProperty' => 'Text', ); function getCMSFields() { $fields = parent::getCMSFields(); // Add fields as usual $additionalField = new TextField('AdditionalProperty'); $fields->addFieldToTab('Root.Content.Main', $additionalField); // If a translation exists, exchange them with // original/translation field pairs $translation = $this->getTranslation(Translatable::default_locale()); if($translation) { $transformation = new Translatable_Transformation($translation); $fields->replaceByName( 'AdditionalProperty', $transformation->transformFormField($additionalField) ); } return $fields; } } ## Translating theHomepage Every homepage has a distinct URL, the default language is /home, a German translation by default would be /home-de_DE. They can be accessed like any other translated page. If you want to access different homepages from the "root" without a URL, add a "locale" GET parameter. The German homepage would also be accessible through /?locale=de_DE. For this to work, please ensure that the translated homepage is a direct translation of the default homepage, and not a new page created through "Create page...". ## Translationgroups Each translation can have an associated "master" object in another language which it is based on, as defined by the "MasterTranslationID" property. This relation is optional, meaning you can create translations which have no representation in the "default language". This "original" doesn't have to be in a default language, meaning a french translation can have a german original, without either of them having a representation in the default english language tree. Caution: There is no versioning for translation groups, meaning associating an object with a group will affect both stage and live records. SiteTree database table (abbreviated) | ID | URLSegment | Title | Locale | | -- | ---------- | ----- | ------ | | 1 | about-us | About us | en_US | | 2 | ueber-uns | Über uns | de_DE | | 3 | contact | Contact | en_US | SiteTree_translationgroups database table | TranslationGroupID | OriginalID | | ------------------ | ---------- | | 99 | 1 | | 99 | 2 | | 199 | 3 | ## CharacterSets Caution: Does not apply any character-set conversion, it is assumed that all content is stored and represented in UTF-8 (Unicode). Please make sure your database and HTML-templates adjust to this. ## "Default"languages Important: If the "default language" of your site is not english (en_US), please ensure to set the appropriate default language for your content before building the database with Translatable enabled: :::php Translatable::set_default_locale(<locale>); ## Locales and languagetags For the Translatable class, a "locale" consists of a language code plus a region code separated by an underscore, for example "de_AT" for German language ("de") in the region Austria ("AT"). See http://www.w3.org/International/articles/language-tags/ for a detailed description. Uninstalling/Disabling Disabling Translatable after creating translations will lead to all pages being shown in the default sitetree regardless of their language. It is advised to start with a new database after uninstalling Translatable, or manually filter out translated objects through their "Locale" property in the database. # Recipes ## Switching languages A widget now exists to switch between languages, and is [available here](http://www.silverstripe.org/Language-Chooser-Widget/). You can easily make your own switchers with the following basic tools. To stay friendly to caches and search engines, each translation of a page must have a unique URL ### By URL :::php http://<mysite>/mypage/?locale=de_DE ### By User Preference Place this in your Page_Controller->init() method: :::php $member = Member::currentUser(); if($member && $member->Locale) { Translatable::set_reading_locale($member->Locale); } ### Templates As every page has its own unique URL, language selection mostly happens explicitly: A user requests a page, which always has only one language. But how does a user coming to your English default language know that there's a Japanese version of this page? By default, SilverStripe core doesn't provide any switching of languages through sessions or browser cookies. As a SEO-friendly CMS, it contains all this information in the URL. Each page in SilverStripe is aware of its translations through the *getTranslations()* method. We can use this method in our template to build a simple language switcher. It shows all available translations in an unordered list with links to the same page in a different language. The example below can be inserted in any of your templates, for example *themes/blackcandy/templates/Layout/Page.ss*. :::php <% if Translations %> <ul class="translations"> <% control Translations %> <li class="$Locale.RFC1766"> <a href="$Link" hreflang="$Locale.RFC1766" title="$Title"> <% sprintf(_t('SHOWINPAGE','Show page in %s'),$Locale.Nice) %> </a> </li> <% end_control %> </ul> <% end_if %> Keep in mind that this will only show you available translations for the current page. The $Locale.Nice casting will just work if your locale value is registered in i18n::get_common_locales(). #### Page-control If you want to put static links in your template, which link to a site by their url, normally you can use the <% control Page(page-url) %>. For sites which use Translatable, this is not possible for more than one language, because the url's of different pages differ. For this case place the following function in your Page_Controller: :::php public function PageByLang($url, $lang) { $SQL_url = Convert::raw2sql($url); $SQL_lang = Convert::raw2sql($lang); $page = Translatable::get_one_by_lang('SiteTree', $SQL_lang, "URLSegment = '$SQL_url'"); if ($page->Locale != Translatable::get_current_locale()) { $page = $page->getTranslation(Translatable::get_current_locale()); } return $page; } So, for example if you have a german page "Kontakt", which should be translated to english as "Contact", you may use: <% control PageByLang(Kontakt,de_DE) %> The control displays the link in the right language, depending on the current locale.\\ Example: <% control PageByLang(Kontakt,de_DE) %> <h2><a href="$Link" title="$Title">$Title</a></h2> <% end_control %> ### Language Chooser Widget You can use a widget on your website to provide a list of links for switching languages: [download](http://silverstripe.org/Language-Chooser-Widget-2/) ### Enabling the _t() function in templates If you're looking to use [the _t() function](http://doc.silverstripe.com/doku.php?id=i18n#the_t_function) in template files, you'll need to [set the i18n locale](multilingualcontent#setting_the_i18n_locale) first. (The reasoning is as follows: Translatable doesn't set the i18n locale. Historically these were two separate systems, but they're reasonably interchangeable for a front-end website. The distinction is mainly valid for the CMS, because you want the CMS to be in English (i18n), but edit pages in different languages (Translatable).) ## Migrating from 2.1 datamodel The datamodel of Translatable changed significantly between its original release in SilverStripe 2.1 and SilverStripe 2.3.2. See our [discussion on the mailinglist](http://groups.google.com/group/silverstripe-dev/browse_thread/thread/91e26e1f78d3c1b4/bd276dd5bbc56283?lnk=gst&q=translatable#bd276dd5bbc56283). To migrate a database that was built with SilverStripe 2.1.x or 2.2.x, follow these steps: * Upgrade your SilverStripe installation to at least 2.3.2 (see [upgrading](upgrading)) * Backup your database content * Login as an administrator * Run http://mysite.com/dev/build * Run http://mysite.com/dev/tasks/MigrateTranslatableTask Please see the [class documentation](http://api.silverstripe.org/trunk/sapphire/dev/MigrateTranslatableTask.html) for limitations of this migration task - not all your data will be preserved. ## Setting the i18n locale You can set the i18n locale value which is used to format dates, currencies and other regionally different values to the same as your current page locale. :::php class Page_Controller extends ContentController { public function init() { parent::init(); if($this->dataRecord->hasExtension('Translatable')) { i18n::set_locale($this->dataRecord->Locale); } } } ## Add new locales The i18n logic has lookup tables for common locales in i18n::$common_locales, which is a subset of i18n::$all_locales. If your locale is not present here, you can simply add it through mysite/_config.php: :::php i18n::$common_locales['de_AT'] = 'Deutsch (Oestereich)'; This should e.g. enable you to use ''$Locale.Nice'' in template code. # Related * [translate.silverstripe.org](http://translate.silverstripe.org): Starting point for community-driven translation of the Silverstripe UI * [i18n](i18n): Developer-level documentation of Silverstripe's i18n capabilities * `[api:Translatable]`: DataObject-interface powering the website-content translations * ["Translatable ModelAdmin" module](http://silverstripe.org/translatablemodeladmin-module/): An extension which allows translations of DataObjects inside `[api:ModelAdmin]`
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/theme-development.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/theme-development.md
10,555
1,758,118,090
en
# Developing Themes [Tutorial 1](tutorial/1-building-a-basic-site#templates) shows you how to create page templates. This guide will help you create your own SilverStripe website theme. Developing your own theme in SilverStripe is a piece of cake thanks to a very straight forward and clean templating language. ## What is a Theme? A theme is a set of HTML/CSS/Javascript and images that can be used to provide a skin for a site. A theme does not include any PHP: instead it should be separate from the code which allows the portability of a design. After all, this is an MVC framework! ## Getting started - Folder Structure To start your theme you first need to create the basic folder structure for the theme. Check out the image below for the layout of your folders. First you need to create a folder in the themes directory called the name of your theme (we're using "blackcandy"). Please note that underscores in the theme name are reserved to denote "sub-themes" (e.g. "blackcandy_blog"). ![themes:basicfilestructure.gif](_images/basicfilestructure.gif) Inside your theme, you need the css, images and templates folders. Each of these folders contain parts of your theme and keeping a good folder structure is super important. Now we have this structure we can put our CSS in the css folder, Images in the images folder and all our HTML in the templates folder. This keeps our workspace clean and easy to use. After you have created the templates folder you need to create 2 more folders within - Includes and Layout (Note the uppercase initial letters). These are 2 different types of templates you will use in your theme - Includes contain snippets of HTML that you want to break out and share between templates (for example the Header can be an include, Footer, Navigation etc) whereas Layout templates are the base page templates. So you can have several includes in a Layout template. ## Getting started - Core Files ### HTML Templates Once you have created your folders you need to start to fill it out with a couple 'Core' files. First and most importantly is we need a HTML template for our design. Read the [Tutorial 1](/tutorials/1-building-a-basic-site#templates) and the HTML pages for more in-depth discussion about the HTML templates and how they work. At the very least we need a Page.ss file (note the .ss extenstion - Don't worry its just HTML and any text editor will still read it). So go ahead and create 2 Page.ss files. One in templates, the other in Layout. ![themes:basicfiles.gif](_images/basicfiles.gif) Whats with the 2 Page.ss files? Well we have 2 so when the user visits a page they get redirected to the top level Page.ss then, depending on what page they are on, we can have a custom template for that page in the Layout folder. If you dont get it now, you will hopefully pick it up over the rest of this. So you have 2 blank Page.ss files. What are we going to do with them? How bout we put some HTML in them so we can see our theme in action. The code for mine is below. ** yourtheme/templates/Page.ss ** :::html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <% base_tag %> $MetaTags(false) <title>Bob's Chicken Shack | $Title</title> </head> <body> <div id="Container"> <div id="Header"> <h1>Bob's Chicken Shack</h1> </div> <div id="Navigation"> <% if Menu(1) %> <ul> <% control Menu(1) %> <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> <% end_control %> </ul> <% end_if %> </div> <div id="Layout"> $Layout </div> <div id="Footer"> <p>Copyright $Now.Year - Bob's Chicken Shack.</p> </div> </div> </body> </html> ** yourtheme/templates/Layout/Page.ss ** :::html <h1>$Title</h1> $Content $Form $PageComments All you have to do now is tell your site to use your new theme - This is defined in the **mysite/_config.php** file :::php SSViewer::set_theme('mythemename'); Go to yoursite.com/?flush=1 and check it out. You should be using your new theme! Not really that awesome or amazing is it? Next we need to add some CSS Magics! ### CSS Files By standard SilverStripe uses 3 CSS Files for your site - * **layout.css** contains the layout and design of the site * **typography.css** contains the styling for the text/fonts/links (used in both front and back ends) * **form.css** styling for forms. You can add more stylesheets using the template tag `<% require themedCSS(filename) %>`, which will load filename.css from your css directory. Note: If you're using a default install of Silverstripe and notice that you're getting layout.css, typography.css and forms.css included without asking for them, they may be being called on lines 21-23 in mysite/code/Page.php. Remove these three Requirements::themedCSS lines, and you will be free to add your own styles. ## Dividing your site the correct way! Most Web page designers 10 years ago used a table-based layout to achieve a consistent look. Now, (Thankfully) there's a different way to achieve the same look. Using CSS and tags (including ''DIV''s) reduces markup code, speeds up page downloads, separates content from it's visual presentation, and brings your code closer to web standards compliance--all while making your website more appealing to search engine spiders. For layout we tend to use ''DIV'' tags as the ''DIV'' tag defines a division/section in a document. Let's have a look at part of a Page.ss for the main layout elements defining a 2 column layout. :::html <div id="Container"> <div id="Header"> <!-- Header --> </div> <div id="Navigation"> <!-- The Main Site Nav --> </div> <div id="Layout"> <!-- The whole site content Has to sit inside here! Anything you want to sub template (eg each page will be different, needs to be contained in $Layout. This calls the file /Layout/Page.ss or anyother sub page template --> $Layout </div> <div id="Footer"> </div> </div> ### HTML naming conventions * Class names should be lowercase, or lowerCamelCase starting with a lowercase letter, for example, latestNews * IDs should be UpperCamelCase and remember ID's can only be used once per page. Example: :::html <div id="Container"><!-- markup goes here --></div> As you can see we normally wrap the site in a container. For this we use the ID 'Container'. Then we divide the main template into sections. :::html <div id="Header"><!-- markup goes here --></div> We have the Header section which includes things like any banner images/ mastheads/ logos or any stuff that belongs at the top of the page, This might vary on the design of the page :::html <div id="Navigation"><!-- markup goes here --></div> Next is a division for the main navigation. This may contain something like: :::html <div id="Navigation"> <% if Menu(1) %> <ul> <% control Menu(1) %> <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> <% end_control %> </ul> <% end_if %> </div> This is the standard for creating the main Navigation. As you can see it outputs the Menu 1 in a unordered list. Before stepping into a control (a foreach loop) it's good practise to check if it exists first. This is not only important in manipulating SilverStripe templates, but in any programming language! :::html <% if MyFunction %> <% control MyFunction %> $Title <% end_control %> <% end_if %> Last and probably least is the Footer division. Here is where you put all the Footer related stuff for your website. Maybe even a nice link saying Website Powered by SilverStripe to show your support. :::html <div id="Footer"> <!-- markup goes here --> </div> # Resources A bunch of resources feel free to use to make your template awesome * http://kuler.adobe.com - Kuler is a great color scheming tool * http://blog.html.it/layoutgala/ - 40 super cool CSS layouts for you to use * http://designmeltdown.com - Great gallery of websites. Browse through and get inspired. * http://validator.w3.org/ - Your template must pass 'or get near' validation. * http://famfamfam.com/lab/icons/ - free, beautiful icons. * http://cssremix.com - Another CSS site gallery for inspiration. * http://www.maxdesign.com.au/presentation/process/ - a good process for creating a design # Reference #### Overriding The templating system will search for the appropriate files in the following order: 1. mysite (or other name given to site folder) 2. themes 3. module (eg blog) So if, for example, you had a typography.css file for a module in the module folder (eg blog/css/), in the theme module directory (eg themes/blackcandy_blog/css/), and in your site folder (eg mysite/css/), the system would use the file mysite/css/typography.css ##### What gets overridden? * CSS * Templates PHP files **do not** get overridden! ### Requirements The [Requirements::themedCSS('cssfile')](http://api.silverstripe.com/default/Requirements.html#themedCSS) function will do the search specified above. This avoids the need to type a full path to the css file, and also provides better ambiguity for themes. ### Subthemes If you have a theme called mytheme_forum, it is considered to be a 'subtheme' of the mytheme theme. This lets module developers release extensions to popular themes that will let their module work with that theme. A subtheme overrides the files in the module. So for instance, if you have the forum setup instead of editing the files within the forum/ module you would create a themes/yourtheme_forum/ folder. ### ThemeDir If you want to refer to an image or other file asset in a .ss template, use $ThemeDir. For example: :::html <img src="$ThemeDir/images/log.gif" /> If your image is in a subtheme, you can refer to that with an argument to ThemeDir. For example, if your image was in mytheme_forum, you could use the following code: :::html <img src="$ThemeDir(forum)/images/log.gif" /> # Conventions, standards and guidelines Following some set standards and conventions makes life easy for you and I. Some conventions for SilverStripe websites, which we suggest following. Take a look at each: * [Coding-Conventions](/misc/coding-conventions) * [:Typography](/reference/typography) We also suggest following various [industry standards](http://www.w3.org/) and conventions.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/templates.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/templates.md
4,959
1,758,118,090
en
# Templates ## Syntax TODO Show a good cross section of built-in-page-controls.md ### Example Template :::html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <% base_tag %> $MetaTags(false) <title>Bob's Chicken Shack | $Title</title> </head> <body> <div id="Container"> <div id="Header"> <h1>Bob's Chicken Shack</h1> </div> <div id="Navigation"> <% if Menu(1) %> <ul> <% control Menu(1) %> <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> <% end_control %> </ul> <% end_if %> </div> <div id="Layout"> $Layout </div> <div id="Footer"> <p>Copyright $Now.Year - Bob's Chicken Shack.</p> </div> </div> </body> </html> ## Structure and Inheritance TODO Take abbreviated descriptions from the first tutorial ## Includes Within SilverStripe templates we have the ability to include other templates from the Includes directory using the SS 'include' tag. For example, the following code would include the `Incldues/SideBar.ss` code: :::html <% include SideBar %> The includes tag can be particularly helpful for nested functionality. Say only include if a variable is true :::html <% if CurrentMember %> <% include MembersOnlyInclude %> <% end_if %> ## Bundling templates into Themes TODO ## CSS and JavaScript files TODO Using `<% require %>` vs Requirements class in Controller::init(), combine_files, different media types, typography.css ## Base Tag The `<% base_tag %>` placeholder is replaced with the HTML base element. Relative links within a document (such as `<img src="someimage.jpg" />`) will become relative to the URI specified in the base tag. This ensures the browser knows where to locate your site’s images and css files. So it is a must for templates! It renders in the template as `<base href="http://www.mydomain.com" />` ## Meta Tags The `$MetaTags` placeholder in a template returns a segment of HTML appropriate for putting into the `<head>` tag. It will set up title, keywords and description meta-tags, based on the CMS content and is editable in the 'Meta-data' tab on a per-page basis. If you don’t want to include the title-tag `<title>` (for custom templating), use `$MetaTags(false)`. By default `$MetaTags` renders: :::html <title>Title of the Page</title> <meta name="generator" http-equiv="generator" content="SilverStripe 2.0" > <meta http-equiv="Content-type" content="text/html; charset=utf-8" > TODO Explain SiteTree properties and SiteTree->MetaTags() overloading ## Casting and Escaping Method and variables names that deal with strings or arrays of strings should have one of the following 5 prefixes: * **RAW_** Raw plain text, as a user would like to see it, without any HTML tags * **XML_** Text suitable for insertion into an HTML or XML data-set. This may contain HTML content, for example if the content came from a WYSIWYG editor. * **JS_** Data that can safely be inserted into JavaScript code. * **ATT_** Data that can safely be inserted into an XML or HTML attribute. The same prefixes are used for both strings and arrays of strings. We did this to keep things simple: passing a string with the wrong encoding is a far subtler a problem than passing an array instead of a string, and therefore much harder to debug. ## Designing reuseable templates Although SilverStripe is ultimately flexible in how you create your templates, there's a couple of best practices. These will help you to design templates for modules, and make it easier for other site developers to integrate them into their own base templates. * Most of your templates should be Layout templates * Build your templates as a [[theme]] so you can easily re-use and exchange them * Your layout template should include a standard markup structure (`<div id="Layout">`$Layout`</div>`) * Layout templates only include content that could be completely replaced by another module (e.g. a forum thread). It might be infeasible to do this 100%, but remember that every piece of navigation that needs to appear inside `$Layout` will mean that you have to customise templates when integrating the module. * Any CSS applied to layout templates should be flexible width. This means the surrounding root template can set its width independently. * Don't include any navigation elements in your Layout templates, they should be contained in the root template. * Break down your templates into groups of includes. Site integrators would then have the power to override individual includes, rather than entire templates. ## Related * [themes](/topics/themes) * [widgets](/topics/widgets) * [Tutorial 1: Building a basic site](/tutorials/1-building-a-basic-site) * [Tutorial 2: Extending a basic site](/tutorials/2-extending-a-basic-site)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/widgets.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/widgets.md
11,281
1,758,118,090
en
# Widgets Widgets are small pieces of functionality such as Showing the latest Comments or Flickr Photos. They normally display on the sidebar of your website. To check out a what a Widget can do see the video http://silverstripe.org/widgets and try out the demo site http://silverstripe.com/assets/screencasts/SilverStripe-Blog-DragDrop-Widgets.swf # How to Use A Widget ### Downloading and Contributing Widgets * To download widgets visit [Widgets section](http://silverstripe.org/widgets) * Upload widgets you want to share to [http://silverstripe.org/widgets/manage/add](http://silverstripe.org/widgets/manage/add). Make sure you read the packaging instructions at the bottom of the page about how to make your widget package. ### Installing a widget By following the "Packaging" rules below, widgets are easily installed. * Download the file and unzip to the main folder of your SilverStripe website, e.g. to "/widget_twitter/". The folder will contain a few files, which generally won't need editing or reading. * Run dev/build * Login to the CMS and go to the 'Blog' page. Choose the "widgets" tab and drag n drop the new widget to activate it. * Your blog will now have the widget shown. ### Adding widgets to other pages As of 2.2.1 this is this is a way to add widgets to other pages (by default only the Blog has widgets enabled). In the future releases we will hopefully make widgets part of SiteTree therefore available on every page. In the mean time you have to do a couple things to get a Widget to work on a page. First step is to add an WidgetArea to the Database to store the widget details. Then you have to edit the CMS to add a Widget Form to manage the widgets. An example of this is below ** mysite/code/Page.php ** :::php class Page extends SiteTree { ... static $has_one = array( "Sidebar" => "WidgetArea", ); function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Sidebar")); return $fields; } .... } Then in your Template you need to call $SideBar whereever you want to render the widget Eg for blackcandy I put this above the closing `</div>` ** themes/myThemeName/templates/Includes/Sidebar.ss ** :::html $Sidebar # Writing your own widgets To create a Widget you need at least three files - a php file containing the class, a template file of the same name and a config file called *_config.php* (if you dont need any config options for the widget to work then you can make it blank). Each widget should be in its own folder like widgets_widgetName/ After installing or creating a new widget, **make sure to run db/build?flush=1** at the end of the URL, *before* attempting to use it. The class should extend the Widget class, and must specify three static variables - $title, the title that will appear in the rendered widget (eg Photos), $cmsTitle, a more descriptive title that will appear in the cms editor (eg Flickr Photos), and $description, a short description that will appear in the cms editor (eg This widget shows photos from Flickr). The class may also specify functions to be used in the template like a page type can. If a Widget has configurable options, then it can specify a number of database fields to store these options in via the static $db array, and also specify a getCMSFields function that returns a !FieldSet, much the same way as a page type does. An example widget is below: **FlickrWidget.php** :::php <?php class FlickrWidget extends Widget { static $db = array( "User" => "Varchar", "Photoset" => "Varchar", "Tags" => "Varchar", "NumberToShow" => "Int" ); static $defaults = array( "NumberToShow" => 8 ); static $title = "Photos"; static $cmsTitle = "Flickr Photos"; static $description = "Shows flickr photos."; function Photos() { Requirements::javascript("sapphire/thirdparty/prototype/prototype.js"); Requirements::javascript("sapphire/thirdparty/scriptaculous/effects.js"); Requirements::javascript("mashups/javascript/lightbox.js"); Requirements::css("mashups/css/lightbox.css"); $flickr = new FlickrService(); if($this->Photoset == "") { $photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1); } else { $photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1); } $output = new DataObjectSet(); foreach($photos->PhotoItems as $photo) { $output->push(new ArrayData(array( "Title" => $photo->title, "Link" => "http://farm1.static.flickr.com/" . $photo->image_path .".jpg", "Image" => "http://farm1.static.flickr.com/" .$photo->image_path. "_s.jpg" ))); } return $output; } function getCMSFields() { return new FieldSet( new TextField("User", "User"), new TextField("PhotoSet", "Photo Set"), new TextField("Tags", "Tags"), new NumericField("NumberToShow", "Number to Show") ); } } ?> **FlickrWidget.ss** :::php <% control Photos %> <a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a> <% end_control %> # Extending and Customizing ### Rendering a $Widget Individually To call a single Widget in a page - without adding a widget area in the CMS for you to add / delete the widgets, you can define a merge variable in the Page Controller and include it in the Page Template. This example creates an RSSWidget with the SilverStripe blog feed. :::php <?php function SilverStripeFeed() { $widget = new RSSWidget(); $widget->RssUrl = "http://feeds.feedburner.com/silverstripe-blog"; return $widget->renderWith("WidgetHolder"); } ?> To render the widget, simply include $SilverStripeFeed in your template: :::html $SilverStripeFeed As directed in the definition of SilverStripeFeed(), the Widget will be rendered through the WidgetHolder template. This is pre-defined at /sapphire/templates/WidgetHolder.ss and simply consists of: :::html <div class="WidgetHolder"> <h3>$Title</h3> $Content </div> You can override the WidgetHolder.ss and Widget.ss templates in your theme too by adding WidgetHolder and Widget templates to ** themes/myThemeName/templates/Includes/ ** ### Changing the title of your widget To change the title of your widget, you need to override the Title() method. By default, this simply returns the $title variable. For example, to set your widgets title to 'Hello World!', you could use: ** widgets_yourWidget/YourWidgetWidget.php ** :::php function Title() { return "Hello World!"; } but, you can do exactly the same by setting your $title variable. A more common reason for overriding Title() is to allow the title to be set in the CMS. Say you had a text field in your widget called WidgetTitle, that you wish to use as your title. If nothing is set, then you'll use your default title. This is similar to the RSS Widget in the blog module. :::php function Title() { return $this->WidgetTitle ? $this->WidgetTitle : self::$title; } This returns the value inputted in the CMS, if it's set or what is in the $title variable if it isn't. ### Forms within Widgets *Requires SilverStripe 2.4 or newer* To implement a form inside a widget, you need to implement a custom controller for your widget to return this form. Make sure that your controller follows the usual naming conventions, and it will be automatically picked up by the [:WidgetArea](http://api.silverstripe.org/trunk/sapphire/widgets/WidgetArea.html) rendering in your *Page.ss* template. *mysite/code/MyWidget.php* :::php class MyWidget extends Widget { static $db = array( 'TestValue' => 'Text' ); } class MyWidget_Controller extends Widget_Controller { function MyFormName() { return new Form( $this, 'MyFormName', new FieldSet( new TextField('TestValue') ), new FieldSet( new FormAction('doAction') ) ); } function doAction($data, $form) { // $this->widget points to the widget } } To output this form, modify your widget template. *mysite/templates/MyWidget.ss* :::html $Content $MyFormName Note: The necessary controller actions are only present in subclasses of `[api:Page_Controller]`. To use widget forms in other controller subclasses, have a look at *ContentController->handleWidget()* and *ContentController::$url_handlers*. See an [alternative recipe for SilverStripe 2.3 or earlier](http://doc.silverstripe.org/recipes/widget-forms-2.3). ## But what if I have widgets on my blog currently?? If you currently have a blog installed, the widget fields are going to double up on those pages (as the blog extends the Page class). One way to fix this is to comment out line 30 in BlogHolder.php and remove the DB entry by running a /db/build. ** blog/code/BlogHolder.php ** :::php <?php class BlogHolder extends Page { ........ static $has_one = array( // "SideBar" => "WidgetArea", COMMENT OUT 'Newsletter' => 'NewsletterType' ....... function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeFieldFromTab("Root.Content.Main","Content"); // $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar")); COMMENT OUT ........ Then you can use the Widget area you defined on Page.php # Releasing Your Widget ## Packaging For a widget to be put in our official widget database they must follow this convention - If the name of your widget was "TwitterWidget" then: #### File Structure for your widget You should have a folder called widget_YourName in the top level (the one with sapphire, cms..) with all your files. See the example below. Your widget **MUST** have at least 1 Template file, 1 PHP file, the README File [(Example)](http://open.silverstripe.com/browser/modules/widgets/twitter/trunk/README)and an _config.php file for configuration. If you dont need any config options for the widget to work then you still need an _config.php by you can make it blank The decision over whether to configure a widget in _config.php or in the CMS is important: * If the setting is the kind of thing that a website author, familiar with common business apps such as Word and Outlook, would understand - then make it configurable in the CMS. * If the setting is the kind of thing that the person setting up the website - doing the design and/or development - would understand, then make it configurable in the _config.php file. This way, the CMS remains an application designed for content authors, and not developers. ** widget_name/_config.php ** :::php <?php /* */ ?> ** Example Widget Structure ** ![](_images/widget_demo.gif) #### How to make the Package * Make a tar.gz file called widgets_flickr-0.1.tar.gz (where 0.1 is the version number). * Ensure when you "unzip" the compressed file it has everything the "widgets_flickr" folder with everything inside it. * If made official, it will be given these locations at silverstripe.com: * SVN location: http://svn.silverstripe.com/open/modules/widgets/flickr/trunk * Official download: http://www.silverstripe.com/assets/downloads/widgets/widgets_flickr-0.1.1.tar.gz
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/search.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/search.md
981
1,758,118,090
en
# Search ## Searching for Pages (and Files) Fulltext search for page content (and other attributes like "Title" or "MetaTags") can be easily added to SilverStripe. See [Tutorial: Site Search](/tutorials/4-site-search) for details. ## Searching for DataObjects The [api:SearchContext] class provides a good base implementation that you can hook into your own controllers. A working implementation of searchable DataObjects can be seen in the [api:ModelAdmin] class. ## Searching for Documents SilverStripe does not have a built-in method to search through file content (e.g. in PDF or DOC format). You can either extract any textual file content into the `[File](api:File)->Content` property, or use a dedicated search service like the [sphinx module](http://silverstripe.org/sphinx-module). ## Related * `[api:ModelAdmin]` * `[api:RestfulServer]` * [Tutorial: Site Search](/tutorials/4-site-search) * [genericviews Module](http://silverstripe.org/generic-views-module)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/javascript.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/javascript.md
22,177
1,758,118,090
en
# Using JavaScript with SilverStripe **Important: Parts of this guide apply to the SilverStripe 2.4 release, particularly around the jQuery.entwine library.** This page describes best practices for developing with JavaScript in SilverStripe. This includes work in the CMS interface, form widgets and custom project code. It is geared towards our "library of choice", jQuery, but most practices can be applied to other libraries as well. ## File Inclusion SilverStripe-driven code should use the ''Requirements'' class to manage clientside dependencies like CSS and JavaScript files, rather than including `<script>` and `<link>` tags in your templates. This has the advantage that a registry of requirements can be built up from different places outside of the main controller, for example included ''FormField'' instances. See [:Requirements](/Requirements) documentation. ## jQuery, jQuery UI and jQuery.entwine: Our libraries of choice We predominantly use [jQuery](http://jquery.com) as our abstraction library for DOM related programming, within the SilverStripe CMS and certain framework aspects. For richer interactions such as drag'n'drop, and more complicated interface elements like tabs or accordions, SilverStripe CMS uses [jQuery UI](http://ui.jquery.com) on top of jQuery. For any custom code developed with jQuery, you have four choices to structure it: Custom jQuery Code, a jQuery Plugin, a jQuery UI Widget, or a ''jQuery.entwine'' behaviour. We'll detail below where each solution is appropriate. **Important**: Historically we have been using [PrototypeJS](http://prototypejs.com), which is now discouraged (see [legacy documentation](/javascript/prototypejs)). SilverStripe as a framework doesn't impose a choice of library. It tries to generate meaningful markup which you can alter with other JavaScript libraries as well. Only the CMS itself and certain form widgets require jQuery to function correctly. You can also use jQuery in parallel with other libraries, see [here](http://docs.jquery.com/Using_jQuery_with_Other_Libraries). ### Custom jQuery Code jQuery allows you to write complex behaviour in a couple of lines of JavaScript. Smaller features which aren't likely to be reused can be custom code without further encapsulation. For example, a button rollover effect doesn't require a full plugin. See "[How jQuery Works](http://docs.jquery.com/How_jQuery_Works)" for a good introduction. ### jQuery Plugins A jQuery Plugin is essentially a method call which can act on a collection of DOM elements. It is contained within the ''jQuery.fn'' namespace, and attaches itself automatically to all jQuery collections. The basics for are outlined in the official [jQuery Plugin Authoring](http://docs.jquery.com/Plugins/Authoring) documentation. There a certain [documented patterns](http://www.learningjquery.com/2007/10/a-plugin-development-pattern) for plugin development, most importantly: * Claim only a single name in the jQuery namespace * Accept an options argument to control plugin behavior * Provide public access to default plugin settings * Provide public access to secondary functions (as applicable) * Keep private functions private * Support the [Metadata Plugin](http://docs.jquery.com/Plugins/Metadata/metadata) Example: A plugin to highlight a collection of elements with a configurable foreground and background colour (abbreviated example from [learningjquery.com](http://www.learningjquery.com/2007/10/a-plugin-development-pattern)). :::javascript // create closure (function($) { // plugin definition $.fn.hilight = function(options) { // build main options before element iteration var opts = $.extend({}, $.fn.hilight.defaults, options); // iterate and reformat each matched element return this.each(function() { $this = $(this); // build element specific options var o = $.meta ? $.extend({}, opts, $this.data()) : opts; // update element styles $this.css({ backgroundColor: o.background, color: o.foreground }); }); }; // plugin defaults $.fn.hilight.defaults = { foreground: "red", background: "yellow" }; // end of closure })(jQuery); Usage: :::javascript (function($) { // Highlight all buttons with default colours jQuery(':button').highlight(); // Highlight all buttons with green background jQuery(':button').highlight({background: "green"}); // Set all further highlight() calls to have a green background $.fn.hilight.defaults.background = "green"; })(jQuery); ### jQuery UI Widgets UI Widgets are jQuery Plugins with a bit more structure, targeted towards interactive elements. They require jQuery and the core libraries in jQuery UI, so are generally more heavyweight if jQuery UI isn't already used elsewhere. Main advantages over simpler jQuery plugins are: * Exposing public methods on DOM elements (incl. pseudo-private methods) * Exposing configuration and getters/setters on DOM elements * Constructor/Destructor hooks * Focus management and mouse interaction See the [official developer guide](http://jqueryui.com/docs/Developer_Guide) and other [tutorials](http://bililite.com/blog/understanding-jquery-ui-widgets-a-tutorial/) to get started. Example: Highlighter :::javascript (function($) { $.widget("ui.myHighlight", { getBlink: function () { return this._getData('blink'); }, setBlink: function (blink) { this._setData('blink', blink); if(blink) this.element.wrapInner('<blink></blink>'); else this.element.html(this.element.children().html()); }, _init: function() { // grab the default value and use it this.element.css('background',this.options.background); this.element.css('color',this.options.foreground); this.setBlink(this.options.blink); } }); // For demonstration purposes, this is also possible with jQuery.css() $.ui.myHighlight.getter = "getBlink"; $.ui.myHighlight.defaults = { foreground: "red", background: "yellow", blink: false }; })(jQuery); Usage: :::javascript (function($) { // call with default options $(':button').myHighlight(); // call with custom options $(':button').myHighlight({background: "green"}); // set defaults for all future instances $.ui.myHighlight.defaults.background = "green"; // Adjust property after initialization $(':button').myHighlight('setBlink', true); // Get property $(':button').myHighlight('getBlink'); })(jQuery); ### entwine: Defining Behaviour and Public APIs jQuery.entwine is a third-party plugin, from its documentation: "A basic desire for jQuery programming is some sort of OO or other organisational method for code. For your consideration, we provide a library for entwineUI style programming. In entwineUI you attach behavioral code to DOM objects. entwine extends this concept beyond what is provided by other libraries to provide a very easy to use system with class like, ploymorphic, namespaced properties." Use jQuery.entwine when your code is likely to be customized by others, for example for most work in the CMS interface. It is also suited for more complex applications beyond a single-purpose plugin. Example: Highlighter :::javascript (function($) { $(':button').entwine({ Foreground: 'red', Background: 'yellow', highlight: function() { this.css('background', this.getBackground()); this.css('color', this.getForeground()); } }); })(jQuery); Usage: :::javascript (function($) { // call with default options $(':button').entwine().highlight(); // set options for existing and new instances $(':button').entwine().setBackground('green'); // get property $(':button').entwine().getBackground(); })(jQuery); This is a deliberately simple example, the strength of jQuery.entwine over simple jQuery plugins lies in its public properties, namespacing, as well as its inheritance based on CSS selectors. Please see the [project documentation](http://github.com/hafriedlander/jquery.entwine/tree/master) for more complete examples. ## Architecture and Best Practices ### Keep things simple Resist the temptation to build "cathedrals" of complex interrelated components. In general, you can get a lot done in jQuery with a few lines of code. Your jQuery code will normally end up as a series of event handlers applied with ''jQuery.live()'' or jQuery.entwine, rather than a complex object graph. ### Don't claim global properties Global properties are evil. They are accesible by other scripts, might be overwritten or mis-used. A popular case is the ''$'' shortcut in different libraries: in PrototypeJS it stands for ''document.getElementByID()'', in jQuery for ''jQuery()''. :::javascript // you can't rely on '$' being defined outside of the closure (function($) { var myPrivateVar; // only available inside the closure // inside here you can use the 'jQuery' object as '$' })(jQuery); You can run ''[jQuery.noConflict()](http://docs.jquery.com/Core/jQuery.noConflict)'' to avoid namespace clashes. NoConflict mode is enabled by default in the SilverStripe CMS javascript. ### Initialize at document.ready You have to ensure that DOM elements you want to act on are loaded before using them. jQuery provides a wrapper around the ''window.onload'' and ''document.ready'' events. :::javascript // DOM elements might not be available here $(document).ready(function() { // The DOM is fully loaded here }); See [jQuery FAQ: Launching Code on Document Ready](http://docs.jquery.com/How_jQuery_Works#Launching_Code_on_Document_Ready). ### Bind events "live" jQuery supports automatically reapplying event handlers when new DOM elements get inserted, mostly through Ajax calls. This "live binding" saves you from reapplying this step manually. Caution: Only applies to certain events, see the [jQuery.live() documentation](http://docs.jquery.com/Events/live). Example: Add a 'loading' classname to all pressed buttons :::javascript // manual binding, only applies to existing elements $('input[[type=submit]]').bind('click', function() { $(this).addClass('loading'); }); // live binding, applies to any inserted elements as well $('input[[type=submit]]').live(function() { $(this).addClass('loading'); }); See [jQuery FAQ: Why do my events stop working after an AJAX request](http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F). ### Assume Element Collections jQuery is based around collections of DOM elements, the library functions typically handle multiple elements (where it makes sense). Encapsulate your code by nesting your jQuery commands inside a ''jQuery().each()'' call. Example: ComplexTableField implements a paginated table with a pop-up for displaying :::javascript $('div.ComplexTableField').each(function() { // This is the over code for the tr elements inside a ComplexTableField. $(this).find('tr').hover( // ... ); }); ### Use plain HTML and jQuery.data() to store data The DOM can make javascript configuration and state-keeping a lot easier, without having to resort to javascript properties and complex object graphs. Example: Simple form change tracking to prevent submission of unchanged data Through CSS properties :::javascript $('form :input').bind('change', function(e) { $(this.form).addClass('isChanged'); }); $('form').bind('submit', function(e) { if($(this).hasClass('isChanged')) return false; }); Through jQuery.data() :::javascript $('form :input').bind('change', function(e) { $(this.form).data('isChanged', true); }); $('form').bind('submit', function(e) { alert($(this).data('isChanged')); if($(this).data('isChanged')) return false; }); See [interactive example on jsbin.com](http://jsbin.com/opuva) You can also use the [jQuery.metadata Plugin](http://docs.jquery.com/Plugins/Metadata/metadata) to serialize data into properties of DOM elements. This is useful if you want to encode element-specific data in markup, for example when rendering a form element through the SilverStripe templating engine. Example: Restricted numeric value field :::html <input type="text" class="restricted-text {min:4,max:10}" /> :::javascript $('.restricted-text').bind('change', function(e) { if( e.target.value < $(this).metadata().min || e.target.value > $(this).metadata().max ) { alert('Invalid value'); return false; } }); See [interactive example on jsbin.com](http://jsbin.com/axafa) ### Return HTML/JSON and HTTPResponse class for AJAX responses Ajax responses will sometimes need to update existing DOM elements, for example refresh a set of search results. Returning plain HTML is generally a good default behaviour, as it allows you to keep template rendering in one place (in SilverStripe PHP code), and is easy to deal with in JavaScript. If you need to process or inspect returned data, consider extracting it from the loaded HTML instead (through id/class attributes, or the jQuery.metadata plugin). For returning status messages, please use the HTTP status-codes. Only return evaluated JavaScript snippets if unavoidable. Most of the time you can just pass data around, and let the clientside react to changes appropriately without telling it directly through JavaScript in AJAX responses. Don't use the [:Form](http://api.silverstripe.org/trunk/forms/core/Form.html) SilverStripe class, which is built solely around this inflexible concept. Example: Autocomplete input field loading page matches through AJAX Template: :::html <ul> <% control Results %> <li id="Result-$ID">$Title</li> <% end_control %> </ul> PHP: :::php class MyController { function autocomplete($request) { $SQL_title = Convert::raw2sql($request->getVar('title')); $results = DataObject::get("Page", "Title = '$SQL_title'"); if(!$results) return new HTTPResponse("Not found", 404); // Use HTTPResponse to pass custom status messages $this->response->setStatusCode(200, "Found " . $results->Count() . " elements"); // render all results with a custom template $vd = new ViewableData(); return $vd->customise(array( "Results" => $results ))->renderWith('AutoComplete'); } } HTML :::html <form action"#"> <div class="autocomplete {url:'MyController/autocomplete'}"> <input type="text" name="title" /> <div class="results" style="display: none;"> </div> <input type="submit" value="action_autocomplete" /> </form> JavaScript: :::javascript $('.autocomplete input').live('change', function() { var resultsEl = $(this).siblings('.results'); resultsEl.load( // get form action, using the jQuery.metadata plugin $(this).parent().metadata().url, // submit all form values $(this.form).serialize(), // callback after data is loaded function(data, status) { resultsEl.show(); // get all record IDs from the new HTML var ids = jQuery('.results').find('li').map(function() { return $(this).attr('id').replace(/Record\-/,''); }); } ); }); Although they are the minority of cases, there are times when a simple HTML fragment isn't enough. For example, if you have server side code that needs to trigger the update of a couple of elements in the CMS left-hand tree, it would be inefficient to send back the HTML of entire tree. SilverStripe can serialize to and from JSON (see the [Convert class](/Convert)), and jQuery deals very well with it through [jQuery.getJSON()](http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback), as long as the HTTP content-type is properly set. ### Use events and observation to link components together The philosophy behind this javascript guide is **component driven development**: your javascript should be structured as a set of components that communicate. Event handlers are a great way of getting components to community, as long as two-way communication isn't required. Set up a number of custom event names that your component will trigger. List them in the component documentation comment. jQuery can bind to DOM events and trigger them through custom code. It can also [trigger custom events](http://docs.jquery.com/Events/trigger), and supports [namespaced events](http://docs.jquery.com/Namespaced_Events). Example: Trigger custom 'validationfailed' event on form submission for each empty element :::javascript $('form').bind('submit', function(e) { // $(this) refers to form $(this).find(':input').each(function() { // $(this) in here refers to input field if(!$(this).val()) $(this).trigger('validationfailed'); }); return false; }); // listen to custom event on each <input> field $('form :input').bind('validationfailed',function(e) { // $(this) refers to input field alert($(this).attr('name')); }); See [interactive example on jsbin.com](http://jsbin.com/ipeca). Don't use event handlers in the following situations: * If two-way communication is required, for example, calling an method in another component, which returns data that you then use. Event handlers can't have return values. * If specific execution order is required. Event handlers are executed in parallel, which makes it difficult to know the exact order in which code in different threads will execute. If the execution order is likely to cause problems, it is better to use a code structure that is executed sequentially. An example might be two events modifying the same piece of the DOM. ### Use callbacks to allow customizations Callbacks are similar to events in that other components can ask your component to execute a piece of code. The advantage is that they lack the two problems listed in bullets just above. The disadvantage of callbacks is that you need to define an custom API for configuring the callbacks; whereas, event observation is a jQuery provided API that leaves components very loosely coupled. ### Use jQuery.entwine to define APIs as necessary By default, most of your JavaScript methods will be hidden in closures like a jQuery plugin, and are not accessible from the outside. As a best practice, each jQuery plugin should only expose one method to initialize and configure it. If you need more public methods, consider using either a jQuery UI Widget, or define your behaviour as jQuery.entwine rules (see above). ### Write Documentation Documentation in JavaScript usually resembles the JavaDoc standard, although there is no agreed standard. Due to the flexibility of the language it can be hard to generate automated documentation, particularly with the predominant usage of closure constructs in jQuery and jQuery.entwine. To generate documentation for SilverStripe code, use [JSDoc toolkit](http://code.google.com/p/jsdoc-toolkit/) (see [reference of supported tags](http://code.google.com/p/jsdoc-toolkit/wiki/TagReference)). For more class-oriented JavaScript, take a look at the [jsdoc cookbook](http://code.google.com/p/jsdoc-toolkit/wiki/CookBook). The ''@lends'' and ''@borrows'' properties are particularly useful for documenting jQuery-style code. JSDoc-toolkit is a commandline utility, see [usage](http://code.google.com/p/jsdoc-toolkit/wiki/CommandlineOptions). Example: jQuery.entwine :::javascript /** * Available Custom Events: * <ul> * <li>ajaxsubmit</li> * <li>validate</li> * <li>loadnewpage</li> * </ul> * * @class Main LeftAndMain interface with some control panel and an edit form. * @name ss.LeftAndMain */ $('.LeftAndMain').entwine('ss', function($){ return/** @lends ss.LeftAndMain */ { /** * Reference to some property * @type Number */ MyProperty: 123, /** * Renders the provided data into an unordered list. * * @param {Object} data * @param {String} status * @return {String} HTML unordered list */ publicMethod: function(data, status) { return '<ul>' + /... + '</ul>'; }, /** * Won't show in documentation, but still worth documenting. * * @return {String} Something else. */ _privateMethod: function() { // ... } }; ]]); ### Unit Testing It is important to verify that your code actually does what it says, and the best way to ensure this are **automated tests**. For jQuery, we use two different tools with different uses: **unit testing** with [QUnit](http://docs.jquery.com/QUnit) (also used by the jQuery team for the core libraries), and **behaviour driven testing** with [JSpec](http://visionmedia.github.com/jspec/). There are overlaps between the two solutions, if in doubt start with JSpec, as it provides a much more powerful testing framework. Example: QUnit test (from [jquery.com](http://docs.jquery.com/QUnit#Using_QUnit)): :::javascript test("a basic test example", function() { ok( true, "this test is fine" ); var value = "hello"; equals( "hello", value, "We expect value to be hello" ); }); Example: JSpec Shopping cart test (from [visionmedia.github.com](http://visionmedia.github.com/jspec/)) describe 'ShoppingCart' before_each cart = new ShoppingCart end describe 'addProduct' it 'should add a product' cart.addProduct('cookie') cart.addProduct('icecream') cart.should.have 2, 'products' end end end ### Break the rules! The guidelines are not intended to be hard and fast rules; they cover the most common cases but not everything. Don't be afraid to experiment with using other approaches. # Links * [Unobtrusive Javascript](http://www.onlinetools.org/articles/unobtrusivejavascript/chapter1.html) * [Quirksmode: In-depth Javascript Resources](http://www.quirksmode.org/resources.html) * [behaviour.js documentation](http://open.silverstripe.org/browser/modules/sapphire/branches/2.4/thirdparty/behaviour/README.md)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/controller.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/controller.md
3,400
1,758,118,090
en
## Introduction Base controller class. You will extend this to take granular control over the actions and url handling of aspects of your SilverStripe site. ## Example mysite/code/Controllers/FastFood.php :::php <?php class FastFood_Controller extends Controller { function order($arguments) { print_r($arguments); } } ?> mysite/_config.php :::php Director::addRules(50, array('fastfood/$Action/$ID/$Name' => 'FastFood_Controller')); Request for '/fastfood/order/24/cheesefries' would result in the following to the $arguments above. If needed, use "?flush=1" on the end of request after making any code changes to your controller. :::html Array ( [Action] => order [ID] => 24 [Name] => cheesefries ) ## URL Handling In the above example the URLs were configured using the `[api:Director]` rules in the **_config.php** file. Alternatively you can specify these in your Controller class via the **$url_handlers** static array (which gets processed by the RequestHandler). This is useful when you want to subvert the fixed action mapping of 'fastfood/order/*' to the function **order**. In the case below we also want any orders coming through '/fastfood/drivethrough/' to use the same order function. mysite/code/Controllers/FastFood.php :::php class FastFood_Controller extends Controller { public static $url_handlers = array( 'drivethrough/$Action/$ID/$Name' => 'order' ); ## URL Patterns The RequestHandler class will parse all rules you specify against the following patterns. **A rule must always start with alphabetical ([A-Za-z]) characters or a $Variable declaration** | Pattern | | Description | | ----------- | | --------------- | | **$** | | **Param Variable** - Starts the name of a paramater variable, it is optional to match this unless ! is used | | **!** | | **Require Variable** - Placing this after a parameter variable requires data to be present for the rule to match | | **%%//%%** | | **Shift Point** - Declares that only variables denoted with a $ are parsed into the $params AFTER this point in the regex | # Examples See maetl's article in the Links below of a detailed explanation. **'$Action%%//%%$ID/$OtherID'** - Standard URL handler for a Controller. Take whatever URLSegment it is set to, find the Action to match a function in the Controller, and parse two optional $param variables that will be named ID and OtherID. **'admin/help%%//%%$Action/$ID'** - Match an url starting with /admin/help/, but don't include /help/ as part of the action (the shift point is set to start parsing variables and the appropriate controller action AFTER the //) **'tag/$Tag!'** - Match an URL starting with /tag/ after the controller's URLSegment and require it to have something after it. If the URLSegment is **order** then '/order/tag/34' and '/order/tag/asdf' match but '/order/tag/' will not You can use the **debug_request=1** switch from the [urlvariabletools](urlvariabletools) to see these in action. ## API Documentation [Click here for the API documentation](http://api.silverstripe.org/trunk/sapphire/Controller.html). ## Links * `[api:Director]` class * [execution-pipeline](/reference/execution-pipeline) * [URL Handling in Controllers](http://maetl.net/silverstripe-url-handling) by maetl
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/debugging.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/debugging.md
5,543
1,758,118,090
en
# Environment Types Silverstripe knows three different environment-types (or "debug-levels"). Each of the levels gives you different tools and functionality. "//dev//", "//test//" and "//live//". You can either configure the environment of the site in the mysite/_config.php file or in your [environment configuration file](/topics/environment-management). The definition of setting an environment in your mysite/_config.php looks like :::php Director::set_environment_type("dev"); ## Available Site Modes ### Dev Mode When developing your websites, adding page types or installing modules you should run your site in devmode. In this mode you will be able to view full error backtraces and view the development tools without logging in as admin. To set your site to dev mode set this in your mysite/_config.php file :::php Director::set_environment_type("dev"); Please note **devmode should not be enabled long term on live sites for security reasons**. In devmode by outputting backtraces of function calls a hacker can gain information about your environment (including passwords) so you should use devmode on a public server very very carefully ### Test Mode Test mode is designed for staging environments or other private collaboration sites before deploying a site live. You do not need to use test mode if you do not have a staging environment or a place for testing which is on a public server) In this mode error messages are hidden from the user and it includes BasicAuth integration if you want to password protect the site. To set your site to test mode set this in your mysite/_config.php file :::php Director::set_environment_type("test"); A common situation is to enable password protected site viewing on your test site only. You can enable that but adding this to your mysite/_config file :::php if(Director::isTest()) BasicAuth::protect_entire_site(); ### Live Mode Live sites should always run in live mode. Error messages are suppressed from the user but can be optionally configured to email the developers. This enables near real time reporting of any fatal errors or warnings on the site and can help find any bugs users run into. To set your site to live mode set this in your mysite/_config.php file :::php Director::set_environment_type("live"); ## Checking Environment Types Use the following methods: :::php Director::isDev(); Director::isTest(); Director::isLive(); This is useful when you have various API keys on your site and separate ones for dev / live or for configuring environment settings based on type :::php if(Director::isDev()) { // this is for dev only } else { // this is for the live site } ## Email Errors :::php if(Director::isLive()) Debug::send_errors_to("[email protected]"); ## Customizing Error-Output You can customize "friendly error messages" in test/live-mode by creating *assets/error-500.html*. # URL Variable Tools You can get lots of information on the current rendering context without writing any code or launching a debugger: Just attach some [Debug Parameters](/reference/urlvariabletools) to your current URL to see the compiled template, or all performed SQL-queries. # Debugging methods The Debug class contains a number of static methods * *Debug::show($myVariable)*: performs a kind of *print_r($myVariable)*, but shows it in a more useful format. * *Debug::message("Wow, that's great")*: prints a short debugging message. * *SS_Backtrace::backtrace()* (2.3: *Debug::backtrace()*): prints a calls-stack * *Debug::sendLiveErrorsTo("[email protected]")*: On the live site, all errors will get sent to this address. ## Error handling On development sites, we deal harshly with any warnings or errors: a full call-stack is shown and execution stops. This is basically so that we deal with them promptly, since most warnings are indication that **something** is broken. On live sites, all errors are emailed to the address specified in Debug::sendLiveErrorsTo($email) ## Debugging techniques Since we don't have a decent interactive debugger going, we use the following debugging techniques: * Putting *Debug::show()* and *Debug::message()* at key places in the code can help you know what's going on. Sometimes, it helps to put this debugging information into the core modules, although, if possible, try and get what you need by using [url querystring variables](/reference/urlvariabletools). * Calling *user_error("breakpoint", E_USER_ERROR)* will kill execution at that point and give you a call stack to see where you came from. Alternatively, *SS_Backtrace::backtrace()* gives you similar information without killing execution. * There are some special [url querystring variables](/reference/urlvariabletools) that can be helpful in seeing what's going on with core modules, such as the templates. * You can also use *$Debug* with *ViewableData* in templates. ### Unit Testing A good way to avoid writing the same test stubs and var_dump() commands over and over again is to codify them as [unit tests](testing-guide). This way you integrate the debugging process right into your quality control, and eventually in the development effort itself as "test-driven development". ### Profiling Silverstripe includes a profiling suite called [Profiler](http://www.adepteo.net/profiler/manual.html) from Carl Taylor at Adepteo. You can use this withing your installation during development to find bottlenecks and more. You can enable the profiler by adding `?debug_profile=1` to your URL.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/form-validation.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/form-validation.md
2,317
1,758,118,090
en
Form validation is a combination of PHP and JavaScript ## PHP ### Introduction Validators are implemented as an argument to the [api:Form] constructor. You create a required fields validator like so. In this case, we're creating a [api:RequiredFields] validator - the [api:Validator] class itself is an abstract class. :::php function Form() { $form = new Form($this, 'Form', new FieldSet( new TextField('MyRequiredField'), new TextField('MyOptionalField') ), new FieldSet( new FormAction('submit', 'Submit') ), new RequiredFields(array('MyRequiredField')) ); // Optional: Add a CSS class for custom styling $form->dataFieldByName('MyRequiredField)->addExtraClass('required'); return $form; } ### Subclassing Validator To create your own validator, you need to subclass validator and define two methods: * **javascript()** Should output a snippet of JavaScript that will get called to perform javascript validation. * **php($data)** Should return true if the given data is valid, and call $this->validationError() if there were any errors. ## JavaScript ### Default validator.js implementation TODO Describe behaviour.js solution easily, how to disable it Setting fieldEl.requiredErrorMsg or formEl.requiredErrorMsg will override the default error message. Both can include the string '$FieldLabel', which will be replaced with the field's label. Otherwise, the message is "Please fill out "$FieldLabel", it is required". You can use Behaviour to load in the appropriate value: :::js Behaviour.register({ '#Form_Form' : { requiredErrorMsg: "Please complete this question before moving on.", } }); ### Other validation libraries By default, SilverStripe forms with an attached Validator instance use the custom Validator.js clientside logic. It is quite hard to customize, and might not be appropriate for all use-cases. You can disable integrated clientside validation, and use your own (e.g. [jquery.validate](http://docs.jquery.com/Plugins/Validation)). Disable for all forms (in `mysite/_config.php`): :::php Validator::set_javascript_validation_handler('none'); Disable for a specific form: :::php $myForm->getValidator()->setJavascriptValidationHandler('none'); ## Related * Model Validation with [api:DataObject->validate()]
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/error-handling.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/error-handling.md
3,905
1,758,118,090
en
## Introduction SilverStripe has its own error trapping and handling support. ## Error Levels SilverStripe recognises two basic levels of error: * **WARNING:** Something strange has happened; the system has attempted to continue as best it can, but the developers need to look at this. This category also include areas where a newer version of SilverStripe requires changes to the site's customised code. * **FATAL ERROR:** There is no way that the system can attempt to continue with the particular operation; it would be dangerous to report success to the user. You should use [user_error](http://www.php.net/user_error) to throw errors where appropriate. The more information we have about what's not right in the system, the better we can make the application. * **E_USER_WARNING:** Err on the side of over-reporting warnings. The more warnings we have, the less chance there is of a developer leaving a bug. Throwing warnings provides a means of ensuring that developers know whow * Deprecated functions / usage patterns * Strange data formats * Things that will prevent an internal function from continuing. Throw a warning and return null. * **E_USER_ERROR:** Throwing one of these errors is going to take down the production site. So you should only throw E_USER_ERROR if it's going to be **dangerous** or **impossible** to continue with the request. Note that currently, the SilverStripe core doesn't follow these standards perfectly. * Right now, **every** failed SQL statement throws a fatal error. Many 'select' queries could probably be reduced to warnings. * A lot of assertion checking in the system that throws errors when it should throw warnings. ## Friendly Website Errors An HTTP 500 error will be sent when there has been a fatal error on either a test or production site. You can make this friendlier - much like the 404 page, the error content can be edited within the CMS. * Create a page of type `[api:ErrorPage]` * Set the error code to 500 * Publish the page. **HOW IT WORKS: **The publication script for ErrorPage will write the full HTML content, including the template styling, to assets/error-500.html. The fatal error handler looks for the presence of this file, and if it exists, dumps the content. This means that database access isn't required to provide a 500 error page. ## Filesystem Logs ### From SilverStripe *Requires SilverStripe 2.3* You can indicate a log file relative to the site root. The named file will have a terse log sent to it, and the full log (an encoded file containing backtraces and things) will go to a file of a similar name, but with the suffix ".full" added. <mysite>/_config.php: :::php // log errors and warnings SS_Log::add_writer(new SS_LogFileWriter('/my/logfile/path'), SS_Log::WARN, '<='); // or just errors SS_Log::add_writer(new SS_LogFileWriter('/my/logfile/path'), SS_Log::ERR); #### Deprecated method (SS 2.3 ?) <mysite>/_config.php: :::php Debug::log_errors_to("/my/logfile/path"); ### From PHP In addition to SilverStripe-integrated logging, it is adviseable to fall back to PHPs native logging functionality. A script might terminate before it reaches the SilverStripe errorhandling, for example in the case of a fatal error. <mysite>/_config.php: :::php ini_set("log_errors", "On"); ini_set("error_log", "/my/logfile/path"); ## Email Logs You can send both fatal errors and warnings in your code to a specified email-address. <mysite>/_config.php: :::php // log errors and warnings SS_Log::add_writer(new SS_LogEmailWriter('[email protected]'), SS_Log::WARN, '<='); // or just errors SS_Log::add_writer(new SS_LogEmailWriter('[email protected]'), SS_Log::ERR); #### Deprecated method (SS 2.3 ?) :::php Debug::send_errors_to("[email protected]"); Debug::send_warnings_to("[email protected]"); // Optional, implied by send_errors_to()
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/environment-management.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/environment-management.md
3,067
1,758,118,090
en
# Environment management As website developers, we noticed that we had a few problems. You may have the same problems: * On our development laptops, we have a number of sites, but the database connection details are the same for each of them. Why should we have to go through the installation process and re-enter them each time? * Each of those sites needed to be in development mode when we were editing them on our laptops, but in production mode when we deploy them to our servers. Additionally, our production host's database connection details will likely be different than our local server. SilverStripe comes with a solution to this: the "_ss_environment.php" file. You can put a single _ss_environment.php file in your "projects" folder on your development box, and it will be used by each of your development sites. #### Setting up your development machine with _ss_environment.php In this example, we assume that you are managing multiple projects as subfolders of "~/Sites/", and that you can visit these at "http://localhost/". For example, you might have a project at "~/Sites/myproject/", and visit it at "http://localhost/myproject/". Create a new file, ~/Sites/_ss_environment.php. Put the following content in it, editing the values of the "SS_DATABASE_..."" and "SS_DEFAULT_ADMIN_..." defines as appropriate. :::php <?php /* What kind of environment is this: development, test, or live (ie, production)? */ define('SS_ENVIRONMENT_TYPE', 'dev/test/live'); /* Database connection */ define('SS_DATABASE_SERVER', 'localhost'); define('SS_DATABASE_USERNAME', 'root'); define('SS_DATABASE_PASSWORD', ''); /* Configure a default username and password to access the CMS on all sites in this environment. */ define('SS_DEFAULT_ADMIN_USERNAME', 'username'); define('SS_DEFAULT_ADMIN_PASSWORD', 'password'); Now, edit each of your site's configuration file, ''~/Sites/(projectname)/mysite/_config.php''. Delete all mention of ''$databaseConfig'' and ''Director::set_dev_servers'', and instead make sure that you file starts like this. :::php <?php global $project; $project = 'mysite'; global $database; $database = '(databasename)'; // Use _ss_environment.php file for configuration require_once("conf/ConfigureFromEnv.php"); #### How it works The mechanism by which the "_ss_environment.php" files work is quite simple. Here's how it works: * At the beginning of SilverStripe's execution, the _ss_environment.php file is searched for, and if it is found, it's included. SilverStripe looks in 3 places for the file: * The site's base folder (ie, a sibling of sapphire, jsparty, and cms) * The parent of the base folder * The grandparent of the base folder * The "_ss_environment.php" file sets a number of "define()". * "conf/ConfigureFromEnv.php" is included from within your "mysite/_config.php". This file has a number of regular configuration commands that use those defines as their arguments. If you are curious, open up "sapphire/conf/ConfigureFromEnv.php" and see for yourself!
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/create-sapphire-test.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/create-sapphire-test.md
6,464
1,758,118,090
en
### How To Create a Sapphire Test A unit test class will test the behaviour of one of your DataObjects. This simple fragment of SiteTreeTest provides us the basics of creating unit tests. :::php <?php /** * Tests for SiteTree */ class SiteTreeTest extends SapphireTest { /** * Define the fixture file to use for this test class */ static $fixture_file = 'sapphire/tests/SiteTreeTest.yml'; /** * Test generation of the URLSegment values. * - Turns things into lowercase-hyphen-format * - Generates from Title by default, unless URLSegment is explicitly set * - Resolves duplicates by appending a number */ function testURLGeneration() { $expectedURLs = array( 'home' => 'home', 'staff' => 'my-staff', 'about' => 'about-us', 'staffduplicate' => 'my-staff-2', 'product1' => '1-1-test-product', 'product2' => 'another-product', 'product3' => 'another-product-2', 'product4' => 'another-product-3', ); foreach($expectedURLs as $fixture => $urlSegment) { $obj = $this->objFromFixture('Page', $fixture); $this->assertEquals($urlSegment, $obj->URLSegment); } } } There are a number of points to note in this code fragment: * Your test is a **subclass of SapphireTest**. Both unit tests and functional tests are a subclass of SapphireTest. * **static $fixture_file** is defined. The testing framework will automatically set up a new database for **each** of your tests. The initial database content will be sourced from the YML file that you list in $fixture_file. You must define this value. Note also that, for the time being, you can only point to one YML file for each test class. * Each **method that starts with the word "test"** will be executed by the TestRunner. Define as many as you like; the database will be rebuilt for each of these. * **$this->objFromFixture($className, $identifier)** can be used to select one of the objects named in your fixture file. To identify to the object, we provide a class name and an identifier. The identifier is specified in the YML file but not saved in the database anywhere. objFromFixture() looks the DataObject up in memory rather than using the database. This means that you can use it to test the functions responsible for looking up content in the database. * **$this->assertEquals()** is one of the many assert... functions that PHPUnit provides us. See below for more information. ### Assertion commands **$this->assertEquals()** is an example of an assertion function. These functions form the basis of our tests - a test fails if and only if one or more of the assertions fail. There are many assertions available: * See [the PHPUnit manual chapter 22](http://www.phpunit.de/pocket_guide/3.2/en/api.html#api.assert.tables.assertions) for a listing of all PHPUnit's built-in assertions. * **$this->assertEmailSent($to, $from, $subject, $content)**: When an email is "sent" during a test run, it's not actually sent. Instead, it is logged in an internal register. You can use assertEmailSent() to verify that an email was sent. Each of the arguments can be a string, for an exact match, or, a preg_match() compatible regular expression, if it starts with "/". ### The Database YAML file The main feature of SapphireTest over the raw PHPUnit classes is that SapphireTest will prepare a temporary database for you. The content of that database is provided in a special YAML file. YAML is a simple markup languages that uses tabs and colons instead of the more verbose XML tags, and because of this much better for developers creating files by hand. We will begin with a sample file and talk our way through it. :::yaml Page: home: Title: Home about: Title: About Us staff: Title: Staff URLSegment: my-staff Parent: =>Page.about staffduplicate: Title: Staff URLSegment: my-staff Parent: =>Page.about products: Title: Products product1: Title: 1.1 Test Product product2: Title: Another Product product3: Title: Another Product product4: Title: Another Product contact: Title: Contact Us ErrorPage: 404: Title: Page not Found ErrorCode: 404 The contents of the YAML file are broken into three levels. * **Top level: class names** - Page and ErrorPage. This is the name of the dataobject class that should be created. The fact that ErrorPage is actually a subclass is irrelevant to the system populating the database. It just instantiates the object you specify. * **Second level: identifiers** - home, about, staff, staffduplicate, etc. These are the identifiers that you pass as the second argument of SapphireTest::objFromFixture(). Each identifier you specify delimits a new database record. This means that every record needs to have an identifier, whether you use it or not. * **Third level: fields** - each field for the record is listed as a 3rd level entry. In most cases, the field's raw content is provided. However, if you want to define a relationship, you can do so using "=>". There are a couple of lines like this: Parent: =>Page.about This will tell the system to set the ParentID database field to the ID of the Page object with the identifier "about". This can be used on any has-one or many-many relationship. Note that we use the name of the relationship (Parent), and not the name of the database field (ParentID) On many-many relationships, you should specify a comma separated list of values. MyRelation: =>Class.inst1,=>Class.inst2,=>Class.inst3 An crucial thing to note is that **the YAML file specifies DataObjects, not database records**. The database is populated by instantiating DataObject objects, setting the fields listed, and calling write(). This means that any onBeforeWrite() or default value logic will be executed as part of the test. This forms the basis of our testURLGeneration() test above. For example, the URLSegment value of Page.staffduplicate is the same as the URLSegment value of Page.staff. When the fixture is set up, the URLSegment value of Page.staffduplicate will actually be my-staff-2. Finally, be aware that requireDefaultRecords() is **not** called by the database populator - so you will need to specify standard pages such as 404 and home in your YAML file.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/create-functional-test.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/create-functional-test.md
2,717
1,758,118,090
en
### Writing functional tests Functional tests test your controllers. The core of these are the same as unit tests: * Create a subclass of SapphireTest in the mysite/tests or (module)/tests folder. * Define static $fixture_file to point to a database YAML file. * Create methods that start with "test" to create your tests. * Assertions are used to work out if a test passed or failed. The code of the tests is a little different. Instead of examining the behaviour of objects, we example the results of URLs. Here is an example from the subsites module: :::php class SubsiteAdminTest extends SapphireTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; /** * Return a session that has a user logged in as an administrator */ function adminLoggedInSession() { return new Session(array( 'loggedInAs' => $this->idFromFixture('Member', 'admin') )); } /** * Test generation of the view */ function testBasicView() { // Open the admin area logged in as admin $response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession()); // Confirm that this URL gets you the entire page, with the edit form loaded $response2 = Director::test('admin/subsites/show/1', null, $this->adminLoggedInSession()); $this->assertTrue(strpos($response2->getBody(), 'id="Root_Configuration"') !== false); $this->assertTrue(strpos($response2->getBody(), '<head') !== false); // Confirm that this URL gets you just the form content, with the edit form loaded $response3 = Director::test('admin/subsites/show/1', array('ajax' => 1), $this->adminLoggedInSession()); $this->assertTrue(strpos($response3->getBody(), 'id="Root_Configuration"') !== false); $this->assertTrue(strpos($response3->getBody(), '<form') === false); $this->assertTrue(strpos($response3->getBody(), '<head') === false); } We are using a new static method here: **Director::test($url, $postVars, $sessionObj)** Director::test() lets us execute a URL and see what happens. It bypasses HTTP, instead relying on the cleanly encapsulated execution model of Controller. It takes 3 arguments: * $url: The URL to execute * $postVars: Post variables to pass to the URL * $sessionObj: A Session object representing the current session. And it returns an HTTPResponse object, which will give you the response headers (including redirection), status code, and body. We can use string processing on the body of the response to then see if it fits with our expectations. If you're testing for natural language responses like error messages, make sure to use [i18n](i18n) translations through the *_t()* method to avoid tests failing when i18n is enabled.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/testing-guide.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/testing-guide.md
6,748
1,758,118,090
en
# Unit and Integration Testing The Sapphire core contains various features designed to simplify the process of creating and managing automated tests. ## Introduction If you are familiar with PHP coding but new to unit testing, you should read the [Introduction](/topics/testing) and check out Mark's presentation [Getting to Grips with SilverStripe Testing](http://www.slideshare.net/maetl/getting-to-grips-with-silverstripe-testing). You should also read over [the PHPUnit manual](http://www.phpunit.de/pocket_guide/3.2/). It provides a lot of fundamental concepts that we build on in this documentation. If you're more familiar with unit testing, but want a refresher of some of the concepts and terminology, you can browse the [Testing Glossary](#glossary). To get started now, follow the installation instructions below, and check [Troubleshooting](/topics/testing/testing-guide-troubleshooting) in case you run into any problems. ## Installation The framework has a required dependency on [PHPUnit](http://www.phpunit.de/) and an optional dependency on [SimpleTest](http://simpletest.org/), the two premiere PHP testing frameworks. To run Sapphire tests, you'll need to be able to access PHPUnit on your include path. First, you'll need to make sure that you have the PEAR command line client installed. To test this out, type `pear help` at your prompt. You should see a bunch of generic PEAR info. If it's not installed, you'll need to set it up first (see: [Getting Started with PEAR](http://www.sitepoint.com/article/getting-started-with-pear/)) or else manually install PHPUnit (see: [Installation instructions](http://www.phpunit.de/pocket_guide/3.3/en/installation.html)). The PHPUnit installation via PEAR is very straightforward. You might have to perform the following commands as root or super user (sudo). We need a specific version of PHPUnit (3.3.x), as 3.4 or higher breaks our test runner (see [#4573](http://open.silverstripe.com/ticket/4573)) At your prompt, type the following commands: pear channel-discover pear.phpunit.de pear channel-discover pear.symfony-project.com pear install phpunit/PHPUnit ## Running Tests ### Via Web Browser Go to the main test URL which will give you options for running various available test suites or individual tests on their own: http://localhost/dev/tests ### Via Command Line `cd` to the root level of your project and run [sake](/topics/commandline) (Sapphire Make) to execute the tests: /path/to/project$ sake dev/tests/all ### Partial Test Runs Run specific tests: dev/tests/MyTest,MyOtherTest Run all tests in a module folder, e.g. "sapphire" dev/tests/module/<modulename> Skip certain tests dev/tests/all SkipTests=MySkippedTest ## Writing Tests Tests are written by creating subclasses of `[api:SapphireTest]`. You should put tests for your site in the `mysite/tests` directory. If you are writing tests for a module, put them in the `(modulename)/tests` directory. Generally speaking, there should be one test class for each application class. The name of the test class should be the application class, with "Test" as a suffix. For instance, we have all the tests for `SiteTree` in `sapphire/tests/SiteTreeTest.php` You will generally write two different kinds of test classes. * **Unit Test:** Test the behaviour of one of your DataObjects. * **Functional Test:** Test the behaviour of one of your controllers. Some people may note that we have used the same naming convention as Ruby on Rails. ## How To Tutorials and recipes for creating tests using the Sapphire framework: * **[Create a Sapphire Test](/topics/testing//create-sapphire-test)** * **Load Test Fixtures** * **[Create a Functional Test](/topics/testing//create-functional-test)** * **[Test Outgoing Email Sending](/topics/testing//test-email-sending)** ## Glossary {#glossary} **Assertion:** A predicate statement that must be true when a test runs. **Test Case:** The atomic class type in most unit test frameworks. New unit tests are created by inheriting from the base test case. **Test Suite:** Also known as a 'test group', a composite of test cases, used to collect individual unit tests into packages, allowing all tests to be run at once. **Fixture:** Usually refers to the runtime context of a unit test - the environment and data prerequisites that must be in place in order to run the test and expect a particular outcome. Most unit test frameworks provide methods that can be used to create fixtures for the duration of a test - `setUp` - and clean them up after the test is done - `tearDown'. **Refactoring:** A behavior preserving transformation of code. If you change the code, while keeping the actual functionality the same, it is refactoring. If you change the behavior or add new functionality it's not. **Smell:** A code smell is a symptom of a problem. Usually refers to code that is structured in a way that will lead to problems with maintenance or understanding. **Spike:** A limited and throwaway sketch of code or experiment to get a feel for how long it will take to implement a certain feature, or a possible direction for how that feature might work. **Test Double:** Also known as a 'Substitute'. A general term for a dummy object that replaces a real object with the same interface. Substituting objects is useful when a real object is difficult or impossible to incorporate into a unit test. **Fake Object**: A substitute object that simply replaces a real object with the same interface, and returns a pre-determined (usually fixed) value from each method. **Mock Object:** A substitute object that mimicks the same behavior as a real object (some people think of mocks as "crash test dummy" objects). Mocks differ from other kinds of substitute objects in that they must understand the context of each call to them, setting expectations of which, and what order, methods will be invoked and what parameters will be passed. **Test-Driven Development (TDD):** A style of programming where tests for a new feature are constructed before any code is written. Code to implement the feature is then written with the aim of making the tests pass. Testing is used to understand the problem space and discover suitable APIs for performing specific actions. **Behavior Driven Development (BDD):** An extension of the test-driven programming style, where tests are used primarily for describing the specification of how code should perform. In practice, there's little or no technical difference - it all comes down to language. In BDD, the usual terminology is changed to reflect this change of focus, so *Specification* is used in place of *Test Case*, and *should* is used in place of *expect* and *assert*.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/email-sending.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/email-sending.md
3,040
1,758,118,090
en
SilverStripe's test system has built-in support for testing emails sent using the Email class. ### How it works For this to work, you need to send emails using the ''Email'' class, which is generally the way that we recommend you send emails in your SilverStripe application. Here is a simple example of how you might do this: :::php $e = new Email(); $e->To = "[email protected]"; $e->Subject = "Hi there"; $e->Body = "I just really wanted to email you and say hi."; $e->send(); Normally, the send() method would send an email using PHP's mail() function. However, if you are running a ''SapphireTest'' test, then it holds off actually sending the email, and instead lets you assert that an email was sent using this method. :::php $this->assertEmailSent("[email protected]", null, "/th.*e$/"); The arguments are ''$to'', ''$from'', ''$subject'', ''$body'', and can be take one of the following three forms: * A string: match exactly that string * ''null''/''false'': match anything * A PERL regular expression (starting with '/'): match that regular expression ### How to use it Given all of that, there is not a lot that you have to do in order to test emailing functionality in your application. * Write your SilverStripe application, using the Email class to send emails. * Write tests that trigger the email sending functionality. * Include appropriate ''$this->assertEmailSent()'' calls in those tests. That's it! ### What isn't tested It's important to realise that this email testing doesn't actually test everything that there is to do with email. The focus of this email testing system is testing that your application is triggering emails correctly. It doesn't test your email infrastructure outside of the webserver. For example: * It won't test that email is correctly configured on your webserver * It won't test whether your emails are going to be lost in someone's spam filter * It won't test bounce-handling or any other auxiliary services of email ### How it's built For those of you who want to dig a little deeper, here's a quick run-through of how the system has been built. As well as explaining how we built the email test, this is a good design pattern for making other "tricky external systems" testable: 1. The ''Email::send()'' method makes uses of a static object, ''Email::$mailer'', to do the dirty work of calling mail(). The default mailer is an object of type ''Mailer'', which performs a normal send. 2. ''Email::set_mailer()'' can be called to load in a new mailer object. 3. ''SapphireTest::setUp()'' method calls ''Email::set_mailer(new TestMailer())'' to replace the default mailer with a ''TestMailer'' object. This replacement mailer doesn't actually do anything when it is asked to send an email; it just records the details of the email in an internal field that can be searched with ''TestMailer::findEmails()''. 4. ''SapphireTest::assertEmailSent()'' calls ''TestMailer::findEmails()'' to see if a mail-send was requested by the application.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/why-test.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/why-test.md
6,144
1,758,118,090
en
# Why Unit Test? *Note: This is part of the [SilverStripe Testing Guide](/topics/testing/).* So at this point, you might be thinking, *"that's way too complicated, I don't have time to write unit tests on top of all the things I'm already doing"*. Fair enough. But, maybe you're already doing things that are close to unit testing without realizing it. Everyone tests all the time, in various ways. Even if you're just refreshing a URL in a browser to review the context of your changes, you're testing! First, ask yourself how much time you're already spending debugging your code. Are you inserting ''echo'', ''print_r'', and ''die'' statements into different parts of your program and watching the details dumping out to screen? **Yes, you know you are.** So how much time do you spend doing this? How much of your development cycle is dependent on dumping out the contents of variables to confirm your assumptions about what they contain? From this position, it may seem that unit testing may take longer and have uncertain outcomes simply because it involves adding more code. You'd be right, in the sense that we should be striving to write as little code as possible on projects. The more code there is, the more room there is for bugs, the harder it is to maintain. There's absolutely no doubt about that. But if you're dumping the contents of variables out to the screen, you are already making assertions about your code. All unit testing does is separate these assertions into separate runnable blocks of code, rather than have them scattered inline with your actual program logic. The practical and immediate advantages of unit testing are twofold. Firstly, they mean you don't have to mix your debugging and analysis code in with your actual program code (with the need to delete, or comment it out once you're done). Secondly, they give you a way to capture the questions you ask about your code while you're writing it, and the ability to run those questions over and over again, with no overhead or interference from other parts of the system. Unit testing becomes particularly useful when exploring boundary conditions or edge case behavior of your code. You can write assertions that verify examples of how your methods will be called, and verify that they always return the right results each time. If you make changes that have the potential to break these expected results, running the unit tests over and over again will give you immediate feedback of any regressions. Unit tests also function as specifications. They are a sure way to describe an API and how it works by simply running the code and demonstrating what parameters each method call expects and each method call returns. You could think of it as live API documentation that provides real-time information about how the code works. Unit test assertions are best understood as **pass/fail** statements about the behavior of your code. Ideally, you want every assertion to pass, and this is usually up by the visual metaphor of green/red signals. When things are all green, it's all good. Red indicates failure, and provides a direct warning that you need to fix or change your code. ## Getting Started Everyone has a different set of ideas about what makes good code, and particular preferences towards a certain style of logic. At the same time, frameworks and programming languages provide clear conventions and design idioms that guide code towards a certain common style. If all this ranting and raving about the importance of testing hasn't made got you thinking that you want to write tests then we haven't done our job well enough! But the key question still remains - *"where do I start?"*. To turn the key in the lock and answer this question, we need to look at how automated testing fits into the different aspects of the SilverStripe platform. There are some significant differences in goals and focus between different layers of the system and interactions between the core, and various supporting modules. ### Sapphire Core In open source core development, we are focussing on a large and (for the most part) stable system with existing well defined behavior. Our overarching goal is that we do not want to break or change this existing behavior, but at the same time we want to extend and improve it. Testing the Sapphire framework should focus on [characterization](http://en.wikipedia.org/wiki/Characterization_Test). We should be writing tests that illustrate the way that the API works, feeding commonly used methods with a range of inputs and states and verifying that these methods respond with clear and predictable results. Especially important is documenting and straighten out edge case behavior, by pushing various objects into corners and twisting them into situations that we know are likely to manifest with the framework in the large. ### SilverStripe Modules Modules usually encapsulate a smaller, and well defined subset of behavior or special features added on top of the core platform. A well constructed module will contain a reference suite of unit tests that documents and verifies all the basic aspects of the module design. See also: [modules](/topics/modules). ### Project Modules Testing focus on client projects will not be quite so straightforward. Every project involves different personalities, goals, and priorities, and most of the time, there is simply not enough time or resources to exhaustively predicate every granular aspect of an application. On application projects, the best option is to keep tests lean and agile. Most useful is a focus on experimentation and prototyping, using the testing framework to explore solution spaces and bounce new code up into a state where we can be happy that it works the way we want it to. ## Rules of Thumb **Be aware of breaking existing behavior.** Run your full suite of tests every time you do a commit. **Not everything is permanent.** If a test is no longer relevant, delete it from the repository. ## See Also * [Getting to Grips with SilverStripe Testing](http://www.slideshare.net/maetl/getting-to-grips-with-silverstripe-testing)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/testing/testing-guide-troubleshooting.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/testing/testing-guide-troubleshooting.md
334
1,758,118,090
en
# SilverStripe Testing Guide - Troubleshooting //Part of the [SilverStripe Testing Guide](testing-guide).// ## I can't run my new test class If you've just added a test class, but you can't see it via the web interface, chances are, you haven't flushed your manifest cache - append ''?flush=1'' to the end of your URL querystring.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-nginx.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-nginx.md
1,151
1,758,118,090
en
#### Installing SilverStripe on an existing Nginx server The prerequisite is that you have already installed Nginx and you are able to run PHP files via the FastCGI-wrapper from Nginx. Now you need to setup a virtual host in Nginx with the following configuration settings: server { listen 80; server_name yoursite.com; root /home/yoursite.com/httpdocs; index index.html index.php; if (!-f $request_filename) { rewrite ^/(.*?)(\?|$)(.*)$ /sapphire/main.php?url=$1&$3 last; } error_page 404 /sapphire/main.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/yoursite.com/httpdocs$fastcgi_script_name; include fastcgi_params; } } The above configuration will setup a new virtual host ''yoursite.com'' with rewrite rules suited for SilverStripe. The location block at the bottom will pass all php scripts to the FastCGI-wrapper. Now you can proceed with the SilverStripe installation normally.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-windows-manual-iis.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-windows-manual-iis.md
6,360
1,758,118,090
en
# Installation on Windows and IIS 7.0 and later This page explains installing SilverStripe manually, without the use of (the easy to use) [Web Platform Installer](/topics/installatin/installation-on-windows-pi). ## Configure an existing IIS server First we need to configure the server: * We assume that you already have a IIS server running. * If you haven't already, [install PHP using these instructions](http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/) * When you are editing the php.ini, enable the mysql, gd2, and mbstring extensions * [Install the Microsoft URL Rewrite Module](http://www.iis.net/expand/URLRewrite) * [Install the Fast-CGI admin panel](http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1682 ) (not required on IIS 7.5+) * If you're running on MySQL, you will need to [download and install that too](http://mysql.com). If you are using the SilverStripe development trunk and wish to use MS SQL server, you will need to perform the following additional server configuration: * Install SQL Server client tools * Install the [SQL Server Driver for PHP 1.1](http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9), "sqlsrv". * `<del>`You will have to use the threadsafe version of the library (php_sqlsrv_ts.dll). On some configurations, PHP will just silently not load a non-threadsafe extension`</del>`. * IMPORTANT: You should install a non-thread safe version of [PHP](http://windows.php.net/) AND a non-thread safe version of the [SQL Server Driver for PHP 1.1](http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9) "sqlsrv". VC9 of both is also preferred. ## Install SilverStripe Then it's time to install the SilverStripe installation package, and modify it to work with IIS: * Download SilverStripe from http://www.silverstripe.org/stable-download/ and unpack it into your web-root, most likely ''c:\inetpub\wwwroot''. * Create a file called ''web.config'' in the silverstripe folder with the following content. :::xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="SilverStripe Clean URLs" stopProcessing="true"> <match url="^(.*)$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="sapphire/main.php?url={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration> * Visit the folder that you just extracted in your web browser. For example, the URL might be ''http://localhost/silverstripe-v2.3/''. You will be shown the install screen. * Enter your MySQL username and password in the boxes provided and press "re-check requirements". You should be able to install now. * After the installation has finished, delete the index.html and index.php files. * You are encouraged to manually configure PHP to allow its mail() command to work, so that SilverStripe can send emails. This is used to email password reset, ecommerce checkouts, and other areas of the system. Your site should be running at `http://localhost/silverstripe-v2.3/` ## Troubleshooting On high traffic sites you might find that you start getting "The FastCGI process exited unexpectedly" errors. This is related to PHP/IIS on FastCGI rather than anything SQL specific. There are plenty of resources on the internet if you Google "PHP The FastCGI process exited unexpectedly". To fix this, [follow this guide on best practise setup](http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/#PHP_Recycling_Behavior) for FastCGI applications on IIS. IMPORTANT: You should ensure you are using the latest version of the sqlsrv driver. sqlsrv 1.1 is the latest, and works considerably better than 1.0. If possible, use PHP 5.3 as well. ## Performance A non-thread safe of PHP is recommended for use with IIS. Thread safety checks are not required, and you'll get a performance boost by not using a thread safe version. If possible, use a version compiled in VC9 instead of VC6. To use VC9 on Windows, you need to have .NET Framework 3.5 installed. This should already be installed on Windows Server 2008, Vista and 7. You should ensure you are using the latest version of the sqlsrv driver. sqlsrv 1.1 is the latest, and works considerably better than 1.0 in terms of reliability and performance. If possible, use PHP 5.3 as well. Try increasing the MaxInstances from 4 to a higher value. For quad core CPUs, a higher value such as 32 should prove to provide a performance enhancement. You can also [install wincache for IIS](http://learn.iis.net/page.aspx/678/use-the-windows-cache-extension-for-php/), to improve performance on live sites. You can also try installing and enabling static and dynamic content compression for IIS on live sites. Do this in IIS Manager > Compression. Doing all of the above should provide a significant performance boost to your site. ## Installing on IIS 5.1 and 6.0 * Follow the instructions above, but note differences: * You cannot install the URL Rewriter shown above, because Microsoft has no such plugin for those IIS older versions. This will mean your URLs are like yoursite.com/index.php/about-us rather than yoursite.com/about-us. If you do want friendly URLs you must you must buy or use other URL rewriting software * IIRF: http://iirf.codeplex.com/ * ISAPI_Rewrite: http://www.helicontech.com/download-isapi_rewrite3.htm * (The freeware, lite version should be fine for simple installations.) * If you have 64-bit windows, you can try this one: * http://www.micronovae.com/ModRewrite/ModRewrite.html * Instructions for installing PHP IIS 5.1 and 6 may be different that for 7. See http://learn.iis.net/page.aspx/248/configuring-fastcgi-extension-for-iis60/ * On XP, you need to disable 'Check that file exists' (See [installation-on-windows-pi](/topics/installation/installation-on-windows-pi)) Matthew Poole has expanded on these instructions with this tutorial: http://cubiksoundz.blogspot.com/2008/12/tech-note-installing-silverstripe-cms.html
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-lighttpd.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-lighttpd.md
3,832
1,758,118,090
en
#### Installing SilverStripe on an existing lighttpd webserver 1. Lighttpd works fine so long as you provide a custom config. Add the following to lighttpd.conf **BEFORE** installing Silverstripe. Replace "yoursite.com" and "/home/yoursite/public_html/" below. $HTTP["host"] == "yoursite.com" { server.document-root = "/home/yoursite/public_html/" # Disable directory listings dir-listing.activate = "disable" # Deny access to template files url.access-deny += ( ".ss" ) static-file.exclude-extensions += ( ".ss" ) # Deny access to Sapphire command-line interface $HTTP["url"] =~ "^/sapphire/cli-script.php" { url.access-deny = ( "" ) } # Disable FastCGI in assets directory (so that PHP files are not executed) $HTTP["url"] =~ "^/assets/" { fastcgi.server = () } # Rewrite URLs so they are nicer url.rewrite-once = ( "^/.*\.[A-Za-z0-9]+.*?$" => "$0", "^/(.*?)(\?|$)(.*)" => "/sapphire/main.php?url=$1&$3" ) # Show SilverStripe error page server.error-handler-404 = "/sapphire/main.php" } Rewrite rules do not check for file existence as they do on Apache. There is a ticket about it for Lighttpd: [http://redmine.lighttpd.net/issues/985](http://redmine.lighttpd.net/issues/985). 2. Extract the SilverStripe software to your lighttpd installation, and run http://yoursite.com/install.php and the installation should proceed normally. #### Multiple installations of SilverStripe on the same host (www.yourhost.com) Running multiple installations of Silverstripe on the same host is a bit more tricky, but not impossible. I would recommend using subdomains instead if you can, for exampe: site1.yourdomain.com and site2.yourdomain.com, it makes things a lot simpler, as you just use two of the above host example blocks. But if you really must run multiple copies of Silverstripe on the same host, you can use something like this (be warned, it's quite nasty): $HTTP["host"] == "yoursite.com" { url.rewrite-once = ( "(?i)(/copy1/.*\.([A-Za-z0-9]+))(.*?)$" => "$0", "(?i)(/copy2/.*\.([A-Za-z0-9]+))(.*?)$" => "$0", "^/copy1/(.*?)(\?|$)(.*)" => "/copy1/sapphire/main.php?url=$1&$3", "^/copy2/(.*?)(\?|$)(.*)" => "/copy2/sapphire/main.php?url=$1&$3" ) $HTTP["url"] =~ "^/copy1/" { server.error-handler-404 = "/copy1/sapphire/main.php" } $HTTP["url"] =~ "^/copy2/" { server.error-handler-404 = "/copy2/sapphire/main.php" } } Note: It doesn't work properly if the directory name copy1 or copy2 on your server has a dot in it, and you then open the image editor inside admin, I found that out the hard way when using a directory name of silverstripe-v2.2.2 after directly unzipping the Silverstripe tarball leaving the name as is. I haven't found a solution for that yet, but for now this method still works properly if you just don't use dots in the directory names. #### Installing lighttpd on Debian * aptitude install lighttpd *(and php5-cgi, mysql-server, etc, as necessary.)* * if apache is already running, lighttpd can still be safely installed. It will complain it cannot start because port 80 is in use. After installing lighttpd, edit /etc/lighttpd/lighttpd.conf and set: "server.port = 81" for example, and run /etc/init.d/lighttpd restart * edit /etc/lighttpd/conf-available/10-fastcgi.conf and set socket to: /var/run/lighttpd/php.socket * enable fastcgi module with /usr/sbin/lighty-enable-mod * /etc/init.d/lighttpd restart * You should now be able to view PHP files in your now-working lighttpd server. * Follow the top instructions on adding the rewrite rules, and then install SilverStripe. ##### More about lighttpd Learn more about the lighttpd webserver at http://www.lighttpd.net/
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-windows-wamp.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-windows-wamp.md
3,371
1,758,118,090
en
# Installation on Windows using WAMP (Apache webserver) An easy and reliable approach to getting SilverStripe running on Windows is to use Apache, which can be convieniently done through [WampServer](http://www.wampserver.com/en/). This can be useful if you are deploying on Linux Apache and want a Microsoft Windows machine with a very similar environment. Note: Installing on Microsoft's IIS webserver through Microsoft WebPI is likely to be easier, see [installation-on-windows-pi](installation-on-windows-pi). ## Install WAMP * [Watch as video.](http://www.silverstripe.com/assets/screencasts/silverstripe-installation-wamp/index.html) 1. Download WampServer from http://www.wampserver.com/en/download.php 2. Run the installer. By default, it will install to C:\wamp. You can choose your own install path if you wish; the directories mentioned below will also be different. 3. Once WampServer has been installed and launched, you will see a little half circle gauge in the task bar, next to the clock. If everything is working, then it will be white. If it's yellow or red, then something is wrong. If you can't see the gauge, then WampServer hasn't been started and you should start WampServer from the start menu. 4. If something's wrong, this usually means that you have another service on port 80 or port 3306. Here are some common sources of problems to check. After correcting these issues, left-click the gauge and choose 'restart all services'. It might a short while to restart, but the gauge should go to white. * You might have IIS running. Check Start -> Control Panel -> Administrative Tools -> Internet Information Services. Ensure that any web site services are stopped. * If you run Skype, visit Select "Tools" -> "Options" in Skype's menu. Find an option "Use port 80 and 443 as alternatives for incoming connection". Make sure that it is de-selected. 5. Left-click the gauge, then select Apache -> Apache Modules -> Rewrite Module. The gauge will flick to yellow, and then return to white. 6. Left-click the gauge, then select MySQL -> my.ini. At the very bottom of the file, and add the following to a new line (without the quotes): "lower_case_table_names = 2". Save the file, close Notepad and left-click the gauge, and selected 'Restart all services'. This is used to ease the transition between a Windows-based install and a Linux-based install where case-sensitivity is important. ## Install SilverStripe * [Download](http://silverstripe.org/download) the latest SilverStripe installer package * Unpack the archive into `C:\wamp\www` * Rename the unpacked directory from `C:\wamp\www\silverstripe-vX.X.X` to `C:\wamp\www\silverstripe` * Visit `http://localhost/silverstripe` - you will see SilverStripe's installation screen. * You should be able to click "Install SilverStripe" and the installer will do its thing. It takes a minute or two. * Once the installer has finished, visit `http://localhost/silverstripe`. You should see your new SilverStripe site's home page. ## Troubleshooting Vista's security controls can cause issues. If you have installed on Vista but you're getting errors, there is a chance that SilverStripe does not have sufficient permissions. Right clicked on the installation folder and go to Permissions > Security > Users > Advanced and give the user full control.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-webserver.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-webserver.md
1,044
1,758,118,090
en
# Installation on a WebServer These instructions show you how to install SilverStripe on any web server. For additional information about installing SilverStripe on specific operation systems, refer to: * [Installation on a Windows Server](http://doc.silverstripe.com/doku.php?id=installation-on-windows) * [Installation on OSX](http://doc.silverstripe.com/doku.php?id=installation-on-mac-osx) ## Installation Steps * [Download](http://silverstripe.org/download) the installer package * Make sure the webserver has MySQL and PHP support. See [Server Requirements](/server-requirements) for more information. * Unpack the installer somewhere into your web-root. Usually the www folder or similar. * Visit your Sites Domain or IP Address in your webbrowser * You will be presented with a form where you enter your MySQL login details and are asked to give your site a 'project name' and the default login details. Fill this out and press the button. * After a couple of minutes, your site will be set up. Visit your Site and Enjoy!
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-mac-osx.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-mac-osx.md
2,081
1,758,118,090
en
# Installation On Mac OSX using MAMP This topic covers setting up your Mac as a Web Server and installing SilverStripe. ## Setting Up MAMP While OSX Comes bundled with PHP and Apache (Thanks Apple!) Its not quite ideal for SilverStripe so for setting up a webserver on OSX we suggest using MAMP - http://www.mamp.info/en/index.php. If you want to use the default OSX PHP version then you will need to recompile your own versions of PHP with GD so you can probably work out how to Install SilverStripe! but for those normal folk you want to go download the latest and greatest [MAMP Version](http://www.mamp.info/en/download.html) and run the installer. Once you have downloaded and Installed MAMP start the Application and Make sure everything is running by clicking the MAMP icon. Under `Preferences -> PHP` make sure Version 5 is Selected. Open up `/Applications/MAMP/conf/PHP5/php.ini` and make the following configuration changes: memory_limit = 64M Once you make that change open the MAMP App Again by clicking on the MAMP Icon and click Stop Servers then Start Servers - this is so our changes to the php.ini take effect. ## Installing SilverStripe Okay! Hard part done. Now for the fun!. [Download](http://silverstripe.org/download) the latest SilverStripe installer package. Copy the tar.gz file to the 'Document Root' for MAMP - By Default its `/Applications/MAMP/htdocs`. Don't know what your Document Root is? Open MAMP Click `Preferences -> Apache`. Extract the tar.gz file to a folder, e.g. `silverstripe/` (you always move the tar.gz file first and not the other way around as SilverStripe uses a '.htaccess' file which is hidden from OSX so if you move SilverStripe the .htaccess file won't come along. Now lets run the web-based SilverStripe installer! Open your web browser and go to `http://localhost:8888/silverstripe/`. Enter your database details - by default with MAMP its user `root` and password `root` and select your account details. Click "Check Details". Once everything is sorted hit Install! and Voila you have SilverStripe installed
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
master/cms/docs/en/topics/installation/installation-on-windows-pi.md
NARKOZ__silverstripe-doc-restructuring/master/cms/docs/en/topics/installation/installation-on-windows-pi.md
2,446
1,758,118,090
en
##### Installation on Windows using Web Platform Installer ![](http://doc.silverstripe.com/assets/windows.png) (Windows XP, 2003, 2008, Vista and 7) ##### Installing SilverStripe * Download and run Microsoft Web Platform Installer (WebPI): [![](http://www.silverstripe.org/assets/downloads/webpi/wpiBadgeGreen.png)](http://www.microsoft.com/web/gallery/install.aspx?appsxml=www.microsoft.com%2fweb%2fwebpi%2f2.0%2fWebApplicationList.xml&amp;appid=105) * In WebPI, select 'SilverStripe' from the 'Content Management System' link * Select install. It will install dependancies like MySQL and PHP if you don't have these installed already. * Type in the questions it asks you, such as the username/password you set in the above MySQL installation: * Everything should be installed, with you seeing the initial webpage * And you can log-in to the CMS ##### Important: Installation issue on XP After you've installed SilverStripe on XP using WebPI. You'll need to make a configuration change to get it working. Specifically, you need to configure XP not to check that a script file exists before executing the script. This is necessary for URLs of the form http://localhost/silverstripe/index.php/about-us/ to work. * Open IIS Administrator * Expand the local computer tree node * Expand the Web Sites tree node * Right click on "Default Web Site" and select "Properties" * Select the "Home Directory" Tab. * Click the "Configuration Button towards the bottom on the right * Select the "Mappings" Tab * Find the .php mapping, select it and click the "Edit" button * Make sure the check box "Check that file exists" is cleared. * Hit OK's all the way back up and restart IIS ##### Support * http://www.silverstripe.org/installing-on-windows-now-easier-thanks-to-microsoft-web-platform-installer/ (This shows a beta version of the software) * Microsoft Forum: http://forums.iis.net/1155.aspx * SilverStripe Installation Issues Forum: http://silverstripe.org/installing-silverstripe/ ##### Screenshots of this installation process ![](_images/webpi-2-a-silverstripe-choice.png) ![](_images/webpi-2-b-dependencies.png) ![](_images/webpi-2-c-downloading-and-installaing.png) ![](_images/webpi-2-d-installer-questions-step1.png) ![](_images/webpi-2-e-installer-questions-step2.png) ![](_images/webpi-2-f-success-message.png) ![](_images/webpi-2-g-silverstripe-homepage.png) ![](_images/webpi-2-h-cms-interface-working.png)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
rendering/README.md
NARKOZ__silverstripe-doc-restructuring/rendering/README.md
634
1,758,118,094
en
This folder is for bits of code to help in the rendering of the markdown extra format plus extensions. MarkdownUltra_Parser.php implements a sub-class of MarkdownExtra_Parser, implemented in PHP Markdown Extra. It handles extended syntax, and alters the rendering for certain features. Specific features handled at present: * Code blocks using ~~~ notation can be extended with a language specifier {lang}, which generates markup that can be interpreted by syntaxhighlighter 2.1 (in javascript). (It doesn't include the libraries or css, just adds to the markup. The container needs to add the libraries and css as required.)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/README.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/README.md
3,930
1,758,616,406
en
# SilverStripe Documentation Restructuring Project This is a temporary repository for developer documentation about the SilverStripe framework, currently located at [http://doc.silverstripe.org]. *Note: This repository is used for collaboration during the restructuring phase, and will move elsewhere afterwards* * [Mailinglist](http://groups.google.com/group/silverstripe-documentation) * [Planning wiki page](http://doc.silverstripe.org/tmp:documentation-restructuring) * [TODO list and bugtracker](http://open.silverstripe.org/query?status=inprogress&status=new&status=replyneeded&status=reviewed&component=Documentation&order=priority&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component) ## Contact * Documentation questions: Ingo Schommer (ingo at silverstripe dot com) * Markdown Conversion: Mark Stephens (mark at silverstripe dot com) ## Contributing ### Requirements You'll need to [install git](http://help.github.com/git-installation-redirect), which is quite straightforward on most operating systems. To edit the files, you just need a text editor. They're written in [Markdown](http://daringfireball.net/projects/markdown/), which many editors have syntax highlighting for (e.g. through the [Textmate plugin](http://github.com/textmate/markdown.tmbundle)). To preview changes, you will need to run a local webserver capable of running SilverStripe. [XAMPP](http://www.apachefriends.org/en/xampp.html) is a good option. ### Folders * `master`: The new markdown files - please edit in here * `scripts`: Helper scripts for conversion and file management ### Forking the project You can **fork** this project within github, as described on [help.github.com](http://help.github.com/forking/). This fork will show up on your own github profile, and can be checked out to your local machine. You don't need a webserver on there, or run any project-specific scripts. Merging back *pull requests* can either be done [straight on github](http://github.com/chillu/silverstripe-doc-restructuring/forkqueue) (for simple cases), or through `git pull` commands (see [guide](http://github.com/guides/pull-requests)). ### Documentation Guidelines Its important to read the [documentation guidelines](http://github.com/chillu/silverstripe-doc-restructuring/blob/master/master/cms/docs/en/misc/contributing.md), in order to keep a consistent writing and formatting style. We use a customized version of [Markdown](http://daringfireball.net/projects/markdown/syntax) and [Markdown Extra](http://michelf.com/projects/php-markdown/extra/) called "[ss-markdown](http://github.com/chillu/silverstripe-doc-restructuring/blob/master/master/cms/docs/en/misc/ss-markdown.md)" ### Previewing your changes The preview/ directory contains a SilverStripe site that you can visit to preview what the documentation site will look like. You will need to create a `_ss_environment.php` file in the root of your project or in the directory above. Here is a minimal one. Alter the database settings to suit your set-up. <?php define('SS_ENVIRONMENT_TYPE', 'dev'); define('SS_DATABASE_SERVER', 'localhost'); define('SS_DATABASE_USERNAME', 'root'); define('SS_DATABASE_PASSWORD', ''); If you have check out silverstripe-doc-restructuring into your webroot, you should be able to visit a URL such as http://localhost/silverstripe-doc-restructuring/preview/ to preview your changes. ### Contributing your changes After **pushing your changes** to your own github fork, you can send us **pull requests**. ## Obsolete actions The following scripts should no longer be used, as they were designed for an earlier stage in the project. ### Import DokuWiki files Note: This is only possible by SilverStripe staff. scp -P 2222 -R <username>@doc.silverstripe.org:/sites/ss2doc/www/assets/data/pages/ input/ ### Convert to Markdown files cd scripts php TranslateSSDocs.php
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/cms/tests/salad/README.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/cms/tests/salad/README.md
739
1,758,616,406
en
# Tests # Given I click on the "Tab Name" tab Given I close window and go back to clean state Given I fill out the log in form with user "user" and password "password" Given I get a permission denied error Given I go to the draft site Given I log in as Fred Given I log in as user Given I log into the CMS as [email protected] Given I log out Given I visit admin/security Given I wait for a status message Given I wait for a success message Given a "Blog" page called "News" as a child of "Blogs" Given a "Publishers" group Given a top-level "BlogPage" page called "News" Given a user called "Fred" in the "Authors" group Given the "News" page can be edited by the "Publishers" group Given the site can be edited by the "Publishers" group
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphire/thirdparty/behaviour/README.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphire/thirdparty/behaviour/README.md
3,664
1,758,616,407
en
# Introduction Behaviour-driven JavaScript library, customized for usage in SilverStripe CMS. Caution: Seriously outdated, consider using [http://github.com/hafriedlander/jquery.entwine](jQuery.entwine) and [http://api.jquery.com/live/](jQuery.live) instead. # Author * Sam Minnee (sam at silverstripe dot com) # Requirements * Custom Prototype 1.4 RC3 (see `sapphire/thirdparty/prototype/prototype.js`) # Tutorial In Sapphire, I've tried to make Javascript development a lot more well-structured. It's very easy to write spaghetti, but this ultimately prevents maintainability. This page is a guide to better Javascript. (hopefully). ## Required includes To use everything mentioned here, first include jsparty/behaviour.js and jsparty/prototype.js. This is a lot of overhead, I know, and producing a leaner core file is definitely on the to do list! ## Class creation and inheritance Classes in Javascript are normally too voodoo to be consistently applied. I've created some libraries to help this. * Class.create() will return a new class. * Class.extend(parentClassName) will return a class that extends form the parent class. * Class.extend(parentClass1).extend(parentClass2) will perform multiple inheritance. Once we've created our classes, then what? You should define the prototype, as indicated below. The initialize method acts as the constructor. The parent constructor is automatically called **before** the child constructor. If you would like to access a parent class' method within a child class, you can refer to this.ParentClassName.methodName(). This is useful if you've overloaded the method but want to base its functionality on the parent method. ### Automatic instantiation This is where things get a even more fruity. We have the power to automatically configure DOM objects - the tags within your HTML - to automatically act as your. This lets you build "intelligence" into the elements on your page - not only overriding event handlers, but creating methods that can be called by other objects throughout the application. Although my experience so far is a little limited, it seems as though this is a much cleaner way of coding our javascript. The thing to remember - the thing which differs from many other Javascript coding styles - is that the DOM object and the "control" object **are one and the same**. Each class will have an applyTo() method. This method can be passed either a **CSS selector** or an element. If you call applyTo() before the page is loaded, the class will be applied in the window.onload() event. #### Example here's how you roll it all together in an example. Resizable = Class.create(); onmousedown : function() { ... }, onmouseup : function() { ... } } SidePanel = Class.create(); SidePanel.prototype = { initialize : function() { ... }, onshow : function() { ... }, onresize : function() { ... }, ajaxGetPanel : function(onComplete) { ... }, afterPanelLoaded : function() { } } VersionList = Class.extend('SidePanel').extend('Resizable'); VersionList.prototype = { afterPanelLoaded : function() { ... } } VersionItem.applyTo('#versions//holder tbody tr'); VersionAction.applyTo('#versions//holder p.pane//actions'); VersionList.applyTo('#versions//holder'); CAUTION: If you want to to have true instance-variables, specify them in initialize() instead of making a new object-property. Resizable = Class.create(); staticVar: "the same in each instance", initialize: function() { this.instanceVar = "current dom-id: " + this.id; } } Resizable.applyTo("div.multipleElements");
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphire/javascript/tree/README.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphire/javascript/tree/README.md
3,644
1,758,616,406
en
# JavaScript Tree Control ## Maintainers * Sam Minnee (sam at silverstripe dot com) ## Features * Build trees using semantic HTML and unobtrusive JavaScript. * Style the tree to suit your application you with CSS. * Demo: http://www.silverstripe.org/assets/tree/demo.html ## Usage The first thing to do is include the appropriate JavaScript and CSS files: <code html> <link rel="stylesheet" type="text/css" media="all" href="tree.css" /> <script type="text/javascript" src="tree.js"></script> </code> Then, create the HTML for you tree. This is basically a nested set of bullet pointed links. The "tree" class at the top is what the script will look for. Note that you can make a tree node closed to begin with by adding `class="closed"`. Here's the HTML code that I inserted to create the demo tree above. <code html> <ul class="tree"> <li><a href="#">item 1</a> <ul> <li><a href="#">item 1.1</a></li> <li class="closed"><a href="#">item 1.2</a> <ul> <li><a href="#">item 1.2.1</a></li> <li><a href="#">item 1.2.2</a></li> <li><a href="#">item 1.2.3</a></li> </ul> </li> <li><a href="#">item 1.3</a></li> </ul> </li> <li><a href="#">item 2</a> <ul> <li><a href="#">item 2.1</a></li> <li><a href="#">item 2.2</a></li> <li><a href="#">item 2.3</a></li> </ul> </li> </ul> </code> Your tree is now complete! ## How it works Obviously, this isn't a complete detail of everything that's going on, but it gives you an insight into the overall process. ### Starting the script In simple situations, creating an auto-loading script is a simple matter of setting window.onload to a function. But what if there's more than one script? To this end, we created an appendLoader() function that will execute multiple loader functions, including a previously defined loader function ### Finding the tree content Rather than write a piece of script to define where your tree is, we've tried to make the script as automatic as possible - it finds all ULs with a class name containing "tree". ### Augmenting the HTML Unfortunately, an LI containing an A isn't sufficient for doing all of the necessary tree styling. Rather than force people to put non-semantic HTML into their file, the script generates extra `<span>` tags. So, the following HTML: <code html> <li> <a href="#">My item</a> </li> </code> Is turned into the more ungainly, and yet more easily styled: <code html> <li> <span class="a"><span class="b"><span class="c"> <a href="#">My item</a> </span></span></span> </li> </code> Additionally, some helper classes are applied to the `<li>` and `<span class="a">` elements: * `"last"` is applied to the last node of any subtree. * `"children"` is applied to any node that has children. ### Styling it up Why the heck do we need 5 styling elements? Basically, because there are 5 background-images to apply: * li: A repeating vertical line is shown. Nested <li> tags give us the multiple vertical lines that we need. * span.a: We overlay the vertical line with 'L' and 'T' elements as needed. * span.b: We overlay '+' or '-' signs on nodes with children. * span.c: This is needed to fix up the vertical line. * a: Finally, we apply the page icon. ### Opening / closing nodes Having come this far, the "dynamic" aspect of the tree control is very trivial. We set a "closed" class on the `<li>` and `<span class="a">` elements, and our CSS takes care of hiding the children, changing the - to a + and changing the folder icon.
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/README.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/README.md
541
1,758,616,407
en
# Documentation Viewer Module ## Maintainer Content * Will Rossiter (Nickname: willr, wrossiter) <[email protected]> ## Requirements * Tested on 2.4 and trunk ## Summary Read nested documentation files from the /docs/ folder in modules. To read documentation go to yoursite.com/dev/docs/. It is likely this will be integrated into the core in future versions once it is polished. For more documentation on how to use the module please read /docs/Writing-Documentation.md (or via this in /dev/docs/sapphiredocs/Writing-Documentation)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/test.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/test.md
346
1,758,616,407
en
## english test test 1.0 [link: subfolder index](subfolder/) [link: subfolder page](subfolder/subpage) [link: with anchor](/test#anchor) [link: http](http://silverstripe.org) [link: api](api:DataObject) [api:DataObject::$has_one] :::php code block with multiple lines Normal text after code block code block without formatting prefix
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/index.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/index.md
27
1,758,616,407
en
## english test index 1.0
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/subfolder/subpage.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/subfolder/subpage.md
297
1,758,616,407
en
[link: absolute index](/) [link: absolute index with name](/index) [link: relative index](../) [link: relative parent page](../test) [link: absolute parent page](/test) ![relative image link](_images/image.png) ![parent image link](../_images/image.png) ![absolute image link](/_images/image.png)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/subfolder/subsubfolder/subsubpage.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/en/subfolder/subsubfolder/subsubpage.md
169
1,758,616,407
en
[link: absolute index](/) [link: relative index](../) [link: relative parent page](../subpage) [link: relative grandparent page](../../test) [link: absolute page](/test)
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/de/test.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/de/test.md
25
1,758,616,407
en
## german test test 1.0
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/de/index.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs/de/index.md
26
1,758,616,407
en
## german test index 1.0
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs-2/en/test.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs-2/en/test.md
0
1,758,616,407
en
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs-2/en/index.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/tests/docs-2/en/index.md
27
1,758,616,407
en
## english test index 2.0
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/docs/en/index.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/docs/en/index.md
982
1,758,616,407
en
# Sapphire Documentation Module This module has been developed to read and display content from markdown files in webbrowser. It is an easy way to bundle end user documentation within a SilverStripe installation. See [Writing Documentation](dev/docs/en/sapphiredocs/writing-documentation) for more information on how to write markdown files which are available here. To include your docs file here create a __docs/en/index.md__ file. You can also include custom paths and versions. To configure the documentation system the configuration information is available on the [Configurations](dev/docs/en/sapphiredocs/configuration-options) page. ## Setup By default, the documentation is available in `dev/docs`. If you want it to live on the webroot instead of a subfolder, add the following configuration to your `mysite/_config.php`: DocumentationViewer::set_link_base(''); Director::addRules(1, array( '$Action' => 'DocumentationViewer', '' => 'DocumentationViewer' ));
2025-09-24T14:46:58.085215
NARKOZ
silverstripe-doc-restructuring
NARKOZ__silverstripe-doc-restructuring
silverstripe-doc-restructuring-master/preview/sapphiredocs/docs/en/Configuration-Options.md
NARKOZ__silverstripe-doc-restructuring/silverstripe-doc-restructuring-master/preview/sapphiredocs/docs/en/Configuration-Options.md
1,013
1,758,616,407
en
# Helpful Configuration Options DocumentationService::set_ignored_files(array()); If you want to ignore (hide) certain file types from being included. DocumentationService::set_automatic_registration(false); By default the documentation system will parse all the directories in your project and include the documentation. If you want to only specify a few folders you can disable it with the above. DocumentationService::register($module, $path, $version = 'current', $lang = 'en', $major_release = false) Registers a module to be included in the system (if automatic registration is off or you need to load a module outside a documentation path). DocumentationService::unregister($module, $version = false, $lang = false) Unregister a module (removes from documentation list). You can specify the module, the version and the lang. If no version is specified then all folders of that lang are removed. If you do not specify a version or lang the whole module will be removed from the documentation.
2025-09-24T14:46:58.085215