Esempio n. 1
0
 static function feed($feed_id, $offset, $limit, $id)
 {
     if ($feed_id != "newest" && $feed_id != "item") {
         return;
     }
     $comments = ORM::factory("comment")->where("state", "published")->orderby("created", "DESC");
     $all_comments = ORM::factory("comment")->where("state", "published")->orderby("created", "DESC");
     if ($feed_id == "item") {
         $comments->where("item_id", $id);
         $all_comments->where("item_id", $id);
     }
     if (!empty($comments)) {
         $feed->view = "comment.mrss";
         $comments = $comments->find_all($limit, $offset);
         $feed->children = array();
         foreach ($comments as $comment) {
             $item = $comment->item();
             $feed->children[] = new ArrayObject(array("pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => nl2br(p::purify($comment->text)), "thumb_url" => $item->thumb_url(), "thumb_height" => $item->thumb_height, "thumb_width" => $item->thumb_width, "item_uri" => url::abs_site("{$item->type}s/{$item->id}"), "title" => p::purify($item->title), "author" => p::clean($comment->author_name())), ArrayObject::ARRAY_AS_PROPS);
         }
         $feed->max_pages = ceil($all_comments->find_all()->count() / $limit);
         $feed->title = htmlspecialchars(t("Recent Comments"));
         $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id));
         $feed->description = t("Recent Comments");
         return $feed;
     }
 }
Esempio n. 2
0
 static function update_index($task)
 {
     try {
         $completed = $task->get("completed", 0);
         $start = microtime(true);
         $message = array();
         foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "photo")->open_paren()->where("exif_records.item_id", null)->orwhere("exif_records.dirty", 1)->close_paren()->find_all() as $item) {
             if (microtime(true) - $start > 1.5) {
                 break;
             }
             $completed++;
             exif::extract($item);
             $message[] = t("Updated Exif meta data for '%title'", array("title" => p::purify($item->title)));
         }
         $task->log($message);
         list($remaining, $total, $percent) = exif::stats();
         $task->set("completed", $completed);
         if ($remaining == 0 || !($remaining + $completed)) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("exif_index_out_of_date");
             $task->percent_complete = 100;
         } else {
             $task->percent_complete = round(100 * $completed / ($remaining + $completed));
         }
         $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $task->log($e->__toString());
     }
 }
Esempio n. 3
0
 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $message = array();
     try {
         $result = graphics::find_dirty_images_query();
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $remaining = $result->count() - count($ignored);
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded) {
                 $success = graphics::generate($item);
                 if (!$success) {
                     $ignored[$item->id] = 1;
                     $message[] = t("Unable to rebuild images for '%title'", array("title" => p::purify($item->title)));
                 } else {
                     $message[] = t("Successfully rebuilt images for '%title'", array("title" => p::purify($item->title)));
                 }
             }
             $completed++;
             $remaining--;
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
         if ($completed + $remaining > 0) {
             $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($remaining == 0) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $message[] = $e->__toString();
     }
     $task->log($message);
 }
Esempio n. 4
0
 static function update($item)
 {
     $data = array();
     $record = ORM::factory("search_record")->where("item_id", $item->id)->find();
     if (!$record->loaded) {
         $record->item_id = $item->id;
     }
     foreach (module::active() as $module) {
         $class_name = "{$module->name}_search";
         if (method_exists($class_name, "item_index_data")) {
             $data[] = call_user_func(array($class_name, "item_index_data"), $record->item());
         }
     }
     $record->data = join(" ", $data);
     $record->dirty = 0;
     $record->save();
     return t("Search index updated for '%title'", array("title" => p::purify($item->title)));
 }
