示例#1
0
 /**
  * Removes user thumbnails
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @return boolean
  */
 public static function remove_thumbnails($user_id)
 {
     /** first validation **/
     if (!trim($user_id)) {
         return false;
     }
     $ext_array = array('jpg', 'jpeg', 'gif', 'png');
     $path = wpl_items::get_path($user_id, 2);
     $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
     foreach ($thumbnails as $thumbnail) {
         wpl_file::delete($thumbnail);
     }
     return true;
 }
示例#2
0
 /**
  * Deletes a file
  * @author Howard R <*****@*****.**>
  * @static
  * @param string $file_name
  * @param int $parent_id
  * @param int $kind
  * @return boolean
  */
 public static function delete_file($file_name, $parent_id, $kind = 0)
 {
     if (!trim($file_name) or !trim($parent_id)) {
         return false;
     }
     $query = "DELETE FROM `#__wpl_items` WHERE `parent_kind`='{$kind}' AND `parent_id`='{$parent_id}' AND `item_name`='{$file_name}'";
     $affected_rows = wpl_db::q($query, 'delete');
     $folder = wpl_items::get_path($parent_id, $kind);
     if (wpl_file::exists($folder . $file_name)) {
         wpl_file::delete($folder . $file_name);
         if (wpl_file::exists($folder . 'thumbnail' . DS . $file_name)) {
             wpl_file::delete($folder . 'thumbnail' . DS . $file_name);
         }
     }
     /** trigger event **/
     wpl_global::event_handler('item_deleted', array('file_name' => $file_name, 'parent_id' => $parent_id));
     return true;
 }
示例#3
0
 private function delete_file($field_id, $user_id, $output = true)
 {
     $field_data = (array) wpl_db::get('*', 'wpl_dbst', 'id', $field_id);
     $user_data = (array) wpl_users::get_wpl_user($user_id);
     $path = wpl_items::get_path($user_id, $field_data['kind']) . $user_data[$field_data['table_column']];
     /** delete file and reset db **/
     wpl_file::delete($path);
     wpl_db::set('wpl_users', $user_id, $field_data['table_column'], '');
     /** delete thumbnails **/
     wpl_users::remove_thumbnails($user_id);
     /** called from other functions (upload function) **/
     if (!$output) {
         return;
     }
     $res = 1;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
示例#4
0
 /**
  * Removes WPL cached data
  * @author Howard <*****@*****.**>
  * @static
  * @param type $cache_type
  * @return boolean
  */
 public static function clear_cache($cache_type = 'all')
 {
     /** first validation **/
     $cache_type = strtolower($cache_type);
     if (trim($cache_type) == '') {
         return false;
     }
     /** import libraries **/
     _wpl_import('libraries.property');
     _wpl_import('libraries.items');
     if ($cache_type == 'unfinalized_properties' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id` FROM `#__wpl_properties` WHERE `finalized`='0'", 'loadAssocList');
         foreach ($properties as $property) {
             wpl_property::purge($property['id']);
         }
     }
     if ($cache_type == 'properties_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`='', `alias`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('alias', 'location_text', 'rendered'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'location_texts' or $cache_type == 'all') {
         $q = " `location_text`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'listings_thumbnails' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id`, `kind` FROM `#__wpl_properties` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($properties as $property) {
             $path = wpl_items::get_path($property['id'], $property['kind']);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     if ($cache_type == 'users_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text', 'rendered'), 'wpl_users');
         }
         $query = "UPDATE `#__wpl_users` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'users_thumbnails' or $cache_type == 'all') {
         $users = wpl_db::select("SELECT `id` FROM `#__wpl_users` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($users as $user) {
             $path = wpl_items::get_path($user['id'], 2);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     /** trigger event **/
     wpl_global::event_handler('cache_cleared', array('cache_type' => $cache_type));
     return true;
 }
示例#5
0
 /**
  * Creates profile image
  * @author Howard <*****@*****.**>
  * @param string $source
  * @param int $width
  * @param int $height
  * @param array $params
  * @param int $watermark
  * @param int $rewrite
  * @param int $crop
  * description: resize and watermark images specially
  */
 public static function create_profile_images($source, $width, $height, $params, $watermark = 0, $rewrite = 0, $crop = '')
 {
     /** first validation **/
     if (!trim($source)) {
         return NULL;
     }
     $image_name = wpl_file::stripExt($params['image_name']);
     $image_ext = wpl_file::getExt($params['image_name']);
     $resized_image_name = 'th' . $image_name . '_' . $width . 'x' . $height . '.' . $image_ext;
     $image_dest = wpl_items::get_path($params['image_parentid'], 2) . $resized_image_name;
     $image_url = wpl_items::get_folder($params['image_parentid'], 2) . $resized_image_name;
     /** check resized files existance and rewrite option **/
     if ($rewrite or !wpl_file::exists($image_dest)) {
         if ($watermark) {
             self::resize_watermark_image($source, $image_dest, $width, $height);
         } else {
             self::resize_image($source, $image_dest, $width, $height, $crop);
         }
     }
     return $image_url;
 }
示例#6
0
    <div id="progress" class="progress progress-success progress-striped">
        <div class="bar"></div>
    </div>
</div>

<div class="error_uploaded_message" id="error_ajax_img">
</div>

<!-- The container for the uploaded files -->
<div id="files" class="gallary-images-wp wpl_files_container">
    <ul class="ui-sortable" id="ajax_gal_sortable">
        <?php 
    // get uploaded images and show them
    $gall_items = wpl_items::get_items($item_id, 'gallery', $this->kind, '', '');
    $image_folder = wpl_items::get_folder($item_id, $this->kind);
    $image_path = wpl_items::get_path($item_id, $this->kind);
    $image_categories = wpl_items::get_item_categories('gallery', $this->kind);
    $max_img_index = 0;
    foreach ($gall_items as $image) {
        $image->index = intval($image->index);
        if ($max_img_index < $image->index) {
            $max_img_index = $image->index;
        }
        /** set resize method parameters **/
        $params = array();
        $params['image_name'] = $image->item_name;
        $params['image_parentid'] = $image->parent_id;
        $params['image_parentkind'] = $image->parent_kind;
        $params['image_source'] = $image_path . $image->item_name;
        $image_thumbnail_url = wpl_images::create_gallary_image(80, 60, $params, 1, 0);
        if ($image->item_cat == 'external') {