示例#1
0
 public function cache_imageAction()
 {
     $request = $this->getRequest();
     $width = (int) $request->getParam('width');
     $height = (int) $request->getParam('height');
     $cached_file = $request->getParam('cached_file');
     $file = $request->getParam('file') . $request->getParam('extension');
     $extension = $request->getParam('extension');
     $gray = $request->getParam('gray') == 'gray';
     $crop = $request->getParam('crop') == 'crop';
     $watermark = $request->getParam('watermark') == 'watermark' ? 'watermark.png' : false;
     $model_images = new Helper_Images();
     $image = false;
     if ($width && $height) {
         $image = $model_images->resize('/' . $file, $width, $height, $crop, $watermark, $gray);
     } else {
         if ($width) {
             $image = $model_images->resizeWidth('/' . $file, $width, $watermark, $gray);
         } else {
             if ($height) {
                 $image = $model_images->resizeHeight('/' . $file, $height, $watermark, $gray);
             } else {
                 $this->forward('error', 'error404');
             }
         }
     }
     if ($image) {
         $response = $this->getResponse();
         $response->addHeader('Content-type:' . JO_File_Ext::getMimeFromFile($image));
         $response->appendBody(file_get_contents($image));
         exit;
     } else {
         $this->forward('error', 'error404');
     }
 }
示例#2
0
 public static function uploadUserAvatar($image, $user_id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         $added_date = time();
         $username = md5($user_id);
         $user_info = new Model_Users_User($user_id);
         if ($user_info->count()) {
             $added_date = $user_info['date_added'];
             $username = $user_info['username'];
         }
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         $name = $username . '_' . $user_id . $ext;
         $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true);
         }
         $user_agent = ini_get('user_agent');
         ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
         if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) {
             self::$error = self::translate('Unable to upload to the local server!');
             return false;
         }
         ini_set('user_agent', $user_agent);
         $max_width = 0;
         $sizes = self::userThumbSizes();
         $pin_sizes = array();
         if ($sizes) {
             $model_images = new Helper_Images();
             foreach ($sizes as $size => $prefix) {
                 $sizes = explode('x', $size);
                 $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext);
                 $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0);
             }
             if ($max_width) {
                 $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width);
                 $thumb_a1 = explode('/uploads/', $thumb_a);
                 if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) {
                     $container = Helper_Config::get('rackspace_users_contaners');
                     try {
                         $images = self::$connect->get_container($container);
                         //$images->make_public(86400*365);
                         //$images = self::$connect->get_container($container);
                         //if(!$images->cdn_uri) {
                         //	self::$error = self::translate("Authentication response did not indicate CDN availability");
                         //	return false;
                         //}
                         $object = $images->create_object($name);
                         $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]);
                         $image_info = $images->get_object($name);
                         if (!$image_info->name) {
                             self::$error = self::translate('Unable to upload to the server!');
                             return false;
                         }
                         foreach ($pin_sizes as $s) {
                             $thumb_b = '';
                             if ($s[0] && $s[1]) {
                                 $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true);
                             } else {
                                 if ($s[0] && !$s[1]) {
                                     $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]);
                                 } else {
                                     if (!$s[0] && $s[1]) {
                                         $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]);
                                     }
                                 }
                             }
                             $thumb_b1 = explode('/uploads/', $thumb_b);
                             if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) {
                                 $object = $images->create_object($s[2]);
                                 $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_b1[1]);
                                 $image_info1 = $images->get_object($s[2]);
                                 if (!$image_info1->name) {
                                     self::$error = self::translate('Unable to upload to the server!');
                                     return false;
                                 }
                             } else {
                                 self::$error = self::translate('Unable to upload to the local server!');
                                 return false;
                             }
                         }
                         return array('store' => 'Model_Upload_Rackspace', 'image' => trim(Helper_Config::get('rackspace_users_contaners_cdn'), '/') . '/' . $image_info->name, 'width' => 0, 'height' => 0);
                     } catch (JO_Exception $e) {
                         self::$error = $e->getMessage();
                         return false;
                     }
                     $model_images->deleteImages('/' . $thumb_a1[1]);
                     $model_images->deleteImages('/cache_avatars/' . $image_path . $name);
                     return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     self::$error = self::translate('Unable to upload to the local server!');
                     return false;
                 }
             } else {
                 self::$error = self::translate('Missing images sizes!');
                 return false;
             }
         } else {
             self::$error = self::translate('Missing images sizes!');
             return false;
         }
     } else {
         self::$error = self::translate('Image format is not valid!');
         return false;
     }
     self::$error = self::translate('Unknown server error!');
     return false;
 }
