1
0

Merge branch 'master' of git@github.com:gallery/gallery3-contrib into talmdal

This commit is contained in:
Tim Almdal 2009-12-26 08:24:13 -08:00
commit 92d56d7037
64 changed files with 677 additions and 624 deletions

View File

@ -36,7 +36,7 @@ class Atom_Entry_Core extends Atom_Base {
}
public function content($text, $type="html") {
$content = $this->dom->createElement("content", html::specialchars($text));
$content = $this->dom->createElement("content", html::chars($text));
$content->setAttribute("type", $type);
$this->element->appendChild($content);
return $this;

View File

@ -27,7 +27,7 @@ class Gallery_Atom_Entry_Core extends Atom_Entry {
parent::__construct("entry");
/* Set feed ID and self link. */
$this->id(html::specialchars(url::abs_current()));
$this->id(html::chars(url::abs_current()));
$this->link()
->rel("self")
->href(url::abs_current());

View File

@ -27,7 +27,7 @@ class Gallery_Atom_Feed_Core extends Atom_Feed {
parent::__construct("feed");
/* Set feed ID and self link. */
$this->id(html::specialchars(url::abs_current()));
$this->id(html::chars(url::abs_current()));
$this->link()
->rel("self")
->href(url::abs_current());

View File

@ -48,7 +48,7 @@ class Admin_Configure_Controller extends Controller
$view->content->form = $form;
//$view->content->products = ORM::factory("product")->orderby("name")->find_all();
//$view->content->products = ORM::factory("product")->order_by("name")->find_all();
print $view;
}

View File

@ -27,7 +27,7 @@ class Admin_Postage_Bands_Controller extends Controller
{
$view = new Admin_View("admin.html");
$view->content = new View("admin_postage_bands.html");
$view->content->postage_bands = ORM::factory("postage_band")->orderby("name")->find_all();
$view->content->postage_bands = ORM::factory("postage_band")->order_by("name")->find_all();
print $view;
}
@ -43,8 +43,8 @@ class Admin_Postage_Bands_Controller extends Controller
$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) {
$postage = ORM::factory("postage_band")->where("name", "=", $name)->find();
if ($postage->loaded()) {
$form->add_postage->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
@ -68,8 +68,8 @@ class Admin_Postage_Bands_Controller extends Controller
public function delete_postage_band_form($id) {
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded) {
kohana::show_404();
if (!$postage->loaded()) {
throw new Kohana_404_Exception();
}
print postage_band::get_delete_form_admin($postage);
}
@ -82,8 +82,8 @@ class Admin_Postage_Bands_Controller extends Controller
}
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded) {
kohana::show_404();
if (!$postage->loaded()) {
throw new Kohana_404_Exception();
}
$form = postage_band::get_delete_form_admin($postage);
@ -105,8 +105,8 @@ class Admin_Postage_Bands_Controller extends Controller
access::verify_csrf();
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded) {
kohana::show_404();
if (!$postage->loaded()) {
throw new Kohana_404_Exception();
}
$form = postage_band::get_edit_form_admin($postage);
@ -115,10 +115,10 @@ class Admin_Postage_Bands_Controller extends Controller
$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)
->where("name", "=", $new_name)
->where("id", "<>", $postage->id)
->find()
->loaded) {
->loaded()) {
$form->edit_postage->inputs["name"]->add_error("in_use", 1);
$valid = false;
} else {
@ -142,8 +142,8 @@ class Admin_Postage_Bands_Controller extends Controller
public function edit_postage_band_form($id) {
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded) {
kohana::show_404();
if (!$postage->loaded()) {
throw new Kohana_404_Exception();
}
$form = postage_band::get_edit_form_admin($postage);

View File

@ -27,7 +27,7 @@ class Admin_Product_Lines_Controller extends Controller
{
$view = new Admin_View("admin.html");
$view->content = new View("admin_product_lines.html");
$view->content->products = ORM::factory("product")->orderby("name")->find_all();
$view->content->products = ORM::factory("product")->order_by("name")->find_all();
print $view;
}
@ -43,8 +43,8 @@ class Admin_Product_Lines_Controller extends Controller
$form = product::get_add_form_admin();
$valid = $form->validate();
$name = $form->add_product->inputs["name"]->value;
$product = ORM::factory("product")->where("name", $name)->find();
if ($product->loaded) {
$product = ORM::factory("product")->where("name", "=", $name)->find();
if ($product->loaded()) {
$form->add_product->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
@ -69,8 +69,8 @@ class Admin_Product_Lines_Controller extends Controller
public function delete_product_form($id) {
$product = ORM::factory("product", $id);
if (!$product->loaded) {
kohana::show_404();
if (!$product->loaded()) {
throw new Kohana_404_Exception();
}
print product::get_delete_form_admin($product);
}
@ -83,8 +83,8 @@ class Admin_Product_Lines_Controller extends Controller
}
$product = ORM::factory("product", $id);
if (!$product->loaded) {
kohana::show_404();
if (!$product->loaded()) {
throw new Kohana_404_Exception();
}
$form = product::get_delete_form_admin($product);
@ -106,8 +106,8 @@ class Admin_Product_Lines_Controller extends Controller
access::verify_csrf();
$product = ORM::factory("product", $id);
if (!$product->loaded) {
kohana::show_404();
if (!$product->loaded()) {
throw new Kohana_404_Exception();
}
$form = product::get_edit_form_admin($product);
@ -116,10 +116,10 @@ class Admin_Product_Lines_Controller extends Controller
$new_name = $form->edit_product->inputs["name"]->value;
if ($new_name != $product->name &&
ORM::factory("product")
->where("name", $new_name)
->where("id !=", $product->id)
->where("name", "=", $new_name)
->where("id", "<>", $product->id)
->find()
->loaded) {
->loaded()) {
$form->edit_product->inputs["name"]->add_error("in_use", 1);
$valid = false;
} else {
@ -144,8 +144,8 @@ class Admin_Product_Lines_Controller extends Controller
public function edit_product_form($id) {
$product = ORM::factory("product", $id);
if (!$product->loaded) {
kohana::show_404();
if (!$product->loaded()) {
throw new Kohana_404_Exception();
}
$form = product::get_edit_form_admin($product);

View File

@ -205,7 +205,7 @@ Items Ordered:
// get the item to add
$item = ORM::factory("item", $id);
if (!$item->loaded)
if (!$item->loaded())
{
//TODO
die("Not loaded id");

View File

@ -49,9 +49,9 @@ class basket_event_Core{
static function item_edit_form($item, $form){
$group = $form->group("products")->label(t("Available Products"));
$product_override = ORM::factory("product_override")->where('item_id', $item->id)->find();
$product_override = ORM::factory("product_override")->where('item_id', "=", $item->id)->find();
$group->checkbox("all")->label("No products except..");
if ($product_override->loaded){
if ($product_override->loaded()){
$group->all->checked($product_override->none);
}
@ -63,11 +63,11 @@ class basket_event_Core{
$cost = $product->cost;
$checked = false;
if ($product_override->loaded){
if ($product_override->loaded()){
$item_product = ORM::factory("item_product")
->where('product_override_id', $product_override->id)
->where('product_id', $product->id)->find();
if ($item_product->loaded){
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded()){
$checked = $item_product->include;
if ($item_product->cost != -1){
$cost = $item_product->cost;
@ -82,7 +82,7 @@ class basket_event_Core{
}
static function item_edit_form_completed($item, $form){
$product_override = ORM::factory("product_override")->where('item_id', $item->id)->find();
$product_override = ORM::factory("product_override")->where('item_id', "=", $item->id)->find();
if ($form->products->all->checked)
{
@ -93,8 +93,8 @@ class basket_event_Core{
foreach ($products as $product){
$p_group = $form->products->__get("product_$product->id");
$item_product = ORM::factory("item_product")
->where('product_override_id', $product_override->id)
->where('product_id', $product->id)->find();
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
$item_product->include = $p_group->__get("exclude_$product->id")->checked;
$item_product->cost = $p_group->__get("cost_$product->id")->value;
@ -105,7 +105,7 @@ class basket_event_Core{
}
else
{
if ($product_override->loaded){
if ($product_override->loaded()){
$product_override->delete();
}
}

View File

@ -67,8 +67,8 @@ class postage_band_Core {
* @return User_Model
*/
static function create($name, $flatrate, $peritemcost) {
$postage = ORM::factory("postage_band")->where("name", $name)->find();
if ($postage->loaded) {
$postage = ORM::factory("postage_band")->where("name", "=", $name)->find();
if ($postage->loaded()) {
throw new Exception("@todo postage already EXISTS $name");
}

View File

@ -74,8 +74,8 @@ class product_Core {
* @return User_Model
*/
static function create($name, $cost, $description, $postage_band) {
$product = ORM::factory("product")->where("name", $name)->find();
if ($product->loaded) {
$product = ORM::factory("product")->where("name", "=", $name)->find();
if ($product->loaded()) {
throw new Exception("@todo USER_ALREADY_EXISTS $name");
}
@ -90,9 +90,9 @@ class product_Core {
static function getProductArray($id){
$producta = array();
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', $id)->find();
$product_override = ORM::factory("product_override")->where('item_id', "=", $id)->find();
if (!$product_override->loaded){
if (!$product_override->loaded()){
// no override found so check parents
// check parents for product override
$item = ORM::factory("item",$id);
@ -100,8 +100,8 @@ class product_Core {
$parents = $item->parents();
foreach ($parents as $parent){
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', $parent->id)->find();
if ($product_override->loaded){
$product_override = ORM::factory("product_override")->where('item_id', "=", $parent->id)->find();
if ($product_override->loaded()){
break;
}
}
@ -111,13 +111,13 @@ class product_Core {
foreach ($products as $product){
$show = true;
$cost = $product->cost;
if ($product_override->loaded){
if ($product_override->loaded()){
$show = !$product_override->none;
$item_product = ORM::factory("item_product")
->where('product_override_id', $product_override->id)
->where('product_id', $product->id)->find();
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded){
if ($item_product->loaded()){
$cost = $item_product->cost;
if (!$show){
$show = $item_product->include;
@ -137,9 +137,9 @@ class product_Core {
static function isForSale($id){
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', $id)->find();
$product_override = ORM::factory("product_override")->where('item_id', "=", $id)->find();
if (!$product_override->loaded){
if (!$product_override->loaded()){
// no override found so check parents
// check parents for product override
$item = ORM::factory("item",$id);
@ -147,8 +147,8 @@ class product_Core {
$parents = $item->parents();
foreach ($parents as $parent){
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', $parent->id)->find();
if ($product_override->loaded){
$product_override = ORM::factory("product_override")->where('item_id', "=", $parent->id)->find();
if ($product_override->loaded()){
break;
}
}
@ -156,15 +156,15 @@ class product_Core {
$products = ORM::factory("product")->find_all();
if ($product_override->loaded && $product_override->none){
if ($product_override->loaded() && $product_override->none){
foreach ($products as $product){
$item_product = ORM::factory("item_product")
->where('product_override_id', $product_override->id)
->where('product_id', $product->id)->find();
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded){
if ($item_product->loaded()){
if ($item_product->include){
return true;

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Postage_Band_Model extends ORM {
var $rules = array(
var $form_rules = array(
"name" => "length[1,32]");
protected $has_many=array('products');

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Product_Model extends ORM {
var $rules = array(
var $form_rules = array(
"name" => "length[1,32]",
"description" => "length[0,255]");
protected $belongs_to=array('postage_band');

View File

@ -21,8 +21,8 @@
<div class="gBlock">
<a href="<?= url::site("admin/postage_bands/add_postage_band_form") ?>"
class="gDialogLink gButtonLink right ui-icon-left ui-state-default ui-corner-all"
title="<?= t("Create a new Postage Band") ?>">
class="g-dialog-link g-button-link right ui-icon-left ui-state-default ui-corner-all"
title="<?= t("Create a new Postage Band") ?>">
<span class="ui-icon ui-icon-circle-plus"></span>
<?= t("Add a new Postage Band") ?>
</a>
@ -34,7 +34,7 @@
<div class="gBlockContent">
<table id="gPostageAdminList">
<tr>
<th><?= t("Name") ?></th>
<th><?= t("Name") ?></th>
<th><?= t("Flat Rate") ?></th>
<th><?= t("Per Item") ?></th>
<th><?= t("Actions") ?></th>
@ -44,27 +44,31 @@
<tr id="gProduct-<?= $postage_band->id ?>" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="product-<?= $postage_band->id ?>" class="core-info ">
<?= html::clean($postage_band->name) ?>
</td>
<td>
<?= basket::formatMoney($postage_band->flat_rate) ?>
</td>
<td>
<?= basket::formatMoney($postage_band->per_item) ?>
</td>
<td class="gActions">
<a href="<?= url::site("admin/postage_bands/edit_postage_band_form/$postage_band->id") ?>"
open_text="<?= t("close") ?>"
class="gPanelLink gButtonLink ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-pencil"></span><span class="gButtonText"><?= t("edit") ?></span></a>
<td>
<?= basket::formatMoney($postage_band->flat_rate) ?>
</td>
<td>
<?= basket::formatMoney($postage_band->per_item) ?>
</td>
<td class="gActions">
<a href="<?= url::site("admin/postage_bands/edit_postage_band_form/$postage_band->id") ?>"
open_text="<?= t("close") ?>"
class="g-panel-link g-button-link ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-pencil"></span>
<?= t("edit") ?>
</a>
<a href="<?= url::site("admin/postage_bands/delete_postage_band_form/$postage_band->id") ?>"
class="gDialogLink gButtonLink ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-trash"></span><?= t("delete") ?></a>
</td>
<a href="<?= url::site("admin/postage_bands/delete_postage_band_form/$postage_band->id") ?>"
class="g-dialog-link g-button-link ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-trash"></span>
<?= t("delete") ?>
</a>
</td>
</tr>
</tr>
<? endforeach ?>
</table>
</table>
</div>
</div>
</div>

View File

@ -24,22 +24,24 @@ class BatchTag_Controller extends Controller {
// Prevent Cross Site Request Forgery
access::verify_csrf();
$input = Input::instance();
// Figure out if the contents of sub-albums should also be tagged
$str_tag_subitems = Input::instance()->post("tag_subitems");
$str_tag_subitems = $input->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();
->where("parent_id", "=", $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();
$children = ORM::factory("item", $input->post("item_id"))
->where("type", "!=", "album")
->descendants();
}
// Loop through each item in the album and make sure the user has
@ -50,7 +52,7 @@ class BatchTag_Controller extends Controller {
// Assuming the user can view/edit the current item, loop
// through each tag that was submitted and apply it to
// the current item.
foreach (split(",", $this->input->post("name")) as $tag_name) {
foreach (split(",", $input->post("name")) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
tag::add($child, $tag_name);
@ -60,7 +62,7 @@ class BatchTag_Controller extends Controller {
}
// Redirect back to the album.
$item = ORM::factory("item", $this->input->post("item_id"));
$item = ORM::factory("item", $input->post("item_id"));
url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
}
}

View File

@ -50,31 +50,31 @@ class CalendarView_Controller extends Controller {
if ($display_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $display_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->find_all()
->count();
}
// Figure out paging stuff.
$page_size = module::get_var("gallery", "page_size", 9);
$page = (int) $this->input->get("page", "1");
$page = (int) Input::instance()->get("page", "1");
$offset = ($page-1) * $page_size;
$max_pages = max(ceil($day_count / $page_size), 1);
// Make sure that the page references a valid offset
if (($page < 1) || ($page > $max_pages)) {
Kohana::show_404();
throw new Kohana_404_Exception();
}
// Set up the page.
@ -88,19 +88,19 @@ class CalendarView_Controller extends Controller {
if ($display_user == "-1") {
$template->set_global("children", ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->orderby("captured", "ASC")
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
} else {
$template->set_global("children", ORM::factory("item")
->viewable()
->where("owner_id", $display_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->orderby("captured", "ASC")
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
}
@ -126,31 +126,31 @@ class CalendarView_Controller extends Controller {
if ($display_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $display_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->find_all()
->count();
}
// Figure out paging stuff.
$page_size = module::get_var("gallery", "page_size", 9);
$page = (int) $this->input->get("page", "1");
$page = (int) Input::instance()->get("page", "1");
$offset = ($page-1) * $page_size;
$max_pages = max(ceil($day_count / $page_size), 1);
// Make sure that the page references a valid offset
if (($page < 1) || ($page > $max_pages)) {
Kohana::show_404();
throw new Kohana_404_Exception();
}
// Set up the page.
@ -164,19 +164,19 @@ class CalendarView_Controller extends Controller {
if ($display_user == "-1") {
$template->set_global("children", ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->orderby("captured", "ASC")
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
} else {
$template->set_global("children", ORM::factory("item")
->viewable()
->where("owner_id", $display_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured <", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->orderby("captured", "ASC")
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
}
@ -204,9 +204,9 @@ class CalendarView_Controller extends Controller {
foreach ($gallery_users as $one_user) {
$count = ORM::factory("item")
->viewable()
->where("owner_id", $one_user->id)
->where("type !=", "album")
->where("captured !=", "")
->where("owner_id", "=", $one_user->id)
->where("type", "!=", "album")
->where("captured", "!=", "")
->find_all()
->count();
if ($count > 0) {
@ -219,10 +219,10 @@ class CalendarView_Controller extends Controller {
$valid_years = Array();
$all_photos = ORM::factory("item")
->viewable()
//->where("owner_id", $one_user->id)
->where("type !=", "album")
->where("captured !=", "")
->orderby("captured", "DESC")
//->where("owner_id", "=", $one_user->id)
->where("type", "!=", "album")
->where("captured", "!=", "")
->order_by("captured", "DESC")
->find_all();
$counter = date('Y', $all_photos[count($all_photos)-1]->captured);
while ($counter <= date('Y', $all_photos[0]->captured)) {

View File

@ -59,7 +59,7 @@ class Calendar_Core extends Event_Subject {
foreach ($days as $i => $day)
{
// Shorten the days to the expected length
$days[$i] = utf8::substr($day, 0, $length);
$days[$i] = mb_substr($day, 0, $length);
}
}

View File

@ -15,18 +15,18 @@
if ($calendar_user == "-1") {
$month_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
->find_all()
->count();
} else {
$month_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
->find_all()
->count();
}
@ -39,26 +39,26 @@
if ($calendar_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->find_all()
->count();
}
if ($day_count > 0) {
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $curr_day)
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $curr_day)
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day), $day_count)));
}
$curr_day++;
@ -68,26 +68,26 @@
if ($calendar_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured <", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured", "<",mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured <", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
->where("owner_id", "=", $calendar_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
->find_all()
->count();
}
if ($day_count > 0) {
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $MAX_DAYS)
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $MAX_DAYS)
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS), $day_count)));
}
}
@ -98,27 +98,27 @@
}
$counter_months++;
}
// Do December seperately, because the mktime code is different.
print "<td>";
$calendar = new Calendar($counter_months, $calendar_year);
if ($calendar_user == "-1") {
$month_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured <", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
->find_all()
->count();
} else {
$month_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured <", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
->where("owner_id", "=", $calendar_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
->find_all()
->count();
->count();
}
if ($month_count > 0) {
$curr_day = 1;
@ -127,26 +127,26 @@
if ($calendar_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured <", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->where("owner_id", "=", $calendar_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
->find_all()
->count();
}
if ($day_count > 0) {
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $curr_day)
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $curr_day)
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day), $day_count)));
}
$curr_day++;
@ -154,26 +154,26 @@
if ($calendar_user == "-1") {
$day_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured <", mktime(0, 0, 0, 1, 1, $calendar_year+1))
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1))
->find_all()
->count();
} else {
$day_count = ORM::factory("item")
->viewable()
->where("owner_id", $calendar_user)
->where("type !=", "album")
->where("captured >=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured <", mktime(0, 0, 0, 1, 1, $calendar_year+1))
->where("owner_id", "=", $calendar_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1))
->find_all()
->count();
->count();
}
if ($day_count > 0) {
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $MAX_DAYS)
$calendar -> attach($calendar -> event()
-> condition('year', $calendar_year)
-> condition('month', $counter_months)
-> condition('day', $MAX_DAYS)
-> output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS), $day_count)));
}

View File

@ -20,10 +20,10 @@
class ContactOwner_Controller extends Controller {
public function emailowner() {
// Display a form that a vistor can use to contact the site owner.
// If this page is disabled, show a 404 error.
if (module::get_var("contactowner", "contact_owner_link") != true) {
kohana::show_404();
throw new Kohana_404_Exception();
}
// Make a new form with a couple of text boxes.
@ -49,16 +49,16 @@ class ContactOwner_Controller extends Controller {
public function emailid($user_id) {
// Display a form that a vistor can use to contact a registered user.
// If this page is disabled, show a 404 error.
if (module::get_var("contactowner", "contact_user_link") != true) {
kohana::show_404();
throw new Kohana_404_Exception();
}
// Locate the record for the user specified by $user_id,
// use this to determine the user's name.
$userDetails = ORM::factory("user")
->where("id", $user_id)
->where("id", "=", $user_id)
->find_all();
// Make a new form with a couple of text boxes.
@ -84,16 +84,16 @@ class ContactOwner_Controller extends Controller {
public function sendemail() {
// Process the data from the form into an email,
// then send the email.
// Copy the data from the email from into a couple of variables.
$str_emailsubject = Input::instance()->post("email_subject");
$str_emailtoid = Input::instance()->post("email_to_id");
$str_emailfrom = Input::instance()->post("email_from");
$str_emailbody = Input::instance()->post("email_body");
// Add in some <br> tags to the message body where ever there are line breaks.
$str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
// Gallery's Sendmail library doesn't allow for custom from addresses,
// so add the from email to the beginning of the message body instead.
$str_emailbody = "Message Sent From " . $str_emailfrom . "\r\n\r\n<br/><br/>" . $str_emailbody;
@ -101,17 +101,17 @@ class ContactOwner_Controller extends Controller {
// Figure out where the email is going to.
$str_emailto = "";
if ($str_emailtoid == -1) {
// If the email id is "-1" send the message to a pre-determined
// If the email id is "-1" send the message to a pre-determined
// owner email address.
$str_emailto = module::get_var("contactowner", "contact_owner_email");
} else {
// or else grab the email from the user table.
$userDetails = ORM::factory("user")
->where("id", $str_emailtoid)
->where("id", "=", $str_emailtoid)
->find_all();
$str_emailto = $userDetails[0]->email;
}
// Send the email message.
Sendmail::factory()
->to($str_emailto)

View File

@ -24,19 +24,19 @@ class contactowner_block_Core {
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
// then $displayBlock will rename set to false and the
// block will not be displayed.
$displayBlock = false;
@ -44,29 +44,29 @@ class contactowner_block_Core {
// 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)
->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 != "") &&
if ((count($userDetails) > 0) && ($userDetails[0]->email != "") &&
(module::get_var("contactowner", "contact_user_link") == true)) {
$block->content->userLink = "<a href=\"" . url::site("contactowner/emailid/" .
$theme->item->owner_id) . "\">" . t("Contact") . " " .
$block->content->userLink = "<a href=\"" . url::site("contactowner/emailid/" .
$theme->item->owner_id) . "\">" . t("Contact") . " " .
$userDetails[0]->name . "</a>";
$displayBlock = true;
}
}
// Figure out if the contact site owner link should be displayed.
if (module::get_var("contactowner", "contact_owner_link")) {
$block->content->ownerLink = "<a href=\"" . url::site("contactowner/emailowner") .
$block->content->ownerLink = "<a href=\"" . url::site("contactowner/emailowner") .
"\">" . t(module::get_var("contactowner", "contact_button_text")) . "</a>";
$displayBlock = true;
}
break;
break;
}
if ($displayBlock) {

View File

@ -1,15 +1,15 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul id="g-contact-owner">
<? if ($ownerLink != "") { ?>
<li style="clear: both;">
<? print ($ownerLink); ?>
<? if (!empty($ownerLink)): ?>
<li style="clear: both">
<?= $ownerLink ?>
</li>
<? } ?>
<? if ($userLink != "") { ?>
<li style="clear: both;">
<? print ($userLink); ?>
</li>
<? } ?>
<? endif ?>
<? if (!empty($userLink)): ?>
<li style="clear: both">
<?= ($userLink); ?>
</li>
<? endif ?>
</ul>

View File

@ -174,7 +174,7 @@ class Admin_Developer_Controller extends Admin_Controller {
}
function mptt_graph() {
$items = ORM::factory("item")->orderby("id")->find_all();
$items = ORM::factory("item")->order_by("id")->find_all();
$data = $this->_build_tree();
$proc = proc_open("/usr/bin/dot -Tsvg",
@ -192,7 +192,7 @@ class Admin_Developer_Controller extends Admin_Controller {
}
private function _build_tree() {
$items = ORM::factory("item")->orderby("id")->find_all();
$items = ORM::factory("item")->order_by("id")->find_all();
$data = "digraph G {\n";
foreach ($items as $item) {
$data .= " $item->parent_id -> $item->id\n";
@ -249,8 +249,8 @@ class Admin_Developer_Controller extends Admin_Controller {
$v = new View("admin_developer_test_data.html");
$v->action = "admin/developer/test_data_create";
$v->hidden = array("csrf" => access::csrf_token());
$album_count = ORM::factory("item")->where("type", "album")->count_all();
$photo_count = ORM::factory("item")->where("type", "photo")->count_all();
$album_count = ORM::factory("item")->where("type", "=", "album")->count_all();
$photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
$v->comment_installed = module::is_active("comment");
$comment_count = empty($v->comment_installed) ? 0 : ORM::factory("comment")->count_all();

View File

@ -183,7 +183,7 @@ class developer_task_Core {
private static function _add_album_or_photo($desired_type=null) {
srand(time());
$parents = ORM::factory("item")->where("type", "album")->find_all()->as_array();
$parents = ORM::factory("item")->where("type", "=", "album")->find_all()->as_array();
$owner_id = user::active()->id;
$test_images = glob(dirname(dirname(__FILE__)) . "/data/*.[Jj][Pp][Gg]");
@ -209,7 +209,7 @@ class developer_task_Core {
private static function _add_comment() {
srand(time());
$photos = ORM::factory("item")->where("type", "photo")->find_all()->as_array();
$photos = ORM::factory("item")->where("type", "=", "photo")->find_all()->as_array();
$users = ORM::factory("user")->find_all()->as_array();
if (empty($photos)) {

View File

@ -44,4 +44,5 @@
</li>
</ul>
</fieldset>
<?= form::close() ?>
</form>

View File

@ -24,7 +24,7 @@ class displaytags_block_Core {
static function get($block_id, $theme) {
$block = "";
// Make sure the current page belongs to an item.
if (!$theme->item()) {
return;
@ -34,9 +34,9 @@ class displaytags_block_Core {
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();
->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) {
@ -47,7 +47,7 @@ class displaytags_block_Core {
$block->content->tags = $tagsItem;
}
break;
break;
}
return $block;
}

View File

@ -1,10 +1,8 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div class="g-display-tags-block">
<? for ($counter=0; $counter<count($tags); $counter++) { ?>
<? if ($counter < count($tags)-1) { ?>
<a href="<?= url::site("tags/$tags[$counter]") ?>"><?= html::clean($tags[$counter]->name) ?></a>,
<? } else {?>
<a href="<?= url::site("tags/$tags[$counter]") ?>"><?= html::clean($tags[$counter]->name) ?></a>
<? } ?>
<? } ?>
<? $not_first = 0; ?>
<? foreach ($tags as $tag): ?>
<?= ($not_first++) ? "," : "" ?>
<a href="<?= url::site("tags/{$tag->name}") ?>"><?= html::clean($tag->name) ?></a>
<? endforeach ?>
</div>

View File

@ -21,7 +21,7 @@ class downloadfullsize_event_Core {
static function photo_menu($menu, $theme) {
if (access::can("view_full", $theme->item)) {
if (module::get_var("downloadfullsize", "fButton")) {
$downloadLink = url::site("downloadfullsize/send/$theme->item");
$downloadLink = url::site("downloadfullsize/send/{$theme->item->id}");
$menu
->append(Menu::factory("link")
->id("downloadfullsize")
@ -35,7 +35,7 @@ class downloadfullsize_event_Core {
static function movie_menu($menu, $theme) {
if (access::can("view_full", $theme->item)) {
if (module::get_var("downloadfullsize", "fButton")) {
$downloadLink = url::site("downloadfullsize/send/$theme->item");
$downloadLink = url::site("downloadfullsize/send/{$theme->item->id}");
$menu
->append(Menu::factory("link")
->id("downloadfullsize")

View File

@ -18,23 +18,23 @@
*/
class Dynamic_Controller extends Controller {
public function updates() {
print $this->_show("updates");
print $this->_show("updates", t("Recent changes"));
}
public function popular() {
print $this->_show("popular");
print $this->_show("popular", t("Most viewed"));
}
private function _show($album) {
$page_size = module::get_var("gallery", "page_size", 9);
$page = $this->input->get("page", "1");
$page = Input::instance()->get("page", "1");
$album_defn = unserialize(module::get_var("dynamic", $album));
$children_count = $album_defn->limit;
if (empty($children_count)) {
$children_count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("type", "!=", "album")
->count_all();
}
@ -44,15 +44,17 @@ class Dynamic_Controller extends Controller {
// Make sure that the page references a valid offset
if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) {
Kohana::show_404();
throw new Kohana_404_Exception();
}
$template = new Theme_View("page.html", "other", "dynamic");
$template = new Theme_View("page.html", "collection", "dynamic");
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", ORM::factory("item")
->viewable()
->where("type !=", "album")
->orderby($album_defn->key_field, "DESC")
->where("type", "!=", "album")
->order_by($album_defn->key_field, "DESC")
->find_all($page_size, $offset));
$template->set_global("children_count", $children_count);
$template->content = new View("dynamic.html");

View File

@ -16,22 +16,30 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class dynamic_theme {
static function sidebar_blocks($theme) {
$albums = array();
foreach (array("updates", "popular") as $album) {
$album_defn = unserialize(module::get_var("dynamic", $album));
if ($album_defn->enabled) {
$albums[$album] = $album_defn->title;
class dynamic_block_Core {
static function get_site_list() {
return array("dynamic" => t("Dynamic Albums"));
}
static function get($block_id) {
switch ($block_id) {
case "dynamic":
$albums = array();
foreach (array("updates", "popular") as $album) {
$album_defn = unserialize(module::get_var("dynamic", $album));
if ($album_defn->enabled) {
$albums[$album] = $album_defn->title;
}
}
if (!empty($albums)) {
$block = new Block();
$block->css_id = "g-dynamic";
$block->title = t("Dynamic Albums");
$block->content = new View("dynamic_block.html");
$block->content->albums = $albums;
return $block;
}
}
if (!empty($albums)) {
$block = new Block();
$block->css_id = "g-dynamic";
$block->title = t("Dynamic Albums");
$block->content = new View("dynamic_block.html");
$block->content->albums = $albums;
return $block;
}
return "";
}

View File

@ -26,14 +26,14 @@ class dynamic_installer {
"limit" => null,
"description" => "",
"key_field" => "view_count",
"title" => t("Most Viewed"))));
"title" => t("Most viewed"))));
module::set_var(
"dynamic", "updates",
serialize((object)array("enabled" => false,
"limit" => null,
"description" => "",
"key_field" => "created",
"title" => t("Recent Changes"))));
"title" => t("Recent changes"))));
module::set_version("dynamic", 1);
}
}

View File

@ -1,3 +1,3 @@
name = Dynamic
description = Adds the Recent Changes and Most Viewed dynamic albums
name = "Dynamic"
description = "Adds the Recent Changes and Most Viewed dynamic albums"
version = 1

View File

@ -1,3 +1,3 @@
name = Google Maps
description = Integrate with the Google Maps service
name = "Google Maps"
description = "Integrate with the Google Maps service"
version = 1

View File

@ -1,3 +1,3 @@
name = Google Analytics
description = Renders the Google Analytics Code at the end of the page. Written by 'mcp'.
name = "Google Analytics"
description = "Renders the Google Analytics Code at the end of the page. Written by 'mcp'."
version = 2

View File

@ -102,7 +102,11 @@ class Json_Album_Controller extends Controller {
$i = 0;
foreach ($album->children() as $child) {
// Do this directly in the database to avoid sending notifications
Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id));
db::build()
->update("items")
->set("weight", ++$i)
->where("id", "=", $child->id)
->execute();
}
$album->sort_column = "weight";
$album->sort_order = "ASC";
@ -118,15 +122,20 @@ class Json_Album_Controller extends Controller {
// Make a hole
$count = count($source_ids);
Database::Instance()->query(
"UPDATE {items} " .
"SET `weight` = `weight` + $count " .
"WHERE `weight` >= $target_weight AND `parent_id` = {$album->id}");
db::build()
->update("items")
->set("weight", new Database_Expression("`weight` + $count"))
->where("weight", ">=", $target_weight)
->where("parent_id", "=", $album->id)
->execute();
// Insert source items into the hole
foreach ($source_ids as $source_id) {
Database::Instance()->update(
"items", array("weight" => $target_weight++), array("id" => $source_id));
db::build()
->update("items")
->set("weight", $target_weight++)
->where("id", "=", $source_id)
->execute();
}
module::event("album_rearrange", $album);

View File

@ -23,29 +23,29 @@ class itemchecksum_Controller extends Controller {
// in the specified album ($album_id).
$item = ORM::factory("item")
->viewable()
->where("parent_id", $album_id)
->where("type !=", "album")
->where("parent_id", "=", $album_id)
->where("type", "!=", "album")
->find_all();
print count($item);
}
public function md5($album_id, $file_name) {
// Locate an item with $file_name in the album $album_id
// and display it's md5 checksum.
$item = ORM::factory("item")
->where("parent_id", $album_id)
->where("name", $file_name)
->where("parent_id", "=", $album_id)
->where("name", "=", $file_name)
->find_all();
if (count($item) > 0) {
access::required("view_full", $item[0]);
// If the KeepOriginal module is active, check for/use the
// If the KeepOriginal module is active, check for/use the
// original image instead of the gallery edited version.
if (module::is_active("keeporiginal")) {
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item[0]->file_path());
if ($item[0]->is_photo() && file_exists($original_image)) {
if ($item[0]->is_photo() && file_exists($original_image)) {
print md5_file($original_image);
} else {
print md5_file($item[0]->file_path());
@ -57,24 +57,24 @@ class itemchecksum_Controller extends Controller {
print "0";
}
}
public function sha1($album_id, $file_name) {
// Locate an item with $file_name in the album $album_id
// and display it's sha-1 checksum.
$item = ORM::factory("item")
->where("parent_id", $album_id)
->where("name", $file_name)
->where("parent_id", "=", $album_id)
->where("name", "=", $file_name)
->find_all();
if (count($item) > 0) {
access::required("view_full", $item[0]);
// If the KeepOriginal module is active, check for/use the
// If the KeepOriginal module is active, check for/use the
// original image instead of the gallery edited version.
if (module::is_active("keeporiginal")) {
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item[0]->file_path());
if ($item[0]->is_photo() && file_exists($original_image)) {
if ($item[0]->is_photo() && file_exists($original_image)) {
print sha1_file($original_image);
} else {
print sha1_file($item[0]->file_path());

View File

@ -1,3 +1,3 @@
name = Keep Original
description = Make a copy of the original photo before rotating it.
name = "Keep Original"
description = "Make a copy of the original photo before rotating it."
version = 1

View File

@ -29,14 +29,14 @@ class latestalbums_rss_Core {
case "latest":
$feed->children = ORM::factory("item")
->viewable()
->where("type", "album")
->orderby("created", "DESC")
->where("type", "=", "album")
->order_by("created", "DESC")
->find_all($limit, $offset);
$all_children = ORM::factory("item")
->viewable()
->where("type", "album")
->orderby("created", "DESC");
->where("type", "=", "album")
->order_by("created", "DESC");
$feed->max_pages = ceil($all_children->find_all()->count() / $limit);
$feed->title = t("Latest albums");

View File

@ -18,47 +18,44 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class latestupdates_Controller extends Controller {
public function albums($id) {
// Figure out how many items to display on each page.
$itemsPerPage = module::get_var("gallery", "page_size", 9);
// Figure out which page # the visitor is on and
$page_size = module::get_var("gallery", "page_size", 9);
// Figure out which page # the visitor is on and
// don't allow the visitor to go below page 1.
$page = $this->input->get("page", 1);
$page = Input::instance()->get("page", 1);
if ($page < 1) {
url::redirect("latestupdates/albums/{$item->id}");
}
// First item to display.
$offset = ($page - 1) * $itemsPerPage;
$offset = ($page - 1) * $page_size;
$item = ORM::factory("item", $id);
// Determine the total number of items,
// for page numbering purposes.
$count = ORM::factory("item", $id)
// for page numbering purposes.
$count = $item
->viewable()
->where("type !=", "album")
->orderby("created", "DESC")
->descendants()
->count();
->descendants_count(null, null, array(array("type", "!=", "album")));
// Figure out what the highest page number is.
$max_pages = ceil($count / $itemsPerPage);
$max_pages = ceil($count / $page_size);
// Don't let the visitor go past the last page.
if ($max_pages && $page > $max_pages) {
if ($max_pages && $page > $max_pages) {
url::redirect("latestupdates/albums/{$item->id}?page=$max_pages");
}
// Figure out which items to display on this page.
$children = ORM::factory("item", $id)
$children = $item
->viewable()
->where("type !=", "album")
->orderby("created", "DESC")
->limit($itemsPerPage)
->offset($offset)
->descendants();
->where("type", "!=", "album")
->order_by("created", "DESC")
->descendants($page_size, $offset);
// Set up the previous and next page buttons.
if ($page > 1) {
$previous_page = $page - 1;
@ -70,9 +67,11 @@ class latestupdates_Controller extends Controller {
}
// Set up and display the actual page.
$template = new Theme_View("page.html", "other", "LatestUpdates");
$template = new Theme_View("page.html", "collection", "LatestUpdates");
$template->page_title = t("Gallery :: Latest Updates");
$template->set_global("page_size", $itemsPerPage);
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", $children);
$template->set_global("children_count", $count);
$template->content = new View("dynamic.html");
@ -82,41 +81,41 @@ class latestupdates_Controller extends Controller {
public function updates() {
// Figure out how many items to display on each page.
$itemsPerPage = module::get_var("gallery", "page_size", 9);
$page_size = module::get_var("gallery", "page_size", 9);
// Figure out which page # the visitor is on and
// Figure out which page # the visitor is on and
// don't allow the visitor to go below page 1.
$page = $this->input->get("page", 1);
$page = Input::instance()->get("page", 1);
if ($page < 1) {
url::redirect("latestupdates/updates");
}
// First item to display.
$offset = ($page - 1) * $itemsPerPage;
$offset = ($page - 1) * $page_size;
// Determine the total number of items,
// for page numbering purposes.
// for page numbering purposes.
$count = ORM::factory("item")
->viewable()
->where("type !=", "album")
->where("type", "!=", "album")
->find_all()
->count();
// Figure out what the highest page number is.
$max_pages = ceil($count / $itemsPerPage);
$max_pages = ceil($count / $page_size);
// Don't let the visitor go past the last page.
if ($max_pages && $page > $max_pages) {
url::redirect("latestupdates/updates?page=$max_pages");
}
// Figure out which items to display on this page.
$items = ORM::factory("item")
->viewable()
->where("type !=", "album")
->orderby("created", "DESC")
->find_all($itemsPerPage, $offset);
->where("type", "!=", "album")
->order_by("created", "DESC")
->find_all($page_size, $offset);
// Set up the previous and next page buttons.
if ($page > 1) {
$previous_page = $page - 1;
@ -126,11 +125,13 @@ class latestupdates_Controller extends Controller {
$next_page = $page + 1;
$view->next_page_link = url::site("latestupdates/updates?page={$next_page}");
}
// Set up and display the actual page.
$template = new Theme_View("page.html", "other", "LatestUpdates");
$template = new Theme_View("page.html", "collection", "LatestUpdates");
$template->page_title = t("Gallery :: Latest Updates");
$template->set_global("page_size", $itemsPerPage);
$template->set_global("page", $page);
$template->set_global("page_size", $page_size);
$template->set_global("max_pages", $max_pages);
$template->set_global("children", $items);
$template->set_global("children_count", $count);
$template->content = new View ("dynamic.html");

View File

@ -23,7 +23,7 @@ class metadescription_theme_Core {
// If the current page belongs to a tag, look up
// the information for that tag.
$tagsItem = ORM::factory("tag")
->where("id", $theme->tag())
->where("id", "=", $theme->tag()->id)
->find_all();
} elseif ($theme->item()) {
@ -31,7 +31,7 @@ class metadescription_theme_Core {
// look up any tags that have been applied to that item.
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $theme->item->id)
->where("items_tags.item_id", "=", $theme->item->id)
->find_all();
} else {

View File

@ -27,7 +27,7 @@ class minislideshow_event_Core {
->label(t("MiniSlide Show settings"))
->url(url::site("admin/minislideshow")));
}
static function module_change($changes) {
// Display a warning message if the RSS module is not installed.
if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) {
@ -47,7 +47,7 @@ class minislideshow_event_Core {
->append(Menu::factory("link")
->id("minislideshow")
->label(t("View MiniSlide Show"))
->url(url::site("minislideshow/showslideshow/" . $theme->item()))
->url(url::site("minislideshow/showslideshow/" . $theme->item()->id))
->css_class("g-dialog-link")
->css_id("g-mini-slideshow-link"));
}
@ -58,7 +58,7 @@ class minislideshow_event_Core {
->append(Menu::factory("link")
->id("minislideshow")
->label(t("View MiniSlide Show"))
->url(url::site("minislideshow/showslideshow/" . $theme->item()))
->url(url::site("minislideshow/showslideshow/" . $theme->item()->id))
->css_class("g-dialog-link")
->css_id("g-mini-slideshow-link"));
}

View File

@ -1,3 +1,3 @@
name = PHPMailer
description = Use PHPMailer when sending email messages.
name = "PHPMailer"
description = "Use PHPMailer when sending email messages."
version = 1

View File

@ -19,7 +19,7 @@
*/
class polar_rose_theme_Core {
static function head($theme) {
if (module::is_installed("rss")) {
if (module::is_installed("rss") && ($theme->item() || $theme->tag())) {
if ($item = $theme->item()) {
$url = rss::feed_link("gallery/album/{$item->id}");
} else if ($tag = $theme->tag()) {

View File

@ -1,3 +1,3 @@
name = Polar Rose
description = Integrate Gallery with the Polar Rose facial recognition service.
name = "Polar Rose"
description = "Integrate Gallery with the Polar Rose facial recognition service."
version = 1

View File

@ -19,7 +19,7 @@
class Admin_register_Controller extends Admin_Controller {
public function index() {
$count = ORM::factory("pending_user")
->where("state !=", 2)
->where("state", "!=", 2)
->count_all();
if ($count == 0) {
site_status::clear("pending_user_registrations");
@ -54,6 +54,7 @@ class Admin_register_Controller extends Admin_Controller {
$post = new Validation($_POST);
$post->add_rules("activate_users", "required");
$post->add_rules("activate", "alpha_numeric");
if ($post->validate()) {
$names = array();
if (!empty($post->activate)) {
@ -66,7 +67,7 @@ class Admin_register_Controller extends Admin_Controller {
}
$count = ORM::factory("pending_user")
->where("state != ", 2)
->where("state", "!=", 2)
->count_all();
if ($count == 0) {
@ -105,7 +106,7 @@ class Admin_register_Controller extends Admin_Controller {
$v->content->group_list[$group->id] = $group->name;
}
}
$hidden = array("csrf" => access::csrf_token());
$hidden = array("name" => "csrf", "value" => access::csrf_token());
if (count($v->content->group_list)) {
$v->content->group_list =
array("" => t("Choose the default group")) + $v->content->group_list;

View File

@ -67,10 +67,10 @@ class register_Controller extends Controller {
public function confirm($hash) {
$pending_user = ORM::factory("pending_user")
->where("hash", $hash)
->where("state", 0)
->where("hash", "=", $hash)
->where("state", "=", 0)
->find();
if ($pending_user->loaded) {
if ($pending_user->loaded()) {
// @todo add a request date to the pending user table and check that it hasn't expired
$policy = module::get_var("registration", "policy");
$pending_user->state = 1;
@ -96,10 +96,10 @@ class register_Controller extends Controller {
public function first($hash) {
$pending_user = ORM::factory("pending_user")
->where("hash", $hash)
->where("state", 2)
->where("hash", "=", $hash)
->where("state", "=", 2)
->find();
if ($pending_user->loaded) {
if ($pending_user->loaded()) {
// @todo add a request date to the pending user table and check that it hasn't expired
$user = identity::lookup_user_by_name($pending_user->name);
if (!empty($user)) {

View File

@ -32,9 +32,9 @@ class register_Core {
return true;
}
$user = ORM::factory("pending_user")
->where("name", $user_name)
->where("name", "=", $user_name)
->find();
return $user->loaded;
return $user->loaded();
}
static function send_user_created_confirmation($user) {

View File

@ -14,69 +14,69 @@
<h1><?= t("User registration adminstration") ?></h1>
<div id="g-registration-admin" class="g-block-content">
<?= form::open($action, array("method" => "post"), $hidden) ?>
<?= form::open_fieldset() ?>
<legend><?= t("Confirmation policy") ?></legend>
<ul>
<? foreach ($policy_list as $policy => $text): ?>
<li>
<?= form::radio("policy", $policy, $policy == $form["policy"]) ?>
<?= form::label("policy", $text) ?>
</li>
<? endforeach ?>
<li>
<?= form::checkbox("email_verification", "true", !empty($form["email_verification"]), $disable_email) ?>
<?= form::label("email_verification", t("Require e-mail verification when a visitor creates an account")) ?>
</li>
<li>
<? if (!empty($group_list)): ?>
<label for="group" class="g-left"> <?= t("Default group: ") ?></label>
<?= form::dropdown(array("name" => "group"), $group_list, $form["group"]) ?></label>
<? endif ?>
</li>
<li>
<?= form::submit(array("id" => "g-registration-admin", "name" => "save", "class" => "submit", "style" => "clear:both!important"), t("Update")) ?>
</li>
</ul>
<?= form::close_fieldset() ?>
<?= form::close() ?>
<fieldset>
<legend><?= t("Confirmation policy") ?></legend>
<ul>
<? foreach ($policy_list as $policy => $text): ?>
<li>
<?= form::radio("policy", $policy, $policy == $form["policy"]) ?>
<?= form::label("policy", $text) ?>
</li>
<? endforeach ?>
<li>
<?= form::checkbox("email_verification", "true", !empty($form["email_verification"]), $disable_email) ?>
<?= form::label("email_verification", t("Require e-mail verification when a visitor creates an account")) ?>
</li>
<li>
<? if (!empty($group_list)): ?>
<label for="group" class="g-left"> <?= t("Default group: ") ?></label>
<?= form::dropdown(array("name" => "group"), $group_list, $form["group"]) ?></label>
<? endif ?>
</li>
<li>
<?= form::submit(array("id" => "g-registration-admin", "name" => "save", "class" => "submit", "style" => "clear:both!important"), t("Update")) ?>
</li>
</ul>
</fieldset>
</form>
</div>
<? if (count($pending)): ?>
<div id="g-activate-pending-users">
<?= form::open($activate, array("method" => "post"), $hidden) ?>
<?= form::open_fieldset() ?>
<legend><?= t("Pending registrations") ?></legend>
<table>
<caption>
<?= t("To delete an unconfirmed registration, first activate it, then delete it from Users/Groups.") ?>
</caption>
<tr>
<th><?= t("Activate") ?></th>
<th><?= t("State") ?></th>
<th><?= t("User name") ?></th>
<th><?= t("Full name") ?></th>
<th><?= t("Email") ?></th>
<th><?= t("Registered") ?></th>
</tr>
<? foreach ($pending as $user): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
<td>
<? if ($user->state != 2): ?>
<?= form::checkbox("activate[]", $user->id) ?>
<? else: ?>
&nbsp;
<? endif ?>
</td>
<td><?= register::format_registration_state($user->state) ?></td>
<td><?= t($user->name) ?></td>
<td><?= t($user->full_name) ?></td>
<td><a href="mailto:<?= t($user->email) ?>"><?= t($user->email) ?></a></td>
<td><?= t(gallery::date_time($user->request_date)) ?></td>
</tr>
<? endforeach ?>
</table>
<?= form::submit(array("id" => "g-registration-activate", "name" => "activate_users", "class" => "submit"), t("Activate selected")) ?>
<?= form::close_fieldset() ?>
<?= form::close() ?>
<fieldset>
<legend><?= t("Pending registrations") ?></legend>
<table>
<caption>
<?= t("To delete an unconfirmed registration, first activate it, then delete it from Users/Groups.") ?>
</caption>
<tr>
<th><?= t("Activate") ?></th>
<th><?= t("State") ?></th>
<th><?= t("User name") ?></th>
<th><?= t("Full name") ?></th>
<th><?= t("Email") ?></th>
<th><?= t("Registered") ?></th>
</tr>
<? foreach ($pending as $user): ?>
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
<td>
<? if ($user->state != 2): ?>
<?= form::checkbox("activate[]", $user->id) ?>
<? else: ?>
&nbsp;
<? endif ?>
</td>
<td><?= register::format_registration_state($user->state) ?></td>
<td><?= t($user->name) ?></td>
<td><?= t($user->full_name) ?></td>
<td><a href="mailto:<?= t($user->email) ?>"><?= t($user->email) ?></a></td>
<td><?= t(gallery::date_time($user->request_date)) ?></td>
</tr>
<? endforeach ?>
</table>
<?= form::submit(array("id" => "g-registration-activate", "name" => "activate_users", "class" => "submit"), t("Activate selected")) ?>
</fieldset>
</form>
</div>
<? endif ?>
</div>

View File

@ -42,7 +42,7 @@ class rescue_task_Core {
$total = $task->get("total");
if (empty($total)) {
$task->set("total", $total = Database::instance()->count_records("items"));
$task->set("total", $total = db::build()->count_records("items"));
$task->set("stack", "1:" . self::LEFT);
$task->set("ptr", 1);
$task->set("completed", 0);
@ -92,7 +92,7 @@ class rescue_task_Core {
$total = $task->get("total");
if (empty($total)) {
$task->set("total", $total = Database::instance()->count_records("items"));
$task->set("total", $total = db::build()->count_records("items"));
$task->set("last_id", 0);
$task->set("completed", 0);
}
@ -101,7 +101,7 @@ class rescue_task_Core {
$completed = $task->get("completed");
foreach (ORM::factory("item")
->where("id >", $last_id)
->where("id", ">", $last_id)
->find_all(100) as $item) {
$item->slug = item::convert_filename_to_slug($item->slug);
$item->save();
@ -120,8 +120,11 @@ class rescue_task_Core {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
Database::instance()
->query("UPDATE {items} SET `relative_path_cache` = NULL, `relative_url_cache` = NULL");
db::build()
->update("items")
->set("relative_path_cache", null)
->set("relative_url_cache", null)
->execute();
} else {
$task->percent_complete = round(100 * $completed / $total);
}
@ -130,19 +133,27 @@ class rescue_task_Core {
}
static function children($parent_id) {
return Database::instance()
return db::build()
->select("id")
->from("items")
->where("parent_id", $parent_id)
->orderby("left_ptr", "ASC")
->get();
->where("parent_id", "=", $parent_id)
->order_by("left_ptr", "ASC")
->execute();
}
static function set_left($id, $value) {
Database::instance()->update("items", array("left_ptr" => $value), array("id" => $id));
db::build()
->update("items")
->set("left_ptr", $value)
->where("id", "=", $id)
->execute();
}
static function set_right($id, $value) {
Database::instance()->update("items", array("right_ptr" => $value), array("id" => $id));
db::build()
->update("items")
->set("right_ptr", $value)
->where("id", "=", $id)
->execute();
}
}

View File

@ -28,21 +28,18 @@ class rwinfo_theme_Core {
// rWatcher Edit: Display Tags
if (module::is_active("tag")) {
$tagsItem = ORM::factory("tag")
$tags = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $item->id)
->where("items_tags.item_id", "=", $item->id)
->find_all();
if (count($tagsItem) > 0) {
if (count($tags) > 0) {
$results .= "<li>";
$results .= t("Tags:") . " ";
for ($counter=0; $counter<count($tagsItem); $counter++) {
if ($counter < count($tagsItem)-1) {
$results .= "<a href=" . url::site("tags/$tagsItem[$counter]") . ">" . html::clean($tagsItem[$counter]->name) . "</a>, ";
} else {
$results .= "<a href=" . url::site("tags/$tagsItem[$counter]") . ">" . html::clean($tagsItem[$counter]->name) . "</a>";
}
$anchors = array();
foreach ($tags as $tag) {
$anchors[] = "<a href=" . url::site("tags/{$tag->id}") . ">" . html::clean($tag->name) . "</a>";
}
$results .= "</li>";
$results .= join(", ", $anchors) . "</li>";
}
}
// rWatcher End Edit

View File

@ -32,24 +32,20 @@
<? endif ?>
<? if (module::is_active("tag")): ?>
<?
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $item->id)
->find_all();
<? $tags = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", "=", $item->id)
->find_all();
?>
<? if (count($tagsItem) > 0): ?>
<li>
<strong class="caption"><?= t("Tags:") ?></strong>
<? for ($counter=0; $counter<count($tagsItem); $counter++) { ?>
<? if ($counter < count($tagsItem)-1) { ?>
<a href="<?= url::site("tags/$tagsItem[$counter]") ?>"><?= html::clean($tagsItem[$counter]->name) ?></a>,
<? } else {?>
<a href="<?= url::site("tags/$tagsItem[$counter]") ?>"><?= html::clean($tagsItem[$counter]->name) ?></a>
<? } ?>
<? } ?>
</li>
<? endif ?>
<? if (count($tags)): ?>
<li>
<strong class="caption"><?= t("Tags:") ?></strong>
<? $not_first = 0; ?>
<? foreach ($tags as $tag): ?>
<?= ($not_first++) ? "," : "" ?>
<a href="<?= url::site("tags/{$tag->name}") ?>"><?= html::clean($tag->name) ?></a>
<? endforeach ?>
</li>
<? endif ?>
<? endif ?>
</ul>

View File

@ -20,12 +20,12 @@
class tagfaces_Controller extends Controller {
public function drawfaces($id) {
// Generate the page that allows the user to draw boxes over a photo.
// Make sure user has access to view and edit the photo.
$item = ORM::factory("item", $id);
access::required("view", $item);
access::required("edit", $item);
// Create the page.
$template = new Theme_View("page.html", "other", "drawfaces");
$template->set_global("item_id", $id);
@ -46,11 +46,11 @@ class tagfaces_Controller extends Controller {
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Convert submitted data to local variables.
$tag_data = Input::instance()->post("facesList");
$item_data = Input::instance()->post("item_id");
// If the user didn't select a tag, display and error and abort.
if (count($tag_data) == 0) {
message::error(t("Please select a tag."));
@ -61,22 +61,22 @@ class tagfaces_Controller extends Controller {
// Delete the face(s) from the database.
foreach ($tag_data as $one_tag) {
ORM::factory("items_face")
->where("id", $one_tag)
->where("id", "=", $one_tag)
->delete_all();
}
// Display a success message.
if (count($tag_data) == 1) {
message::success(t("One face deleted."));
} else {
message::success(count($tag_data) . t(" faces deleted."));
}
}
url::redirect("tagfaces/drawfaces/$item_data");
}
public function saveface() {
// Save the face coordinates to the specified tag.
// Prevent Cross Site Request Forgery
access::verify_csrf();
@ -89,7 +89,7 @@ class tagfaces_Controller extends Controller {
$str_y1 = Input::instance()->post("y");
$str_x2 = Input::instance()->post("x2");
$str_y2 = Input::instance()->post("y2");
// If the user didn't select a face, display an error and abort.
if (($str_x1 == "") || ($str_x2 == "") || ($str_y1 == "") || ($str_y2 == "")) {
message::error(t("Please select a face."));
@ -105,7 +105,7 @@ class tagfaces_Controller extends Controller {
url::redirect("tagfaces/drawfaces/$item_data");
return;
}
// Save a new Note to the database.
$newnote = ORM::factory("items_note");
$newnote->item_id = $item_data;
@ -116,12 +116,12 @@ class tagfaces_Controller extends Controller {
$newnote->title = $str_face_title;
$newnote->description = $str_face_description;
$newnote->save();
} else {
// Check to see if the tag already has a face associated with it.
$existingFace = ORM::factory("items_face")
->where("tag_id", $tag_data)
->where("item_id", $item_data)
->where("tag_id", "=", $tag_data)
->where("item_id", "=", $item_data)
->find_all();
if (count($existingFace) == 0) {
@ -156,7 +156,7 @@ class tagfaces_Controller extends Controller {
// Generate the form that allows the user to select a tag to
// save the face too. Also displays the coordinates of the face
// and the "Save face" button.
// Make a new Form.
$form = new Forge("tagfaces/saveface", "", "post",
array("id" => "g-tag-faces-form"));
@ -164,7 +164,7 @@ class tagfaces_Controller extends Controller {
// Create an array of all the tags for the current item.
$all_tags = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $id)
->where("items_tags.item_id", "=", $id)
->find_all();
// Generate an array of tags to use as checkboxes.
@ -177,18 +177,18 @@ class tagfaces_Controller extends Controller {
// Make a checklist of tags on the form.
$tags_group = $form->group("FaceTag")
->label(t("Select a tag or enter in a title:"));
$tags_group->dropdown('tagsList')
->label(t("Select a tag:"))
->options($array_tags);
$tags_group->input("face_title")
->label(t("Title"));
$tags_description = $form->group("TagsDescription")
->label(t("Description (optional):"));
$tags_description->input("face_description");
// Generate input boxes to hold the coordinates of the face.
$coordinates_group = $form->group("FaceCoordinates")
->label(t("Coordinates:"));
@ -212,21 +212,21 @@ class tagfaces_Controller extends Controller {
private function _get_delfaces_form($id) {
// Generate a form to allow the user to remove face data
// from a photo.
// Make a new Form.
$form = new Forge("tagfaces/delface", "", "post",
array("id" => "g-tag-del-faces-form"));
// Create an array of all the tags that already have faces.
$existing_faces = ORM::factory("items_face")
->where("item_id", $id)
->where("item_id", "=", $id)
->find_all();
// turn the $existing_faces array into an array that can be used
// for a checklist.
$array_faces = "";
foreach ($existing_faces as $oneFace) {
$array_faces[$oneFace->id] = array(ORM::factory("tag",
$array_faces[$oneFace->id] = array(ORM::factory("tag",
$oneFace->tag_id)->name, false);
}
@ -238,7 +238,7 @@ class tagfaces_Controller extends Controller {
->options($array_faces)
->label(t("Select the tag(s) that correspond(s) to the face(s) you wish to delete:"));
}
// Add the id# of the photo and a delete button to the form.
$form->hidden("item_id")->value($id);
$form->submit("DeleteFace")->value(t("Delete face(s)"));

View File

@ -32,15 +32,15 @@ class tagfaces_event_Core {
}
}
static function site_menu($menu, $theme) {
static function site_menu($menu, $theme) {
// Create a menu option for adding face data.
if (!$theme->item()) {
return;
}
$item = $theme->item();
if ($item->is_photo()) {
if ($item->is_photo()) {
if ((access::can("view", $item)) && (access::can("edit", $item))) {
$menu->get("options_menu")
->append(Menu::factory("link")
@ -55,20 +55,20 @@ class tagfaces_event_Core {
static function item_deleted($item) {
// Check for and delete existing Faces and Notes.
$existingFaces = ORM::factory("items_face")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
if (count($existingFaces) > 0) {
ORM::factory("items_face")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->delete_all();
}
$existingNotes = ORM::factory("items_note")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
if (count($existingNotes) > 0) {
ORM::factory("items_note")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->delete_all();
}
}

View File

@ -24,12 +24,12 @@ class tagfaces_theme_Core {
$item = $theme->item;
$existingFaces = ORM::factory("items_face")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
$existingNotes = ORM::factory("items_note")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
// If it does, add an image map to the page to display them.
if ((count($existingFaces) > 0) || (count($existingNotes) > 0)) {
return new View("drawfaces_highlight_block.html");

View File

@ -2,12 +2,12 @@
<?
// Check and see if the current photo has any faces or notes associated with it.
$existingFaces = ORM::factory("items_face")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
$existingNotes = ORM::factory("items_note")
->where("item_id", $item->id)
->where("item_id", "=", $item->id)
->find_all();
// If it does, then insert some javascript and display an image map
// to show where the faces are at.
if ((count($existingFaces) > 0) || (count($existingNotes) > 0)) {
@ -15,15 +15,15 @@
<style>
.transparent30
{
filter:alpha(opacity=30);
-moz-opacity: 0.3;
opacity: 0.3;
filter:alpha(opacity=30);
-moz-opacity: 0.3;
opacity: 0.3;
}
.transparent80
{
filter:alpha(opacity=80);
-moz-opacity: 0.8;
opacity: 0.8;
filter:alpha(opacity=80);
-moz-opacity: 0.8;
opacity: 0.8;
}
</style>
@ -39,7 +39,7 @@
var photodiv = document.getElementById('g-photo');
var photoimg = document.getElementById('<?="g-photo-id-{$item->id}"?>');
var divface = document.getElementById('divsquare');
divface.style.display = 'block';
divface.style.left = (photoimg.offsetLeft + x1) + 'px';
divface.style.top = (photodiv.offsetTop + y1) + 'px';
@ -50,17 +50,17 @@
} else {
divface.onclick = function() {self.location.href = str_url;}
}
divtext.style.display = 'block';
divtext.style.left = divface.style.left;
if (str_description == '') {
divtext.innerText = str_title;
divtext.textContent = str_title;
} else {
divtext.innerHTML = str_title + '<br/>' + str_description;
}
divtext.style.top = (parseInt(divface.style.top.split('p')[0]) + parseInt(divface.style.height.split('p')[0]) + 2) + 'px';
}
@ -69,12 +69,12 @@
document.getElementById('divsquare').style.display = 'none';
document.getElementById('divtagtext').style.display = 'none';
}
// Call setfacemap when the page loads.
window.onload = setfacemap();
</script>
<div id="divtagtext" class="transparent80" style="position:absolute;display:none;border:2px #000000 outset;background-color:#ffffff;font-weight:bold;"></div>
<div id="divtagtext" class="transparent80" style="position:absolute;display:none;border:2px #000000 outset;background-color:#ffffff;font-weight:bold;"></div>
<div id="divsquare" class="transparent30" onMouseOut="hidebox()" style="position:absolute;display:none;border:2px solid #000000;background-color:#ffffff;" onclick="self.location.href = '';"></div>
<map name="faces">

View File

@ -26,10 +26,10 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Generate a form for Google Maps Settings.
$view->content->googlemaps_form = $this->_get_googlemaps_form();
// Generate a list of tags to display.
$query = ORM::factory("tag");
$view->content->tags = $query->orderby("name", "ASC")->find_all();
$view->content->tags = $query->order_by("name", "ASC")->find_all();
// Display the page.
print $view;
@ -37,24 +37,25 @@ class Admin_TagsMap_Controller extends Admin_Controller {
public function edit_gps($tag_id) {
// Generate a new admin page to edit gps data for the tag specified by $tag_id.
// Determine the name of the tag.
$tagName = ORM::factory("tag")
->where("id", $tag_id)
->where("id", "=", $tag_id)
->find_all();
// Set up the admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_tagsmap_edit.html");
$view->content->tagsmapedit_form = $this->_get_tagsgpsedit_form($tag_id);
$view->content->tag_name = $tagName[0]->name;
$view->content->zoom = module::get_var("tagsmap", "googlemap_zoom");
print $view;
}
public function orphaned_tags() {
// Locate and delete any orphaned GPS data.
$int_deleted_records = 0;
// Generate a list of all tags with GPS data.
$existingGPS = ORM::factory("tags_gps")
->find_all();
@ -62,36 +63,36 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Loop through each record and see if a corresponding tag exists.
foreach ($existingGPS as $oneGPS) {
$oneTag = ORM::factory("tag")
->where("id", $oneGPS->tag_id)
->where("id", "=", $oneGPS->tag_id)
->find_all();
// If the tag no longer exists then delete the record.
if (count($oneTag) == 0) {
// Delete the record.
ORM::factory("tags_gps")
->where("tag_id", $oneGPS->tag_id)
->where("tag_id", "=", $oneGPS->tag_id)
->delete_all();
$int_deleted_records++;
}
}
// Redirect back to the main screen and display a "success" message.
message::success($int_deleted_records . t(" Orphaned Record(s) have been deleted."));
url::redirect("admin/tagsmap");
}
public function confirm_delete_gps($tag_id) {
// Make sure the user meant to hit the delete button.
$view = new Admin_View("admin.html");
$view->content = new View("admin_tagsmap_delete.html");
$view->content->tag_id = $tag_id;
// Determine the name of the tag.
$tagName = ORM::factory("tag")
->where("id", $tag_id)
->where("id", "=", $tag_id)
->find_all();
$view->content->tag_name = $tagName[0]->name;
print $view;
}
@ -100,7 +101,7 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Delete the record.
ORM::factory("tags_gps")
->where("tag_id", $tag_id)
->where("tag_id", "=", $tag_id)
->delete_all();
// Redirect back to the main screen and display a "success" message.
@ -120,11 +121,13 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Check and see if this ID already has GPS data, then create
// input boxes to either update it or enter in new information.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag_id)
->where("tag_id", "=", $tag_id)
->find_all();
if (count($existingGPS) == 0) {
$tagsgps_group->input("gps_latitude")->label(t("Latitude"))->value("");
$tagsgps_group->input("gps_longitude")->label(t("Longitude"))->value("");
$tagsgps_group->input("gps_latitude")
->label(t("Latitude"))->value(module::get_var("tagsmap", "googlemap_latitude"));
$tagsgps_group->input("gps_longitude")
->label(t("Longitude"))->value(module::get_var("tagsmap", "googlemap_longitude"));
$tagsgps_group->textarea("gps_description")->label(t("Description"))->value("");
} else {
$tagsgps_group->input("gps_latitude")->label(t("Latitude"))->value($existingGPS[0]->latitude);
@ -151,11 +154,11 @@ class Admin_TagsMap_Controller extends Admin_Controller {
$str_longitude = Input::instance()->post("gps_longitude");
$str_description = Input::instance()->post("gps_description");
// Save to database.
// Save to database.
// Check and see if this ID already has GPS data,
// Update it if it does, create a new record if it doesn't.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $str_tagid)
->where("tag_id", "=", $str_tagid)
->find_all();
if (count($existingGPS) == 0) {
$newgps = ORM::factory("tags_gps");
@ -172,7 +175,7 @@ class Admin_TagsMap_Controller extends Admin_Controller {
$updatedGPS->description = $str_description;
$updatedGPS->save();
}
// Redirect back to the main screen and display a "success" message.
message::success(t("Your Settings Have Been Saved."));
url::redirect("admin/tagsmap");
@ -186,53 +189,62 @@ class Admin_TagsMap_Controller extends Admin_Controller {
// Input box for the Maps API Key
$googlemap_group = $form->group("GoogleMapsKey");
$googlemap_group->input("google_api_key")
->label(t("Google Maps API Key"))
->value(module::get_var("tagsmap", "googlemap_api_key"));
->label(t("Google Maps API Key"))
->value(module::get_var("tagsmap", "googlemap_api_key"))
->rules("required");
// Input boxes for the Maps starting location map type and zoom.
$startingmap_group = $form->group("GoogleMapsPos");
$startingmap_group->input("google_starting_latitude")
->label(t("Starting Latitude"))
->value(module::get_var("tagsmap", "googlemap_latitude"));
->label(t("Starting Latitude"))
->value(module::get_var("tagsmap", "googlemap_latitude"))
->rules("required");
$startingmap_group->input("google_starting_longitude")
->label(t("Starting Longitude"))
->value(module::get_var("tagsmap", "googlemap_longitude"));
->label(t("Starting Longitude"))
->value(module::get_var("tagsmap", "googlemap_longitude"))
->rules("required");
$startingmap_group->input("google_default_zoom")
->label(t("Default Zoom Level"))
->value(module::get_var("tagsmap", "googlemap_zoom"));
$startingmap_group->input("google_default_type")
->label(t("Default Map Type") . " (G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_3D_MAP)")
->value(module::get_var("tagsmap", "googlemap_type"));
->label(t("Default Zoom Level"))
->value(module::get_var("tagsmap", "googlemap_zoom"))
->rules("required");
$startingmap_group->dropdown("google_default_type")
->label(t("Default Map Type"))
->options(
array("G_NORMAL_MAP", "G_SATELLITE_MAP", "G_HYBRID_MAP",
"G_PHYSICAL_MAP", "G_SATELLITE_3D_MAP"));
// Add a save button to the form.
$form->submit("SaveSettings")->value(t("Save"));
// Return the newly generated form.
return $form;
}
public function savemapprefs() {
// Save information associated with Google Maps to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Figure out the values of the text boxes
$str_googlekey = Input::instance()->post("google_api_key");
$str_googlelatitude = Input::instance()->post("google_starting_latitude");
$str_googlelongitude = Input::instance()->post("google_starting_longitude");
$str_googlezoom = Input::instance()->post("google_default_zoom");
$str_googlemaptype = Input::instance()->post("google_default_type");
// Save Settings.
module::set_var("tagsmap", "googlemap_api_key", $str_googlekey);
module::set_var("tagsmap", "googlemap_latitude", $str_googlelatitude);
module::set_var("tagsmap", "googlemap_longitude", $str_googlelongitude);
module::set_var("tagsmap", "googlemap_zoom", $str_googlezoom);
module::set_var("tagsmap", "googlemap_type", $str_googlemaptype);
$form = $this->_get_googlemaps_form();
if ($form->validate()) {
Kohana_Log::add("error",print_r($form,1));
module::set_var("tagsmap", "googlemap_api_key", $form->GoogleMapsKey->google_api_key->value);
module::set_var("tagsmap", "googlemap_latitude", $form->GoogleMapsPos->google_starting_latitude->value);
module::set_var("tagsmap", "googlemap_longitude", $form->GoogleMapsPos->google_starting_longitude->value);
module::set_var("tagsmap", "googlemap_zoom", $form->GoogleMapsPos->google_default_zoom->value);
module::set_var("tagsmap", "googlemap_type", $form->GoogleMapsPos->google_default_type->value);
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your Settings Have Been Saved."));
url::redirect("admin/tagsmap");
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your settings have been saved."));
url::redirect("admin/tagsmap");
}
// Else show the page with errors
$view = new Admin_View("admin.html");
$view->content = new View("admin_tagsmap.html");
$view->content->googlemaps_form = $form;
$view->content->tags = ORM::factory("tag")->order_by("name", "ASC")->find_all();
print $view;
}
}

View File

@ -31,8 +31,12 @@ class tagsmap_installer {
KEY(`tag_id`, `id`))
DEFAULT CHARSET=utf8;");
// Set the module's version number.
module::set_version("tagsmap", 1);
// Set the default to Australia (homage to rWatcher)
module::set_var("tagsmap", "googlemap_latitude", -26.11);
module::set_var("tagsmap", "googlemap_longitude", 134);
module::set_var("tagsmap", "googlemap_zoom", 5);
module::set_var("tagsmap", "googlemap_type", "G_NORMAL_MAP");
module::set_version("tagsmap", 2);
}
static function deactivate() {

View File

@ -1,3 +1,3 @@
name = "TagsMap"
description = "Assign GPS coordinates to existing tags and display them on a map."
version = 1
version = 2

View File

@ -50,7 +50,7 @@
<?
// Check and see if this ID already has GPS data, display a delete button if it does.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag->id)
->where("tag_id", "=", $tag->id)
->find_all();
if (count($existingGPS) > 0) {
?>
@ -69,7 +69,7 @@
</table>
</div>
<div class="g-block">
<div class="g-block">
<h3>
<?= t("Remove Orphaned GPS Data") ?>
</h3>

View File

@ -10,10 +10,10 @@
<script src="http://www.google.com/jsapi?key=<?= module::get_var("tagsmap", "googlemap_api_key") ?>" type="text/javascript"></script>
<script type="text/javascript">
<script type="text/javascript">
google.load("maps", "2.160");
var lat = document.getElementById("gps_latitude").value;
var lon = document.getElementById("gps_longitude").value;
var lat = $("input[name=gps_latitude]");
var lon = $("input[name=gps_longitude]");
var map;
@ -23,36 +23,36 @@
map.addMapType(G_PHYSICAL_MAP);
map.setMapType(G_PHYSICAL_MAP);
map.enableScrollWheelZoom();
map.setCenter(new GLatLng(<?=module::get_var("tagsmap", "googlemap_latitude"); ?>, <?=module::get_var("tagsmap", "googlemap_longitude"); ?>));
map.setZoom(<?=module::get_var("tagsmap", "googlemap_zoom"); ?>);
map.addControl(new GSmallMapControl()); // affiche le curseur de zoom
map.addControl(new GMapTypeControl()); // affiche le curseur de déplacement
map.addControl(new GScaleControl()); // affiche lechelle
map.setCenter(new GLatLng(lat.attr("value"), lon.attr("value")));
map.setZoom(<?=$zoom ?>);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
GEvent.addListener(map,"dblclick",function(overlay, latlng) {
document.getElementById("gps_longitude").value = latlng.x;
document.getElementById("gps_latitude").value = latlng.y;
lon.attr("value", latlng.x);
lat.attr("value", latlng.y);
var markeri = new GMarker(latlng, {draggable: true});
map.addOverlay(markeri);
GEvent.addListener(markeri, "dragend", function(point){
document.getElementById("gps_longitude").value = point.x;
document.getElementById("gps_latitude").value = point.y;
lon.attr("value", point.x);
lat.attr("value", point.y);
});
});
}
if (lon != '' && lat != ''){
var point = new GLatLng(lat,lon);
map.setCenter(point, 8);
if (lon.attr("value") && lat.attr("value")){
var point = new GLatLng(lat.attr("value"), lon.attr("value"));
map.setCenter(point, 4);
var marker = new GMarker(point, {draggable: true});
map.addOverlay(marker);
GEvent.addListener(marker, "dragend", function(point){
document.getElementById("gps_longitude").value = point.x;
document.getElementById("gps_latitude").value = point.y;
lon.attr("value", point.x);
lat.attr("value", point.y);
});
}
}
google.setOnLoadCallback(Gload);
</script>

View File

@ -25,8 +25,8 @@ class user_homes_event_Core {
* is refreshed after logging in the direction can occur.
*/
static function user_login($user) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
if ($home->loaded && $home->home != 0) {
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
if ($home->loaded() && $home->home != 0) {
Session::instance()->set("redirect_home", $home->home);
}
}
@ -52,7 +52,7 @@ class user_homes_event_Core {
*/
static function user_before_delete($user) {
ORM::factory("user_home")
->where("id", $user->id)
->where("id", "=", $user->id)
->delete_all();
}
@ -70,7 +70,7 @@ class user_homes_event_Core {
* Called after a user has been added
*/
static function user_add_form_admin_completed($user, $form) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
$home->id = $user->id;
$home->home = $form->add_user->user_home->value;
$home->save();
@ -80,8 +80,8 @@ class user_homes_event_Core {
* Called when admin is editing a user
*/
static function user_edit_form_admin($user, $form) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
if ($home->loaded) {
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
if ($home->loaded()) {
$selected = $home->home;
} else {
$selected = 0;
@ -96,7 +96,7 @@ class user_homes_event_Core {
* Called after a user had been edited by the admin
*/
static function user_edit_form_admin_completed($user, $form) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
$home->id = $user->id;
$home->home = $form->edit_user->user_home->value;
$home->save();
@ -107,9 +107,9 @@ class user_homes_event_Core {
* Called when user is editing their own form
*/
static function user_edit_form($user, $form) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
if ($home->loaded) {
if ($home->loaded()) {
$selected = $home->home;
} else {
$selected = 0;
@ -125,7 +125,7 @@ class user_homes_event_Core {
* Called after a user had been edited by the user
*/
static function user_edit_form_completed($user, $form) {
$home = ORM::factory("user_home")->where("id", $user->id)->find();
$home = ORM::factory("user_home")->where("id", "=", $user->id)->find();
$home->id = $user->id;
$home->home = $form->edit_user->user_home->value;
$home->save();
@ -152,8 +152,9 @@ class user_homes_event_Core {
}
$albums = ORM::factory("item")
->where(array("parent_id" => $parent->id, "type" => "album"))
->orderby(array("title" => "ASC"))
->where("parent_id", "=", $parent->id)
->where("type", "=", "album")
->order_by("title", "ASC")
->find_all();
foreach ($albums as $album) {
self::tree($album, "-$dashes", $array);

View File

@ -30,8 +30,10 @@ class videodimensions_event_Core {
static function item_edit_form_completed($item, $form) {
// Save the new height and width to the database.
$item->height = $form->edit_item->vidheight->value;
$item->width = $form->edit_item->vidwidth->value;
$item->save();
if ($item->is_movie()) {
$item->height = $form->edit_item->vidheight->value;
$item->width = $form->edit_item->vidwidth->value;
$item->save();
}
}
}

View File

@ -25,7 +25,10 @@ class exif_event_Core {
}
static function item_deleted($item) {
Database::instance()->delete("exif_records", array("item_id" => $item->id));
db::build()
->delete("exif_records")
->where("item_id", "=", $item->id)
->execute();
}
static function photo_menu($menu, $theme) {

View File

@ -114,6 +114,7 @@
<ul id="g-viewformat">
<? if (($sidebarallowed == "left") or ($sidebarallowed == "any")): ?>
<? $iscurrent = ($sidebarvisible == "left"); ?>
<? $url = "" ?>
<li><?= ($iscurrent) ? null : '<a title="Sidebar Left" href="' . $url . '?sb=left">'; ?><span class="g-viewthumb-left <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">Sidebar Left</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? endif ?>
<? if ($sidebarallowed == "any"): ?>

View File

@ -23,9 +23,9 @@ class Three_Nids_Controller extends Controller {
access::required("view", $item);
$comments = ORM::factory("comment")
->where("item_id", $item->id)
->where("state", "published")
->orderby("created", "ASC")
->where("item_id", "=", $item->id)
->where("state", "=", "published")
->order_by("created", "ASC")
->find_all();
$v = new Theme_View("comments.html", "other", "comment-fragment");

View File

@ -116,9 +116,9 @@ class three_nids_Core {
access::required("view", $item);
return ORM::factory("comment")
->where("item_id", $item->id)
->where("state", "published")
->orderby("created", "DESC")
->where("item_id", "=", $item->id)
->where("state", "=", "published")
->order_by("created", "DESC")
->count_all();
}
}