示例#1
0
 public function configAction()
 {
     $request = $this->getRequest();
     $this->noLayout(true);
     /* price formats */
     $currencies = WM_Currency::getCurrencies();
     $price_left = array();
     $price_right = array();
     if ($currencies) {
         foreach ($currencies as $currency) {
             if (trim($currency['symbol_left'])) {
                 $price_left[] = preg_quote(trim($currency['symbol_left']));
             }
             if (trim($currency['symbol_right'])) {
                 $price_right[] = preg_quote(trim($currency['symbol_right']));
             }
         }
     }
     $price = array();
     if ($price_left) {
         $price['price_left'] = 'js:/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/';
     }
     if ($price_right) {
         $price['price_right'] = 'js:/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/';
     }
     /* config data */
     $loged = JO_Session::get('user[user_id]');
     $config = array('loged' => $loged, 'load_dynamically_extensions' => array(), 'load_dynamically_extensions_css' => array(), 'facebook_app_id' => null, 'regExPrice' => $price, 'comments_list' => (int) Helper_Config::get('config_comments_list'), 'disable_js' => (int) Helper_Config::get('config_disable_js'), 'invate_limit' => 5, 'baseUrl' => $request->getBaseUrl(), 'search_autocomplete' => WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete'), 'get_user_friends' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends'), 'edit_description' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=editDescription'), 'order_boards' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=sort_order'), 'resend_email_verification' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=resend'), 'createboardwithoutcategory' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory'), 'text' => array('text_save_description' => $this->translate('Save Description'), 'text_rearrange_boards' => $this->translate('Rearrange Boards'), 'text_save_arrangement' => $this->translate('Save Arrangement'), 'text_create_board_input' => $this->translate('Create New Board'), 'text_create_board_button' => $this->translate('Create')));
     $other_config = Model_Extensions::getByMethod('extensions_config_js');
     if (is_array($other_config)) {
         $front = $this->getFrontController();
         foreach ($other_config as $ext) {
             $settings = Model_Extensions::getSettingsPairs($ext);
             if (isset($settings[$ext . '_module_status_enable']) && $settings[$ext . '_module_status_enable']) {
                 $call = $front->formatModuleName('model_' . $ext . '_jsConfig');
                 $config = call_user_func(array($call, 'extendsConfig'), $config);
             }
         }
     }
     //format config
     $this->view->config_data = JO_Javascript::encode($config);
     $response = $this->getResponse();
     $response->addHeader('Cache-Control: no-cache, must-revalidate');
     $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     $response->addHeader('Content-type: application/javascript; charset=utf-8');
 }
示例#2
0
 public function __construct($pin_id, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $pin_info = new Model_Pins_Pin($pin_id);
         if (!$pin_info->count()) {
             return $this;
         }
         $pin_info = $pin_info->data;
         if (isset($data['board_id'])) {
             $board_info = new Model_Boards_Board($data['board_id']);
             if ($board_info->count()) {
                 $data['board_id'] = $board_info['board_board_id'];
                 $data['category_id'] = $board_info['board_category_id'];
                 $data['public'] = $board_info['board_public'];
             } else {
                 $data['board_id'] = 0;
             }
         }
         $data['likes'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM pins_likes WHERE pin_id = pins.pin_id)');
         $data['comments'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT comment_id) FROM pins_comments WHERE pin_id = pins.pin_id)');
         $data['date_modified'] = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $data['source_id'] = 0;
         //sorce
         if (isset($data['from']) && $data['from']) {
             $source = new Model_Sources_GetSourceByUrl($data['from']);
             if ($source->source_id) {
                 $data['source_id'] = $source->source_id;
             }
         }
         $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time());
         /* price */
         //$data['price'] = 0;
         if (isset($data['price']) && $data['price']) {
             $currencies = WM_Currency::getCurrencies();
             $price_left = array();
             $price_right = array();
             if ($currencies) {
                 foreach ($currencies as $currency) {
                     if (trim($currency['symbol_left'])) {
                         $price_left[] = preg_quote(trim($currency['symbol_left']));
                     }
                     if (trim($currency['symbol_right'])) {
                         $price_right[] = preg_quote(trim($currency['symbol_right']));
                     }
                 }
                 if ($price_left) {
                     if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                         $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                         $currency = self::getCurrencyBySimbol(trim($match[1]));
                         if ($currency) {
                             $data['price'] = round($price_tmp / $currency, 4);
                         }
                     }
                 }
                 if (!$data['price'] && $price_right) {
                     if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                         $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                         $currency = self::getCurrencyBySimbol(trim($match[2]));
                         if ($currency) {
                             $data['price'] = round($price_tmp / $currency, 4);
                         }
                     }
                 }
             }
         }
         /* end price */
         $from = isset($data['from']) ? $data['from'] : time();
         $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0;
         if (!$data['is_video']) {
             $auto = new Helper_AutoEmbed();
             if ($auto->parseUrl($from)) {
                 $data['is_video'] = 1;
             }
         }
         /* is video */
         ///////////////// Event onComplete /////////////////////
         $on_add_call = Helper_Config::get('pin_onbefore_edit');
         if ($on_add_call) {
             foreach ($on_add_call as $call) {
                 call_user_func($call, $data);
             }
         }
         //edit pin
         $result = Helper_Db::update('pins', $data, array('pin_id = ?' => $pin_id));
         ///////////////// update latest pins for board /////////////////////
         if (isset($data['board_id']) && $data['board_id'] && $pin_info['pin_board_id'] != $data['board_id']) {
             new Model_Boards_UpdateLatestPins($data['board_id']);
             new Model_Boards_UpdateLatestPins($pin_info['pin_board_id']);
             $board_info = new Model_Boards_Board($data['board_id']);
             if ($board_info->count()) {
                 if ($board_info['board_cover'] == $pin_id) {
                     $res = Helper_Db::update('boards', array('cover' => 0), array('board_id = >' => $pin_info['pin_board_id']));
                     if (!$result && $res) {
                         $result = $res;
                     }
                 }
             }
         }
         ///////////////// update latest pins for user /////////////////////
         new Model_Users_UpdateLatestPins($pin_info['pin_user_id']);
         ///////////////// Word for search index's /////////////////////
         $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
         $words = array();
         foreach ($spl as $word) {
             $word = mb_strtolower($word, 'utf-8');
             if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') {
                 $words[$word] = $word;
             }
         }
         ///////////////// Word for search index's insert /////////////////////
         Helper_Db::delete('pins_invert', array('pin_id = ?' => $pin_id));
         foreach ($words as $word => $data1) {
             $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
             if (!$dic_id) {
                 $dic_id = Helper_Db::insert('pins_dictionary', array('word' => $word));
             }
             if ($dic_id) {
                 $res = Helper_Db::insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id));
                 if (!$result && $res) {
                     $result = $res;
                 }
             }
         }
         ///////////////// Extension on edit //////////////////
         $extensions = Model_Extensions::getByMethod('pin_onedit');
         if ($extensions) {
             $front = JO_Front::getInstance();
             foreach ($extensions as $id => $ext) {
                 $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'onedit'), $pin_id, $data);
                 if ($pin_data_ext && is_array($pin_data_ext)) {
                     $data = array_merge(data, $pin_data_ext);
                 }
             }
         }
         ///////////////// Event onComplete /////////////////////
         $trigger = new Helper_Triggers_PinOnEdit();
         $trigger->bind($pin_id);
         $this->affected_rows = $result;
         $db->commit();
     } catch (JO_Exception $e) {
         echo $e;
         exit;
         $db->rollBack();
     }
 }
