diff --git a/3.0/modules/item_links/helpers/item_links_event.php b/3.0/modules/item_links/helpers/item_links_event.php
new file mode 100644
index 00000000..12cc94a1
--- /dev/null
+++ b/3.0/modules/item_links/helpers/item_links_event.php
@@ -0,0 +1,58 @@
+where("item_id", "=", $item->id)
+ ->find_all();
+
+ $existing_url = "";
+ if (count($item_url) > 0) {
+ $existing_url = $item_url[0]->url;
+ }
+ $form->edit_item
+ ->input("item_links_url")
+ ->label(t("Redirect to URL:"))
+ ->value($existing_url);
+ }
+
+ static function item_deleted($item) {
+ // Whenever an item is deleted, delete any corresponding data.
+ db::build()->delete("item_links")->where("item_id", "=", $item->id)->execute();
+ }
+
+ static function item_edit_form_completed($item, $form) {
+ // Update the database with any changes to the item_links field.
+ $record = ORM::factory("item_link")->where("item_id", "=", $item->id)->find();
+
+ if ($form->edit_item->item_links_url->value != "") {
+ if (!$record->loaded()) {
+ $record->item_id = $item->id;
+ }
+ $record->url = $form->edit_item->item_links_url->value;
+ $record->save();
+ } else {
+ db::build()->delete("item_links")->where("item_id", "=", $item->id)->execute();
+ }
+ }
+}
diff --git a/3.0/modules/item_links/helpers/item_links_installer.php b/3.0/modules/item_links/helpers/item_links_installer.php
new file mode 100644
index 00000000..f9d34d98
--- /dev/null
+++ b/3.0/modules/item_links/helpers/item_links_installer.php
@@ -0,0 +1,34 @@
+query("CREATE TABLE IF NOT EXISTS {item_links} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9) NOT NULL,
+ `url` text default NULL,
+ PRIMARY KEY (`id`),
+ KEY(`item_id`, `id`))
+ DEFAULT CHARSET=utf8;");
+
+ // Set the module's version number.
+ module::set_version("item_links", 1);
+ }
+}
diff --git a/3.0/modules/item_links/helpers/item_links_theme.php b/3.0/modules/item_links/helpers/item_links_theme.php
new file mode 100644
index 00000000..fbfcbb45
--- /dev/null
+++ b/3.0/modules/item_links/helpers/item_links_theme.php
@@ -0,0 +1,34 @@
+item()) {
+ $item_url = ORM::factory("item_link")
+ ->where("item_id", "=", $theme->item->id)
+ ->find_all();
+ if (count($item_url) > 0) {
+ url::redirect($item_url[0]->url);
+ }
+ }
+ return;
+ }
+}
diff --git a/3.0/modules/item_links/models/item_link.php b/3.0/modules/item_links/models/item_link.php
new file mode 100644
index 00000000..65335e27
--- /dev/null
+++ b/3.0/modules/item_links/models/item_link.php
@@ -0,0 +1,21 @@
+page_title = t("Manage pages");
+ $view->content = new View("admin_pages.html");
+ $query = ORM::factory("static_page");
+ $view->content->pages = $query->order_by("name", "ASC")->find_all();
+ $view->content->form = $this->get_prefs_form();
+ print $view;
+ }
+
+ public function createpage() {
+ // Display a form for creating a new page.
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Create page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_new_page_form();
+ print $view;
+ }
+
+ public function editpage($id) {
+ // Display a form for editing an existing page.
+ $existing_page = ORM::factory("static_page", $id);
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Edit page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_edit_page_form($existing_page);
+ print $view;
+ }
+
+ public function savepage() {
+ // Save a page to the database.
+
+ access::verify_csrf();
+
+ // Store form values into variables.
+ $page_id = Input::instance()->post("page_id");
+ $page_name = urlencode(trim(Input::instance()->post("page_name")));
+ $page_title = Input::instance()->post("page_title");
+ $page_code = Input::instance()->post("page_code");
+ $display_menu = Input::instance()->post("display_menu");
+
+ // If $page_id is set, update an existing page.
+ if (isset($page_id)) {
+ $update_page = ORM::factory("static_page", $page_id);
+ $update_page->title = $page_title;
+ $update_page->html_code = $page_code;
+ $update_page->display_menu = $display_menu;
+ $update_page->save();
+ message::success(t("Page %page_name updated", array("page_name" => $update_page->name)));
+ log::success("pages", t("Page %page_name updated", array("page_name" => $update_page->name)));
+ url::redirect("admin/pages");
+ } else {
+
+ // If $page_id is not set, we are dealing with a new page.
+ // Check and make sure a page with the same names doesn't already exist.
+ $existing_page = ORM::factory("static_page")
+ ->where("name", "=", $page_name)
+ ->find_all();
+
+ // If the page doesn't exist, save it to the database.
+ if (count($existing_page) == 0) {
+ $new_page = ORM::factory("static_page");
+ $new_page->name = $page_name;
+ $new_page->title = $page_title;
+ $new_page->html_code = $page_code;
+ $new_page->display_menu = $display_menu;
+ $new_page->save();
+ message::success(t("Page %page_name created", array("page_name" => $page_name)));
+ log::success("pages", t("Page %page_name created", array("page_name" => $page_name)));
+ url::redirect("admin/pages");
+ } else {
+
+ // If the page does exist, ask the user if they want to overwrite the old page with the new one.
+ message::error(t("Page %page_name already exists, press Save again to overwrite.", array("page_name" => $page_name)));
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Edit page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_overwrite_page_form($existing_page[0]->id, $page_name, $page_title, $page_code, $display_menu);
+ print $view;
+ }
+ }
+ }
+
+ public function form_delete($id) {
+ // Display a form asking the user if they want to delete a page.
+ $one_page = ORM::factory("static_page", $id);
+ if ($one_page->loaded()) {
+ print $this->get_delete_form($one_page);
+ }
+ }
+
+ public function delete($id) {
+ // Delete the specified page.
+
+ access::verify_csrf();
+
+ // Make sure $id belongs to an actual page.
+ $one_page = ORM::factory("static_page", $id);
+ if (!$one_page->loaded()) {
+ throw new Kohana_404_Exception();
+ }
+
+ // If the form validates, delete the specified page.
+ $form = $this->get_delete_form($one_page);
+ if ($form->validate()) {
+ $name = $one_page->name;
+ $one_page->delete();
+ message::success(t("Deleted page %page_name", array("page_name" => $name)));
+ log::success("pages", t("Deleted page %page_name", array("page_name" => $name)));
+ json::reply(array("result" => "success", "location" => url::site("admin/pages")));
+ } else {
+ print $form;
+ }
+ }
+
+ public function form_rename($id) {
+ // Display a form to allow the user to rename a page.
+ $one_page = ORM::factory("static_page", $id);
+ if ($one_page->loaded()) {
+ print InPlaceEdit::factory(urldecode($one_page->name))
+ ->action("admin/pages/rename/$id")
+ ->render();
+ }
+ }
+
+ public function rename($id) {
+ // Rename an existing page.
+ access::verify_csrf();
+
+ // Make sure the page specified by $id exists.
+ $one_page = ORM::factory("static_page", $id);
+ if (!$one_page->loaded()) {
+ throw new Kohana_404_Exception();
+ }
+
+ $in_place_edit = InPlaceEdit::factory($one_page->name)
+ ->action("admin/pages/rename/$one_page->id")
+ ->rules(array("required", "length[1,64]"));
+
+ // If the form validates, and if the new name doesn't already exist, rename the page.
+ if ($in_place_edit->validate()) {
+ $old_name = $one_page->name;
+ $new_name = urlencode(trim($in_place_edit->value()));
+ $new_name_exists = ORM::factory("static_page")->where("name", "=", $new_name)->find_all();
+ if (count($new_name_exists) == 0) {
+ $one_page->name = $new_name;
+ $one_page->save();
+ $message = t("Renamed page %old_name to %new_name",
+ array("old_name" => $old_name, "new_name" => $new_name));
+ message::success($message);
+ log::success("pages", $message);
+ json::reply(array("result" => "success", "location" => url::site("admin/pages")));
+ } else {
+ json::reply(array("result" => "error", "form" => (string)$in_place_edit->render()));
+ }
+ } else {
+ json::reply(array("result" => "error", "form" => (string)$in_place_edit->render()));
+ }
+ }
+
+ static function get_delete_form($one_page) {
+ // Generate a new form asking the user if they want to delete a page.
+ $form = new Forge("admin/pages/delete/$one_page->id", "", "post", array("id" => "g-delete-pages-form"));
+ $group = $form->group("delete_page")
+ ->label(t("Really delete page %page_name?", array("page_name" => $one_page->name)));
+ $group->submit("")->value(t("Delete Page"));
+ return $form;
+ }
+
+ private function get_new_page_form() {
+ // Generate a form for creating a new page.
+ $form = new Forge("admin/pages/savepage", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("new_page");
+ $pages_group->input("page_name")
+ ->label(t("Name"));
+ $pages_group->input("page_title")
+ ->label(t("Title"));
+ $pages_group->textarea("page_code")
+ ->label(t("HTML Code"));
+ $pages_group->checkbox("display_menu")
+ ->label(t("Display in menu?"))
+ ->checked(false);
+ $pages_group->submit("save_page")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ private function get_overwrite_page_form($id, $name, $title, $html_code, $display_menu) {
+ // Generate a form for overwriting an existing page.
+ $form = new Forge("admin/pages/savepage", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("new_page");
+ $pages_group->hidden("page_id")
+ ->value($id);
+ $pages_group->input("page_name")
+ ->label(t("Name"))
+ ->readonly()
+ ->value($name);
+ $pages_group->input("page_title")
+ ->label(t("Title"))
+ ->value($title);
+ $pages_group->textarea("page_code")
+ ->label(t("HTML Code"))
+ ->value($html_code);
+ $pages_group->checkbox("display_menu")
+ ->label(t("Display in menu?"))
+ ->checked($display_menu);
+ $pages_group->submit("save_page")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ private function get_edit_page_form($existing_page) {
+ // Generate a form for editing an existing page. Reuse the overwrite form for as it's basically the same thing.
+ return ($this->get_overwrite_page_form($existing_page->id, $existing_page->name, $existing_page->title, $existing_page->html_code, $existing_page->display_menu));
+ }
+
+ private function get_prefs_form() {
+ // Generate a form for global preferences.
+ $form = new Forge("admin/pages/saveprefs", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("preferences")->label(t("Settings"));
+ $pages_group->checkbox("display_sidebar")
+ ->label(t("Hide sidebar on Pages?"))
+ ->checked(module::get_var("pages", "show_sidebar"));
+ $pages_group->submit("save_prefs")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ public function saveprefs() {
+ // Save a preferences to the database.
+
+ access::verify_csrf();
+
+ // Save form variables.
+ module::set_var("pages", "show_sidebar", Input::instance()->post("display_sidebar"));
+
+ // Display message and load main pages admin screen.
+ message::success(t("Your settings have been saved."));
+ url::redirect("admin/pages");
+ }
+}
diff --git a/3.0/modules/pages/controllers/pages.php b/3.0/modules/pages/controllers/pages.php
new file mode 100644
index 00000000..8b0f7c2d
--- /dev/null
+++ b/3.0/modules/pages/controllers/pages.php
@@ -0,0 +1,42 @@
+where("name", "=", $page_name)
+ ->find_all();
+
+ // If it doesn't exist, display a 404 error.
+ if (count($existing_page) == 0) {
+ throw new Kohana_404_Exception();
+ }
+
+ // Display the page.
+ $template = new Theme_View("page.html", "other", "Pages");
+ $template->page_title = t("Gallery :: ") . $existing_page[0]->title;
+ $template->content = new View("pages_display.html");
+ $template->content->title = $existing_page[0]->title;
+ $template->content->body = $existing_page[0]->html_code;
+ print $template;
+ }
+}
diff --git a/3.0/modules/pages/css/jHtmlArea.css b/3.0/modules/pages/css/jHtmlArea.css
new file mode 100644
index 00000000..641ea291
--- /dev/null
+++ b/3.0/modules/pages/css/jHtmlArea.css
@@ -0,0 +1,48 @@
+div.jHtmlArea { display: inline block; border: solid 1px #ccc; }
+div.jHtmlArea div { padding: 0px; margin: 0px; }
+div.jHtmlArea .ToolBar { }
+div.jHtmlArea .ToolBar ul { border: solid 0px #ccc; margin: 1px; padding: 1px; position:relative; display: inline; background: #fff url(../images/jHtmlArea_Toolbar_Group_BG.png) repeat-x;}
+div.jHtmlArea .ToolBar ul li { list-style-type: none; float: left; border: none; padding: 1px; margin: 1px; }
+div.jHtmlArea .ToolBar ul li:hover { border: solid 1px #ccc; background: #ddd url(../images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png); padding: 0; }
+div.jHtmlArea .ToolBar ul li a { display: block; width: 16px; height: 16px; background: url(../images/jHtmlArea.png) no-repeat -16px -500px; border: none; cursor: pointer; padding: 0px; }
+div.jHtmlArea .ToolBar ul li a.highlighted { border: solid 1px #aaa; background-color: #bbb; padding: 0; }
+div.jHtmlArea .ToolBar ul li.separator {height: 16px; margin: 0 2px 0 3px; border-left: 1px solid #ccc;}
+div.jHtmlArea .ToolBar ul li.separator:hover { padding: 1px; background-color: #fff; border-top:none; border-bottom:none; border-right:none;}
+
+div.jHtmlArea .ToolBar ul li a:hover { }
+div.jHtmlArea .ToolBar ul li a.bold { background-position: 0 0; }
+div.jHtmlArea .ToolBar ul li a.italic { background-position: -16px 0; }
+div.jHtmlArea .ToolBar ul li a.underline { background-position: -32px 0; }
+div.jHtmlArea .ToolBar ul li a.strikethrough { background-position: -48px 0; }
+div.jHtmlArea .ToolBar ul li a.link { background-position: -64px 0; }
+div.jHtmlArea .ToolBar ul li a.unlink { background-position: -80px 0; }
+div.jHtmlArea .ToolBar ul li a.orderedlist { background-position: -96px 0; }
+div.jHtmlArea .ToolBar ul li a.unorderedlist { background-position: -112px 0; }
+div.jHtmlArea .ToolBar ul li a.image { background-position: -128px 0; }
+div.jHtmlArea .ToolBar ul li a.cut { background-position: -144px 0; }
+div.jHtmlArea .ToolBar ul li a.copy { background-position: -160px 0; }
+div.jHtmlArea .ToolBar ul li a.paste { background-position: -176px 0; }
+
+div.jHtmlArea .ToolBar ul li a.html { background-position: -192px 0; opacity:0.6; filter:alpha(opacity=60);}
+div.jHtmlArea .ToolBar ul li a.html.highlighted { opacity:1.0; filter:alpha(opacity=100);}
+
+div.jHtmlArea .ToolBar ul li a.h1 { background-position: 0 -16px;}
+div.jHtmlArea .ToolBar ul li a.h2 { background-position: -16px -16px;}
+div.jHtmlArea .ToolBar ul li a.h3 { background-position: -32px -16px;}
+div.jHtmlArea .ToolBar ul li a.h4 { background-position: -48px -16px;}
+div.jHtmlArea .ToolBar ul li a.h5 { background-position: -64px -16px;}
+div.jHtmlArea .ToolBar ul li a.h6 { background-position: -80px -16px;}
+div.jHtmlArea .ToolBar ul li a.subscript { background-position: -96px -16px;}
+div.jHtmlArea .ToolBar ul li a.superscript { background-position: -112px -16px;}
+div.jHtmlArea .ToolBar ul li a.indent { background-position: -128px -16px;}
+div.jHtmlArea .ToolBar ul li a.outdent { background-position: -144px -16px;}
+div.jHtmlArea .ToolBar ul li a.horizontalrule { background-position: -160px -16px;}
+div.jHtmlArea .ToolBar ul li a.p { background-position: -176px -16px;}
+
+
+div.jHtmlArea .ToolBar ul li a.justifyleft { background-position: 0 -32px;}
+div.jHtmlArea .ToolBar ul li a.justifycenter { background-position: -16px -32px;}
+div.jHtmlArea .ToolBar ul li a.justifyright { background-position: -32px -32px;}
+div.jHtmlArea .ToolBar ul li a.increasefontsize { background-position: -48px -32px;}
+div.jHtmlArea .ToolBar ul li a.decreasefontsize { background-position: -64px -32px;}
+div.jHtmlArea .ToolBar ul li a.forecolor { background-position: -80px -32px;}
\ No newline at end of file
diff --git a/3.0/modules/pages/helpers/pages_block.php b/3.0/modules/pages/helpers/pages_block.php
new file mode 100644
index 00000000..089dd12b
--- /dev/null
+++ b/3.0/modules/pages/helpers/pages_block.php
@@ -0,0 +1,57 @@
+ t("Pages Links"));
+ }
+
+ static function get($block_id, $theme) {
+ $block = "";
+
+ switch ($block_id) {
+ case "pages_block":
+
+ // Create a new block with a list of all Pages and their links.
+
+ // Query the database for all existing pages.
+ // If at least one page exists, display the sidebar block.
+ $query = ORM::factory("static_page");
+ $pages = $query->order_by("title", "ASC")->find_all();
+ if (count($pages) > 0) {
+
+ // Loop through each page and generate an HTML list of their links and titles.
+ $content = "
";
+ foreach ($pages as $one_page) {
+ $content .= "- name) . "\">" . $one_page->title . "
";
+ }
+ $content .= "
";
+
+ // Make a new sidebar block.
+ $block = new Block();
+ $block->css_id = "g-pages";
+ $block->title = t("Pages");
+ $block->content = new View("pages_sidebar.html");
+ $block->content->links = $content;
+ }
+ break;
+ }
+ return $block;
+ }
+}
diff --git a/3.0/modules/pages/helpers/pages_event.php b/3.0/modules/pages/helpers/pages_event.php
new file mode 100644
index 00000000..9e37aa8b
--- /dev/null
+++ b/3.0/modules/pages/helpers/pages_event.php
@@ -0,0 +1,44 @@
+get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("pages")
+ ->label(t("Pages Settings"))
+ ->url(url::site("admin/pages")));
+ }
+
+ static function site_menu($menu, $theme) {
+ $menu_pages = ORM::factory("static_page")
+ ->where("display_menu", "=", true)
+ ->order_by("title", "DESC")
+ ->find_all();
+ if (count($menu_pages) > 0) {
+ foreach ($menu_pages as $one_page) {
+ $menu->add_after("home", Menu::factory("link")
+ ->id("pages-" . $one_page->id)
+ ->label($one_page->title)
+ ->url(url::site("pages/show/" . $one_page->name)));
+ }
+ }
+ }
+}
diff --git a/3.0/modules/pages/helpers/pages_installer.php b/3.0/modules/pages/helpers/pages_installer.php
new file mode 100644
index 00000000..cd1f1546
--- /dev/null
+++ b/3.0/modules/pages/helpers/pages_installer.php
@@ -0,0 +1,44 @@
+query("CREATE TABLE IF NOT EXISTS {static_pages} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(255) default NULL,
+ `title` varchar(255) default NULL,
+ `html_code` text default NULL,
+ `display_menu` boolean default 0,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ DEFAULT CHARSET=utf8;");
+
+ // Set the module version number.
+ module::set_version("pages", 2);
+ }
+ static function upgrade($version) {
+ $db = Database::instance();
+ if ($version == 1) {
+ $db->query("ALTER TABLE {static_pages} ADD COLUMN `display_menu` boolean default 0");
+ module::set_version("pages", $version = 2);
+ }
+ }
+}
diff --git a/3.0/modules/pages/helpers/pages_theme.php b/3.0/modules/pages/helpers/pages_theme.php
new file mode 100644
index 00000000..ec57a2ce
--- /dev/null
+++ b/3.0/modules/pages/helpers/pages_theme.php
@@ -0,0 +1,27 @@
+script("jHtmlArea-0.7.0.js") .
+ $theme->css("jHtmlArea.css");
+ }
+}
+
\ No newline at end of file
diff --git a/3.0/modules/pages/images/jHtmlArea.png b/3.0/modules/pages/images/jHtmlArea.png
new file mode 100644
index 00000000..54c66a10
Binary files /dev/null and b/3.0/modules/pages/images/jHtmlArea.png differ
diff --git a/3.0/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png b/3.0/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
new file mode 100644
index 00000000..bcfb0545
Binary files /dev/null and b/3.0/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png differ
diff --git a/3.0/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png b/3.0/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png
new file mode 100644
index 00000000..4287b5b8
Binary files /dev/null and b/3.0/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png differ
diff --git a/3.0/modules/pages/js/jHtmlArea-0.7.0.js b/3.0/modules/pages/js/jHtmlArea-0.7.0.js
new file mode 100644
index 00000000..d1e360c4
--- /dev/null
+++ b/3.0/modules/pages/js/jHtmlArea-0.7.0.js
@@ -0,0 +1,403 @@
+/*
+* jHtmlArea 0.7.0 - WYSIWYG Html Editor jQuery Plugin
+* Copyright (c) 2009 Chris Pietschmann
+* http://jhtmlarea.codeplex.com
+* Licensed under the Microsoft Reciprocal License (Ms-RL)
+* http://jhtmlarea.codeplex.com/license
+*/
+(function($) {
+ $.fn.htmlarea = function(opts) {
+ if (opts && typeof (opts) === "string") {
+ var args = [];
+ for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
+ var htmlarea = jHtmlArea(this[0]);
+ var f = htmlarea[opts];
+ if (f) { return f.apply(htmlarea, args); }
+ }
+ return this.each(function() { jHtmlArea(this, opts); });
+ };
+ var jHtmlArea = window.jHtmlArea = function(elem, options) {
+ if (elem.jquery) {
+ return jHtmlArea(elem[0]);
+ }
+ if (elem.jhtmlareaObject) {
+ return elem.jhtmlareaObject;
+ } else {
+ return new jHtmlArea.fn.init(elem, options);
+ }
+ };
+ jHtmlArea.fn = jHtmlArea.prototype = {
+
+ // The current version of jHtmlArea being used
+ jhtmlarea: "0.7.0",
+
+ init: function(elem, options) {
+ if (elem.nodeName.toLowerCase() === "textarea") {
+ var opts = $.extend({}, jHtmlArea.defaultOptions, options);
+ elem.jhtmlareaObject = this;
+
+ var textarea = this.textarea = $(elem);
+ var container = this.container = $("").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
+
+ var toolbar = this.toolbar = $("").addClass("ToolBar").appendTo(container);
+ priv.initToolBar.call(this, opts);
+
+ var iframe = this.iframe = $("").height(textarea.height());
+ iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
+ var htmlarea = this.htmlarea = $("").append(iframe);
+
+ container.append(htmlarea).append(textarea.hide());
+
+ priv.initEditor.call(this, opts);
+ priv.attachEditorEvents.call(this);
+
+ // Fix total height to match TextArea
+ iframe.height(iframe.height() - toolbar.height());
+ toolbar.width(textarea.width() - 2);
+
+ if (opts.loaded) { opts.loaded.call(this); }
+ }
+ },
+ dispose: function() {
+ this.textarea.show().insertAfter(this.container);
+ this.container.remove();
+ this.textarea[0].jhtmlareaObject = null;
+ },
+ execCommand: function(a, b, c) {
+ this.iframe[0].contentWindow.focus();
+ this.editor.execCommand(a, b || false, c || null);
+ this.updateTextArea();
+ },
+ ec: function(a, b, c) {
+ this.execCommand(a, b, c);
+ },
+ queryCommandValue: function(a) {
+ this.iframe[0].contentWindow.focus();
+ return this.editor.queryCommandValue(a);
+ },
+ qc: function(a) {
+ return this.queryCommandValue(a);
+ },
+ getSelectedHTML: function() {
+ if ($.browser.msie) {
+ return this.getRange().htmlText;
+ } else {
+ var elem = this.getRange().cloneContents();
+ return $("").append($(elem)).html();
+ }
+ },
+ getSelection: function() {
+ if ($.browser.msie) {
+ //return (this.editor.parentWindow.getSelection) ? this.editor.parentWindow.getSelection() : this.editor.selection;
+ return this.editor.selection;
+ } else {
+ return this.iframe[0].contentDocument.defaultView.getSelection();
+ }
+ },
+ getRange: function() {
+ var s = this.getSelection();
+ if (!s) { return null; }
+ //return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
+ return (s.getRangeAt) ? s.getRangeAt(0) : s.createRange();
+ },
+ html: function(v) {
+ if (v) {
+ this.pastHTML(v);
+ } else {
+ return toHtmlString();
+ }
+ },
+ pasteHTML: function(html) {
+ this.iframe[0].contentWindow.focus();
+ var r = this.getRange();
+ if ($.browser.msie) {
+ r.pasteHTML(html);
+ } else if ($.browser.mozilla) {
+ r.deleteContents();
+ r.insertNode($((html.indexOf("<") != 0) ? $("").append(html) : html)[0]);
+ } else { // Safari
+ r.deleteContents();
+ r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "" + html + "" : html))[0]);
+ }
+ r.collapse(false);
+ r.select();
+ },
+ cut: function() {
+ this.ec("cut");
+ },
+ copy: function() {
+ this.ec("copy");
+ },
+ paste: function() {
+ this.ec("paste");
+ },
+ bold: function() { this.ec("bold"); },
+ italic: function() { this.ec("italic"); },
+ underline: function() { this.ec("underline"); },
+ strikeThrough: function() { this.ec("strikethrough"); },
+ image: function(url) {
+ if ($.browser.msie && !url) {
+ this.ec("insertImage", true);
+ } else {
+ this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
+ }
+ },
+ removeFormat: function() {
+ this.ec("removeFormat", false, []);
+ this.unlink();
+ },
+ link: function() {
+ if ($.browser.msie) {
+ this.ec("createLink", true);
+ } else {
+ this.ec("createLink", false, prompt("Link URL:", "http://"));
+ }
+ },
+ unlink: function() { this.ec("unlink", false, []); },
+ orderedList: function() { this.ec("insertorderedlist"); },
+ unorderedList: function() { this.ec("insertunorderedlist"); },
+ superscript: function() { this.ec("superscript"); },
+ subscript: function() { this.ec("subscript"); },
+
+ p: function() {
+ this.formatBlock("");
+ },
+ h1: function() {
+ this.heading(1);
+ },
+ h2: function() {
+ this.heading(2);
+ },
+ h3: function() {
+ this.heading(3);
+ },
+ h4: function() {
+ this.heading(4);
+ },
+ h5: function() {
+ this.heading(5);
+ },
+ h6: function() {
+ this.heading(6);
+ },
+ heading: function(h) {
+ this.formatBlock($.browser.msie ? "Heading " + h : "h" + h);
+ },
+
+ indent: function() {
+ this.ec("indent");
+ },
+ outdent: function() {
+ this.ec("outdent");
+ },
+
+ insertHorizontalRule: function() {
+ this.ec("insertHorizontalRule", false, "ht");
+ },
+
+ justifyLeft: function() {
+ this.ec("justifyLeft");
+ },
+ justifyCenter: function() {
+ this.ec("justifyCenter");
+ },
+ justifyRight: function() {
+ this.ec("justifyRight");
+ },
+
+ increaseFontSize: function() {
+ if ($.browser.msie) {
+ this.ec("fontSize", false, this.qc("fontSize") + 1);
+ } else if ($.browser.safari) {
+ this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "larger")[0]);
+ } else {
+ this.ec("increaseFontSize", false, "big");
+ }
+ },
+ decreaseFontSize: function() {
+ if ($.browser.msie) {
+ this.ec("fontSize", false, this.qc("fontSize") - 1);
+ } else if ($.browser.safari) {
+ this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "smaller")[0]);
+ } else {
+ this.ec("decreaseFontSize", false, "small");
+ }
+ },
+
+ forecolor: function(c) {
+ this.ec("foreColor", false, c || prompt("Enter HTML Color:", "#"));
+ },
+
+ formatBlock: function(v) {
+ this.ec("formatblock", false, v || null);
+ },
+
+ showHTMLView: function() {
+ this.updateTextArea();
+ this.textarea.show();
+ this.htmlarea.hide();
+ $("ul li:not(li:has(a.html))", this.toolbar).hide();
+ $("ul:not(:has(:visible))", this.toolbar).hide();
+ $("ul li a.html", this.toolbar).addClass("highlighted");
+ },
+ hideHTMLView: function() {
+ this.updateHtmlArea();
+ this.textarea.hide();
+ this.htmlarea.show();
+ $("ul", this.toolbar).show();
+ $("ul li", this.toolbar).show().find("a.html").removeClass("highlighted");
+ },
+ toggleHTMLView: function() {
+ (this.textarea.is(":hidden")) ? this.showHTMLView() : this.hideHTMLView();
+ },
+
+ toHtmlString: function() {
+ return this.editor.body.innerHTML;
+ },
+ toString: function() {
+ return this.editor.body.innerText;
+ },
+
+ updateTextArea: function() {
+ this.textarea.val(this.toHtmlString());
+ },
+ updateHtmlArea: function() {
+ this.editor.body.innerHTML = this.textarea.val();
+ }
+ };
+ jHtmlArea.fn.init.prototype = jHtmlArea.fn;
+
+ jHtmlArea.defaultOptions = {
+ toolbar: [
+ ["html"], ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
+ ["increasefontsize", "decreasefontsize"],
+ ["orderedlist", "unorderedlist"],
+ ["indent", "outdent"],
+ ["justifyleft", "justifycenter", "justifyright"],
+ ["link", "unlink", "image", "horizontalrule"],
+ ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
+ ["cut", "copy", "paste"]
+ ],
+ css: null,
+ toolbarText: {
+ bold: "Bold", italic: "Italic", underline: "Underline", strikethrough: "Strike-Through",
+ cut: "Cut", copy: "Copy", paste: "Paste",
+ h1: "Heading 1", h2: "Heading 2", h3: "Heading 3", h4: "Heading 4", h5: "Heading 5", h6: "Heading 6", p: "Paragraph",
+ indent: "Indent", outdent: "Outdent", horizontalrule: "Insert Horizontal Rule",
+ justifyleft: "Left Justify", justifycenter: "Center Justify", justifyright: "Right Justify",
+ increasefontsize: "Increase Font Size", decreasefontsize: "Decrease Font Size", forecolor: "Text Color",
+ link: "Insert Link", unlink: "Remove Link", image: "Insert Image",
+ orderedlist: "Insert Ordered List", unorderedlist: "Insert Unordered List",
+ subscript: "Subscript", superscript: "Superscript",
+ html: "Show/Hide HTML Source View"
+ }
+ };
+ var priv = {
+ toolbarButtons: {
+ strikethrough: "strikeThrough", orderedlist: "orderedList", unorderedlist: "unorderedList",
+ horizontalrule: "insertHorizontalRule",
+ justifyleft: "justifyLeft", justifycenter: "justifyCenter", justifyright: "justifyRight",
+ increasefontsize: "increaseFontSize", decreasefontsize: "decreaseFontSize",
+ html: function(btn) {
+ this.toggleHTMLView();
+ }
+ },
+ initEditor: function(options) {
+ var edit = this.editor = this.iframe[0].contentWindow.document;
+ edit.designMode = 'on';
+ edit.open();
+ edit.write(this.textarea.val());
+ edit.close();
+ if (options.css) {
+ var e = edit.createElement('link'); e.rel = 'stylesheet'; e.type = 'text/css'; e.href = options.css; edit.getElementsByTagName('head')[0].appendChild(e);
+ }
+ },
+ initToolBar: function(options) {
+ var that = this;
+
+ var menuItem = function(className, altText, action) {
+ return $("
").append($("").addClass(className).attr("title", altText).click(function() { action.call(that, $(this)); }));
+ };
+
+ function addButtons(arr) {
+ var ul = $("").appendTo(that.toolbar);
+ for (var i = 0; i < arr.length; i++) {
+ var e = arr[i];
+ if ((typeof (e)).toLowerCase() === "string") {
+ if (e === "|") {
+ ul.append($(''));
+ } else {
+ var f = (function(e) {
+ // If button name exists in priv.toolbarButtons then call the "method" defined there, otherwise call the method with the same name
+ var m = priv.toolbarButtons[e] || e;
+ if ((typeof (m)).toLowerCase() === "function") {
+ return function(btn) { m.call(this, btn); };
+ } else {
+ return function() { this[m](); this.editor.body.focus(); };
+ }
+ })(e.toLowerCase());
+ var t = options.toolbarText[e.toLowerCase()];
+ ul.append(menuItem(e.toLowerCase(), t || e, f));
+ }
+ } else {
+ ul.append(menuItem(e.css, e.text, e.action));
+ }
+ }
+ };
+ if (options.toolbar.length !== 0 && priv.isArray(options.toolbar[0])) {
+ for (var i = 0; i < options.toolbar.length; i++) {
+ addButtons(options.toolbar[i]);
+ }
+ } else {
+ addButtons(options.toolbar);
+ }
+ },
+ attachEditorEvents: function() {
+ var t = this;
+
+ var fnHA = function() {
+ t.updateHtmlArea();
+ };
+
+ this.textarea.click(fnHA).
+ keyup(fnHA).
+ keydown(fnHA).
+ mousedown(fnHA).
+ blur(fnHA);
+
+
+
+ var fnTA = function() {
+ t.updateTextArea();
+ };
+
+ $(this.editor.body).click(fnTA).
+ keyup(fnTA).
+ keydown(fnTA).
+ mousedown(fnTA).
+ blur(fnTA);
+
+ $('form').submit(function() { t.toggleHTMLView(); t.toggleHTMLView(); });
+ //$(this.textarea[0].form).submit(function() { //this.textarea.closest("form").submit(function() {
+
+
+ // Fix for ASP.NET Postback Model
+ if (window.__doPostBack) {
+ var old__doPostBack = __doPostBack;
+ window.__doPostBack = function() {
+ if (t) {
+ if (t.toggleHTMLView) {
+ t.toggleHTMLView();
+ t.toggleHTMLView();
+ }
+ }
+ return old__doPostBack.apply(window, arguments);
+ };
+ }
+
+ },
+ isArray: function(v) {
+ return v && typeof v === 'object' && typeof v.length === 'number' && typeof v.splice === 'function' && !(v.propertyIsEnumerable('length'));
+ }
+ };
+})(jQuery);
\ No newline at end of file
diff --git a/3.0/modules/pages/models/static_page.php b/3.0/modules/pages/models/static_page.php
new file mode 100644
index 00000000..b5519123
--- /dev/null
+++ b/3.0/modules/pages/models/static_page.php
@@ -0,0 +1,21 @@
+
+
+
+ $pages_per_column = $pages->count()/5 ?>
+ $column_page_count = 0 ?>
+
+
+
= t("Manage pages") ?>
+ = $form; ?>
+
+
+
+ = t2("There is one page", "There are %count pages", $pages->count()) ?>
+ ">=t("Add new page") ?>
+
+
+
+ foreach ($pages as $i => $one_page): ?>
+ $current_letter = strtoupper(mb_substr($one_page->name, 0, 1)) ?>
+
+ if ($i == 0): /* first letter */ ?>
+ = html::clean($current_letter) ?>
+
+ elseif ($last_letter != $current_letter): /* new letter */ ?>
+
+ if ($column_page_count > $pages_per_column): /* new column */ ?>
+ $column_page_count = 0 ?>
+ |
+
+ endif ?>
+ = html::clean($current_letter) ?>
+
+ |
+
+
+
+
diff --git a/3.0/modules/pages/views/admin_pages_new.html.php b/3.0/modules/pages/views/admin_pages_new.html.php
new file mode 100644
index 00000000..b7b59532
--- /dev/null
+++ b/3.0/modules/pages/views/admin_pages_new.html.php
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
= $theme->page_title ?>
+
+ =$form ?>
+
+
diff --git a/3.0/modules/pages/views/pages_display.html.php b/3.0/modules/pages/views/pages_display.html.php
new file mode 100644
index 00000000..7f704624
--- /dev/null
+++ b/3.0/modules/pages/views/pages_display.html.php
@@ -0,0 +1,26 @@
+
+ if (module::get_var("pages", "show_sidebar")) : ?>
+
+ endif ?>
+
+
= $title ?>
+
+ =$body ?>
+
+
diff --git a/3.0/modules/pages/views/pages_sidebar.html.php b/3.0/modules/pages/views/pages_sidebar.html.php
new file mode 100644
index 00000000..af959fa7
--- /dev/null
+++ b/3.0/modules/pages/views/pages_sidebar.html.php
@@ -0,0 +1,2 @@
+
+= $links ?>
diff --git a/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php b/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php
index cb28053c..10ebfe97 100644
--- a/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php
+++ b/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php
@@ -29,12 +29,26 @@ class tagsinalbum_block_Core {
case "tagsinalbum":
if (($theme->item) && ($theme->item->is_album())) {
$item = $theme->item;
- $all_tags = ORM::factory("tag")
+
+ // Create an ORM query for finding one instance of each tag
+ // used by children in the current album.
+ $tags_model = ORM::factory("tag")
->join("items_tags", "items_tags.tag_id", "tags.id")
->join("items", "items.id", "items_tags.item_id", "LEFT")
->where("items.parent_id", "=", $item->id)
- ->order_by("tags.id", "ASC")
- ->find_all();
+ ->order_by("tags.name", "ASC")
+ ->group_by("tags.id");
+
+ // Limit $all_tags to the first X tags if max_display_tags is set,
+ // else populate it with all tags used by this album's children.
+ $all_tags = "";
+ if (module::get_var("tagsinalbum", "max_display_tags") > 0) {
+ $all_tags = $tags_model->find_all(module::get_var("tagsinalbum", "max_display_tags"));
+ } else {
+ $all_tags = $tags_model->find_all();
+ }
+
+ // If this album has children that are tagged, display those tags.
if (count($all_tags) > 0) {
$block = new Block();
$block->css_id = "g-tags-in-album-block";
diff --git a/3.0/modules/tagsinalbum/module.info b/3.0/modules/tagsinalbum/module.info
index 6966c3e5..cc732774 100644
--- a/3.0/modules/tagsinalbum/module.info
+++ b/3.0/modules/tagsinalbum/module.info
@@ -1,7 +1,7 @@
name = "Tags In Album"
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
version = 2
-author_name = ""
-author_url = ""
+author_name = "rWatcher"
+author_url = "http://codex.gallery2.org/User:RWatcher"
info_url = "http://codex.gallery2.org/Gallery3:Modules:tagsinalbum"
-discuss_url = "http://gallery.menalto.com/forum_module_tagsinalbum"
+discuss_url = "http://gallery.menalto.com/node/99171"
diff --git a/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php b/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
index 6c8b1dff..8d9e0910 100644
--- a/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
+++ b/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
@@ -1,33 +1,11 @@
- // Create an array to store the tag names and urls in.
- $display_tags = array();
-
- // Loop through all tags in the album, copying their
- // names and urls into the array and skipping duplicates.
- $last_tagid = "";
- foreach ($all_tags as $one_tag) {
- if ($last_tagid != $one_tag->id) {
- $tag = ORM::factory("tag", $one_tag->id);
- $display_tags[] = array(html::clean($tag->name), $tag->url());
- $last_tagid = $one_tag->id;
- }
- if (module::get_var("tagsinalbum", "max_display_tags") > 0) {
- if (count($display_tags) == module::get_var("tagsinalbum", "max_display_tags")) {
- break;
- }
- }
- }
-
- // Sort the array.
- asort($display_tags);
-
- // Print out the list of tags as clickable links.
+ // Loop through each tag in $all_tags, and display it as a link.
$not_first = 0;
- foreach ($display_tags as $one_tag) {
+ foreach ($all_tags as $one_tag) {
if ($not_first++ > 0) {
print ", ";
}
- print "" . $one_tag[0] . "";
+ print "url() . "\">" . html::clean($one_tag->name) . "";
}
?>
diff --git a/3.1/modules/item_links/helpers/item_links_event.php b/3.1/modules/item_links/helpers/item_links_event.php
new file mode 100644
index 00000000..12cc94a1
--- /dev/null
+++ b/3.1/modules/item_links/helpers/item_links_event.php
@@ -0,0 +1,58 @@
+where("item_id", "=", $item->id)
+ ->find_all();
+
+ $existing_url = "";
+ if (count($item_url) > 0) {
+ $existing_url = $item_url[0]->url;
+ }
+ $form->edit_item
+ ->input("item_links_url")
+ ->label(t("Redirect to URL:"))
+ ->value($existing_url);
+ }
+
+ static function item_deleted($item) {
+ // Whenever an item is deleted, delete any corresponding data.
+ db::build()->delete("item_links")->where("item_id", "=", $item->id)->execute();
+ }
+
+ static function item_edit_form_completed($item, $form) {
+ // Update the database with any changes to the item_links field.
+ $record = ORM::factory("item_link")->where("item_id", "=", $item->id)->find();
+
+ if ($form->edit_item->item_links_url->value != "") {
+ if (!$record->loaded()) {
+ $record->item_id = $item->id;
+ }
+ $record->url = $form->edit_item->item_links_url->value;
+ $record->save();
+ } else {
+ db::build()->delete("item_links")->where("item_id", "=", $item->id)->execute();
+ }
+ }
+}
diff --git a/3.1/modules/item_links/helpers/item_links_installer.php b/3.1/modules/item_links/helpers/item_links_installer.php
new file mode 100644
index 00000000..f9d34d98
--- /dev/null
+++ b/3.1/modules/item_links/helpers/item_links_installer.php
@@ -0,0 +1,34 @@
+query("CREATE TABLE IF NOT EXISTS {item_links} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9) NOT NULL,
+ `url` text default NULL,
+ PRIMARY KEY (`id`),
+ KEY(`item_id`, `id`))
+ DEFAULT CHARSET=utf8;");
+
+ // Set the module's version number.
+ module::set_version("item_links", 1);
+ }
+}
diff --git a/3.1/modules/item_links/helpers/item_links_theme.php b/3.1/modules/item_links/helpers/item_links_theme.php
new file mode 100644
index 00000000..fbfcbb45
--- /dev/null
+++ b/3.1/modules/item_links/helpers/item_links_theme.php
@@ -0,0 +1,34 @@
+item()) {
+ $item_url = ORM::factory("item_link")
+ ->where("item_id", "=", $theme->item->id)
+ ->find_all();
+ if (count($item_url) > 0) {
+ url::redirect($item_url[0]->url);
+ }
+ }
+ return;
+ }
+}
diff --git a/3.1/modules/item_links/models/item_link.php b/3.1/modules/item_links/models/item_link.php
new file mode 100644
index 00000000..65335e27
--- /dev/null
+++ b/3.1/modules/item_links/models/item_link.php
@@ -0,0 +1,21 @@
+page_title = t("Manage pages");
+ $view->content = new View("admin_pages.html");
+ $query = ORM::factory("static_page");
+ $view->content->pages = $query->order_by("name", "ASC")->find_all();
+ $view->content->form = $this->get_prefs_form();
+ print $view;
+ }
+
+ public function createpage() {
+ // Display a form for creating a new page.
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Create page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_new_page_form();
+ print $view;
+ }
+
+ public function editpage($id) {
+ // Display a form for editing an existing page.
+ $existing_page = ORM::factory("static_page", $id);
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Edit page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_edit_page_form($existing_page);
+ print $view;
+ }
+
+ public function savepage() {
+ // Save a page to the database.
+
+ access::verify_csrf();
+
+ // Store form values into variables.
+ $page_id = Input::instance()->post("page_id");
+ $page_name = urlencode(trim(Input::instance()->post("page_name")));
+ $page_title = Input::instance()->post("page_title");
+ $page_code = Input::instance()->post("page_code");
+ $display_menu = Input::instance()->post("display_menu");
+
+ // If $page_id is set, update an existing page.
+ if (isset($page_id)) {
+ $update_page = ORM::factory("static_page", $page_id);
+ $update_page->title = $page_title;
+ $update_page->html_code = $page_code;
+ $update_page->display_menu = $display_menu;
+ $update_page->save();
+ message::success(t("Page %page_name updated", array("page_name" => $update_page->name)));
+ log::success("pages", t("Page %page_name updated", array("page_name" => $update_page->name)));
+ url::redirect("admin/pages");
+ } else {
+
+ // If $page_id is not set, we are dealing with a new page.
+ // Check and make sure a page with the same names doesn't already exist.
+ $existing_page = ORM::factory("static_page")
+ ->where("name", "=", $page_name)
+ ->find_all();
+
+ // If the page doesn't exist, save it to the database.
+ if (count($existing_page) == 0) {
+ $new_page = ORM::factory("static_page");
+ $new_page->name = $page_name;
+ $new_page->title = $page_title;
+ $new_page->html_code = $page_code;
+ $new_page->display_menu = $display_menu;
+ $new_page->save();
+ message::success(t("Page %page_name created", array("page_name" => $page_name)));
+ log::success("pages", t("Page %page_name created", array("page_name" => $page_name)));
+ url::redirect("admin/pages");
+ } else {
+
+ // If the page does exist, ask the user if they want to overwrite the old page with the new one.
+ message::error(t("Page %page_name already exists, press Save again to overwrite.", array("page_name" => $page_name)));
+ $view = new Admin_View("admin.html");
+ $view->page_title = t("Edit page");
+ $view->content = new View("admin_pages_new.html");
+ $view->content->form = $this->get_overwrite_page_form($existing_page[0]->id, $page_name, $page_title, $page_code, $display_menu);
+ print $view;
+ }
+ }
+ }
+
+ public function form_delete($id) {
+ // Display a form asking the user if they want to delete a page.
+ $one_page = ORM::factory("static_page", $id);
+ if ($one_page->loaded()) {
+ print $this->get_delete_form($one_page);
+ }
+ }
+
+ public function delete($id) {
+ // Delete the specified page.
+
+ access::verify_csrf();
+
+ // Make sure $id belongs to an actual page.
+ $one_page = ORM::factory("static_page", $id);
+ if (!$one_page->loaded()) {
+ throw new Kohana_404_Exception();
+ }
+
+ // If the form validates, delete the specified page.
+ $form = $this->get_delete_form($one_page);
+ if ($form->validate()) {
+ $name = $one_page->name;
+ $one_page->delete();
+ message::success(t("Deleted page %page_name", array("page_name" => $name)));
+ log::success("pages", t("Deleted page %page_name", array("page_name" => $name)));
+ json::reply(array("result" => "success", "location" => url::site("admin/pages")));
+ } else {
+ print $form;
+ }
+ }
+
+ public function form_rename($id) {
+ // Display a form to allow the user to rename a page.
+ $one_page = ORM::factory("static_page", $id);
+ if ($one_page->loaded()) {
+ print InPlaceEdit::factory(urldecode($one_page->name))
+ ->action("admin/pages/rename/$id")
+ ->render();
+ }
+ }
+
+ public function rename($id) {
+ // Rename an existing page.
+ access::verify_csrf();
+
+ // Make sure the page specified by $id exists.
+ $one_page = ORM::factory("static_page", $id);
+ if (!$one_page->loaded()) {
+ throw new Kohana_404_Exception();
+ }
+
+ $in_place_edit = InPlaceEdit::factory($one_page->name)
+ ->action("admin/pages/rename/$one_page->id")
+ ->rules(array("required", "length[1,64]"));
+
+ // If the form validates, and if the new name doesn't already exist, rename the page.
+ if ($in_place_edit->validate()) {
+ $old_name = $one_page->name;
+ $new_name = urlencode(trim($in_place_edit->value()));
+ $new_name_exists = ORM::factory("static_page")->where("name", "=", $new_name)->find_all();
+ if (count($new_name_exists) == 0) {
+ $one_page->name = $new_name;
+ $one_page->save();
+ $message = t("Renamed page %old_name to %new_name",
+ array("old_name" => $old_name, "new_name" => $new_name));
+ message::success($message);
+ log::success("pages", $message);
+ json::reply(array("result" => "success", "location" => url::site("admin/pages")));
+ } else {
+ json::reply(array("result" => "error", "form" => (string)$in_place_edit->render()));
+ }
+ } else {
+ json::reply(array("result" => "error", "form" => (string)$in_place_edit->render()));
+ }
+ }
+
+ static function get_delete_form($one_page) {
+ // Generate a new form asking the user if they want to delete a page.
+ $form = new Forge("admin/pages/delete/$one_page->id", "", "post", array("id" => "g-delete-pages-form"));
+ $group = $form->group("delete_page")
+ ->label(t("Really delete page %page_name?", array("page_name" => $one_page->name)));
+ $group->submit("")->value(t("Delete Page"));
+ return $form;
+ }
+
+ private function get_new_page_form() {
+ // Generate a form for creating a new page.
+ $form = new Forge("admin/pages/savepage", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("new_page");
+ $pages_group->input("page_name")
+ ->label(t("Name"));
+ $pages_group->input("page_title")
+ ->label(t("Title"));
+ $pages_group->textarea("page_code")
+ ->label(t("HTML Code"));
+ $pages_group->checkbox("display_menu")
+ ->label(t("Display in menu?"))
+ ->checked(false);
+ $pages_group->submit("save_page")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ private function get_overwrite_page_form($id, $name, $title, $html_code, $display_menu) {
+ // Generate a form for overwriting an existing page.
+ $form = new Forge("admin/pages/savepage", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("new_page");
+ $pages_group->hidden("page_id")
+ ->value($id);
+ $pages_group->input("page_name")
+ ->label(t("Name"))
+ ->readonly()
+ ->value($name);
+ $pages_group->input("page_title")
+ ->label(t("Title"))
+ ->value($title);
+ $pages_group->textarea("page_code")
+ ->label(t("HTML Code"))
+ ->value($html_code);
+ $pages_group->checkbox("display_menu")
+ ->label(t("Display in menu?"))
+ ->checked($display_menu);
+ $pages_group->submit("save_page")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ private function get_edit_page_form($existing_page) {
+ // Generate a form for editing an existing page. Reuse the overwrite form for as it's basically the same thing.
+ return ($this->get_overwrite_page_form($existing_page->id, $existing_page->name, $existing_page->title, $existing_page->html_code, $existing_page->display_menu));
+ }
+
+ private function get_prefs_form() {
+ // Generate a form for global preferences.
+ $form = new Forge("admin/pages/saveprefs", "", "post",
+ array("id" => "g-pages-admin-form"));
+
+ $pages_group = $form->group("preferences")->label(t("Settings"));
+ $pages_group->checkbox("display_sidebar")
+ ->label(t("Hide sidebar on Pages?"))
+ ->checked(module::get_var("pages", "show_sidebar"));
+ $pages_group->submit("save_prefs")
+ ->value(t("Save"));
+
+ return $form;
+ }
+
+ public function saveprefs() {
+ // Save a preferences to the database.
+
+ access::verify_csrf();
+
+ // Save form variables.
+ module::set_var("pages", "show_sidebar", Input::instance()->post("display_sidebar"));
+
+ // Display message and load main pages admin screen.
+ message::success(t("Your settings have been saved."));
+ url::redirect("admin/pages");
+ }
+}
diff --git a/3.1/modules/pages/controllers/pages.php b/3.1/modules/pages/controllers/pages.php
new file mode 100644
index 00000000..8b0f7c2d
--- /dev/null
+++ b/3.1/modules/pages/controllers/pages.php
@@ -0,0 +1,42 @@
+where("name", "=", $page_name)
+ ->find_all();
+
+ // If it doesn't exist, display a 404 error.
+ if (count($existing_page) == 0) {
+ throw new Kohana_404_Exception();
+ }
+
+ // Display the page.
+ $template = new Theme_View("page.html", "other", "Pages");
+ $template->page_title = t("Gallery :: ") . $existing_page[0]->title;
+ $template->content = new View("pages_display.html");
+ $template->content->title = $existing_page[0]->title;
+ $template->content->body = $existing_page[0]->html_code;
+ print $template;
+ }
+}
diff --git a/3.1/modules/pages/css/jHtmlArea.css b/3.1/modules/pages/css/jHtmlArea.css
new file mode 100644
index 00000000..641ea291
--- /dev/null
+++ b/3.1/modules/pages/css/jHtmlArea.css
@@ -0,0 +1,48 @@
+div.jHtmlArea { display: inline block; border: solid 1px #ccc; }
+div.jHtmlArea div { padding: 0px; margin: 0px; }
+div.jHtmlArea .ToolBar { }
+div.jHtmlArea .ToolBar ul { border: solid 0px #ccc; margin: 1px; padding: 1px; position:relative; display: inline; background: #fff url(../images/jHtmlArea_Toolbar_Group_BG.png) repeat-x;}
+div.jHtmlArea .ToolBar ul li { list-style-type: none; float: left; border: none; padding: 1px; margin: 1px; }
+div.jHtmlArea .ToolBar ul li:hover { border: solid 1px #ccc; background: #ddd url(../images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png); padding: 0; }
+div.jHtmlArea .ToolBar ul li a { display: block; width: 16px; height: 16px; background: url(../images/jHtmlArea.png) no-repeat -16px -500px; border: none; cursor: pointer; padding: 0px; }
+div.jHtmlArea .ToolBar ul li a.highlighted { border: solid 1px #aaa; background-color: #bbb; padding: 0; }
+div.jHtmlArea .ToolBar ul li.separator {height: 16px; margin: 0 2px 0 3px; border-left: 1px solid #ccc;}
+div.jHtmlArea .ToolBar ul li.separator:hover { padding: 1px; background-color: #fff; border-top:none; border-bottom:none; border-right:none;}
+
+div.jHtmlArea .ToolBar ul li a:hover { }
+div.jHtmlArea .ToolBar ul li a.bold { background-position: 0 0; }
+div.jHtmlArea .ToolBar ul li a.italic { background-position: -16px 0; }
+div.jHtmlArea .ToolBar ul li a.underline { background-position: -32px 0; }
+div.jHtmlArea .ToolBar ul li a.strikethrough { background-position: -48px 0; }
+div.jHtmlArea .ToolBar ul li a.link { background-position: -64px 0; }
+div.jHtmlArea .ToolBar ul li a.unlink { background-position: -80px 0; }
+div.jHtmlArea .ToolBar ul li a.orderedlist { background-position: -96px 0; }
+div.jHtmlArea .ToolBar ul li a.unorderedlist { background-position: -112px 0; }
+div.jHtmlArea .ToolBar ul li a.image { background-position: -128px 0; }
+div.jHtmlArea .ToolBar ul li a.cut { background-position: -144px 0; }
+div.jHtmlArea .ToolBar ul li a.copy { background-position: -160px 0; }
+div.jHtmlArea .ToolBar ul li a.paste { background-position: -176px 0; }
+
+div.jHtmlArea .ToolBar ul li a.html { background-position: -192px 0; opacity:0.6; filter:alpha(opacity=60);}
+div.jHtmlArea .ToolBar ul li a.html.highlighted { opacity:1.0; filter:alpha(opacity=100);}
+
+div.jHtmlArea .ToolBar ul li a.h1 { background-position: 0 -16px;}
+div.jHtmlArea .ToolBar ul li a.h2 { background-position: -16px -16px;}
+div.jHtmlArea .ToolBar ul li a.h3 { background-position: -32px -16px;}
+div.jHtmlArea .ToolBar ul li a.h4 { background-position: -48px -16px;}
+div.jHtmlArea .ToolBar ul li a.h5 { background-position: -64px -16px;}
+div.jHtmlArea .ToolBar ul li a.h6 { background-position: -80px -16px;}
+div.jHtmlArea .ToolBar ul li a.subscript { background-position: -96px -16px;}
+div.jHtmlArea .ToolBar ul li a.superscript { background-position: -112px -16px;}
+div.jHtmlArea .ToolBar ul li a.indent { background-position: -128px -16px;}
+div.jHtmlArea .ToolBar ul li a.outdent { background-position: -144px -16px;}
+div.jHtmlArea .ToolBar ul li a.horizontalrule { background-position: -160px -16px;}
+div.jHtmlArea .ToolBar ul li a.p { background-position: -176px -16px;}
+
+
+div.jHtmlArea .ToolBar ul li a.justifyleft { background-position: 0 -32px;}
+div.jHtmlArea .ToolBar ul li a.justifycenter { background-position: -16px -32px;}
+div.jHtmlArea .ToolBar ul li a.justifyright { background-position: -32px -32px;}
+div.jHtmlArea .ToolBar ul li a.increasefontsize { background-position: -48px -32px;}
+div.jHtmlArea .ToolBar ul li a.decreasefontsize { background-position: -64px -32px;}
+div.jHtmlArea .ToolBar ul li a.forecolor { background-position: -80px -32px;}
\ No newline at end of file
diff --git a/3.1/modules/pages/helpers/pages_block.php b/3.1/modules/pages/helpers/pages_block.php
new file mode 100644
index 00000000..089dd12b
--- /dev/null
+++ b/3.1/modules/pages/helpers/pages_block.php
@@ -0,0 +1,57 @@
+ t("Pages Links"));
+ }
+
+ static function get($block_id, $theme) {
+ $block = "";
+
+ switch ($block_id) {
+ case "pages_block":
+
+ // Create a new block with a list of all Pages and their links.
+
+ // Query the database for all existing pages.
+ // If at least one page exists, display the sidebar block.
+ $query = ORM::factory("static_page");
+ $pages = $query->order_by("title", "ASC")->find_all();
+ if (count($pages) > 0) {
+
+ // Loop through each page and generate an HTML list of their links and titles.
+ $content = "";
+ foreach ($pages as $one_page) {
+ $content .= "- name) . "\">" . $one_page->title . "
";
+ }
+ $content .= "
";
+
+ // Make a new sidebar block.
+ $block = new Block();
+ $block->css_id = "g-pages";
+ $block->title = t("Pages");
+ $block->content = new View("pages_sidebar.html");
+ $block->content->links = $content;
+ }
+ break;
+ }
+ return $block;
+ }
+}
diff --git a/3.1/modules/pages/helpers/pages_event.php b/3.1/modules/pages/helpers/pages_event.php
new file mode 100644
index 00000000..9e37aa8b
--- /dev/null
+++ b/3.1/modules/pages/helpers/pages_event.php
@@ -0,0 +1,44 @@
+get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("pages")
+ ->label(t("Pages Settings"))
+ ->url(url::site("admin/pages")));
+ }
+
+ static function site_menu($menu, $theme) {
+ $menu_pages = ORM::factory("static_page")
+ ->where("display_menu", "=", true)
+ ->order_by("title", "DESC")
+ ->find_all();
+ if (count($menu_pages) > 0) {
+ foreach ($menu_pages as $one_page) {
+ $menu->add_after("home", Menu::factory("link")
+ ->id("pages-" . $one_page->id)
+ ->label($one_page->title)
+ ->url(url::site("pages/show/" . $one_page->name)));
+ }
+ }
+ }
+}
diff --git a/3.1/modules/pages/helpers/pages_installer.php b/3.1/modules/pages/helpers/pages_installer.php
new file mode 100644
index 00000000..cd1f1546
--- /dev/null
+++ b/3.1/modules/pages/helpers/pages_installer.php
@@ -0,0 +1,44 @@
+query("CREATE TABLE IF NOT EXISTS {static_pages} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(255) default NULL,
+ `title` varchar(255) default NULL,
+ `html_code` text default NULL,
+ `display_menu` boolean default 0,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ DEFAULT CHARSET=utf8;");
+
+ // Set the module version number.
+ module::set_version("pages", 2);
+ }
+ static function upgrade($version) {
+ $db = Database::instance();
+ if ($version == 1) {
+ $db->query("ALTER TABLE {static_pages} ADD COLUMN `display_menu` boolean default 0");
+ module::set_version("pages", $version = 2);
+ }
+ }
+}
diff --git a/3.1/modules/pages/helpers/pages_theme.php b/3.1/modules/pages/helpers/pages_theme.php
new file mode 100644
index 00000000..ec57a2ce
--- /dev/null
+++ b/3.1/modules/pages/helpers/pages_theme.php
@@ -0,0 +1,27 @@
+script("jHtmlArea-0.7.0.js") .
+ $theme->css("jHtmlArea.css");
+ }
+}
+
\ No newline at end of file
diff --git a/3.1/modules/pages/images/jHtmlArea.png b/3.1/modules/pages/images/jHtmlArea.png
new file mode 100644
index 00000000..54c66a10
Binary files /dev/null and b/3.1/modules/pages/images/jHtmlArea.png differ
diff --git a/3.1/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png b/3.1/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
new file mode 100644
index 00000000..bcfb0545
Binary files /dev/null and b/3.1/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png differ
diff --git a/3.1/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png b/3.1/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png
new file mode 100644
index 00000000..4287b5b8
Binary files /dev/null and b/3.1/modules/pages/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png differ
diff --git a/3.1/modules/pages/js/jHtmlArea-0.7.0.js b/3.1/modules/pages/js/jHtmlArea-0.7.0.js
new file mode 100644
index 00000000..d1e360c4
--- /dev/null
+++ b/3.1/modules/pages/js/jHtmlArea-0.7.0.js
@@ -0,0 +1,403 @@
+/*
+* jHtmlArea 0.7.0 - WYSIWYG Html Editor jQuery Plugin
+* Copyright (c) 2009 Chris Pietschmann
+* http://jhtmlarea.codeplex.com
+* Licensed under the Microsoft Reciprocal License (Ms-RL)
+* http://jhtmlarea.codeplex.com/license
+*/
+(function($) {
+ $.fn.htmlarea = function(opts) {
+ if (opts && typeof (opts) === "string") {
+ var args = [];
+ for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
+ var htmlarea = jHtmlArea(this[0]);
+ var f = htmlarea[opts];
+ if (f) { return f.apply(htmlarea, args); }
+ }
+ return this.each(function() { jHtmlArea(this, opts); });
+ };
+ var jHtmlArea = window.jHtmlArea = function(elem, options) {
+ if (elem.jquery) {
+ return jHtmlArea(elem[0]);
+ }
+ if (elem.jhtmlareaObject) {
+ return elem.jhtmlareaObject;
+ } else {
+ return new jHtmlArea.fn.init(elem, options);
+ }
+ };
+ jHtmlArea.fn = jHtmlArea.prototype = {
+
+ // The current version of jHtmlArea being used
+ jhtmlarea: "0.7.0",
+
+ init: function(elem, options) {
+ if (elem.nodeName.toLowerCase() === "textarea") {
+ var opts = $.extend({}, jHtmlArea.defaultOptions, options);
+ elem.jhtmlareaObject = this;
+
+ var textarea = this.textarea = $(elem);
+ var container = this.container = $("").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
+
+ var toolbar = this.toolbar = $("").addClass("ToolBar").appendTo(container);
+ priv.initToolBar.call(this, opts);
+
+ var iframe = this.iframe = $("").height(textarea.height());
+ iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
+ var htmlarea = this.htmlarea = $("").append(iframe);
+
+ container.append(htmlarea).append(textarea.hide());
+
+ priv.initEditor.call(this, opts);
+ priv.attachEditorEvents.call(this);
+
+ // Fix total height to match TextArea
+ iframe.height(iframe.height() - toolbar.height());
+ toolbar.width(textarea.width() - 2);
+
+ if (opts.loaded) { opts.loaded.call(this); }
+ }
+ },
+ dispose: function() {
+ this.textarea.show().insertAfter(this.container);
+ this.container.remove();
+ this.textarea[0].jhtmlareaObject = null;
+ },
+ execCommand: function(a, b, c) {
+ this.iframe[0].contentWindow.focus();
+ this.editor.execCommand(a, b || false, c || null);
+ this.updateTextArea();
+ },
+ ec: function(a, b, c) {
+ this.execCommand(a, b, c);
+ },
+ queryCommandValue: function(a) {
+ this.iframe[0].contentWindow.focus();
+ return this.editor.queryCommandValue(a);
+ },
+ qc: function(a) {
+ return this.queryCommandValue(a);
+ },
+ getSelectedHTML: function() {
+ if ($.browser.msie) {
+ return this.getRange().htmlText;
+ } else {
+ var elem = this.getRange().cloneContents();
+ return $("").append($(elem)).html();
+ }
+ },
+ getSelection: function() {
+ if ($.browser.msie) {
+ //return (this.editor.parentWindow.getSelection) ? this.editor.parentWindow.getSelection() : this.editor.selection;
+ return this.editor.selection;
+ } else {
+ return this.iframe[0].contentDocument.defaultView.getSelection();
+ }
+ },
+ getRange: function() {
+ var s = this.getSelection();
+ if (!s) { return null; }
+ //return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
+ return (s.getRangeAt) ? s.getRangeAt(0) : s.createRange();
+ },
+ html: function(v) {
+ if (v) {
+ this.pastHTML(v);
+ } else {
+ return toHtmlString();
+ }
+ },
+ pasteHTML: function(html) {
+ this.iframe[0].contentWindow.focus();
+ var r = this.getRange();
+ if ($.browser.msie) {
+ r.pasteHTML(html);
+ } else if ($.browser.mozilla) {
+ r.deleteContents();
+ r.insertNode($((html.indexOf("<") != 0) ? $("").append(html) : html)[0]);
+ } else { // Safari
+ r.deleteContents();
+ r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "" + html + "" : html))[0]);
+ }
+ r.collapse(false);
+ r.select();
+ },
+ cut: function() {
+ this.ec("cut");
+ },
+ copy: function() {
+ this.ec("copy");
+ },
+ paste: function() {
+ this.ec("paste");
+ },
+ bold: function() { this.ec("bold"); },
+ italic: function() { this.ec("italic"); },
+ underline: function() { this.ec("underline"); },
+ strikeThrough: function() { this.ec("strikethrough"); },
+ image: function(url) {
+ if ($.browser.msie && !url) {
+ this.ec("insertImage", true);
+ } else {
+ this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
+ }
+ },
+ removeFormat: function() {
+ this.ec("removeFormat", false, []);
+ this.unlink();
+ },
+ link: function() {
+ if ($.browser.msie) {
+ this.ec("createLink", true);
+ } else {
+ this.ec("createLink", false, prompt("Link URL:", "http://"));
+ }
+ },
+ unlink: function() { this.ec("unlink", false, []); },
+ orderedList: function() { this.ec("insertorderedlist"); },
+ unorderedList: function() { this.ec("insertunorderedlist"); },
+ superscript: function() { this.ec("superscript"); },
+ subscript: function() { this.ec("subscript"); },
+
+ p: function() {
+ this.formatBlock("");
+ },
+ h1: function() {
+ this.heading(1);
+ },
+ h2: function() {
+ this.heading(2);
+ },
+ h3: function() {
+ this.heading(3);
+ },
+ h4: function() {
+ this.heading(4);
+ },
+ h5: function() {
+ this.heading(5);
+ },
+ h6: function() {
+ this.heading(6);
+ },
+ heading: function(h) {
+ this.formatBlock($.browser.msie ? "Heading " + h : "h" + h);
+ },
+
+ indent: function() {
+ this.ec("indent");
+ },
+ outdent: function() {
+ this.ec("outdent");
+ },
+
+ insertHorizontalRule: function() {
+ this.ec("insertHorizontalRule", false, "ht");
+ },
+
+ justifyLeft: function() {
+ this.ec("justifyLeft");
+ },
+ justifyCenter: function() {
+ this.ec("justifyCenter");
+ },
+ justifyRight: function() {
+ this.ec("justifyRight");
+ },
+
+ increaseFontSize: function() {
+ if ($.browser.msie) {
+ this.ec("fontSize", false, this.qc("fontSize") + 1);
+ } else if ($.browser.safari) {
+ this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "larger")[0]);
+ } else {
+ this.ec("increaseFontSize", false, "big");
+ }
+ },
+ decreaseFontSize: function() {
+ if ($.browser.msie) {
+ this.ec("fontSize", false, this.qc("fontSize") - 1);
+ } else if ($.browser.safari) {
+ this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "smaller")[0]);
+ } else {
+ this.ec("decreaseFontSize", false, "small");
+ }
+ },
+
+ forecolor: function(c) {
+ this.ec("foreColor", false, c || prompt("Enter HTML Color:", "#"));
+ },
+
+ formatBlock: function(v) {
+ this.ec("formatblock", false, v || null);
+ },
+
+ showHTMLView: function() {
+ this.updateTextArea();
+ this.textarea.show();
+ this.htmlarea.hide();
+ $("ul li:not(li:has(a.html))", this.toolbar).hide();
+ $("ul:not(:has(:visible))", this.toolbar).hide();
+ $("ul li a.html", this.toolbar).addClass("highlighted");
+ },
+ hideHTMLView: function() {
+ this.updateHtmlArea();
+ this.textarea.hide();
+ this.htmlarea.show();
+ $("ul", this.toolbar).show();
+ $("ul li", this.toolbar).show().find("a.html").removeClass("highlighted");
+ },
+ toggleHTMLView: function() {
+ (this.textarea.is(":hidden")) ? this.showHTMLView() : this.hideHTMLView();
+ },
+
+ toHtmlString: function() {
+ return this.editor.body.innerHTML;
+ },
+ toString: function() {
+ return this.editor.body.innerText;
+ },
+
+ updateTextArea: function() {
+ this.textarea.val(this.toHtmlString());
+ },
+ updateHtmlArea: function() {
+ this.editor.body.innerHTML = this.textarea.val();
+ }
+ };
+ jHtmlArea.fn.init.prototype = jHtmlArea.fn;
+
+ jHtmlArea.defaultOptions = {
+ toolbar: [
+ ["html"], ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
+ ["increasefontsize", "decreasefontsize"],
+ ["orderedlist", "unorderedlist"],
+ ["indent", "outdent"],
+ ["justifyleft", "justifycenter", "justifyright"],
+ ["link", "unlink", "image", "horizontalrule"],
+ ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
+ ["cut", "copy", "paste"]
+ ],
+ css: null,
+ toolbarText: {
+ bold: "Bold", italic: "Italic", underline: "Underline", strikethrough: "Strike-Through",
+ cut: "Cut", copy: "Copy", paste: "Paste",
+ h1: "Heading 1", h2: "Heading 2", h3: "Heading 3", h4: "Heading 4", h5: "Heading 5", h6: "Heading 6", p: "Paragraph",
+ indent: "Indent", outdent: "Outdent", horizontalrule: "Insert Horizontal Rule",
+ justifyleft: "Left Justify", justifycenter: "Center Justify", justifyright: "Right Justify",
+ increasefontsize: "Increase Font Size", decreasefontsize: "Decrease Font Size", forecolor: "Text Color",
+ link: "Insert Link", unlink: "Remove Link", image: "Insert Image",
+ orderedlist: "Insert Ordered List", unorderedlist: "Insert Unordered List",
+ subscript: "Subscript", superscript: "Superscript",
+ html: "Show/Hide HTML Source View"
+ }
+ };
+ var priv = {
+ toolbarButtons: {
+ strikethrough: "strikeThrough", orderedlist: "orderedList", unorderedlist: "unorderedList",
+ horizontalrule: "insertHorizontalRule",
+ justifyleft: "justifyLeft", justifycenter: "justifyCenter", justifyright: "justifyRight",
+ increasefontsize: "increaseFontSize", decreasefontsize: "decreaseFontSize",
+ html: function(btn) {
+ this.toggleHTMLView();
+ }
+ },
+ initEditor: function(options) {
+ var edit = this.editor = this.iframe[0].contentWindow.document;
+ edit.designMode = 'on';
+ edit.open();
+ edit.write(this.textarea.val());
+ edit.close();
+ if (options.css) {
+ var e = edit.createElement('link'); e.rel = 'stylesheet'; e.type = 'text/css'; e.href = options.css; edit.getElementsByTagName('head')[0].appendChild(e);
+ }
+ },
+ initToolBar: function(options) {
+ var that = this;
+
+ var menuItem = function(className, altText, action) {
+ return $("
").append($("").addClass(className).attr("title", altText).click(function() { action.call(that, $(this)); }));
+ };
+
+ function addButtons(arr) {
+ var ul = $("").appendTo(that.toolbar);
+ for (var i = 0; i < arr.length; i++) {
+ var e = arr[i];
+ if ((typeof (e)).toLowerCase() === "string") {
+ if (e === "|") {
+ ul.append($(''));
+ } else {
+ var f = (function(e) {
+ // If button name exists in priv.toolbarButtons then call the "method" defined there, otherwise call the method with the same name
+ var m = priv.toolbarButtons[e] || e;
+ if ((typeof (m)).toLowerCase() === "function") {
+ return function(btn) { m.call(this, btn); };
+ } else {
+ return function() { this[m](); this.editor.body.focus(); };
+ }
+ })(e.toLowerCase());
+ var t = options.toolbarText[e.toLowerCase()];
+ ul.append(menuItem(e.toLowerCase(), t || e, f));
+ }
+ } else {
+ ul.append(menuItem(e.css, e.text, e.action));
+ }
+ }
+ };
+ if (options.toolbar.length !== 0 && priv.isArray(options.toolbar[0])) {
+ for (var i = 0; i < options.toolbar.length; i++) {
+ addButtons(options.toolbar[i]);
+ }
+ } else {
+ addButtons(options.toolbar);
+ }
+ },
+ attachEditorEvents: function() {
+ var t = this;
+
+ var fnHA = function() {
+ t.updateHtmlArea();
+ };
+
+ this.textarea.click(fnHA).
+ keyup(fnHA).
+ keydown(fnHA).
+ mousedown(fnHA).
+ blur(fnHA);
+
+
+
+ var fnTA = function() {
+ t.updateTextArea();
+ };
+
+ $(this.editor.body).click(fnTA).
+ keyup(fnTA).
+ keydown(fnTA).
+ mousedown(fnTA).
+ blur(fnTA);
+
+ $('form').submit(function() { t.toggleHTMLView(); t.toggleHTMLView(); });
+ //$(this.textarea[0].form).submit(function() { //this.textarea.closest("form").submit(function() {
+
+
+ // Fix for ASP.NET Postback Model
+ if (window.__doPostBack) {
+ var old__doPostBack = __doPostBack;
+ window.__doPostBack = function() {
+ if (t) {
+ if (t.toggleHTMLView) {
+ t.toggleHTMLView();
+ t.toggleHTMLView();
+ }
+ }
+ return old__doPostBack.apply(window, arguments);
+ };
+ }
+
+ },
+ isArray: function(v) {
+ return v && typeof v === 'object' && typeof v.length === 'number' && typeof v.splice === 'function' && !(v.propertyIsEnumerable('length'));
+ }
+ };
+})(jQuery);
\ No newline at end of file
diff --git a/3.1/modules/pages/models/static_page.php b/3.1/modules/pages/models/static_page.php
new file mode 100644
index 00000000..b5519123
--- /dev/null
+++ b/3.1/modules/pages/models/static_page.php
@@ -0,0 +1,21 @@
+
+
+
+ $pages_per_column = $pages->count()/5 ?>
+ $column_page_count = 0 ?>
+
+
+
= t("Manage pages") ?>
+ = $form; ?>
+
+
+
+ = t2("There is one page", "There are %count pages", $pages->count()) ?>
+ ">=t("Add new page") ?>
+
+
+
+ foreach ($pages as $i => $one_page): ?>
+ $current_letter = strtoupper(mb_substr($one_page->name, 0, 1)) ?>
+
+ if ($i == 0): /* first letter */ ?>
+ = html::clean($current_letter) ?>
+
+ elseif ($last_letter != $current_letter): /* new letter */ ?>
+
+ if ($column_page_count > $pages_per_column): /* new column */ ?>
+ $column_page_count = 0 ?>
+ |
+
+ endif ?>
+ = html::clean($current_letter) ?>
+
+ |
+
+
+
+
diff --git a/3.1/modules/pages/views/admin_pages_new.html.php b/3.1/modules/pages/views/admin_pages_new.html.php
new file mode 100644
index 00000000..b7b59532
--- /dev/null
+++ b/3.1/modules/pages/views/admin_pages_new.html.php
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
= $theme->page_title ?>
+
+ =$form ?>
+
+
diff --git a/3.1/modules/pages/views/pages_display.html.php b/3.1/modules/pages/views/pages_display.html.php
new file mode 100644
index 00000000..7f704624
--- /dev/null
+++ b/3.1/modules/pages/views/pages_display.html.php
@@ -0,0 +1,26 @@
+
+ if (module::get_var("pages", "show_sidebar")) : ?>
+
+ endif ?>
+
+
= $title ?>
+
+ =$body ?>
+
+
diff --git a/3.1/modules/pages/views/pages_sidebar.html.php b/3.1/modules/pages/views/pages_sidebar.html.php
new file mode 100644
index 00000000..af959fa7
--- /dev/null
+++ b/3.1/modules/pages/views/pages_sidebar.html.php
@@ -0,0 +1,2 @@
+
+= $links ?>
diff --git a/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php b/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php
index cb28053c..10ebfe97 100644
--- a/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php
+++ b/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php
@@ -29,12 +29,26 @@ class tagsinalbum_block_Core {
case "tagsinalbum":
if (($theme->item) && ($theme->item->is_album())) {
$item = $theme->item;
- $all_tags = ORM::factory("tag")
+
+ // Create an ORM query for finding one instance of each tag
+ // used by children in the current album.
+ $tags_model = ORM::factory("tag")
->join("items_tags", "items_tags.tag_id", "tags.id")
->join("items", "items.id", "items_tags.item_id", "LEFT")
->where("items.parent_id", "=", $item->id)
- ->order_by("tags.id", "ASC")
- ->find_all();
+ ->order_by("tags.name", "ASC")
+ ->group_by("tags.id");
+
+ // Limit $all_tags to the first X tags if max_display_tags is set,
+ // else populate it with all tags used by this album's children.
+ $all_tags = "";
+ if (module::get_var("tagsinalbum", "max_display_tags") > 0) {
+ $all_tags = $tags_model->find_all(module::get_var("tagsinalbum", "max_display_tags"));
+ } else {
+ $all_tags = $tags_model->find_all();
+ }
+
+ // If this album has children that are tagged, display those tags.
if (count($all_tags) > 0) {
$block = new Block();
$block->css_id = "g-tags-in-album-block";
diff --git a/3.1/modules/tagsinalbum/module.info b/3.1/modules/tagsinalbum/module.info
index 6966c3e5..cc732774 100644
--- a/3.1/modules/tagsinalbum/module.info
+++ b/3.1/modules/tagsinalbum/module.info
@@ -1,7 +1,7 @@
name = "Tags In Album"
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
version = 2
-author_name = ""
-author_url = ""
+author_name = "rWatcher"
+author_url = "http://codex.gallery2.org/User:RWatcher"
info_url = "http://codex.gallery2.org/Gallery3:Modules:tagsinalbum"
-discuss_url = "http://gallery.menalto.com/forum_module_tagsinalbum"
+discuss_url = "http://gallery.menalto.com/node/99171"
diff --git a/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php b/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
index 6c8b1dff..8d9e0910 100644
--- a/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
+++ b/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
@@ -1,33 +1,11 @@
- // Create an array to store the tag names and urls in.
- $display_tags = array();
-
- // Loop through all tags in the album, copying their
- // names and urls into the array and skipping duplicates.
- $last_tagid = "";
- foreach ($all_tags as $one_tag) {
- if ($last_tagid != $one_tag->id) {
- $tag = ORM::factory("tag", $one_tag->id);
- $display_tags[] = array(html::clean($tag->name), $tag->url());
- $last_tagid = $one_tag->id;
- }
- if (module::get_var("tagsinalbum", "max_display_tags") > 0) {
- if (count($display_tags) == module::get_var("tagsinalbum", "max_display_tags")) {
- break;
- }
- }
- }
-
- // Sort the array.
- asort($display_tags);
-
- // Print out the list of tags as clickable links.
+ // Loop through each tag in $all_tags, and display it as a link.
$not_first = 0;
- foreach ($display_tags as $one_tag) {
+ foreach ($all_tags as $one_tag) {
if ($not_first++ > 0) {
print ", ";
}
- print "" . $one_tag[0] . "";
+ print "url() . "\">" . html::clean($one_tag->name) . "";
}
?>