aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-13 17:46:45 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-13 17:46:45 +0000
commitece80595836be086201629824bceeae05892cd55 (patch)
tree9171c63c657bd4a511f8f1e4474eef96418d71f8
parent2ac6d8f4d1738d299dab4fc5ac0cd28f7c3c00b5 (diff)
downloadelgg-ece80595836be086201629824bceeae05892cd55.tar.gz
elgg-ece80595836be086201629824bceeae05892cd55.tar.bz2
Removed ECML from Site Pages.
git-svn-id: http://code.elgg.org/elgg/trunk@5721 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/sitepages/README.txt114
-rw-r--r--mod/sitepages/languages/en.php30
-rw-r--r--mod/sitepages/manifest.xml6
-rw-r--r--mod/sitepages/sitepages_functions.php130
-rw-r--r--mod/sitepages/start.php48
-rw-r--r--mod/sitepages/views/default/sitepages/keywords.php30
-rw-r--r--mod/sitepages/views/default/sitepages/keywords/user_list.php4
7 files changed, 57 insertions, 305 deletions
diff --git a/mod/sitepages/README.txt b/mod/sitepages/README.txt
index b2c36c71e..3080db7a0 100644
--- a/mod/sitepages/README.txt
+++ b/mod/sitepages/README.txt
@@ -3,12 +3,10 @@ HTML metatags.
CONTENTS:
1. Overview
- 2. Using Front Page Keywords
- 2.1 Built-in keywords
- 2.2 Entities
- 2.3 Views
- 3. Custom Front Page Keywords
- 4. Hints and Quirks
+ 2. Using ECML on the front pages
+ 2.1 [[login_box]]
+ 2.2 [[site_stats]]
+ 2.3 [[user_list]]
1. OVERVIEW
@@ -17,100 +15,36 @@ CONTENTS:
and Privacy pages, and also allows simple modifications of the logged in
and logged out views, as well as CSS and meta description and tags for SEO.
- The biggest feature of Site Pages is its support for an extensible keyword
- system that allows end-users to quickly add elements to the front page of
- their site.
+2. USING ECML ON THE FRONT PAGES
-2. USING FRONT PAGE KEYWORDS
+ Site Pages supports ECML on the front page and provides the following
+ ECML keywords:
- Keywords are specially formatted strings that can be used on the logged in
- and logged out front pages to include lists of objects, views, or plugin-
- supplied content. All keywords are surrounded by two brackets:
- [[keyword]]. Some keywords, like views and entity lists, take optional
- parameters.
+ [[login_box]] -- A login box. Required on the logged out front page.
+ [[site_stats]] -- Simple site statistics.
+ [[user_list]] -- A list of users.
- When editing the front pages, a list of available keywords appears in the
- sidebar.
+ To learn more about ECML, click the ECML icon below the input fields.
-2.1 BUILT IN KEYWORDS
+2.1 [[login_box]]
+ The Login Box keyword displays a box to let users log in. This view
+ is required on the logged out front page.
- Site Pages includes a few built-in keywords to get you started:
- [[login_box]] - This keyword is required on the logged out page to
- Allow users to log into your site.
- [[site_stats]] - Shows the total members in your site, the currently
- active members, and other fun stuff.
+2.2 [[site_stats]]
+ The Site Stats keyword doesn't do anything yet.
-2.2 Entities
+2.3 [user_list]]
+ The User List keyword displays a list of users and takes the following
+ optional arguments (*default if not passed):
- You can generate a list of entities by using the [[entity]] keyword. This
- keyword takes similar arguments to the elgg_get_entities() function. See
- documentation in that function for a complete list.
+ list_type=*new|online|random -- Show new users, users active in the
+ last 10 minutes, or a random selection.
- Additional / changed parameters supported by keywords:
- * owner: The username owner. (You can still use owner_guid)
+ only_with_avatars=*true|false -- Only show users who have uploaded an
+ avatar
- Example: To generate a list of all blog posts by the user named 'admin':
- [[entities: type=object, subtype=blog, owner=admin]]
-
- Example: To show newest group created:
- [[entities: type=object, subtype=group, limit=1]]
-
-
-2.1 Views
-
- Keywords support outputting arbitrary views with the [[view]] keyword and
- supports passing arguments as name=value pairs.
-
- Example: Output a text input field with a default value:
- [[view: input/text, value=This is a test!]]
-
- NB: Do NOT quote the name or values when passing them. Also, as of 1.8
- using commas or = in the name or value is unsupported.
-
-
-3.0 CUSTOM FRONT PAGE KEYWORDS
-
- Plugins can add their own keywords by replying to the 'get_keywords' hook
- of type 'sitepages.' Each keyword must be bound to a valid view. Almost
- all functionality in custom keywords could be implemented using the 'view'
- keyword, but custom keywords provide a simple way for non-techy users to
- include ready-made views without the fuss of knowing what they're doing.
-
- Custom keywords support arguments in the same format as views and entities.
- These arguments are passed to the custom view via the $vars array. It is
- the responsibility of the custom view to parse these arguments.
-
- The below example creates the 'my_plugin_keyword' keyword that displays the
- view at 'my_plugin/keyword_view.' This is exactly the same as saying
- [[view: my_plugin/keyword_view]] but much simpler for the user.
-
- Example:
- register_plugin_hook('get_keywords', 'sitepages', 'my_plugin_keywords');
-
- function my_plugin_keywords($hook, $type, $value, $params) {
- $value['my_plugin_keyword'] = array(
- 'view' => 'my_plugin/keyword_view',
- 'description' => 'Provides the awesome My Plugin keyword'
- );
-
- return $value;
- }
-
-
-4. HINTS AND QUIRKS
-
- * A custom keyword is slightly more complicated to implement, but is
- much simpler for the end user to use.
-
- * Custom keywords can contain only alphanumeric and the underscore
- character.
-
- * All keywords have limited support for passing arguments but the arguments
- cannot contain '=' or ','. If you need complicated arguments for a custom
- keyword, it's better to split the functionality into multiple keywords and
- views instead of requiring complicated arguments.
-
+ limit=*10 -- Show this many users. \ No newline at end of file
diff --git a/mod/sitepages/languages/en.php b/mod/sitepages/languages/en.php
index 49222d7a3..d42e5425a 100644
--- a/mod/sitepages/languages/en.php
+++ b/mod/sitepages/languages/en.php
@@ -50,32 +50,12 @@ $english = array(
'sitepages:error' => "There has been an error, please try again and if the problem persists, contact the administrator",
/**
- * Key words
+ * ECML
*/
- 'sitepages:keywords_title' => 'Keywords',
- 'sitepages:keywords_instructions' =>
- 'Keywords are replaced with content when viewed. They must be surrounded by
- two square brackets ([[ and ]]). You can build your own or use the ones listed below.
- Hover over a keyword to read its description.',
-
- 'sitepages:keywords_instructions_more' =>
- '
- <p>You can build your own keywords for views and entities.</p>
-
- <p>[[entity: type=type, subtype=subtype, owner=username, limit=number]]<br />
-
- EX: To show 5 blog posts by admin:<br />
- [[entity: type=object, subtype=blog, owner=admin, limit=5]]</p>
-
- <p>You can also specify a valid Elgg view:<br />
- [[view: elgg_view, name=value]]</p>
-
- <p>Ex: To show a text input with a default value:<br />
- [[view: input/text, value=This is a default value]]</p>',
-
- 'sitepages:keywords:login_box' => 'A standard login box. Useful for the logged out content area.',
- 'sitepages:keywords:site_stats' => 'This does not exist yet.',
- 'sitepages:keywords:user_list' => "Lists users. Supports only_with_avatars=TRUE|FALSE, list_type=newest|online|random, limit",
+ 'sitepages:ecml:keywords:login_box' => 'A standard login box. Useful for the logged out content area.',
+ 'sitepages:ecml:keywords:site_stats' => 'This does not exist yet.',
+ 'sitepages:ecml:keywords:user_list' => "Lists users. Supports only_with_avatars=TRUE|FALSE, list_type=newest|online|random, limit",
+ 'sitepages:ecml:views:custom_frontpage' => "The front page view",
);
add_translation('en', $english); \ No newline at end of file
diff --git a/mod/sitepages/manifest.xml b/mod/sitepages/manifest.xml
index 1e14f5800..1ed844b9e 100644
--- a/mod/sitepages/manifest.xml
+++ b/mod/sitepages/manifest.xml
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin_manifest>
<field key="author" value="Curverider" />
- <field key="version" value="1.0" />
- <field key="description" value="Create an about, terms and privacy pages. You can also edit the frontpage if you know a little html/css." />
+ <field key="version" value="1.8" />
+ <field key="description" value="Create about, terms and privacy pages. You can also edit the frontpage if you know a little html/css." />
+ <field key="category" value="official" />
<field key="category" value="customization" />
+ <field key="requires" value="ecml2" />
<field key="website" value="http://www.elgg.org/" />
<field key="copyright" value="(C) Curverider 2008-2010" />
<field key="licence" value="GNU Public License version 2" />
diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php
index baf8e365b..80db39d14 100644
--- a/mod/sitepages/sitepages_functions.php
+++ b/mod/sitepages/sitepages_functions.php
@@ -62,15 +62,12 @@ function sitepages_create_sitepage_object($page_type) {
function sitepages_get_edit_section_content($page_type) {
set_context('admin');
- $keywords = '';
-
$title = elgg_view_title(elgg_echo('sitepages'));
$menu = elgg_view('sitepages/menu', array('page_type' => $page_type));
switch ($page_type) {
case 'front':
$view = 'sitepages/forms/editfront';
- $keywords = elgg_view('sitepages/keywords');
break;
case 'seo':
@@ -86,7 +83,7 @@ function sitepages_get_edit_section_content($page_type) {
$form .= elgg_view($view, array('page_type' => $page_type));
$body = $title . $menu . $form;
- $content = elgg_view_layout('one_column_with_sidebar', $body, $keywords);
+ $content = elgg_view_layout('one_column_with_sidebar', $body);
return $content;
}
@@ -111,131 +108,6 @@ function sitepages_get_page_content($page_type) {
return $content;
}
-
-/**
- * Used to determine how to handle special non-static keywords.
- *
- * @param unknown_type $matches
- * @return html
- */
-function sitepages_parse_view_match($matches) {
- global $CONFIG;
-
- $keyword = $matches[0];
- $type = trim($matches[1]);
- $params_string = trim($matches[2]);
-
- switch ($type) {
- case 'entity':
- $options = sitepages_keywords_parse_entity_params($params_string);
- // must use this lower-level function because I missed refactoring
- // the list entity functions for relationships.
- // (which, since you're here, is the only function that runs through all
- // possible options for elgg_get_entities*() functions...)
- $entities = elgg_get_entities_from_relationship($options);
- $content = elgg_view_entity_list($entities, count($entities), $options['offset'],
- $options['limit'], $options['full_view'], $options['view_type_toggle'], $options['pagination']);
- break;
-
- case 'view':
- // parses this into an acceptable array for $vars.
- $info = sitepages_keywords_parse_view_params($params_string);
- $content = elgg_view($info['view'], $info['vars']);
-
- break;
-
- default:
- // match against custom keywords with optional args
- if (isset($CONFIG->sitepages_keywords[$type])) {
- $keyword_info = $CONFIG->sitepages_keywords[$type];
- $vars = sitepages_keywords_tokenize_params($params_string);
- $content = elgg_view($keyword_info['view'], $vars);
- }
- break;
- }
-
- // if nothing matched return the original string.
- if (!$content) {
- $content = $matches[0];
- }
-
- return $content;
-}
-
-/**
- * Creates an array from a "name=value, name1=value2" string.
- *
- * @param $string
- * @return array
- */
-function sitepages_keywords_tokenize_params($string) {
- $pairs = array_map('trim', explode(',', $string));
- $params = array();
-
- foreach ($pairs as $pair) {
- list($name, $value) = explode('=', $pair);
-
- $name = trim($name);
- $value = trim($value);
-
- // normalize BOOL values
- if ($value === 'true') {
- $value = TRUE;
- } elseif ($value === 'false') {
- $value = FALSE;
- }
-
- // don't check against value since a falsy/empty value is valid.
- if ($name) {
- $params[$name] = $value;
- }
- }
-
- return $params;
-}
-
-/**
- *
- * @param $string
- * @return unknown_type
- */
-function sitepages_keywords_parse_view_params($string) {
- $vars = sitepages_keywords_tokenize_params($string);
-
- // the first element key is the view
- $var_keys = array_keys($vars);
- $view = $var_keys[0];
-
- $info = array(
- 'view' => $view,
- 'vars' => $vars
- );
-
- return $info;
-
-}
-
-/**
- * Returns an options array suitable for using in elgg_get_entities()
- *
- * @param string $string "name=value, name2=value2"
- * @return array
- */
-function sitepages_keywords_parse_entity_params($string) {
- $params = sitepages_keywords_tokenize_params($string);
-
- // handle some special cases
- if (isset($params['owner'])) {
- if ($user = get_user_by_username($params['owner'])) {
- $params['owner_guid'] = $user->getGUID();
- }
- }
-
- // @todo probably need to add more for
- // group -> container_guid, etc
- return $params;
-}
-
/**
* Utility object to store site page information.
*/
diff --git a/mod/sitepages/start.php b/mod/sitepages/start.php
index a1a9f6978..bacad75fa 100644
--- a/mod/sitepages/start.php
+++ b/mod/sitepages/start.php
@@ -12,16 +12,11 @@
* @link http://elgg.org/
*
* @todo
- * Check for SQL injection problems.
- * Force [[login_box]] in the logged out view.
* Make sure this stuff doesn't show up in search.
- * Check entity keyword views against fullview. Force to FALSE?
* DRY up actions and views
- * Implement sticky forms
* Use $entity->view to redirect to url of page.
* The tool settings view is probably not needed as it can be added to the front page edit tab.
* You can say pg/sitepages/edit|read/any_page_i_want and it will let you.
- * Clean up and probably move the docs for keywords.
*/
/**
@@ -48,24 +43,9 @@ function sitepages_init() {
register_plugin_hook('index', 'system', 'sitepages_custom_index');
}
- // parse views for keywords
- register_plugin_hook('display', 'view', 'sitepages_parse_view');
-
- // register the views we want to parse for the keyword replacement
- // right now this is just the custom front page, but we can
- // expand it to the other pages later.
- $CONFIG->sitepages_parse_views = array(
- 'sitepages/custom_frontpage'
- );
-
- // an example of how to register and respond to the get_keywords trigger
- register_plugin_hook('get_keywords', 'sitepages', 'sitepages_keyword_hook');
-
- // grab the list of keywords and their views from plugins
- if ($keywords = trigger_plugin_hook('get_keywords', 'sitepages', NULL, array())) {
- ksort($keywords);
- $CONFIG->sitepages_keywords = $keywords;
- }
+ // define our own ecml keywords and views
+ register_plugin_hook('get_keywords', 'ecml', 'sitepages_ecml_keyword_hook');
+ register_plugin_hook('get_views', 'ecml', 'sitepages_ecml_views_hook');
register_action("sitepages/add", FALSE, $CONFIG->pluginspath . "sitepages/actions/add.php");
register_action("sitepages/addfront", FALSE, $CONFIG->pluginspath . "sitepages/actions/addfront.php");
@@ -205,24 +185,38 @@ function sitepages_parse_view($hook, $entity_type, $return_value, $params) {
* @param unknown_type $params
* @return unknown_type
*/
-function sitepages_keyword_hook($hook, $entity_type, $return_value, $params) {
+function sitepages_ecml_keyword_hook($hook, $entity_type, $return_value, $params) {
$return_value['login_box'] = array(
'view' => 'account/forms/login',
- 'description' => elgg_echo('sitepages:keywords:login_box')
+ 'description' => elgg_echo('sitepages:ecml:keywords:login_box')
);
$return_value['user_list'] = array(
'view' => 'sitepages/keywords/user_list',
- 'description' => elgg_echo('sitepages:keywords:user_list')
+ 'description' => elgg_echo('sitepages:ecml:keywords:user_list')
);
$return_value['site_stats'] = array(
'view' => 'sitepages/keywords/site_stats',
- 'description' => elgg_echo('sitepages:keywords:site_stats')
+ 'description' => elgg_echo('sitepages:ecml:keywords:site_stats')
);
return $return_value;
}
+/**
+ * Register the frontpage with ECML.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $return_value
+ * @param unknown_type $params
+ */
+function sitepages_ecml_views_hook($hook, $entity_type, $return_value, $params) {
+ $return_value['sitepages/custom_frontpage'] = elgg_echo('sitepages:ecml:views:custom_frontpage');
+
+ return $return_value;
+}
+
register_elgg_event_handler('init', 'system', 'sitepages_init');
register_elgg_event_handler('pagesetup', 'system', 'sitepages_pagesetup'); \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/keywords.php b/mod/sitepages/views/default/sitepages/keywords.php
deleted file mode 100644
index d7fb8ad97..000000000
--- a/mod/sitepages/views/default/sitepages/keywords.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Lists available keywords
- *
- * @package SitePages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.org/
- */
-
-$keywords = $vars['config']->sitepages_keywords;
-$title = elgg_echo('sitepages:keywords_title');
-$instructions = elgg_echo('sitepages:keywords_instructions');
-$more_info = elgg_echo('sitepages:keywords_instructions_more');
-
-$keywords_html = '';
-foreach ($keywords as $keyword => $info) {
- $desc = htmlentities($info['description']);
- $keywords_html .= "<li><acronym title=\"$desc\">[[$keyword]]</acronym></li>";
-}
-
-echo "
-<h3>$title</h3>
-<p>$instructions</p>
-$more_info
-<ul>
- $keywords_html
-</ul>
-"; \ No newline at end of file
diff --git a/mod/sitepages/views/default/sitepages/keywords/user_list.php b/mod/sitepages/views/default/sitepages/keywords/user_list.php
index 2f2f09c49..0961cb682 100644
--- a/mod/sitepages/views/default/sitepages/keywords/user_list.php
+++ b/mod/sitepages/views/default/sitepages/keywords/user_list.php
@@ -10,7 +10,7 @@
*/
$only_with_avatars = (isset($vars['only_with_avatars'])) ? $vars['only_with_avatars'] : TRUE;
-$list_type = (isset($vars['list_type'])) ? $vars['list_type'] : 'newest';
+$list_type = (isset($vars['list_type'])) ? $vars['list_type'] : 'new';
$limit = (isset($vars['limit'])) ? $vars['limit'] : 10;
$options = array(
@@ -23,7 +23,7 @@ if ($only_with_avatars == TRUE) {
}
switch ($list_type) {
- case 'newest':
+ case 'new':
$options['order_by'] = 'e.time_created DESC';
break;