本文整理汇总了PHP中gallery类的典型用法代码示例。如果您正苦于以下问题:PHP gallery类的具体用法?PHP gallery怎么用?PHP gallery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gallery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_menu
public function admin_menu() {
$menu = Menu::factory("root");
gallery::admin_menu($menu, $this);
module::event("admin_menu", $menu, $this);
$menu->compact();
return $menu;
}
示例2: site_menu
public function site_menu()
{
$menu = Menu::factory("root");
gallery::site_menu($menu, $this);
module::event("site_menu", $menu, $this);
return $menu->compact();
}
示例3: css
/**
* Add a css file to the combined css list.
* @param $file the file name or path of the script to include. If a path is specified then
* it needs to be relative to DOCROOT. Just specifying a file name will result
* in searching Kohana's cascading file system.
*/
public function css($file)
{
if ($path = gallery::find_file("css", $file, false)) {
$this->css[$path] = 1;
} else {
Kohana_Log::add("error", "Can't find css file: {$file}");
}
}
示例4: __construct
/**
* Kohana 2.4 introduces a new connection parameter. If it's not specified, make sure that we
* define it here to avoid an error later on.
*
* @todo: add an upgrade path to modify var/database.php so that we can avoid doing this at
* runtime.
*/
protected function __construct(array $config)
{
if (!isset($config["connection"]["params"])) {
$config["connection"]["params"] = null;
}
parent::__construct($config);
if (gallery::show_profiler()) {
$this->config['benchmark'] = true;
}
}
示例5: index
public function index()
{
$input = Input::instance();
$reply = GalleryRemoteReply::factory(gallery_remote::GR_STAT_SUCCESS);
if ($this->_check_protocol($input, $reply)) {
$reply->set('debug_gallery_version', gallery::version_string());
$reply->set('debug_user', identity::active_user()->name);
$reply->set('debug_user_type', 'Gallery_User');
$reply->set('debug_user_already_logged_in', identity::active_user()->id != identity::guest()->id ? '1' : '');
$reply->set('server_version', '2.15');
$cmd = trim($input->post('cmd'));
if ($cmd == 'login') {
$this->_login($input, $reply);
} else {
if (self::isloggedin()) {
switch ($cmd) {
case 'no-op':
$reply->set('status_text', 'Noop command successful.');
$reply->send();
break;
case 'fetch-albums':
case 'fetch-albums-prune':
$this->_fetch_albums_prune($input, $reply);
break;
case 'new-album':
$this->_new_album($input, $reply);
break;
case 'album-properties':
$this->_album_properties($input, $reply);
break;
case 'add-item':
$this->_add_item($input, $reply);
break;
case 'move-album':
$this->_move_album($input, $reply);
break;
case 'increment-view-count':
$this->_increment_view_count($input, $reply);
break;
case 'image-properties':
$this->_image_properties($input, $reply);
break;
case 'fetch-album-images':
$this->_fetch_album_images($input, $reply);
break;
default:
$reply->send(gallery_remote::UNKNOWN_CMD);
}
} else {
$reply->send(gallery_remote::LOGIN_MISSING);
}
}
}
}
示例6: css
/**
* If css combining is enabled, add this css to the list of css that will be
* combined into a single style element. When combined, the order of style elements
* is preserved.
*
* @param $file the file name or path of the css to include. If a path is specified then
* it needs to be relative to DOCROOT. Just specifying a file name will result
* in searching Kohana's cascading file system.
* @param $group the group of css to combine this with. defaults to "core"
*/
public function css($file, $group = "core")
{
if ($path = gallery::find_file("css", $file, false)) {
if (isset($this->combine_queue["css"])) {
$this->combine_queue["css"][$group][$path] = 1;
} else {
return html::stylesheet($path);
}
} else {
Kohana_Log::add("error", "Can't find css file: {$file}");
}
}
示例7: activate
static function activate()
{
gallery::set_path_env(array(getenv("PATH"), module::get_var("gallery", "extra_binary_paths")));
$exiv = exec('which exiv2');
if ($exiv == '') {
# Proper warning
} else {
module::set_var("author", "exiv_path", $exiv);
$out = array();
exec("{$exiv} -V", $out);
$parts = split(' ', $out[0]);
module::set_var("author", "exiv_version", $parts[1]);
}
}
示例8: report_item_conversion_support
static function report_item_conversion_support()
{
if (gallery::RELEASE_CHANNEL == "release") {
if (version_compare(gallery::VERSION, rawphoto_version::MIN_RELEASE_VERSION, ">=")) {
site_status::clear("rawphoto_needs_item_conversion_support");
} else {
site_status::warning(t("The <em>Raw Photos</em> module requires Gallery %version or higher.", array("version" => rawphoto_version::MIN_RELEASE_VERSION)), "rawphoto_needs_item_conversion_support");
}
} else {
if (version_compare(gallery::build_number(), rawphoto_version::MIN_BUILD_NUMBER, ">=")) {
site_status::clear("rawphoto_needs_item_conversion_support");
} else {
site_status::warning(t("The <em>Raw Photos</em> module requires Gallery %version, build %build_number or higher.", array("version" => gallery::VERSION, "build_number" => rawphoto_version::MIN_BUILD_NUMBER)), "rawphoto_needs_item_conversion_support");
}
}
}
示例9: add_image
/**
* Add image to item
* @return void
* @param integer id of item
* @param string dir with images
*/
public function add_image($item, $dir)
{
// Check for user permission
if (user::is_got()) {
$this->set_title(Kohana::lang('gallery.add_image'));
$this->add_breadcrumb(Kohana::lang('gallery.add_image'), url::current());
// Set redirect URL
if (isset($_POST['redirect'])) {
$redirect = $_POST['redirect'];
} else {
$redirect = request::referrer();
}
$form = array('image' => '', 'redirect' => $redirect);
$errors = array();
if (isset($_FILES)) {
$files = new Validation($_FILES);
// Rules
$files->add_rules('image', 'upload::valid', 'upload::required', 'upload::type[jpg,jpeg]', 'upload::size[500K]');
if ($files->validate()) {
// Temporary file
$filename = upload::save('image');
// Get new name
$id = gallery::get_image_new_name($item, $dir);
// Save original and thumb
Image::factory($filename)->save('./data/' . $dir . '/' . $item . '_' . $id . '.jpg');
Image::factory($filename)->resize(128, 128, Image::AUTO)->quality(85)->save('./data/' . $dir . '/' . $item . '_' . $id . '_m.jpg');
// Remove the temporary file
unlink($filename);
url::redirect($form['redirect']);
} else {
// Repopulate form with error and original values
$form = arr::overwrite($form, $files->as_array());
$errors = $files->errors('gallery_errors');
}
}
// View
$this->template->content = new View('admin/add_image');
$this->template->content->errors = $errors;
$this->template->content->form = $form;
} else {
url::redirect('/denied');
}
}
示例10: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "metadata":
if ($theme->item()) {
$block = new Block();
$block->css_id = "g-metadata";
$block->title = $theme->item()->is_album() ? t("Album info") : ($theme->item()->is_movie() ? t("Movie info") : t("Photo info"));
$block->content = new View("info_block.html");
if ($theme->item->title && module::get_var("info", "show_title")) {
$info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title));
}
if ($theme->item->description && module::get_var("info", "show_description")) {
$info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description)));
}
if (!$theme->item->is_album() && module::get_var("info", "show_name")) {
$info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name));
}
if ($theme->item->captured && module::get_var("info", "show_captured")) {
$info["captured"] = array("label" => t("Captured:"), "value" => gallery::date_time($theme->item->captured));
}
if ($theme->item->owner && module::get_var("info", "show_owner")) {
$display_name = $theme->item->owner->display_name();
if ($theme->item->owner->url) {
$info["owner"] = array("label" => t("Owner:"), "value" => html::anchor(html::clean($theme->item->owner->url), html::clean($display_name)));
} else {
$info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name));
}
}
if ($theme->item->width && $theme->item->height && module::get_var("info", "show_dimensions")) {
$info["size"] = array("label" => t("Dimensions:"), "value" => t("%width x %height px", array("width" => $theme->item->width, "height" => $theme->item->height)));
}
$block->content->metadata = $info;
module::event("info_block_get_metadata", $block, $theme->item);
}
break;
}
return $block;
}
示例11: get
static function get($block_id, $theme)
{
$block = new Block();
switch ($block_id) {
case "simple":
$item = $theme->item;
if (!$item or !$item->is_photo()) {
return "";
}
$block->css_id = "g-about-this-photo";
$block->title = t("About this photo");
$block->content = new View("about_this_photo.html");
// exif API doesn't give easy access to individual keys, so do this the hard way
if (module::is_active("exif")) {
$exif = ORM::factory("exif_record")->where("item_id", "=", $theme->item()->id)->find();
if ($exif->loaded()) {
$exif = unserialize($exif->data);
$timestamp = strtotime($exif["DateTime"]);
//$block->content->date = gallery::date($timestamp);
$block->content->date = date('D j M Y', $timestamp);
$block->content->time = gallery::time($timestamp);
}
}
$block->content->vcount = $theme->item()->view_count;
// IPTC - copied more or less from iptc.php
if (module::is_active("iptc")) {
$record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find();
if ($record->loaded()) {
$record = unserialize($record->data);
$block->content->source = $record["Source"];
$block->content->caption = $record["Caption"];
}
}
if (module::is_active("tag")) {
$block->content->tags = tag::item_tags($theme->item());
}
break;
}
return $block;
}
示例12: reply
static function reply($data = array())
{
Session::instance()->abort_save();
header("X-Gallery-API-Version: " . rest::API_VERSION);
switch (Input::instance()->get("output", "json")) {
case "json":
json::reply($data);
break;
case "jsonp":
if (!($callback = Input::instance()->get("callback", ""))) {
throw new Rest_Exception("Bad Request", 400, array("errors" => array("callback" => "missing")));
}
if (preg_match('/^[$A-Za-z_][0-9A-Za-z_]*$/', $callback) == 1) {
header("Content-type: application/javascript; charset=UTF-8");
print "{$callback}(" . json_encode($data) . ")";
} else {
throw new Rest_Exception("Bad Request", 400, array("errors" => array("callback" => "invalid")));
}
break;
case "html":
header("Content-type: text/html; charset=UTF-8");
if ($data) {
$html = preg_replace("#([\\w]+?://[\\w]+[^ \\'\"\n\r\t<]*)#ise", "'<a href=\"\\1\" >\\1</a>'", var_export($data, 1));
} else {
$html = t("Empty response");
}
print "<pre>{$html}</pre>";
if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
}
break;
default:
throw new Rest_Exception("Bad Request", 400);
}
}
示例13: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "metadata":
if ($theme->item()) {
$block = new Block();
$block->css_id = "g-metadata";
$block->title = $theme->item()->is_album() ? t("Album info") : t("Photo info");
$block->content = new View("info_block.html");
if ($theme->item->title && module::get_var("info", "show_title")) {
$info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title));
}
if ($theme->item->description && module::get_var("info", "show_description")) {
$info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description)));
}
if (!$theme->item->is_album() && module::get_var("info", "show_name")) {
$info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name));
}
if ($theme->item->captured && module::get_var("info", "show_captured")) {
$info["captured"] = array("label" => t("Captured:"), "value" => gallery::date_time($theme->item->captured));
}
if ($theme->item->owner && module::get_var("info", "show_owner")) {
$display_name = $theme->item->owner->display_name();
if ($theme->item->owner->url) {
$info["owner"] = array("label" => t("Owner:"), "value" => "<a href=\"{$theme->item->owner->url}\">" . html::clean($display_name) . "</a>");
} else {
$info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name));
}
}
$block->content->metadata = $info;
module::event("info_block_get_metadata", $block, $theme->item);
}
break;
}
return $block;
}
示例14: tag_ItemList
/**
* Display list of items associated with page and of specified type
*
* @param array $tag_params
* @param array $children
*/
public function tag_ItemList($tag_params, $children, $type)
{
$manager = UserPageItemsManager::getInstance();
$page_id = isset($tag_params['page']) ? fix_id($tag_params['page']) : null;
// create query conditions
$conditions = array();
if (!is_null($page_id)) {
$conditions['page'] = $page_id;
}
$conditions['type'] = $type;
// get items from database
$items = $manager->getItems(array('id', 'item'), $conditions);
if ($type == user_page::VIDEO) {
// create template
$template = $this->loadTemplate($tag_params, 'page_items_video.xml');
// connect tag handlers
if (class_exists('youtube')) {
$module = youtube::getInstance();
$template->registerTagHandler('_video', $module, 'tag_Video');
}
} else {
// create template
$template = $this->loadTemplate($tag_params, 'page_items_gallery.xml');
// connect tag handlers
if (class_exists('gallery')) {
$module = gallery::getInstance();
$template->registerTagHandler('_gallery', $module, 'tag_Group');
}
}
// parse items
if (count($items) > 0) {
foreach ($items as $item) {
$params = array('item' => $item->item, 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('user_pages_items_delete', 400, $this->getLanguageConstant('title_delete_page'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'page_items_delete'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例15: credits
static function credits()
{
$version_string = SafeString::of_safe_html('<bdo dir="ltr">Gallery ' . gallery::version_string() . '</bdo>');
return "<li class=\"g-first\">" . t(module::get_var("gallery", "credits"), array("url" => "http://gallery.menalto.com", "gallery_version" => $version_string)) . "</li>";
}