Esempio n. 5
0
 public function print_photo($id)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $id);
     access::required("view_full", $item);
     if (access::group_can(group::everybody(), "view_full", $item)) {
         $full_url = $item->file_url(true);
         $thumb_url = $item->thumb_url(true);
     } else {
         $proxy = ORM::factory("digibug_proxy");
         $proxy->uuid = md5(rand());
         $proxy->item_id = $item->id;
         $proxy->save();
         $full_url = url::abs_site("digibug/print_proxy/full/{$proxy->uuid}");
         $thumb_url = url::abs_site("digibug/print_proxy/thumb/{$proxy->uuid}");
     }
     $v = new View("digibug_form.html");
     $v->order_parms = array("digibug_api_version" => "100", "company_id" => module::get_var("digibug", "company_id"), "event_id" => module::get_var("digibug", "event_id"), "cmd" => "addimg", "partner_code" => "69", "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $full_url, "thumb_1" => $thumb_url, "image_height_1" => $item->height, "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, "title_1" => p::purify($item->title));
     print $v;
 }
Esempio n. 6
0
 static function feed($feed_id, $offset, $limit, $id)
 {
     switch ($feed_id) {
         case "latest":
             $feed->children = ORM::factory("item")->viewable()->where("type !=", "album")->orderby("created", "DESC")->find_all($limit, $offset);
             $all_children = ORM::factory("item")->viewable()->where("type !=", "album")->orderby("created", "DESC");
             $feed->max_pages = ceil($all_children->find_all()->count() / $limit);
             $feed->title = t("Recent Updates");
             $feed->link = url::abs_site("albums/1");
             $feed->description = t("Recent Updates");
             return $feed;
         case "album":
             $item = ORM::factory("item", $id);
             access::required("view", $item);
             $feed->children = $item->viewable()->descendants($limit, $offset, array("type" => "photo"));
             $feed->max_pages = ceil($item->viewable()->descendants_count(array("type" => "photo")) / $limit);
             $feed->title = p::purify($item->title);
             $feed->link = url::abs_site("albums/{$item->id}");
             $feed->description = nl2br(p::purify($item->description));
             return $feed;
     }
 }