示例#3
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
         Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
         JO_Session::clear('category_id');
         $this->view->user_info = JO_Session::get('user');
         Model_Email::send(JO_Session::get('user[email]'), JO_Registry::get('noreply_mail'), sprintf($this->translate('Welcome to %s!'), JO_Registry::get('site_name')), $this->view->render('welcome', 'mail'));
     }
     $this->view->og_namespace = trim(JO_Registry::get('og_namespace'));
     $this->view->og_recipe = trim(JO_Registry::get('og_recipe'));
     if (!$this->view->og_recipe) {
         $this->view->og_namespace = '';
     }
     $this->view->show_landing = !JO_Registry::get('enable_free_registration');
     $to_title = '';
     if (JO_Session::get('user[user_id]')) {
         $to_title = JO_Session::get('user[fullname]') . ' / ';
     }
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . JO_Registry::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', $to_title . JO_Registry::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', JO_Registry::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', JO_Registry::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('site_name', JO_Registry::get('site_name'));
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->meta_title = JO_Registry::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(JO_Registry::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . JO_Registry::get('site_logo');
     }
     if (JO_Registry::get('favicon') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('favicon'))) {
         $this->getLayout()->placeholder('favicon', $request->getBaseUrl() . 'uploads' . JO_Registry::get('favicon'));
     }
     $this->getLayout()->placeholder('site_logo', $this->view->site_logo);
     $this->view->show_header_invate = !JO_Session::get('user[user_id]');
     if (!JO_Session::get('user[user_id]')) {
         switch (true) {
             case $request->getAction() == 'login':
                 $this->view->show_header_invate = true;
             case $request->getAction() == 'register':
                 $this->view->show_header_invate = true;
                 break;
         }
     }
     $this->view->controller_open = $request->getController();
     $this->view->show_header_line = !in_array($request->getController(), array('pin'));
     $this->view->show_slider = !in_array($request->getController(), array('users', 'pin', 'settings', 'prefs', 'password'));
     if ($request->getController() == 'users') {
         $this->view->show_header_line = false;
     }
     //==== brand =====//
     $this->view->show_brand = true;
     if (JO_Registry::get('license_powered_check') == 'false' && JO_Registry::get('config_hide_brand')) {
         $this->view->show_brand = false;
     }
     ////////// CURRENCY
     //autoupdate currency if set
     if (JO_Registry::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
     }
     $currencies = WM_Currency::getCurrencies();
     $price_left = array();
     $price_right = array();
     if ($currencies) {
         foreach ($currencies as $currency) {
             if (trim($currency['symbol_left'])) {
                 $price_left[] = preg_quote(trim($currency['symbol_left']));
             }
             if (trim($currency['symbol_right'])) {
                 $price_right[] = preg_quote(trim($currency['symbol_right']));
             }
         }
     }
     $this->view->price_left = implode('|', $price_left);
     $this->view->price_right = implode('|', $price_right);
     //////////// Categories ////////////
     $this->view->categories = array();
     $categories1 = array("0" => array("category_id" => "9999", "title" => "TODO", "image" => ""));
     $this->view->category_active = false;
     $categories2 = Model_Categories::getCategories(array('filter_status' => 1));
     $categories = array_merge($categories1, $categories2);
     $x = 0;
     foreach ($categories as $category) {
         if ($x == 0) {
             $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
             $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=all&category_id=' . $category['category_id']);
             if ($request->getRequest('category_id') == 9999) {
                 $category['active'] = TRUE;
                 $this->view->category_active = $category['title'];
             } else {
                 $category['active'] = FALSE;
             }
             $this->view->categories[] = $category;
         } else {
             $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
             $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $category['category_id']);
             $category['active'] = $category['category_id'] == $request->getRequest('category_id');
             if ($category['active']) {
                 $this->view->category_active = $category['title'];
             } else {
                 $i = 0;
                 foreach ($category['subcategories'] as $subcategory) {
                     $category['subcategories'][$i]['active'] = $subcategory['category_id'] == $request->getRequest('category_id');
                     if ($category['subcategories'][$i]['active']) {
                         $this->view->category_active = $subcategory['title'];
                     }
                     $i++;
                 }
             }
             $this->view->categories[] = $category;
         }
         $x = 1;
     }
     ////////////////////////////// USER MENU ///////////////////////////
     $this->view->is_loged = JO_Session::get('user[user_id]');
     if ($this->view->is_loged) {
         $model_images = new Helper_Images();
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $this->view->self_avatar = $avatar['image'];
         $this->view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $this->view->is_loged);
         $this->view->mails = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mails');
         $this->view->self_firstname = JO_Session::get('user[firstname]');
         $this->view->logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
         $this->view->invites = WM_Router::create($request->getBaseUrl() . '?controller=invites');
         $this->view->invites_fb = WM_Router::create($request->getBaseUrl() . '?controller=invites&action=facebook');
         $this->view->user_pins = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged);
         $this->view->user_pins_likes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged . '&filter=likes');
         $this->view->settings = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->landing = WM_Router::create($request->getBaseUrl() . '?controller=landing');
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register');
     $category_id = null;
     if ($request->getRequest('category_id')) {
         $category_id = $request->getRequest('category_id');
         ////////////////////////////// GIFTS ///////////////////////////
         $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts&category_id=' . $category_id);
         $this->view->gifts1 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=1&price_to=20&category_id=' . $category_id);
         $this->view->gifts2 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=20&price_to=50&category_id=' . $category_id);
         $this->view->gifts3 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=50&price_to=100&category_id=' . $category_id);
         $this->view->gifts4 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=100&price_to=200&category_id=' . $category_id);
         $this->view->gifts5 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=200&price_to=500&category_id=' . $category_id);
         $this->view->gifts6 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=500&category_id=' . $category_id);
         //////////// Video ////////////
         $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos&category_id=' . $category_id);
         /*
                             //////////// Popular ////////////
                             $this->view->popular_url = WM_Router::create( $request->getBaseUrl() . '?controller=popular&category_id='.$category_id );
         */
         //////////// Articles ////////////
         $this->view->article_url = WM_Router::create($request->getBaseUrl() . '?controller=articles&category_id=' . $category_id);
         //////////// Ranking ////////////
         $this->view->pinTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=1&category_id=' . $category_id);
         $this->view->pinTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=2&category_id=' . $category_id);
         $this->view->profileTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=3&category_id=' . $category_id);
         $this->view->profileTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=4&category_id=' . $category_id);
     } else {
         ////////////////////////////// GIFTS ///////////////////////////
         $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts');
         $this->view->gifts1 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=1&price_to=20');
         $this->view->gifts2 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=20&price_to=50');
         $this->view->gifts3 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=50&price_to=100');
         $this->view->gifts4 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=100&price_to=200');
         $this->view->gifts5 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=200&price_to=500');
         $this->view->gifts6 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=500');
         //////////// Video ////////////
         $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos');
         /*
                             //////////// Popular ////////////
                             $this->view->popular_url = WM_Router::create( $request->getBaseUrl() . '?controller=popular' );
         */
         //////////// Articles ////////////
         $this->view->article_url = WM_Router::create($request->getBaseUrl() . '?controller=articles');
         //////////// Ranking ////////////
         $this->view->pinTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=1');
         $this->view->pinTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=2');
         $this->view->profileTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=3');
         $this->view->profileTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=4');
     }
     //////////// Popular ////////////
     $this->view->popular_url = WM_Router::create($request->getBaseUrl() . '?controller=premiostt');
     //////////// ALL PINS ////////////
     $this->view->all_url = WM_Router::create($request->getBaseUrl() . '?controller=all');
     //////////// activate ////////////
     $this->view->activate_url = WM_Router::create($request->getBaseUrl() . '?controller=index&action=indexActivate');
     //////////// Eventtos ////////////
     $this->view->events_url = WM_Router::create($request->getBaseUrl() . '?controller=events');
     //////////// Volunttarios ////////////
     if ($this->view->is_loged) {
         $this->view->voluntarios_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=voluntarioMenuPopup&user_id=' . $this->view->is_loged);
     } else {
         $this->view->voluntarios_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=voluntarioMenuPopup');
     }
     ////////////////////////////// SEARCH ///////////////////////////
     //$this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     if (in_array($request->getAction(), array('advanced', 'page', 'view'))) {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } elseif (in_array($request->getAction(), array('advanced', 'advanced'))) {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } else {
         $with_action = 0;
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     }
     //$this->view->search_autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     if (strpos($this->view->search, '?') !== false) {
         $this->view->show_hidden = true;
         $this->view->with_action = $with_action;
     }
     //$this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search...');
     /*
     		if(in_array($request->getAction(), array('amatteur'))) {
     			$with_action = 0;
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search');
     		} elseif( in_array($request->getAction(), array('activate', 'services')) ) {
     			$with_action = $request->getAction();
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search&action='.$request->getAction());
     } else {
     			$with_action = 0;
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search');
     		}
     		
     		$this->view->search_autocomplete_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     		if(strpos($this->view->search_advanced, '?') !== false) {
     			$this->view->show_hidden = true;
     			$this->view->with_action = $with_action;    
     		}
     		
     		$this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search...');
     */
     $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=amatteur');
     ////////////////////////////// ADD PIN ///////////////////////////
     $this->view->addPin = WM_Router::create($request->getBaseUrl() . '?controller=addpin');
     ////////////////////////////// MAILS ///////////////////////////
     $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create');
     $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state');
     $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view');
     ////////////////////////////// FULL URL ///////////////////////////
     $this->view->full_url_js = false;
     switch (true) {
         case 'index' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl());
             break;
         case 'search' == $request->getController():
             if (in_array($request->getAction(), array('index', 'page', 'view'))) {
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getRequest('q'));
             } else {
                 $parametros = "";
                 $this->view->keywords = $request->issetQuery('location') ? $request->getQuery('location') : $this->translate('Search...');
                 /*
                                                     if ($request->issetPost('firstname'))
                                                     {
                    $parametros .= "&firstname=". $request->getPost('firstname');
                                                     } 
                 
                                                     if ($request->issetPost('words'))
                                                     {
                    $parametros .= "&words=". $request->getPost('words');
                                                     } 
                                                     if ($request->issetPost('location'))
                                                     {
                    $parametros .= "&location=". $request->getPost('location');
                                                     } 
                                                     if ($request->issetPost('sport_category_1'))
                                                     {
                    $parametros .= "&sport_category_1=". $request->getPost('sport_category_1');
                                                     }         
                                                     if ($request->issetPost('sport_category_2'))
                                                     {
                    $parametros .= "&sport_category_2=". $request->getPost('sport_category_2');
                                                     }
                                                     if ($request->issetPost('sport_category_3'))
                                                     {
                    $parametros .= "&sport_category_3=". $request->getPost('sport_category_3');
                                                     } 
                                                     if ($request->issetPost('type_user'))
                                                     {
                    $parametros .= "&type_user="******"&gender=". $request->getRequest('gender');
                                                     } 
                 
                                                     //location		
                                                     if ($request->issetPost('location'))
                                                     {
                    $parametros .= "&location=". $request->getPost('location');
                                                     } 
                 
                                                     //sport category
                                                     if ($request->issetPost('sport_category'))
                                                     {
                    $parametros .= "&sport_category=". $request->getPost('sport_category');
                                                     } 
                 
                                                     //age
                                                     if ($request->issetPost('age'))
                                                     {
                    $parametros .= "&age=". $request->getPost('age');
                                                     } 
                 
                                                     //level
                                                     if ($request->issetPost('level'))
                                                     {
                    $parametros .= "&level=". $request->getPost('level');
                                                     } 
                 
                                                     //option1		
                                                     if ($request->issetPost('option1'))
                                                     {
                    $parametros .= "&option1=". $request->getPost('option1');
                                                     } 
                 
                                                     //option2		
                                                     if ($request->issetPost('option2'))
                                                     {
                    $parametros .= "&option2=". $request->getPost('option2');
                                                     } 
                 
                                                     //option3
                                                     if ($request->issetPost('option3'))
                                                     {
                    $parametros .= "&option3=". $request->getPost('option3');
                                                     } 
                 
                                                     //option4		
                                                     if ($request->issetPost('option4'))
                                                     {
                    $parametros .= "&option4=". $request->getPost('option4');
                                                     } 
                 
                                                     //option5		
                                                     if ($request->issetPost('option5'))
                                                     {
                    $parametros .= "&option5=". $request->getPost('option5');
                                                     } 
                 
                                                     //option6		
                                                     if ($request->issetPost('option6'))
                                                     {
                    $parametros .= "&option6=". $request->getPost('option6');
                                                     } 
                 
                                                     //option7		
                                                     if ($request->issetPost('option7'))
                                                     {
                    $parametros .= "&option7=". $request->getPost('option7');
                                                     } 
                 
                                                     //option8		
                                                     if ($request->issetPost('option8'))
                                                     {
                    $parametros .= "&option8=". $request->getPost('option8');
                                                     } 
                 
                                                     //option9		
                                                     if ($request->issetPost('option9'))
                                                     {
                    $parametros .= "&option9=". $request->getPost('option9');
                                                     } 
                 
                                                     //option10		
                                                     if ($request->issetPost('option10'))
                                                     {
                    $parametros .= "&option10=". $request->getPost('option10');
                                                     }
                                                     
                                                     //option11		
                                                     if ($request->issetPost('option11'))
                                                     {
                    $parametros .= "&option11=". $request->getPost('option11');
                                                     } 
                 
                                                     //option12		
                                                     if ($request->issetPost('option12'))
                                                     {
                    $parametros .= "&option12=". $request->getPost('option12');
                                                     } 
                 
                                                     //option13
                                                     if ($request->issetPost('option13'))
                                                     {
                    $parametros .= "&option13=". $request->getPost('option13');
                                                     } 
                 
                                                     //option14		
                                                     if ($request->issetPost('option14'))
                                                     {
                    $parametros .= "&option14=". $request->getPost('option14');
                                                     } 
                 
                                                     //option15		
                                                     if ($request->issetPost('option15'))
                                                     {
                    $parametros .= "&option15=". $request->getPost('option15');
                                                     } 
                 
                                                     //option16		
                                                     if ($request->issetPost('option16'))
                                                     {
                    $parametros .= "&option16=". $request->getPost('option16');
                                                     } 
                 
                                                     //option17		
                                                     if ($request->issetPost('option17'))
                                                     {
                    $parametros .= "&option17=". $request->getPost('option17');
                                                     } 
                 
                                                     //option18		
                                                     if ($request->issetPost('option18'))
                                                     {
                    $parametros .= "&option18=". $request->getPost('option18');
                                                     } 
                 * 
                 */
                 if ($request->issetRequest('zoom')) {
                     $parametros .= "&zoom=" . $request->getRequest('zoom');
                 }
                 if ($request->issetRequest('id')) {
                     $parametros .= "&id=" . $request->getRequest('id');
                 }
                 if ($request->issetRequest('firstname')) {
                     $parametros .= "&firstname=" . $request->getRequest('firstname');
                 }
                 if ($request->issetRequest('words')) {
                     $parametros .= "&words=" . $request->getRequest('words');
                 }
                 if ($request->issetRequest('location')) {
                     $parametros .= "&location=" . $request->getRequest('location');
                 }
                 if ($request->issetRequest('sport_category_1')) {
                     $parametros .= "&sport_category_1=" . $request->getRequest('sport_category_1');
                 }
                 if ($request->issetRequest('sport_category_2')) {
                     $parametros .= "&sport_category_2=" . $request->getRequest('sport_category_2');
                 }
                 if ($request->issetRequest('sport_category_3')) {
                     $parametros .= "&sport_category_3=" . $request->getRequest('sport_category_3');
                 }
                 if ($request->issetRequest('type_user')) {
                     $parametros .= "&type_user="******"&gender=" . $request->getRequest('gender');
                 }
                 //location
                 if ($request->issetRequest('location')) {
                     $parametros .= "&location=" . $request->getRequest('location');
                 }
                 //sport category
                 if ($request->issetRequest('sport_category')) {
                     $parametros .= "&sport_category=" . $request->getRequest('sport_category');
                 }
                 //age
                 if ($request->issetRequest('age')) {
                     $parametros .= "&age=" . $request->getRequest('age');
                 }
                 //level
                 if ($request->issetRequest('level')) {
                     $parametros .= "&level=" . $request->getRequest('level');
                 }
                 //option1
                 if ($request->issetRequest('option1')) {
                     $parametros .= "&option1=" . $request->getRequest('option1');
                 }
                 //option2
                 if ($request->issetRequest('option2')) {
                     $parametros .= "&option2=" . $request->getRequest('option2');
                 }
                 //option3
                 if ($request->issetRequest('option3')) {
                     $parametros .= "&option3=" . $request->getRequest('option3');
                 }
                 //option4
                 if ($request->issetRequest('option4')) {
                     $parametros .= "&option4=" . $request->getRequest('option4');
                 }
                 //option5
                 if ($request->issetRequest('option5')) {
                     $parametros .= "&option5=" . $request->getRequest('option5');
                 }
                 //option6
                 if ($request->issetRequest('option6')) {
                     $parametros .= "&option6=" . $request->getRequest('option6');
                 }
                 //option7
                 if ($request->issetRequest('option7')) {
                     $parametros .= "&option7=" . $request->getRequest('option7');
                 }
                 //option8
                 if ($request->issetRequest('option8')) {
                     $parametros .= "&option8=" . $request->getRequest('option8');
                 }
                 //option9
                 if ($request->issetRequest('option9')) {
                     $parametros .= "&option9=" . $request->getRequest('option9');
                 }
                 //option10
                 if ($request->issetRequest('option10')) {
                     $parametros .= "&option10=" . $request->getRequest('option10');
                 }
                 //option11
                 if ($request->issetRequest('option11')) {
                     $parametros .= "&option11=" . $request->getRequest('option11');
                 }
                 //option12
                 if ($request->issetRequest('option12')) {
                     $parametros .= "&option12=" . $request->getRequest('option12');
                 }
                 //option13
                 if ($request->issetRequest('option13')) {
                     $parametros .= "&option13=" . $request->getRequest('option13');
                 }
                 //option14
                 if ($request->issetRequest('option14')) {
                     $parametros .= "&option14=" . $request->getRequest('option14');
                 }
                 //option15
                 if ($request->issetRequest('option15')) {
                     $parametros .= "&option15=" . $request->getRequest('option15');
                 }
                 //option16
                 if ($request->issetRequest('option16')) {
                     $parametros .= "&option16=" . $request->getRequest('option16');
                 }
                 //option17
                 if ($request->issetRequest('option17')) {
                     $parametros .= "&option17=" . $request->getRequest('option17');
                 }
                 //option18
                 if ($request->issetRequest('option18')) {
                     $parametros .= "&option18=" . $request->getRequest('option18');
                 }
                 $parametros .= "&kk=kk";
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction() . '&q=' . $request->getRequest('q') . '&id=' . $request->getRequest('id') . $parametros);
             }
             break;
         case 'all' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=all');
             break;
         case 'videos' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=videos');
             break;
         case 'popular' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=popular');
             break;
         case 'category' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $request->getRequest('category_id'));
             break;
         case 'source' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $request->getRequest('source_id'));
             break;
         case 'boards' == $request->getController() && in_array($request->getAction(), array('index', 'page')):
             $url = '';
             if ($request->getRequest('user_id')) {
                 $url = '&user_id=' . $request->getRequest('user_id');
             }
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view' . $url . '&board_id=' . $request->getRequest('board_id'));
             break;
         case 'gifts' == $request->getController():
             $url = '';
             if ($request->issetParam('price_from')) {
                 $url .= (int) $request->getRequest('price_from');
             }
             if ($request->issetParam('price_to')) {
                 $url .= ':' . (int) $request->getRequest('price_to');
             }
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=gifts' . ($url ? '&action=' . $url : ''));
             break;
         case 'users' == $request->getController():
             if (in_array($request->getAction(), array('pins', 'followers', 'following', 'likers', 'liking', 'activity')) && $request->getRequest('user_id')) {
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=users&action=' . $request->getAction() . '&user_id=' . $request->getRequest('user_id') . ($request->getQuery('filter') ? '&filter=' . $request->getQuery('filter') : ''));
             }
             break;
     }
     if ($request->getRequest('user_id')) {
         $user_info = Model_Users::getUser($request->getRequest('user_id'));
         if ($user_info && $user_info['dont_search_index']) {
             $this->getLayout()->placeholder('inhead', '<meta name="robots" content="noindex"/>');
         }
     }
     ////////////////////////////// ABOUT MENU ///////////////////////////
     $this->view->about_menu = array();
     $has = false;
     if (is_array(JO_Registry::forceGet('about_menu'))) {
         foreach (JO_Registry::forceGet('about_menu') as $row => $page_id) {
             if ($row == 0) {
                 $class = 'first';
             } else {
                 if (count(JO_Registry::forceGet('about_menu')) - 1 == $row) {
                     $class = 'last';
                 } else {
                     $class = '';
                 }
             }
             //				$class = $row==0?' first':'';
             if ($page_id == -1) {
                 $has = true;
             } else {
                 $pinfo = Model_Pages::getPage($page_id);
                 if ($pinfo && $pinfo['status']) {
                     if ($has) {
                         $class .= " group";
                         $has = false;
                     }
                     $this->view->about_menu[] = array('class' => trim($class), 'title' => $pinfo['title'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_id));
                 }
             }
         }
     }
     ////////////////////////////// NEW PASSWORD ///////////////////////////
     $this->view->show_new_password = false;
     if (JO_Session::get('user[user_id]') && JO_Session::get('user[email]') != JO_Session::get('user[new_email]')) {
         switch (true) {
             case 'index' == $request->getController():
             case 'all' == $request->getController():
             case 'category' == $request->getController():
             case 'videos' == $request->getController():
             case 'popular' == $request->getController():
             case 'gifts' == $request->getController():
                 $this->view->show_new_password = true;
                 break;
         }
     }
     ////////////////////////////// Board category ///////////////////////////
     if (is_array($board_info = JO_Registry::forceGet('board_category_change'))) {
         $this->view->board_category_change = array('title' => $board_info['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']));
     }
 }
