diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-25 22:00:44 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-25 22:00:44 +0000 |
commit | c2e2d3ae222a55086bed95d897c6e8c50b066c37 (patch) | |
tree | 9039f6be684ab133c13e5f4cb8e36ff37f2aec5a /mod/sitepages | |
parent | d86408d2662b961645b4ed4cdbd37d5150819cf4 (diff) | |
download | elgg-c2e2d3ae222a55086bed95d897c6e8c50b066c37.tar.gz elgg-c2e2d3ae222a55086bed95d897c6e8c50b066c37.tar.bz2 |
Converting all line endings to unix style.
git-svn-id: http://code.elgg.org/elgg/trunk@5512 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/sitepages')
-rw-r--r-- | mod/sitepages/actions/addmeta.php | 70 | ||||
-rw-r--r-- | mod/sitepages/sitepages_functions.php | 448 | ||||
-rw-r--r-- | mod/sitepages/views/default/settings/sitepages/edit.php | 36 | ||||
-rw-r--r-- | mod/sitepages/views/default/sitepages/forms/editmeta.php | 84 | ||||
-rw-r--r-- | mod/sitepages/views/default/sitepages/keywords.php | 58 | ||||
-rw-r--r-- | mod/sitepages/views/default/sitepages/metatags.php | 76 |
6 files changed, 386 insertions, 386 deletions
diff --git a/mod/sitepages/actions/addmeta.php b/mod/sitepages/actions/addmeta.php index e5c947776..ec72d6339 100644 --- a/mod/sitepages/actions/addmeta.php +++ b/mod/sitepages/actions/addmeta.php @@ -1,36 +1,36 @@ -<?php
-/**
- * Site pages meta tags and desc page save/edit
- *
- * @package SitePages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- *
- */
-
-admin_gatekeeper();
-
-$description = get_input('description', '', FALSE);
-$metatags = get_input('metatags', '', FALSE);
-
-// Cache to the session
-$_SESSION['description'] = $description;
-$_SESSION['metatags'] = $metatags;
-
-if (!$sitepage = sitepages_get_sitepage_object('seo')) {
- $sitepage = sitepages_create_sitepage_object('seo');
-}
-
-$sitepage->title = $metatags;
-$sitepage->description = $description;
-
-if ($sitepage->save()) {
- system_message(elgg_echo("sitepages:seocreated"));
- unset($_SESSION['description']); unset($_SESSION['metatags']);
-} else {
- register_error(elgg_echo("sitepages:error"));
-}
-
+<?php +/** + * Site pages meta tags and desc page save/edit + * + * @package SitePages + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + * + */ + +admin_gatekeeper(); + +$description = get_input('description', '', FALSE); +$metatags = get_input('metatags', '', FALSE); + +// Cache to the session +$_SESSION['description'] = $description; +$_SESSION['metatags'] = $metatags; + +if (!$sitepage = sitepages_get_sitepage_object('seo')) { + $sitepage = sitepages_create_sitepage_object('seo'); +} + +$sitepage->title = $metatags; +$sitepage->description = $description; + +if ($sitepage->save()) { + system_message(elgg_echo("sitepages:seocreated")); + unset($_SESSION['description']); unset($_SESSION['metatags']); +} else { + register_error(elgg_echo("sitepages:error")); +} + forward($_SERVER['HTTP_REFERER']);
\ No newline at end of file diff --git a/mod/sitepages/sitepages_functions.php b/mod/sitepages/sitepages_functions.php index 20e7cb0b6..bc14d1a54 100644 --- a/mod/sitepages/sitepages_functions.php +++ b/mod/sitepages/sitepages_functions.php @@ -1,225 +1,225 @@ -<?php
-/**
- * Helper functions for Site Pages.
- *
- * @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/
- */
-
-
-/**
- * Returns a single object that holds information about
- * customizations for the $section site page. The object guid
- * is stored as private data on the site entity. This allows the pages
- * to still be searchable as standard entities.
- *
- * @param $type
- * @return mixed ElggSitePage on success, FALSE on fail
- */
-function sitepages_get_sitepage_object($page_type) {
- global $CONFIG;
-
- $page_guid = get_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type");
- $sitepage = get_entity($page_guid);
-
- if ($sitepage instanceof ElggSitePage || $sitepage->page_type == $page_type) {
- return $sitepage;
- }
-
- return FALSE;
-}
-
-/**
- * Creates a site page object.
- *
- * @param str $page_type
- * @return mixed ElggSitePage on success, FALSE on fail.
- */
-function sitepages_create_sitepage_object($page_type) {
- global $CONFIG;
-
- $sitepage = new ElggSitePage();
- $sitepage->page_type = $page_type;
- $sitepage->access_id = ACCESS_PUBLIC;
- $sitepage->save();
-
- if ($sitepage->save() && set_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type", $sitepage->getGUID())) {
- return $sitepage;
- }
-
- return FALSE;
-}
-
-/**
- * Assembles html for edit sections of site pages.
- *
- * @param str $section
- * @return str html
- */
-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':
- $view = 'sitepages/forms/editmeta';
- break;
-
- default:
- $view = 'sitepages/forms/edit';
- break;
-
- }
-
- $form .= elgg_view($view, array('page_type' => $page_type));
- $body = $title . $menu . $form;
-
- $content = elgg_view_layout('one_column_with_sidebar', $body, $keywords);
- return $content;
-}
-
-/**
- * Assembles html for displaying site pages
- *
- * @param string $page_type
- * @return string Formatted html
- */
-function sitepages_get_page_content($page_type) {
- $body = elgg_view_title(elgg_echo("sitepages:". strtolower($page_type)));
-
- $sitepage = sitepages_get_sitepage_object($page_type);
-
- if ($sitepage) {
- $body .= elgg_view('page_elements/elgg_content', array('body' => $sitepage->description));
- } else {
- $body .= elgg_view('page_elements/elgg_content', array('body' => elgg_echo('sitepages:notset')));
- }
-
- $content = elgg_view_layout('one_column_with_sidebar', $body);
- return $content;
-}
-
-
-/**
- * Used to determine how to handle special non-static keywords.
- *
- * @param unknown_type $matches
- * @return html
- */
-function sitepages_parse_view_match($matches) {
- $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;
-
- }
-
- 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);
- $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.
- */
-class ElggSitePage extends ElggObject {
- public function initialise_attributes() {
- parent::initialise_attributes();
-
- $this->attributes['subtype'] = 'sitepages_page';
- }
+<?php +/** + * Helper functions for Site Pages. + * + * @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/ + */ + + +/** + * Returns a single object that holds information about + * customizations for the $section site page. The object guid + * is stored as private data on the site entity. This allows the pages + * to still be searchable as standard entities. + * + * @param $type + * @return mixed ElggSitePage on success, FALSE on fail + */ +function sitepages_get_sitepage_object($page_type) { + global $CONFIG; + + $page_guid = get_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type"); + $sitepage = get_entity($page_guid); + + if ($sitepage instanceof ElggSitePage || $sitepage->page_type == $page_type) { + return $sitepage; + } + + return FALSE; +} + +/** + * Creates a site page object. + * + * @param str $page_type + * @return mixed ElggSitePage on success, FALSE on fail. + */ +function sitepages_create_sitepage_object($page_type) { + global $CONFIG; + + $sitepage = new ElggSitePage(); + $sitepage->page_type = $page_type; + $sitepage->access_id = ACCESS_PUBLIC; + $sitepage->save(); + + if ($sitepage->save() && set_private_setting($CONFIG->site->getGUID(), "sitepages:$page_type", $sitepage->getGUID())) { + return $sitepage; + } + + return FALSE; +} + +/** + * Assembles html for edit sections of site pages. + * + * @param str $section + * @return str html + */ +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': + $view = 'sitepages/forms/editmeta'; + break; + + default: + $view = 'sitepages/forms/edit'; + break; + + } + + $form .= elgg_view($view, array('page_type' => $page_type)); + $body = $title . $menu . $form; + + $content = elgg_view_layout('one_column_with_sidebar', $body, $keywords); + return $content; +} + +/** + * Assembles html for displaying site pages + * + * @param string $page_type + * @return string Formatted html + */ +function sitepages_get_page_content($page_type) { + $body = elgg_view_title(elgg_echo("sitepages:". strtolower($page_type))); + + $sitepage = sitepages_get_sitepage_object($page_type); + + if ($sitepage) { + $body .= elgg_view('page_elements/elgg_content', array('body' => $sitepage->description)); + } else { + $body .= elgg_view('page_elements/elgg_content', array('body' => elgg_echo('sitepages:notset'))); + } + + $content = elgg_view_layout('one_column_with_sidebar', $body); + return $content; +} + + +/** + * Used to determine how to handle special non-static keywords. + * + * @param unknown_type $matches + * @return html + */ +function sitepages_parse_view_match($matches) { + $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; + + } + + 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); + $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. + */ +class ElggSitePage extends ElggObject { + public function initialise_attributes() { + parent::initialise_attributes(); + + $this->attributes['subtype'] = 'sitepages_page'; + } }
\ No newline at end of file diff --git a/mod/sitepages/views/default/settings/sitepages/edit.php b/mod/sitepages/views/default/settings/sitepages/edit.php index 9705aaae5..8a8a2d271 100644 --- a/mod/sitepages/views/default/settings/sitepages/edit.php +++ b/mod/sitepages/views/default/settings/sitepages/edit.php @@ -1,19 +1,19 @@ -<?php
-/**
- * Settings Site Pages
- *
- * @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/
- */
-?>
-
-<p>
- <?php echo elgg_echo('sitepages:ownfront'); ?>
- <select name="params[ownfrontpage]">
- <option value="yes" <?php if ($vars['entity']->ownfrontpage == 'yes') echo " selected=\"yes\" "; ?>><?php echo elgg_echo('option:yes'); ?></option>
- <option value="no" <?php if ($vars['entity']->ownfrontpage != 'yes') echo " selected=\"yes\" "; ?>><?php echo elgg_echo('option:no'); ?></option>
- </select>
+<?php +/** + * Settings Site Pages + * + * @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/ + */ +?> + +<p> + <?php echo elgg_echo('sitepages:ownfront'); ?> + <select name="params[ownfrontpage]"> + <option value="yes" <?php if ($vars['entity']->ownfrontpage == 'yes') echo " selected=\"yes\" "; ?>><?php echo elgg_echo('option:yes'); ?></option> + <option value="no" <?php if ($vars['entity']->ownfrontpage != 'yes') echo " selected=\"yes\" "; ?>><?php echo elgg_echo('option:no'); ?></option> + </select> </p>
\ No newline at end of file diff --git a/mod/sitepages/views/default/sitepages/forms/editmeta.php b/mod/sitepages/views/default/sitepages/forms/editmeta.php index cb67bd41d..b9a454bbf 100644 --- a/mod/sitepages/views/default/sitepages/forms/editmeta.php +++ b/mod/sitepages/views/default/sitepages/forms/editmeta.php @@ -1,43 +1,43 @@ -<?php
-/**
- * Edit form for the custom meta tags and desc
- *
- * @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/
- */
-
-$action = 'sitepages/addmeta';
-
-if ($sitepages_object = sitepages_get_sitepage_object('seo')) {
- $meta_tags = $sitepages_object->title;
- $meta_description = $sitepages_object->description;
-} else {
- $meta_tags = '';
- $meta_description = '';
-}
-
-$input_keywords = elgg_view('input/text', array('internalname' => 'metatags', 'value' => $meta_tags));
-$input_description = elgg_view('input/plaintext', array('internalname' => 'description', 'value' => $meta_description));
-$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
-
-$description = elgg_echo("sitepages:metadescription");
-$metatags = elgg_echo("sitepages:metatags");
-
-$form_body = <<<___EOT
-
-<p><label>$description
-$input_description</p></label>
-
-<p><label>$metatags
-$input_keywords</p></label>
-
-$hidden_guid
-$submit_input
-
-___EOT;
-
-//display the form
+<?php +/** + * Edit form for the custom meta tags and desc + * + * @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/ + */ + +$action = 'sitepages/addmeta'; + +if ($sitepages_object = sitepages_get_sitepage_object('seo')) { + $meta_tags = $sitepages_object->title; + $meta_description = $sitepages_object->description; +} else { + $meta_tags = ''; + $meta_description = ''; +} + +$input_keywords = elgg_view('input/text', array('internalname' => 'metatags', 'value' => $meta_tags)); +$input_description = elgg_view('input/plaintext', array('internalname' => 'description', 'value' => $meta_description)); +$submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save'))); + +$description = elgg_echo("sitepages:metadescription"); +$metatags = elgg_echo("sitepages:metatags"); + +$form_body = <<<___EOT + +<p><label>$description +$input_description</p></label> + +<p><label>$metatags +$input_keywords</p></label> + +$hidden_guid +$submit_input + +___EOT; + +//display the form echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body));
\ No newline at end of file diff --git a/mod/sitepages/views/default/sitepages/keywords.php b/mod/sitepages/views/default/sitepages/keywords.php index 457ab99c7..d7fb8ad97 100644 --- a/mod/sitepages/views/default/sitepages/keywords.php +++ b/mod/sitepages/views/default/sitepages/keywords.php @@ -1,30 +1,30 @@ -<?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>
+<?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/metatags.php b/mod/sitepages/views/default/sitepages/metatags.php index d3939f73e..973ab6417 100644 --- a/mod/sitepages/views/default/sitepages/metatags.php +++ b/mod/sitepages/views/default/sitepages/metatags.php @@ -1,39 +1,39 @@ -<?php
-/**
- * Add any additional defined metatags or CSS.
- *
- * @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/
- */
-
-$meta_details = sitepages_get_sitepage_object('seo');
-
-if ($meta_details) {
- $metatags = $meta_details->title;
- $description = $meta_details->description;
-
- echo <<<___END
-
- <meta name="description" content="$description" />
- <meta name="keywords" content="$metatags" />
-
-___END;
-}
-
-// only show on the custom front page.
-if (get_context() == 'sitepages:front') {
- $custom_css = sitepages_get_sitepage_object('front');
-
- if ($custom_css && $custom_css->css) {
- echo <<<___END
-
- <style type="text/css">
- {$custom_css->css}
- </style>
-
-___END;
- }
+<?php +/** + * Add any additional defined metatags or CSS. + * + * @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/ + */ + +$meta_details = sitepages_get_sitepage_object('seo'); + +if ($meta_details) { + $metatags = $meta_details->title; + $description = $meta_details->description; + + echo <<<___END + + <meta name="description" content="$description" /> + <meta name="keywords" content="$metatags" /> + +___END; +} + +// only show on the custom front page. +if (get_context() == 'sitepages:front') { + $custom_css = sitepages_get_sitepage_object('front'); + + if ($custom_css && $custom_css->css) { + echo <<<___END + + <style type="text/css"> + {$custom_css->css} + </style> + +___END; + } }
\ No newline at end of file |