Example #1
0
 public function upload()
 {
     /** import upload library **/
     _wpl_import('assets.packages.ajax_uploader.UploadHandler');
     $kind = wpl_request::getVar('kind', 0);
     $params = array();
     $params['accept_ext'] = wpl_flex::get_field_options(301);
     $extentions = explode(',', $params['accept_ext']['ext_file']);
     $ext_str = '';
     foreach ($extentions as $extention) {
         $ext_str .= $extention . '|';
     }
     // remove last |
     $ext_str = substr($ext_str, 0, -1);
     $ext_str = rtrim($ext_str, ';');
     $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null);
     $upload_handler = new UploadHandler($custom_op);
     $response = json_decode($upload_handler->json_response);
     if (isset($response->files[0]->error)) {
         return;
     }
     $attachment_categories = wpl_items::get_item_categories('attachment', $kind);
     // get item category with first index
     $item_cat = reset($attachment_categories)->category_name;
     $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0;
     $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index);
     wpl_items::save($item);
 }
Example #2
0
 public function get_qr_image($qrfile_prefix = 'qr_', $size = 4, $outer_margin = 2)
 {
     $url = wpl_global::get_full_url();
     $file_name = $qrfile_prefix . md5($url) . '.png';
     $file_path = wpl_global::get_upload_base_path() . 'qrcode' . DS . $file_name;
     if (!wpl_file::exists($file_path)) {
         if (!wpl_file::exists(dirname($file_path))) {
             wpl_folder::create(dirname($file_path));
         }
         $QRcode = new QRcode();
         $QRcode->png($url, $file_path, 'L', $size, $outer_margin);
     }
     return wpl_global::get_upload_base_url() . 'qrcode/' . $file_name;
 }
Example #3
0
 /**
  * Uninstalling WPL
  * @author Howard <*****@*****.**>
  * @return boolean
  */
 public function uninstall_wpl()
 {
     $tables = wpl_db::select('SHOW TABLES');
     $database = wpl_db::get_DBO();
     foreach ($tables as $table_name => $table) {
         if (strpos($table_name, $database->prefix . 'wpl_') !== false) {
             /** drop table **/
             wpl_db::q("DROP TABLE `{$table_name}`");
         }
     }
     /** delete options **/
     wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete');
     /** remove WPL upload directory **/
     if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) {
         $original_blog_id = wpl_global::get_current_blog_id();
         // Get all blogs
         $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn');
         foreach ($blogs as $blog) {
             if (!isset($blog->blog_id)) {
                 continue;
             }
             switch_to_blog($blog->blog_id);
             $upload_path = wpl_global::get_upload_base_path($blog->blog_id);
             if (wpl_folder::exists($upload_path)) {
                 wpl_folder::delete($upload_path);
             }
         }
         switch_to_blog($original_blog_id);
     } else {
         $upload_path = wpl_global::get_upload_base_path();
         if (wpl_file::exists($upload_path)) {
             wpl_file::delete($upload_path);
         }
     }
     return true;
 }
Example #4
0
$auto_play = isset($this->instance['data']['auto_play']) ? $this->instance['data']['auto_play'] : true;
$smart_resize = isset($this->instance['data']['smart_resize']) ? $this->instance['data']['smart_resize'] : false;
$slide_interval = isset($this->instance['data']['slide_interval']) ? $this->instance['data']['slide_interval'] : 3000;
/** add Layout js **/
$js[] = (object) array('param1' => 'modern.slider', 'param2' => 'js/libraries/wpl.modern.slider.min.js');
foreach ($js as $javascript) {
    wpl_extensions::import_javascript($javascript);
}
$larg_images = $thumbnail = NULL;
foreach ($wpl_properties as $key => $gallery) {
    if (isset($gallery["items"]["gallery"][0])) {
        $params = array();
        $params['image_name'] = $gallery["items"]["gallery"][0]->item_name;
        $params['image_parentid'] = $gallery["items"]["gallery"][0]->parent_id;
        $params['image_parentkind'] = $gallery["items"]["gallery"][0]->parent_kind;
        $params['image_source'] = wpl_global::get_upload_base_path() . $params['image_parentid'] . DS . $params['image_name'];
        $image_title = wpl_property::update_property_title($gallery['raw']);
        if (isset($gallery['items']['gallery'][0]->item_extra2) and trim($gallery['items']['gallery'][0]->item_extra2) != '') {
            $image_alt = $gallery['items']['gallery'][0]->item_extra2;
        } else {
            $image_alt = $gallery['raw']['meta_keywords'];
        }
        $image_description = $gallery["items"]["gallery"][0]->item_extra2;
        if ($gallery["items"]["gallery"][0]->item_cat != 'external') {
            $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params);
            $thumbnail_url = wpl_images::create_gallary_image($thumbnail_width, $thumbnail_height, $params);
        } else {
            $image_url = $gallery["items"]["gallery"][0]->item_extra3;
            $thumbnail_url = $gallery["items"]["gallery"][0]->item_extra3;
        }
        $larg_images .= '
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wp_debug ? __('On', WPL_TEXTDOMAIN) : __('Off', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
            	<i class="icon-<?php 
echo $wp_debug ? 'warning' : 'confirm';
?>
"></i>
            </span>
		</li>
        <!-- Upload directory permission -->
        <?php 
$wpl_writable = substr(sprintf('%o', fileperms(wpl_global::get_upload_base_path())), -4) >= '0755' ? true : false;
?>
        <li>
        	<span class="wpl-requirement-name"><?php 
echo __('Upload dir', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-require"><?php 
echo __('Writable', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wpl_writable ? __('Yes', WPL_TEXTDOMAIN) : __('No', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
Example #6
0
    $pic_count = '<div class="pic_count">' . $property['raw']['pic_numb'] . '</div>';
    $price = '<div class="price">' . $property['materials']['price']['value'] . '</div>';
    ?>
	<div id="main_infowindow">
		<div class="main_infowindow_l">
			<?php 
    if (isset($property['items']['gallery'])) {
        $i = 0;
        $images_total = count($property['items']['gallery']);
        foreach ($property['items']['gallery'] as $key1 => $image) {
            /** 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'] = wpl_global::get_upload_base_path() . $image->parent_id . DS . $image->item_name;
            /** resize image if does not exist **/
            if (isset($image->item_cat) and $image->item_cat != 'external') {
                $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params);
            } else {
                $image_url = $image->item_extra3;
            }
            echo '<img itemprop="image" id="wpl_gallery_image' . $property_id . '_' . $i . '" src="' . $image_url . '" class="wpl_gallery_image" onclick="wpl_Plisting_slider(' . $i . ',' . $images_total . ',' . $property_id . ');" width="' . $image_width . '" height="' . $image_height . '" style="width: ' . $image_width . 'px; height: ' . $image_height . 'px;" />';
            $i++;
        }
    } else {
        echo '<div class="no_image_box"></div>';
    }
    ?>
		</div>
		<div class="main_infowindow_r">
Example #7
0
 /**
  * Returns item directory path. If it's not exist it creates the directory 
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $parent_id
  * @param int $kind
  * @return string
  */
 public static function get_path($parent_id, $kind = 0)
 {
     if ($kind == 2) {
         $path = wpl_global::get_upload_base_path() . 'users' . DS . $parent_id . DS;
     } else {
         $path = wpl_global::get_upload_base_path() . $parent_id . DS;
     }
     if (!wpl_folder::exists($path)) {
         wpl_folder::create($path);
     }
     return $path;
 }