Merge pull request #76 from rWatcher/master
New Modules Pages and Item Links plus updates to TagsInAlbum.
This commit is contained in:
commit
e290542761
58
3.0/modules/item_links/helpers/item_links_event.php
Normal file
58
3.0/modules/item_links/helpers/item_links_event.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_event_Core {
|
||||||
|
static function item_edit_form($item, $form) {
|
||||||
|
// Create fields on the album edit screen to allow the user to link
|
||||||
|
// the item to another page.
|
||||||
|
|
||||||
|
$item_url = ORM::factory("item_link")
|
||||||
|
->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
3.0/modules/item_links/helpers/item_links_installer.php
Normal file
34
3.0/modules/item_links/helpers/item_links_installer.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_installer {
|
||||||
|
static function install() {
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->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);
|
||||||
|
}
|
||||||
|
}
|
34
3.0/modules/item_links/helpers/item_links_theme.php
Normal file
34
3.0/modules/item_links/helpers/item_links_theme.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_theme_Core {
|
||||||
|
static function head($theme) {
|
||||||
|
// If the current page is an item, and if it's in the item_links table,
|
||||||
|
// then redirect to the specified web page.
|
||||||
|
if ($theme->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;
|
||||||
|
}
|
||||||
|
}
|
21
3.0/modules/item_links/models/item_link.php
Normal file
21
3.0/modules/item_links/models/item_link.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Item_Link_Model extends ORM {
|
||||||
|
}
|
7
3.0/modules/item_links/module.info
Normal file
7
3.0/modules/item_links/module.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name = "Item Links"
|
||||||
|
description = "Allows users to use Gallery items as links to external URLs."
|
||||||
|
version = 1
|
||||||
|
author_name = "rWatcher"
|
||||||
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:item_links"
|
||||||
|
discuss_url = "http://gallery.menalto.com/node/102548"
|
271
3.0/modules/pages/controllers/admin_pages.php
Normal file
271
3.0/modules/pages/controllers/admin_pages.php
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Admin_Pages_Controller extends Admin_Controller {
|
||||||
|
public function index() {
|
||||||
|
// Display the admin page.
|
||||||
|
$view = new Admin_View("admin.html");
|
||||||
|
$view->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 <i>%old_name</i> to <i>%new_name</i>",
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
42
3.0/modules/pages/controllers/pages.php
Normal file
42
3.0/modules/pages/controllers/pages.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Pages_Controller extends Controller {
|
||||||
|
public function show($page_name) {
|
||||||
|
// Display the page specified by $page_name, or a 404 error if it doesn't exist.
|
||||||
|
|
||||||
|
// Run a database search to look up the page.
|
||||||
|
$existing_page = ORM::factory("static_page")
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
}
|
48
3.0/modules/pages/css/jHtmlArea.css
Normal file
48
3.0/modules/pages/css/jHtmlArea.css
Normal file
@ -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;}
|
57
3.0/modules/pages/helpers/pages_block.php
Normal file
57
3.0/modules/pages/helpers/pages_block.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_block_Core {
|
||||||
|
static function get_site_list() {
|
||||||
|
return array("pages_block" => 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 = "<ul id=\"g-pages-list\">";
|
||||||
|
foreach ($pages as $one_page) {
|
||||||
|
$content .= "<li style=\"clear: both;\"><a href=\"" . url::site("pages/show/" . $one_page->name) . "\">" . $one_page->title . "</a></li>";
|
||||||
|
}
|
||||||
|
$content .= "</ul>";
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
44
3.0/modules/pages/helpers/pages_event.php
Normal file
44
3.0/modules/pages/helpers/pages_event.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_event_Core {
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
// Add a settings link to the admin menu.
|
||||||
|
$menu->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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
3.0/modules/pages/helpers/pages_installer.php
Normal file
44
3.0/modules/pages/helpers/pages_installer.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_installer {
|
||||||
|
static function install() {
|
||||||
|
// Create a table to store pages in.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
3.0/modules/pages/helpers/pages_theme.php
Normal file
27
3.0/modules/pages/helpers/pages_theme.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_theme_Core {
|
||||||
|
static function admin_head($theme) {
|
||||||
|
// Load jHtmlArea js and css.
|
||||||
|
return $theme->script("jHtmlArea-0.7.0.js") .
|
||||||
|
$theme->css("jHtmlArea.css");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
BIN
3.0/modules/pages/images/jHtmlArea.png
Normal file
BIN
3.0/modules/pages/images/jHtmlArea.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
3.0/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
Normal file
BIN
3.0/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 964 B |
Binary file not shown.
After Width: | Height: | Size: 942 B |
403
3.0/modules/pages/js/jHtmlArea-0.7.0.js
Normal file
403
3.0/modules/pages/js/jHtmlArea-0.7.0.js
Normal file
@ -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 = $("<div/>").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
|
||||||
|
|
||||||
|
var toolbar = this.toolbar = $("<div/>").addClass("ToolBar").appendTo(container);
|
||||||
|
priv.initToolBar.call(this, opts);
|
||||||
|
|
||||||
|
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
|
||||||
|
iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
|
||||||
|
var htmlarea = this.htmlarea = $("<div/>").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 $("<p/>").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) ? $("<span/>").append(html) : html)[0]);
|
||||||
|
} else { // Safari
|
||||||
|
r.deleteContents();
|
||||||
|
r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : 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("<p>");
|
||||||
|
},
|
||||||
|
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 $("<li/>").append($("<a href='javascript:void(0);'/>").addClass(className).attr("title", altText).click(function() { action.call(that, $(this)); }));
|
||||||
|
};
|
||||||
|
|
||||||
|
function addButtons(arr) {
|
||||||
|
var ul = $("<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($('<li class="separator"/>'));
|
||||||
|
} 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);
|
21
3.0/modules/pages/models/static_page.php
Normal file
21
3.0/modules/pages/models/static_page.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Static_Page_Model extends ORM {
|
||||||
|
}
|
7
3.0/modules/pages/module.info
Normal file
7
3.0/modules/pages/module.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name = "Pages"
|
||||||
|
description = "Allows Gallery admins to create static pages."
|
||||||
|
version = 2
|
||||||
|
author_name = "rWatcher"
|
||||||
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:Pages"
|
||||||
|
discuss_url = "http://gallery.menalto.com/node/102534"
|
59
3.0/modules/pages/views/admin_pages.html.php
Normal file
59
3.0/modules/pages/views/admin_pages.html.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("document").ready(function() {
|
||||||
|
// using JS for adding link titles to avoid running t() for each tag
|
||||||
|
$("#g-page-admin .g-page-name").attr("title", <?= t("Click to edit this page")->for_js() ?>);
|
||||||
|
$("#g-page-admin .g-delete-link").attr("title", $(".g-delete-link:first span").html());
|
||||||
|
|
||||||
|
// In-place editing for tag admin
|
||||||
|
$(".g-editable").gallery_in_place_edit({
|
||||||
|
form_url: <?= html::js_string(url::site("admin/pages/form_rename/__ID__")) ?>
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<? $pages_per_column = $pages->count()/5 ?>
|
||||||
|
<? $column_page_count = 0 ?>
|
||||||
|
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= t("Manage pages") ?> </h1>
|
||||||
|
<?= $form; ?>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<table id="g-page-admin">
|
||||||
|
<caption>
|
||||||
|
<?= t2("There is one page", "There are %count pages", $pages->count()) ?><br />
|
||||||
|
<a href="<?=url::site("admin/pages/createpage") ?>"><?=t("Add new page") ?></a>
|
||||||
|
</caption>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<? foreach ($pages as $i => $one_page): ?>
|
||||||
|
<? $current_letter = strtoupper(mb_substr($one_page->name, 0, 1)) ?>
|
||||||
|
|
||||||
|
<? if ($i == 0): /* first letter */ ?>
|
||||||
|
<strong><?= html::clean($current_letter) ?></strong>
|
||||||
|
<ul>
|
||||||
|
<? elseif ($last_letter != $current_letter): /* new letter */ ?>
|
||||||
|
</ul>
|
||||||
|
<? if ($column_page_count > $pages_per_column): /* new column */ ?>
|
||||||
|
<? $column_page_count = 0 ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? endif ?>
|
||||||
|
<strong><?= html::clean($current_letter) ?></strong>
|
||||||
|
<ul>
|
||||||
|
<? endif ?>
|
||||||
|
<li>
|
||||||
|
<span class="g-editable g-page-name" rel="<?= $one_page->id ?>"><?= html::clean($one_page->name) ?></span>
|
||||||
|
<a href="<?= url::site("admin/pages/editpage/$one_page->id") ?>" class="g-edit-link g-button" title="<?= t("Edit this page") ?>"><span class="ui-icon ui-icon-pencil"><?= t("Edit this page") ?></span></a>
|
||||||
|
<a href="<?= url::site("pages/show/" . $one_page->name) ?>" class="g-view-link g-button" title="<?= t("View this page") ?>" target="_blank"><span class="ui-icon ui-icon-info"><?= t("View this page") ?></span></a>
|
||||||
|
<a href="<?= url::site("admin/pages/form_delete/$one_page->id") ?>" class="g-dialog-link g-delete-link g-button"><span class="ui-icon ui-icon-trash"><?= t("Delete this page") ?></span></a>
|
||||||
|
</li>
|
||||||
|
<? $column_page_count++ ?>
|
||||||
|
<? $last_letter = $current_letter ?>
|
||||||
|
<? endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
20
3.0/modules/pages/views/admin_pages_new.html.php
Normal file
20
3.0/modules/pages/views/admin_pages_new.html.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<body>
|
||||||
|
<style type="text/css">
|
||||||
|
textarea {
|
||||||
|
height: 35em;
|
||||||
|
width: 97%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$("textarea").htmlarea(); // Initialize all TextArea's as jHtmlArea's with default values
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= $theme->page_title ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<?=$form ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
26
3.0/modules/pages/views/pages_display.html.php
Normal file
26
3.0/modules/pages/views/pages_display.html.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<? if (module::get_var("pages", "show_sidebar")) : ?>
|
||||||
|
<style type="text/css">
|
||||||
|
<? if (module::get_var("gallery", "active_site_theme") == "greydragon") : ?>
|
||||||
|
#g-column-right {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.g-page-block-content {
|
||||||
|
width: 99%;
|
||||||
|
}
|
||||||
|
<? else: ?>
|
||||||
|
#g-sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#g-content {
|
||||||
|
width: 950px;
|
||||||
|
}
|
||||||
|
<? endif ?>
|
||||||
|
</style>
|
||||||
|
<? endif ?>
|
||||||
|
<div class="g-page-block">
|
||||||
|
<h1> <?= $title ?> </h1>
|
||||||
|
<div class="g-page-block-content">
|
||||||
|
<?=$body ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
2
3.0/modules/pages/views/pages_sidebar.html.php
Normal file
2
3.0/modules/pages/views/pages_sidebar.html.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<?= $links ?>
|
@ -29,12 +29,26 @@ class tagsinalbum_block_Core {
|
|||||||
case "tagsinalbum":
|
case "tagsinalbum":
|
||||||
if (($theme->item) && ($theme->item->is_album())) {
|
if (($theme->item) && ($theme->item->is_album())) {
|
||||||
$item = $theme->item;
|
$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_tags", "items_tags.tag_id", "tags.id")
|
||||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||||
->where("items.parent_id", "=", $item->id)
|
->where("items.parent_id", "=", $item->id)
|
||||||
->order_by("tags.id", "ASC")
|
->order_by("tags.name", "ASC")
|
||||||
->find_all();
|
->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) {
|
if (count($all_tags) > 0) {
|
||||||
$block = new Block();
|
$block = new Block();
|
||||||
$block->css_id = "g-tags-in-album-block";
|
$block->css_id = "g-tags-in-album-block";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name = "Tags In Album"
|
name = "Tags In Album"
|
||||||
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
||||||
version = 2
|
version = 2
|
||||||
author_name = ""
|
author_name = "rWatcher"
|
||||||
author_url = ""
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
info_url = "http://codex.gallery2.org/Gallery3:Modules:tagsinalbum"
|
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"
|
||||||
|
@ -1,33 +1,11 @@
|
|||||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
<?
|
<?
|
||||||
// Create an array to store the tag names and urls in.
|
// Loop through each tag in $all_tags, and display it as a link.
|
||||||
$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.
|
|
||||||
$not_first = 0;
|
$not_first = 0;
|
||||||
foreach ($display_tags as $one_tag) {
|
foreach ($all_tags as $one_tag) {
|
||||||
if ($not_first++ > 0) {
|
if ($not_first++ > 0) {
|
||||||
print ", ";
|
print ", ";
|
||||||
}
|
}
|
||||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
print "<a href=\"" . $one_tag->url() . "\">" . html::clean($one_tag->name) . "</a>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
58
3.1/modules/item_links/helpers/item_links_event.php
Normal file
58
3.1/modules/item_links/helpers/item_links_event.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_event_Core {
|
||||||
|
static function item_edit_form($item, $form) {
|
||||||
|
// Create fields on the album edit screen to allow the user to link
|
||||||
|
// the item to another page.
|
||||||
|
|
||||||
|
$item_url = ORM::factory("item_link")
|
||||||
|
->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
3.1/modules/item_links/helpers/item_links_installer.php
Normal file
34
3.1/modules/item_links/helpers/item_links_installer.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_installer {
|
||||||
|
static function install() {
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->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);
|
||||||
|
}
|
||||||
|
}
|
34
3.1/modules/item_links/helpers/item_links_theme.php
Normal file
34
3.1/modules/item_links/helpers/item_links_theme.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class item_links_theme_Core {
|
||||||
|
static function head($theme) {
|
||||||
|
// If the current page is an item, and if it's in the item_links table,
|
||||||
|
// then redirect to the specified web page.
|
||||||
|
if ($theme->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;
|
||||||
|
}
|
||||||
|
}
|
21
3.1/modules/item_links/models/item_link.php
Normal file
21
3.1/modules/item_links/models/item_link.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Item_Link_Model extends ORM {
|
||||||
|
}
|
7
3.1/modules/item_links/module.info
Normal file
7
3.1/modules/item_links/module.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name = "Item Links"
|
||||||
|
description = "Allows users to use Gallery items as links to external URLs."
|
||||||
|
version = 1
|
||||||
|
author_name = "rWatcher"
|
||||||
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:item_links"
|
||||||
|
discuss_url = "http://gallery.menalto.com/node/102548"
|
271
3.1/modules/pages/controllers/admin_pages.php
Normal file
271
3.1/modules/pages/controllers/admin_pages.php
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Admin_Pages_Controller extends Admin_Controller {
|
||||||
|
public function index() {
|
||||||
|
// Display the admin page.
|
||||||
|
$view = new Admin_View("admin.html");
|
||||||
|
$view->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 <i>%old_name</i> to <i>%new_name</i>",
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
42
3.1/modules/pages/controllers/pages.php
Normal file
42
3.1/modules/pages/controllers/pages.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Pages_Controller extends Controller {
|
||||||
|
public function show($page_name) {
|
||||||
|
// Display the page specified by $page_name, or a 404 error if it doesn't exist.
|
||||||
|
|
||||||
|
// Run a database search to look up the page.
|
||||||
|
$existing_page = ORM::factory("static_page")
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
}
|
48
3.1/modules/pages/css/jHtmlArea.css
Normal file
48
3.1/modules/pages/css/jHtmlArea.css
Normal file
@ -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;}
|
57
3.1/modules/pages/helpers/pages_block.php
Normal file
57
3.1/modules/pages/helpers/pages_block.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_block_Core {
|
||||||
|
static function get_site_list() {
|
||||||
|
return array("pages_block" => 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 = "<ul id=\"g-pages-list\">";
|
||||||
|
foreach ($pages as $one_page) {
|
||||||
|
$content .= "<li style=\"clear: both;\"><a href=\"" . url::site("pages/show/" . $one_page->name) . "\">" . $one_page->title . "</a></li>";
|
||||||
|
}
|
||||||
|
$content .= "</ul>";
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
44
3.1/modules/pages/helpers/pages_event.php
Normal file
44
3.1/modules/pages/helpers/pages_event.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_event_Core {
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
// Add a settings link to the admin menu.
|
||||||
|
$menu->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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
3.1/modules/pages/helpers/pages_installer.php
Normal file
44
3.1/modules/pages/helpers/pages_installer.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_installer {
|
||||||
|
static function install() {
|
||||||
|
// Create a table to store pages in.
|
||||||
|
$db = Database::instance();
|
||||||
|
$db->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
3.1/modules/pages/helpers/pages_theme.php
Normal file
27
3.1/modules/pages/helpers/pages_theme.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class pages_theme_Core {
|
||||||
|
static function admin_head($theme) {
|
||||||
|
// Load jHtmlArea js and css.
|
||||||
|
return $theme->script("jHtmlArea-0.7.0.js") .
|
||||||
|
$theme->css("jHtmlArea.css");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
BIN
3.1/modules/pages/images/jHtmlArea.png
Normal file
BIN
3.1/modules/pages/images/jHtmlArea.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
3.1/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
Normal file
BIN
3.1/modules/pages/images/jHtmlArea_Toolbar_Group_BG.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 964 B |
Binary file not shown.
After Width: | Height: | Size: 942 B |
403
3.1/modules/pages/js/jHtmlArea-0.7.0.js
Normal file
403
3.1/modules/pages/js/jHtmlArea-0.7.0.js
Normal file
@ -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 = $("<div/>").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
|
||||||
|
|
||||||
|
var toolbar = this.toolbar = $("<div/>").addClass("ToolBar").appendTo(container);
|
||||||
|
priv.initToolBar.call(this, opts);
|
||||||
|
|
||||||
|
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
|
||||||
|
iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
|
||||||
|
var htmlarea = this.htmlarea = $("<div/>").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 $("<p/>").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) ? $("<span/>").append(html) : html)[0]);
|
||||||
|
} else { // Safari
|
||||||
|
r.deleteContents();
|
||||||
|
r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : 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("<p>");
|
||||||
|
},
|
||||||
|
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 $("<li/>").append($("<a href='javascript:void(0);'/>").addClass(className).attr("title", altText).click(function() { action.call(that, $(this)); }));
|
||||||
|
};
|
||||||
|
|
||||||
|
function addButtons(arr) {
|
||||||
|
var ul = $("<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($('<li class="separator"/>'));
|
||||||
|
} 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);
|
21
3.1/modules/pages/models/static_page.php
Normal file
21
3.1/modules/pages/models/static_page.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2011 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Static_Page_Model extends ORM {
|
||||||
|
}
|
7
3.1/modules/pages/module.info
Normal file
7
3.1/modules/pages/module.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
name = "Pages"
|
||||||
|
description = "Allows Gallery admins to create static pages."
|
||||||
|
version = 2
|
||||||
|
author_name = "rWatcher"
|
||||||
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
|
info_url = "http://codex.gallery2.org/Gallery3:Modules:Pages"
|
||||||
|
discuss_url = "http://gallery.menalto.com/node/102534"
|
59
3.1/modules/pages/views/admin_pages.html.php
Normal file
59
3.1/modules/pages/views/admin_pages.html.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("document").ready(function() {
|
||||||
|
// using JS for adding link titles to avoid running t() for each tag
|
||||||
|
$("#g-page-admin .g-page-name").attr("title", <?= t("Click to edit this page")->for_js() ?>);
|
||||||
|
$("#g-page-admin .g-delete-link").attr("title", $(".g-delete-link:first span").html());
|
||||||
|
|
||||||
|
// In-place editing for tag admin
|
||||||
|
$(".g-editable").gallery_in_place_edit({
|
||||||
|
form_url: <?= html::js_string(url::site("admin/pages/form_rename/__ID__")) ?>
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<? $pages_per_column = $pages->count()/5 ?>
|
||||||
|
<? $column_page_count = 0 ?>
|
||||||
|
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= t("Manage pages") ?> </h1>
|
||||||
|
<?= $form; ?>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<table id="g-page-admin">
|
||||||
|
<caption>
|
||||||
|
<?= t2("There is one page", "There are %count pages", $pages->count()) ?><br />
|
||||||
|
<a href="<?=url::site("admin/pages/createpage") ?>"><?=t("Add new page") ?></a>
|
||||||
|
</caption>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<? foreach ($pages as $i => $one_page): ?>
|
||||||
|
<? $current_letter = strtoupper(mb_substr($one_page->name, 0, 1)) ?>
|
||||||
|
|
||||||
|
<? if ($i == 0): /* first letter */ ?>
|
||||||
|
<strong><?= html::clean($current_letter) ?></strong>
|
||||||
|
<ul>
|
||||||
|
<? elseif ($last_letter != $current_letter): /* new letter */ ?>
|
||||||
|
</ul>
|
||||||
|
<? if ($column_page_count > $pages_per_column): /* new column */ ?>
|
||||||
|
<? $column_page_count = 0 ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? endif ?>
|
||||||
|
<strong><?= html::clean($current_letter) ?></strong>
|
||||||
|
<ul>
|
||||||
|
<? endif ?>
|
||||||
|
<li>
|
||||||
|
<span class="g-editable g-page-name" rel="<?= $one_page->id ?>"><?= html::clean($one_page->name) ?></span>
|
||||||
|
<a href="<?= url::site("admin/pages/editpage/$one_page->id") ?>" class="g-edit-link g-button" title="<?= t("Edit this page") ?>"><span class="ui-icon ui-icon-pencil"><?= t("Edit this page") ?></span></a>
|
||||||
|
<a href="<?= url::site("pages/show/" . $one_page->name) ?>" class="g-view-link g-button" title="<?= t("View this page") ?>" target="_blank"><span class="ui-icon ui-icon-info"><?= t("View this page") ?></span></a>
|
||||||
|
<a href="<?= url::site("admin/pages/form_delete/$one_page->id") ?>" class="g-dialog-link g-delete-link g-button"><span class="ui-icon ui-icon-trash"><?= t("Delete this page") ?></span></a>
|
||||||
|
</li>
|
||||||
|
<? $column_page_count++ ?>
|
||||||
|
<? $last_letter = $current_letter ?>
|
||||||
|
<? endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
20
3.1/modules/pages/views/admin_pages_new.html.php
Normal file
20
3.1/modules/pages/views/admin_pages_new.html.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<body>
|
||||||
|
<style type="text/css">
|
||||||
|
textarea {
|
||||||
|
height: 35em;
|
||||||
|
width: 97%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$("textarea").htmlarea(); // Initialize all TextArea's as jHtmlArea's with default values
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div class="g-block">
|
||||||
|
<h1> <?= $theme->page_title ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<?=$form ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
26
3.1/modules/pages/views/pages_display.html.php
Normal file
26
3.1/modules/pages/views/pages_display.html.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<? if (module::get_var("pages", "show_sidebar")) : ?>
|
||||||
|
<style type="text/css">
|
||||||
|
<? if (module::get_var("gallery", "active_site_theme") == "greydragon") : ?>
|
||||||
|
#g-column-right {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.g-page-block-content {
|
||||||
|
width: 99%;
|
||||||
|
}
|
||||||
|
<? else: ?>
|
||||||
|
#g-sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#g-content {
|
||||||
|
width: 950px;
|
||||||
|
}
|
||||||
|
<? endif ?>
|
||||||
|
</style>
|
||||||
|
<? endif ?>
|
||||||
|
<div class="g-page-block">
|
||||||
|
<h1> <?= $title ?> </h1>
|
||||||
|
<div class="g-page-block-content">
|
||||||
|
<?=$body ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
2
3.1/modules/pages/views/pages_sidebar.html.php
Normal file
2
3.1/modules/pages/views/pages_sidebar.html.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<?= $links ?>
|
@ -29,12 +29,26 @@ class tagsinalbum_block_Core {
|
|||||||
case "tagsinalbum":
|
case "tagsinalbum":
|
||||||
if (($theme->item) && ($theme->item->is_album())) {
|
if (($theme->item) && ($theme->item->is_album())) {
|
||||||
$item = $theme->item;
|
$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_tags", "items_tags.tag_id", "tags.id")
|
||||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||||
->where("items.parent_id", "=", $item->id)
|
->where("items.parent_id", "=", $item->id)
|
||||||
->order_by("tags.id", "ASC")
|
->order_by("tags.name", "ASC")
|
||||||
->find_all();
|
->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) {
|
if (count($all_tags) > 0) {
|
||||||
$block = new Block();
|
$block = new Block();
|
||||||
$block->css_id = "g-tags-in-album-block";
|
$block->css_id = "g-tags-in-album-block";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name = "Tags In Album"
|
name = "Tags In Album"
|
||||||
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
||||||
version = 2
|
version = 2
|
||||||
author_name = ""
|
author_name = "rWatcher"
|
||||||
author_url = ""
|
author_url = "http://codex.gallery2.org/User:RWatcher"
|
||||||
info_url = "http://codex.gallery2.org/Gallery3:Modules:tagsinalbum"
|
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"
|
||||||
|
@ -1,33 +1,11 @@
|
|||||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
<?
|
<?
|
||||||
// Create an array to store the tag names and urls in.
|
// Loop through each tag in $all_tags, and display it as a link.
|
||||||
$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.
|
|
||||||
$not_first = 0;
|
$not_first = 0;
|
||||||
foreach ($display_tags as $one_tag) {
|
foreach ($all_tags as $one_tag) {
|
||||||
if ($not_first++ > 0) {
|
if ($not_first++ > 0) {
|
||||||
print ", ";
|
print ", ";
|
||||||
}
|
}
|
||||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
print "<a href=\"" . $one_tag->url() . "\">" . html::clean($one_tag->name) . "</a>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user