示例#3
0
 public static function getUserImage($user, $prefix = null)
 {
     if (!$user['avatar']) {
         $user['avatar'] = Helper_Config::get('no_avatar');
     }
     $sizes = self::userThumbSizes();
     $format_size = false;
     if ($sizes) {
         foreach ($sizes as $val => $key) {
             if ($key == $prefix) {
                 $format_size = $val;
                 break;
             }
         }
     }
     if (!$format_size) {
         return false;
     }
     $user['user_id'] = $user['user_id'] ? $user['user_id'] : -1;
     $image_stored = self::userAvatarExist($user['user_id'], $prefix);
     if ($image_stored) {
         return $image_stored;
     }
     $model_images = new Helper_Images();
     $sizes = explode('x', $format_size);
     $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
     $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
     if ($width && $height) {
         $img = $model_images->resize($user['avatar'], $width, $height, true);
     } else {
         if ($width && !$height) {
             $img = $model_images->resizeWidth($user['avatar'], $width);
         } else {
             if ($height && !$width) {
                 $img = $model_images->resizeHeight($user['avatar'], $height);
             }
         }
     }
     if ($img) {
         $data = array('image' => $img, 'original' => $model_images->original($user['avatar']), 'width' => $model_images->getSizes('width'), 'height' => $model_images->getSizes('height'), 'mime' => JO_File_Ext::getMimeFromFile($img), 'size' => $prefix, 'user_id' => $user['user_id']);
         self::userAvatarCreate($data);
         return $data;
     }
     return false;
 }
示例#4
0
 public static function uploadUserAvatar($avatar, $user_id = 0)
 {
     //try {
     if (($imageinfo = getimagesize($avatar)) !== false) {
         if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $user_id) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $user_id)) {
             @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $user_id, 0777, true);
         }
         $ext = strtolower(strrchr($avatar, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         $name = md5(time() . mt_rand()) . '_' . $user_id . $ext;
         if (@copy($avatar, BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/' . $name)) {
             $added_date = time();
             if (is_array($user_info = Model_Users::getUser($user_id))) {
                 $added_date = $user_info['date_added'];
                 self::deleteUserImage($user_info);
             }
             $user_agent = ini_get('user_agent');
             ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
             $container = 'amatteur_users';
             $auth = new JO_Api_Rackspace_Authentication(JO_Registry::get('rsUsername'), JO_Registry::get('rsApiKey'));
             if ($auth->authenticate()) {
                 $conn = new JO_Api_Rackspace_Connection($auth);
                 $contaners = $conn->list_public_containers();
                 if (!in_array($container, $contaners)) {
                     $conn->create_container($container);
                     $contaners[] = $container;
                 }
                 if ($contaners && in_array($container, $contaners)) {
                     $images = $conn->get_container($container);
                     $images->make_public(86400 * 365);
                     $images = $conn->get_container($container);
                     if (!$images->cdn_uri) {
                         return false;
                     }
                     $object = $images->create_object($name);
                     $object->load_from_filename(BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/' . $name);
                     $image_info = $images->get_object($name);
                     if (!$image_info->name) {
                         return false;
                     }
                     $model_images = new Helper_Images();
                     $temp_width = 0;
                     $temp_height = 0;
                     $sizes = self::userThumbSizes();
                     if ($sizes) {
                         foreach ($sizes as $size => $prefix) {
                             $sizes = explode('x', $size);
                             $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
                             $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
                             $name_pref = basename($name, $ext) . $prefix . $ext;
                             if ($width && $height) {
                                 $thumb_a = $model_images->resize('/cache_avatars/' . $user_id . '/' . $name, $width, $height, true);
                             } else {
                                 if ($width && !$height) {
                                     $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $user_id . '/' . $name, $width);
                                 } else {
                                     if ($height && !$width) {
                                         $thumb_a = $model_images->resizeHeight('/cache_avatars/' . $user_id . '/' . $name, $height);
                                     }
                                 }
                             }
                             if ($prefix == '_B') {
                                 $temp_width = $model_images->getSizes('width');
                                 $temp_height = $model_images->getSizes('height');
                             }
                             $thumb_a1 = explode('/uploads/', $thumb_a);
                             if ($thumb_a1 && isset($thumb_a1[1])) {
                                 $object = $images->create_object($name_pref);
                                 $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]);
                             }
                         }
                     }
                     self::recursiveDelete(BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/');
                     self::recursiveDelete(BASE_PATH . '/uploads/cache/cache_avatars/' . $user_id . '/');
                     if ($temp_width) {
                         return array('store' => 'rackspace', 'image' => $images->cdn_uri . '/' . $image_info->name, 'width' => $temp_width, 'height' => $temp_height);
                     }
                 }
             }
         }
     }
     return false;
     /*} catch (JO_Exception $e) {
     			return false;
     		}*/
     return false;
 }