示例#4
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     $data['category_id'] = 0;
     $data['public'] = 1;
     if (isset($data['board_id'])) {
         $board_info = new Model_Boards_Board($data['board_id']);
         if ($board_info->count()) {
             $data['board_id'] = $board_info['board_board_id'];
             $data['category_id'] = $board_info['board_category_id'];
             $data['public'] = $board_info['board_public'];
         } else {
             $data['board_id'] = 0;
         }
     } else {
         $data['board_id'] = 0;
     }
     $data['date_added'] = WM_Date::format(time(), 'yy-mm-dd H:i:s');
     $data['date_modified'] = $data['date_added'];
     $data['user_id'] = isset($data['user_id']) ? $data['user_id'] : (string) JO_Session::get('user[user_id]');
     $data['store'] = Helper_Config::get('file_upload_method') ? Helper_Config::get('file_upload_method') : 'Model_Upload_Locale';
     $data['source_id'] = 0;
     //sorce
     if (isset($data['from']) && $data['from']) {
         $source = new Model_Sources_GetSourceByUrl($data['from']);
         if ($source->source_id) {
             $data['source_id'] = $source->source_id;
         }
     }
     $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time());
     /* price */
     //$data['price'] = 0;
     if (isset($data['price']) && $data['price']) {
         $currencies = WM_Currency::getCurrencies();
         $price_left = array();
         $price_right = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 if (trim($currency['symbol_left'])) {
                     $price_left[] = preg_quote(trim($currency['symbol_left']));
                 }
                 if (trim($currency['symbol_right'])) {
                     $price_right[] = preg_quote(trim($currency['symbol_right']));
                 }
             }
             if ($price_left) {
                 if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[1]));
                     if ($currency) {
                         $data['price'] = round($price_tmp / $currency, 4);
                     }
                 }
             }
             if (!$data['price'] && $price_right) {
                 if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[2]));
                     if ($currency) {
                         $data['price'] = round($price_tmp / $currency, 4);
                     }
                 }
             }
         }
     }
     /* end price */
     $from = isset($data['from']) ? $data['from'] : time();
     $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0;
     if (!$data['is_video']) {
         $auto = new Helper_AutoEmbed();
         if ($auto->parseUrl($from)) {
             $data['is_video'] = 1;
         }
     }
     /* is video */
     ///////////////// Event onComplete /////////////////////
     $on_add_call = Helper_Config::get('pin_onbefore_create');
     if ($on_add_call) {
         foreach ($on_add_call as $call) {
             call_user_func($call, $data);
         }
     }
     ///////////////// upload image /////////////////////
     $image = false;
     if (isset($data['media']) && !isset($data['image'])) {
         $image = $data['media'];
     } else {
         if (isset($data['image'])) {
             $image = $data['image'];
         }
     }
     if (!isset($data['gallery']) && !$image) {
         return $this;
     }
     $data['image'] = '';
     //create pin
     $data['pin_id'] = Helper_Db::insert('pins', $data);
     if (!$data['pin_id']) {
         return $this;
     }
     if (isset($data['gallery'])) {
         if (is_array($data['gallery']) && count($data['gallery']) > 0) {
             $method_for_upload = Helper_Config::get('file_upload_method');
             if ($method_for_upload) {
                 foreach ($data['gallery'] as $row => $image_get) {
                     if ($this->error) {
                         return $this;
                     }
                     $image = call_user_func(array($method_for_upload, 'uploadPin'), $image_get, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']);
                     $this->error = call_user_func(array($method_for_upload, 'getError'));
                     if ($image && isset($image['image'])) {
                         if ($row == 0) {
                             Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id']));
                         } else {
                             $gal_id = Helper_Db::insert('pins_gallery', array('image' => $image['image'], 'store' => $image['store'], 'pin_id' => $data['pin_id'], 'sort_order' => $row));
                             if (!$gal_id) {
                                 return $this;
                             }
                         }
                     } else {
                         return $this;
                     }
                 }
             } else {
                 Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
                 return $this;
             }
         } else {
             Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
             return $this;
         }
     } else {
         $method_for_upload = Helper_Config::get('file_upload_method');
         if ($method_for_upload && $image) {
             $image = call_user_func(array($method_for_upload, 'uploadPin'), $image, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']);
             $this->error = call_user_func(array($method_for_upload, 'getError'));
             if ($image && isset($image['image'])) {
                 Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id']));
             } else {
                 Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
                 return $this;
             }
         } else {
             Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
             return $this;
         }
     }
     ///////////////// update latest pins for board /////////////////////
     if (isset($data['board_id']) && $data['board_id']) {
         new Model_Boards_UpdateLatestPins($data['board_id']);
     }
     ///////////////// update latest pins for user /////////////////////
     new Model_Users_UpdateLatestPins($data['user_id']);
     ///////////////// Pin total repins /////////////////////
     if (isset($data['repin_from']) && $data['repin_from']) {
         $pin_repin = new Model_Pins_Pin($data['repin_from']);
         if ($pin_repin->count()) {
             Helper_Db::update('pins', array('repins' => $db->fetchOne($db->select()->from('pins', 'COUNT(pin_id)')->where('repin_from = ?', $data['repin_from'])->limit(1))), array('pin_id = ?' => $data['repin_from']));
         }
     }
     ///////////////// Word for search index's /////////////////////
     $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
     $words = array();
     foreach ($spl as $word) {
         $word = mb_strtolower($word, 'utf-8');
         if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') {
             $words[$word] = $word;
         }
     }
     ///////////////// Word for search index's insert /////////////////////
     foreach ($words as $word => $data1) {
         $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
         if (!$dic_id) {
             $db->insert('pins_dictionary', array('word' => $word));
             $dic_id = $db->lastInsertId();
         }
         if ($dic_id) {
             $db->insert('pins_invert', array('pin_id' => $data['pin_id'], 'dic_id' => $dic_id));
         }
     }
     Helper_Db::delete('pins_images', array('pin_id = ?' => $data['pin_id']));
     ///////////////// Extension on create //////////////////
     $extensions = Model_Extensions::getByMethod('pin_oncreate');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'oncreate'), $data['pin_id'], $data);
             if ($pin_data_ext && is_array($pin_data_ext)) {
                 $data = array_merge(data, $pin_data_ext);
             }
         }
     }
     ///////////////// Event onComplete /////////////////////
     $trigger = new Helper_Triggers_PinOnCreate();
     $trigger->bind($data['pin_id']);
     $this->data = $data;
     // 		parent::__construct($data);
 }
