summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/editor-bind-code.html71
-rw-r--r--internal/utils.php39
2 files changed, 110 insertions, 0 deletions
diff --git a/internal/editor-bind-code.html b/internal/editor-bind-code.html
new file mode 100644
index 0000000..915d55c
--- /dev/null
+++ b/internal/editor-bind-code.html
@@ -0,0 +1,71 @@
+<!-- Editor deffered loading -->
+<link href="http://cdn.aloha-editor.org/latest/css/aloha.css" type="text/css" rel="stylesheet" />
+<script type="text/javascript" src="http://cdn.aloha-editor.org/latest/lib/vendor/jquery-1.7.1.js"></script>
+<script type="text/javascript" src="http://cdn.aloha-editor.org/latest/lib/require.js"></script>
+<script>
+ var Aloha = window.Aloha || ( window.Aloha = {} );
+
+ Aloha.settings = {
+ locale: 'fr',
+ plugins: {
+ format: {
+ config : [ 'b', 'i','sub','sup'],
+ editables : {
+ // no formatting allowed for title
+ '#title' : [ ],
+ // formatting for all editable DIVs
+ 'div' : [ 'b', 'i', 'del', 'sub', 'sup' ],
+ // content is a DIV and has class .article so it gets both buttons
+ '.article' : [ 'b', 'i', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat']
+ }
+ },
+ list: {
+ // all elements with no specific configuration get an UL, just for fun :)
+ config : [ 'ul' ],
+ editables : {
+ // Even if this is configured it is not set because OL and UL are not allowed in H1.
+ '#title' : [ 'ol' ],
+ // all divs get OL
+ 'div' : [ 'ol' ],
+ // content is a DIV. It would get only OL but with class .article it also gets UL.
+ '.article' : [ 'ul' ]
+ }
+ },
+ link: {
+ config : [ 'a' ],
+ editables : {
+ // No links in the title.
+ '#title' : [ ]
+ }
+ }
+ },
+ sidebar: {
+ disabled: false
+ }
+ };
+</script>
+
+<script type="text/javascript" src="http://cdn.aloha-editor.org/latest/lib/aloha.js"
+ data-aloha-plugins="common/ui,
+ common/format,
+ common/table,
+ common/list,
+ common/link,
+ common/highlighteditables,
+ common/block,
+ common/undo,
+ common/image,
+ common/contenthandler,
+ common/paste,
+ common/commands,
+ common/abbr"></script>
+
+<script type="text/javascript">
+Aloha.ready(function() {
+ // mark the editable parts
+ $('#title').aloha();
+ $('#teaser').aloha();
+ $('#content').aloha();
+});
+
+</script>
diff --git a/internal/utils.php b/internal/utils.php
new file mode 100644
index 0000000..c9f8320
--- /dev/null
+++ b/internal/utils.php
@@ -0,0 +1,39 @@
+<?php
+ function sanitize($arg_array, $arg_key, $replace_chars_re, $default_value) {
+ if ( ! array_key_exists($arg_key, $arg_array) ) return $default_value;
+ return preg_replace($replace_chars_re, '_', $arg_array[$arg_key]);
+ }
+
+ function sanitize_ini($ini_path, $array_entry_props) {
+ $arr = parse_ini_file("$ini_path");
+ if ( is_array($arr) ) {
+ foreach ( $arr as $k => $v ) {
+ if ( array_key_exists($k, $array_entry_props)
+ && array_key_exists('replace_chars_re', $array_entry_props[$k])
+ &&| array_key_exists('default_value', $array_entry_props[$k])
+ ) {
+ $arr[$k] = sanitize($arr, $k,
+ $array_entry_props[$k]['replace_chars_re'],
+ $array_entry_props[$k]['default_value'] );
+ } else {
+ unset($arr[$k]);
+ }
+ }
+ }
+ return $arr;
+ }
+
+ define('SANITIZE_SITE_CONF', array(
+ 'default_page' => array( 'replace_chars_re' => '/[^a-z0-9\/]+/', 'default_value' => 'en/index' ),
+ )
+ );
+
+ define('SANITIZE_PAGE_PROPS', array(
+ 'title' => array( 'replace_chars_re' => '/[^.]+/', 'default_value' => '(missing title in props.ini)' ),
+ 'template' => array( 'replace_chars_re' => '/[^a-z0-9]+/', 'default_value' => 'default' ),
+ 'layout' => array( 'replace_chars_re' => '/[^a-z0-9]+/', 'default_value' => 'article' ),
+ )
+ );
+
+?>
+