示例#5
0
 public static function uploadUserAvatar($image, $user_id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         $added_date = time();
         $username = md5($user_id);
         $user_info = new Model_Users_User($user_id);
         if ($user_info->count()) {
             $added_date = $user_info['date_added'];
             $username = $user_info['username'];
         }
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         $name = $username . '_' . $user_id . $ext;
         $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true);
         }
         $user_agent = ini_get('user_agent');
         ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
         if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) {
             self::$error = self::translate('Unable to upload to the local server!');
             return false;
         }
         ini_set('user_agent', $user_agent);
         $max_width = 0;
         $sizes = self::userThumbSizes();
         $pin_sizes = array();
         if ($sizes) {
             $model_images = new Helper_Images();
             foreach ($sizes as $size => $prefix) {
                 $sizes = explode('x', $size);
                 $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext);
                 $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0);
             }
             if ($max_width) {
                 $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width);
                 $thumb_a1 = explode('/uploads/', $thumb_a);
                 if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) {
                     self::upload(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name);
                     if (self::$error) {
                         return false;
                     }
                     foreach ($pin_sizes as $s) {
                         if (self::$error) {
                             return false;
                         }
                         $thumb_b = '';
                         if ($s[0] && $s[1]) {
                             $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true);
                         } else {
                             if ($s[0] && !$s[1]) {
                                 $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]);
                             } else {
                                 if (!$s[0] && $s[1]) {
                                     $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]);
                                 }
                             }
                         }
                         $thumb_b1 = explode('/uploads/', $thumb_b);
                         if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) {
                             self::upload(BASE_PATH . '/uploads/' . $thumb_b1[1], $image_path . $s[2]);
                             if (self::$error) {
                                 return false;
                             }
                         } else {
                             self::$error = self::translate('Unable to upload to the local server!');
                             return false;
                         }
                     }
                     $model_images->deleteImages('/' . $thumb_a1[1]);
                     $model_images->deleteImages('/cache_avatars/' . $image_path . $name);
                     return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     self::$error = self::translate('Unable to upload to the local server!');
                     return false;
                 }
             } else {
                 self::$error = self::translate('Missing images sizes!');
                 return false;
             }
         } else {
             self::$error = self::translate('Missing images sizes!');
             return false;
         }
     } else {
         self::$error = self::translate('Image format is not valid!');
         return false;
     }
     self::$error = self::translate('Unknown server error!');
     return false;
 }
