1
0

Merge commit 'upstream/master'

This commit is contained in:
Romain LE DISEZ 2010-01-24 23:25:27 +01:00
commit fbf635b099
254 changed files with 28856 additions and 774 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

@ -48,13 +48,15 @@ class Admin_ContactOwner_Controller extends Admin_Controller {
$str_contactbutton = Input::instance()->post("owner_button_text");
$str_contactemail = Input::instance()->post("owner_email");
$str_contactname = Input::instance()->post("owner_name");
$str_messageheader = Input::instance()->post("message_header");
// Save Settings.
module::set_var("contactowner", "contact_owner_link", $ownerLink);
module::set_var("contactowner", "contact_user_link", $userLink);
module::set_var("contactowner", "contact_button_text", $str_contactbutton);
module::set_var("contactowner", "contact_owner_email", $str_contactemail );
module::set_var("contactowner", "contact_owner_name", $str_contactname );
module::set_var("contactowner", "contact_owner_email", $str_contactemail);
module::set_var("contactowner", "contact_owner_name", $str_contactname);
module::set_var("contactowner", "contact_owner_header", $str_messageheader);
message::success(t("Your Settings Have Been Saved."));
// Load Admin page.
@ -86,9 +88,12 @@ class Admin_ContactOwner_Controller extends Admin_Controller {
$add_contacts->input("owner_button_text")->label(t("Contact Owner Link Text"))->value(module::get_var("contactowner", "contact_button_text"));
$add_contacts->input("owner_email")->label(t("Owner Email Address"))->value(module::get_var("contactowner", "contact_owner_email"));
$add_contacts->input("owner_name")->label(t("Owner Name"))->value(module::get_var("contactowner", "contact_owner_name"));
$message_prefs = $form->group("messagePrefs");
$message_prefs->input("message_header")->label(t("Email Message Header"))->value(module::get_var("contactowner", "contact_owner_header"));
// Add a save button to the form.
$add_contacts->submit("SaveSettings")->value(t("Save"));
$form->submit("SaveSettings")->value(t("Save"));
// Return the newly generated form.
return $form;

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,47 +84,71 @@ 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;
// 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
// 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)
->find_all();
$str_emailto = $userDetails[0]->email;
// Make sure the form was submitted.
if ($_POST) {
// Set up some rules to validate the form against.
$post = new Validation($_POST);
$post->add_rules('email_from', 'required', 'valid::email');
$post->add_rules('email_subject', 'required');
$post->add_rules('email_body', 'required');
// If the form was filled out properly then...
if ($post->validate()) {
// Copy the data from the email form 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.
// Also add in the admin-defined message header.
$str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
// 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
// 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)
->find_all();
$str_emailto = $userDetails[0]->email;
}
// Send the email message.
Sendmail::factory()
->to($str_emailto)
->subject($str_emailsubject)
->header("Mime-Version", "1.0")
->header("Content-type", "text/html; charset=utf-8")
->message($str_emailbody)
->send();
// Display a message telling the visitor that their email has been sent.
$template = new Theme_View("page.html", "other", "Contact");
$template->content = new View("contactowner_emailform.html");
$template->content->sendmail_form = t("Your Message Has Been Sent.");
print $template;
} else {
// Display a message telling the visitor that their email has been not been sent,
// along with the reason(s) why.
$template = new Theme_View("page.html", "other", "Contact");
$template->content = new View("contactowner_emailform.html");
$template->content->sendmail_form = t("Your Message Has Not Been Sent.");
$template->content->sendmail_form = $template->content->sendmail_form . "<br/><br/>" . t("Reason(s):") . "<br/>";
foreach($post->errors('form_error_messages') as $error) {
$template->content->sendmail_form = $template->content->sendmail_form . " - " . t($error) . "<br/>";
}
print $template;
}
}
// Send the email message.
Sendmail::factory()
->to($str_emailto)
->subject($str_emailsubject)
->header("Mime-Version", "1.0")
->header("Content-type", "text/html; charset=utf-8")
->message($str_emailbody)
->send();
// Display a message telling the visitor that their email has been sent.
$template = new Theme_View("page.html", "other", "Contact");
$template->content = new View("contactowner_emailform.html");
$template->content->sendmail_form = t("Your Message Has Been Sent.");
print $template;
}
}
}

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

@ -0,0 +1,35 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class contactowner_installer {
static function install() {
// Set some default values
module::set_var("contactowner", "contact_owner_link", false);
module::set_var("contactowner", "contact_user_link", true);
module::set_var("contactowner", "contact_button_text", "Email The Webmaster");
module::set_var("contactowner", "contact_owner_name", "Webmaster");
module::set_var("contactowner", "contact_owner_header", "You have received a message through your website:");
module::set_version("contactowner", 2);
}
static function uninstall() {
module::delete("contactowner");
}
}

View File

@ -1,3 +1,3 @@
name = "ContactOwner"
description = "Allows visitors to send the website owner an email."
version = 1
version = 2

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="<?= $tag->url() ?>"><?= html::clean($tag->name) ?></a>
<? endforeach ?>
</div>

View File

@ -33,13 +33,9 @@ class Admin_DownloadFullsize_Controller extends Admin_Controller {
// Figure out which boxes where checked
$dlLinks_array = Input::instance()->post("DownloadLinkOptions");
$tButton = false;
$fButton = false;
$download_original_button = false;
for ($i = 0; $i < count($dlLinks_array); $i++) {
if ($dlLinks_array[$i] == "tButton") {
$tButton = true;
}
if ($dlLinks_array[$i] == "fButton") {
$fButton = true;
}
@ -56,7 +52,6 @@ class Admin_DownloadFullsize_Controller extends Admin_Controller {
}
// Save Settings.
module::set_var("downloadfullsize", "tButton", $tButton);
module::set_var("downloadfullsize", "fButton", $fButton);
message::success(t("Your Selection Has Been Saved."));
@ -74,8 +69,7 @@ class Admin_DownloadFullsize_Controller extends Admin_Controller {
array("id" => "g-download-fullsize-adminForm"));
// Make an array for the different types of download links.
$linkOptions["fButton"] = array(t("Show Floppy Disk Link"), module::get_var("downloadfullsize", "fButton"));
$linkOptions["tButton"] = array(t("Show Text Download Text Link"), module::get_var("downloadfullsize", "tButton"));
$linkOptions["fButton"] = array(t("Show Floppy Disk Picture Link"), module::get_var("downloadfullsize", "fButton"));
// Setup a few checkboxes on the form.
$add_links = $form->group("DownloadLinks");

View File

@ -0,0 +1,51 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class downloadfullsize_block_Core {
static function get_site_list() {
return array("downloadfullsize" => t("Download Item"));
}
static function get($block_id, $theme) {
$item = $theme->item;
switch ($block_id) {
case "downloadfullsize":
// If Item is movie then...
if ($item && $item->is_movie() && access::can("view_full", $item)) {
$block = new Block();
$block->css_id = "g-download-fullsize";
$block->title = t("Download Movie");
$block->content = new View("downloadfullsize_block.html");
return $block;
}
// If Item is photo then...
if ($item && $item->is_photo() && access::can("view_full", $item)) {
$block = new Block();
$block->css_id = "g-download-fullsize";
$block->title = t("Download Photo");
$block->content = new View("downloadfullsize_block.html");
return $block;
}
}
return "";
}
}

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

@ -23,33 +23,4 @@ class downloadfullsize_theme {
$theme->css("downloadfullsize_menu.css");
}
}
static function sidebar_blocks($theme) {
$item = $theme->item();
if ($item && $item->is_movie() && access::can("view_full", $item)) {
if (module::get_var("downloadfullsize", "tButton")) {
$block = new Block();
$block->css_id = "g-download-fullsize";
$block->title = t("Download");
$block->content = new View("downloadfullsize_block.html");
$block->content->item = ORM::factory("item", 1);
return $block;
}
}
if ($item && $item->is_photo() && access::can("view_full", $item)) {
if (module::get_var("downloadfullsize", "tButton")) {
$block = new Block();
$block->css_id = "g-download-fullsize";
$block->title = t("Download");
$block->content = new View("downloadfullsize_block.html");
$block->content->item = ORM::factory("item", 1);
return $block;
}
}
}
}

View File

