if ($model->save()) {
                if (isset($_POST['delete_current_image']) && $_POST['delete_current_image'] == 'on') {
                    $model->removeImage();
                }
                $model->saveImage();
                $this->redirect(array('view', 'id' => $model->id));
            }
        }
        $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess));
    }
    /**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
    public function actionDelete($id)
    {
        if (Yii::app()->request->isPostRequest) {
            // we only allow deletion via POST request
            $model = $this->loadModel($id);
            if (!empty($model->large_image)) {
                $ImageProcessing = new ImageProcessing();
                $ImageProcessing->delete(YII_UPLOAD_DIR . '/' . Banners::$folderUpload . "/" . $model->large_image);
                //                                $ImageProcessing->delete(Banners::$folderUpload."/".$model->large_image);
                //                                $ImageProcessing->delete(Banners::$folderUpload."/thumbs/".$model->large_image);
            }
Exemple #2
0
 /**
  * <Jason>
  * <Email: pmhai90@gmail.com>
  */
 public static function resizeCover($model)
 {
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/upload/admin/' . self::$folderUpload . '/' . $model->id;
     $ImageProcessing->file = $model->cover;
     $ImageProcessing->thumbs = Memodule::$aSizeCover;
     $ImageProcessing->create_thumbs();
 }
Exemple #3
0
function ctrl_process_image() {
    include_lib('image_processing/image_processing.php');
    $imageP = new ImageProcessing();
    $preset = param(1);

    if (param(2)=='ext') {
        $file = 'http://'.param(3);
    } else {
        $file = cfg('projects_dir').param(2).'/'.param(3);
    }
    
    $imageP->show($file,$preset);
}
Exemple #4
0
 private static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new ImageProcessing();
     }
     return self::$instance;
 }
 /**
  * Jun 07, 2014 - ANH DUNG
  * To do: save file 
  * @param: $model is model ProGlobalEnquiry
  * @param: $fieldName file_name
  * @return: name of image upload/global_enquiry
  */
 public static function saveFile($model, $fieldName)
 {
     if (is_null($model->{$fieldName})) {
         return '';
     }
     $aDate = explode('-', $model->date_only);
     $pathUpload = ProGlobalEnquiry::$folderUpload . "/{$aDate['0']}/{$aDate['1']}/{$aDate['2']}";
     $ext = $model->{$fieldName}->getExtensionName();
     $file_name_slug = strtolower(MyFunctionCustom::slugify($model->{$fieldName}->getName()));
     $file_name_slug = str_replace(strtolower($ext), '', $file_name_slug);
     $model->file_name_slug = $file_name_slug;
     $fileName = date('Y-m-d');
     $fileName = time() . '-' . ActiveRecord::randString() . '.' . $ext;
     $imageProcessing = new ImageProcessing();
     $imageProcessing->createDirectoryByPath($pathUpload);
     $model->{$fieldName}->saveAs($pathUpload . '/' . $fileName);
     $model->{$fieldName} = $fileName;
     return $fileName;
 }
Exemple #6
0
 public function createAndSendRadarGIF($radar_code, $image_radius_code)
 {
     $radar_string = BoM::getBoMRadarString($radar_code, $image_radius_code);
     $web_image_paths = BoM::getRadarTransparencies($radar_code, $image_radius_code);
     $file_path = self::getNewLocalFilePath($web_image_paths);
     if (count($web_image_paths) < 2) {
         \GroupBot\Telegram::talk($this->chat_id, emoji(0x274c) . " Something went wrong getting the radar images fam. The radar might be down. Check here to see if it's working: \n \nhttp://www.bom.gov.au/products/" . $radar_string . ".loop.shtml#skip");
         return false;
     }
     if (!$this->telegram->sendIfExists($file_path)) {
         \GroupBot\Telegram::sendChatSendingPhotoStatus($this->chat_id);
         ImageProcessing::createBackground($radar_string);
         $images = ImageProcessing::overlay($web_image_paths, $radar_string);
         ImageProcessing::animate($images, $file_path);
         $this->telegram->sendGIFThroughTelegram($file_path);
     }
     return true;
 }
Exemple #7
0
<?php

if ($index % 2 == 0) {
    ?>
<div class="grid">
<?php 
}
?>
    <?php 
$cmsFormater = new CmsFormatter();
$mDefaultPhoto = Listing::getDefaultImgListing($data->id);
$linkImage = ImageProcessing::bindImageByModel($mDefaultPhoto, '120', '96');
?>
    <div class="item">
        <div class="image">
            <div class="img-box"><img src="<?php 
echo $linkImage;
?>
" alt="image" /></div>
            <p><a href="#" class="ico-check">Select to Enquire</a></p>
            <p><a href="javascript:void(0);" data-listing-id="<?php 