示例#6
0
 public static function uploadEventImage1($avatar, $user_id = 0)
 {
     try {
         $added_date = time();
         if (is_array($user_info = Model_Users::getUser($user_id))) {
             $added_date = $user_info['date_added'];
         }
         $date_added = WM_Date::format($added_date, 'yy-mm-dd H:i:s');
         $s3 = new JO_Api_Amazon(JO_Registry::get('awsAccessKey'), JO_Registry::get('awsSecretKey'));
         $s3->putBucket(JO_Registry::get('bucklet'), JO_Api_Amazon::ACL_PUBLIC_READ);
         if ($s3->getBucketLogging(JO_Registry::get('bucklet'))) {
             if (($imageinfo = @getimagesize($avatar)) !== false) {
                 $ext = strtolower(strrchr($avatar, "."));
                 $name = $user_id . $ext;
                 $image_path = 'events/' . WM_Date::format($date_added, 'yy/mm/');
                 if (!file_exists(BASE_PATH . '/uploads/cache_events/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_events/' . $image_path)) {
                     @mkdir(BASE_PATH . '/uploads/cache_events/' . $image_path, 0777, true);
                 }
                 @copy($avatar, BASE_PATH . '/uploads/cache_events/' . $image_path . $name);
                 if (self::uploatToServer(BASE_PATH . '/uploads/cache_events/' . $image_path . $name, $image_path . $name)) {
                     $model_images = new Helper_Images();
                     $temp_width = 0;
                     $temp_height = 0;
                     $sizes = self::userThumbSizes();
                     if ($sizes) {
                         foreach ($sizes as $size => $prefix) {
                             $sizes = explode('x', $size);
                             $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
                             $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
                             $name_pref = basename($name, $ext) . $prefix . $ext;
                             if ($width && $height) {
                                 $thumb_a = $model_images->resize('/cache_events/' . $image_path . $name, $width, $height, true);
                             } else {
                                 if ($width && !$height) {
                                     $thumb_a = $model_images->resizeWidth('/cache_events/' . $image_path . $name, $width);
                                 } else {
                                     if ($height && !$width) {
                                         $thumb_a = $model_images->resizeHeight('/cache_events/' . $image_path . $name, $height);
                                     }
                                 }
                             }
                             if ($prefix == '_B') {
                                 $temp_width = $model_images->getSizes('width');
                                 $temp_height = $model_images->getSizes('height');
                             }
                             $thumb_a1 = explode('/uploads/', $thumb_a);
                             if ($thumb_a1 && isset($thumb_a1[1])) {
                                 if (!self::uploatToServer(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name_pref)) {
                                 }
                             }
                         }
                     }
                     //$model_images->deleteImages('/cache_events/' . $image_path . $name);
                     if ($temp_width) {
                         return array('store' => 'amazons3', 'image' => $image_path . $name, 'width' => $temp_width, 'height' => $temp_height);
                     } else {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
     } catch (JO_Exception $e) {
         return false;
     }
     return false;
 }
示例#7
0
 public function indexAction()
 {
     if (JO_Session::get('order_id')) {
         JO_Session::clear('order_id');
     }
     $request = $this->getRequest();
     $image_model = new Helper_Images();
     JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri());
     $this->view->currency = WM_Currency::getCurrency();
     $itemID = $request->getRequest('item_id');
     $item = Model_Items::get($itemID);
     if (!is_array($item) || $item['status'] == 'deleted' || JO_Session::get('username') && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') {
         return $this->forward('error', 'error404');
     }
     if (JO_Session::get('order_id')) {
         Model_Orders::delete(JO_Session::get('order_id'));
         JO_Session::clear('order_id');
     }
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $user = Model_Users::getUser($item['user_id']);
     $user['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']));
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => $user['userhref']), array('name' => $item['name']));
     $this->view->item_href = $this->view->form_action = $this->view->item_link = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $faqs_data = Model_Faq::getAll($itemID);
     if (JO_Session::get('user_id') == $item['user_id'] || $faqs_data) {
         $this->view->faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     if (JO_Session::get('user_id') == $item['user_id']) {
         $this->view->edit_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $this->view->screenshots = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=screenshots&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     if (!empty($item['demo_url'])) {
         $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     $item['description'] = strip_tags(html_entity_decode($item['description']), '<br><p><span><h1><h2><h3><a><img><big><small><ul><ol><li>');
     $this->getLayout()->meta_title = $item['name'];
     $meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255);
     $this->getLayout()->meta_description = $meta_description;
     if ((int) JO_Registry::get($item['module'] . '_items_screenshots_width') && (int) JO_Registry::get($item['module'] . '_items_screenshots_height')) {
         $item['big_image'] = $image_model->resize($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_width'), JO_Registry::forceGet($item['module'] . '_items_screenshots_height'), true);
     } elseif ((int) JO_Registry::get($item['module'] . '_items_screenshots_width')) {
         $item['big_image'] = $image_model->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_width'));
     } elseif ((int) JO_Registry::get($item['module'] . '_items_screenshots_height')) {
         $item['big_image'] = $image_model->resizeHeight($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_height'));
     } else {
         $item['big_image'] = false;
     }
     $this->view->otherItems = array();
     $otherItems = Model_Items::getByUser($item['user_id'], 0, 4, false, 'id <> ' . (int) $item['id']);
     if ($otherItems) {
         foreach ($otherItems as $i => $ot) {
             $this->view->otherItems[] = Helper_Items::returnViewIndex($ot);
         }
     }
     $files = glob(dirname(__FILE__) . '/Payments/*.php');
     if ($files) {
         $payments_data = $sort_order = $order_obj = array();
         foreach ($files as $row => $file) {
             if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) {
                 $key = mb_strtolower($match[1], 'utf-8');
                 if (JO_Registry::forceGet($key . '_status')) {
                     JO_Loader::loadFile($file);
                     $sort_order[$row] = (int) JO_Registry::forceGet($key . '_sort_order');
                     $logo = JO_Registry::forceGet($key . '_logo');
                     if ($logo) {
                         list($width) = getimagesize('uploads/' . $logo);
                         if ($width > 70) {
                             $logo = $image_model->resizeWidth($logo, 70);
                         } else {
                             $logo = 'uploads/' . $logo;
                         }
                     } else {
                         $logo = '';
                     }
                     $payments_data[$row] = array('name' => $this->translate($match[1]), 'sort' => (int) JO_Registry::forceGet($key . '_sort_order'), 'logo' => $logo);
                 }
             }
         }
         array_multisort($sort_order, SORT_ASC, $payments_data);
         $this->view->payments = $payments_data;
     }
     $this->view->your_profit = WM_Currency::format($item['your_profit']);
     $this->view->usertotal = WM_Currency::format(JO_Session::get('total'));
     $item['price'] = WM_Currency::format($item['price']);
     $this->view->user = $user;
     $this->view->item = $item;
     $membership = Model_Membership::getAll();
     if ($membership) {
         $this->view->membership_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=membership');
         $this->view->membership_pay_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=pay_membership');
     }
     $this->view->deposit = WM_Router::create($request->getBaseUrl() . '?controller=users&action=deposit');
     $this->view->deposit_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=pay_deposit');
     $this->view->payment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=payment');
     $this->view->children = array();
     $this->view->children['rightside'] = 'items/rightside';
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
示例#8
0
 public static function getEventImage($user, $prefix = null)
 {
     $sizes = self::userThumbSizes();
     $format_size = false;
     if ($sizes) {
         foreach ($sizes as $val => $key) {
             if ($key == $prefix) {
                 $format_size = $val;
                 break;
             }
         }
     }
     if (!$format_size) {
         return false;
     }
     $model_images = new Helper_Images();
     $sizes = explode('x', $format_size);
     $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
     $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
     if ($width && $height) {
         $img = $model_images->resize($user['avatar'], $width, $height, true);
     } else {
         if ($width && !$height) {
             $img = $model_images->resizeWidth($user['avatar'], $width);
         } else {
             if ($height && !$width) {
                 $img = $model_images->resizeHeight($user['avatar'], $height);
             }
         }
     }
     if ($img) {
         return array('image' => $img, 'original' => $model_images->original($user['avatar']), 'width' => $model_images->getSizes('width'), 'height' => $model_images->getSizes('height'), 'mime' => JO_File_Ext::getMimeFromFile($img));
     }
     return false;
 }