Commit Graph

140 Commits

Author SHA1 Message Date
micmania1
b89ab1eb16 Added SSViewer::get_templates_by_class() to make the functionality in LeftAndMain::getTemplatesWithSuffix() more open. 2013-12-01 07:42:37 +00:00
Cam Spiers
14486902fb Allow users to extend the SSTemplateParser by defining open & closed blocks
Currently the only way the extend SSTemplateParser is to define a class
extension of it and then tell the injector component to use your new
custom class. This new change allows a user to define new "open blocks"
and "closed blocks" for SSTemplateParser to use without needing to
recompile the real SSTemplateParser class.

The following example shows how the functionality can be used
to add a new <% minify %>…<% end_minify %> syntax to the template parser

In a config.yml file, define the new minify closed block to call the
static function "Minifier::minify"

```
Injector:
	SSTemplateParser:
		properties:
			closedBlocks:
				minify: "Minifier::minify"
```

Define a new class with the minify static method that returns the new
template code when regenerating templates:

```
class Minifier {
    public static function minify(&$res) {
        return <<<PHP
{$res['Template']['php']}
\$val = zz\Html\HTMLMinify::minify(\$val, array('optimizationLevel' => zz\Html\HTMLMinify::OPTIMIZATION_ADVANCED));
PHP;
    }
}
```
2013-11-04 14:24:58 +13:00
Ingo Schommer
2c145cd454 API JS i18n files with short locale names, generated by build task
The files are uploaded to transifex.com now, which means we needed
to consolidate the file names (= locales). Since Transifex doesn't allow
arbitrary JavaScript structures, we're using an intermediary JSON
format which gets transformed into the JS used by the framework.

See b59f3858af for generator logic.

Fixes https://github.com/silverstripe/silverstripe-framework/issues/2499
2013-10-25 12:05:46 +02:00
Cam Spiers
ac418ce99e Feature to allow that changing the SSTemplateParser through the Injector system
The motivation for this was to allow module developers to change what parser is used to parse SilverStripe templates.
This change enables people to compile their own version of the SilverStripe template parser and use it without modifying core files.
2013-10-18 12:42:39 +13:00
Simon Welsh
151baeede1 Correct line length and indentation 2013-08-21 18:54:05 +12:00
Jörn Röder
e2a43961d0 fixed undefined offset #2276 2013-07-28 19:39:40 +02:00
Jeremy Thomerson
f6ff39369f FEATURE: <% include %> inherits iterator scope of parent template 2013-07-07 12:39:42 +00:00
Ingo Schommer
429bbc5223 Merge pull request #2137 from jthomerson/pulls/fix_viewable_data_wrapped_value
FIX: ViewableData wasn't setting values when using default cast
2013-07-02 00:40:56 -07:00
Hamish Friedlander
ae3e3f3b44 FIX Arguments to method calls reseting scope 2013-06-25 17:35:16 +12:00
CheeseSucker
b52087105c FIX: ViewableData::obj() would sometimes return an empty object
For instance, this happens when these criteria are met:
  1) No casting has been specified for a method in $casting.
  2) A template accesses the field without any casting
  3) Any casts by the template will now yield an empty object.

After a brief look at the commit history, it can seem like this bug is several years old, unless it is a side-effect of other changes in the code.

== Steps to reproduce ==
Add two methods to be accessed by a template. Make sure you do not define an entry in $casting for them:
	public function Testus() {
		return "Te<x>t1";
	}

	public function Testus2() {
		return "Te<x>t2";
	}

Add this to a template:
	<p>
		First access:<br />
		"$Testus" : "$Testus.XML"<br />
		"$Testus2.XML" : "$Testus2"<br />
	</p>
	<p>
		Second access:<br />
		"$Testus" : "$Testus.XML"<br />
		"$Testus2.XML" : "$Testus2"<br />
	</p>

Open the page in a browser, and you will get:
 First access:
"Tet1" : ""
"Te<x>t2" : "Tet2"

Second access:
"Tet1" : ""
"" : "Tet2"

We see that any cast can yield an empty string.
2013-06-21 16:16:49 +00:00
Sam Minnee
526b40414a FIX: Ensure that actions inferred from templates with the "_action" suffix also respect allowed_actions.
FIX: Ensure SSViewer::hasTemplate() is aware of themes.