@ -2,7 +2,7 @@
<? if ($theme->item->is_photo()) { ?>
<div class="g-download-fullsize-block">
<a href="<?= url::site("downloadfullsize/send/$theme->item") ?>"
<a href="<?= url::site("downloadfullsize/send/{$theme->item->id}") ?>"
title="<?= t("Download Photo") ?>"
class="g-button ui-icon-left ui-state-default ui-corner-all"><?= t("Download Fullsize Image") ?></a>
</div>
@ -10,9 +10,9 @@
<? if ($theme->item->is_movie()) { ?>
<div class="g-download-fullsize-block">
<a href="<?= url::site("downloadfullsize/send/$theme->item") ?>"
<a href="<?= url::site("downloadfullsize/send/{$theme->item->id}") ?>"
title="<?= t("Download Video") ?>"
class="g-button ui-icon-left ui-state-default ui-corner-all"><?= t("Download Video") ?></a>
class="g-button ui-icon-left ui-state-default ui-corner-all"><?= t("Download Movie") ?></a>
</div>
<? } ?>

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

@ -0,0 +1,47 @@
<?php defined("SYSPATH") or die("No direct script access.");/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class 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;
}
}
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

@ -34,7 +34,7 @@ class Json_Album_Controller extends Controller {
$item = ORM::factory("item", $item_id);
access::required("view", $item);
$children = $item->children(null, 0, $where);
$children = $item->children(null, null, $where);
$encoded = array();
foreach ($children as $id => $child){
$encoded[$id] = self::child_json_encode($child);
@ -44,7 +44,7 @@ class Json_Album_Controller extends Controller {
}
function is_admin() {
if (user::active()->admin) {
if (identity::active_user()->admin) {
print json_encode(array("result" => "success", "csrf" => access::csrf_token()));
return;
}
@ -54,7 +54,7 @@ class Json_Album_Controller extends Controller {
function albums($item_id) {
print $this->child_elements($item_id,array("type" => "album"));
print $this->child_elements($item_id, array(array("type", "=", "album")));
}
function children($item_id){
@ -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

@ -18,15 +18,19 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class ldap_installer {
static function install() {
module::set_version("ldap", 1);
$root = item::root();
$ldap_provider = new IdentityProvider("ldap");
foreach ($ldap_provider->groups() as $group) {
module::event("group_created", $group);
access::allow($group, "view", $root);
access::allow($group, "view_full", $root);
static function can_activate() {
$messages = array();
if (array_search("ldap", get_loaded_extensions()) === false) {
$messages["error"][] =
t("Cannot install LDAP identity provider as the PHP LDAP extension module is not enabled.");
} else {
$messages["warn"][] = IdentityProvider::confirmation_message();
}
return $messages;
}
static function install() {
IdentityProvider::change_provider("ldap");
}
static function uninstall() {
@ -36,4 +40,14 @@ class ldap_installer {
module::event("group_deleted", $group);
}
}
static function initialize() {
module::set_version("ldap", 1);
$root = item::root();
foreach (IdentityProvider::instance()->groups() as $group) {
module::event("group_created", $group);
access::allow($group, "view", $root);
access::allow($group, "view_full", $root);
}
}
}

View File

@ -239,9 +239,6 @@ class Ldap_User implements User_Definition {
case "id":
return $this->ldap_entry["uidnumber"][0];
case "groups":
return IdentityProvider_Ldap_Driver::groups_for($this);
case "locale": // @todo
return null;
@ -266,6 +263,10 @@ class Ldap_User implements User_Definition {
}
}
public function groups() {
return IdentityProvider_Ldap_Driver::groups_for($this);
}
public function avatar_url($size=80, $default=null) {
return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s",
md5($this->email), $size, $default ? "&d=" . urlencode($default) : "");

View File

@ -1,6 +1,3 @@
name = "LDAP"
description = "Use LDAP for authentication"
version = 1
; Don't show this module on the module administration screen
no_module_admin = 1

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");
@ -32,6 +32,9 @@ class Admin_register_Controller extends Admin_Controller {
access::verify_csrf();
$post = new Validation($_POST);
$post->add_rules("policy", "required");
$post->add_rules("group", array($this, "passthru"));
$post->add_rules("email_verification", array($this, "passthru"));
$group_list = array();
if ($post->validate()) {
module::set_var("registration", "policy", $post->policy);
@ -49,11 +52,18 @@ class Admin_register_Controller extends Admin_Controller {
}
}
// We need this validation callback in order to have the optional fields copied to
// validation array.
public function passthru($field) {
return true;
}
public function activate() {
access::verify_csrf();
$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 +76,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 +115,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

@ -37,13 +37,13 @@ class register_Controller extends Controller {
$policy = module::get_var("registration", "policy");
if ($policy == "visitor") {
if ($pending_user->state == 1) {
Session::instance()->set("registration_first_usage");
$user = register::create_new_user($pending_user->id);
Session::instance()->set("registration_first_usage");
auth::login($user);
Session::instance()->set("registration_first_usage", true);
$pending_user->delete();
} else {
register::send_confirmation($pending_user);
$user = register::create_new_user($pending_user->id, true);
message::success(t("A confirmation email has been sent to your email address."));
}
} else if ($pending_user->state == 1) {
@ -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

@ -21,8 +21,13 @@ class register_Core {
private static $_states;
static function format_registration_state($state) {
if (empty(self::$_state)) {
self::$_states = array(t("Unconfirmed"), t("Confirmed"), t("Activated"));
if (empty(self::$_states)) {
$policy = module::get_var("registration", "policy");
$email_verification = module::get_var("registration", "email_verification");
$pending = $policy == "admin_only" || ($policy == "admin_approval" && !$email_verification);
self::$_states = array(t("Unconfirmed"),
$pending ? t("Pending") : t("Confirmed"),
t("Activated"));
}
return self::$_states[$state];
}
@ -32,15 +37,16 @@ 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) {
static function send_user_created_confirmation($user, $requires_first=false) {
$message = new View("register_welcome.html");
$message->user = $user;
$message->site_url = url::abs_site("register/first/{$user->hash}");
$message->site_url = $requires_first ? url::abs_site("register/first/{$user->hash}") :
url::abs_site("");
self::_sendemail($user->email, t("Your userid has been created"), $message);
}

View File

@ -27,7 +27,7 @@ class register_event {
static function user_menu($menu, $theme) {
$user = identity::active_user();
if ($theme->page_subtype != "login" && $user->guest) {
if ($user->guest) {
$menu->append(Menu::factory("dialog")
->id("user_menu_register")
->css_id("g-register-menu")

View File

@ -14,69 +14,71 @@
<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>
<? else: ?>
<?= form::hidden("group", $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

@ -16,24 +16,17 @@
* 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 sso_event {
static function gallery_ready() {
$sso_username = Input::instance()->server("REMOTE_USER");
$user = Session::instance()->get("user");
if (empty($user) || $user->name != $sso_username) {
try {
identity::set_active_user(identity::lookup_user_by_name($sso_username));
} catch (Exception $e) {
Kohana_Log::add("error", "Couldn't authenticate as $sso_username: " .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
}
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 "";
}
}

3
modules/sso/module.info Normal file
View File

@ -0,0 +1,3 @@
name = "SSO"
description = "Support single-signon authentication"
version = 1

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();
@ -85,11 +85,11 @@ class tagfaces_Controller extends Controller {
$str_face_title = str_replace("'", "\'", Input::instance()->post("face_title"));
$str_face_description = str_replace("'", "\'", Input::instance()->post("face_description"));
$item_data = Input::instance()->post("item_id");
$str_x1 = Input::instance()->post("x");
$str_y1 = Input::instance()->post("y");
$str_x1 = Input::instance()->post("x1");
$str_y1 = Input::instance()->post("y1");
$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,28 +177,32 @@ 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:"));
$coordinates_group->input("x")
$coordinates_group->input("x1")
->id('x1')
->label(t("X1"));
$coordinates_group->input("y")
$coordinates_group->input("y1")
->id('y1')
->label(t("Y1"));
$coordinates_group->input("x2")
->id('x2')
->label(t("X2"));
$coordinates_group->input("y2")
->id('y2')
->label(t("Y2"));
// Add the id# of the photo and a save button to the form.
@ -212,21 +216,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 +242,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

@ -53,8 +53,8 @@
// Our simple event handler, called from onChange and onSelect
// event handlers, as per the Jcrop invocation above
function showCoords(c) {
jQuery('#x').val(c.x);
jQuery('#y').val(c.y);
jQuery('#x1').val(c.x);
jQuery('#y1').val(c.y);
jQuery('#x2').val(c.x2);
jQuery('#y2').val(c.y2);
};
@ -87,10 +87,10 @@
#face_description {
width: 400px;
}
#x {
#x1 {
width: 40px;
}
#y {
#y1 {
width: 40px;
}
#x2 {
@ -108,7 +108,7 @@ li {
</style>
<div id="g-coordinates">
<?= $form ?>
<?=$form ?>
</div>
<br/><br/><br/>
@ -121,6 +121,12 @@ li {
</div>
</fieldset>
<br/>
<div id="g-exit-faces">

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">
@ -83,7 +83,7 @@
foreach ($existingFaces as $oneFace) {
$oneTag = ORM::factory("tag", $oneFace->tag_id)
?>
<area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=url::site("tags/$oneFace->tag_id") ?>" title="<?=html::clean($oneTag->name); ?>" alt="<?=$oneTag->name; ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=html::clean($oneTag->name); ?>', '<?=html::clean($oneFace->description); ?>', '<?=url::site("tags/$oneFace->tag_id") ?>')" />
<area shape="rect" coords="<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>" href="<?=$oneTag->url() ?>" title="<?=html::clean($oneTag->name); ?>" alt="<?=$oneTag->name; ?>" onMouseOver="highlightbox(<?=$oneFace->x1 ?>,<?=$oneFace->y1 ?>,<?=$oneFace->x2 ?>,<?=$oneFace->y2 ?>,'<?=html::clean($oneTag->name); ?>', '<?=html::clean($oneFace->description); ?>', '<?=$oneTag->url() ?>')" />
<? } ?>
<?

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

@ -0,0 +1,146 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Theme_Options_Controller extends Admin_Controller {
static function get_edit_form_admin() {
$form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form"));
$group = $form->group("requirements")->label("Prerequisites checklist");
$group->checkbox("shadowbox")->label(t("Shadowbox module"))
->checked((module::is_active("shadowbox")))->disabled(true);
$file = THEMEPATH . "greydragon/theme.info";
$theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
$group = $form->group("edit_theme")->label(t("Grey Dragon Theme") . " - " . t("v.") . $theme_info->version);
$group->input("row_count")->label(t("Rows per album page"))->id("g-page-size")
->rules("required|valid_digit")
->value(module::get_var("gallery", "page_size") / 3);
$group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("g-resize-size")
->rules("required|valid_digit")
->value(module::get_var("gallery", "resize_size"));
$group->checkbox("build_resize")->label(t("Mark to build all resizes (from Maintenace page)"))->id("g-build-resize")->value(false);
$group->checkbox("build_thumbs")->label(t("Mark to build all thumbnails (200x200) (from Maintenace page)"))->id("g-build-thumb")->value(false);
$group->checkbox("photonav_top")->label(t("Show top photo navigator"))
->checked(module::get_var("th_greydragon", "photonav_top"));
$group->checkbox("photonav_bottom")->label(t("Show bottom photo navigator"))
->checked(module::get_var("th_greydragon", "photonav_bottom"));
$group->dropdown("sidebar_allowed")->label(t("Allowed SideBar Positions"))
->options(array("any" => t("Any"), "left" => t("Left"), "right" => t("Right"), "none" => t("None")))
->selected(module::get_var("th_greydragon", "sidebar_allowed"));
$group->dropdown("sidebar_visible")->label(t("Default SideBar Position"))
->options(array("right" => t("Right"), "left" => t("Left"), "none" => t("None")))
->selected(module::get_var("th_greydragon", "sidebar_visible"));
$group->input("header_text")->label(t("Header text"))->id("g-header-text")
->value(module::get_var("gallery", "header_text"));
$group->input("footer_text")->label(t("Footer text"))->id("g-footer-text")
->value(module::get_var("gallery", "footer_text"));
$group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text")
->checked(module::get_var("gallery", "show_credits"));
$group->input("copyright")->label(t("Copyright message to display on footer"))->id("g-theme-copyright")
->value(module::get_var("th_greydragon", "copyright"));
$group->input("logo_path")->label(t("URL or path to alternate logo image"))->id("g-site-logo")
->value(module::get_var("th_greydragon", "logo_path"));
module::event("theme_edit_form", $form);
$group = $form->group("buttons");
$group->submit("")->value(t("Save"));
return $form;
}
public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_theme_options.html");
$view->content->form = self::get_edit_form_admin();
print $view;
}
public function save() {
access::verify_csrf();
$form = self::get_edit_form_admin();
if ($form->validate()) {
$edit_theme = $form->edit_theme;
module::set_var("gallery", "page_size", $edit_theme->row_count->value * 3);
$resize_size = $edit_theme->resize_size->value;
$thumb_size = 200;
$build_resize = $edit_theme->build_resize->value;
$build_thumbs = $edit_theme->build_thumbs->value;
if (module::get_var("gallery", "resize_size") != $resize_size) {
module::set_var("gallery", "resize_size", $resize_size);
$build_resize = true;
}
if (module::get_var("gallery", "thumb_size") != $thumb_size) {
module::set_var("gallery", "thumb_size", $thumb_size);
}
if ($build_resize) {
graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
graphics::add_rule("gallery", "resize", "gallery_graphics::resize",
array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
}
if ($build_thumbs) {
graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
graphics::add_rule("gallery", "thumb", "gallery_graphics::resize",
array("width" => 200, "height" => 200, "master" => Image::AUTO), 100);
}
module::set_var("th_greydragon", "photonav_top", $edit_theme->photonav_top->value);
module::set_var("th_greydragon", "photonav_bottom", $edit_theme->photonav_bottom->value);
$sidebar_allowed = $edit_theme->sidebar_allowed->value;
$sidebar_visible = $edit_theme->sidebar_visible->value;
if ($sidebar_allowed == "none") { $sidebar_visible = "none"; }
if ($sidebar_allowed == "right") { $sidebar_visible = "right"; }
if ($sidebar_allowed == "left") { $sidebar_visible = "left"; }
module::set_var("th_greydragon", "sidebar_allowed", $sidebar_allowed);
module::set_var("th_greydragon", "sidebar_visible", $sidebar_visible);
module::set_var("gallery", "header_text", $edit_theme->header_text->value);
module::set_var("gallery", "footer_text", $edit_theme->footer_text->value);
module::set_var("gallery", "show_credits", $edit_theme->show_credits->value);
module::set_var("th_greydragon", "copyright", $edit_theme->copyright->value);
module::set_var("th_greydragon", "logo_path", $edit_theme->logo_path->value);
module::event("theme_edit_form_completed", $form);
message::success(t("Updated theme details"));
url::redirect("admin/theme_options");
} else {
$view = new Admin_View("admin.html");
$view->content = $form;
print $view;
}
}
}

View File

@ -1,5 +1,18 @@
Grey Dragon Theme Changelog
version 1.5.8
- Finally admin module for theme is there. After theme installation, visit Appearance/Theme Options to configure the theme.
If you had older version of the theme, initial setup is also required.
The following settings are available:
- Rows per album page - theme uses 3 columns layout for pictures, therefore default page_size is computed in x3 increments
- Thumb size is restricted to 200 and therefore not available for administration
- Mark to build resizes/thumbs - allows force rebuilding of images
- Show/Hide top/bottom photo navigators
- Specify allowed and default sidebar position
- Administrator can now specify Copyright message to display in the footer
- Site logo is now default to Gallery 3 logo, but admin can provide a path to custom logo.
- Sidebar session cookie is set to expire in 365 days
version 1.5.7
- Status message has been moved into header as popup to prevent obstruction of the main view.
jQuery is used to fade it out in 10 sec.

View File

@ -81,7 +81,7 @@ h5 { font-weight: bold; }
/* Pagination ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
.g-paginator { display: inline-block; width: 100%; padding: 4px 0 6px 0; font-size: 80%; zoom: 1; }
.g-paginator { display: inline-block; width: 100%; padding: 4px 0 0 0; font-size: 80%; zoom: 1; }
.g-paginator li { display: inline; float: left; margin-left: 0; zoom: 1; }
.g-paginator a { padding: 0 0 0 2px; }
@ -91,7 +91,7 @@ h5 { font-weight: bold; }
/* Album grid ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
.g-thumbcrop { overflow: hidden; position: relative; width: 200px; height: 150px; }
#g-album-grid { padding: 0px; width: 100%; }
#g-album-grid { padding: 6px 0 0 0; width: 100%; }
#g-album-grid .g-item { position: relative; float: left; padding: 10px 9px 0px 9px; width: 30.5%; height: 190px; background: url('../images/image_thumb.gif') no-repeat; }
#g-album-grid .g-item p { text-align: center; }
#g-album-grid h2 { position: absolute; top: 164px; left: 12px; width: 150px; font: 100%/100% Arial, Helvetica, sans-serif; }
@ -119,7 +119,7 @@ h5 { font-weight: bold; }
#g-info h1 { padding-bottom: 1px; border-bottom: 1px solid #888; }
#g-info .g-description { display: none; }
/* #g-info h1:hover .g-description { position: relative; z-index: 10; top: 10px; left: 0px; width: 90%; display: block; afloat: left; border: 1px solid #888; padding: 6px; }*/
#g-photo { padding: 6px 0 0 6px; text-align: center; }
#g-photo { padding: 6px 0 6px 6px; text-align: center; }
#g-albumheader h1 { padding-bottom: 1px; margin-bottom: 6px; border-bottom: 1px solid #888; }
/* Footer section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

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) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -1,6 +1,6 @@
name = "Grey Dragon Theme"
description = "A Crisp theme uses on clear grey colors and minimized on JS overhead"
version = 1.5.6
version = 1.5.8
author = "2009 Serguei Dosyukov"
site = 1
admin = 0

View File

@ -5,7 +5,11 @@
<h1><?= html::purify($item->title) ?></h1>
<div class="g-description"><?= ($item->description)? bb2html(html::purify($item->description), 1) : null; ?></div>
</div>
<? if (module::get_var("th_greydragon", "photonav_top")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<ul id="g-album-grid">
<? if (count($children)): ?>
<? foreach ($children as $i => $child): ?>
@ -41,4 +45,7 @@
<? endif; ?>
</ul>
<?= $theme->album_bottom() ?>
<? if (module::get_var("th_greydragon", "photonav_bottom")): ?>
<?= $theme->paginator() ?>
<? endif ?>

View File

@ -6,6 +6,10 @@
<h1><?= html::clean($title) ?></h1>
</div>
<? if (module::get_var("th_greydragon", "photonav_top")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<ul id="g-album-grid">
<? foreach ($children as $i => $child): ?>
<li class="g-item <?= $child->is_album() ? "g-album" : "" ?>">
@ -26,4 +30,6 @@
</ul>
<?= $theme->dynamic_bottom() ?>
<? if (module::get_var("th_greydragon", "photonav_bottom")): ?>
<?= $theme->paginator() ?>
<? endif ?>

View File

@ -5,16 +5,25 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Copyright (c) 2009 DragonSoft. All Rights Reserved -->
<? $sidebaralign = $_REQUEST['align'];
if (empty($sidebaralign)) {
if (isset($_COOKIE['sidebaralign'])) {
$sidebaralign = $_COOKIE['sidebaralign'];
<? $sidebarvisible = $_REQUEST['sb'];
if (empty($sidebarvisible)) {
if (isset($_COOKIE['gd_sidebar'])) {
$sidebarvisible = $_COOKIE['gd_sidebar'];
} else {
$sidebaralign = "right";
$sidebarvisible = module::get_var("th_greydragon", "sidebar_visible", "");
}
} else {
setcookie("sidebaralign", $sidebaralign, 0);
// Sidebar position is kept for 360 days
setcookie("gd_sidebar", $sidebarvisible, time() + 31536000);
}
$sidebarallowed = module::get_var("th_greydragon", "sidebar_allowed", "");
if ($sidebarallowed == "") { $sidebarallowed = "any"; };
if ($sidebarvisible == "") { $sidebarvisible = "right"; };
if ($sidebarallowed == "none") { $sidebarvisible = "none"; }
if ($sidebarallowed == "right") { $sidebarvisible = "right"; }
if ($sidebarallowed == "left") { $sidebarvisible = "left"; }
?>
<head>
@ -70,7 +79,9 @@
<?= $header_text ?>
<? else: ?>
<a id="g-logo" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
<img alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= $theme->url("images/logo.png") ?>" />
<? $logo_path = module::get_var("th_greydragon", "logo_path", url::file("lib/images/logo.png")); ?>
<? // $theme->url("images/logo.png") ?>
<img alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= $logo_path ?>" />
</a>
<? endif ?>
@ -99,14 +110,23 @@
</div>
<div id="g-main">
<div id="g-main-in">
<? if ($sidebarallowed == "any"): ?>
<ul id="g-viewformat">
<? $iscurrent = ($sidebaralign == "left"); ?>
<li><?= ($iscurrent) ? null : '<a title="Sidebar Left" href="' . $url . '?align=left">'; ?><span class="g-viewthumb-left <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">Sidebar Left</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? $iscurrent = ($sidebaralign == "full"); ?>
<li><?= ($iscurrent) ? null : '<a title="No Sidebar" href="' . $url . '?align=full">'; ?><span class="g-viewthumb-full <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">No Sidebar</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? $iscurrent = ($sidebaralign == "right"); ?>
<li><?= ($iscurrent) ? null : '<a title="Sidebar Right" href="' . $url . '?align=right">'; ?><span class="g-viewthumb-right <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">Sidebar Right</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? 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"): ?>
<? $iscurrent = ($sidebarvisible == "none"); ?>
<li><?= ($iscurrent) ? null : '<a title="No Sidebar" href="' . $url . '?sb=none">'; ?><span class="g-viewthumb-full <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">No Sidebar</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? endif ?>
<? if (($sidebarallowed == "right") or ($sidebarallowed == "any")): ?>
<? $iscurrent = ($sidebarvisible == "right"); ?>
<li><?= ($iscurrent) ? null : '<a title="Sidebar Right" href="' . $url . '?sb=right">'; ?><span class="g-viewthumb-right <?= ($iscurrent)? "g-viewthumb-current" : null; ?>">Sidebar Right</span><?= ($iscurrent)? null : "</a>"; ?></li>
<? endif ?>
</ul>
<? endif ?>
<div id="g-view-menu" class="g-buttonset">
<? if ($page_subtype == "album"):?>
@ -120,21 +140,21 @@
<? endif ?>
</div>
<? if ($sidebaralign=="left"): ?>
<? if ($sidebarvisible=="left"): ?>
<?= '<div id="g-column-left">' ?>
<? elseif ($sidebaralign=="full"): ?>
<? elseif ($sidebarvisible=="none"): ?>
<? else: ?>
<?= '<div id="g-column-right">' ?>
<? endif ?>
<? if (($theme->page_subtype != "login") && ($sidebaralign != "full")): ?>
<? if (($theme->page_subtype != "login") && ($sidebarvisible != "none")): ?>
<?= new View("sidebar.html") ?>
<? endif ?>
<?= ($sidebaralign != "full")? "</div>" : null ?>
<?= ($sidebarvisible != "none")? "</div>" : null ?>
<? if ($sidebaralign=="left"): ?>
<? if ($sidebarvisible == "left"): ?>
<?= '<div id="g-column-centerright">' ?>
<? elseif ($sidebaralign=="full"): ?>
<? elseif ($sidebarvisible == "none"): ?>
<?= '<div id="g-column-centerfull">' ?>
<? else: ?>
<?= '<div id="g-column-centerleft">' ?>
@ -163,18 +183,17 @@
</ul>
<? endif ?>
<? $copyright = module::get_var("th_greydragon", "copyright"); ?>
<div id="g-footer-rightside"><?= ($copyright) ? $copyright : 'Copyright &copy; 2009&nbsp;All Rights Reserved'; ?><br /><br />
<div id="g-footer-rightside"><?= ($copyright) ? $copyright : null; ?><br /><br />
<? // <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="15" width="44" /></a> ?>
</div>
<?= $theme->user_menu() ?>
</div>
<?= $theme->page_bottom() ?>
<!--start player-->
<? // <embed src="/music/collection.m3u" hidden="true" autostart="true" loop="true"></embed>
<? // <!--start player-->
// <embed src="/music/collection.m3u" hidden="true" autostart="true" loop="true"></embed>
// <noembed><bgsound src="/music/collection.m3u"></noembed>
?>
<!--end player-->
<?
// <!--end player-->
//<object type="application/x-shockwave-flash" data="http://photo.dragonsoft.us/music/xspf_player/xspf_player.swf?playlist_url=http://photo.dragonsoft.us/music/collection.xspf&autoplay=true&repeat_playlist=true&player_title=KICK&playlist_size=3" width="400" height="151">
//<param name="movie" value="http://photo.dragonsoft.us/music/xspf_player/xspf_player.swf?playlist_url=http://photo.dragonsoft.us/music/collection.xspf&autoplay=true&repeat_playlist=true&player_title=KICK&playlist_size=3" />
//</object>

View File

@ -7,8 +7,9 @@
<h1><?= html::purify($item->title) ?></h1>
<div class="g-hideitem"><?= bb2html(html::purify($item->description), 1) ?></div>
</div>
<?= $theme->paginator() ?>
<? // = new View("pager_photo.html") ?>
<? if (module::get_var("th_greydragon", "photonav_top")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<div id="g-photo">
<?= $theme->resize_top($item) ?>
@ -22,7 +23,8 @@
<?= $theme->resize_bottom($item) ?>
</div>
<?= $theme->paginator() ?>
<?// = new View("pager_photo.html") ?>
<? if (module::get_var("th_greydragon", "photonav_bottom")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<?= $theme->photo_bottom() ?>
</div>

View File

@ -4,7 +4,11 @@
<h1><?= t("Search Results for \"%term\"", array("term" => $q)) ?> </h1>
<? if (count($items)): ?>
<?= $theme->pager() ?>
<? if (module::get_var("th_greydragon", "photonav_top")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<ul id="g-album-grid">
<? foreach ($items as $item): ?>
<? $item_class = "g-photo"; ?>
@ -19,7 +23,10 @@
</li>
<? endforeach ?>
</ul>
<?= $theme->pager() ?>
<? if (module::get_var("th_greydragon", "photonav_bottom")): ?>
<?= $theme->paginator() ?>
<? endif ?>
<? else: ?>
<p>&nbsp;</p>

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();
}
}

320
web_client/@install.php Normal file
View File

@ -0,0 +1,320 @@
<?php defined('SYSPATH') OR die('No direct access allowed. This file is automatically ran by index.php.'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Kohana Installation</title>
<style type="text/css">
body {
width: 42em;
margin: 0 auto;
font-family: sans-serif;
font-size: 90%;
}
#tests table {
border-collapse: collapse;
width: 100%;
}
#tests table th, #tests table td {
padding: 0.2em 0.4em;
text-align: left;
vertical-align: top;
}
#tests table th {
width: 12em;
font-weight: normal;
font-size: 1.2em;
}
#tests table tr:nth-child(odd) {
background: #eee;
}
#tests table td.pass {
color: #191;
}
#tests table td.fail {
color: #911;
}
#tests #results {
color: #fff;
}
#tests #results p {
padding: 0.8em 0.4em;
}
#tests #results p.pass {
background: #191;
}
#tests #results p.fail {
background: #911;
}
</style>
</head>
<body>
<h1>Environment Tests</h1>
<p>
The following tests have been run to determine if Kohana will work in your environment. If any of the tests have failed, consult the <a href="http://docs.kohanaphp.com/installation">documentation</a>
for more information on how to correct the problem.
</p>
<div id="tests">
<?php $failed = FALSE?>
<table cellspacing="0">
<tr>
<th>PHP Version</th>
<?php if (version_compare(PHP_VERSION, '5.2', '>=')): ?>
<td class="pass">
<?php echo PHP_VERSION?>
</td>
<?php else : $failed = TRUE?>
<td class="fail">
Kohana requires PHP 5.2 or newer, this version is <?php echo PHP_VERSION?>.
</td>
<?php endif?>
</tr>
<tr>
<th>System Directory</th>
<?php if (is_dir(SYSPATH)): ?>
<td class="pass">
<?php echo SYSPATH?>
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The configured
<code>
system
</code>
directory does not exist or does not contain required files.
</td>
<?php endif?>
</tr>
<tr>
<th>Application Directory</th>
<?php if (is_dir(APPPATH) AND is_file(APPPATH.'config/config'.EXT) AND is_file(APPPATH.'Bootstrap'.EXT)): ?>
<td class="pass">
<?php echo APPPATH?>
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The configured
<code>
application
</code>
directory does not exist or does not contain required files.
</td>
<?php endif?>
</tr>
<tr>
<th>Modules Directory</th>
<?php if (is_dir(MODPATH)): ?>
<td class="pass">
<?php echo MODPATH?>
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The configured
<code>
modules
</code>
directory does not exist or does not contain required files.
</td>
<?php endif?>
</tr>
<tr>
<th>Logs Directory</th>
<?php if (is_dir(APPPATH.'logs') AND is_writable(APPPATH.'logs')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The default
<code>
logs
</code>
directory does not exist or is not writable. Depending on your log driver and config settings, this may not be a problem.
</td>
<?php endif?>
</tr>
<tr>
<th>Cache Directory</th>
<?php if (is_dir(APPPATH.'cache') AND is_writable(APPPATH.'cache')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The default
<code>
cache
</code>
directory does not exist or is not writable. Depending on your cache driver and config settings, this may not be a problem.
</td>
<?php endif?>
</tr>
<tr>
<th>PCRE UTF-8</th>
<?php if ( ! function_exists('preg_match')): $failed = TRUE?>
<td class="fail">
<a href="http://php.net/pcre">PCRE</a>
support is missing.
</td>
<?php elseif ( ! @preg_match('/^.$/u', 'ñ')): $failed = TRUE?>
<td class="fail">
<a href="http://php.net/pcre">PCRE</a>
has not been compiled with UTF-8 support.
</td>
<?php elseif ( ! @preg_match('/^\pL$/u', 'ñ')): $failed = TRUE?>
<td class="fail">
<a href="http://php.net/pcre">PCRE</a>
has not been compiled with Unicode property support.
</td>
<?php else : ?>
<td class="pass">
Pass
</td>
<?php endif?>
</tr>
<tr>
<th>Reflection Enabled</th>
<?php if (class_exists('ReflectionClass')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
PHP <a href="http://www.php.net/reflection">reflection</a>
is either not loaded or not compiled in.
</td>
<?php endif?>
</tr>
<tr>
<th>Filters Enabled</th>
<?php if (function_exists('filter_list')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The <a href="http://www.php.net/filter">filter</a>
extension is either not loaded or not compiled in.
</td>
<?php endif?>
</tr>
<tr>
<th>Iconv Extension Loaded</th>
<?php if (extension_loaded('iconv')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
The <a href="http://php.net/iconv">iconv</a>
extension is not loaded.
</td>
<?php endif?>
</tr>
<tr>
<th>SPL Enabled</th>
<?php if (function_exists('spl_autoload_register')): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
<a href="http://php.net/spl">SPL</a>
is not enabled.
</td>
<?php endif?>
</tr>
<tr>
<th>Multibyte String Enabled</th>
<?php if (extension_loaded('mbstring')): ?>
<td class="pass">Pass</td>
<?php else: $failed = TRUE; ?>
<td class="fail">The <a href="http://php.net/mbstring">mbstring</a>
extension is not loaded.</td>
<?php endif ?>
</tr>
<?php if (extension_loaded('mbstring')): ?>
<tr>
<th>Mbstring Not Overloaded</th>
<?php if (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING): $failed = TRUE?>
<td class="fail">
The <a href="http://php.net/mbstring">mbstring</a>
extension is overloading PHP's native string functions.
</td>
<?php else : ?>
<td class="pass">
Pass
</td>
<?php endif?>
</tr>
<?php endif?>
<tr>
<th>XML support</th>
<?php if ( ! function_exists('utf8_encode')): $failed = TRUE?>
<td class="fail">
PHP is compiled without <a href="http://php.net/xml">XML</a>
support, thus lacking support for
<code>
utf8_encode()
</code>/
<code>
utf8_decode()
</code>.
</td>
<?php else : ?>
<td class="pass">
Pass
</td>
<?php endif?>
</tr>
<th>Timezone</th>
<?php try { new DateTimeZone(ini_get('date.timezone')); ?>
<td class="pass">Pass</td>
<?php } catch (Exception $e) { $failed = TRUE ?>
<td class="fail">
The current timezone, <code>'<?php echo ini_get('date.timezone') ?>'</code>, is not valid.
You must configure it in <code>php.ini</code> or <code>config/locale.php</code>.
</td>
<?php } ?>
</tr>
<tr>
<th>URI Determination</th>
<?php if (isset($_SERVER['SCRIPT_NAME']) AND (isset($_SERVER['PATH_INFO']) OR isset($_SERVER['ORIG_PATH_INFO']) OR isset($_SERVER['PHP_SELF']))): ?>
<td class="pass">
Pass
</td>
<?php else : $failed = TRUE?>
<td class="fail">
At least one of <code>$_SERVER['PATH_INFO']</code>, <code>$_SERVER['ORIG_PATH_INFO']</code>, or <code>$_SERVER['PHP_SELF']</code> must be available.
</td>
<?php endif?>
</tr>
</table>
<div id="results">
<?php if ($failed === TRUE): ?>
<p class="fail">
Kohana may not work correctly with your environment.
</p>
<?php else : ?>
<p class="pass">
Your environment passed all requirements. Remove or rename the
<code>
install<?php echo EXT?>
</code>
file now.
</p>
<?php endif?>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Kohana License</title>
</head>
<body>
<h2>Kohana License Agreement</h2>
<p>This license is a legal agreement between you and the Kohana Software Foundation for the use of Kohana Framework (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.</p>
<p>Copyright (c) 2007-2009 Kohana Team<br/>All rights reserved.</p>
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
<ul>
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
<li>Neither the name of the Kohana nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.</li>
</ul>
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
<p><small>NOTE: This license is modeled after the BSD software license.</small></p>
</body>
</html>

View File

@ -0,0 +1,59 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Kohana process control file, loaded by the front controller.
*
* $Id: Bootstrap.php 4679 2009-11-10 01:45:52Z isaiah $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
*/
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH.'core/Benchmark'.EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');
// Load core files
require SYSPATH.'core/Event'.EXT;
final class Event extends Event_Core {}
require SYSPATH.'core/Kohana'.EXT;
final class Kohana extends Kohana_Core {}
require SYSPATH.'core/Kohana_Exception'.EXT;
class Kohana_Exception extends Kohana_Exception_Core {}
require SYSPATH.'core/Kohana_Config'.EXT;
require SYSPATH.'libraries/drivers/Config'.EXT;
require SYSPATH.'libraries/drivers/Config/Array'.EXT;
final class Kohana_Config extends Kohana_Config_Core {}
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');
// Make the magic happen!
Event::run('system.execute');

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1,123 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Base path of the web site. If this includes a domain, eg: localhost/kohana/
* then a full URL will be used, eg: http://localhost/kohana/. If it only includes
* the path, and a site_protocol is specified, the domain will be auto-detected.
*/
$config['site_domain'] = '/g3_client/';
/**
* Force a default protocol to be used by the site. If no site_protocol is
* specified, then the current protocol is used, or when possible, only an
* absolute path (with no protocol/domain) is used.
*/
$config['site_protocol'] = 'http';
/**
* Name of the front controller for this application. Default: index.php
*
* This can be removed by using URL rewriting.
*/
$config['index_page'] = 'index.php';
/**
* Fake file extension that will be added to all generated URLs. Example: .html
*/
$config['url_suffix'] = '';
/**
* Length of time of the internal cache in seconds. 0 or FALSE means no caching.
* The internal cache stores file paths and config entries across requests and
* can give significant speed improvements at the expense of delayed updating.
*/
$config['internal_cache'] = FALSE;
/**
* Internal cache directory.
*/
$config['internal_cache_path'] = APPPATH.'cache/';
/**
* Enable internal cache encryption - speed/processing loss
* is neglible when this is turned on. Can be turned off
* if application directory is not in the webroot.
*/
$config['internal_cache_encrypt'] = TRUE;
/**
* Encryption key for the internal cache, only used
* if internal_cache_encrypt is TRUE.
*
* Make sure you specify your own key here!
*
* The cache is deleted when/if the key changes.
*/
$config['internal_cache_key'] = 'g3_client';
/**
* Enable or disable gzip output compression. This can dramatically decrease
* server bandwidth usage, at the cost of slightly higher CPU usage. Set to
* the compression level (1-9) that you want to use, or FALSE to disable.
*
* Do not enable this option if you are using output compression in php.ini!
*/
$config['output_compression'] = FALSE;
/**
* Enable or disable global XSS filtering of GET, POST, and SERVER data. This
* option also accepts a string to specify a specific XSS filtering tool.
*/
$config['global_xss_filtering'] = FALSE;
/**
* Enable or disable hooks.
*/
$config['enable_hooks'] = true;
/**
* Enable or disable displaying of Kohana error pages. This will not affect
* logging. Turning this off will disable ALL error pages.
*/
$config['display_errors'] = TRUE;
/**
* Enable or disable statistics in the final output. Stats are replaced via
* specific strings, such as {execution_time}.
*
* @see http://docs.kohanaphp.com/general/configuration
*/
$config['render_stats'] = TRUE;
/**
* Filename prefixed used to determine extensions. For example, an
* extension to the Controller class would be named MY_Controller.php.
*/
$config['extension_prefix'] = 'MY_';
/**
* An optional list of Config Drivers to use, they "fallback" to the one below them if they
* dont work so the first driver is tried then so on until it hits the built in "array" driver and fails
*/
$config['config_drivers'] = array();
/**
* Additional resource paths, or "modules". Each path can either be absolute
* or relative to the docroot. Modules can include any resource that can exist
* in your application directory, configuration files, controllers, views, etc.
*/
$config['modules'] = array
(
// MODPATH.'auth', // Authentication
// MODPATH.'forge', // Form generation
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'media', // Media caching and compression
// MODPATH.'gmaps', // Google Maps integration
// MODPATH.'archive', // Archive utility
// MODPATH.'payment', // Online payments
// MODPATH.'unit_test', // Unit testing
// MODPATH.'object_db', // New OOP Database library (testing only!)
);
/**
* Base path of the gallery3 restFULL API
*/
$config["gallery3_site"] = "http://????/gallery3/index.php/rest";

View File

@ -0,0 +1,25 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Redirect edit requests to edit handler.
$config["^(edit|add|delete)_(\w+)(.*)$"] = "g3_handlers/$1/$2$3";
// Set the default route
$config['_default'] = 'g3_client';

View File

@ -0,0 +1,48 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Session
*
* Session driver name.
*/
$config['driver'] = 'cookie';
/**
* Session storage parameter, used by drivers.
*/
$config['storage'] = '';
/**
* Session name.
* It must contain only alphanumeric characters and underscores. At least one letter must be present.
*/
$config['name'] = 'kohanasession';
/**
* Session parameters to validate: user_agent, ip_address, expiration.
*/
$config['validate'] = array('user_agent');
/**
* Enable or disable session encryption.
* Note: this has no effect on the native session driver.
*/
$config['encryption'] = FALSE;
/**
* Session lifetime. Number of seconds that each session will last.
* A value of 0 will keep the session active until the browser is closed (with a limit of 24h).
*/
$config['expiration'] = 43200; // 24 hours
/**
* Number of page loads before the session id is regenerated.
* A value of 0 will disable automatic session id regeneration.
* NOTE: Enabling automatic session regeneration can cause a race condition see the
* docs for details: http://docs.kohanaphp.com/libraries/session#regenerate
*/
$config['regenerate'] = 0;
/**
* Percentage probability that the gc (garbage collection) routine is started.
*/
$config['gc_probability'] = 2;

View File

@ -0,0 +1,157 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class G3_Client_Controller extends Template_Controller {
// Set the name of the template to use
public $template = 'g3_template.html';
public function index() {
$this->template->title = 'G3 Web Client';
if (Session::instance()->get("g3_client_access_token")) {
$response = G3Remote::instance()->get_resource("gallery");
$this->template->content = $this->_get_main_view($response->resource);
} else {
$this->template->content = new View('login.html');
$this->template->content->errors = $this->template->content->form =
array("user" => "", "password" => "");
}
}
public function login() {
$form = $errors = array("user" => "", "password" => "");
$post = new Validation($_POST);
$post->add_rules("user", "required");
$post->add_rules("password", "required");
if ($valid = $post->validate()) {
try {
$token = G3Remote::instance()->get_access_token($post["user"], $post["password"]);
Session::instance()->set("g3_client_access_token", $token);
$response = G3Remote::instance()->get_resource("gallery");
$valid = true;
$content = $this->_get_main_view($response->resource);
} catch (Exception $e) {
Kohana_Log::add("error", Kohana_Exception::text($e));
$valid = false;
}
}
if (!$valid) {
$content = new View('login.html');
$content->form = arr::overwrite($form, $post->as_array());
$content->errors = arr::overwrite($errors, $post->errors());
}
$this->auto_render = false;
print json_encode(array("status" => $valid ? "ok" : "error", "content" => (string)$content));
}
public function albums() {
$path = $this->input->get("path");
$response = G3Remote::instance()->get_resource("gallery/$path", array("filter" => "album"));
$this->auto_render = false;
print $this->_get_album_tree($response->resource);
}
public function detail() {
$path = $this->input->get("path");
$response = G3Remote::instance()->get_resource("gallery/$path");
$this->auto_render = false;
print $this->_get_detail($response->resource);
}
public function tagged_album($tags) {
$response = G3Remote::instance()->get_resource("tag/$tags");
$this->auto_render = false;
$v = new View("tag_detail.html");
$v->resources = $response->resources;
print $v;
}
public function block($type) {
switch ($type) {
case "random":
print $this->_get_image_block();
break;
case "tags":
print "";
break;
default:
print "";
}
$this->auto_render = false;
}
private function _get_album_tree($resource) {
$v = new View("tree_part.html");
$v->element = (object)array("title" => $resource->title, "path" => $resource->path);
$v->element->children = array();
foreach ($resource->children as $child) {
if ($child->type != "album") {
continue;
}
$v->element->children[] = $child;
}
return $v;
}
private function _get_main_view($resource) {
$v = new View("main.html");
$v->album_tree = $this->_get_album_tree($resource);
$v->detail = $this->_get_detail($resource);
$v->image_block = $this->_get_image_block();
$v->tag_block = $this->_get_tag_block();
return $v;
}
private function _get_detail($resource) {
$v = new View("{$resource->type}_detail.html");
$v->resource = $resource;
$v->parent_path = substr($resource->path, 0, -strlen($resource->slug));
if (strrpos($v->parent_path, "/") == strlen($v->parent_path) - 1) {
$v->parent_path = substr($v->parent_path, 0, -1);
}
return $v;
}
private function _get_image_block() {
$response = G3Remote::instance()->get_resource("image_block", array("type" => "random"));
if ($response->status == "OK") {
$v = new View("image_block.html");
$v->path = $response->resource->path;
$v->src = $response->resource->thumb_url;
$v->title = $response->resource->title;
} else {
$v = "";
}
return $v;
}
private function _get_tag_block() {
$response = G3Remote::instance()->get_resource("tag", array("limit" => "15"));
if ($response->status == "OK") {
$v = new View("tag_block.html");
$v->tags = $response->tags;
$v->max_count = $response->tags[0]->count;;
} else {
$v = "";
}
return $v;
}
} // End G3 Client Controller

View File

@ -0,0 +1,120 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class G3_Handlers_Controller extends Controller {
public function edit($type) {
$path = $this->input->get("path");
if ($_POST) {
try {
unset($_POST["do_edit"]);
$result = G3Remote::instance()->update_resource("gallery/$path", $_POST);
if ($result->status == "OK") {
$form = null;
$result = "success";
} else {
$form = g3_client::get_form($type, false, $path, (object)$_POST);
foreach (array_keys($_POST) as $field) {
if (isset($result->fields->$field)) {
$form->errors[$field] = $result->fields->$field;
}
}
$result = "display";
}
} catch (Exception $e) {
$form = g3_client::get_form($type, false, $path, (object)$_POST);
$form->errors["form_error"] = $e->getMessage();
$result = "error";
}
} else {
$response = G3Remote::instance()->get_resource("gallery/$path");
$form = g3_client::get_form($type, false, $path, $response->resource);
$result = "display";
}
print g3_client::format_response($type, $path, $form, $result);
}
public function add($type) {
$path = $this->input->get("path");
if ($_POST) {
try {
$data = array(
"title" => $_POST["title"],
"name" => $_POST["name"],
"slug" => g3_client::sanitize_title($_POST["slug"], $_POST["name"]),
"description" => $_POST["description"]);
if ($_FILES) {
if (empty($_FILES["image"]["error"])) {
unset($_FILES["image"]["error"]);
$data["image"] = (object)$_FILES["image"];
} else {
throw new Exception("File upload failed for reason: {$_FILES['image']['error']}");
}
}
$path = !empty($path) ? $path . "/" : $path;
$result = G3Remote::instance()->add_resource("gallery/$path{$data['name']}", $data);
if ($result->status == "OK") {
$form = null;
$result = "success";
} else {
$form = g3_client::get_form($type, true, $path, (object)$_POST);
foreach (array_keys($_POST) as $field) {
if (isset($result->fields->$field)) {
$form->errors[$field] = $result->fields->$field;
}
}
$result = "display";
}
} catch (Exception $e) {
Kohana_Log::add("error", (string)$e);
$form = g3_client::get_form($type, true, $path, (object)$_POST);
$form->errors["form_error"] = $e->getMessage();
$result = "error";
}
} else {
$form = g3_client::get_form($type, true, $path);
$result = "display";
}
print g3_client::format_response($type, $path, $form, $result);
}
public function delete($type) {
$path = $this->input->get("path");
if ($_POST) {
try {
$response = G3Remote::instance()->delete_resource("gallery/$path");
print json_encode(array("result" => "success", "path" => $response->resource->parent_path,
"type" => $type));
} catch (Exception $e) {
print json_encode(array("result" => "fail", "message" => $e->getMessage()));
}
return;
} else {
$response = G3Remote::instance()->get_resource("gallery/$path");
$v = new View("delete.html");
$v->title = $response->resource->title;
$v->path = "delete_album/?path=$path";
}
print json_encode(array("form" => (string)$v));
}
} // End G3 Album Controller

View File

@ -0,0 +1,78 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class g3_client_Core {
static function get_form($type, $add_form, $path, $data=null) {
$form = new stdClass();
$form->adding = $add_form;
$form->form = array("title" => (object)array("value" => "", "label" => "Title"),
"name" => (object)array("value" => "", "label" => "Name"),
"description" => (object)array("value" => "", "label" => "Description"),
"slug" => (object)array("value" => "", "label" => "Internet Address"));
// @todo add sort column sort order fields
$form->errors = array("title" => "", "name" => "", "description" => "", "slug" => "");
if ($type != "album" && $add_form) {
$form->form["image"] = (object)array("value" => "", "label" => "Image File");
$form->errors["image"] = "";
}
if (empty($path) && !$add_form) {
$form->form["name"]->readonly = $form->form["slug"]->readonly = "readonly";
}
if ($data) {
foreach (array_keys($form->form) as $field) {
if (isset($data->$field)) {
$form->form[$field]->value = $data->$field;
}
}
}
return $form;
}
static function format_response($type, $path, $form, $result) {
$json = (object)array("result" => $result);
if ($result != "success") {
$json->form = new View("edit.html");
$json->form->title = ($form->adding ? "Add " : "Update ") . ucwords($type);
$json->form->url = $form->adding ? "add" : "edit";
$json->form->button_text = $form->adding ? "Add" : "Update";
$json->form->path = $path;
$json->form->type = $type;
$json->form->form = (object)$form->form;
$json->form->errors = (object)$form->errors;
$json->form = (string)$json->form;
} else {
$json->path = $path;
$json->type = $type;
}
return json_encode($json);
}
/**
* Sanitize a filename into something safe
* @param string $filename
* @return string sanitized filename
*/
static function sanitize_title($field, $title) {
$result = preg_replace("/[^A-Za-z0-9-_]+/", "-", empty($field) ? $title : $field);
return trim($result, "-");
}
}

View File

@ -0,0 +1,23 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
$access_token = Session::instance()->get("g3_client_access_token");
$site = Kohana::config("core.gallery3_site");
G3Remote::instance($site, $access_token);

View File

@ -0,0 +1,298 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// This class does not depend on any Kohana services so that it can be used in non-Kohana
// applications.
class G3Remote {
protected static $_instance;
private $_gallery3_site;
private $_access_token;
public static function instance($site=null, $access_token=null) {
if (!isset(G3Remote::$_instance)) {
G3Remote::$_instance = new G3Remote($site, $access_token);
}
return G3Remote::$_instance;
}
/**
* Constructs a new G3Remote object
*
* @param array Database config array
* @return G3Remote
*/
protected function __construct($site, $access_token) {
// Store the config locally
$this->_gallery3_site = $site;
$this->_access_token = $access_token;
}
public function get_access_token($user, $password) {
$request = "{$this->_gallery3_site}/access_key";
list ($response_status, $response_headers, $response_body) =
G3Remote::_get($request, array("user" => $user, "password" => $password));
if (G3Remote::_success($response_status)) {
$response = json_decode($response_body);
if ($response->status == "OK") {
$this->_access_token = $response->token;
} else {
throw new Exception("Remote host failure: {$response->message}");
}
} else {
throw new Exception("Remote host failure: $response_status");
}
return $this->_access_token;
}
public function get_resource($path, $params=array()) {
return $this->_do_request("get", $path, $params);
}
public function delete_resource($path) {
return $this->_do_request("delete", $path);
}
public function update_resource($path, $params) {
return $this->_do_request("put", $path, $params);
}
public function add_resource($path, $params) {
return $this->_do_request("post", $path, $params);
}
private function _do_request($method, $path, $params=array()) {
$request_path = "{$this->_gallery3_site}/$path";
$headers = array();
if ($method == "put" || $method == "delete") {
$headers["X_GALLERY_REQUEST_METHOD"] = $method;
$method = "post";
}
if (!empty($this->_access_token)) {
$headers["X_GALLERY_REQUEST_KEY"] = $this->_access_token;
}
list ($response_status, $response_headers, $response_body) =
$method == "get" ? G3Remote::_get($request_path, $params, $headers) :
G3Remote::_post($request_path, $params, $headers);
if (G3Remote::_success($response_status)) {
$response = json_decode($response_body);
switch ($response->status) {
case "OK":
case "VALIDATE_ERROR":
return $response;
default:
throw new Exception("Remote host failure: {$response->message}");
}
} else {
throw new Exception("Remote host failure: $response_status");
}
}
private static function _post($url, $post_data_array, $extra_headers=array()) {
$boundary = str_repeat("-", 9) . md5(microtime());
$boundary_length = strlen($boundary);
$extra_headers['Content-Type'] = "multipart/form-data; boundary=$boundary";
$length = 0;
$fields = array();
foreach ($post_data_array as $field => $value) {
$fields[$field] = array();
if (is_string($value)) {
$fields[$field]["disposition"] = "Content-Disposition: form-data; name=\"$field\"\r\n\r\n";
$fields[$field]["type"] = "";
$fields[$field]["value"] = "$value\r\n";
} else {
$fields[$field]["disposition"] =
"Content-Disposition: form-data; name=\"$field\"; filename=\"{$value->name}\"\r\n";
$fields[$field]["type"] = "Content-Type: {$value->type}\r\n\r\n";
$fields[$field]["value"] = "\r\n";
$fields[$field]["local_file"] = $value->tmp_name;
$length += $value->size;
}
$length += strlen($fields[$field]["disposition"]) + strlen($fields[$field]["value"]) +
strlen($fields[$field]["type"]) + $boundary_length + 4;
}
$length += $boundary_length + 6; // boundary terminator and last crlf
$extra_headers['Content-Length'] = $length;
$socket = G3Remote::_open_socket($url, 'POST', $extra_headers);
$sent_length = 0;
foreach ($fields as $field => $value) {
$sent_length += fwrite($socket, "--$boundary\r\n");
$sent_length += fwrite($socket, $value["disposition"]);
if (!empty($value["type"])) {
$sent_length += fwrite($socket, $value["type"]);
$file = fopen($value["local_file"], "rb");
while (!feof($file)) {
$buffer = fread($file, 8192);
$sent_length += fwrite($socket, $buffer);
fflush($socket);
}
}
$sent_length += fwrite($socket, $value["value"]);
fflush($socket);
}
$sent_length += fwrite($socket, "--$boundary--\r\n");
fflush($socket);
/* Read the web page into a buffer */
return G3Remote::_get_response($socket);
}
private static function _get($url, $_data_array=array(), $extra_headers=array()) {
$_data_raw = self::_encode_data($_data_array, $extra_headers);
$handle = G3Remote::_open_socket("{$url}?$_data_raw", "GET", $extra_headers);
/* Read the web page into a buffer */
return G3Remote::_get_response($handle);
}
private static function _success($response_status) {
return preg_match("/^HTTP\/\d+\.\d+\s2\d{2}(\s|$)/", trim($response_status));
}
/**
* Encode the data. For each key/value pair, urlencode both the key and the value and then
* concatenate together. As per the specification, each key/value pair is separated with an
* ampersand (&)
* @param array $data_array the key/value data
* @param array $extra_headers extra headers to pass to the server
* @return string the encoded post data
*/
private static function _encode_data($_data_array, &$extra_headers) {
$_data_raw = '';
foreach ($_data_array as $key => $value) {
if (!empty($_data_raw)) {
$_data_raw .= '&';
}
$_data_raw .= urlencode($key) . '=' . urlencode($value);
}
return $_data_raw;
}
/**
* Open the socket to server
*/
static function _open_socket($url, $method='GET', $headers=array()) {
/* Convert illegal characters */
$url = str_replace(' ', '%20', $url);
$url_components = self::_parse_url_for_fsockopen($url);
$handle = fsockopen(
$url_components['fsockhost'], $url_components['port'], $errno, $errstr, 5);
if (empty($handle)) {
return array(null, null, null);
}
$header_lines = array('Host: ' . $url_components['host']);
foreach ($headers as $key => $value) {
$header_lines[] = $key . ': ' . $value;
}
$success = fwrite($handle, sprintf("%s %s HTTP/1.0\r\n%s\r\n\r\n",
$method,
$url_components['uri'],
implode("\r\n", $header_lines)));
fflush($handle);
return $handle;
}
/**
* Read the http response
*/
static function _get_response($handle) {
/*
* Read the status line. fgets stops after newlines. The first line is the protocol
* version followed by a numeric status code and its associated textual phrase.
*/
$response_status = trim(fgets($handle, 4096));
if (empty($response_status)) {
// 'Empty http response code, maybe timeout'
return array(null, null, null);
}
/* Read the headers */
$response_headers = array();
while (!feof($handle)) {
$line = trim(fgets($handle, 4096));
if (empty($line)) {
break;
}
/* Normalize the line endings */
$line = str_replace("\r", '', $line);
list ($key, $value) = explode(':', $line, 2);
if (isset($response_headers[$key])) {
if (!is_array($response_headers[$key])) {
$response_headers[$key] = array($response_headers[$key]);
}
$response_headers[$key][] = trim($value);
} else {
$response_headers[$key] = trim($value);
}
}
/* Read the body */
$response_body = '';
while (!feof($handle)) {
$response_body .= fread($handle, 4096);
}
fclose($handle);
return array($response_status, $response_headers, $response_body);
}
/**
* Prepare for fsockopen call.
* @param string $url
* @return array url components
* @access private
*/
private static function _parse_url_for_fsockopen($url) {
$url_components = parse_url($url);
if (strtolower($url_components['scheme']) == 'https') {
$url_components['fsockhost'] = 'ssl://' . $url_components['host'];
$default_port = 443;
} else {
$url_components['fsockhost'] = $url_components['host'];
$default_port = 80;
}
if (empty($url_components['port'])) {
$url_components['port'] = $default_port;
}
if (empty($url_components['path'])) {
$url_components['path'] = '/';
}
$uri = $url_components['path']
. (empty($url_components['query']) ? '' : '?' . $url_components['query']);
/* Unescape ampersands, since if the url comes from form input it will be escaped */
$url_components['uri'] = str_replace('&amp;', '&', $uri);
return $url_components;
}
}

View File

@ -0,0 +1 @@
*

Some files were not shown because too many files have changed in this diff Show More