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


PHP Model_Location::delete_icon方法代码示例

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


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

示例1: action_icon

 public function action_icon()
 {
     //get icon
     if (isset($_FILES['location_icon'])) {
         $icon = $_FILES['location_icon'];
     } else {
         $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'index')));
     }
     $location = new Model_Location($this->request->param('id'));
     if (core::config('image.aws_s3_active')) {
         require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
         $s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
     }
     if (core::post('icon_delete') and $location->delete_icon() == TRUE) {
         Alert::set(Alert::SUCCESS, __('Icon deleted.'));
         $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $location->id_location)));
     }
     // end of icon delete
     if (!Upload::valid($icon) or !Upload::not_empty($icon) or !Upload::type($icon, explode(',', core::config('image.allowed_formats'))) or !Upload::size($icon, core::config('image.max_image_size') . 'M')) {
         if (Upload::not_empty($icon) && !Upload::type($icon, explode(',', core::config('image.allowed_formats')))) {
             Alert::set(Alert::ALERT, $icon['name'] . ' ' . sprintf(__('Is not valid format, please use one of this formats "%s"'), core::config('image.allowed_formats')));
             $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $location->id_location)));
         }
         if (!Upload::size($icon, core::config('image.max_image_size') . 'M')) {
             Alert::set(Alert::ALERT, $icon['name'] . ' ' . sprintf(__('Is not of valid size. Size is limited to %s MB per image'), core::config('image.max_image_size')));
             $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $location->id_location)));
         }
         Alert::set(Alert::ALERT, $icon['name'] . ' ' . __('Image is not valid. Please try again.'));
         $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $location->id_location)));
     } else {
         if ($icon != NULL) {
             // saving/uploading img file to dir.
             $path = 'images/locations/';
             $root = DOCROOT . $path;
             //root folder
             $icon_name = $location->seoname . '.png';
             // if folder does not exist, try to make it
             if (!file_exists($root) and !@mkdir($root, 0775, true)) {
                 // mkdir not successful ?
                 Alert::set(Alert::ERROR, __('Image folder is missing and cannot be created with mkdir. Please correct to be able to upload images.'));
                 return;
                 // exit function
             }
             // save file to root folder, file, name, dir
             if ($file = Upload::save($icon, $icon_name, $root)) {
                 // put icon to Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     $s3->putObject($s3->inputFile($file), core::config('image.aws_s3_bucket'), $path . $icon_name, S3::ACL_PUBLIC_READ);
                 }
                 // update location info
                 $location->has_image = 1;
                 $location->last_modified = Date::unix2mysql();
                 $location->save();
                 Alert::set(Alert::SUCCESS, $icon['name'] . ' ' . __('Icon is uploaded.'));
             } else {
                 Alert::set(Alert::ERROR, $icon['name'] . ' ' . __('Icon file could not been saved.'));
             }
             $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $location->id_location)));
         }
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:61,代码来源:location.php


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