To do this, RequestHandler::definingClassForAction() has been created, splitting out the code that looks up the class that defines a given action into its own method.  This is then overridden in Controller to look at templates.
2013-06-19 20:11:50 +12:00
Jeremy Thomerson
4c0b452c0f ENHANCEMENT: allow overridable JS/CSS minification
This allows someone to extends Requirements_Backend and plug in their own minification
of files, including CSS minification.  It also allows them to override whether or not
the header comment is written for each file.
2013-06-04 12:52:11 +00:00
Colin Richardson
b2934d7ebf FIX: exclude directory from available themes when underscore is first character
Change FALSE to lowercase
2013-05-23 16:49:35 +01:00
Ingo Schommer
3b02d22989 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	dev/CsvBulkLoader.php
2013-05-09 10:34:20 +02:00
Ingo Schommer
cef955c8b9 Removed stray ampersand in Requirements (fixes #1809)
Only happens with suffix_requirements=true
2013-04-30 00:35:25 +02:00
Zauberfisch
034f575003 MINOR: if no doctyle is set, include comments inside <html>
MINOR: if <html> tag is inside a html comment do not add a comment
2013-04-22 18:16:09 +00:00
Zauberfisch
94b37f9c85 MINOR: moved includeDebuggingComments logic into own method to allow separated tests 2013-04-22 14:12:43 +00:00
Zauberfisch
7c66e8e7a2 API: try to place source_file_comments after doctype instead of html 2013-04-22 13:53:20 +00:00
Sam Minnee
eb583c5f14 NEW: Added DataObject::getQueriedDatabaseFields() as faster alternative to toMap()
API: CompositeDBField::setValue() may be passed an object as its second argument, in addition to array.

These changes provide a 15% - 20% performance improvement, and as such justify an small API change in the 3.0 branch. It will likely affect anyone who has created their own composite fields, which is fortunately not all that common.
2013-04-21 13:39:11 +12:00
s-m
acf2ff8ce6 BUG: Fix for #1487
The parser could sometimes generate invalid code if the
source-file-comments were enabled, this moves the comments outside the
html-tag to circumvent these problems, update test as well.
2013-04-15 19:54:41 +02:00
s-m
29e6bd513c BUG: Allow empty else- and else_if-blocks
This fix allows empty else and else-if blocks to be processed, fixes #1660
2013-04-10 16:17:44 +02:00
s-m
6a95db0eff API: Support inequalities in templates
This adds support for <, <=, >, >= in templates
2013-04-08 17:07:39 +02:00
Ingo Schommer
7121fc3f85 FIX Config isolation in Director::test() 2013-04-07 23:59:10 +02:00
Ingo Schommer
828ac7fe4f API Replaced SSViewer.custom_theme with SSViewer.theme_enabled
Since we can't influence the setting of configuration values,
we also can't set/unset the 'custom_theme' value based on which
theme is set. This means the 'custom_theme' value goes stale,
and we can't rely on it e.g. in FilesystemPublisher.

The 'theme_enabled' toggle is a cleaner solution to the same problem,
since the 'custom_theme' was really just a way to remember the original
theme, while still disabling it. The toggle makes this more explicit,
but also requires users of the 'theme' setting to check for it.
2013-04-07 23:59:10 +02:00
s-m
14de34cb9b Sync template-parser files
The template-parser files were not in sync, there were some lines added
in SSTemplateParser.php from 3334eafcb1
and 0a9f3b75a9 , I readded those parts
into the SSTemplateParser-include-file and recreated the
SSTemplateParser.php to get to a synced state...
2013-04-05 19:12:54 +02:00
Ingo Schommer
0242686a7a Requirements acces to files with query strings (fixes #7735)
Originally authored by florian.thoma, tests added
by Ingo Schommer. Also removed query params from
file paths before calling mtime() on it.

See https://github.com/silverstripe/sapphire/pull/1023
2013-04-03 16:39:59 +02:00
Ingo Schommer
3334eafcb1 API Marked statics private, use Config API instead (#8317)
See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
2013-03-24 17:20:53 +01:00
Ingo Schommer
0a9f3b75a9 Fixed deprecated usage of <% control %> 2013-03-19 12:58:14 +01:00
Hamish Friedlander
743a186c32 API Make SSViewer#process return HTMLText not string
This means that you dont have to worry about casting it
as HTMLText again when using the result in a template or other context

However in some situations code might be assuming it can
check with is_string, in which case you now need to use instanceof HTMLText
2013-03-14 12:49:03 +13:00
Hamish Friedlander
9bd6dd9ade API Make default_cast Text and not HTMLText 2013-03-14 12:49:03 +13:00
Hamish Friedlander
d2650bbc44 NEW Disable shortcodes in $Layout and $Content in SSViewer 2013-03-14 12:49:03 +13:00
g4b0
2f16951634 BUG: ampersand escaping 2013-03-11 09:58:14 +01:00
miiihi
5af35a89ce ENHANCEMENT Allow multiline comments in SS3 templates 2013-03-07 18:45:07 +01:00
Hamish Friedlander
7efae6b95f Merge remote-tracking branch 'origin/3.0' into 3.1 2013-02-18 14:31:57 +13:00
Simon Welsh
be8482aa73 Merge pull request #1173 from ajshort/include-object-argument
BUG: Pass named include argument as objects.
2013-02-13 23:44:29 -08:00
ajshort
d3629be344 BUG: Pass named include argument as objects.
This means you can pass objects such as lists as named parameters, not
just strings.
2013-02-14 18:31:40 +11:00
Ingo Schommer
d969e29d00 API Require ADMIN for ?showtemplate=1 2013-02-12 23:26:04 +01:00
Ingo Schommer
b44720179c Merge pull request #1180 from mateusz/css-combining-media
API Add possibility to combine media-targeting stylesheets.
2013-02-12 14:13:45 -08:00
Mateusz Uzdowski
53feb3a5ae API Add possibility to combine media-targeting stylesheets. 2013-02-13 11:04:05 +13:00
ajshort
a4096ecc70 Add a self method to the SSViewer scope.
This returns the current object, and resets the scope.
2013-02-11 17:53:14 +11:00
Ingo Schommer
14a56c18e9 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	control/Director.php
2013-02-07 21:45:16 +01:00
Ingo Schommer
b381e9933d Include "media" attr for module customCSS() (fixes #8219) 2013-02-01 10:23:16 +01:00
Ingo Schommer
5f8115f4c7 BUGFIX Hard fallback to en_US.js in Requirements
Ideally we'll have region-less locales like en.js as fallbacks,
but for now this prevents the UI becoming non-operational
e.g. when both i18n::set_locale() and i18n::default_locale()
are set to 'en_NZ'.
2013-01-09 22:31:19 +01:00
Ingo Schommer
618a3d0314 Requirements acces to files with query strings (fixes #7735)
Originally authored by florian.thoma, tests added
by Ingo Schommer. Also removed query params from
file paths before calling mtime() on it.

See https://github.com/silverstripe/sapphire/pull/1023
2012-12-18 01:01:19 +01:00
Matt Lewis
af6eccea96 Fixing typo in Requirements allowing access to files requested with query strings 2012-12-18 00:53:54 +01:00
Simon Welsh
b0121b541c Add codesniffer that ensures indentation is with tabs. 2012-12-12 17:33:31 +13:00
Simon Welsh
fc5dd2994c Add codesniffer that ensures indentation is with tabs. 2012-12-12 00:12:11 +13:00
Ingo Schommer
d92258da8f Allow calling SSViewer_Scope on empty sets
Specifically fixes a bug where a SelectionGroup_Item
without a "child" field causes fatal errors.
2012-12-11 11:07:00 +01:00
Ingo Schommer
c55c7c33f8 Merge branch '3.0'
Conflicts:
	admin/code/CMSProfileController.php
	composer.json
	tests/model/DataObjectTest.php
2012-11-22 23:51:28 +01:00
Sander van Dragt
8f89aa9171 BUG only call filemtime if file exists
Added file_exists check before calling filemtime as this results in
'filemtime(): stat failed'
2012-11-21 13:11:53 +13:00