示例#5
0
 public static function create($data)
 {
     $board_info = Model_Boards::getBoard($data['board_id']);
     $db = JO_Db::getDefaultAdapter();
     $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s');
     $image = '';
     $price = '';
     $source_id = Model_Source::getSourceByUrl($data['from']);
     /* price */
     $currencies = WM_Currency::getCurrencies();
     $price_left = '';
     $price_right = '';
     if ($currencies) {
         foreach ($currencies as $currency) {
             if (trim($currency['symbol_left'])) {
                 $price_left[] = preg_quote(trim($currency['symbol_left']));
             }
             if (trim($currency['symbol_right'])) {
                 $price_right[] = preg_quote(trim($currency['symbol_right']));
             }
         }
         if ($price_left) {
             if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                 $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                 $currency = self::getCurrencyBySimbol(trim($match[1]));
                 if ($currency) {
                     $price = round($price_tmp / $currency, 4);
                 }
             }
         }
         if (!$price && $price_right) {
             if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                 $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                 $currency = self::getCurrencyBySimbol(trim($match[2]));
                 if ($currency) {
                     $price = round($price_tmp / $currency, 4);
                 }
             }
         }
     }
     /* end price */
     $from = isset($data['from']) ? $data['from'] : time();
     $is_video = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0;
     if (!$is_video) {
         $auto = new Helper_AutoEmbed();
         if ($auto->parseUrl($from)) {
             $is_video = 1;
         }
     }
     /* add to db */
     $db->insert('pins', array('category_id' => (string) $board_info['category_id'], 'board_id' => (string) $data['board_id'], 'user_id' => (string) JO_Session::get('user[user_id]'), 'date_added' => $date_added, 'date_modified' => $date_added, 'description' => $data['description'], 'title' => isset($data['title']) ? $data['title'] : '', 'price' => $price, 'from' => $from, 'from_md5' => md5($from), 'is_video' => $is_video, 'source_id' => isset($data['source_id']) ? $data['source_id'] : $source_id, 'via' => isset($data['via']) ? $data['via'] : '', 'repin_from' => isset($data['repin_from']) ? $data['repin_from'] : '', 'public' => (int) $board_info['public'], 'pinmarklet' => isset($data['pinmarklet']) ? 1 : 0, 'from_repin' => isset($data['from_repin']) ? $data['from_repin'] : '', 'store' => JO_Registry::get('default_upload_method') ? JO_Registry::get('default_upload_method') : 'locale'));
     $pin_id = $db->lastInsertId();
     if (!$pin_id) {
         return false;
     }
     ///// upload images
     $front = JO_Front::getInstance();
     $request = JO_Request::getInstance();
     $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method'));
     $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
     if (!file_exists($upload_model_file)) {
         $upload_model = Helper_Pin::formatUploadModule('locale');
         $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
     }
     $image = false;
     if (file_exists($upload_model_file)) {
         $image = call_user_func(array($upload_model, 'uploadPin'), $data['image'], isset($data['title']) && $data['title'] ? $data['title'] : null, $pin_id);
     }
     // 		if(!$image && $upload_model != $front->formatModuleName('model_upload_locale')) {
     // 			$image = call_user_func(array($upload_model, 'uploadPin'), $data['image'], (isset($data['title']) && $data['title'] ? $data['title'] : null), $pin_id );
     // 		}
     if (!$image) {
         $db->delete('pins', array('pin_id = ?' => (string) $pin_id));
         return false;
     } else {
         $db->update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $pin_id));
     }
     //if($board_info['user_id'] == JO_Session::get('user[user_id]')) {
     Model_Boards::updateLatestPins($data['board_id'], $pin_id);
     //}
     Model_Users::updateLatestPins($pin_id);
     if (isset($data['repin_from']) && $data['repin_from']) {
         $pin_repin = self::getPin($data['repin_from']);
         if ($pin_repin) {
             $db->update('pins', array('repins' => $pin_repin['repins'] + 1), array('pin_id = ?' => $data['repin_from']));
         }
     }
     $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
     $words = array();
     foreach ($spl as $word) {
         $word = mb_strtolower($word, 'utf-8');
         if (!in_array($word, self::common()) && $word[0] . $word[1] != '&#') {
             $words[$word] = $word;
         }
     }
     foreach ($words as $word => $data1) {
         $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
         if (!$dic_id) {
             $db->insert('pins_dictionary', array('word' => $word));
             $dic_id = $db->lastInsertId();
         }
         if ($dic_id) {
             $db->insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id));
         }
     }
     if (JO_Session::get('user[facebook_connect]') && JO_Session::get('user[facebook_timeline]')) {
         try {
             $session = JO_Registry::get('facebookapi')->getUser();
             JO_Registry::get('facebookapi')->setExtendedAccessToken();
             if (JO_Registry::get('facebookapi')->api('/me')) {
                 $access_token = JO_Registry::get('facebookapi')->getAccessToken();
                 $pin_url = WM_Router::create(JO_Request::getInstance()->getBaseUrl() . '?controller=pin&pin_id=' . $pin_id);
                 $statusUpdate = JO_Registry::get('facebookapi')->api('/me/feed', 'post', array('link' => $pin_url, 'cb' => ''));
                 $og_namespace = trim(JO_Registry::get('og_namespace'));
                 $og_recipe = trim(JO_Registry::get('og_recipe'));
                 if (!$og_recipe) {
                     $og_namespace = '';
                 }
                 if ($og_namespace) {
                     $params = array($og_recipe => $pin_url, 'access_token' => $access_token);
                     $response = JO_Registry::get('facebookapi')->api('/me/' . $og_namespace . ':' . $og_recipe, 'post', $params);
                 }
             }
         } catch (JO_Exception $e) {
         }
     }
     self::rebuildCache(array($pin_id));
     if (isset($data['repin_from'])) {
         self::rebuildCache($data['repin_from']);
     }
     return $pin_id;
 }
