本文整理汇总了PHP中graphics::can方法的典型用法代码示例。如果您正苦于以下问题:PHP graphics::can方法的具体用法?PHP graphics::can怎么用?PHP graphics::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphics
的用法示例。
在下文中一共展示了graphics::can方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buttons
static function buttons($item, $page_type)
{
$elements = array("left" => array(), "center" => array(), "right" => array(), "additional" => array());
switch ($item->type) {
case "movie":
$edit_title = t("Edit this movie");
$move_title = t("Move this movie to another album");
$cover_title = t("Choose this movie as the album cover");
$delete_title = t("Delete this movie");
break;
case "album":
$edit_title = t("Edit this album");
$move_title = t("Move this album to another album");
$cover_title = t("Choose this album as the album cover");
$delete_title = t("Delete this album");
break;
default:
$edit_title = t("Edit this photo");
$move_title = t("Move this photo to another album");
$cover_title = t("Choose this photo as the album cover");
$delete_title = t("Delete this photo");
break;
}
$csrf = access::csrf_token();
$elements["left"][] = (object) array("title" => $edit_title, "class" => "gDialogLink gButtonLink", "icon" => "ui-icon-pencil", "href" => url::site("quick/form_edit/{$item->id}?page_type={$page_type}"));
if ($item->is_photo() && graphics::can("rotate")) {
$elements["left"][] = (object) array("title" => t("Rotate 90 degrees counter clockwise"), "class" => "gButtonLink", "icon" => "ui-icon-rotate-ccw", "href" => url::site("quick/rotate/{$item->id}/ccw?csrf={$csrf}&page_type={$page_type}"));
$elements["left"][] = (object) array("title" => t("Rotate 90 degrees clockwise"), "class" => "gButtonLink", "icon" => "ui-icon-rotate-cw", "href" => url::site("quick/rotate/{$item->id}/cw?csrf={$csrf}&page_type={$page_type}"));
}
// Don't move photos from the photo page; we don't yet have a good way of redirecting after move
if ($page_type == "album") {
$elements["left"][] = (object) array("title" => $move_title, "class" => "gDialogLink gButtonLink", "icon" => "ui-icon-folder-open", "href" => url::site("move/browse/{$item->id}"));
}
$parent = $item->parent();
if (access::can("edit", $parent)) {
// We can't make this item the highlight if it's an album with no album cover, or if it's
// already the album cover.
if ($item->type == "album" && empty($item->album_cover_item_id) || $item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id || $parent->album_cover_item_id == $item->id) {
$disabledState = " ui-state-disabled";
} else {
$disabledState = " ";
}
$elements["right"][] = (object) array("title" => $cover_title, "class" => "gButtonLink{$disabledState}", "icon" => "ui-icon-star", "href" => url::site("quick/make_album_cover/{$item->id}?csrf={$csrf}&page_type={$page_type}"));
$elements["right"][] = (object) array("title" => $delete_title, "class" => "gDialogLink gButtonLink", "icon" => "ui-icon-trash", "id" => "gQuickDelete", "href" => url::site("quick/form_delete/{$item->id}?csrf={$csrf}&page_type={$page_type}"));
}
if ($item->is_album()) {
$elements["additional"][] = (object) array("title" => t("Add a photo"), "class" => "add_item gDialogLink", "href" => url::site("simple_uploader/app/{$item->id}"));
$elements["additional"][] = (object) array("title" => t("Add an album"), "class" => "add_album gDialogLink", "href" => url::site("form/add/albums/{$item->id}?type=album"));
$elements["additional"][] = (object) array("title" => t("Edit permissions"), "class" => "permissions gDialogLink", "href" => url::site("permissions/browse/{$item->id}"));
}
return $elements;
}
示例2: resize
/**
* Resize an image. Valid options are width, height and master. Master is one of the Image
* master dimension constants.
*
* @param string $input_file
* @param string $output_file
* @param array $options
* @param Item_Model $item (optional)
*/
static function resize($input_file, $output_file, $options, $item = null)
{
graphics::init_toolkit();
module::event("graphics_resize", $input_file, $output_file, $options, $item);
if (@filesize($input_file) == 0) {
throw new Exception("@todo EMPTY_INPUT_FILE");
}
$dims = getimagesize($input_file);
if (max($dims[0], $dims[1]) <= min($options["width"], $options["height"])) {
// Image would get upscaled; do nothing
copy($input_file, $output_file);
} else {
$image = Image::factory($input_file)->resize($options["width"], $options["height"], $options["master"])->quality(module::get_var("gallery", "image_quality"));
if (graphics::can("sharpen")) {
$image->sharpen(module::get_var("gallery", "image_sharpen"));
}
$image->save($output_file);
}
module::event("graphics_resize_completed", $input_file, $output_file, $options, $item);
}
示例3: t
echo url::site("quick/form_edit/{$item->id}?page_type={$page_type}");
?>
"
title="<?php
echo $title;
?>
">
<span class="ui-icon ui-icon-pencil">
<?php
echo $title;
?>
</span>
</a>
<?php
if ($item->is_photo() && graphics::can("rotate")) {
?>
<a class="gButtonLink ui-corner-all ui-state-default" href="<?php
echo url::site("quick/rotate/{$item->id}/ccw?csrf={$csrf}&page_type={$page_type}");
?>
"
title="<?php
echo t("Rotate 90 degrees counter clockwise");
?>
">
<span class="ui-icon ui-icon-rotate-ccw">
<?php
echo t("Rotate 90 degrees counter clockwise");
?>
</span>
</a>
示例4: context_menu
static function context_menu($menu, $theme, $item, $thumb_css_selector)
{
$menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label(t("Options"))->css_class("ui-icon-carat-1-n"));
if (access::can("edit", $item)) {
$page_type = $theme->page_type();
switch ($item->type) {
case "movie":
$edit_title = t("Edit this movie");
$delete_title = t("Delete this movie");
break;
case "album":
$edit_title = t("Edit this album");
$delete_title = t("Delete this album");
break;
default:
$edit_title = t("Edit this photo");
$delete_title = t("Delete this photo");
break;
}
$cover_title = t("Choose as the album cover");
$move_title = t("Move to another album");
$csrf = access::csrf_token();
$options_menu->append(Menu::factory("dialog")->id("edit")->label($edit_title)->css_class("ui-icon-pencil")->url(url::site("quick/form_edit/{$item->id}?page_type={$page_type}")));
if ($item->is_photo() && graphics::can("rotate")) {
$options_menu->append(Menu::factory("ajax_link")->id("rotate_ccw")->label(t("Rotate 90° counter clockwise"))->css_class("ui-icon-rotate-ccw")->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('{$thumb_css_selector}')) }")->url(url::site("quick/rotate/{$item->id}/ccw?csrf={$csrf}&page_type={$page_type}")))->append(Menu::factory("ajax_link")->id("rotate_cw")->label(t("Rotate 90° clockwise"))->css_class("ui-icon-rotate-cw")->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('{$thumb_css_selector}')) }")->url(url::site("quick/rotate/{$item->id}/cw?csrf={$csrf}&page_type={$page_type}")));
}
// Don't move photos from the photo page; we don't yet have a good way of redirecting after
// move
if ($page_type == "album") {
$options_menu->append(Menu::factory("dialog")->id("move")->label($move_title)->css_class("ui-icon-folder-open")->url(url::site("move/browse/{$item->id}")));
}
$parent = $item->parent();
if (access::can("edit", $parent)) {
// We can't make this item the highlight if it's an album with no album cover, or if it's
// already the album cover.
if ($item->type == "album" && empty($item->album_cover_item_id) || $item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id || $parent->album_cover_item_id == $item->id) {
$disabledState = " ui-state-disabled";
} else {
$disabledState = " ";
}
if ($item->parent()->id != 1) {
$options_menu->append(Menu::factory("ajax_link")->id("make_album_cover")->label($cover_title)->css_class("ui-icon-star")->ajax_handler("function(data) { window.location.reload() }")->url(url::site("quick/make_album_cover/{$item->id}?csrf={$csrf}")));
}
$options_menu->append(Menu::factory("dialog")->id("delete")->label($delete_title)->css_class("ui-icon-trash")->css_id("gQuickDelete")->url(url::site("quick/form_delete/{$item->id}?csrf={$csrf}&page_type={$page_type}")));
}
if ($item->is_album()) {
$options_menu->append(Menu::factory("dialog")->id("add_item")->label(t("Add a photo"))->css_class("ui-icon-plus")->url(url::site("simple_uploader/app/{$item->id}")))->append(Menu::factory("dialog")->id("add_album")->label(t("Add an album"))->css_class("ui-icon-note")->url(url::site("form/add/albums/{$item->id}?type=album")))->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->css_class("ui-icon-key")->url(url::site("permissions/browse/{$item->id}")));
}
}
}
示例5: resize
/**
* Resize an image. Valid options are width, height and master. Master is one of the Image
* master dimension constants.
*
* @param string $input_file
* @param string $output_file
* @param array $options
* @param Item_Model $item (optional)
*/
static function resize($input_file, $output_file, $options, $item = null)
{
graphics::init_toolkit();
$temp_file = system::temp_filename("resize_", pathinfo($output_file, PATHINFO_EXTENSION));
module::event("graphics_resize", $input_file, $temp_file, $options, $item);
if (@filesize($temp_file) > 0) {
// A graphics_resize event made an image - move it to output_file and use it.
@rename($temp_file, $output_file);
} else {
// No events made an image - proceed with standard process.
if (@filesize($input_file) == 0) {
throw new Exception("@todo EMPTY_INPUT_FILE");
}
list($input_width, $input_height, $input_mime, $input_extension) = photo::get_file_metadata($input_file);
if ($input_width && $input_height && (empty($options["width"]) || empty($options["height"]) || empty($options["master"]) || max($input_width, $input_height) <= min($options["width"], $options["height"]))) {
// Photo dimensions well-defined, but options not well-defined or would upscale the image.
// Do not resize. Check mimes to see if we can copy the file or if we need to convert it.
// (checking mimes avoids needlessly converting jpg to jpeg, etc.)
$output_mime = legal_file::get_photo_types_by_extension(pathinfo($output_file, PATHINFO_EXTENSION));
if ($input_mime && $output_mime && $input_mime == $output_mime) {
// Mimes well-defined and identical - copy input to output
copy($input_file, $output_file);
} else {
// Mimes not well-defined or not the same - convert input to output
$image = Image::factory($input_file)->quality(module::get_var("gallery", "image_quality"))->save($output_file);
}
} else {
// Resize the image. This also implicitly converts its format if needed.
$image = Image::factory($input_file)->resize($options["width"], $options["height"], $options["master"])->quality(module::get_var("gallery", "image_quality"));
if (graphics::can("sharpen")) {
$image->sharpen(module::get_var("gallery", "image_sharpen"));
}
$image->save($output_file);
}
}
module::event("graphics_resize_completed", $input_file, $output_file, $options, $item);
}
示例6: t
</span>
</a>
<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="close"
disabled="1" title="<?php
echo t("Close Drawer");
?>
" style="display: none">
<span class="ui-icon ui-icon-arrowthickstop-1-s"><?php
echo t("Close Drawer");
?>
</span>
</a>
<?php
if (graphics::can("rotate")) {
?>
<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCcw"
disabled="1" title="<?php
echo t("Rotate 90 degrees counter clockwise");
?>
">
<span class="ui-icon ui-icon-rotate-ccw"><?php
echo t("Rotate 90 degrees counter clockwise");
?>
</span>
</a>
<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCw"
disabled="1" title="<?php
echo t("Rotate 90 degrees clockwise");