echo $data->id;
?>
" class="ico-star shortlist">Shortlist</a></p>
        </div>
        <div class="description">
            <h3><a href="<?php 
echo Yii::app()->createAbsoluteUrl('site/listingdetail', array('slug' => $data->slug));
?>
">
                    <?php 
Exemple #8
0
  */
 public function formatLandLorIdType($model)
 {
     if (isset(Users::$aIdType[$model->id_type])) {
         return Users::$aIdType[$model->id_type];
     }
     return '';
 }
 /**
  * @Author: ANH DUNG Apr 02, 2014
  * @Todo: format upload_employment_pass_passport Tenant at BE 
  * @Param: $model model user
  */
 public function formatEmploymentPassPassport($data)
 {
Exemple #9
0
 * ------------------------------------------------------------
 */
$src = '';
$username = '';
$phone = '';
$srcCompany = '';
$agent_cea = '';
$company = '';
$CEALicenseNo = '';
if (is_numeric($agent_id)) {
    $mUser = Users::model()->findByPk($agent_id);
    if ($mUser) {
        $src = ImageProcessing::bindImageByModel($mUser, 100, 100, array('avatar' => 1));
        $username = $mUser->title . ' ' . $mUser->first_name . ' ' . $mUser->last_name;
        $phone = $mUser->phone;
        $srcCompany = ImageProcessing::bindImageByModel($mUser, 106, 75, array('agent_company_logo' => 1));
        $agent_cea = $mUser->agent_cea;
        $company = $mUser->agent_company_name;
        $CEALicenseNo = $mUser->license;
    }
}
?>
<h2 class="title-2">Contact Agent</h2>
 <div class="contact-agent contact-agent-<?php 
echo $position;
?>
 clearfix">
     <div class="agent-left agent-left-<?php 
echo $position;
?>
">
Exemple #10
0
echo $form->labelEx($model, 'cover');
?>
        <?php 
echo $form->fileField($model, 'imageFile');
?>
        <span class='errorMessage'>( *.jpg , *.gif , *.png )( MaxSize : 3M )(width: 217px,height: 194px)</span>
        <?php 
echo Yii::t('translation', $form->error($model, 'imageFile'));
?>
	</div>
    <?php 
if ($action == 'update') {
    ?>
        <div class="column" style="width: 98%; padding:15px 0 15px 0;">
            <img src="<?php 
    echo ImageProcessing::bindImageByModel($model, 217, 194, 'cover');
    ?>
"  style="width:110px;margin-left: 118px;";/>
            <!--<img src="<?php 
    echo Yii::app()->createAbsoluteUrl('/upload/admin/module/' . $model->id . '/' . $model->cover);
    ?>
"  style="width:110px;margin-left: 118px;";/>-->
        </div>
    <?php 
}
?>
    
    
	<div class="row">
		<?php 
echo Yii::t('translation', $form->labelEx($model, 'status'));
Exemple #11
0
 //            }
 //        }
 //        else{
 //             if ($this->banner_type == TOP || $this->banner_type == BOTTOM) {
 //                $ImageProcessing->file = $this->large_image;
 //                $ImageProcessing->thumbs = self::$aSizeBannerTop;    //resize Of banner
 //                $ImageProcessing->create_thumbs();
 //             }
 //             else{
 //                 $ImageProcessing->file = $this->large_image;
 //                $ImageProcessing->thumbs = self::$aSizeBannerMiddle;    //resize Of banner
 //                $ImageProcessing->create_thumbs();
 //             }
Exemple #12
0
                    <label class="lb">Avatar :</label>
                    <div class="group-upload">

                        <?php 
echo $form->fileField($model, 'avatar', array());
?>
                        <span>Only <?php 
echo Users::$AllowFileAvatar;
?>
 are allow. Recommended Dimension:  66 px x 65 px</span>
                        <?php 
if (!$model->isNewRecord && $model->avatar != '') {
    $res = '';
    //                            $file = ROOT."/".Users::$folderUpload."/"."$model->id/".$model->avatar;
    //                            if(file_exists($file) && !empty($model->avatar)){
    $link = ImageProcessing::bindImageByModel($model, null, null, array('avatar' => 1));
    $res = "<a href='{$link}' class='show-image' target='_blank'>{$model->avatar}</a>";
    //                            }
    ?>
                            <p style="text-align: left;padding-left: 222px;">
                                <br>
                                <span>Current File: <?php 
    echo $res;
    ?>
</span>
                            </p>
                            <p style="text-align: left;padding-left: 222px;">
                                <br/> <input type="checkbox" name="delete_current_image" class="delete_current_image">
                                &nbsp;&nbsp;&nbsp;Delete current avartar
                            </p>
            
Exemple #13
0
		<?php 
echo Yii::t('translation', $form->labelEx($model, 'avatar'));
?>
		<?php 
echo $form->fileField($model, 'avatar', array());
?>
                <span>Only <?php 
echo Users::$AllowFileAvatar;
?>
 are allow. Recommended Dimension:  66 px x 65 px</span>
                <?php 
if (!$model->isNewRecord && $model->avatar != '') {
    ?>
                    <p style="text-align: left;padding-left: 170px;">
                        <img src="<?php 
    echo ImageProcessing::bindImageByModel($model, 100, 100, array('avatar' => 1));
    ?>
">                            
                        <br/> 
                        <input type="checkbox" name="delete_current_image" class="delete_current_image">
                        Delete Current Avatar
                    </p>
                    <script>
                        $('.delete_current_image').click(function() {
                            if ($(this).is(':checked')) {
                                $(this).parent('p').parent('div').find('input:file').hide().val('');
                            } else
                                $(this).parent('p').parent('div').find('input:file').show();
                        });

Exemple #14
0
 /**
  * <Jason>
  * 09-08-2013
  * To do: deleteImage of category
  */
 public static function deleteImage($model, $is_home_page = false)
 {
     $model = Pages::model()->findByPk($model->id);
     if ($is_home_page == true) {
         if (is_null($model) || empty($model->thumb_image)) {
             return;
         }
         $ImageProcessing = new ImageProcessing();
         $ImageProcessing->folder = '/upload/admin/pages/' . $model->id;
         $ImageProcessing->delete($ImageProcessing->folder . '/' . $model->thumb_image);
         foreach (Pages::$aSizeHomePage as $key => $value) {
             $ImageProcessing->delete($ImageProcessing->folder . '/' . $key . '/' . $model->thumb_image);
         }
     } else {
         if (is_null($model) || empty($model->featured_image)) {
             return;
         }
         $ImageProcessing = new ImageProcessing();
         $ImageProcessing->folder = '/upload/admin/pages/' . $model->id;
         $ImageProcessing->delete($ImageProcessing->folder . '/' . $model->featured_image);
         foreach (Pages::$aSizeBanner as $key => $value) {
             $ImageProcessing->delete($ImageProcessing->folder . '/' . $key . '/' . $model->featured_image);
         }
     }
 }
Exemple #15
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     try {
         $model = Pages::model()->findbyPk($id);
         $model->scenario = 'update';
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         $old_image = $model->featured_image;
         $old_home_page = $model->thumb_image;
         if (isset($_POST['Pages'])) {
             $oldImg = $model->banner;
             $model->attributes = $_POST['Pages'];
             $uploadFile = CUploadedFile::getInstance($model, 'banner');
             $model->parent_id = $_POST['Pages']['parent_id'];
             //                $model->show_footer = $_POST['Pages']['show_footer'];
             //                $model->show_home_page = $_POST['Pages']['show_home_page'];
             //                $model->short_content = $_POST['Pages']['short_content'];
             //                $model->order = $_POST['Pages']['order'];
             if (isset($_POST['ck'])) {
                 $model->show_desc = 1;
             } else {
                 $model->show_desc = 0;
             }
             $isEmptyFileInput = empty($_FILES["Pages"]["name"]["imageFile"]);
             $new_banner = '';
             if (!$isEmptyFileInput) {
                 //has file input
                 $model->imageFile = CUploadedFile::getInstance($model, 'imageFile');
             }
             $isEmptyHomePageInput = empty($_FILES["Pages"]["name"]["thumbFile"]);
             $new_home_page = '';
             if (!$isEmptyHomePageInput) {
                 //has file input
                 $model->thumbFile = CUploadedFile::getInstance($model, 'thumbFile');
             }
             if ($model->validate()) {
                 if ($uploadFile) {
                     // remove old image and save new image to disk
                     $model->removeBanner($oldImg);
                     $model->saveBanner($uploadFile);
                 } else {
                     $model->banner = $oldImg;
                     // keep old image
                 }
                 if (!$isEmptyFileInput) {
                     //has file input
                     $errorBanner = false;
                     if (MyFunctionCustom::bannerIsSmall($model->imageFile->getTempName(), Pages::$aSizeBanner['960x252']['width'], Pages::$aSizeBanner['960x252']['height'])) {
                         $errorBanner = true;
                     }
                     //Checked size of banner
                     if ($errorBanner) {
                         $model->addError('imageFile', 'Banner file size need larger than 960x252.');
                     } else {
                         $ext_banner = $model->imageFile->getExtensionName();
                         $timestamp_banner = time();
                         $new_banner = $timestamp_banner . '.' . $ext_banner;
                     }
                 }
                 if (!$isEmptyHomePageInput) {
                     //has file input
                     //Checked size of banner
                     $errorBanner = false;
                     if (MyFunctionCustom::bannerEqual($model->thumbFile->getTempName(), Pages::$aSizeHomePage['204x94']['width'], Pages::$aSizeHomePage['204x94']['height'])) {
                         $errorBanner = true;
                     }
                     //Checked size of banner
                     if ($errorBanner) {
                         $model->addError('thumbFile', 'Thumb file size must be equal 204x94.');
                     } else {
                         $ext_home_page = $model->thumbFile->getExtensionName();
                         $timestamp_home_page = time();
                         $model->thumb_image = $timestamp_home_page . '.' . $ext_home_page;
                     }
                 }
                 if (!$model->hasErrors()) {
                     if (isset($_POST['delete_current_image']) && $_POST['delete_current_image'] == 'on') {
                         Pages::deleteImage($model);
                         $model->featured_image = NULL;
                         if (!$isEmptyFileInput) {
                             $ImageProcessing = new ImageProcessing();
                             $ImageProcessing->delete('upload/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $old_image);
                             $ImageProcessing->createDirectoryByPath('upload/admin/' . Pages::$folderUpload . '/' . $model->id);
                             $model->imageFile->saveAs(YII_UPLOAD_DIR . '/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $new_banner);
                             $model->featured_image = $new_banner;
                             $model->resizeBanner();
                         }
                         $model->update();
                     } else {
                         if ($new_banner != NULL) {
                             $model->featured_image = $new_banner;
                         }
                         if ($model->update()) {
                             if (!$isEmptyFileInput) {
                                 $ImageProcessing = new ImageProcessing();
                                 $ImageProcessing->delete('upload/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $old_image);
                                 $ImageProcessing->createDirectoryByPath('upload/admin/' . Pages::$folderUpload . '/' . $model->id);
                                 $model->imageFile->saveAs(YII_UPLOAD_DIR . '/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $model->featured_image);
                                 $model->resizeBanner();
                             }
                         }
                     }
                     //For home page
                     if (isset($_POST['delete_current_image_home_page']) && $_POST['delete_current_image_home_page'] == 'on') {
                         Pages::deleteImage($model, true);
                         $model->thumb_image = NULL;
                         if (!$isEmptyHomePageInput) {
                             $ImageProcessing = new ImageProcessing();
                             $ImageProcessing->delete('upload/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $old_home_page);
                             $ImageProcessing->createDirectoryByPath('upload/admin/' . Pages::$folderUpload . '/' . $model->id);
                             $model->thumbFile->saveAs(YII_UPLOAD_DIR . '/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $new_home_page);
                             $model->thumb_image = $new_home_page;
                             $model->resizeHomePages();
                         }
                         $model->update();
                     } else {
                         if ($new_home_page != NULL) {
                             $model->thumb_image = $new_home_page;
                         }
                         if ($model->update()) {
                             if (!$isEmptyHomePageInput) {
                                 $ImageProcessing = new ImageProcessing();
                                 $ImageProcessing->delete('upload/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $old_home_page);
                                 $ImageProcessing->createDirectoryByPath('upload/admin/' . Pages::$folderUpload . '/' . $model->id);
                                 $model->thumbFile->saveAs(YII_UPLOAD_DIR . '/admin/' . Pages::$folderUpload . '/' . $model->id . '/' . $model->thumb_image);
                                 $model->resizeHomePages();
                             }
                         }
                     }
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             }
         }
         $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess));
     } catch (exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }
Exemple #16
0
     $fileName = $mProTransactionsVendorPurchaserDetail->scanned_employment_pass;
     $url_download = Yii::app()->createAbsoluteUrl('/') . "/{$fileFolder}/{$fileModelId}/{$fileName}";
     MyFormat::DownloadFile($url_download, $pathSaveFile, $fileName);
     $mUser->upload_employment_pass_passport = $fileName;
 }
 if (!empty($mProTransactionsVendorPurchaserDetail->scanned_passport)) {
     $fileName = $mProTransactionsVendorPurchaserDetail->scanned_passport;
     $url_download = Yii::app()->createAbsoluteUrl('/') . "/{$fileFolder}/{$fileModelId}/{$fileName}";
     MyFormat::DownloadFile($url_download, $pathSaveFile, $fileName);
     $mUser->scanned_passport = $fileName;
Exemple #17
0
 function update_colors($limit, $offset)
 {
     $query = $this->db->get_where('image', array('image_color_ranges' => null), $limit, $offset);
     $res = $query->result();
     foreach ($res as $image) {
         $img_data = ImageProcessing::GetImageInfo($this->config->item('app_path') . $image->image_path);
         $data = array('image_palette' => json_encode($img_data->relevantColors), 'image_color_ranges' => json_encode($img_data->relevantColorRanges));
         $this->db->where('image_id', $image->image_id);
         $this->db->update('image', $data);
         var_dump($img_data->path);
     }
 }
Exemple #18
0
 /**
  * @Author: Jason  Apr 11, 2014
  * @Todo: only remove file of report defect
  * @Param: $modelDel is model DeportDefect
  * @Param: $nameField field file in model report
  */
 public static function removeFile($modelDel, $nameField, $pathUpload)
 {
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/' . $pathUpload . '/' . $modelDel->id;
     $ImageProcessing->delete($ImageProcessing->folder . '/' . $modelDel->{$nameField});
     //        $ImageHelper = new ImageHelper();
     //        $ImageHelper->folder = '/'.$pathUpload;
     //        $ImageHelper->deleteFile($ImageHelper->folder . '/' . $modelRemove->$fieldName);
     //        foreach ( $aSize as $key => $value) {
     //            $ImageHelper->deleteFile($ImageHelper->folder . '/' . $key . '/' . $modelRemove->$fieldName);
     //        }
     foreach (self::$aSize as $key => $value) {
         $ImageProcessing->deleteFile($ImageProcessing->folder . '/' . $key . '/' . $modelDel->{$nameField});
     }
 }
Exemple #19
0
 /**
  * Apr 01, 2014 - ANH DUNG
  * To do: save file 
  * @param: $model model proresume
  * @param: $nameField ex: file_resume
  * @param: $pathUpload ex: 'upload/resume'  
  * @return: name of image
  */
 public static function saveFile($model, $nameField, $pathUpload, $count)
 {
     if (is_null($model->{$nameField})) {
         return '';
     }
     $ext = $model->{$nameField}->getExtensionName();
     $fileName = MyFunctionCustom::slugify($model->{$nameField}->getName());
     $fileName = str_replace(strtolower($ext), '', $fileName);
     $fileName = trim($fileName, '-');
     $fileName = trim($fileName);
     $fileName = $fileName . '-' . time() . $count . '.' . $ext;
     $imageProcessing = new ImageProcessing();
     $imageProcessing->createDirectoryByPath($pathUpload . '/' . $model->id);
     $model->{$nameField}->saveAs($pathUpload . '/' . $model->id . '/' . $fileName);
     return $fileName;
 }
Exemple #20
0
 public function reply($postId)
 {
     $session = $this->alternatesession->session_exists();
     if ($session) {
         $data['user'] = $session;
         $data['title'] = $this->config->item('site_name') . ' - Upload';
         $data['meta_description'] = $this->config->item('site_description');
         $data['meta_keywords'] = $this->config->item('site_keywords');
         if (!strpos($postId, '-')) {
             $slug = strlen($postId);
         } else {
             $slug = strpos($postId, '-');
         }
         $post_id = substr($postId, 0, $slug);
         //Pull in an array of tweets
         $post_data = $this->rest->get('posts/single/' . $post_id);
         $data['post'] = $post_data->post[0];
         $this->form_validation->set_error_delimiters('<p class="help">', '</p>');
         // check form submission and validate
         if ($this->form_validation->run('upload_image') == false) {
             //form has errors : show page and errors
             $this->load->view('common/page_top.php', $data);
             $this->load->view('post/reply.php', $data);
             $this->load->view('common/page_end.php', $data);
         } else {
             // get the uid from the session data and hash it to be used as the user upload folder name
             $user_hash = do_hash($session->user_email);
             // set the upload configuration
             $ulConfig['upload_path'] = './data/' . $user_hash . '/';
             $ulConfig['allowed_types'] = 'jpg|png';
             $ulConfig['max_width'] = '400';
             $ulConfig['max_height'] = '300';
             $ulConfig['encrypt_name'] = true;
             $ulConfig['overwrite'] = false;
             // load the file uploading lib and initialize
             $this->load->library('upload', $ulConfig);
             $this->upload->initialize($ulConfig);
             // check if upload was successful and react
             if (!$this->upload->do_upload('image_file')) {
                 $data['errors'] = array('message' => $this->upload->display_errors());
                 //form has errors : show page and errors
                 //form has errors : show page and errors
                 $this->load->view('common/page_top.php', $data);
                 $this->load->view('post/reply.php', $data);
                 $this->load->view('common/page_end.php', $data);
             } else {
                 $data = array('upload_data' => $this->upload->data());
                 // set the data to write in db;
                 $image_color_data = ImageProcessing::GetImageInfo($data['upload_data']['full_path']);
                 $imgdata = array('path' => substr($ulConfig['upload_path'] . $data['upload_data']['file_name'], 1), 'palette' => json_encode($image_color_data->relevantColors), 'ranges' => json_encode($image_color_data->relevantColorRanges));
                 $config['image_library'] = 'gd2';
                 $config['source_image'] = $ulConfig['upload_path'] . $data['upload_data']['file_name'];
                 $config['create_thumb'] = true;
                 $config['maintain_ratio'] = true;
                 $config['width'] = 200;
                 $config['height'] = 150;
                 $this->load->library('image_lib', $config);
                 $this->image_lib->resize();
                 $post_put_data = array('image_data' => $imgdata, 'post_title' => $this->input->post('post_title'), 'post_text' => $this->input->post('post_text'), 'post_tags' => $this->input->post('post_tags'), 'post_parent_id' => $this->input->post('post_parent_id'), 'user_id' => $session->user_id);
                 $post_put = $this->rest->put('reply/post', $post_put_data);
                 if ($post_put->request_status) {
                     redirect('/view/' . $post_put->post_id);
                 } else {
                     $this->rest->put('trash/throw', array('trash_path' => $imgdata['path']));
                     $data['title'] = $this->config->item('site_name');
                     $data['meta_description'] = $this->config->item('site_description');
                     $data['meta_keywords'] = $this->config->item('site_keywords');
                     $data['errors'] = array('message' => 'Something is broken. Let\'s all pray to the Mighty Carmona!');
                     //form has errors : show page and errors
                     $this->load->view('common/page_top.php', $data);
                     $this->load->view('post/reply.php', $data);
                     $this->load->view('common/page_end.php', $data);
                 }
             }
         }
     } else {
         redirect(site_url());
     }
 }
 /**
  * Apr 01, 2014 - ANH DUNG
  * To do: delete file  of model ProTransactionsVendorPurchaserDetail
  * @param: $model ProTransactionsVendorPurchaserDetail
  * @param: $nameField ex: upload_employment_pass_passport
  * @param: $pathUpload ex: 'upload/tenant' 
  */
 public static function deleteOldFile($model, $nameField)
 {
     $pathUpload = self::$folderUpload;
     $modelDel = self::model()->findByPk($model->id);
     if (is_null($modelDel) || empty($modelDel->{$nameField})) {
         return;
     }
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/' . $pathUpload . '/' . $modelDel->id;
     $ImageProcessing->delete($ImageProcessing->folder . '/' . $modelDel->{$nameField});
 }
         }
     } catch (Exception $e) {
         //            $response['message'] = 'An error has occured.';
         $response['message'] = $e->getMessage();
         $response['code'] = false;
     }
     echo json_encode($response);
     die;
 }
 /**
  * @Author: ANH DUNG Jul 25, 2014
  * @Todo: remove inventory photo
  * @Param: $id 
  */
 public function actionAjaxRemoveFileAll($id)
 {
     MyFormat::CheckRequiredLogin();
     $model = ProInventoryPhoto::model()->findByPk($id);
<?php

include 'ImageProcessing.php';
$imageFileName = $_GET['image'];
$relativeImagePath = 'images/' . $imageFileName;
$test = ImageProcessing::GetImageInfo($relativeImagePath);
?>

<html>
<head></head>
<body>
<img src="<?php 
echo $relativeImagePath;
?>
">
<p style="font-family: sans-serif;"><?php 
echo $test->path;
?>
, <?php 
echo $test->format;
?>
, <?php 
echo $test->width;
?>
x<?php 
echo $test->height;
?>
</p>
<ul style="list-style:none; padding:0; margin:0;">
<?php 
foreach ($test->relevantColors as $rgb) {
Exemple #24
0
         throw new CHttpException(404, "Invalid request");
     }
     $criteria = new CDbCriteria();
     //        $criteria->compare(" t.property_name_or_address", $_GET['term'], true);
     Listing::GetConditionSearchListing($criteria, $_GET['term']);
     //        $criteria->addInCondition(" t.user_id", array(Yii::app()->user->id) );
     //        $criteria->compare(" t.status_listing", STATUS_LISTING_ACTIVE);
     $criteria->with = array('rTransaction');
     $criteria->compare(" rTransaction.user_id", Yii::app()->user->id);
     $criteria->limit = 30;
     $criteria->together = true;
     $models = ProTransactionsPropertyDetail::model()->findAll($criteria);
     $session = Yii::app()->session;
     $returnVal = array();
     $aTransId = array();
     // use for ProTransactionsPropertyDetail->getListTenanciesAgent
     $cmsFormat = new CmsFormatter();
     foreach ($models as $model) {
         //            $label = CHtml::encode($model->property_name_or_address);
         $label = $model->property_name_or_address;
         $returnVal[] = array('label' => $label, 'value' => $label);
         $aTransId[$model->transactions_id] = $model->transactions_id;
     }
     $session['ARR_TRANS_ID_TENANCY'] = $aTransId;
     echo CJSON::encode($returnVal);
     Yii::app()->end();
 }
 public function actionRemark_detail($id)
 {
     $model = Listing::model()->findByPk($id);
     if (empty($model)) {
         Yii::log("The requested page does not exist.");
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $role_id = '';
     if (isset(Yii::app()->session['LOGGED_USER'])) {
         $userCurent = Yii::app()->session['LOGGED_USER'];
         if (isset($userCurent->role_id) && $userCurent->role_id <= ROLE_ADMIN) {
             $role_id = $userCurent->role_id;
         }
     }
     $model->scenario = 'admin_rejected';
     if (!empty($role_id)) {
         if (isset($_POST['Listing'])) {
             $model->attributes = $_POST['Listing'];
             if ($model->validate()) {
                 $model->remark_by_admin = strip_tags($model->remark_by_admin);
                 $model->status_listing = STATUS_LISTING_REJECTED;
                 $model->rejected_on = date('Y-m-d h:i:s');
                 $model->is_rejected = 1;
                 $model->save();
                 die('<script type="text/javascript">parent.$.fancybox.close();parent.$.fn.yiiGridView.update("sr-resume-request-grid");  </script>');
             }
         }
     }
     $this->render('listing/remark_detail', array('model' => $model, 'role_id' => $role_id));
 }
 public function actionAppeal($id)
 {
     $model = Listing::model()->findByPk($id);
     if (empty($model)) {
         Yii::log("The requested page does not exist.");
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $model->scenario = 'listing_appeal_upload_file';
     if (isset($_POST['Listing'])) {
 /**
  * Jun 07, 2014 - ANH DUNG
  * To do: save file 
  * @param: $model is model ProGlobalEnquiry
  * @param: $fieldName file_name
  * @return: name of image upload/global_enquiry
  */
 public static function saveFile($model, $fieldName)
 {
     if (is_null($model->{$fieldName})) {
         return '';
     }
     $pathUpload = ProInventoryPhoto::$folderUpload;
     $ext = $model->{$fieldName}->getExtensionName();
     $file_name_slug = strtolower(MyFunctionCustom::slugify($model->{$fieldName}->getName()));
     $file_name_slug = str_replace(strtolower($ext), '', $file_name_slug);
     $model->file_name_slug = $file_name_slug;
     $fileName = date('Y-m-d');
     $uid = isset(Yii::app()->user->id) ? Yii::app()->user->id : 999999;
     $fileName = $uid . '-' . time() . '-' . ActiveRecord::randString() . '.' . $ext;
     $imageProcessing = new ImageProcessing();
     $imageProcessing->createDirectoryByPath($pathUpload);
     $model->{$fieldName}->saveAs($pathUpload . '/' . $fileName);
     $model->{$fieldName} = $fileName;
     return $fileName;
 }
 public function actionAjax_upload_doc($id, $type)
 {
     if (isset($_GET['title'])) {
         $_SESSION['title'] = strip_tags(trim($_GET['title']));
         die;
     }
     $model = $this->loadModel($id);
     if ($model) {
         $totalImgupload = ProListingUploadCea::model()->countByAttributes(array('listing_id' => $id));
         if (!ProListingUploadCea::checkLimitFileUpload($id)) {
             $result['errorMesage'] = 'Limit ' . LIMIT_DOC_UPLOAD . ' file upload';
             die(json_encode($result));
         }
         //upload file ajax
         Yii::import("ext.EAjaxUpload.qqFileUploader");
         $ImageProcessing = new ImageProcessing();
         $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}");
         $ImageProcessing->createSingleDirectoryByPath("/upload/listing/{$id}/cea");
         $folder = "upload/listing/{$id}/cea/";
         $allowedExtensions = array("doc", "docx", "xls", "xlsx", "pdf", "csv");
         $sizeLimit = 5 * 1024 * 1024;
         // maximum file size in bytes
         $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
         $result = $uploader->handleUpload($folder, true);
         $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
         $fileSize = filesize($folder . $result['filename']);
         //GETTING FILE SIZE
         $fileName = $result['filename'];
         //GETTING FILE NAME
         if (isset($result['success']) && $result['success'] == true) {
             $cea = new ProListingUploadCea();
             $cea->listing_id = $id;
             $cea->file = $fileName;
             $cea->title = isset($_SESSION['title']) ? $_SESSION['title'] : '';
             $cea->created_date = date('Y-m-d h:i:s');
             $cea->validate();
             if ($cea->save()) {
                 unset($_SESSION['title']);
             }
         }
         echo $return;
         // it's array
         //            if (isset($_FILES['Listing']) && isset($_POST['Listing']['title_cea'])) {
         //                $totalImgupload = ProListingUploadCea::model()->countByAttributes(array('listing_id' => $id));
         //                if (!ProListingUploadCea::checkLimitFileUpload($id)) {
         //                    echo "limit";
         //                    die();
         //                }
         //                $data = CUploadedFile::getInstances($model, 'file_upload');
         //                if ($_POST['Listing']['title_cea'] != '' && !empty($data)) {
         //                    foreach ($data as $k => $file) {
         //                        $name = date('d-m-Y-h-i-s') . "." . $file->getExtensionName();
         //                        $cea = new ProListingUploadCea();
         //                        $cea->attributes = $_POST['Listing'];
         //                        $cea->listing_id = $id;
         //                        $cea->file_upload = $file;
         //                        $cea->file = $name;
         //                        $cea->title = isset($_POST['Listing']['title_cea']) ? $_POST['Listing']['title_cea'] : '';
         //                        $cea->created_date = date('Y-m-d h:i:s');
         //                        $cea->validate();
         //                        if ($cea->save()) {
         //                            $ImageProcessing = new ImageProcessing();
         //                            $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id");
         //                            $ImageProcessing->createSingleDirectoryByPath("/upload/listing/$id/cea");
         //                            $file->saveAs(YII_UPLOAD_DIR . "/listing/$id/cea/$name");
         //                        }
         //                    }
         //                }
         //            }
     }
 }
Exemple #27
0
 /**
  * @Author: ANH DUNG Aug 12, 2014
  * @Todo: put WarterMark
  * @Param: $model model 
  */
 public static function PutWarterMarkPhotoListing($model)
 {
     $listing_id = $model->listing_id;
     $fileName = $model->image;
     foreach (ProListingPhotos::$szie as $folder => $item) {
         ImageProcessing::addWarterMark(YII_UPLOAD_DIR . "/listing/{$listing_id}/{$folder}/{$fileName}", YII_UPLOAD_DIR . "/listing/{$listing_id}/{$folder}/{$fileName}");
     }
 }
Exemple #28
0
    <div class="inventory_photo_show">
        <ul class="photo-list clearfix">
            <?php 
foreach ($aModelPhoto as $key => $item) {
    ?>
            <?php 
    $first = 'first';
    $last = 'last';
    if ($key != 0) {
        $first = '';
    }
    if ($key != $countModelPhoto - 1) {
        $last = '';
    }
    $pathPhoto = ImageProcessing::bindImageByModel($item, 160, 160);
    $pathPhotoBig = ImageProcessing::bindImageByModel($item, -1, -1);
    $linkRemove = '';
    $CanRemove = $item->user_id == Yii::app()->user->id ? true : false;
    if ($CanRemove) {
        $linkRemove = Yii::app()->createAbsoluteUrl('enquiry/ajaxRemoveFileAll', array('id' => $item->id));
    }
    ?>
            <li class="<?php 
    echo $first . " {$last}";
    ?>
" >
                <a href="<?php 
    echo $pathPhotoBig;
    ?>
" class="FancyPhoto"  rel='group'>
                    <img src="<?php 
 /**
  * @Author: ANH DUNG  Apr 01, 2014
  * @Todo: only remove file of transaction
  * @Param: $modelDel is model ProTransactionsPropertyDocument     
  */
 public static function removeFile($modelDel)
 {
     $ImageProcessing = new ImageProcessing();
     $ImageProcessing->folder = '/' . self::$folderUpload . '/' . $modelDel->transactions_id;
     $ImageProcessing->delete($ImageProcessing->folder . '/' . $modelDel->file_name);
 }
Exemple #30
0
<?php

$this->breadcrumbs = array('Module' => array('index'), $model->name);
$menus = array(array('label' => 'Module Management', 'url' => array('index')), array('label' => 'Create Module', 'url' => array('create')), array('label' => 'Update Module', 'url' => array('update', 'id' => $model->id)), array('label' => 'Delete Module', 'url' => array('delete'), 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')));
$this->menu = ControllerActionsName::createMenusRoles($menus, $actions);
?>

<h1>View Module: <?php 
echo $model->name;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('name', array('name' => 'short_description', 'type' => 'html', 'value' => $model->short_description), array('name' => 'description', 'type' => 'html', 'value' => $model->description), 'status:status', 'order_at', array('name' => 'course_id', 'value' => $model->course->name), array('name' => 'cover', 'type' => 'html', 'value' => CHtml::image(ImageProcessing::bindImageByModel($model, 217, 194, 'cover'))))));