Exemplo n.º 1
0
 private function getForm()
 {
     $request = $this->getRequest();
     $id = $request->getQuery('id');
     if ($id) {
         $info = Model_Smiles::getSmile($id);
     }
     $this->view->page_num = $this->getRequest()->getRequest('page', 1);
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } elseif (isset($info)) {
         $this->view->name = $info['name'];
     } else {
         $this->view->name = '';
     }
     if ($request->getPost('visible')) {
         $this->view->visible = $request->getPost('visible');
     } elseif (isset($info)) {
         $this->view->visible = $info['visible'];
     } else {
         $this->view->visible = 'true';
     }
     if ($request->getPost('code')) {
         $this->view->code = $request->getPost('code');
     } elseif (isset($info)) {
         $this->view->code = $info['code'];
     } else {
         $this->view->code = '';
     }
     if (isset($info)) {
         $this->view->photo = $info['photo'];
     } else {
         $this->view->photo = '';
     }
 }
Exemplo n.º 2
0
 public function commentsAction()
 {
     $request = $this->getRequest();
     $this->view->currency = WM_Currency::getCurrency();
     $itemID = $request->getRequest('comments');
     $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');
     }
     $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() . '?controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     JO_Session::set('redirect', $this->view->comment_link);
     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 = $item['user'] = Model_Users::getUser($item['user_id']);
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']))), array('name' => $item['name'], 'href' => $this->view->item_link), array('name' => $this->translate('Comments')));
     $model_images = new Model_Images();
     $filter = '';
     if ($request->getRequest('filter')) {
         $filter = ' AND items_comments.id = ' . (int) $request->getRequest('filter');
     }
     $bayers = Model_Orders::getBayers($itemID);
     $comments = Model_Comments::getAll(0, 0, "item_id = '" . (int) $itemID . "' AND reply_to = 0" . $filter, true);
     $this->view->smiles = Model_Smiles::getSmilesImages();
     $this->view->comments = array();
     if ($comments) {
         $bbcode_parser = new WM_BBCode_Parser();
         $bbcode_parser->loadDefaultCodes();
         foreach ($comments as $comment) {
             if ($comment['avatar']) {
                 $comment['avatar'] = $model_images->resize($comment['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
             } else {
                 $comment['avatar'] = 'data/themes/images/noavatar.png';
             }
             $bbcode_parser->parse($comment['comment']);
             $comment['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml());
             $comment['badges'] = Helper_Author::userBadges(Model_Users::getUser($comment['owner_id']));
             $comment['datetime'] = WM_Date::format($comment['datetime'], 'dd M yy', true);
             $comment['is_buy'] = $bayers && in_array($comment['user_id'], $bayers);
             $comment['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username']));
             $comment['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['id']);
             $comment['replyhref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=reply&c_id=' . $comment['id']);
             foreach ($comment['reply'] as $key => $reply) {
                 if ($comment['reply'][$key]['avatar']) {
                     $comment['reply'][$key]['avatar'] = $model_images->resize($comment['reply'][$key]['avatar'], 50, 50, true);
                 } else {
                     $comment['reply'][$key]['avatar'] = 'data/themes/images/small_noavatar.png';
                 }
                 $bbcode_parser->parse($comment['reply'][$key]['comment']);
                 $comment['reply'][$key]['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml());
                 $comment['reply'][$key]['badges'] = Helper_Author::userBadges(Model_Users::getUser($comment['reply'][$key]['owner_id']));
                 $comment['reply'][$key]['datetime'] = WM_Date::format($reply['datetime'], 'dd M yy', true);
                 $comment['reply'][$key]['is_buy'] = $bayers && in_array($reply['user_id'], $bayers);
                 $comment['reply'][$key]['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'reply'][$key]['username']));
                 $comment['reply'][$key]['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['reply'][$key]['id']);
             }
             $this->view->comments[] = $comment;
         }
     }
     $this->view->add_comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=add_comment&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $this->getLayout()->meta_title = $item['name'];
     $this->getLayout()->meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255);
     $this->view->item = $item;
     $this->view->user = $user;
     $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';
 }
Exemplo n.º 3
0
 public function searchAction()
 {
     $request = $this->getRequest();
     $keyword = $request->getRequest('keyword_comment');
     $keyword = trim(mb_strtolower(urldecode($keyword), 'UTF-8'));
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Forum'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum')), array('name' => $this->translate('Search')));
     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->error = JO_Session::get('msg_error');
         $this->view->data = JO_Session::get('data');
         JO_Session::clear('msg_error');
         JO_Session::clear('data');
     }
     $this->view->mainCategories = array();
     $this->view->mainCategories = Model_Forum::getAll();
     foreach ($this->view->mainCategories as $k => $v) {
         $this->view->mainCategories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $this->view->mainCategories[$k]['id'] . '/' . WM_Router::clearName($this->view->mainCategories[$k]['name']));
     }
     $this->view->mainCategories = array_merge(array(0 => array('name' => $this->translate('All Topics'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))), $this->view->mainCategories);
     $this->view->headline = $this->translate('All Topics');
     $this->view->sel_thread = -1;
     $this->view->headline = $this->translate('Search') . ': ' . $keyword;
     $threads = Model_Forum::getSearch($keyword);
     $total_records = count($threads);
     if ($threads) {
         $model_images = new Model_Images();
         $page = (int) $request->getRequest('page', 1);
         if ($page < 1) {
             $page = 1;
         }
         $limit = JO_Registry::get('front_limit');
         $total_records = count($threads);
         $start = $page * $limit - $limit;
         if ($start > $total_records) {
             $page = max(ceil($total_records / $limit), 1);
             $start = $page * $limit - $limit;
         } elseif ($start < 0) {
             $start = 0;
         }
         $threads = array_slice($threads, $start, $limit);
         $this->view->smiles = Model_Smiles::getSmilesImages();
         $bbcode_parser = new WM_BBCode_Parser();
         $bbcode_parser->loadDefaultCodes();
         foreach ($threads as $th) {
             if ($th['avatar']) {
                 $th['avatar'] = $model_images->resize($th['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
             } else {
                 $th['avatar'] = 'data/themes/images/noavatar.png';
             }
             $th['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username']));
             $th_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $th['id'] . '/' . WM_Router::clearName($th['name']));
             $th['threadhref'] = $thread_link;
             $th['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=report/' . $th['id']);
             $th['recent_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=recents_for_user&username='******'username']));
             $th['threads_user_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=threads_for_user&username='******'username']));
             $bbcode_parser->parse($th['comment']);
             $th['comment_formated'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml());
             $last_page = ceil($thread['cnt'] / $limit);
             $th['datetime'] = WM_Date::format($th['datetime'], 'dd M yy H:i');
             $th['badges'] = Helper_Author::userBadges($th['badges']);
             $this->view->threads[] = $th;
         }
         $pagination = new Model_Pagination();
         $pagination->setLimit($limit);
         $pagination->setPage($page);
         $pagination->setText(array('text_prev' => $this->view->translate('Prev'), 'text_next' => $this->view->translate('Next')));
         $pagination->setTotal($total_records);
         $pagination->setUrl(WM_Router::create($request->getBaseUrl() . '?controller=forum&action=index&page={page}'));
         $this->view->pagination = $pagination->render();
         if (!empty($this->view->pagination)) {
             $this->view->pagination = str_replace('{of}', $this->view->translate('OF'), $this->view->pagination);
         }
         $this->view->add_comment_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=add_new_comment');
     }
     $this->view->children = array();
     $this->view->children['rightside'] = 'forum/rightside';
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Exemplo n.º 4
0
 public static function replaceEmoticons($comment)
 {
     static $orig, $repl;
     if (!isset($orig)) {
         $orig = $repl = array();
         $db = JO_Db::getDefaultAdapter();
         $tables = $db->listTables();
         if (!in_array('smiles', $tables)) {
             return $comment;
         }
         $all_list = Model_Smiles::getSmiles();
         $smilies = array();
         if ($all_list) {
             $smilies = $all_list;
         }
         if (count($smilies)) {
             usort($smilies, array('Model_Comments', '_smiley_sort'));
         }
         for ($i = 0; $i < count($smilies); $i++) {
             if (trim($smilies[$i]['code']) && file_exists(BASE_PATH . '/uploads/' . $smilies[$i]['photo']) && is_file(BASE_PATH . '/uploads/' . $smilies[$i]['photo'])) {
                 $codes = explode(',', $smilies[$i]['code']);
                 foreach ($codes as $code) {
                     $code = trim($code);
                     if ($code) {
                         $orig[] = "/(?<=.\\W|\\W.|^\\W)" . self::_preg_quote($code, "/") . "(?=.\\W|\\W.|\\W\$)/";
                         $repl[] = '<img src="uploads/' . $smilies[$i]['photo'] . '" alt="' . $smilies[$i]['name'] . '" border="0" />';
                     }
                 }
             }
         }
     }
     if (count($orig)) {
         $comment = preg_replace($orig, $repl, ' ' . $comment . ' ');
         $comment = substr($comment, 1, -1);
     }
     return $comment;
 }