當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UploadField::handle方法代碼示例

本文整理匯總了PHP中UploadField::handle方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadField::handle方法的具體用法?PHP UploadField::handle怎麽用?PHP UploadField::handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UploadField的用法示例。


在下文中一共展示了UploadField::handle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * {@inheritdoc}
  */
 public function handle(\ElggEntity $entity)
 {
     $this->tmp_icon_sizes = array();
     // make sure we do not duplicate icon creation
     elgg_register_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'), 999);
     $result = parent::handle($entity);
     elgg_unregister_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'));
     if (!$result) {
         return $entity;
     }
     $shortname = $this->getShortname();
     $upload = $this->getValues($entity);
     $icon_sizes = hypeApps()->iconFactory->getSizes($upload);
     $custom_icon_sizes = (array) $this->input_vars->{"icon_sizes"};
     $icon_sizes = array_merge($icon_sizes, $custom_icon_sizes);
     if (empty($icon_sizes)) {
         return $entity;
     }
     $image_upload_crop_coords = (array) get_input('image_upload_crop_coords', array());
     $ratio_coords = (array) elgg_extract($shortname, $image_upload_crop_coords, array());
     list($master_width, $master_height) = getimagesize($_FILES[$shortname]['tmp_name']);
     foreach ($icon_sizes as $icon_name => $icon_size) {
         $ratio = (int) $icon_size['w'] / (int) $icon_size['h'];
         $coords = (array) elgg_extract("{$ratio}", $ratio_coords, array());
         $x1 = (int) elgg_extract('x1', $coords);
         $x2 = (int) elgg_extract('x2', $coords);
         $y1 = (int) elgg_extract('y1', $coords);
         $y2 = (int) elgg_extract('y2', $coords);
         if ($x2 <= $x1 || $y2 <= $y1) {
             // do not crop
             $this->tmp_coords = false;
         } else {
             $this->tmp_coords = $coords;
             $this->tmp_coords['master_width'] = $master_width;
             $this->tmp_coords['master_height'] = $master_height;
         }
         if (!isset($icon_size['name'])) {
             $icon_size['name'] = $icon_name;
         }
         $this->tmp_icon_sizes = array($icon_size['name'] => $icon_size);
         $options = array('icon_sizes' => $this->tmp_icon_sizes, 'coords' => $this->tmp_coords);
         elgg_register_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'), 999);
         if (hypeApps()->iconFactory->create($upload, $_FILES[$shortname]['tmp_name'], $options)) {
             foreach (array('x1', 'x2', 'y1', 'y2') as $c) {
                 $upload->{"_coord_{$ratio}_{$coord}"} = elgg_extract($c, $coords, 0);
                 if ($ratio === 1) {
                     $upload->{$c} = elgg_extract($c, $coords, 0);
                 }
             }
         }
         elgg_unregister_plugin_hook_handler('entity:icon:sizes', 'object', array($this, 'getIconSizes'));
     }
     $upload->icontime = time();
     return $entity;
 }
開發者ID:hypejunction,項目名稱:hypeprototyper,代碼行數:58,代碼來源:ImageUploadField.php


注:本文中的UploadField::handle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。