diff --git a/last_commit.txt b/last_commit.txt new file mode 100755 index 00000000..ee47b710 --- /dev/null +++ b/last_commit.txt @@ -0,0 +1 @@ +Removed preload \ No newline at end of file diff --git a/modules/basket/controllers/admin_postage_bands.php b/modules/basket/controllers/admin_postage_bands.php new file mode 100644 index 00000000..f843d0ca --- /dev/null +++ b/modules/basket/controllers/admin_postage_bands.php @@ -0,0 +1,154 @@ +content = new View("admin_postage_bands.html"); + $view->content->postage_bands = ORM::factory("postage_band")->orderby("name")->find_all(); + + print $view; + } + + public function add_postage_band_form() { + print postage_band::get_add_form_admin(); + } + + + public function add_postage_band() { + access::verify_csrf(); + + $form = postage_band::get_add_form_admin(); + $valid = $form->validate(); + $name = $form->add_postage->inputs["name"]->value; + $postage = ORM::factory("postage_band")->where("name", $name)->find(); + if ($postage->loaded) { + $form->add_postage->inputs["name"]->add_error("in_use", 1); + $valid = false; + } + + if ($valid) { + $postage = postage_band::create( + $name, + $form->add_postage->flat_rate->value, + $form->add_postage->per_item->value + ); + + $postage->save(); + message::success(t("Created postage band %postage_name", array( + "postage_name" => html::clean($postage->name)))); + print json_encode(array("result" => "success")); + } else { + print json_encode(array("result" => "error", + "form" => $form->__toString())); + } + } + + public function delete_postage_band_form($id) { + $postage = ORM::factory("postage_band", $id); + if (!$postage->loaded) { + kohana::show_404(); + } + print postage_band::get_delete_form_admin($postage); + } + + public function delete_postage_band($id) { + access::verify_csrf(); + + if ($id == user::active()->id || $id == user::guest()->id) { + access::forbidden(); + } + + $postage = ORM::factory("postage_band", $id); + if (!$postage->loaded) { + kohana::show_404(); + } + + $form = postage_band::get_delete_form_admin($postage); + if($form->validate()) { + $name = $postage->name; + $postage->delete(); + } else { + print json_encode(array("result" => "error", + "form" => $form->__toString())); + } + + $message = t("Deleted user %postage_band", array("postage_band" => html::clean($name))); + log::success("user", $message); + message::success($message); + print json_encode(array("result" => "success")); + } + + public function edit_postage_band($id) { + access::verify_csrf(); + + $postage = ORM::factory("postage_band", $id); + if (!$postage->loaded) { + kohana::show_404(); + } + + $form = postage_band::get_edit_form_admin($postage); + $valid = $form->validate(); + if ($valid) { + $new_name = $form->edit_postage->inputs["name"]->value; + if ($new_name != $postage->name && + ORM::factory("postage_band") + ->where("name", $new_name) + ->where("id !=", $postage->id) + ->find() + ->loaded) { + $form->edit_postage->inputs["name"]->add_error("in_use", 1); + $valid = false; + } else { + $postage->name = $new_name; + } + } + + if ($valid) { + $postage->flat_rate = $form->edit_postage->flat_rate->value; + $postage->per_item = $form->edit_postage->per_item->value; + $postage->save(); + + message::success(t("Changed postage band %postage_name", + array("postage_name" => html::clean($postage->name)))); + print json_encode(array("result" => "success")); + } else { + print json_encode(array("result" => "error", + "form" => $form->__toString())); + } + } + + public function edit_postage_band_form($id) { + $postage = ORM::factory("postage_band", $id); + if (!$postage->loaded) { + kohana::show_404(); + } + + $form = postage_band::get_edit_form_admin($postage); + + print $form; + } + +} \ No newline at end of file diff --git a/modules/basket/controllers/admin_product_lines.php b/modules/basket/controllers/admin_product_lines.php index 1794bc28..f063ad36 100644 --- a/modules/basket/controllers/admin_product_lines.php +++ b/modules/basket/controllers/admin_product_lines.php @@ -51,7 +51,11 @@ class Admin_Product_Lines_Controller extends Controller if ($valid) { $product = product::create( - $name, $form->add_product->cost->value, $form->add_product->description->value); + $name, + $form->add_product->cost->value, + $form->add_product->description->value, + $form->add_product->postage_band->value + ); $product->save(); message::success(t("Created product %product_name", array( @@ -83,7 +87,7 @@ class Admin_Product_Lines_Controller extends Controller kohana::show_404(); } - $form = user::get_delete_form_admin($product); + $form = product::get_delete_form_admin($product); if($form->validate()) { $name = $product->name; $product->delete(); @@ -126,6 +130,7 @@ class Admin_Product_Lines_Controller extends Controller if ($valid) { $product->cost = $form->edit_product->cost->value; $product->description = $form->edit_product->description->value; + $product->postage_band_id = $form->edit_product->postage_band->value; $product->save(); message::success(t("Changed product %product_name", diff --git a/modules/basket/controllers/basket.php b/modules/basket/controllers/basket.php index 2ae4e62e..9bdbe20b 100644 --- a/modules/basket/controllers/basket.php +++ b/modules/basket/controllers/basket.php @@ -31,7 +31,7 @@ class Basket_Controller extends Controller { print $template; } - private function getCheckoutForm(){ + private function getCheckoutForm(){ $form = new Forge("basket/confirm", "", "post", array("id" => "checkout", "name" =>"checkout")); $group = $form->group("contact")->label(t("Contact Details")); $group->input("fullname")->label(t("Name"))->id("fullname"); @@ -110,6 +110,8 @@ class Basket_Controller extends Controller { $basket = Session_Basket::get(); //$admin_address = basket::getEmailAddress(); + $postage = $basket->postage_cost(); + $product_cost = $basket->cost(); $admin_email = "Order for : ".$basket->name." @@ -121,7 +123,9 @@ class Basket_Controller extends Controller { ".$basket->email." ".$basket->phone." Placed at ".date("d F Y - H:i" ,time())." -Total Owed ".$basket->cost()." in ".basket::getCurrency()." +Cost of Ordered Products = ".$product_cost." +Postage and Packaging Costs + ".$postage." +Total Owed ".($product_cost+$postage)." Total in ".basket::getCurrency()." Items Ordered: diff --git a/modules/basket/helpers/basket.php b/modules/basket/helpers/basket.php index d4993786..7bcc0060 100644 --- a/modules/basket/helpers/basket.php +++ b/modules/basket/helpers/basket.php @@ -42,9 +42,9 @@ class basket_Core { static $format= array( "AUD" => "$", "CAD" => "$", - "EUR" => "�", - "GBP" => "�", - "JPY" => "�", + "EUR" => "€", + "GBP" => "£", + "JPY" => "¥", "USD" => "$", "NZD" => "$", "CHF" => "", @@ -114,7 +114,7 @@ class basket_Core { } static function formatMoney($money){ - return self::$format[self::getCurrency()].number_format($money); + return self::$format[self::getCurrency()].number_format($money,2); } static function setEmailAddress($email){ @@ -141,6 +141,12 @@ class basket_Core { "; + $postage = $session_basket->postage_cost(); + if ($postage > 0) { + $form = $form." +"; + } + $id = 1; foreach ($session_basket->contents as $key => $basket_item){ $form = $form." @@ -149,6 +155,7 @@ class basket_Core { quantity\"/>"; $id++; } + $form = $form.""; return $form; diff --git a/modules/basket/helpers/basket_event.php b/modules/basket/helpers/basket_event.php index 25b55f28..ade43e96 100644 --- a/modules/basket/helpers/basket_event.php +++ b/modules/basket/helpers/basket_event.php @@ -38,6 +38,11 @@ class basket_event_Core{ ->id("product_line") ->label(t("Product Lines")) ->url(url::site("admin/product_lines"))); + $basket_menu->append( + Menu::factory("link") + ->id("postage_bands") + ->label(t("Postage Bands")) + ->url(url::site("admin/postage_bands"))); } diff --git a/modules/basket/helpers/basket_installer.php b/modules/basket/helpers/basket_installer.php index 23c4e8f9..48c58d4b 100644 --- a/modules/basket/helpers/basket_installer.php +++ b/modules/basket/helpers/basket_installer.php @@ -17,14 +17,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class basket_installer { - static function install() { + +class basket_installer +{ + static function install(){ + $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {products} ( `id` int(9) NOT NULL auto_increment, `name` TEXT NOT NULL, - `cost` INTEGER(9) default 0, + `cost` DECIMAL(10,2) default 0, `description` varchar(1024), + `postage_band_id` int(9) default 1, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;"); @@ -40,21 +44,57 @@ class basket_installer { `product_override_id` int(9) NOT NULL, `product_id` int(9) NOT NULL, `include` BOOLEAN default false, - `cost` INTEGER(9) default -1, + `cost` DECIMAL(10,2) default -1, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + $db->query("CREATE TABLE IF NOT EXISTS {postage_bands} ( + `id` int(9) NOT NULL auto_increment, + `name` TEXT NOT NULL, + `flat_rate` DECIMAL(10,2) default 0, + `per_item` DECIMAL(10,2) default 0, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;"); - product::create("4x6",5,"4\"x6\" print"); - product::create("8x10",25,"8\"x10\" print"); - product::create("8x12",30,"8\"x12\" print"); + postage_band::create("No Postage",0,0); + + product::create("4x6",5,"4\"x6\" print",1); + product::create("8x10",25,"8\"x10\" print",1); + product::create("8x12",30,"8\"x12\" print",1); + + + module::set_version("basket", 2); - module::set_version("basket", 1); } - static function uninstall() { + static function upgrade($version) { + $db = Database::instance(); + if ($version == 1) { + + // fix for allowing decimel place in money + $db->query("ALTER TABLE {products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default 0;"); + $db->query("ALTER TABLE {item_products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default -1;"); + + // postage bands + $db->query("ALTER TABLE {products} ADD COLUMN `postage_band_id` int(9) default 1"); + $db->query("CREATE TABLE IF NOT EXISTS {postage_bands} ( + `id` int(9) NOT NULL auto_increment, + `name` TEXT NOT NULL, + `flat_rate` DECIMAL(10,2) default 0, + `per_item` DECIMAL(10,2) default 0, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + postage_band::create("No Postage",0,0); + + module::set_version("basket", $version = 2); + } + } + + static function uninstall(){ $db = Database::instance(); $db->query("DROP TABLE IF EXISTS {products}"); $db->query("DROP TABLE IF EXISTS {product_overrides}"); $db->query("DROP TABLE IF EXISTS {item_products}"); + $db->query("DROP TABLE IF EXISTS {postage_bands}"); } } diff --git a/modules/basket/helpers/postage_band.php b/modules/basket/helpers/postage_band.php new file mode 100644 index 00000000..b69f84c4 --- /dev/null +++ b/modules/basket/helpers/postage_band.php @@ -0,0 +1,99 @@ + "gAddPostageForm")); + $group = $form->group("add_postage")->label(t("Add Postage Band")); + $group->input("name")->label(t("Name"))->id("gPostageName") + ->error_messages("in_use", t("There is already a postage band with that name")); + $group->input("flat_rate")->label(t("Flat Rate"))->id("gFlatRate"); + $group->input("per_item")->label(t("Per Item"))->id("gPetItem"); + $group->submit("")->value(t("Add Postage Band")); + $postage = ORM::factory("postage_band"); + $form->add_rules_from($postage); + return $form; + } + + static function get_edit_form_admin($postage) { + $form = new Forge("admin/postage_bands/edit_postage_band/$postage->id", "", "post", + array("id" => "gEditPostageForm")); + $group = $form->group("edit_postage")->label(t("Edit Postage Band")); + $group->input("name")->label(t("Name"))->id("gPostageName")->value($postage->name); + $group->inputs["name"]->error_messages( + "in_use", t("There is already a postage band with that name")); + $group->input("flat_rate")->label(t("Flat Rate"))->id("gFlatRate")->value($postage->flat_rate); + $group->input("per_item")->label(t("Per Item"))->id("gPetItem")-> + value($postage->per_item); + + $group->submit("")->value(t("Modify Postage Band")); + $form->add_rules_from($postage); + return $form; + } + + + static function get_delete_form_admin($postage) { + $form = new Forge("admin/postage_bands/delete_postage_band/$postage->id", "", "post", + array("id" => "gDeletePostageForm")); + $group = $form->group("delete_postage")->label( + t("Are you sure you want to delete postage band %name?", array("name" => $postage->name))); + $group->submit("")->value(t("Delete postage band %name", array("name" => $postage->name))); + return $form; + } + + /** + * Create a new postage band + * + * @param string $name + * @param string $full_name + * @param string $password + * @return User_Model + */ + static function create($name, $flatrate, $peritemcost) { + $postage = ORM::factory("postage_band")->where("name", $name)->find(); + if ($postage->loaded) { + throw new Exception("@todo postage already EXISTS $name"); + } + + $postage->name = $name; + $postage->flat_rate = $flatrate; + $postage->per_item = $peritemcost; + + $postage->save(); + return $postage; + } + + /** + * returns the array of postage bands + * @return an array of postage bands + */ + static function getPostageArray(){ + $postagea = array(); + + $postages = ORM::factory("postage_band")->find_all(); + foreach ($postages as $postage){ + $show = true; + $postagea[$postage->id] = $postage->name; + } + + return $postagea; + } + +} \ No newline at end of file diff --git a/modules/basket/helpers/product.php b/modules/basket/helpers/product.php index 34e9e745..8811d28e 100644 --- a/modules/basket/helpers/product.php +++ b/modules/basket/helpers/product.php @@ -24,8 +24,11 @@ class product_Core { $group = $form->group("add_product")->label(t("Add Product")); $group->input("name")->label(t("Name"))->id("g-product-name") ->error_messages("in_use", t("There is already a product with that name")); - $group->input("cost")->label(t("Cost"))->id("g-cost"); + $group->input("cost")->label(t("Cost"))->id("gCost"); $group->input("description")->label(t("Description"))->id("g-description"); + $group->dropdown("postage_band") + ->label(t("Postage Band")) + ->options(postage_band::getPostageArray()); $group->submit("")->value(t("Add Product")); $product = ORM::factory("product"); $form->add_rules_from($product); @@ -42,6 +45,10 @@ class product_Core { $group->input("cost")->label(t("Cost"))->id("g-cost")->value($product->cost); $group->input("description")->label(t("Description"))->id("g-description")-> value($product->description); + $group->dropdown("postage_band") + ->label(t("Postage Band")) + ->options(postage_band::getPostageArray()) + ->selected($product->postage_band_id); $group->submit("")->value(t("Modify Product")); $form->add_rules_from($product); @@ -66,7 +73,7 @@ class product_Core { * @param string $password * @return User_Model */ - static function create($name, $cost, $description) { + static function create($name, $cost, $description, $postage_band) { $product = ORM::factory("product")->where("name", $name)->find(); if ($product->loaded) { throw new Exception("@todo USER_ALREADY_EXISTS $name"); @@ -75,7 +82,7 @@ class product_Core { $product->name = $name; $product->cost = $cost; $product->description = $description; - + $product->postage_band_id = $postage_band; $product->save(); return $product; } diff --git a/modules/basket/libraries/Session_Basket.php b/modules/basket/libraries/Session_Basket.php index 3aa31f12..11de4db0 100644 --- a/modules/basket/libraries/Session_Basket.php +++ b/modules/basket/libraries/Session_Basket.php @@ -64,6 +64,11 @@ class basket_item return $prod->description; } + public function getProduct(){ + $prod = ORM::factory("product", $this->product); + return $prod; + } + public function getCode(){ $photo = ORM::factory("item", $this->item); $prod = ORM::factory("product", $this->product); @@ -122,6 +127,32 @@ class Session_Basket_Core { unset($this->contents[$key]); } + public function postage_cost(){ + $postage_cost = 0; + $postage_bands = array(); + $postage_quantities = array(); + if (isset($this->contents)){ + // create array of postage bands + foreach ($this->contents as $product => $basket_item){ + $postage_band = $basket_item->getProduct()->postage_band; + if (isset($postage_bands[$postage_band->id])) + { + $postage_quantities[$postage_band->id] += $basket_item->quantity; + } + else + { + $postage_quantities[$postage_band->id] = $basket_item->quantity; + $postage_bands[$postage_band->id] = $postage_band; + } + } + + foreach ($postage_bands as $id => $postage_band){ + $postage_cost += $postage_band->flat_rate + ($postage_band->per_item * $postage_quantities[$id]); + } + } + return $postage_cost; + } + public function cost(){ $cost = 0; if (isset($this->contents)){ diff --git a/modules/basket/models/postage_band.php b/modules/basket/models/postage_band.php new file mode 100644 index 00000000..83eb6e08 --- /dev/null +++ b/modules/basket/models/postage_band.php @@ -0,0 +1,26 @@ + "length[1,32]"); + + protected $has_many=array('products'); + +} diff --git a/modules/basket/models/product.php b/modules/basket/models/product.php index c89c7254..2bd6a59b 100644 --- a/modules/basket/models/product.php +++ b/modules/basket/models/product.php @@ -21,4 +21,6 @@ class Product_Model extends ORM { var $rules = array( "name" => "length[1,32]", "description" => "length[0,255]"); + protected $belongs_to=array('postage_band'); + } diff --git a/modules/basket/module.info b/modules/basket/module.info index 426ff687..5bf1f888 100644 --- a/modules/basket/module.info +++ b/modules/basket/module.info @@ -1,3 +1,3 @@ name = "Shopping Basket" description = "Provides a simple shopping basket and checkout with paypal integration" -version = 1 +version = 2 diff --git a/modules/basket/views/admin_postage_bands.html.php b/modules/basket/views/admin_postage_bands.html.php new file mode 100644 index 00000000..436c2a83 --- /dev/null +++ b/modules/basket/views/admin_postage_bands.html.php @@ -0,0 +1,70 @@ + +
+ + " + class="gDialogLink gButtonLink right ui-icon-left ui-state-default ui-corner-all" + title=""> + + + + +

+ +

+ +
+ + + + + + + + + $postage_band): ?> + "> + + + + + + + +
+ name) ?> + + flat_rate) ?> + + per_item) ?> + + id") ?>" + open_text="" + class="gPanelLink gButtonLink ui-state-default ui-corner-all ui-icon-left"> + + + id") ?>" + class="gDialogLink gButtonLink ui-state-default ui-corner-all ui-icon-left"> + +
+
+ +
\ No newline at end of file diff --git a/modules/basket/views/admin_product_lines.html.php b/modules/basket/views/admin_product_lines.html.php index b0ee1322..896f6edb 100644 --- a/modules/basket/views/admin_product_lines.html.php +++ b/modules/basket/views/admin_product_lines.html.php @@ -37,6 +37,7 @@ + @@ -51,6 +52,11 @@ description) ?> + + postage_band->name) ?> + + + id") ?>" open_text="" diff --git a/modules/basket/views/confirm_order.html.php b/modules/basket/views/confirm_order.html.php index da04a5f6..d6bbac00 100644 --- a/modules/basket/views/confirm_order.html.php +++ b/modules/basket/views/confirm_order.html.php @@ -51,8 +51,14 @@ function so(){document.confirm.submit();} + postage_cost();?> + 0):?> "> - Total Costcost())?> + Postage and Packaging + + + "> + Total Costcost() + $postage))?> diff --git a/modules/basket/views/view_basket.html.php b/modules/basket/views/view_basket.html.php index bb506e06..298172be 100644 --- a/modules/basket/views/view_basket.html.php +++ b/modules/basket/views/view_basket.html.php @@ -88,8 +88,14 @@ + postage_cost();?> + 0):?> "> - Total Cost + Postage and Packaging + + + "> + Total Cost diff --git a/modules/batchtag/controllers/batchtag.php b/modules/batchtag/controllers/batchtag.php index fc17f594..e4bbbf73 100644 --- a/modules/batchtag/controllers/batchtag.php +++ b/modules/batchtag/controllers/batchtag.php @@ -24,11 +24,23 @@ class BatchTag_Controller extends Controller { // Prevent Cross Site Request Forgery access::verify_csrf(); - // Generate an array of all non-album items in the current album. - $children = ORM::factory("item") - ->where("parent_id", $this->input->post("item_id")) - ->where("type !=", "album") - ->find_all(); + // Figure out if the contents of sub-albums should also be tagged + $str_tag_subitems = Input::instance()->post("tag_subitems"); + + $children = ""; + if ($str_tag_subitems == false) { + // Generate an array of all non-album items in the current album. + $children = ORM::factory("item") + ->where("parent_id", $this->input->post("item_id")) + ->where("type !=", "album") + ->find_all(); + } else { + // Generate an array of all non-album items in the current album + // and any sub albums. + $children = ORM::factory("item", $this->input->post("item_id")) + ->where("type !=", "album") + ->descendants(); + } // Loop through each item in the album and make sure the user has // access to view and edit it. diff --git a/modules/batchtag/helpers/batchtag_theme.php b/modules/batchtag/helpers/batchtag_block.php similarity index 71% rename from modules/batchtag/helpers/batchtag_theme.php rename to modules/batchtag/helpers/batchtag_block.php index 190604f2..8bc3afc6 100644 --- a/modules/batchtag/helpers/batchtag_theme.php +++ b/modules/batchtag/helpers/batchtag_block.php @@ -17,20 +17,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class batchtag_theme_Core { - static function sidebar_blocks($theme) { - // Display form for tagging in the album sidebar. - - // Make sure the current page belongs to an item. - if (!$theme->item()) { - return; - } - - $item = $theme->item(); - - // Only display the form in albums that the user has edit permission in. - if ($item->is_album() && access::can("edit", $item)) { +class batchtag_block_Core { + static function get_site_list() { + return array("batch_tag" => t("Batch Tag")); + } + static function get($block_id, $theme) { + $block = ""; + + // Only display on album pages that the user can edit. + $item = $theme->item(); + if (!$item->is_album() || !access::can("edit", $item)) { + return; + } + + switch ($block_id) { + case "batch_tag": // Make a new sidebar block. $block = new Block(); $block->css_id = "g-batch-tag"; @@ -43,12 +45,17 @@ class batchtag_theme_Core { $label = t("Tag everything in this album:"); $group = $form->group("add_tag")->label("Add Tag"); $group->input("name")->label($label)->rules("required|length[1,64]"); + $group->checkbox("tag_subitems") + ->label(t("Include sub-albums?")) + ->value(true) + ->checked(false); + $group->hidden("item_id")->value($item->id); $group->submit("")->value(t("Add Tag")); - $block->content->form = $form; + $block->content->batch_tag_form = $form; - // Display the block. - return $block; - } + break; + } + return $block; } -} \ No newline at end of file +} diff --git a/modules/batchtag/module.info b/modules/batchtag/module.info index 398147ac..eb00345a 100644 --- a/modules/batchtag/module.info +++ b/modules/batchtag/module.info @@ -1,3 +1,3 @@ -name = BatchTag -description = Automatically apply a tag to the entire contents of an album. +name = "BatchTag" +description = "Automatically apply a tag to the entire contents of an album." version = 1 diff --git a/modules/batchtag/views/batchtag_block.html.php b/modules/batchtag/views/batchtag_block.html.php index 4993189e..9f820b35 100644 --- a/modules/batchtag/views/batchtag_block.html.php +++ b/modules/batchtag/views/batchtag_block.html.php @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/modules/contactowner/helpers/contactowner_block.php b/modules/contactowner/helpers/contactowner_block.php new file mode 100644 index 00000000..bf01d338 --- /dev/null +++ b/modules/contactowner/helpers/contactowner_block.php @@ -0,0 +1,78 @@ + t("Contact Owner")); + } + + static function get($block_id, $theme) { + $block = ""; + + switch ($block_id) { + case "contact_owner": + + // Create a new block to display the links in. + $block = new Block(); + $block->css_id = "g-contact-owner"; + $block->title = t("Contact"); + $block->content = new View("contactowner_block.html"); + + // if $displayBlock is true, this block will be displayed, + // if there aren't any links to put in the block for whatever reason + // then $displayBlock will rename set to false and the + // block will not be displayed. + $displayBlock = false; + + if ($theme->item()) { + // Locate the record for the user that created the current item. + // Their name will be displayed as part of the contact link. + $userDetails = ORM::factory("user") + ->where("id", $theme->item->owner_id) + ->find_all(); + + // Figure out if the contact item owner email link should be displayed. + // only display it if the current owner has an email address and + // the option for allowing item owners to be contacted is set to true. + if ((count($userDetails) > 0) && ($userDetails[0]->email != "") && + (module::get_var("contactowner", "contact_user_link") == true)) { + $block->content->userLink = "item->owner_id) . "\">" . t("Contact") . " " . + $userDetails[0]->name . ""; + $displayBlock = true; + } + } + + // Figure out if the contact site owner link should be displayed. + if (module::get_var("contactowner", "contact_owner_link")) { + $block->content->ownerLink = "" . t(module::get_var("contactowner", "contact_button_text")) . ""; + $displayBlock = true; + } + + break; + } + + if ($displayBlock) { + return $block; + } else { + return ""; + } + } +} diff --git a/modules/contactowner/helpers/contactowner_theme.php b/modules/contactowner/helpers/contactowner_theme.php deleted file mode 100644 index bc243c0a..00000000 --- a/modules/contactowner/helpers/contactowner_theme.php +++ /dev/null @@ -1,70 +0,0 @@ -item()) { - return; - } - - // Locate the record for the user that created the current item. - // Their name will be displayed as part of the contact link. - $userDetails = ORM::factory("user") - ->where("id", $theme->item->owner_id) - ->find_all(); - - // Create a new block to display the links in. - $block = new Block(); - $block->css_id = "g-contact-owner"; - $block->title = t("Contact:"); - $block->content = new View("contactowner_block.html"); - - // if $displayBlock is true, this block will be displayed, - // if there aren't any links to put in the block for whatever reason - // then $displayBlock will rename set to false and the - // block will not be displayed. - $displayBlock = false; - - // Figure out if the contact item owner email link should be displayed. - // only display it if the current owner has an email address and - // the option for allowing item owners to be contacted is set to true. - if ((count($userDetails) > 0) && ($userDetails[0]->email != "") && - (module::get_var("contactowner", "contact_user_link") == true)) { - $block->content->userLink = "item->owner_id) . "\">" . t("Contact") . " " . $userDetails[0]->name . ""; - $displayBlock = true; - } - - // Figure out if the contact site owner link should be displayed. - if (module::get_var("contactowner", "contact_owner_link")) { - $block->content->ownerLink = "" . t(module::get_var("contactowner", "contact_button_text")) . ""; - $displayBlock = true; - } - - if ($displayBlock) { - return $block; - } - } -} diff --git a/modules/contactowner/module.info b/modules/contactowner/module.info index 673023c3..1dce49be 100644 --- a/modules/contactowner/module.info +++ b/modules/contactowner/module.info @@ -1,3 +1,3 @@ -name = ContactOwner -description = Allows visitors to send the website owner an email. +name = "ContactOwner" +description = "Allows visitors to send the website owner an email." version = 1 diff --git a/modules/displaytags/helpers/displaytags_block.php b/modules/displaytags/helpers/displaytags_block.php new file mode 100644 index 00000000..454ff0b6 --- /dev/null +++ b/modules/displaytags/helpers/displaytags_block.php @@ -0,0 +1,54 @@ + t("Display Tags")); + } + + static function get($block_id, $theme) { + $block = ""; + + // Make sure the current page belongs to an item. + if (!$theme->item()) { + return; + } + + switch ($block_id) { + case "display_tags": + // Create an array of all the tags for the current item. + $tagsItem = ORM::factory("tag") + ->join("items_tags", "tags.id", "items_tags.tag_id") + ->where("items_tags.item_id", $theme->item->id) + ->find_all(); + + // If the current item has at least one tag, display it/them. + if (count($tagsItem) > 0) { + $block = new Block(); + $block->css_id = "g-display-tags"; + $block->title = t("Tags"); + $block->content = new View("displaytags_block.html"); + $block->content->tags = $tagsItem; + } + + break; + } + return $block; + } +} diff --git a/modules/displaytags/module.info b/modules/displaytags/module.info index b905a8e4..d8458f10 100644 --- a/modules/displaytags/module.info +++ b/modules/displaytags/module.info @@ -1,3 +1,3 @@ -name = DisplayTags -description = Display all tags for the current photo/album. +name = "DisplayTags" +description = "Display all tags for the current photo/album." version = 1 diff --git a/modules/downloadfullsize/helpers/downloadfullsize_theme.php b/modules/downloadfullsize/helpers/downloadfullsize_theme.php index a8ab828e..6ec329dc 100644 --- a/modules/downloadfullsize/helpers/downloadfullsize_theme.php +++ b/modules/downloadfullsize/helpers/downloadfullsize_theme.php @@ -19,11 +19,9 @@ */ class downloadfullsize_theme { static function head($theme) { - if (!$theme->item()) { - return; + if ($theme->item && access::can("view_full", $theme->item)) { + $theme->css("downloadfullsize_menu.css"); } - - return new View("downloadfullsize_header_block.html"); } static function sidebar_blocks($theme) { diff --git a/modules/downloadfullsize/module.info b/modules/downloadfullsize/module.info index 3f31f39a..6c732c9d 100644 --- a/modules/downloadfullsize/module.info +++ b/modules/downloadfullsize/module.info @@ -1,3 +1,3 @@ -name = DownloadFullsize -description = Displays a link to download the fullsize version of the current photo. +name = "DownloadFullsize" +description = "Displays a link to download the fullsize version of the current photo." version = 1 diff --git a/modules/downloadfullsize/views/downloadfullsize_header_block.html.php b/modules/downloadfullsize/views/downloadfullsize_header_block.html.php deleted file mode 100644 index df91292b..00000000 --- a/modules/downloadfullsize/views/downloadfullsize_header_block.html.php +++ /dev/null @@ -1,3 +0,0 @@ - - -" /> diff --git a/modules/editcreation/css/editcreation.css b/modules/editcreation/css/editcreation.css new file mode 100644 index 00000000..6894018c --- /dev/null +++ b/modules/editcreation/css/editcreation.css @@ -0,0 +1,3 @@ +select { + display: inline; +} diff --git a/modules/editcreation/helpers/editcreation_event.php b/modules/editcreation/helpers/editcreation_event.php index 6cadc8f9..e7eeb455 100644 --- a/modules/editcreation/helpers/editcreation_event.php +++ b/modules/editcreation/helpers/editcreation_event.php @@ -21,10 +21,7 @@ class editcreation_event_Core { static function item_edit_form($item, $form) { // Add a couple of drop-down boxes to allow the user to edit the date // that $item was created on. - - // Inject some css to make everything look right. - print ("\n"); - + // Add the datecreated element to the form. $form->edit_item->dateselect("datecreated") ->label(t("Created")) diff --git a/modules/displaytags/helpers/displaytags_theme.php b/modules/editcreation/helpers/editcreation_theme.php similarity index 55% rename from modules/displaytags/helpers/displaytags_theme.php rename to modules/editcreation/helpers/editcreation_theme.php index 529ac5de..c50cd739 100644 --- a/modules/displaytags/helpers/displaytags_theme.php +++ b/modules/editcreation/helpers/editcreation_theme.php @@ -1,4 +1,5 @@ -item()) { return; } - - // Create an array of all the tags for the current item. - $tagsItem = ORM::factory("tag") - ->join("items_tags", "tags.id", "items_tags.tag_id") - ->where("items_tags.item_id", $theme->item->id) - ->find_all(); - - // If the current item has at least one tag, display it/them. - if (count($tagsItem) > 0) { - $block = new Block(); - $block->css_id = "g-display-tags"; - $block->title = t("Tags"); - $block->content = new View("displaytags_block.html"); - $block->content->tags = $tagsItem; - return $block; + $item = $theme->item(); + if ( $item && access::can("edit", $item) ) { + $theme->css("editcreation.css"); } - } + } } diff --git a/modules/embedlinks/helpers/embedlinks_block.php b/modules/embedlinks/helpers/embedlinks_block.php new file mode 100644 index 00000000..44539854 --- /dev/null +++ b/modules/embedlinks/helpers/embedlinks_block.php @@ -0,0 +1,55 @@ + t("Embed Links Dialog"), "embed_links_album" => t("Embed Links Album")); + } + + static function get($block_id, $theme) { + $block = ""; + + switch ($block_id) { + case "embed_links_dialog": + // If displaying links in a dialog box is enabled then + // insert buttons into the bottom of the side bar + // to open up the dialog window. + if (module::get_var("embedlinks", "DialogLinks") && $theme->item()) { + $block = new Block(); + $block->css_id = "g-embed-links-sidebar"; + $block->title = t("Link To This Page"); + $block->content = new View("embedlinks_sidebar.html"); + } + break; + + case "embed_links_album": + // If the current item is an album and if "In Page" links are enabled then + // display links to the current album in the theme sidebar. + if ($theme->item()->is_album() && module::get_var("embedlinks", "InPageLinks")) { + $block = new Block(); + $block->css_id = "g-embed-links-album-sidebar"; + $block->title = t("Links"); + $block->content = new View("embedlinks_album_block.html"); + } + break; + } + + return $block; + } +} diff --git a/modules/embedlinks/helpers/embedlinks_theme.php b/modules/embedlinks/helpers/embedlinks_theme.php index 251b7e5c..c6d9cf92 100644 --- a/modules/embedlinks/helpers/embedlinks_theme.php +++ b/modules/embedlinks/helpers/embedlinks_theme.php @@ -18,31 +18,6 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class embedlinks_theme_Core { - static function sidebar_blocks($theme) { - // If the current item is an album and if "In Page" links are enabled then - // display links to the current album in the theme sidebar. - if ($theme->item()->is_album() && module::get_var("embedlinks", "InPageLinks")) { - $block = new Block(); - $block->css_id = "g-metadata"; - $block->title = t("Links"); - $block->content = new View("embedlinks_album_block.html"); - return $block; - } - } - - static function sidebar_bottom($theme) { - // If displaying links in a dialog box is enabled then - // insert buttons into the bottom of the side bar - // to open up the dialog window. - if (module::get_var("embedlinks", "DialogLinks")) { - $block = new Block(); - $block->css_id = "g-metadata"; - $block->title = t("Link To This Page:"); - $block->content = new View("embedlinks_sidebar.html"); - return $block; - } - } - static function photo_bottom($theme) { // If the current item is a photo and displaying "In Page" links // is enabled, then insert HTML/BBCode links into the bottom diff --git a/modules/embedlinks/module.info b/modules/embedlinks/module.info index de716d1a..a2917bcd 100644 --- a/modules/embedlinks/module.info +++ b/modules/embedlinks/module.info @@ -1,3 +1,3 @@ -name = EmbedLinks -description = Display BBCode and HTML code to embed links to albums/images into other web pages. +name = "EmbedLinks" +description = "Display BBCode and HTML code to embed links to albums/images into other web pages." version = 1 diff --git a/modules/embedlinks/views/embedlinks_htmldialog.html.php b/modules/embedlinks/views/embedlinks_htmldialog.html.php index 5847e8cc..46537754 100644 --- a/modules/embedlinks/views/embedlinks_htmldialog.html.php +++ b/modules/embedlinks/views/embedlinks_htmldialog.html.php @@ -5,7 +5,7 @@ input[type="text"] { }

-
+