本文整理匯總了PHP中Images::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::get方法的具體用法?PHP Images::get怎麽用?PHP Images::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_image
public function action_image($galleryID, $imageID)
{
if (Auth::guest()) {
Session::put('lastURL', URI::full());
return Redirect::to('login');
}
$image = Images::get($imageID);
if ($image != null) {
Images::incrementViews($imageID);
$liked = Likes::has($imageID, Auth::user()->id);
return View::make('home.image')->with('image', $image)->with('galleryID', $galleryID)->with('liked', $liked);
} else {
return "Image does not exists!";
}
}
示例2: transform_reference
/**
* reference another page at this site
*
* The function transforms a local reference (e.g;, [code][user=2][/code])
* to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]),
* adds a title and, sometimes, set a description as well.
*
* @param string any string, maybe with a local reference in it
* @return an array($url, $title, $description) or NULL
*
* @see images/view.php
* @see links/edit.php
* @see shared/codes.php
*/
public static function transform_reference($text)
{
global $context;
// translate this reference to an internal link
if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) {
switch ($matches[1]) {
// article link
case 'article':
if ($item = Articles::get($matches[2])) {
return array(Articles::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// section link
// section link
case 'section':
if ($item = Sections::get($matches[2])) {
return array(Sections::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// file link
// file link
case 'file':
if ($item = Files::get($matches[2])) {
return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name'])));
}
return array('', $text, '');
// image link
// image link
case 'image':
include_once $context['path_to_root'] . 'images/images.php';
if ($item = Images::get($matches[2])) {
return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
}
return array('', $text, '');
// category link
// category link
case 'category':
if ($item = Categories::get($matches[2])) {
return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// user link
// user link
case 'user':
if ($item = Users::get($matches[2])) {
return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
}
return array('', $text, '');
}
}
return array('', $text, '');
}
示例3: touch
/**
* remember the last action for this category
*
* @param string the description of the last action
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*
* @see shared/anchor.php
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no category bound
if (!isset($this->item['id'])) {
return;
}
// sanity check
if (!$origin) {
logger::remember('categories/category.php: unexpected NULL origin at touch()');
return;
}
// components of the query
$query = array();
// append a reference to a new image to the description
if ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
}
}
// also use it as thumnail if none has been defined yet
if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) {
include_once $context['path_to_root'] . 'images/images.php';
if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
// refresh stamp only if image update occurs within 6 hours after last edition
if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) {
$silently = TRUE;
}
// suppress a reference to an image that has been deleted
} elseif ($action == 'image:delete') {
// suppress reference in main description field
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
// suppress references as icon and thumbnail as well
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
if ($url = Images::get_thumbnail_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
}
// set an existing image as the category icon
} elseif ($action == 'image:set_as_icon') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
$query[] = "icon_url = '" . SQL::escape($url) . "'";
}
// also use it as thumnail if none has been defined yet
if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// set an existing image as the category thumbnail
} elseif ($action == 'image:set_as_thumbnail') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_thumbnail_href($image)) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// append a new image, and set it as the article thumbnail
} elseif ($action == 'image:set_as_both') {
//.........這裏部分代碼省略.........
示例4: elseif
* @reference
* @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
*/
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'images.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Images::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// load the skin, maybe with a variant
load_skin('images', $anchor);
// clear the tab we are in, if any
if (is_object($anchor)) {
$context['current_focus'] = $anchor->get_focus();
}
// the path to this page
if (is_object($anchor) && $anchor->is_viewable()) {
$context['path_bar'] = $anchor->get_path_bar();
}
示例5: touch
/**
* remember the last action for this article
*
* This function is called by related items. What does it do?
* - On image creation, the adequate code is added to the description field to let the image be displayed inline
* - On icon selection, the icon field is updated
* - On thumbnail image selection, the thumbnail image field is updated
* - On location creation, some code is inserted in the description field to display location name inline
* - On table creation, some code is inserted in the description field to display the table inline
*
* @see articles/article.php
* @see articles/edit.php
* @see shared/anchor.php
*
* @param string one of the pre-defined action code
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// we make extensive use of comments below
include_once $context['path_to_root'] . 'comments/comments.php';
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no article bound
if (!isset($this->item['id'])) {
return;
}
// delegate to overlay
if (is_object($this->overlay) && $this->overlay->touch($action, $origin, $silently) === false) {
return;
// stop on false
}
// clear floating objects
if ($action == 'clear') {
$this->item['description'] .= ' [clear]';
$query = "UPDATE " . SQL::table_name('articles') . " SET description='" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
SQL::query($query);
return;
}
// get the related overlay, if any
if (!isset($this->overlay)) {
$this->overlay = NULL;
if (isset($this->item['overlay'])) {
$this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']);
}
}
// components of the query
$query = array();
// a new comment has been posted
if ($action == 'comment:create') {
// purge oldest comments
Comments::purge_for_anchor('article:' . $this->item['id']);
// file upload
} elseif ($action == 'file:create' || $action == 'file:upload') {
// actually, several files have been added
$label = '';
if (!$origin) {
// only when comments are allowed
if (!Articles::has_option('no_comments', $this->anchor, $this->item)) {
// remember this as an automatic notification
$fields = array();
$fields['anchor'] = 'article:' . $this->item['id'];
$fields['description'] = i18n::s('Several files have been added');
$fields['type'] = 'notification';
Comments::post($fields);
}
// one file has been added
} elseif (!Codes::check_embedded($this->item['description'], 'embed', $origin) && ($item = Files::get($origin, TRUE))) {
// this file is eligible for being embedded in the page
if (isset($item['file_name']) && Files::is_embeddable($item['file_name'])) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
$label = '[embed=' . $origin . ']';
}
// else add a comment to take note of the upload
} else {
// only when comments are allowed
if (!Articles::has_option('no_comments', $this->anchor, $this->item)) {
// remember this as an automatic notification
$fields = array();
$fields['anchor'] = 'article:' . $this->item['id'];
if ($action == 'file:create') {
$fields['description'] = '[file=' . $item['id'] . ',' . $item['file_name'] . ']';
} else {
$fields['description'] = '[download=' . $item['id'] . ',' . $item['file_name'] . ']';
}
Comments::post($fields);
}
}
}
// we are in some interactive thread
if ($origin && $this->has_option('view_as_chat')) {
// default is to download the file
if (!$label) {
$label = '[download=' . $origin . ']';
//.........這裏部分代碼省略.........
示例6: touch
/**
* remember the last action for this section
*
* @see articles/article.php
* @see shared/anchor.php
*
* @param string the description of the last action
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// we make extensive use of comments below
include_once $context['path_to_root'] . 'comments/comments.php';
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no section bound
if (!isset($this->item['id'])) {
return;
}
// delegate to overlay
if (is_object($this->overlay) && $this->overlay->touch($action, $origin, $silently) === false) {
return;
// stop on false
}
// sanity check
if (!$origin) {
logger::remember('sections/section.php: unexpected NULL origin at touch()');
return;
}
// components of the query
$query = array();
// a new page has been added to the section
if ($action == 'article:publish' || $action == 'article:submit') {
// limit the number of items attached to this section
if (isset($this->item['maximum_items']) && $this->item['maximum_items'] > 10) {
Articles::purge_for_anchor('section:' . $this->item['id'], $this->item['maximum_items']);
}
// a new comment has been posted
} elseif ($action == 'comment:create') {
// purge oldest comments
Comments::purge_for_anchor('section:' . $this->item['id']);
// file upload
} elseif ($action == 'file:create' || $action == 'file:upload') {
// actually, several files have been added
$label = '';
if (!$origin) {
$fields = array();
$fields['anchor'] = 'section:' . $this->item['id'];
$fields['description'] = i18n::s('Several files have been added');
$fields['type'] = 'notification';
Comments::post($fields);
// one file has been added
} elseif (!Codes::check_embedded($this->item['description'], 'embed', $origin) && ($item = Files::get($origin, TRUE))) {
// this file is eligible for being embedded in the page
if (isset($item['file_name']) && Files::is_embeddable($item['file_name'])) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
$label = '[embed=' . $origin . ']';
}
// else add a comment to take note of the upload
} elseif (Comments::allow_creation($this->item, null, 'section')) {
$fields = array();
$fields['anchor'] = 'section:' . $this->item['id'];
if ($action == 'file:create') {
$fields['description'] = '[file=' . $item['id'] . ',' . $item['file_name'] . ']';
} else {
$fields['description'] = '[download=' . $item['id'] . ',' . $item['file_name'] . ']';
}
Comments::post($fields);
}
}
// include flash videos in a regular page
if ($label) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'";
}
// suppress references to a deleted file
} elseif ($action == 'file:delete') {
// suppress reference in main description field
$text = Codes::delete_embedded($this->item['description'], 'download', $origin);
$text = Codes::delete_embedded($text, 'embed', $origin);
$text = Codes::delete_embedded($text, 'file', $origin);
// save changes
$query[] = "description = '" . SQL::escape($text) . "'";
// append a reference to a new image to the description
} elseif ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
//.........這裏部分代碼省略.........
示例7: delete
/**
* delete one image in the database and in the file system
*
* @param int the id of the image to delete
* @return boolean TRUE on success, FALSE otherwise
*/
public static function delete($id)
{
global $context;
// load the row
$item = Images::get($id);
if (!$item['id']) {
Logger::error(i18n::s('No item has been found.'));
return FALSE;
}
// delete the image files silently
$file_path = $context['path_to_root'] . Files::get_path($item['anchor'], 'images');
Safe::unlink($file_path . '/' . $item['image_name']);
Safe::unlink($file_path . '/' . $item['thumbnail_name']);
Safe::rmdir($file_path . '/thumbs');
Safe::rmdir($file_path);
Safe::rmdir(dirname($file_path));
// delete related items
Anchors::delete_related_to('image:' . $id);
// delete the record in the database
$query = "DELETE FROM " . SQL::table_name('images') . " WHERE id = " . SQL::escape($item['id']);
if (SQL::query($query) === FALSE) {
return FALSE;
}
// job done
return TRUE;
}
示例8: touch
/**
* remember the last action for this user
*
* @param string the description of the last action
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*
* @see shared/anchor.php
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no item bound
if (!isset($this->item['id'])) {
return;
}
// sanity check
if (!$origin) {
logger::remember('users/user.php: unexpected NULL origin at touch()');
return;
}
// components of the query
$query = array();
// append a reference to a new image to the description
if ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
}
}
// refresh stamp only if image update occurs within 6 hours after last edition
if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) {
$silently = TRUE;
}
// suppress a reference to an image that has been deleted
} elseif ($action == 'image:delete') {
// suppress reference in main description field
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
// suppress references as icon and thumbnail as well
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
if ($this->item['avatar_url'] == $url) {
$query[] = "avatar_url = ''";
}
}
if ($url = Images::get_thumbnail_href($image)) {
if ($this->item['avatar_url'] == $url) {
$query[] = "avatar_url = ''";
}
}
}
// set an existing image as the user avatar
} elseif ($action == 'image:set_as_avatar') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
$query[] = "avatar_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// set an existing image as the user thumbnail
} elseif ($action == 'image:set_as_thumbnail') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_thumbnail_href($image)) {
$query[] = "avatar_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// append a new image
} elseif ($action == 'image:set_as_both') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
}
// do not remember minor changes
$silently = TRUE;
// add a reference to a location in the article description
} elseif ($action == 'location:create') {
if (!Codes::check_embedded($this->item['description'], 'location', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [location=' . $origin . ']') . "'";
}
// suppress a reference to a location that has been deleted
} elseif ($action == 'location:delete') {
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'location', $origin)) . "'";
// add a reference to a new table in the user description
} elseif ($action == 'table:create') {
if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
//.........這裏部分代碼省略.........
示例9: render_object
/**
* render a link to an object
*
* Following types are supported:
* - article - link to an article page
* - category - link to a category page
* - comment - link to a comment page
* - download - link to a download page
* - file - link to a file page
* - flash - display a file as a native flash object, or play a flash video
* - go
* - image - display an in-line image
* - next - link to an article page
* - previous - link to an article page
* - section - link to a section page
* - server - link to a server page
* - user - link to a user page
*
* @param string the type
* @param string the id, with possible options or variant
* @return string the rendered text
**/
public static function render_object($type, $id)
{
global $context;
$id = Codes::fix_tags($id);
// depending on type
switch ($type) {
// link to an article
case 'article':
// maybe an alternate title has been provided
$attributes = preg_split("/\\s*,\\s*/", $id, 2);
$id = $attributes[0];
// load the record from the database
if (!($item = Articles::get($id))) {
$output = '[article=' . $id . ']';
} else {
// ensure we have a label for this link
if (isset($attributes[1])) {
$text = $attributes[1];
$type = 'basic';
} else {
$text = Skin::strip($item['title']);
}
// make a link to the target page
$url = Articles::get_permalink($item);
// return a complete anchor
$output =& Skin::build_link($url, $text, $type);
}
return $output;
// insert article description
// insert article description
case 'article.description':
// maybe an alternate title has been provided
$attributes = preg_split("/\\s*,\\s*/", $id, 2);
$id = $attributes[0];
// load the record from the database
if (!($item = Articles::get($id))) {
$output = '[article.description=' . $id . ']';
} else {
// ensure we have a label for this link
if (isset($attributes[1])) {
$text = $attributes[1];
$type = 'basic';
} else {
$text = Skin::strip($item['title']);
}
// make a link to the target page
$url = Articles::get_permalink($item);
// return a complete anchor
$output =& Skin::build_link($url, $text, 'article');
// the introduction text, if any
$output .= BR . Codes::beautify($item['introduction']);
// load overlay, if any
if (isset($item['overlay']) && $item['overlay']) {
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get text related to the overlay, if any
if (is_object($overlay)) {
$output .= $overlay->get_text('view', $item);
}
}
// the description, which is the actual page body
$output .= '<div>' . Codes::beautify($item['description']) . '</div>';
}
return $output;
// link to a category
// link to a category
case 'category':
// maybe an alternate title has been provided
$attributes = preg_split("/\\s*,\\s*/", $id, 2);
$id = $attributes[0];
// load the record from the database
if (!($item = Categories::get($id))) {
$output = '[category=' . $id . ']';
} else {
// ensure we have a label for this link
if (isset($attributes[1])) {
$text = $attributes[1];
$type = 'basic';
} else {
//.........這裏部分代碼省略.........