Esempio n. 7
0
 public function delete($id)
 {
     access::verify_csrf();
     $item = model_cache::get("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     if ($item->is_album()) {
         $msg = t("Deleted album <b>%title</b>", array("title" => p::purify($item->title)));
     } else {
         $msg = t("Deleted photo <b>%title</b>", array("title" => p::purify($item->title)));
     }
     $parent = $item->parent();
     $item->delete();
     message::success($msg);
     if (Input::instance()->get("page_type") == "album") {
         print json_encode(array("result" => "success", "reload" => 1));
     } else {
         print json_encode(array("result" => "success", "location" => url::site("albums/{$parent->id}")));
     }
 }
  }
  download = function(){
    // send request
    $('<form action="<?php 
echo url::site("admin/maintenance/save_log/{$task->id}?csrf={$csrf}");
?>
" method="post"></form>').
appendTo('body').submit().remove();
  };
</script>
<div id="gTaskLogDialog">
  <h1> <?php 
echo $task->name;
?>
 </h1>
  <div class="gTaskLog">
    <pre><?php 
echo p::purify($task->get_log());
?>
</pre>
  </div>
  <button id="gCloseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?php 
echo t("Close");
?>
</button>
  <button id="gSaveButton" class="ui-state-default ui-corner-all" onclick="download()"><?php 
echo t("Save");
?>
</button>
</div>
Esempio n. 9
0
<div id="gSiteMenu" style="display: none">
<?php 
echo $theme->site_menu();
?>
</div>

<?php 
echo $theme->header_bottom();
?>

<? if (!empty($parents)): ?>
<ul class="gBreadcrumbs">
  <? foreach ($parents as $parent): ?>
  <li>
    <a href="<?php 
echo url::site("albums/{$parent->id}?show={$item->id}");
?>
">
      <?php 
echo p::purify($parent->title);
?>
    </a>
  </li>
  <? endforeach ?>
  <li class="active"><?php 
echo p::purify($item->title);
?>
</li>
</ul>
<? endif ?>
Esempio n. 10
0
      <author><?php 
echo p::clean($child->author);
?>
</author>
      <guid isPermaLink="true"><?php 
echo $child->item_uri;
?>
</guid>
      <pubDate><?php 
echo $child->pub_date;
?>
</pubDate>
      <content:encoded>
        <![CDATA[
          <p><?php 
echo nl2br(p::purify($child->text));
?>
</p>
          <p>
            <img alt="" src="<?php 
echo $child->thumb_url;
?>
"
                 height="<?php 
echo $child->thumb_height;
?>
" width="<?php 
echo $child->thumb_width;
?>
" />
            <br />
<?php

defined("SYSPATH") or die("No direct script access.");
?>
<ul>
  <? foreach ($comments as $i => $comment): ?>
  <li class="<?php 
echo $i % 2 == 0 ? "gEvenRow" : "gOddRow";
?>
">
    <img src="<?php 
echo $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true));
?>
"
         class="gAvatar"
         alt="<?php 
echo p::clean($comment->author_name());
?>
"
         width="32"
         height="32" />
    <?php 
echo gallery::date_time($comment->created);
?>
    <?php 
echo t('<a href="#">%author_name</a> said <em>%comment_text</em>', array("author_name" => p::clean($comment->author_name()), "comment_text" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
?>
  </li>
  <? endforeach ?>
</ul>
Esempio n. 12
0
  <head>
    <title><?php 
echo p::clean($subject);
?>
 </title>
  </head>
  <body>
    <h2><?php 
echo p::clean($subject);
?>
</h2>
    <table>
      <tr>
        <td colspan="2">
          <?php 
echo t("To view the changed album %title use the link below.", array("title" => p::purify($item->parent()->title)));
?>
        </td>
      </tr>
      <tr>
        <td><?php 
echo t("Url:");
?>
</td>
        <td>
          <a href="<?php 
echo $item->parent()->url(array(), true);
?>
">
            <?php 
echo $item->parent()->url(array(), true);
Esempio n. 13
0
  var csrf = "<?php 
echo $csrf;
?>
";
  var rearrangeUrl = "<?php 
echo url::site("__URI__/__ITEM_ID____TASK_ID__?csrf={$csrf}");
?>
";
  $("#doc3").ready(function() {
    organize_dialog_init();
  });
</script>
<fieldset style="display: none">
  <legend><?php 
echo t("Organize %name", array("name" => p::purify($item->title)));
?>
</legend>
</fieldset>
<div id="doc3" class="yui-t7">
  <div id="bd">
    <div class="yui-gf">
      <div class="yui-u first">
        <h3><?php 
echo t("Albums");
?>
</h3>
      </div>
      <div id="gMessage" class="yui-u">
        <div class="gInfo"><?php 
echo t("Select one or more items to edit; drag and drop items to re-order or move between albums");
Esempio n. 14
0
 /**
  * Display an existing comment.
  *  @todo Set proper Content-Type in a central place (REST_Controller::dispatch?).
  *  @see REST_Controller::_show($resource)
  */
 public function _show($comment)
 {
     $item = ORM::factory("item", $comment->item_id);
     access::required("view", $item);
     if ($comment->state != "published") {
         return;
     }
     if (rest::output_format() == "json") {
         print json_encode(array("result" => "success", "data" => array("id" => $comment->id, "author_name" => p::clean($comment->author_name()), "created" => $comment->created, "text" => nl2br(p::purify($comment->text)))));
     } else {
         $view = new Theme_View("comment.html", "fragment");
         $view->comment = $comment;
         print $view;
     }
 }
Esempio n. 15
0
 /**
  * Import a single comment.
  */
 static function import_comment(&$queue)
 {
     $g2_comment_id = array_shift($queue);
     try {
         $g2_comment = g2(GalleryCoreApi::loadEntitiesById($g2_comment_id));
     } catch (Exception $e) {
         return t("Failed to import Gallery 2 comment with id: %id\\%exception", array("id" => $g2_comment_id, "exception" => $e->__toString()));
     }
     $text = $g2_comment->getSubject();
     if ($text) {
         $text .= " ";
     }
     $text .= $g2_comment->getComment();
     // Just import the fields we know about.  Do this outside of the comment API for now so that
     // we don't trigger spam filtering events
     $comment = ORM::factory("comment");
     $comment->author_id = self::map($g2_comment->getCommenterId());
     $comment->guest_name = $g2_comment->getAuthor();
     $comment->item_id = self::map($g2_comment->getParentId());
     $comment->text = self::_transform_bbcode($text);
     $comment->state = "published";
     $comment->server_http_host = $g2_comment->getHost();
     $comment->created = $g2_comment->getDate();
     $comment->save();
     self::map($g2_comment->getId(), $comment->id);
     return t("Imported comment '%comment' for item with id: %id", array("id" => $comment->item_id, "comment" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
 }
Esempio n. 16
0
" class="gThumbnail"
           alt="photo" src="<?php 
echo $child->thumb_url();
?>
"
           width="<?php 
echo $child->thumb_width;
?>
"
           height="<?php 
echo $child->thumb_height;
?>
" />
    </a>
    <h2><?php 
echo p::purify($child->title);
?>
</h2>
    <?php 
echo $theme->thumb_bottom($child);
?>
    <ul class="gMetadata">
      <?php 
echo $theme->thumb_info($child);
?>
    </ul>
  </li>
  <? endforeach ?>
</ul>
<?php 
echo $theme->dynamic_bottom();
<?php

defined("SYSPATH") or die("No direct script access.");
?>
<?
  $item = $theme->item;
  $metaTags = "";
  if (count($tags) > 0) {
    for ($counter=0; $counter<count($tags); $counter++) {
      if ($counter < count($tags)-1) {
        $metaTags = $metaTags . p::clean($tags[$counter]->name) . ",";
      } else {
        $metaTags = $metaTags . p::clean($tags[$counter]->name);
      }
    }  
  }
?>
<META NAME="KEYWORDS" CONTENT="<?php 
echo $metaTags;
?>
">
<META NAME="DESCRIPTION" CONTENT="<?php 
echo nl2br(p::purify($item->description));
?>
">
Esempio n. 18
0
 public function sort()
 {
     access::verify_csrf();
     $itemids = $this->input->post("item");
     $item = ORM::factory("item")->in("id", $itemids[0])->find();
     access::required("view", $item);
     access::required("edit", $item);
     $form = organize::get_sort_edit_form($item);
     if ($form->validate()) {
         $orig = clone $item;
         $item->sort_column = $form->column->value;
         $item->sort_order = $form->direction->value;
         $item->save();
         log::success("content", "Updated album", "<a href=\"albums/{$item->id}\">view</a>");
         $message = t("Saved album %album_title", array("album_title" => p::purify($item->title)));
         print json_encode(array("form" => $form->__toString(), "message" => $message));
     } else {
         print json_encode(array("form" => $form->__toString()));
     }
 }
Esempio n. 19
0
?>
              />
              <? else: ?>
              <?php 
echo t("No thumbnail");
?>
              <? endif ?>
            </a>
          </div>
        </div>
        <p><?php 
echo gallery::date($comment->created);
?>
</p>
           <?php 
echo nl2br(p::purify($comment->text));
?>
      </td>
      <td>
        <ul class="gButtonSetVertical">
        <? if ($comment->state != "unpublished"): ?>
          <li>
            <a href="javascript:set_state('unpublished',<?php 
echo $comment->id;
?>
)"
                class="gButtonLink ui-state-default ui-icon-left">
              <span class="ui-icon ui-icon-check"></span>
              <?php 
echo t("Unapprove");
?>