示例#6
0
 public static function edit($pin_id, $data)
 {
     $pin_info = self::getPin($pin_id);
     if (!$pin_info) {
         return;
     }
     $db = JO_Db::getDefaultAdapter();
     $date_modified = WM_Date::format(time(), 'yy-mm-dd H:i:s');
     $board_info = Model_Boards::getBoard($data['board_id']);
     $source_id = Model_Source::getSourceByUrl($data['from']);
     /* price */
     $price = $pin_info['price'];
     /*if( preg_match('/(\$|\£|\€|\¥|\₪|zł|\฿)([\s]{0,2})?(?:(?:\d{1,5}(?:\,\d{3})+)|(?:\d+))(?:\.\d{2})?/', $data['price'], $match) ) {
     			$price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
     			$currency = self::getCurrencyBySimbol(trim($match[1]));
     			if($currency) {
     				$price = round( $price_tmp / $currency, 4 );
     			}
     		}*/
     if (isset($pin_info['price']) && $pin_info['price']) {
         $currencies = WM_Currency::getCurrencies();
         $price_left = array();
         $price_right = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 if (trim($currency['symbol_left'])) {
                     $price_left[] = preg_quote(trim($currency['symbol_left']));
                 }
                 if (trim($currency['symbol_right'])) {
                     $price_right[] = preg_quote(trim($currency['symbol_right']));
                 }
             }
             if ($price_left) {
                 if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[1]));
                     if ($currency) {
                         $price = round($price_tmp / $currency, 4);
                     }
                 }
             }
             if (!$pin_info['price'] && $price_right) {
                 if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[2]));
                     if ($currency) {
                         $price = round($price_tmp / $currency, 4);
                     }
                 }
             }
         }
     }
     $data['is_video'] = 'false';
     $help_video = new Helper_AutoEmbed();
     if ($help_video->parseUrl($data['from'])) {
         $data['is_video'] = 'true';
     }
     $is_update = $db->update('pins', array('category_id' => (string) $board_info['category_id'], 'board_id' => $data['board_id'], 'date_modified' => $date_modified, 'from' => $data['from'], 'from_md5' => md5($data['from']), 'description' => $data['description'], 'price' => $price, 'is_video' => $data['is_video'] == 'true' ? 1 : 0, 'source_id' => isset($data['source_id']) ? $data['source_id'] : $source_id, 'date_modified' => new JO_Db_Expr('NOW()')), array('pin_id = ?' => $pin_id));
     $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
     $words = array();
     foreach ($spl as $word) {
         $word = mb_strtolower($word, 'utf-8');
         if (!in_array($word, self::common()) && $word[0] . $word[1] != '&#') {
             $words[$word] = $word;
         }
     }
     foreach ($words as $word => $data1) {
         $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
         if (!$dic_id) {
             $db->insert('pins_dictionary', array('word' => $word));
             $dic_id = $db->lastInsertId();
         }
         if ($dic_id) {
             $db->insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id));
         }
     }
     if ($pin_info['board_id'] != $data['board_id']) {
         //mahame i slagame ot stariq i v noviq/////
         Model_Boards::updateLatestPins($pin_info['board_id']);
         Model_Boards::updateLatestPins($data['board_id']);
         $board_info2 = Model_Boards::getBoard($pin_info['board_id']);
         if ($board_info2['cover'] == $pin_id) {
             $db->update('boards', array('cover' => 0), array('board_id = >' => $pin_info['board_id']));
         }
     }
     Model_Users::updateLatestPins($pin_info['user_id']);
     self::deleteCache($pin_info);
 }
