Exemplo n.º 1
0
 public function editAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         JO_Session::set('msg_error', $this->translate('You must be logged to access that page'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     $itemID = $request->getRequest('edit');
     $item = Model_Items::get($itemID);
     if (JO_Session::get('user_id') != $item['user_id']) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&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_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->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('Edit')));
     $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $categories = Model_Categories::getMain();
     if ($categories) {
         foreach ($categories as $category) {
             $this->view->categories[] = array('id' => $category['id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $category['id']), 'name' => $category['name']);
         }
     }
     $this->view->mainCategories = $categories;
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     } elseif (JO_Session::get('msg_error')) {
         $this->view->error = JO_Session::get('msg_error');
         $data = JO_Session::get('data');
         JO_Session::clear('msg_error');
         JO_Session::clear('data');
     }
     $this->view->sel_category = isset($data) ? $data['category_id'] : reset($item['categories'][0]);
     $allCategories = Model_Categories::getWithChilds();
     $this->view->categoriesSelect = array();
     $categoriesSelect = Model_Categories::generateSelect($allCategories, $this->view->sel_category, $this->view->sel_category);
     if ($categoriesSelect) {
         $categories = explode('|', $categoriesSelect);
         foreach ($categories as $category) {
             if (!empty($category)) {
                 $c = explode('>', $category);
                 $this->view->categoriesSelect[] = array('id' => $c[0], 'name' => $c[1]);
             }
         }
     }
     $this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $this->view->sel_category . ",%'");
     $this->view->total_sales_cnt = JO_Session::get('sales');
     $this->view->total_balance = WM_Currency::format(JO_Session::get('total'));
     $user = array('user_id' => JO_Session::get('user_id'), 'sold' => JO_Session::get('sold'));
     $this->view->percent = Model_Percentes::getPercentRow($user);
     if (isset($data)) {
         $item['name'] = $data['name'];
         $item['description'] = $data['description'];
         $item['theme_preview'] = $data['theme_preview'];
         $item['theme_preview_zip'] = $data['theme_preview_zip'];
         $item['main_file'] = $data['main_file'];
         $item['reviewer_comment'] = $data['reviewer_comment'];
         $item['attributes'] = $data['attributes'];
         isset($data['source_license']) && ($item['source_license'] = $data['source_license']);
         isset($data['free_request']) && ($item['free_file'] = true);
     }
     $item['suggested_price'] = isset($data['suggested_price']) ? $data['suggested_price'] : $item['price'];
     $item['selected_categories'] = isset($data['category']) ? $data['category'] : JO_Array::multi_array_to_single_uniq($item['categories']);
     $item['selected_attributes'] = isset($data['attributes']) ? JO_Array::multi_array_to_single_uniq($data['attributes']) : JO_Array::multi_array_to_single_uniq($item['attributes']);
     $item['selected_tags'] = isset($data['tags']) ? $data['tags'] : implode(', ', JO_Array::multi_array_to_single_uniq($item['tags']));
     $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item'));
     if ($help) {
         $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id']));
     }
     $this->view->uploaded_files = JO_Session::get('uploaded_files');
     $this->view->uploaded_arhives = JO_Session::get('uploaded_arhives');
     $this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=upload&action=doupload');
     $this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=doedit');
     $this->view->d = $item;
     $this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Exemplo n.º 2
0
 public function get_categoriesAction()
 {
     $this->noLayout(true);
     $request = $this->getRequest();
     $category_id = $request->getRequest('get_categories');
     $result = '';
     if ($category_id) {
         $allCategories = Model_Categories::getWithChilds();
         $categoriesSelect = Model_Categories::generateSelect($allCategories, $category_id, $category_id);
         if ($categoriesSelect) {
             $categories = explode('|', $categoriesSelect);
             foreach ($categories as $category) {
                 $c = explode('>', $category);
                 if (!empty($c[0])) {
                     $result .= '<p><input type="checkbox" name="category[' . $c[0] . ']" id="custom_categories_' . $c[0] . '" /><label for="custom_categories_' . $c[0] . '">' . $c[1] . '</label></p>';
                 }
             }
         }
         die($result);
     }
 }