当前位置: 首页>>代码示例>>PHP>>正文


PHP Images::post方法代码示例

本文整理汇总了PHP中Images::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Images::post方法的具体用法?PHP Images::post怎么用?PHP Images::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Images的用法示例。


在下文中一共展示了Images::post方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_to

 /**
  * upload a file as a image attach to a given anchor
  * to be used in custom "edit_as" script
  * 
  * @global string $context
  * @param object $anchor
  * @param array $file (from $_FILES)
  * @param bool $set_as_thumb
  * @param bool $put
  */
 public static function upload_to($anchor, $file, $set_as_thumb = false, $put = false)
 {
     global $context;
     // attach some image
     $path = Files::get_path($anchor->get_reference(), 'images');
     // $_REQUEST['action'] = 'set_as_icon'; // instruction for image::upload
     if (isset($file) && ($uploaded = Files::upload($file, $path, array('Image', 'upload')))) {
         // prepare image informations
         $image = array();
         $image['image_name'] = $uploaded;
         $image['image_size'] = $file['size'];
         $image['thumbnail_name'] = 'thumbs/' . $uploaded;
         $image['anchor'] = $anchor->get_reference();
         //$combined = array_merge($image, $_FILES);
         // post the image which was uploaded
         if ($image['id'] = Images::post($image)) {
             // successfull post
             $context['text'] .= '<p>' . i18n::s('Following image has been added:') . '</p>' . Codes::render_object('image', $image['id']) . '<br style="clear:left;" />' . "\n";
             // set image as icon and thumbnail
             if ($set_as_thumb) {
                 // delete former icon if any
                 /*if(isset($anchor->item['icon_url'])
                                                         && $anchor->item['icon_url']
                                                         && $match = Images::get_by_anchor_and_name($anchor->get_reference(), pathinfo($anchor->item['icon_url'],PATHINFO_BASENAME))) {
                 
                 
                                                     if($match['id'] != $image['id'])
                                                         Images::delete($match['id']);
                                                 }*/
                 $fields = array('thumbnail_url' => Images::get_thumbnail_href($image), 'icon_url' => Images::get_icon_href($image));
                 if ($put) {
                     $fields['id'] = $_REQUEST['id'];
                     $class = $anchor->get_static_group_class();
                     $class::put_attributes($fields);
                 } else {
                     $_REQUEST = array_merge($_REQUEST, $fields);
                 }
             }
         }
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:51,代码来源:images.php

示例2: submit_image


//.........这里部分代码省略.........
         return NULL;
     }
     // file size
     $file_size = strlen($content);
     // sanity check
     if ($file_size < 7) {
         Logger::remember('agents/messages.php: Short image skipped', $file_name);
         return NULL;
     }
     // sanity check
     if (!$anchor) {
         Logger::remember('agents/messages.php: No anchor to use for submitted image', $file_name);
         return NULL;
     }
     // get anchor data -- this is a mutable object
     $host = Anchors::get($anchor, TRUE);
     if (!is_object($host)) {
         Logger::remember('agents/messages.php: Unknown anchor ' . $anchor, $file_name);
         return NULL;
     }
     // create target folders
     $file_path = Files::get_path($anchor, 'images');
     if (!Safe::make_path($file_path)) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path);
         return NULL;
     }
     if (!Safe::make_path($file_path . '/thumbs')) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path . '/thumbs');
         return NULL;
     }
     $file_path = $context['path_to_root'] . $file_path . '/';
     // save the entity in the file system
     if (!($file = Safe::fopen($file_path . $file_name, 'wb'))) {
         Logger::remember('agents/messages.php: Impossible to open ' . $file_path . $file_name);
         return NULL;
     }
     if (fwrite($file, $content) === FALSE) {
         Logger::remember('agents/messages.php: Impossible to write to ' . $file_path . $file_name);
         return NULL;
     }
     fclose($file);
     // get image information
     if (!($image_information = Safe::GetImageSize($file_path . $file_name))) {
         Safe::unlink($file_path . $file_name);
         Logger::remember('agents/messages.php: No image information in ' . $file_path . $file_name);
         return NULL;
     }
     // we accept only gif, jpeg and png
     if ($image_information[2] != 1 && $image_information[2] != 2 && $image_information[2] != 3) {
         Safe::unlink($file_path . $file_name);
         Logger::remember('agents/messages.php: Rejected image type for ' . $file_path . $file_name);
         return NULL;
     }
     // build a thumbnail
     $thumbnail_name = 'thumbs/' . $file_name;
     // do not stop on error
     include_once $context['path_to_root'] . 'images/image.php';
     if (!Image::shrink($file_path . $file_name, $file_path . $thumbnail_name, FALSE, FALSE)) {
         Logger::remember('agents/messages.php: No thumbnail has been created for ' . $file_path . $file_name);
     }
     // resize the image where applicable
     if (Image::adjust($file_path . $file_name, FALSE)) {
         $file_size = Safe::filesize($file_path . $file_name);
     }
     // all details
     $details = array();
     // image size
     if ($image_information = Safe::GetImageSize($file_path . $file_name)) {
         $details[] = i18n::c('Size') . ': ' . $image_information[0] . ' x ' . $image_information[1];
     }
     // update image description
     $item = array();
     $item['anchor'] = $anchor;
     $item['image_name'] = $file_name;
     $item['thumbnail_name'] = $thumbnail_name;
     $item['image_size'] = $file_size;
     $item['description'] = '';
     if (isset($content_description) && $content_description != $file_name) {
         $item['description'] .= $content_description;
     }
     if (@count($details)) {
         $item['description'] .= "\n\n" . '<p class="details">' . implode("<br />\n", $details) . "</p>\n";
     }
     $item['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
     $item['edit_name'] = $user['nick_name'];
     $item['edit_id'] = $user['id'];
     $item['edit_address'] = $user['email'];
     // create an image record in the database
     include_once $context['path_to_root'] . 'images/images.php';
     if (!($item['id'] = Images::post($item))) {
         Logger::remember('agents/messages.php: Impossible to save image ' . $item['image_name']);
         return NULL;
     }
     if ($context['debug_messages'] == 'Y') {
         Logger::remember('agents/messages.php: Messages::submit_image()', $item, 'debug');
     }
     // insert the image in the anchor page
     $host->touch('image:create', $item['id'], TRUE);
     return 'image:' . $item['id'];
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:messages.php

示例3: array

         // an image has been found
         if (Image::upload($node, $context['path_to_root'] . $file_path . '/', TRUE)) {
             $count++;
             // resize the image where applicable
             Image::adjust($context['path_to_root'] . $file_path . '/' . $node, TRUE, 'standard');
             // if the file does not exist yet
             if (!($item =& Images::get_by_anchor_and_name($anchor->get_reference(), $node))) {
                 // create a new image record for this file
                 $item = array();
                 $item['anchor'] = $anchor->get_reference();
                 $item['image_name'] = $node;
                 $item['thumbnail_name'] = 'thumbs/' . $node;
                 $item['image_size'] = Safe::filesize($file_path . '/' . $node);
                 $item['use_thumbnail'] = 'A';
                 // ensure it is always displayed as a clickable small image
                 $item['id'] = Images::post($item);
             }
             // ensure that the image is in anchor description field
             $nodes[$node] = $item['id'];
         }
     }
     Safe::closedir($handle);
     // embed uploaded images in alphabetical order
     ksort($nodes);
     foreach ($nodes as $name => $id) {
         $anchor->touch('image:create', $id);
     }
 }
 // clear floating thumbnails
 if ($count) {
     $anchor->touch('clear');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php


注:本文中的Images::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。