示例#7
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . JO_Registry::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', JO_Registry::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', JO_Registry::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', JO_Registry::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(JO_Registry::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads/' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = JO_Registry::get('site_logo');
     }
     $this->view->home_action = $request->getBaseUrl();
     $this->getCategories();
     $this->view->menuPages = Model_Pages::getPagesMenu();
     if (isset($this->view->menuPages[0])) {
         foreach ($this->view->menuPages[0] as $k => $v) {
             $this->view->menuPages[0][$k]['href'] = $v['url'] ? $v['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']));
             if (isset($this->view->menuPages[$v['id']])) {
                 foreach ($this->view->menuPages[$v['id']] as $r => $t) {
                     $this->view->menuPages[$v['id']][$r]['href'] = $t['url'] ? $t['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $t['id'] . '&name=' . WM_Router::clearName($t['name']));
                 }
             }
         }
     }
     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');
     }
     $this->view->recent_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=recent');
     $this->view->top_sellers_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=popular');
     $this->view->feature_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=featured');
     $this->view->collections_href = WM_Router::create($request->getBaseUrl() . '?controller=collections');
     $this->view->top_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=top');
     $this->view->all_authors_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=authors');
     $this->view->search = WM_Router::create($request->getBaseUrl() . '?controller=search');
     ////////// CURRENCY
     //autoupdate currency if set
     if (JO_Registry::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
         $currencies = WM_Currency::getCurrencies();
         $this->view->currencies = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 $currency['active'] = $currency['code'] == WM_Currency::getCurrencyCode();
                 $this->view->currencies[] = $currency;
             }
         }
     }
     ///////// LANGUAGES
     $languages = WM_Locale::getLanguages();
     if ($languages && count($languages) > 1) {
         $this->view->languages = array();
         $config_language_id = JO_Registry::get('config_language_id');
         foreach ($languages as $language) {
             if ($language['language_id'] == $config_language_id) {
                 $this->view->current_language = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             } else {
                 $this->view->languages[] = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             }
         }
     }
     $username = JO_Session::get('username');
     if ($username) {
         $this->view->user = Model_Users::getUser(JO_Session::get('user_id'));
         $this->view->user['total'] = WM_Currency::format($this->view->user['total']);
         $ind = 0;
         $this->view->options = array(array('name' => $this->view->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('My Account'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Downloads'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Collections'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Deposit'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=deposit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Dashboard'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Upload'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Earnings'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=earnings'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Statement'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=statement'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Withdrawal'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=withdrawal'), 'css' => 'icon-' . ++$ind));
         $this->view->user_logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
     } else {
         $this->view->user_registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration');
         $this->view->user_login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         $this->view->user_lost_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=lost_username');
         $this->view->user_reset_password = WM_Router::create($request->getBaseUrl() . '?controller=users&action=reset_password');
     }
     $threads = Model_Forum::getAll();
     if ($threads) {
         $this->view->forum_link = WM_Router::create($request->getBaseUrl() . '?controller=forum');
         $this->view->threads = array();
         foreach ($threads as $thread) {
             $this->view->threads[] = array('name' => $thread['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $thread['id'] . '&name=' . WM_Router::clearName($thread['name'])));
         }
     }
     $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
     $this->view->facebook_link = $facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=callback_facebook'), 'req_perms' => JO_Registry::forceGet('facebook_req_perms'), 'scope' => JO_Registry::forceGet('facebook_req_perms')));
     $this->view->children = array();
     $this->view->children['extensions_top'] = 'extensions/top';
     //	$this->view->children['extensions_topmiddle'] = 'extensions/topmiddle';
 }